????

Your IP : 3.16.10.2


Current Path : /home/webcloude/public_html/wp-content/plugins/astra-sites/inc/lib/gutenberg-templates/dist/
Upload File :
Current File : //home/webcloude/public_html/wp-content/plugins/astra-sites/inc/lib/gutenberg-templates/dist/138.js

"use strict";(globalThis.webpackChunkast_block_templates=globalThis.webpackChunkast_block_templates||[]).push([[138],{3138:(e,t,o)=>{o.r(t),o.d(t,{default:()=>$});var a=o(3771),s=o(8242),r=o(1594),n=o(6134),l=o(3914),c=o(6597),i=o(7642),p=o(9583),m=o(6041),u=o(9431),d=o(2513),g=o(9392),b=o(8354),f=o(4403),y=o(5446),h=o(4715),k=o(8330),v=o(1760);const{post:I}=wp.ajax,{parse:w}=wp.blocks,{bypassAuth:_}=ast_block_template_vars,P=(0,a.A)((0,s.A)((e=>{const{getImportItemInfo:t,getCurrentScreen:o,getSitePreview:a,getActiveBlockPaletteSlug:s,getActivePagePaletteSlug:r,getDisableAi:n,getAdaptiveMode:l}=e("astra-sites");return{importItemInfo:t(),sitePreview:a(),currentScreen:o(),activeBlockPaletteSlug:s(),activePagePaletteSlug:r(),disableAI:n(),adaptiveMode:l()}})),(0,i.A)((e=>{const{setImportItemInfo:t,setTogglePopup:o,setOnboardingAiPopup:a}=e("astra-sites"),{insertBlocks:s}=wp.data.dispatch("core/block-editor");return{setImportItemInfo:t,onSetTogglePopup:o,insertBlocks:s,setOnboardingAiPopup:a}})))((0,r.memo)((({onImportFail:e,setImportItemInfo:t,requiredPlugins:o,importItemInfo:a,title:s,btnClass:i,insertBlocks:P,onSetTogglePopup:A,item:E,onClick:S,onBlockImport:x,activeBlockPaletteSlug:R,activePagePaletteSlug:N,currentScreen:C,disableAI:T,importing:$=!1,adaptiveMode:B,showIcon:O=!0})=>{let[j]=(0,r.useState)(a),F=o||[];const W=i||"",[D]=(0,r.useState)(s||"Import"),{index:L}=wp.data.select("core/block-editor").getBlockInsertionPoint(),{importInProgress:q,syncLibNotice:M,stepData:{token:z}}=(0,l.A)((e=>{const{getImportInProgress:t,getNotice:o,getAIStepData:a}=e(k.U);return{importInProgress:t(),syncLibNotice:o(),stepData:a()}}),[]),{setImportInProgress:H,toggleConnectZipAI:U,setNotice:Q}=(0,c.A)(k.U),V="info"===M?.type,X=(0,n.Fx)(),Z=(e,t,o)=>{(0,y.oR)((0,h.A)({title:e,message:t}),h.A.getOptions({type:o}))},G=async()=>{try{Q({type:"import-info",message:(0,v.__)("Activating Spectra plugin…","astra-sites")}),await(0,u.s)({slug:"ultimate-addons-for-gutenberg",init:"ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php",name:"Spectra"})}catch(e){H(!1),Z("Import failed!","Spectra activation failed!","error")}},J=async()=>{try{Q({type:"import-info",message:(0,v.__)("Activating WPForms plugin…","astra-sites")}),await(0,u.s)({slug:"wpforms-lite",init:"wpforms-lite/wpforms.php",name:"WPForms Lite"}),await te()}catch(e){H(!1),Z("Import failed!","WPForms activation failed!","error")}},K=()=>{const t=j.original_content,o="all-blocks-grid"===C?"block":"page",a="block"===o?j["blocks-category"][0]:j["pages-category"][0];I({action:"ast_block_templates_import_block",content:t,category:a,_ajax_nonce:ast_block_template_vars._ajax_nonce,style:"all-blocks-grid"===C?R:N,disableAI:T,block_type:o,adaptiveMode:B}).done((e=>{H(!1);const t=(0,n.XD)(w(e));P(t,L,"",!1),Y(t[0].clientId),A(),document.getElementById("ast-block-templates-modal-wrap").classList.remove("open"),document.body.classList.remove("ast-block-templates-modal-open"),(X.inactive||X.notInstalled)&&(0,b.mP)(),"function"==typeof x&&x(e,L)})).fail((()=>{H(!1),e(),Z("Import failed!","Failed to import the block. Please try again later or contact support for assistance.","error-import")}))},Y=e=>{e&&setTimeout((()=>{const t=ee(),o="block-"+e,a=t.getElementById(o);a&&a.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}),2500)},ee=()=>{const e=document.getElementsByClassName("is-tablet-preview"),t=document.getElementsByClassName("is-mobile-preview");if(0!==e.length||0!==t.length){const o=e[0]||t[0];let a=!1;o&&(a=o.getElementsByTagName("iframe")[0]);const s=a?.contentWindow.document||a?.contentDocument;if(s)return s}return document},te=()=>{j?.["post-meta"]?.["astra-site-wpforms-path"]||""?I({action:"ast_block_templates_import_wpforms",id:j.id,_ajax_nonce:ast_block_template_vars._ajax_nonce}).done((()=>{K()})).fail((()=>{H(!1),Z("Import failed!","WPForms import failed!","error")})):K()};return React.createElement(p.A,{className:(0,n.xW)("min-w-[4.875rem] h-7 hover:shadow-small sp-text-sm",W,(q&&!$||V)&&"opacity-50 cursor-not-allowed"),type:"button",variant:"primary",onClick:z||_?async o=>{q||V||(H(!0),"function"==typeof S&&S(o),X.notInstalled?(await(async()=>{try{Q({type:"import-info",message:(0,v.__)("Installing Spectra plugin…","astra-sites")}),await(0,u.o)({slug:"ultimate-addons-for-gutenberg",init:"ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php",name:"Spectra"})}catch(e){H(!1),Z("Import failed!","Spectra installation failed!","error")}})(),await G()):X.inactive&&await G(),(0,g.V)(E.ID,"astra-blocks").then((e=>{t(e),j=e,F=e?.["post-meta"]?.["astra-blocks-required-plugins"]?d.j.parse(e["post-meta"]["astra-blocks-required-plugins"]):[],F.length?"not-installed"===ast_block_template_vars.wpforms_status?(async()=>{try{Q({type:"import-info",message:(0,v.__)("Installing WPForms plugin…","astra-sites")}),await(0,u.o)({slug:"wpforms-lite",init:"wpforms-lite/wpforms.php",name:"WPForms Lite"}),await J()}catch(e){H(!1),Z("Import failed!","WPForms installation failed!","error")}})():"inactive"===ast_block_template_vars.wpforms_status?J():te():te()})).catch((t=>{Z("Import failed!",t,"error-import"),H(!1),e()})))}:async()=>{U(),(0,n.HU)("ast-import",{blockId:E.ID,blockType:E.type,blockPaletteSlug:R,pagePaletteSlug:N})},isSmall:!0,hasPrefixIcon:!$&&O},$?React.createElement(m.A,{className:"h-4 w-4 !shrink-0"}):React.createElement(React.Fragment,null,O&&React.createElement(f.A,{className:"h-4 w-4 !shrink-0"}),React.createElement("span",{className:"truncate"},D)))})));var A=o(9260);const E=e=>{const t=["skip","logo","fav-icon"];for(const o of t)if(e.includes(o))return!0;return!1},S={linearTween:(e,t,o,a)=>o*e/a+t,easeInQuad:(e,t,o,a)=>o*(e/=a)*e+t,easeOutQuad:(e,t,o,a)=>-o*(e/=a)*(e-2)+t,easeInOutQuad:(e,t,o,a)=>(e/=a/2)<1?o/2*e*e+t:-o/2*(--e*(e-2)-1)+t,easeInCubic:(e,t,o,a)=>o*(e/=a)*e*e+t,easeOutCubic:(e,t,o,a)=>(e/=a,o*(--e*e*e+1)+t),easeInOutCubic:(e,t,o,a)=>(e/=a/2)<1?o/2*e*e*e+t:o/2*((e-=2)*e*e+2)+t};Object.seal(S);const x=S;var R=o(7497);const{spectra_common_styles:N,is_rtl:C}=ast_block_template_vars,T="visible",$=(0,a.A)((0,s.A)((e=>{const{getDisableAi:t,getDisablePreview:o,getTogglePopup:a}=e("astra-sites");return{disableAi:t(),disablePreview:o(),togglePopup:a()}})))((0,r.memo)((({item:e,content:t,stylesheet:o,astraCustomizer:a,globalStylesheet:s,colorPalette:l,dynamicContent:c,selectedImages:i,disableAi:p,togglePopup:m,email:u,phone:d,address:g})=>{const b=(0,r.useRef)(null),f=(0,r.useRef)(null),y=e["thumbnail-image-url"]||"",h=e["featured-image-url"]||"",k=(0,n.Fx)();let v=0,I=0;const[w,_]=(0,r.useState)({importing:!1}),[S,$]=(0,r.useState)(`${ast_block_template_vars.uri}dist/placeholder_200_200.png`),[B,O]=(0,r.useState)(`${ast_block_template_vars.uri}dist/placeholder_200_200.png`);function j(){const e=b?.current,t=f?.current;if(!e||!t)return;const o=e.parentNode.offsetWidth/1200,a=o*t.offsetHeight;e.style.transform=`scale(${o})`,e.style.height=`${a}px`}(0,r.useLayoutEffect)((()=>{let e=!0;const r=i,n=new Image;n.src=y;const m=new Image;m.src=h;const b=f.current;function k(t,o){e&&(t.onload=()=>{o(t.src)})}k(n,$),k(m,O);const w=document.getElementById("astra-wp-editor-styles-inline-css")?.textContent.replace(/:root/g,".block-container").replace(/body/g,".block-container"),_=document.getElementById("astra-block-editor-styles-inline-css")?.textContent.replace(/:root/g,".block-container").replace(/body/g,".block-container");let P="";if(o&&(o=((e,t=[])=>p?e:0!==Object.keys(c).length&&c?t&&0===t.length?e:e.replace(/background-image\s*:\s*url\(['"]?([^'")]+)['"]?\)/g,(function(e,o){if(E(o))return e;if(!t[I]?.url)return"";const a=t[I]?.url;return I++,I%=t.length,'background-image: url("'+a+'")'})):e)(o,r)),P+=a?`<style type="text/css" id="gt-astra-customizer">${a}</style>`:"",P+=`<style type="text/css" id="gt-spectra-common-stylesheet">${N}</style>`,P=o?`${P} <style type="text/css" id="gt-common-stylesheet">${o}</style>`:P,s&&(P+=`<style type="text/css" id="gt-global-stylesheet"> ${s} </style>`),w&&(P+=`<style type="text/css" id="gt-wpeditor-css" > ${w} </style>`),_&&(P+=`<style type="text/css" id="gt-blockeditor-css"> ${_} </style>`),b&&t){let e=b.shadowRoot;if(null===e&&(e=b.attachShadow({mode:"open"})),null===e)return;let o=t;if(!p){const e=c??[];e&&Object.keys(e)?.length>0&&Object.keys(e).forEach((t=>{o=null!==e[t]?o.replace(t,e[t]):o})),c&&Object.keys(c).length>0&&(A=o,u&&(A=A.replace("contact@example.com",u)),d&&(A=A.replace("202-555-0188",d)),g&&(A=A.replace("2360 Hood Avenue, San Diego, CA, 92123",g)),o=A,o=W(o))}e.innerHTML=P+'<div class="st-block-container">'+o+"</div>",l.forEach(((t,o)=>{e?.host.style.setProperty(`--ast-global-color-${o}`,t)}));const a=b.shadowRoot.querySelectorAll("img");e&&(a.forEach((e=>{E(e.src)||p||0===r?.length||0===Object.keys(c).length||!c||F(e,"hidden")})),j(),((e,t)=>{p||0!==Object.keys(c).length&&c&&t?.length&&e?.forEach((function(e){E(e.src)||(e.onload=()=>{const o=e.getAttribute("src")||"";if(o.includes("unsplash")||o.includes("pexels")||o.includes("pixabay"))return void F(e,T);const a=t[v];if(void 0!==a)if(a.url.includes("unsplash")||a.url.includes("pexels")||a.url.includes("pixabay")){if(v++,void 0===t[v]&&(v=0),"PICTURE"===e.parentNode.nodeName)e.parentNode.querySelectorAll("source").forEach((e=>{e.setAttribute("srcset",a.optimized_url)})),e.parentNode.querySelector("img").setAttribute("src",a.optimized_url);else{const t=document.createElement("img");t.src=a.optimized_url,e.parentNode.replaceChild(t,e)}F(e,T)}else F(e,T);else F(e,T)},e.onerror=()=>{F(e,T)})}))})(a,r))}var A;return()=>{e=!1}}),[e,p,c,i]),(0,r.useEffect)((()=>{const e=new ResizeObserver(j);return e.observe(document.documentElement),()=>{e&&e.disconnect()}}),[]),(0,r.useEffect)((()=>{const e=document.querySelector("#ast-block-templates-modal-wrap");if(!e)return;const t=new MutationObserver(j);return t.observe(e,{childList:!0,attributes:!0,subtree:!0}),()=>{t&&t.disconnect()}}),[]),(0,r.useEffect)((()=>{const e=f?.current;if(e){const t=e.shadowRoot;l.forEach(((e,o)=>{null!==t&&t.host.style.setProperty(`--ast-global-color-${o}`,e)}))}}),[l]);const F=(e,t)=>{e&&(e.style.visibility=t)},W=(e="")=>g?e.replace(/(src="https:\/\/maps\.google\.com\/maps\?q=)([^&]+)(&z=\d+&hl=en&t=m&output=embed&iwloc=near")/g,`$1${encodeURIComponent(g)}$3`):e;let D=0,L=0;const q=(e,t,o)=>{const a=e.scrollTop,s=t-a;let r=0;const n=function(){r+=20;const t=x.linearTween(r,a,s,o);e.scrollTop=t,r<o&&(D=setTimeout(n,20))};n()};(0,r.useEffect)((()=>{m||(v=0,I=0)}),[m]);const M=C?"origin-top-right":"origin-top-left";return React.createElement(R.A,{className:(0,n.xW)("w-full h-fit",!0===w.importing?"importing":"")},React.createElement("div",{className:(0,n.xW)("cursor-pointer relative border border-solid border-border-primary hover:border-accent-spectra transition duration-150 ease-in-out overflow-hidden group",w.importing&&"border-accent-spectra")},React.createElement("div",{className:`thumbnail left-0 m-0 min-h-[auto] overflow-visible text-left top-0 ${M} relative pointer-events-none`,ref:b},React.createElement("div",{className:"absolute w-[1200px] pointer-events-none max-h-[1600px] overflow-hidden",ref:f},!t&&React.createElement("img",{srcSet:`${B}, ${S}`,src:S,alt:"Preview"}),React.createElement("div",{className:"preview"},React.createElement("span",{className:"ast-block-templates-icon ast-block-templates-icon-search"})))),React.createElement("div",{className:"absolute inset-0 grid grid-cols-1 grid-rows-1 place-items-end",onMouseEnter:()=>{if("page"!==e.type)return;const t=f.current;D&&clearTimeout(D),L=setTimeout((()=>{q(t,t.scrollHeight,4e3)}),1e3)},onMouseLeave:()=>{L&&clearTimeout(L);const e=f.current;D&&clearTimeout(D),q(e,0,1500)}},React.createElement("div",{className:(0,n.xW)("opacity-0 group-hover:opacity-100 w-full flex items-center justify-between px-3 py-2 backdrop-blur-sm bg-white/[0.85] shadow-action-buttons transition-all duration-150 ease-in-out",!0===w.importing?"opacity-100":"")},React.createElement(P,{title:k.notInstalled?"Install Spectra & Insert":k.inactive?"Activate Spectra & Insert":"Insert",showIcon:k.active,liveRequest:!0,item:e,importing:w.importing,onClick:()=>{_({...w,importing:!0})},onBlockImport:()=>{_({...w,importing:!1})},onImportFail:()=>{_({...w,importing:!1})}}),React.createElement(A.A,{item:e})))))})))}}]);