laipower/wp-content/plugins/menu-icons/vendor/codeinwp/themeisle-sdk/assets/js/build/promos/index.js

1 line
15 KiB
JavaScript

(()=>{"use strict";var e,t={165:()=>{const e=window.wp.element,t=window.wp.blockEditor,o=window.wp.components,n=window.wp.compose,i=window.wp.data,s=window.wp.hooks,r=()=>{const{createNotice:t}=(0,i.dispatch)("core/notices"),[o,n]=(0,e.useState)({}),[s,r]=(0,e.useState)("loading");return(0,i.useSelect)((e=>{if(Object.keys(o).length)return;const{getEntityRecord:t}=e("core"),i=t("root","site");i&&(r("loaded"),n(i))}),[]),[e=>null==o?void 0:o[e],async function(e,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Settings saved.";const s={[e]:o};try{const e=await fetch("/wp-json/wp/v2/settings",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},body:JSON.stringify(s)});e.ok||(r("error"),t("error","Could not save the settings.",{isDismissible:!0,type:"snackbar"}));const o=await e.json();r("loaded"),t("success",i,{isDismissible:!0,type:"snackbar"}),n(o)}catch(e){console.error("Error updating option:",e)}},s]},l=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((o=>{wp.updates.ajax(!0===t?"install-theme":"install-plugin",{slug:e,success:()=>{o({success:!0})},error:e=>{o({success:!1,code:e.errorCode})}})}))},a=e=>new Promise((t=>{jQuery.get(e).done((()=>{t({success:!0})})).fail((()=>{t({success:!1})}))})),m=(e,t)=>{const o={};return Object.keys(t).forEach((function(e){"innerBlocks"!==e&&(o[e]=t[e])})),e.push(o),Array.isArray(t.innerBlocks)?(o.innerBlocks=t.innerBlocks.map((e=>e.id)),t.innerBlocks.reduce(m,e)):e},c={button:{display:"flex",justifyContent:"center",width:"100%"},image:{padding:"20px 0"},skip:{container:{display:"flex",flexDirection:"column",alignItems:"center"},button:{fontSize:"9px"},poweredby:{fontSize:"9px",textTransform:"uppercase"}}},d={"blocks-css":{title:"Custom CSS",description:"Enable Otter Blocks to add Custom CSS for this block.",image:"css.jpg"},"blocks-animation":{title:"Animations",description:"Enable Otter Blocks to add Animations for this block.",image:"animation.jpg"},"blocks-conditions":{title:"Visibility Conditions",description:"Enable Otter Blocks to add Visibility Conditions for this block.",image:"conditions.jpg"}},p=t=>{let{onClick:n}=t;return(0,e.createElement)("div",{style:c.skip.container},(0,e.createElement)(o.Button,{style:c.skip.button,variant:"tertiary",onClick:n},"Skip for now"),(0,e.createElement)("span",{style:c.skip.poweredby},"Recommended by ",window.themeisleSDKPromotions.product))},u=(0,n.createHigherOrderComponent)((n=>i=>{if(i.isSelected&&Boolean(window.themeisleSDKPromotions.showPromotion)){const[s,m]=(0,e.useState)(!1),[u,h]=(0,e.useState)("default"),[w,g]=(0,e.useState)(!1),[E,k,y]=r(),f=async()=>{m(!0),await l("otter-blocks"),k("themeisle_sdk_promotions_otter_installed",!Boolean(E("themeisle_sdk_promotions_otter_installed"))),await a(window.themeisleSDKPromotions.otterActivationUrl),m(!1),h("installed")},P=()=>"installed"===u?(0,e.createElement)("p",null,(0,e.createElement)("strong",null,"Awesome! Refresh the page to see Otter Blocks in action.")):(0,e.createElement)(o.Button,{variant:"secondary",onClick:f,isBusy:s,style:c.button},"Install & Activate Otter Blocks"),S=()=>{const e={...window.themeisleSDKPromotions.option};e[window.themeisleSDKPromotions.showPromotion]=(new Date).getTime()/1e3|0,k("themeisle_sdk_promotions",JSON.stringify(e)),window.themeisleSDKPromotions.showPromotion=!1};return(0,e.useEffect)((()=>{w&&S()}),[w]),w?(0,e.createElement)(n,i):(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,i),(0,e.createElement)(t.InspectorControls,null,Object.keys(d).map((t=>{if(t===window.themeisleSDKPromotions.showPromotion){const n=d[t];return(0,e.createElement)(o.PanelBody,{key:t,title:n.title,initialOpen:!1},(0,e.createElement)("p",null,n.description),(0,e.createElement)(P,null),(0,e.createElement)("img",{style:c.image,src:window.themeisleSDKPromotions.assets+n.image}),(0,e.createElement)(p,{onClick:()=>g(!0)}))}}))))}return(0,e.createElement)(n,i)}),"withInspectorControl");(0,i.select)("core/edit-site")||(0,s.addFilter)("editor.BlockEdit","themeisle-sdk/with-inspector-controls",u);const h=window.wp.plugins,w=window.wp.editPost;function g(t){let{stacked:n=!1,noImage:i=!1,type:s,onDismiss:m,onSuccess:c,initialStatus:d=null}=t;const{assets:p,title:u,email:h,option:w,optionKey:g,labels:E,optimoleActivationUrl:k,optimoleApi:y,optimoleDash:f,nonce:P}=window.themeisleSDKPromotions,[S,v]=(0,e.useState)(!1),[b,D]=(0,e.useState)(h||""),[B,_]=(0,e.useState)(!1),[N,K]=(0,e.useState)(d),[C,O]=r(),A=async()=>{_(!0);const e={...w};e[s]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await O(g,JSON.stringify(e)),m&&m()},x=()=>{v(!S)},j=e=>{D(e.target.value)},I=async e=>{e.preventDefault(),K("installing"),await l("optimole-wp"),K("activating"),await a(k),O("themeisle_sdk_promotions_optimole_installed",!Boolean(C("themeisle_sdk_promotions_optimole_installed"))),K("connecting");try{await fetch(y,{method:"POST",headers:{"X-WP-Nonce":P,"Content-Type":"application/json"},body:JSON.stringify({email:b})}),c&&c(),K("done")}catch(e){K("done")}};if(B)return null;const R=()=>"done"===N?(0,e.createElement)("div",{className:"done"},(0,e.createElement)("p",null," ",E.optimole.all_set),(0,e.createElement)(o.Button,{icon:"external",isPrimary:!0,href:f,target:"_blank"},E.optimole.gotodash)):N?(0,e.createElement)("p",{className:"om-progress"},(0,e.createElement)("span",{className:"dashicons dashicons-update spin"}),(0,e.createElement)("span",null,"installing"===N&&E.optimole.installing,"activating"===N&&E.optimole.activating,"connecting"===N&&E.optimole.connecting,"…")):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",null,"Enter your email address to create & connect your account"),(0,e.createElement)("form",{onSubmit:I},(0,e.createElement)("input",{defaultValue:b,type:"email",onChange:j,placeholder:E.optimole.email_placeholder}),(0,e.createElement)(o.Button,{isPrimary:!0,type:"submit"},E.optimole.start_cta))),T=()=>(0,e.createElement)(o.Button,{disabled:N&&"done"!==N,onClick:A,isLink:!0,className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},E.optimole.dismisscta));return n?(0,e.createElement)("div",{className:"ti-om-stack-wrap"},(0,e.createElement)("div",{className:"om-stack-notice"},T(),(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("h2",null,E.optimole.heading),(0,e.createElement)("p",null,"om-editor"===s||"om-image-block"===s?E.optimole.message1:E.optimole.message2),!S&&"done"!==N&&(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x,className:"cta"},E.optimole.gst),(S||"done"===N)&&R(),(0,e.createElement)("i",null,u))):(0,e.createElement)(e.Fragment,null,T(),(0,e.createElement)("div",{className:"content"},!i&&(0,e.createElement)("img",{src:p+"/optimole-logo.svg",alt:"Optimole logo"}),(0,e.createElement)("div",null,(0,e.createElement)("p",null,u),(0,e.createElement)("p",{className:"description"},"om-media"===s?E.optimole.message3:E.optimole.message4),!S&&(0,e.createElement)("div",{className:"actions"},(0,e.createElement)(o.Button,{isPrimary:!0,onClick:x},E.optimole.gst),(0,e.createElement)(o.Button,{isLink:!0,target:"_blank",href:"https://wordpress.org/plugins/optimole-wp"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null," ",E.optimole.learnmore))),S&&(0,e.createElement)("div",{className:"form-wrap"},R()))))}const E=()=>{const[t,o]=(0,e.useState)(!0),{getBlocks:n}=(0,i.useSelect)((e=>{const{getBlocks:t}=e("core/block-editor");return{getBlocks:t}}));var s;if((s=n(),"core/image",s.reduce(m,[]).filter((e=>"core/image"===e.name))).length<2)return null;const r="ti-sdk-optimole-post-publish "+(t?"":"hidden");return(0,e.createElement)(w.PluginPostPublishPanel,{className:r},(0,e.createElement)(g,{stacked:!0,type:"om-editor",onDismiss:()=>{o(!1)}}))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(this.debug)this.runAll();else switch(this.promo){case"om-attachment":this.runAttachmentPromo();break;case"om-media":this.runMediaPromo();break;case"om-editor":this.runEditorPromo();break;case"om-image-block":this.runImageBlockPromo();break;case"om-elementor":this.runElementorPromo()}}runAttachmentPromo(){wp.media.view.Attachment.Details.prototype.on("ready",(()=>{setTimeout((()=>{this.removeAttachmentPromo(),this.addAttachmentPromo()}),100)})),wp.media.view.Modal.prototype.on("close",(()=>{setTimeout(this.removeAttachmentPromo,100)}))}runMediaPromo(){if(window.themeisleSDKPromotions.option["om-media"])return;const t=document.querySelector("#ti-optml-notice");t&&(0,e.render)((0,e.createElement)(g,{type:"om-media",onDismiss:()=>{t.style.opacity=0}}),t)}runImageBlockPromo(){if(window.themeisleSDKPromotions.option["om-image-block"])return;let o=!0,i=null;const r=(0,n.createHigherOrderComponent)((n=>s=>"core/image"===s.name&&o?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,s),(0,e.createElement)(t.InspectorControls,null,(0,e.createElement)(g,{stacked:!0,type:"om-image-block",initialStatus:i,onDismiss:()=>{o=!1},onSuccess:()=>{i="done"}}))):(0,e.createElement)(n,s)),"withImagePromo");(0,s.addFilter)("editor.BlockEdit","optimole-promo/image-promo",r,99)}runEditorPromo(){window.themeisleSDKPromotions.option["om-editor"]||(0,h.registerPlugin)("optimole-promo",{render:E})}runElementorPromo(){if(!window.elementor)return;const t=this;elementor.on("preview:loaded",(()=>{elementor.panel.currentView.on("set:page:editor",(o=>{t.domRef&&(0,e.unmountComponentAtNode)(t.domRef),o.activeSection&&"section_image"===o.activeSection&&t.runElementorActions(t)}))}))}addAttachmentPromo(){if(this.domRef&&(0,e.unmountComponentAtNode)(this.domRef),window.themeisleSDKPromotions.option["om-attachment"])return;const t=document.querySelector("#ti-optml-notice-helper");t&&(this.domRef=t,(0,e.render)((0,e.createElement)("div",{className:"notice notice-info ti-sdk-om-notice",style:{margin:0}},(0,e.createElement)(g,{noImage:!0,type:"om-attachment",onDismiss:()=>{t.style.opacity=0}})),t))}removeAttachmentPromo(){const t=document.querySelector("#ti-optml-notice-helper");t&&(0,e.unmountComponentAtNode)(t)}runElementorActions(t){if(window.themeisleSDKPromotions.option["om-elementor"])return;const o=document.querySelector("#elementor-panel__editor__help"),n=document.createElement("div");n.id="ti-optml-notice",t.domRef=n,o&&(o.parentNode.insertBefore(n,o),(0,e.render)((0,e.createElement)(g,{stacked:!0,type:"om-elementor",onDismiss:()=>{n.style.opacity=0}}),n))}runAll(){this.runAttachmentPromo(),this.runMediaPromo(),this.runEditorPromo(),this.runImageBlockPromo(),this.runElementorPromo()}};const k=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=(0,e.useState)(""),[m,c]=r();return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{disabled:"installing"===i,onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["rop-posts"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await c(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},variant:"link",className:"om-notice-dismiss"},(0,e.createElement)("span",{className:"dashicons-no-alt dashicons"}),(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Boost your content's reach effortlessly! Introducing ",(0,e.createElement)("b",null,"Revive Old Posts"),", a cutting-edge plugin from the makers of ",window.themeisleSDKPromotions.product,". Seamlessly auto-share old & new content across social media, driving traffic like never before."),(0,e.createElement)("div",{className:"rop-notice-actions"},"installed"!==i?(0,e.createElement)(o.Button,{variant:"primary",isBusy:"installing"===i,onClick:async()=>{s("installing"),await l("tweet-old-post"),await a(window.themeisleSDKPromotions.ropActivationUrl),c("themeisle_sdk_promotions_rop_installed",!Boolean(m("themeisle_sdk_promotions_rop_installed"))),s("installed")}},"Install & Activate"):(0,e.createElement)(o.Button,{variant:"primary",href:window.themeisleSDKPromotions.ropDash},"Visit Dashboard"),(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:"https://wordpress.org/plugins/tweet-old-post/"},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["rop-posts"])return;const t=document.querySelector("#ti-rop-notice");t&&(0,e.render)((0,e.createElement)(k,{onDismiss:()=>{t.style.display="none"}}),t)}};const y=t=>{let{onDismiss:n=(()=>{})}=t;const[i,s]=r(),{neveFSEMoreUrl:l}=window.themeisleSDKPromotions;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.Button,{onClick:async()=>{const e={...window.themeisleSDKPromotions.option};e["neve-fse-themes-popular"]=(new Date).getTime()/1e3|0,window.themeisleSDKPromotions.option=e,await s(window.themeisleSDKPromotions.optionKey,JSON.stringify(e)),n&&n()},className:"notice-dismiss"},(0,e.createElement)("span",{className:"screen-reader-text"},"Dismiss this notice.")),(0,e.createElement)("p",null,"Meet ",(0,e.createElement)("b",null,"Neve FSE")," from the makers of ",window.themeisleSDKPromotions.product,". A theme that makes full site editing on WordPress straightforward and user-friendly."),(0,e.createElement)("div",{className:"neve-fse-notice-actions"},(0,e.createElement)(o.Button,{variant:"link",target:"_blank",href:l},(0,e.createElement)("span",{className:"dashicons dashicons-external"}),(0,e.createElement)("span",null,"Learn more"))))};new class{constructor(){const{showPromotion:e,debug:t}=window.themeisleSDKPromotions;this.promo=e,this.debug="1"===t,this.domRef=null,this.run()}run(){if(window.themeisleSDKPromotions.option["neve-fse-themes-popular"])return;const t=document.querySelector("#ti-neve-fse-notice");t&&(0,e.render)((0,e.createElement)(y,{onDismiss:()=>{t.style.display="none"}}),t)}}}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=(t,o,i,s)=>{if(!o){var r=1/0;for(c=0;c<e.length;c++){o=e[c][0],i=e[c][1],s=e[c][2];for(var l=!0,a=0;a<o.length;a++)(!1&s||r>=s)&&Object.keys(n.O).every((e=>n.O[e](o[a])))?o.splice(a--,1):(l=!1,s<r&&(r=s));if(l){e.splice(c--,1);var m=i();void 0!==m&&(t=m)}}return t}s=s||0;for(var c=e.length;c>0&&e[c-1][2]>s;c--)e[c]=e[c-1];e[c]=[o,i,s]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={826:0,431:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var i,s,r=o[0],l=o[1],a=o[2],m=0;if(r.some((t=>0!==e[t]))){for(i in l)n.o(l,i)&&(n.m[i]=l[i]);if(a)var c=a(n)}for(t&&t(o);m<r.length;m++)s=r[m],n.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return n.O(c)},o=self.webpackChunkthemeisle_sdk=self.webpackChunkthemeisle_sdk||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var i=n.O(void 0,[431],(()=>n(165)));i=n.O(i)})();