(()=>{var e={942:(e,t)=>{var a;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e="",t=0;t<arguments.length;t++){var a=arguments[t];a&&(e=c(e,i(a)))}return e}function i(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var a in e)n.call(e,a)&&e[a]&&(t=c(t,a));return t}function c(e,t){return t?e?e+" "+t:e+t:e}e.exports?(r.default=r,e.exports=r):void 0===(a=function(){return r}.apply(t,[]))||(e.exports=a)}()}},t={};function a(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,a),i.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React,t=window.wp.element,n=window.wp.components,r=window.wp.i18n;var i=a(942),c=a.n(i);const s=()=>{const{assets:a,neveData:i,tpcData:s,strings:l,tpcAdminURL:o}=template_directory,{themeNotInstalled:m,themeNotActive:u,tpcNotInstalled:d,tpcNotActive:p}=l,[v,g]=(0,t.useState)(!1),[y,E]=(0,t.useState)(!1),[f,w]=(0,t.useState)(i.cta),[_,h]=(0,t.useState)(!1),[S,N]=(0,t.useState)(!1),[b,x]=(0,t.useState)(s.cta),A={activating:g,installing:E,currentState:w},j={activating:h,installing:N,currentState:x},[C,k]=(0,t.useState)(!1),[P,T]=(0,t.useState)(!1);let I=m;"activate"===i.cta&&(I=u);let O=d;"activate"===s.cta&&(O=p);const B={install:{static:(0,r.__)("Install and Activate","neve"),progress:(0,r.__)("Installing","neve")},activate:{static:(0,r.__)("Activate","neve"),progress:(0,r.__)("Activating","neve")}},L=(t,a,i,c,s,l,o)=>{const m={install:(0,e.createElement)(n.Button,{disabled:t,isPrimary:!t,isSecondary:t,className:t&&"is-loading",icon:t&&"update",onClick:()=>M(c,s,l,o)},t?B.install.progress+"...":B.install.static),activate:(0,e.createElement)(n.Button,{disabled:a,isPrimary:!a,isSecondary:a,className:a&&"is-loading",icon:a&&"update",onClick:()=>D(c,o)},a?B.activate.progress+"...":B.activate.static),deactivate:(0,e.createElement)(n.Button,{disabled:!0,isSecondary:!0,className:"is-loading"},(0,r.__)("Activated"))};return(0,e.createElement)(e.Fragment,null,m[i])},M=(e,t,a,n)=>{e.installing(!0),wp.updates.ajax(`install-${t}`,{slug:a,success:()=>{D(e,n)},error:t=>{"folder_exists"===t.errorCode?D(e,n):(k(t.errorMessage?t.errorMessage:(0,r.__)("Something went wrong. Please try again.","themeisle-companion")),e.installing(!1),setTimeout(()=>k(!1),3e3))}})},D=(e,t)=>{e.installing(!1),e.activating(!0),e.currentState("activate"),(async e=>{const t={method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","x-wp-nonce":template_directory.nonce}};return await fetch(e,t).then(e=>e)})(t).then(t=>{t.ok?(e.activating(!1),e.currentState("deactivate"),T(!0)):(k((0,r.__)("Something went wrong. Please try again.","themeisle-companion")),e.activating(!1),setTimeout(()=>k(!1),3e3))})},F="deactivate"!==s.cta,R="deactivate"!==i.cta;"deactivate"===b&&"deactivate"===f&&(window.location.href=o);const $=!F||!R;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"ss-background",style:{backgroundImage:`url(${a}/img/starter.jpg)`}}),(0,e.createElement)("div",{className:"unavailable-starter-sites"},(0,e.createElement)("div",{className:c()(["slider",{"move-right":P&&!$},{single:$}])},F&&(0,e.createElement)("div",{className:"content-wrap"},(0,e.createElement)("img",{src:a+"/img/tpc.svg",alt:(0,r.__)("Templates Cloud Logo","themeisle-companion")}),(0,e.createElement)("h1",null,B[s.cta].static+" Templates Cloud"),(0,e.createElement)("p",{className:"error"},O),L(S,_,b,j,"plugin","templates-patterns-collection",s.activate)),R&&(0,e.createElement)("div",{className:"content-wrap"},(0,e.createElement)("img",{src:a+"/img/neve.svg",alt:(0,r.__)("Neve Theme Logo","themeisle-companion")}),(0,e.createElement)("h1",null,B[i.cta].static+" Neve"),(0,e.createElement)("p",{className:"error"},I),L(y,v,f,A,"theme","neve",i.activate))),"deactivate"!==i.cta&&"deactivate"!==s.cta&&(0,e.createElement)("div",{className:"stepper"},(0,e.createElement)("button",{className:c()(["dot",{current:!P}]),onClick:()=>T(!P)}),(0,e.createElement)("button",{className:c()(["dot",{current:P}]),onClick:()=>T(!P)})),C&&(0,e.createElement)("div",{className:"error"}," ",C," ")))},l=()=>(0,e.createElement)("div",null,(0,e.createElement)(s,null));(0,t.render)((0,e.createElement)(()=>(0,e.createElement)(l,null),null),document.getElementById("obfx-template-directory"))})()})();