"use strict";(self.webpackChunkdami=self.webpackChunkdami||[]).push([[2425],{82425:(t,a,i)=>{i.r(a),i.d(a,{default:()=>n});var e=i(93150),s=i.n(e),d=i(31791);async function n({data:t,id:a}){const i=this.getBlockConnections(a),e=(t,a)=>{const e=new Error(t);return e.nextBlockId=i,a&&(e.data=a),e};this.windowId=null;let n=null;const r=t.activeTab??!0,c=t.findTabBy||"match-patterns",h=["next-tab","prev-tab"].includes(c);if(!this.activeTab.id&&h)throw new Error("no-tab");const l="match-patterns"!==c?await s().tabs.query({}):[];if(["match-patterns","tab-title"].includes(c)){const a={};if("match-patterns"===t.findTabBy?a.url=t.matchPattern:"tab-title"===t.findTabBy&&(a.title=t.tabTitle),[n]=await s().tabs.query(a),!n){if(!t.createIfNoMatch)throw e("no-match-tab",{pattern:t.matchPattern});if(!t.url.startsWith("http"))throw e("invalid-active-tab",{url:t.url});n=await s().tabs.create({active:r,url:t.url,windowId:this.windowId})}}else if(h){const t=c.includes("next")?1:-1;let a=l.findIndex((t=>t.id===this.activeTab.id));a+=t,a<0?a=l.length-1:a>l.length-1&&(a=0),n=l[a]}else if("tab-index"===c&&(n=l[t.tabIndex],!n))throw e(`Can't find a tab with ${t.tabIndex} index`);return await s().tabs.update(n.id,{active:r}),this.activeTab.id=n.id,this.activeTab.frameId=0,this.activeTab.url=n.url,this.windowId=n.windowId,this.settings.debugMode&&(await(0,d.xq)(n.id,this.activeTab.id),this.debugAttached=!0),this.preloadScripts.length>0&&(this.engine.isMV2?await this._sendMessageToTab({isPreloadScripts:!0,label:"javascript-code",data:{scripts:this.preloadScripts}}):await(0,d.SR)({scripts:this.preloadScripts,frameSelector:this.frameSelector,target:{tabId:this.activeTab.id,frameIds:[this.activeTab.frameId||0]}})),r&&await s().windows.update(n.windowId,{focused:!0}),{nextBlockId:i,data:n.url}}}}]);