"use strict";(self.webpackChunkdami=self.webpackChunkdami||[]).push([[7249],{47249:(t,e,a)=>{a.r(e),a.d(e,{default:()=>o});var n=a(59022),i=a(93150),c=a.n(i),s=a(31791);const r=(0,n.k)("1234567890abcdef",5);const o=async function(t,{refData:e}){if(!this.activeTab.id)throw new Error("no-tab");const{data:a}=t,n=(await Promise.allSettled(a.preloadScripts.map((t=>t.src.startsWith("http")?fetch(t.src).then((t=>t.text())).then((e=>({type:t.type,script:e}))):Promise.reject(new Error("Invalid URL")))))).reduce(((t,e)=>("rejected"===e.status||t.push(e.value),t)),[]);a.preloadScripts=n;const i={...t,data:a};return a.javascript&&this.engine.isMV2&&(i.data.injectJS=!0,i.data.automaScript=function(t){const e=`automa${r()}`;return`\nconst ${e} = ${JSON.stringify(t)};\n${(0,s.XB)(e)}\nfunction automaSetVariable(name, value) {\n  ${e}.variables[name] = value;\n}\nfunction automaExecWorkflow(options = {}) {\n  window.dispatchEvent(new CustomEvent('automa:execute-workflow', { detail: options }));\n}\n  `}({...e,secrets:{}})),await this._sendMessageToTab(i,{},a.runBeforeLoad??!1),a.javascript&&!this.engine.isMV2&&await c().scripting.executeScript({world:"MAIN",args:[a.javascript,t.id,i.script.automaScript,n],target:{tabId:this.activeTab.id,frameIds:[this.activeTab.frameId||0]},func:(t,e,a,n)=>{const i=`automa-${e}`;n.forEach((t=>{const e=document.createElement(t.type);e.id=`${i}-script`,e.textContent=t.script,document.body.appendChild(e)}));const c=document.createElement("script");c.id=`${i}-javascript`,c.textContent=`(() => { ${a}\n${t} })()`,document.body.appendChild(c)}}),{data:"",nextBlockId:this.getBlockConnections(t.id)}}}}]);