import{ab as f,d as r,a0 as a,ac as m}from"./app-QjDgb7aF.js";import{m as y}from"./vue-Cm77DuTi.js";const t=y(new f("deck",{profile:{where:"deviceAccount",default:"default"},columns:{where:"deviceAccount",default:[]},layout:{where:"deviceAccount",default:[]},columnAlign:{where:"deviceAccount",default:"left"},alwaysShowMainColumn:{where:"deviceAccount",default:!0},navWindow:{where:"deviceAccount",default:"window"}})),x=async()=>{let n;try{n=await r("i/registry/get",{scope:["client","deck","profiles"],key:t.state.profile})}catch(e){if(e.code==="NO_SUCH_KEY"){if(t.state.profile==="default"){i();return}t.set("columns",[]),t.set("layout",[]);return}throw e}t.set("columns",n.columns),t.set("layout",n.layout)},i=m(1e3,()=>{r("i/registry/set",{scope:["client","deck","profiles"],key:t.state.profile,value:{columns:t.reactiveState.columns.value,layout:t.reactiveState.layout.value}})});async function h(){return await r("i/registry/keys",{scope:["client","deck","profiles"]})}async function p(n){return await r("i/registry/remove",{scope:["client","deck","profiles"],key:n})}async function v(n,e){n!==e&&(await r("i/registry/set",{scope:["client","deck","profiles"],key:e,value:{columns:t.state.columns,layout:t.state.layout}}),t.set("profile",e),i(),p(n))}function I(n){n.name===void 0&&(n.name=null),t.push("columns",n),t.push("layout",[n.id]),i()}function k(n){t.set("columns",t.state.columns.filter(e=>e.id!==n)),t.set("layout",t.state.layout.map(e=>e.filter(l=>l!==n)).filter(e=>e.length>0)),i()}function C(n,e){const l=t.state.layout.findIndex(d=>d.indexOf(n)!==-1),s=t.state.layout[l].findIndex(d=>d===n),o=t.state.layout.findIndex(d=>d.indexOf(e)!==-1),u=t.state.layout[o].findIndex(d=>d===e),c=a(t.state.layout);c[l][s]=e,c[o][u]=n,t.set("layout",c),i()}function A(n){const e=a(t.state.layout);t.state.layout.some((l,s)=>{if(l.includes(n)){const o=t.state.layout[s-1];return o&&(e[s-1]=t.state.layout[s],e[s]=o,t.set("layout",e)),!0}}),i()}function S(n){const e=a(t.state.layout);t.state.layout.some((l,s)=>{if(l.includes(n)){const o=t.state.layout[s+1];return o&&(e[s+1]=t.state.layout[s],e[s]=o,t.set("layout",e)),!0}}),i()}function W(n){const e=a(t.state.layout),l=t.state.layout.findIndex(o=>o.includes(n)),s=a(t.state.layout[l]);s.some((o,u)=>{if(o===n){const c=s[u-1];return c&&(s[u-1]=n,s[u]=c,e[l]=s,t.set("layout",e)),!0}}),i()}function O(n){const e=a(t.state.layout),l=t.state.layout.findIndex(o=>o.includes(n)),s=a(t.state.layout[l]);s.some((o,u)=>{if(o===n){const c=s[u+1];return c&&(s[u+1]=n,s[u]=c,e[l]=s,t.set("layout",e)),!0}}),i()}function b(n){let e=a(t.state.layout);const l=t.state.layout.findIndex(s=>s.includes(n));e=e.map(s=>s.filter(o=>o!==n)),e[l-1].push(n),e=e.filter(s=>s.length>0),t.set("layout",e),i()}function D(n){let e=a(t.state.layout);const l=t.state.layout.findIndex(u=>u.includes(n)),s=e[l];e=e.map(u=>u.filter(c=>c!==n)),e.splice(l+1,0,[n]),e=e.filter(u=>u.length>0),t.set("layout",e);const o=a(t.state.columns);for(const u of o)s.includes(u.id)&&(u.active=!0);t.set("columns",o),i()}function P(n,e){const l=a(t.state.columns),s=t.state.columns.findIndex(u=>u.id===n),o=a(t.state.columns[s]);o!=null&&(o.widgets==null&&(o.widgets=[]),o.widgets.unshift(e),l[s]=o,t.set("columns",l),i())}function R(n,e){const l=a(t.state.columns),s=t.state.columns.findIndex(u=>u.id===n),o=a(t.state.columns[s]);o!=null&&(o.widgets=o.widgets.filter(u=>u.id!==e.id),l[s]=o,t.set("columns",l),i())}function Y(n,e){const l=a(t.state.columns),s=t.state.columns.findIndex(u=>u.id===n),o=a(t.state.columns[s]);o!=null&&(o.widgets=e,l[s]=o,t.set("columns",l),i())}function j(n,e,l){const s=a(t.state.columns),o=t.state.columns.findIndex(c=>c.id===n),u=a(t.state.columns[o]);u!=null&&(u.widgets=u.widgets.map(c=>c.id===e?{...c,data:l}:c),s[o]=u,t.set("columns",s),i())}function L(n,e){const l=a(t.state.columns),s=t.state.columns.findIndex(u=>u.id===n),o=a(t.state.columns[s]);if(o!=null){for(const[u,c]of Object.entries(e))o[u]=c;l[s]=o,t.set("columns",l),i()}}export{A as a,S as b,W as c,O as d,b as e,t as f,P as g,R as h,j as i,Y as j,I as k,x as l,h as m,v as n,p as o,D as p,k as r,C as s,L as u};
//# sourceMappingURL=deck-store-DD0t0E5L.js.map
