(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`98855b37a3d52795063fb5f65b16b203e1f309a7`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`3d9d8ab2-1aa2-4bd3-a58f-4cb0f287af96`,e._sentryDebugIdIdentifier=`sentry-dbid-3d9d8ab2-1aa2-4bd3-a58f-4cb0f287af96`)}catch{}})();import{Q as e,et as t,v as n}from"./element-plus-B1fHG2BL.js";import{i as r,s as i}from"./vue-Dx4PbTpV.js";import{a,d as o,f as s,i as c,u as l}from"./main-CNgG4xjc.js";import{a as u,f as d,i as f,m as p,p as m}from"../index.js";let h=function(e){return e.Popup=`popup`,e.Options=`options`,e}({});const g=i(`collectionEditStore`,()=>{let r=t(``),i=e([]),[u,d]=p({id:``,name:``,desc:``,uri:[{id:0,value:``,method:o.default}],matchItem:[],isEnable:!0,strictPort:!1}),[f,h]=p({id:``,name:``,target:``}),g=e(l.Create),v=e(l.Create),y=n(()=>u.value.id),b=n(()=>f.value.id),x=n(()=>i.value.filter(e=>e.isEnable)),S=n(()=>r.value?i.value.filter(e=>e.name.toLowerCase().includes(r.value.toLowerCase())):i.value);function C(){chrome.storage&&(a.setItem(`enabledCollectionList`,JSON.stringify(x.value)),c.sendMessage(s.UpdateEnabledCollectionListData))}function w(e){let t=[l.Create,l.Edit];if(e===y.value&&t.includes(g.value))return;let n=i.value.find(t=>t.id===e);n?(u.value=m(n),g.value=l.Edit):(d(),u.value.id=e,g.value=l.Create)}function T(){u.value.uri.push(_(u.value.uri.length+1))}function E(){u.value.uri=u.value.uri.filter(e=>e.value!==``)}function D(){u.value.isEnable=!u.value.isEnable}function O(){E();let e=i.value.findIndex(e=>e.id===y.value);e===-1?i.value.push({...u.value}):i.value[e]=m(u.value),g.value=l.Saved,C()}function k(){i.value=i.value.filter(e=>e.id!==y.value),C()}function A(e){let t=u.value.matchItem.find(t=>t.id===e);t?(f.value=m(t),v.value=l.Edit):(h(),f.value.id=e,v.value=l.Create)}async function j(){let e=u.value.matchItem.findIndex(e=>e.id===b.value);e===-1?u.value.matchItem.push(m(f.value)):u.value.matchItem[e]=m(f.value)}function M(e){let t=e||b.value;u.value.matchItem=u.value.matchItem.filter(e=>e.id!==t)}return{searchKeyword:r,collectionListData:i,enabledCollectionList:x,filterCollectionList:S,collectionForm:u,collectionFormId:y,collectionFormState:g,InitCollectionData:w,SaveCollectionData:O,AddURIItem:T,ChangeCollectionState:D,DeleteCollectionItem:k,matchForm:f,matchFormState:v,InitMatchData:A,SaveMatchData:j,DeleteMatchItem:M}},{persist:!0});function _(e){return{id:e,value:``,method:o.default}}function v(){let e=r(),t=g();async function n(n){let{pageTarget:r,blank:i}=n,a=n.collectionId??d();if(t.InitCollectionData(a),i){let t=e.resolve({name:f.CollectionEdit,params:{collectionId:a}});globalThis.open(t.href)}else await e.push({name:r===h.Popup?u.CollectionEdit:f.CollectionEdit,params:{collectionId:a}})}async function i(e){await n({pageTarget:h.Popup,collectionId:e})}async function a(t){await e.push({name:u.MatchEdit,params:t})}async function s(e){let{pageTarget:t,blank:n}=e;await m({blank:n,routerName:t===h.Popup?u.Collection:f.Collection})}function c(){globalThis.open(`https://docs.switchhoster.com`)}async function l(e){let{pageTarget:t,blank:n}=e;await m({blank:n,routerName:t===h.Popup?u.Settings:f.Settings})}function p(){let e={id:d(),name:`测试集合`,desc:`这是一个演示的集合，帮助你快速的掌握使用方法`,uri:[{id:0,value:`www.switchhoster.com`,method:o.default}],matchItem:[],isEnable:!0,strictPort:!1};for(let t=0;t<5;t++)e.matchItem.push({id:d(),name:`verify${t+1}`,target:`verify${t+1}.switchhoster.com`});t.collectionForm=e,t.SaveCollectionData(),globalThis.open(`https://www.switchhoster.com/playground`)}async function m(t){let{blank:n,routerName:r}=t;n?globalThis.open(e.resolve({name:r}).href):await e.push({name:r})}return{gotoCollectionEditPage:n,gotoMatchEditPage:a,gotoCollectionPage:s,goBackCollectionEditPage:i,gotoSettingPage:l,gotoDocs:c,importDemoCollectionData:p}}export{g as n,h as r,v as t};
//# sourceMappingURL=usePopup-DtGdnVsG.js.map