"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[4604,8198],{74604:(t,e,a)=>{a.r(e),a.d(e,{default:()=>i});var s=a(86087),n=a(88198),c=a(27723),o=a(10790);const i=(0,s.memo)(()=>{const{loaded:t,wscStatus:e,tokenStatus:a,getStatus:i,startOnboarding:l,resetWsc:r,enableWsc:d,disableWsc:u}=(0,n.default)();(0,s.useEffect)(()=>{i()},[]);const b=(0,s.useCallback)(()=>{if(a)switch(a){case"enabled":r();break;case"disabled":case"pending":l()}},[a]),w=(0,s.useCallback)(()=>{if(e)switch(e){case"enabled":u();break;case"disabled":d()}},[e]);let g="enabled"===e?(0,c.__)("Disable Website Scan","complianz-gdpr"):(0,c.__)("Enable Website Scan","complianz-gdpr"),p="enabled"===e?"button-secondary":"button-primary",_="enabled"===a?(0,c.__)("Reset Website Scan","complianz-gdpr"):(0,c.__)("Activate Website Scan","complianz-gdpr"),h="enabled"===a?"button-danger":"button-primary",S="pending"===a;return(0,o.jsx)("div",{className:"cmplz-wsc_actions-container",children:(0,o.jsx)("div",{className:"cmplz-wsc_actions-row",children:(0,o.jsxs)("div",{className:"cmplz-wsc_actions-buttons",children:["disabled"!==a&&"pending"!==e&&(0,o.jsx)("button",{className:`button ${p}`,onClick:w,children:g}),(0,o.jsx)("button",{disabled:S,className:`button ${h}`,onClick:b,children:_})]})})})})},88198:(t,e,a)=>{a.r(e),a.d(e,{default:()=>o});var s=a(9588),n=a(81621);const c={loaded:!1,tokenStatus:"",wscStatus:"",wscSignupDate:"",batchStats:null,syncing:!1},o=(0,n.vt)((t,e)=>({...c,startOnboarding:async()=>{const t=new URL(cmplz_settings.dashboard_url);t.searchParams.set("websitescan",""),setTimeout(()=>{window.location.href=t.href},500)},getStatus:async()=>{if(!e().getStatusCalled)try{let e={};const{wsc_status:a,token_status:n,wsc_signup_date:c,batch_stats:o}=await s.doAction("get_wsc_status",e).then(t=>t);t({tokenStatus:n,wscStatus:a,wscSignupDate:c,batchStats:null!=o?o:null,loaded:!0})}catch(t){console.error("Getting status error: ",t)}},resetWsc:async()=>{if(confirm("Are you sure? This will delete all your Website Scan data."))try{const{result:e,redirect:a}=await s.doAction("reset_wsc").then(t=>t);e&&(t(t=>({...c,startOnboarding:t.startOnboarding,getStatus:t.getStatus,enableWsc:t.enableWsc,disableWsc:t.disableWsc,resetWsc:t.resetWsc})),setTimeout(()=>{window.location.reload()},500))}catch(t){console.error("Resetting WSC error: ",t)}finally{setTimeout(()=>{window.location.reload()},300)}},enableWsc:async()=>{try{const{updated:e,wsc_status:a,token_status:n}=await s.doAction("enable_wsc").then(t=>t);t({updated:e,tokenStatus:n,wscStatus:a,loaded:!0})}catch(t){console.error("Enabling WSC error: ",t)}},disableWsc:async()=>{try{const{updated:e,wsc_status:a,token_status:n}=await s.doAction("disable_wsc").then(t=>t);t({updated:e,tokenStatus:n,wscStatus:a,loaded:!0})}catch(t){console.error("Disabling WSC error: ",t)}},requestActivationEmail:async()=>{try{await s.doAction("request_activation_email"),e().getStatus()}catch(t){console.error("Requesting activation email error: ",t)}}}))}}]);