OwlCyberSecurity - MANAGER
Edit File: 870.js
"use strict";(self.webpackChunkast_block_templates=self.webpackChunkast_block_templates||[]).push([[870],{7870:function(e,t,o){o.r(t),o.d(t,{default:function(){return $}});var s=o(5711),a=o(5940),r=o(7363),n=o(8195),l=o(5302),c=o(1882),i=o(8096),p=o(5868),m=o(4142),u=o(9148),d=o(6128),g=o(1569),b=o(5622),f=o(8680),h=o(1277),y=o(7712),v=o(3698);const{post:k}=wp.ajax,{parse:I}=wp.blocks,{bypassAuth:w}=ast_block_template_vars;var _=(0,s.Z)((0,a.Z)((e=>{const{getImportItemInfo:t,getCurrentScreen:o,getSitePreview:s,getActiveBlockPaletteSlug:a,getActivePagePaletteSlug:r,getDisableAi:n,getAdaptiveMode:l}=e("ast-block-templates");return{importItemInfo:t(),sitePreview:s(),currentScreen:o(),activeBlockPaletteSlug:a(),activePagePaletteSlug:r(),disableAI:n(),adaptiveMode:l()}})),(0,i.Z)((e=>{const{setImportItemInfo:t,setTogglePopup:o,setOnboardingAiPopup:s}=e("ast-block-templates"),{insertBlocks:a}=wp.data.dispatch("core/block-editor");return{setImportItemInfo:t,onSetTogglePopup:o,insertBlocks:a,setOnboardingAiPopup:s}})))((0,r.memo)((e=>{let{setImportItemInfo:t,requiredPlugins:o,importItemInfo:s,title:a,btnClass:i,insertBlocks:_,onSetTogglePopup:P,item:E,onClick:S,onBlockImport:x,activeBlockPaletteSlug:A,activePagePaletteSlug:R,currentScreen:N,disableAI:C,importing:$=!1,adaptiveMode:T,showIcon:j=!0}=e,[B]=(0,r.useState)(s),O=o||[];const Z=i||"",[L]=(0,r.useState)(a||"Import"),{index:D}=wp.data.select("core/block-editor").getBlockInsertionPoint(),{importInProgress:q,syncLibNotice:M,stepData:{token:z}}=(0,l.Z)((e=>{const{getImportInProgress:t,getNotice:o,getAIStepData:s}=e(v.L);return{importInProgress:t(),syncLibNotice:o(),stepData:s()}}),[]),{setImportInProgress:F,toggleConnectZipAI:W}=(0,c.Z)(v.L),H="info"===M?.type,K=(0,n.gt)(),Q=(e,t,o)=>{(0,h.Am)((0,y.Z)({title:e,message:t}),y.Z.getOptions({type:o}))},U=async()=>{try{await(0,u.j)({slug:"ultimate-addons-for-gutenberg",init:"ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php",name:"Spectra"})}catch(e){F(!1),Q("Import failed!","Spectra activation failed!","error")}},V=()=>{(0,u.j)({slug:"wpforms-lite",init:"wpforms-lite/wpforms.php",name:"WPForms Lite"}).then((()=>{Y()})).catch((()=>{F(!1),Q("Import failed!","WPForms activation failed!","error")}))},G=()=>{const e=B.original_content,t="all-blocks-grid"===N?"block":"page",o="block"===t?B["blocks-category"][0]:B["pages-category"][0];k({action:"ast_block_templates_import_block",content:e,category:o,_ajax_nonce:ast_block_template_vars._ajax_nonce,style:"all-blocks-grid"===N?A:R,disableAI:C,block_type:t,adaptiveMode:T}).done((e=>{F(!1);const t=(0,n.CN)(I(e));_(t,D,"",!1),J(t[0].clientId),P(),document.getElementById("ast-block-templates-modal-wrap").classList.remove("open"),document.body.classList.remove("ast-block-templates-modal-open"),(K.inactive||K.notInstalled)&&(0,b.iP)(),"function"==typeof x&&x(e,D)})).fail((()=>{F(!1),Q("Import failed!","Failed to import the block. Please try again later or contact support for assistance.","error")}))},J=e=>{e&&setTimeout((()=>{const t=X(),o="block-"+e,s=t.getElementById(o);s&&s.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}),2500)},X=()=>{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 s=!1;o&&(s=o.getElementsByTagName("iframe")[0]);const a=s?.contentWindow.document||s?.contentDocument;if(a)return a}return document},Y=()=>{B?.["post-meta"]?.["astra-site-wpforms-path"]||""?k({action:"ast_block_templates_import_wpforms",id:B.id,_ajax_nonce:ast_block_template_vars._ajax_nonce}).done((()=>{G()})).fail((()=>{F(!1),Q("Import failed!","WPForms import failed!","error")})):G()};return React.createElement(p.Z,{className:(0,n.AK)("min-w-[4.875rem] h-7 hover:shadow-small sp-text-sm",Z,(q&&!$||H)&&"opacity-50 cursor-not-allowed"),type:"button",variant:"primary",onClick:z||w?async e=>{q||H||(F(!0),"function"==typeof S&&S(e),K.notInstalled?await(async()=>{try{await(0,u.H)({slug:"ultimate-addons-for-gutenberg",init:"ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php",name:"Spectra"}),await U()}catch(e){F(!1),Q("Import failed!","Spectra installation failed!","error")}})():K.inactive&&await U(),(0,g.I)(E.ID,"astra-blocks").then((e=>{t(e),B=e,O=e?.["post-meta"]?.["astra-blocks-required-plugins"]?d.t.parse(e["post-meta"]["astra-blocks-required-plugins"]):[],O.length?"not-installed"===ast_block_template_vars.wpforms_status?(0,u.H)({slug:"wpforms-lite",init:"wpforms-lite/wpforms.php",name:"WPForms Lite"}).then((()=>{V()})).catch((()=>{F(!1),Q("Import failed!","WPForms installation failed!","error")})):"inactive"===ast_block_template_vars.wpforms_status?V():Y():Y()})).catch((e=>{Q("Import failed!",e,"error"),F(!0)})))}:async()=>{W(),(0,n.jw)("ast-import",{blockId:E.ID,blockType:E.type,blockPaletteSlug:A,pagePaletteSlug:R})},isSmall:!0,hasPrefixIcon:!$&&j},$?React.createElement(m.Z,{className:"h-4 w-4 !shrink-0"}):React.createElement(React.Fragment,null,j&&React.createElement(f.Z,{className:"h-4 w-4 !shrink-0"}),React.createElement("span",{className:"truncate"},L)))}))),P=o(168);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,s){return o*e/s+t},easeInQuad(e,t,o,s){return o*(e/=s)*e+t},easeOutQuad(e,t,o,s){return-o*(e/=s)*(e-2)+t},easeInOutQuad(e,t,o,s){return(e/=s/2)<1?o/2*e*e+t:-o/2*(--e*(e-2)-1)+t},easeInCubic(e,t,o,s){return o*(e/=s)*e*e+t},easeOutCubic(e,t,o,s){return e/=s,o*(--e*e*e+1)+t},easeInOutCubic(e,t,o,s){return(e/=s/2)<1?o/2*e*e*e+t:o/2*((e-=2)*e*e+2)+t}};Object.seal(S);var x=S,A=o(3433);const{spectra_common_styles:R,is_rtl:N}=ast_block_template_vars,C="visible";var $=(0,s.Z)((0,a.Z)((e=>{const{getDisableAi:t,getDisablePreview:o,getTogglePopup:s}=e("ast-block-templates");return{disableAi:t(),disablePreview:o(),togglePopup:s()}})))((0,r.memo)((e=>{let{item:t,content:o,stylesheet:s,astraCustomizer:a,globalStylesheet:l,colorPalette:c,dynamicContent:i,selectedImages:p,disableAi:m,togglePopup:u,email:d,phone:g,address:b}=e;const f=(0,r.useRef)(null),h=(0,r.useRef)(null),y=t["thumbnail-image-url"]||"",v=t["featured-image-url"]||"",k=(0,n.gt)();let I=0,w=0;const[S,$]=(0,r.useState)({importing:!1}),[T,j]=(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 Z(){const e=f?.current,t=h?.current;if(!e||!t)return;const o=e.parentNode.offsetWidth/1200,s=o*t.offsetHeight;e.style.transform=`scale(${o})`,e.style.height=`${s}px`}(0,r.useLayoutEffect)((()=>{let e=!0;const t=p,r=new Image;r.src=y;const n=new Image;n.src=v;const u=h.current;function f(t,o){e&&(t.onload=()=>{o(t.src)})}f(r,j),f(n,O);const k=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="";var S,x,A;if(s&&(S=s,x=t,s=m?S:0!==Object.keys(i).length&&i?x&&0===x.length?S:S.replace(/background-image\s*:\s*url\(['"]?([^'")]+)['"]?\)/g,(function(e,t){if(E(t))return e;if(!x[w]?.url)return"";const o=x[w]?.url;return w++,w%=x.length,'background-image: url("'+o+'")'})):S),P+=a?`<style type="text/css" id="gt-astra-customizer">${a}</style>`:"",P+=`<style type="text/css" id="gt-spectra-common-stylesheet">${R}</style>`,P=s?`${P} <style type="text/css" id="gt-common-stylesheet">${s}</style>`:P,l&&(P+=`<style type="text/css" id="gt-global-stylesheet"> ${l} </style>`),k&&(P+=`<style type="text/css" id="gt-wpeditor-css" > ${k} </style>`),_&&(P+=`<style type="text/css" id="gt-blockeditor-css"> ${_} </style>`),u&&o){let e=u.shadowRoot;if(null===e&&(e=u.attachShadow({mode:"open"})),null===e)return;let s=o;if(!m){const e=i??[];e&&Object.keys(e)?.length>0&&Object.keys(e).forEach((t=>{s=null!==e[t]?s.replace(t,e[t]):s})),i&&Object.keys(i).length>0&&(A=s,d&&(A=A.replace("contact@example.com",d)),g&&(A=A.replace("202-555-0188",g)),b&&(A=A.replace("2360 Hood Avenue, San Diego, CA, 92123",b)),s=A,s=D(s))}e.innerHTML=P+'<div class="st-block-container">'+s+"</div>",c.forEach(((t,o)=>{e?.host.style.setProperty(`--ast-global-color-${o}`,t)}));const a=u.shadowRoot.querySelectorAll("img");e&&(a.forEach((e=>{E(e.src)||m||0===t?.length||0===Object.keys(i).length||!i||L(e,"hidden")})),Z(),((e,t)=>{m||0!==Object.keys(i).length&&i&&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 L(e,C);const s=t[I];if(void 0!==s)if(s.url.includes("unsplash")||s.url.includes("pexels")||s.url.includes("pixabay")){if(I++,void 0===t[I]&&(I=0),"PICTURE"===e.parentNode.nodeName)e.parentNode.querySelectorAll("source").forEach((e=>{e.setAttribute("srcset",s.optimized_url)})),e.parentNode.querySelector("img").setAttribute("src",s.optimized_url);else{const t=document.createElement("img");t.src=s.optimized_url,e.parentNode.replaceChild(t,e)}L(e,C)}else L(e,C);else L(e,C)},e.onerror=()=>{L(e,C)})}))})(a,t))}return()=>{e=!1}}),[t,m,i,p]),(0,r.useEffect)((()=>{const e=new ResizeObserver(Z);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(Z);return t.observe(e,{childList:!0,attributes:!0,subtree:!0}),()=>{t&&t.disconnect()}}),[]),(0,r.useEffect)((()=>{const e=h?.current;if(e){const t=e.shadowRoot;c.forEach(((e,o)=>{null!==t&&t.host.style.setProperty(`--ast-global-color-${o}`,e)}))}}),[c]);const L=(e,t)=>{e&&(e.style.visibility=t)},D=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return b?e.replace(/(src="https:\/\/maps\.google\.com\/maps\?q=)([^&]+)(&z=\d+&hl=en&t=m&output=embed&iwloc=near")/g,`$1${encodeURIComponent(b)}$3`):e};let q=0,M=0;const z=(e,t,o)=>{const s=e.scrollTop,a=t-s;let r=0;const n=function(){r+=20;const t=x.linearTween(r,s,a,o);e.scrollTop=t,r<o&&(q=setTimeout(n,20))};n()};(0,r.useEffect)((()=>{u||(I=0,w=0)}),[u]);const F=N?"origin-top-right":"origin-top-left";return React.createElement(A.Z,{className:(0,n.AK)("w-full h-fit",!0===S.importing?"importing":"")},React.createElement("div",{className:(0,n.AK)("cursor-pointer relative border border-solid border-border-primary hover:border-accent-spectra transition duration-150 ease-in-out overflow-hidden group",S.importing&&"border-accent-spectra")},React.createElement("div",{className:`thumbnail left-0 m-0 min-h-[auto] overflow-visible text-left top-0 ${F} relative pointer-events-none`,ref:f},React.createElement("div",{className:"absolute w-[1200px] pointer-events-none max-h-[1600px] overflow-hidden",ref:h},!o&&React.createElement("img",{srcSet:`${B}, ${T}`,src:T,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"!==t.type)return;const e=h.current;q&&clearTimeout(q),M=setTimeout((()=>{z(e,e.scrollHeight,4e3)}),1e3)},onMouseLeave:()=>{M&&clearTimeout(M);const e=h.current;q&&clearTimeout(q),z(e,0,1500)}},React.createElement("div",{className:(0,n.AK)("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===S.importing?"opacity-100":"")},React.createElement(_,{title:k.notInstalled?"Install Spectra & Insert":k.inactive?"Activate Spectra & Insert":"Insert",showIcon:k.active,liveRequest:!0,item:t,importing:S.importing,onClick:()=>{$({...S,importing:!0})},onBlockImport:()=>{$({...S,importing:!1})}}),React.createElement(P.Z,{item:t})))))})))}}]);