"use strict";(self.webpackChunkcomplianz_gdpr=self.webpackChunkcomplianz_gdpr||[]).push([[4759],{34759:(t,s,c)=>{c.r(s),c.d(s,{default:()=>n});var i=c(81621),e=c(16535),r=c(9588);const n=(0,i.vt)(((t,s)=>({integrationsLoaded:!1,fetching:!1,services:[],plugins:[],scripts:[],placeholders:[],blockedScripts:[],setScript:(s,c)=>{t((0,e.Ay)((t=>{if("block_script"===c){let c=t.blockedScripts;if(s.urls){for(const[t,i]of Object.entries(s.urls)){if(!i||0===i.length)continue;let t=!1;for(const[s,e]of Object.entries(c))i===s&&(t=!0);t||(c[i]=i)}t.blockedScripts=c}}const i=t.scripts[c].findIndex((t=>t.id===s.id));-1!==i&&(t.scripts[c][i]=s)})))},fetchIntegrationsData:async()=>{if(s().fetching)return;t({fetching:!0});const{services:c,plugins:i,scripts:e,placeholders:r,blocked_scripts:n}=await p();let o=e;o.block_script&&o.block_script.length>0&&o.block_script.forEach(((t,s)=>{t.id=s})),o.add_script&&o.add_script.length>0&&o.add_script.forEach(((t,s)=>{t.id=s})),o.whitelist_script&&o.whitelist_script.length>0&&o.whitelist_script.forEach(((t,s)=>{t.id=s})),t((()=>({integrationsLoaded:!0,services:c,plugins:i,scripts:o,fetching:!1,placeholders:r,blockedScripts:n})))},addScript:c=>{t({fetching:!0}),s().scripts[c]&&Array.isArray(s().scripts[c])||t((0,e.Ay)((t=>{t.scripts[c]=[]}))),t((0,e.Ay)((t=>{t.scripts[c].push({name:"general",id:t.scripts[c].length,enable:!0})})));let i=s().scripts;return r.doAction("update_scripts",{scripts:i}).then((s=>(t({fetching:!1}),s))).catch((t=>{console.error(t)}))},saveScript:(c,i)=>{t({fetching:!0}),s().scripts[i]&&Array.isArray(s().scripts[i])||t((0,e.Ay)((t=>{t.scripts[i]=[]}))),t((0,e.Ay)((t=>{const s=t.scripts[i].findIndex((t=>t.id===c.id));-1!==s&&(t.scripts[i][s]=c)})));let n=s().scripts;return r.doAction("update_scripts",{scripts:n}).then((s=>(t({fetching:!1}),s))).catch((t=>{console.error(t)}))},deleteScript:(c,i)=>{t({fetching:!0}),s().scripts[i]&&Array.isArray(s().scripts[i])||t((0,e.Ay)((t=>{t.scripts[i]=[]}))),t((0,e.Ay)((t=>{const s=t.scripts[i].findIndex((t=>t.id===c.id));-1!==s&&t.scripts[i].splice(s,1)})));let n=s().scripts;return r.doAction("update_scripts",{scripts:n}).then((s=>(t({fetching:!1}),s))).catch((t=>{console.error(t)}))},updatePluginStatus:async(s,c)=>{t({fetching:!0}),t((0,e.Ay)((t=>{const i=t.plugins.findIndex((t=>t.id===s));-1!==i&&(t.plugins[i].enabled=c)})));const i=await r.doAction("update_plugin_status",{plugin:s,enabled:c}).then((t=>t)).catch((t=>{console.error(t)}));return t({fetching:!1}),i},updatePlaceholderStatus:async(s,c,i)=>{t({fetching:!0}),i&&t((0,e.Ay)((t=>{const i=t.plugins.findIndex((t=>t.id===s));-1!==i&&(t.plugins[i].placeholder=c?"enabled":"disabled")})));const n=await r.doAction("update_placeholder_status",{id:s,enabled:c}).then((t=>t)).catch((t=>{console.error(t)}));return t({fetching:!1}),n}}))),p=()=>r.doAction("get_integrations_data",{}).then((t=>t)).catch((t=>{console.error(t)}))}}]);