@camstack/addon-admin-ui 1.2.396 → 1.2.397

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/assets/{AddonAssetIcon-Bsc0Q_3X.js → AddonAssetIcon-7ZvCceV6.js} +1 -1
  2. package/dist/assets/{AddonIntegrationBody-BlFQPEEQ.js → AddonIntegrationBody-CmsA9jC5.js} +1 -1
  3. package/dist/assets/{Addons-DHOaRo4Z.js → Addons-B0lqxfjl.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-LBOgOUcc.js → AdminSectionedPage-Dj5EzIqk.js} +1 -1
  5. package/dist/assets/{AiProfiles-BYM2mL6O.js → AiProfiles-BYQcaDzE.js} +1 -1
  6. package/dist/assets/{BrokerForm-BgDrpr2d.js → BrokerForm-Oa4W78DW.js} +1 -1
  7. package/dist/assets/{Build-BYVR_ulC.js → Build-DTkrXnV9.js} +1 -1
  8. package/dist/assets/{Calendars-CkjePTFG.js → Calendars-DF3EOrCw.js} +1 -1
  9. package/dist/assets/{Cluster-B9MwPMBe.js → Cluster-9ZOqQRY0.js} +1 -1
  10. package/dist/assets/{ClusterStepModel-B2r5_D5H.js → ClusterStepModel-ZEYxPYn0.js} +1 -1
  11. package/dist/assets/{CompositionEditorPage-B5U_zxxm.js → CompositionEditorPage-BOTNyxzw.js} +1 -1
  12. package/dist/assets/{Data-BZZqsqK6.js → Data-Ct8SqRSf.js} +1 -1
  13. package/dist/assets/{DeviceDetail-DjstCWsc.js → DeviceDetail-Dn0-0JDf.js} +1 -1
  14. package/dist/assets/{Devices-C7zT7ydf.js → Devices-X3jFUswR.js} +1 -1
  15. package/dist/assets/{Identity-DpH1uRn3.js → Identity-bdrVgYed.js} +1 -1
  16. package/dist/assets/{IntegrationDetail-f4S1F5L6.js → IntegrationDetail-BFt35GRb.js} +1 -1
  17. package/dist/assets/{Integrations-BarXh0he.js → Integrations-TPrR0bGF.js} +1 -1
  18. package/dist/assets/Integrations-vjs0FPms.js +1 -0
  19. package/dist/assets/{Library-jXVmp8tU.js → Library-Ck49o54W.js} +1 -1
  20. package/dist/assets/{Locations-CbGaB8Bw.js → Locations-aqPkrde8.js} +1 -1
  21. package/dist/assets/{Logs-Hrbd9vai.js → Logs-C8EFuHw0.js} +1 -1
  22. package/dist/assets/{MyAccess-3L4FooAQ.js → MyAccess-C8p-J8wW.js} +1 -1
  23. package/dist/assets/{Network-C3tAes19.js → Network-CaDC37pB.js} +1 -1
  24. package/dist/assets/{NodeAddonsSettingsPanel-Cowue7E1.js → NodeAddonsSettingsPanel-BCFsPpmx.js} +1 -1
  25. package/dist/assets/{Notifications-Bqpjzecc.js → Notifications-B2CuenV0.js} +1 -1
  26. package/dist/assets/{Recordings-Cj6OgNgS.js → Recordings-1xAqwANe.js} +1 -1
  27. package/dist/assets/{ScanNetworkModal-Dk1bC4tM.js → ScanNetworkModal-C9-sEf0w.js} +1 -1
  28. package/dist/assets/{SessionsList-DhmGBoSx.js → SessionsList-0Ev1b1-K.js} +1 -1
  29. package/dist/assets/{Showroom-BHWXtcx1.js → Showroom-DbgC7jrf.js} +1 -1
  30. package/dist/assets/{System-wXq9VrJZ.js → System-UCSG2wyb.js} +1 -1
  31. package/dist/assets/{Terminal-CnHA__F7.js → Terminal-BN5uwTST.js} +1 -1
  32. package/dist/assets/{device-integration-icon-NxxJpgpC.js → device-integration-icon-DqKmRTQS.js} +1 -1
  33. package/dist/assets/{index-CBIV3kmO.js → index-I1VJhtqM.js} +2 -2
  34. package/dist/assets/{location-owned-usage-BTy5fZ71.js → location-owned-usage-DmAH-1FL.js} +1 -1
  35. package/dist/assets/{mf-entry-bootstrap-0-4804e55d.js → mf-entry-bootstrap-0-53adc98f.js} +1 -1
  36. package/dist/assets/{useNodeUrlSelection-A0Mj6YnO.js → useNodeUrlSelection-C2aUQ5pz.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/dist/server/addon.js +1 -1
  39. package/package.json +1 -1
  40. package/dist/assets/Integrations-DVNBeRUJ.js +0 -1
@@ -1 +1 @@
1
- import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{D as c,_t as l,ct as u,gt as d,ht as f,ot as p,yt as m}from"./player-overlays-mP7nvLXZ.js";import{An as h,Ed as g,Fd as _,Fn as v,Gc as y,In as b,Kn as x,Mn as S,Pn as C,Tr as w,U as ee,Vt as T,dd as E,jn as te,ld as D,md as O,mu as k,rl as ne,rr as A}from"./src-BeE19PxU.js";import{t as j}from"./archive-C3YvN3bo.js";import{n as M,t as N}from"./format-size-D8E_VMta.js";import{ei as P}from"./client-D5nV-lIF.js";import{I as re}from"./index-CBIV3kmO.js";var F=m(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]);t();function I(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function ie(e,t){let n=I(t);return`${e}:${n.length>0?n:`default`}`}var ae=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),oe=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function L(e){let t=oe.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?oe.length:t}function R(e){return e.filter(e=>!e.name.startsWith(`.`)&&!ae.has(e.name)).toSorted((e,t)=>{let n=L(e.name)-L(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function se({nodeId:t,value:r,onChange:i}){let c=p().trpcClient,[l,u]=a([]),[d,f]=a(r),[m,h]=a(null),[g,_]=a(null),[v,y]=a(``),b=e(async(e,n)=>{_(null);try{let r=await c.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),f(r.path),n&&i(r.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[c,t,i]);s(()=>{f(r),(async()=>{let e=await c.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){u(R(e.entries)),await b(r.startsWith(`/`)?r:`/`,!1);return}try{let e=await c.filesystemBrowse.listAllowedRoots.query({nodeId:t});u(e),await b(r&&e.some(e=>r.startsWith(e))?r:e[0]??``,!1)}catch(e){u([]),h(null),_(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let x=async()=>{if(!(!v.trim()||!m)){_(null);try{let e=`${m.path.replace(/\/+$/,``)}/${v.trim()}`;await c.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),y(``),await b(m.path,!0)}catch(e){_(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return n(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[o(`div`,{className:`flex flex-wrap gap-1`,children:l.map(e=>o(`button`,{onClick:()=>void b(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),o(`input`,{value:d,onChange:e=>{f(e.target.value),i(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&n(`div`,{className:`text-[10px] text-foreground-subtle`,children:[S(m.freeBytes),` free / `,S(m.totalBytes)]}),o(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(e=>n(`button`,{onClick:()=>void b(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),n(`div`,{className:`flex gap-1`,children:[o(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`new folder`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),o(`button`,{onClick:()=>void x(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:`Create`})]}),g&&o(`div`,{className:`text-[10px] text-red-400`,children:g})]})}t();function z({initialType:e,onClose:t,onCreated:s}){let c=i(),l=p().trpcClient,[u,f]=a(`picker`),[m,_]=a(e),[x,C]=a(null),[w,T]=a({}),[E,D]=a(``),[O,k]=a(null),[A,j]=a(!1),[M,N]=a(`hub`),[P,F]=a(null),[I,ae]=a(!1),oe=e=>T(t=>({...t,basePath:e})),L=typeof w.basePath==`string`?w.basePath:``,R=y(),z=r(()=>{let e=R.data;return Array.isArray(e)?e:[]},[R.data]),B=R.isLoading,V=ne({onSuccess:()=>{c.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),H=r(()=>O!==null&&O.length>0?O:ie(m,E),[m,E,O]),U=async()=>{if(x){ae(!0),F(null);try{F(await(e=>l.storage.testConfig.query(e))({providerId:x.providerId,config:w}))}catch(e){F({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{ae(!1)}}};return o(h,{open:!0,onOpenChange:e=>!e&&t(),children:n(S,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(v,{children:[o(b,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${x?.displayName??``}`,naming:`Add Location — Name`}[u]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,o(`span`,{className:`font-mono`,children:m})]})]}),n(te,{children:[u===`picker`&&n(`div`,{className:`space-y-2`,children:[B&&o(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!B&&z.length===0&&n(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:[`No storage-provider supports type "`,m,`". Install a compatible addon (e.g.`,` `,o(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),z.map(e=>n(`button`,{onClick:()=>{C(e),f(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[o(`p`,{className:`text-xs font-semibold text-foreground`,children:e.displayName}),o(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:e.providerId})]}),o(d,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),u===`config`&&x&&n(`div`,{className:`space-y-3`,children:[o(re,{schema:x.configSchema,values:w,onChange:T}),x.nodeLocal&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(ee,{selectedNodeId:M,onSelect:N,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(se,{nodeId:M,value:L,onChange:oe})]}),P&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${P.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:P.ok?`Connection OK.`:`Test failed: ${P.error??`unknown error`}`}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{U()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?`Testing…`:`Test connection`}),o(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),u===`naming`&&x&&n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`${m} on ${x.displayName}`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1`,children:[n(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[`Id`,` `,o(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:`— auto-derived; override if needed`})]}),o(`input`,{type:`text`,value:H,onChange:e=>k(e.target.value),placeholder:ie(m,E),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,o(`code`,{className:`font-mono`,children:`<type>:<slug>`}),`. Lowercase letters, digits, and hyphens only.`]})]}),n(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[o(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-primary mt-0.5`}),n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`text-xs font-medium text-foreground`,children:`Enable immediately`}),o(`div`,{className:`text-[10px] text-foreground-subtle`,children:`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`})]})]}),V.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:V.error instanceof Error?V.error.message:String(V.error)}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{_(e),C(null),T({}),D(``),k(null),j(!1),F(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),n(`button`,{onClick:()=>{x&&V.mutate({id:H,type:m,displayName:E.trim(),providerId:x.providerId,config:w,enabled:A,nodeId:x.nodeLocal?M:void 0})},disabled:V.isPending||E.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[V.isPending?o(g,{className:`h-3.5 w-3.5 animate-spin`}):null,V.isPending?`Saving…`:`Save`]})]})]})]})]})]})})}function B(e){return P(e)}function V(e){return e===`active`}var H=[{mode:`active`,label:`Active`,consequence:`New data is written here, and the oldest is deleted when the disk fills up.`,requiresConfirmation:!1},{mode:`readonly`,label:`Read-only`,consequence:`Nothing new is written and nothing is ever deleted. A frozen archive that stays on the timeline.`,requiresConfirmation:!1},{mode:`drain`,label:`Drain`,consequence:`Nothing new is written. The oldest data here is deleted, a little at a time, until this location is empty.`,requiresConfirmation:!1},{mode:`disabled`,label:`Disabled`,consequence:`Nothing is written and nothing is read: the footage stored here disappears from the timeline until you turn it back on. Nothing is deleted.`,requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ce(e){return U(e).requiresConfirmation}var le=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:le}}function ue(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function de(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function fe(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function pe(e,t){let n={...t.config??e.config};t.mode!==void 0&&(fe(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:fe(t.mode).enabled}}var me=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function he(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function ge(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function _e(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function ve(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function ye(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*me;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function be(e){return e===`gb`?`GB to keep free`:`% of the volume to keep free`}function xe(e,t=10){return`CamStack keeps ${e.value===null?`${String(t)}% of the volume (the default)`:e.unit===`gb`?`${String(e.value)} GB`:`${String(e.value)}% of the volume`} free on this disk. As it fills up, the OLDEST data stored here is deleted to hold that much free space; if it cannot be held any more, new data goes to another location of the same type instead of filling the disk. Leave the value empty for the default (${String(t)}%).`}function Se(e){return G(e.maxUsedGb)}function Ce(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*me,reason:t===`drain`?`drain`:`legacy`}}t();function we({config:e,defaultPercent:t=10,onChange:r}){let[i,s]=a(()=>he(e).unit),c=ge(e,i),l={unit:i,value:c},u=Se(e),d=t=>{s(t),r(_e(e,{unit:t,value:null}))},f=t=>{r(_e(e,{unit:i,value:ve(t,i)}))};return n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Protected free space`}),n(`div`,{className:`flex items-center gap-2`,children:[n(`select`,{"aria-label":`Protection unit`,value:i,onChange:e=>{d(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[o(`option`,{value:`percent`,children:`% of the volume`}),o(`option`,{value:`gb`,children:`GB of free space`})]}),o(`input`,{type:`number`,"aria-label":be(i),min:0,max:i===`percent`?100:void 0,value:c===null?``:c,placeholder:i===`percent`?String(t):`default`,onChange:e=>{f(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:xe(l,t)}),u!==null&&n(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:[`This location also stores a maximum used size of `,u,` GB. That limit is managed by the system now and is no longer editable here; it is kept as it is.`]})]})}t();function Te({location:e,onClose:t,onSaved:s}){let c=i(),l=p().trpcClient,[u,d]=a({...e.config}),[f,m]=a(e.displayName),[_,w]=a(null),[T,E]=a(!1),D=y(),O=r(()=>{let t=D.data;return Array.isArray(t)?t.find(t=>t.providerId===e.providerId)??null:null},[D.data,e.providerId]),k=ne({onSuccess:()=>{c.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),A=O?.shouldSaveDiskSpace===!0,j=O?.nodeLocal===!0,[M,N]=a(typeof e.nodeId==`string`?e.nodeId:`hub`),P=typeof u.basePath==`string`?u.basePath:``,F=e=>d(t=>({...t,basePath:e})),I=O?.minFreePercent??10,ie=async()=>{E(!0),w(null);try{w(await(e=>l.storage.testConfig.query(e))({providerId:e.providerId,locationId:e.id,config:u}))}catch(e){w({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{E(!1)}};return o(h,{open:!0,onOpenChange:e=>!e&&t(),children:n(S,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(v,{children:[n(b,{children:[`Edit `,e.displayName]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[o(`span`,{className:`font-mono`,children:e.id}),` ·`,` `,O?.displayName??e.providerId]})]}),n(te,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:f,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),O&&o(re,{schema:O.configSchema,values:u,onChange:d}),j&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(ee,{selectedNodeId:M,onSelect:N,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(se,{nodeId:M,value:P,onChange:F})]}),A&&o(we,{config:u,defaultPercent:I,onChange:d}),!O&&!D.isLoading&&n(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Provider `,o(`code`,{className:`font-mono`,children:e.providerId}),` is no longer registered. Field schema unavailable; raw config is preserved on save.`]}),_&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${_.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:_.ok?`Connection OK.`:`Test failed: ${_.error??`unknown error`}`}),k.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:k.error instanceof Error?k.error.message:String(k.error)})]}),n(C,{className:`justify-between`,children:[o(x,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),n(`div`,{className:`flex items-center gap-2`,children:[o(x,{variant:`outline`,size:`sm`,onClick:()=>{ie()},disabled:T||!O,children:T?`Testing…`:`Test connection`}),n(x,{size:`sm`,onClick:()=>{k.mutate(pe(e,{displayName:f.trim(),config:u,nodeId:j?M:e.nodeId}))},disabled:k.isPending||f.trim().length===0,children:[k.isPending?o(g,{className:`h-3.5 w-3.5 animate-spin`}):null,k.isPending?`Saving…`:`Save`]})]})]})]})})}function Ee(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function De(e){if(!Ee(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=K(e.startedAtMs),r=K(e.startBytes),i=K(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:K(e.estimatedEmptyAtMs)}}function Oe(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=De(n);e!==null&&t.set(e.locationId,e)}return t}function ke(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Ae(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:ke(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function je(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Me(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ne(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Pe({drain:e}){if(e.kind===`idle`)return null;if(e.kind===`unreported`)return o(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`,children:`Draining · remaining not reported yet`});if(e.kind===`drained`)return o(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`,children:`Drained · nothing left to move`});let t=e.drainedFraction===null?null:Math.round(e.drainedFraction*100);return n(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[t!==null&&o(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":`Drain progress`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,children:o(`span`,{className:`block h-full bg-warning`,style:{width:`${t}%`}})}),n(`span`,{children:[Me(e.bytesRemaining),` left`,t!==null&&` · ${t}% moved`]}),e.estimatedEmptyAtMs===null?o(`span`,{"data-testid":`drain-eta-absent`,title:`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`,children:`· empty time not known yet`}):n(`span`,{"data-testid":`drain-eta`,children:[`· empty `,Ne(e.estimatedEmptyAtMs)]})]})}var Fe=[`ok`,`warn`,`critical`];function Ie(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Le(e){return Math.min(1,Math.max(0,e))}function q(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Le((n-t)/n);return{fraction:r,severity:Ie(r),recordingsFraction:Le(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Re(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=q(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Fe.indexOf(e.severity)>Fe.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}var ze=`Capacity unknown — nothing measured this volume from here. A remote share, a location on another node, or a mount that did not answer.`;function J(e){return Math.min(1,Math.max(0,e))}function Y(e){return Math.round(J(e)*1e3)/10}function X(e){return`${String(Math.round(J(e)*100))}%`}function Be(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?ze:`${ze} CamStack holds ${e} here.`}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=q({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?J(o/r):m.fraction,g=m===null?Ie(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:`${N(s)} kept free`,owned:f===null||_===null?null:`${N(f)} of recordings (${X(_)})`,cap:v===null?null:v.reason===`drain`?`${N(v.bytes)} drain target (managed by CamStack)`:`${N(v.bytes)} cap (managed by CamStack)`},S=[`${x.freeTotal} free of ${x.total} (${x.freeTotalPercent} free)`,x.owned===null?null:`CamStack holds ${x.owned}`,x.reserve===null?null:l?`${x.reserve} — less free than that right now, the oldest data here is being deleted`:x.reserve,x.cap===null?null:b?`${x.cap} — already below what is stored here, the oldest is being deleted`:x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:`Kept free`,value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:`CamStack`,value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?`Used`:`Other data`,value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:`Free`,value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?`Drain target`:`Cap`,value:`${N(v.bytes)} · managed by CamStack`,alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:Y(c/r),ownedPercent:f===null?null:Y(f/r),usedPercent:Y(p/r),freePercent:Y(u/r),capPercent:y===null?null:Y(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var Ve={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Z={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function He(e,t){return e===`used`?Ve[t]:Z[e]}function Ue({location:e,ownedBytes:t}){let r=e.capacity??null,i=ye(he(e.config),r?.totalBytes??null),a=Be({totalBytes:r?.totalBytes??null,availableBytes:r?.availableBytes??null},i,{ownedBytes:t??null,cap:Ce(e.config,B(e))});return a.kind===`unknown`?o(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:a.summary,children:a.owned===null?`Capacity unknown`:`Capacity unknown · CamStack holds ${a.owned}`}):n(`div`,{className:`mt-1 space-y-1`,title:a.summary,children:[n(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[a.segments.reservePercent>0&&o(`div`,{className:Z.reserve,style:{width:`${String(a.segments.reservePercent)}%`}}),a.segments.ownedPercent!==null&&o(`div`,{className:Z.owned,style:{width:`${String(a.segments.ownedPercent)}%`}}),o(`div`,{className:Ve[a.severity],style:{width:`${String(a.segments.usedPercent)}%`}}),o(`div`,{className:Z.free,style:{width:`${String(a.segments.freePercent)}%`}}),a.segments.capPercent!==null&&o(`div`,{className:`absolute inset-y-0 w-px ${a.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(a.segments.capPercent)}%`}})]}),o(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:a.legend.map(e=>n(`li`,{className:`flex items-center gap-1`,children:[o(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${He(e.segment,a.severity)}`}),n(`span`,{className:`text-[10px] tabular-nums ${e.alarming?`text-danger`:`text-foreground-subtle`}`,children:[e.label,` `,e.value]})]},e.segment))})]})}var We={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ge={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Ke=`storage.discardLocation`,qe=`storage.discardLocationStatus`,Je=`storage.discardLocationCancel`;function Ye(e){return We[e]??null}function Xe(e){return Ge[e]??null}function Ze(e){return!V(B(e))}function Qe(e,t){return Ye(e.type)===null||!Ze(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var $e=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function et(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!$e.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function tt(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}t();var nt=2e3;function rt({location:e,siblings:t}){return Qe(e,t)?o(it,{location:e}):null}function it({location:e}){let t=A(),r=w(),i=Xe(e.type),[c,l]=a(null),[u,d]=a(null),[f,p]=a(!1);if(s(()=>{if(i===null)return;let e=!1,t=async()=>{try{let t=await r.mutateAsync({addonId:i,action:qe,input:{}});if(e)return;l(et(t))}catch{}};t();let n=setInterval(()=>void t(),nt);return()=>{e=!0,clearInterval(n)}},[i,e.id]),i===null)return null;let m=c!==null&&c.locationId===e.id,h=m&&c.running,_=m&&c.phase!==`idle`,v=async()=>{if(await t({title:`Discard leftovers on "${e.displayName}"?`,message:`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`,confirmLabel:`Discard leftovers`,variant:`danger`})){d(null),p(!0);try{await r.mutateAsync({addonId:i,action:Ke,input:{locationId:e.id}}),l(et(await r.mutateAsync({addonId:i,action:qe,input:{}})))}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}},y=async()=>{try{await r.mutateAsync({addonId:i,action:Je,input:{}})}catch(e){d(e instanceof Error?e.message:String(e))}};return n(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[h?n(`button`,{type:`button`,onClick:()=>void y(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[o(k,{className:`h-3 w-3`}),`Cancel`]}):n(`button`,{type:`button`,onClick:()=>void v(),disabled:f,title:`Permanently delete leftover files on this location. Other locations are not affected.`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[f?o(g,{className:`h-3 w-3 animate-spin`}):o(F,{className:`h-3 w-3`}),`Discard leftovers`]}),_&&c!==null&&n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:o(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${tt(c)}%`}})}),n(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[c.phase,c.camerasTotal>0?` · ${c.camerasDone}/${c.camerasTotal} cam`:``,c.dbRowsDeleted>0?` · ${c.dbRowsDeleted} rows`:``,c.detail?` · ${c.detail}`:``]})]}),(u||m&&c?.error)&&o(`p`,{className:`text-[10px] text-danger leading-tight`,children:u??c?.error})]})}t();var at={active:D,readonly:j,drain:M,disabled:f},ot={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function st({mode:e,open:t,onToggle:r}){let i=U(e),a=at[e];return n(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Location state`,onClick:r,title:i.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${ot[e]}`,children:[o(a,{className:`h-3 w-3`}),i.label,o(l,{className:`h-3 w-3 ${t?`rotate-180`:``}`})]})}function ct({mode:e,blockedReasons:t,onSelect:r,onDismiss:i}){return s(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[i]),n(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":`Location state choices`,children:[n(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Location state`}),o(`button`,{type:`button`,"aria-label":`Close location state choices`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3 w-3`})})]}),H.map(a=>{let s=t[a.mode],c=s!==``,l=at[a.mode],u=a.mode===e;return n(`button`,{type:`button`,role:`radio`,"aria-checked":u,"aria-label":a.label,disabled:c,onClick:()=>{c||(i(),u||r(a.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${c?`cursor-not-allowed opacity-60`:u?`bg-primary/10`:`hover:bg-primary/5`}`,children:[n(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[o(l,{className:`h-3 w-3`}),a.label,u&&o(`span`,{className:`text-[9px] uppercase text-primary`,children:`current`})]}),o(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:a.consequence}),c&&o(`span`,{className:`text-[10px] leading-snug text-warning`,children:s})]},a.mode)})]})}t();function lt(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function ut({location:e,onEdit:t,onDelete:r,onSetMode:i,blockedReasons:s,canDelete:c,siblings:l=[],drain:d,ownedBytes:f}){let[p,m]=a(!1),h=lt(e.config),g=B(e);return n(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[n(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[o(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:o(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e.providerId})}),n(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`text-xs font-medium text-foreground truncate`,children:e.displayName}),h&&o(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:h}),o(Ue,{location:e,ownedBytes:f??null}),d!==void 0&&o(Pe,{drain:d})]})]}),n(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[o(rt,{location:e,siblings:l}),o(st,{mode:g,open:p,onToggle:()=>{m(e=>!e)}}),n(`button`,{onClick:()=>t(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[o(O,{className:`h-3 w-3`}),`Edit`]}),c&&o(`button`,{onClick:()=>r(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:`Delete location`,children:o(u,{className:`h-3 w-3`})})]}),p&&o(ct,{mode:g,blockedReasons:s,onSelect:t=>i(e,t),onDismiss:()=>{m(!1)}})]})}t();function dt({type:e,displayName:t,description:i,cardinality:a,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:f,ownedBytesById:p,drainById:m}){let h=r(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return n(T,{headingId:`storage-location-${e}`,title:t,icon:_,testId:`storage-location-group-${e}`,actions:a===`multi`?n(x,{size:`sm`,type:`button`,onClick:()=>l(e),children:[o(E,{className:`h-3 w-3`}),`Add`]}):void 0,children:[n(`div`,{className:`${c} space-y-2`,children:[n(`div`,{className:`space-y-0.5`,children:[o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e}),i!==void 0&&i!==``&&o(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:i}),a===`single`&&o(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:`Single — one location per type. Edit the existing entry; it can't be split.`})]}),h.length===0&&o(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:a===`multi`?`No location registered. Click "Add" to register one.`:`No location registered yet — should be auto-seeded at next boot.`})]}),h.length>0&&o(`div`,{className:`border-t border-border`,children:h.map(e=>o(ut,{location:e,cardinality:a,canDelete:de(e,h,a),onEdit:u,onDelete:d,onSetMode:f,blockedReasons:ue(e,h),ownedBytes:p?.get(e.id)??null,drain:Ae(je(e),m?.get(e.id)),siblings:h},e.id))})]})}var ft=[`recordings`,`recordingsLow`];function pt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function mt(e,t){if(t===void 0||!ft.includes(e.type))return null;let n=t.find(t=>pt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function ht(e,t){let n=new Map;for(let r of e){let e=mt(r,t);e!==null&&n.set(r.id,e)}return n}export{Oe as a,U as c,Re as i,ce as l,dt as n,Te as o,q as r,pe as s,ht as t,z as u};
1
+ import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{D as c,_t as l,ct as u,gt as d,ht as f,ot as p,yt as m}from"./player-overlays-mP7nvLXZ.js";import{An as h,Ed as g,Fd as _,Fn as v,Gc as y,In as b,Kn as x,Mn as S,Pn as C,Tr as w,U as ee,Vt as T,dd as E,jn as te,ld as D,md as O,mu as k,rl as ne,rr as A}from"./src-BeE19PxU.js";import{t as j}from"./archive-C3YvN3bo.js";import{n as M,t as N}from"./format-size-D8E_VMta.js";import{ei as P}from"./client-D5nV-lIF.js";import{I as re}from"./index-I1VJhtqM.js";var F=m(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]);t();function I(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function ie(e,t){let n=I(t);return`${e}:${n.length>0?n:`default`}`}var ae=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),oe=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function L(e){let t=oe.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?oe.length:t}function R(e){return e.filter(e=>!e.name.startsWith(`.`)&&!ae.has(e.name)).toSorted((e,t)=>{let n=L(e.name)-L(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function se({nodeId:t,value:r,onChange:i}){let c=p().trpcClient,[l,u]=a([]),[d,f]=a(r),[m,h]=a(null),[g,_]=a(null),[v,y]=a(``),b=e(async(e,n)=>{_(null);try{let r=await c.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),f(r.path),n&&i(r.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[c,t,i]);s(()=>{f(r),(async()=>{let e=await c.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){u(R(e.entries)),await b(r.startsWith(`/`)?r:`/`,!1);return}try{let e=await c.filesystemBrowse.listAllowedRoots.query({nodeId:t});u(e),await b(r&&e.some(e=>r.startsWith(e))?r:e[0]??``,!1)}catch(e){u([]),h(null),_(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let x=async()=>{if(!(!v.trim()||!m)){_(null);try{let e=`${m.path.replace(/\/+$/,``)}/${v.trim()}`;await c.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),y(``),await b(m.path,!0)}catch(e){_(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return n(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[o(`div`,{className:`flex flex-wrap gap-1`,children:l.map(e=>o(`button`,{onClick:()=>void b(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),o(`input`,{value:d,onChange:e=>{f(e.target.value),i(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&n(`div`,{className:`text-[10px] text-foreground-subtle`,children:[S(m.freeBytes),` free / `,S(m.totalBytes)]}),o(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(e=>n(`button`,{onClick:()=>void b(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),n(`div`,{className:`flex gap-1`,children:[o(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`new folder`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),o(`button`,{onClick:()=>void x(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:`Create`})]}),g&&o(`div`,{className:`text-[10px] text-red-400`,children:g})]})}t();function z({initialType:e,onClose:t,onCreated:s}){let c=i(),l=p().trpcClient,[u,f]=a(`picker`),[m,_]=a(e),[x,C]=a(null),[w,T]=a({}),[E,D]=a(``),[O,k]=a(null),[A,j]=a(!1),[M,N]=a(`hub`),[P,F]=a(null),[I,ae]=a(!1),oe=e=>T(t=>({...t,basePath:e})),L=typeof w.basePath==`string`?w.basePath:``,R=y(),z=r(()=>{let e=R.data;return Array.isArray(e)?e:[]},[R.data]),B=R.isLoading,V=ne({onSuccess:()=>{c.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),H=r(()=>O!==null&&O.length>0?O:ie(m,E),[m,E,O]),U=async()=>{if(x){ae(!0),F(null);try{F(await(e=>l.storage.testConfig.query(e))({providerId:x.providerId,config:w}))}catch(e){F({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{ae(!1)}}};return o(h,{open:!0,onOpenChange:e=>!e&&t(),children:n(S,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(v,{children:[o(b,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${x?.displayName??``}`,naming:`Add Location — Name`}[u]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,o(`span`,{className:`font-mono`,children:m})]})]}),n(te,{children:[u===`picker`&&n(`div`,{className:`space-y-2`,children:[B&&o(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!B&&z.length===0&&n(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:[`No storage-provider supports type "`,m,`". Install a compatible addon (e.g.`,` `,o(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),z.map(e=>n(`button`,{onClick:()=>{C(e),f(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[o(`p`,{className:`text-xs font-semibold text-foreground`,children:e.displayName}),o(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:e.providerId})]}),o(d,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),u===`config`&&x&&n(`div`,{className:`space-y-3`,children:[o(re,{schema:x.configSchema,values:w,onChange:T}),x.nodeLocal&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(ee,{selectedNodeId:M,onSelect:N,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(se,{nodeId:M,value:L,onChange:oe})]}),P&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${P.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:P.ok?`Connection OK.`:`Test failed: ${P.error??`unknown error`}`}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{U()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?`Testing…`:`Test connection`}),o(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),u===`naming`&&x&&n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`${m} on ${x.displayName}`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1`,children:[n(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[`Id`,` `,o(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:`— auto-derived; override if needed`})]}),o(`input`,{type:`text`,value:H,onChange:e=>k(e.target.value),placeholder:ie(m,E),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,o(`code`,{className:`font-mono`,children:`<type>:<slug>`}),`. Lowercase letters, digits, and hyphens only.`]})]}),n(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[o(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-primary mt-0.5`}),n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`text-xs font-medium text-foreground`,children:`Enable immediately`}),o(`div`,{className:`text-[10px] text-foreground-subtle`,children:`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`})]})]}),V.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:V.error instanceof Error?V.error.message:String(V.error)}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{_(e),C(null),T({}),D(``),k(null),j(!1),F(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),n(`button`,{onClick:()=>{x&&V.mutate({id:H,type:m,displayName:E.trim(),providerId:x.providerId,config:w,enabled:A,nodeId:x.nodeLocal?M:void 0})},disabled:V.isPending||E.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[V.isPending?o(g,{className:`h-3.5 w-3.5 animate-spin`}):null,V.isPending?`Saving…`:`Save`]})]})]})]})]})]})})}function B(e){return P(e)}function V(e){return e===`active`}var H=[{mode:`active`,label:`Active`,consequence:`New data is written here, and the oldest is deleted when the disk fills up.`,requiresConfirmation:!1},{mode:`readonly`,label:`Read-only`,consequence:`Nothing new is written and nothing is ever deleted. A frozen archive that stays on the timeline.`,requiresConfirmation:!1},{mode:`drain`,label:`Drain`,consequence:`Nothing new is written. The oldest data here is deleted, a little at a time, until this location is empty.`,requiresConfirmation:!1},{mode:`disabled`,label:`Disabled`,consequence:`Nothing is written and nothing is read: the footage stored here disappears from the timeline until you turn it back on. Nothing is deleted.`,requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ce(e){return U(e).requiresConfirmation}var le=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:le}}function ue(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function de(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function fe(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function pe(e,t){let n={...t.config??e.config};t.mode!==void 0&&(fe(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:fe(t.mode).enabled}}var me=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function he(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function ge(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function _e(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function ve(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function ye(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*me;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function be(e){return e===`gb`?`GB to keep free`:`% of the volume to keep free`}function xe(e,t=10){return`CamStack keeps ${e.value===null?`${String(t)}% of the volume (the default)`:e.unit===`gb`?`${String(e.value)} GB`:`${String(e.value)}% of the volume`} free on this disk. As it fills up, the OLDEST data stored here is deleted to hold that much free space; if it cannot be held any more, new data goes to another location of the same type instead of filling the disk. Leave the value empty for the default (${String(t)}%).`}function Se(e){return G(e.maxUsedGb)}function Ce(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*me,reason:t===`drain`?`drain`:`legacy`}}t();function we({config:e,defaultPercent:t=10,onChange:r}){let[i,s]=a(()=>he(e).unit),c=ge(e,i),l={unit:i,value:c},u=Se(e),d=t=>{s(t),r(_e(e,{unit:t,value:null}))},f=t=>{r(_e(e,{unit:i,value:ve(t,i)}))};return n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Protected free space`}),n(`div`,{className:`flex items-center gap-2`,children:[n(`select`,{"aria-label":`Protection unit`,value:i,onChange:e=>{d(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[o(`option`,{value:`percent`,children:`% of the volume`}),o(`option`,{value:`gb`,children:`GB of free space`})]}),o(`input`,{type:`number`,"aria-label":be(i),min:0,max:i===`percent`?100:void 0,value:c===null?``:c,placeholder:i===`percent`?String(t):`default`,onChange:e=>{f(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:xe(l,t)}),u!==null&&n(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:[`This location also stores a maximum used size of `,u,` GB. That limit is managed by the system now and is no longer editable here; it is kept as it is.`]})]})}t();function Te({location:e,onClose:t,onSaved:s}){let c=i(),l=p().trpcClient,[u,d]=a({...e.config}),[f,m]=a(e.displayName),[_,w]=a(null),[T,E]=a(!1),D=y(),O=r(()=>{let t=D.data;return Array.isArray(t)?t.find(t=>t.providerId===e.providerId)??null:null},[D.data,e.providerId]),k=ne({onSuccess:()=>{c.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),A=O?.shouldSaveDiskSpace===!0,j=O?.nodeLocal===!0,[M,N]=a(typeof e.nodeId==`string`?e.nodeId:`hub`),P=typeof u.basePath==`string`?u.basePath:``,F=e=>d(t=>({...t,basePath:e})),I=O?.minFreePercent??10,ie=async()=>{E(!0),w(null);try{w(await(e=>l.storage.testConfig.query(e))({providerId:e.providerId,locationId:e.id,config:u}))}catch(e){w({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{E(!1)}};return o(h,{open:!0,onOpenChange:e=>!e&&t(),children:n(S,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(v,{children:[n(b,{children:[`Edit `,e.displayName]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[o(`span`,{className:`font-mono`,children:e.id}),` ·`,` `,O?.displayName??e.providerId]})]}),n(te,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:f,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),O&&o(re,{schema:O.configSchema,values:u,onChange:d}),j&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(ee,{selectedNodeId:M,onSelect:N,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(se,{nodeId:M,value:P,onChange:F})]}),A&&o(we,{config:u,defaultPercent:I,onChange:d}),!O&&!D.isLoading&&n(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Provider `,o(`code`,{className:`font-mono`,children:e.providerId}),` is no longer registered. Field schema unavailable; raw config is preserved on save.`]}),_&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${_.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:_.ok?`Connection OK.`:`Test failed: ${_.error??`unknown error`}`}),k.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:k.error instanceof Error?k.error.message:String(k.error)})]}),n(C,{className:`justify-between`,children:[o(x,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),n(`div`,{className:`flex items-center gap-2`,children:[o(x,{variant:`outline`,size:`sm`,onClick:()=>{ie()},disabled:T||!O,children:T?`Testing…`:`Test connection`}),n(x,{size:`sm`,onClick:()=>{k.mutate(pe(e,{displayName:f.trim(),config:u,nodeId:j?M:e.nodeId}))},disabled:k.isPending||f.trim().length===0,children:[k.isPending?o(g,{className:`h-3.5 w-3.5 animate-spin`}):null,k.isPending?`Saving…`:`Save`]})]})]})]})})}function Ee(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function De(e){if(!Ee(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=K(e.startedAtMs),r=K(e.startBytes),i=K(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:K(e.estimatedEmptyAtMs)}}function Oe(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=De(n);e!==null&&t.set(e.locationId,e)}return t}function ke(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Ae(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:ke(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function je(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Me(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ne(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Pe({drain:e}){if(e.kind===`idle`)return null;if(e.kind===`unreported`)return o(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`,children:`Draining · remaining not reported yet`});if(e.kind===`drained`)return o(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`,children:`Drained · nothing left to move`});let t=e.drainedFraction===null?null:Math.round(e.drainedFraction*100);return n(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[t!==null&&o(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":`Drain progress`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,children:o(`span`,{className:`block h-full bg-warning`,style:{width:`${t}%`}})}),n(`span`,{children:[Me(e.bytesRemaining),` left`,t!==null&&` · ${t}% moved`]}),e.estimatedEmptyAtMs===null?o(`span`,{"data-testid":`drain-eta-absent`,title:`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`,children:`· empty time not known yet`}):n(`span`,{"data-testid":`drain-eta`,children:[`· empty `,Ne(e.estimatedEmptyAtMs)]})]})}var Fe=[`ok`,`warn`,`critical`];function Ie(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Le(e){return Math.min(1,Math.max(0,e))}function q(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Le((n-t)/n);return{fraction:r,severity:Ie(r),recordingsFraction:Le(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Re(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=q(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Fe.indexOf(e.severity)>Fe.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}var ze=`Capacity unknown — nothing measured this volume from here. A remote share, a location on another node, or a mount that did not answer.`;function J(e){return Math.min(1,Math.max(0,e))}function Y(e){return Math.round(J(e)*1e3)/10}function X(e){return`${String(Math.round(J(e)*100))}%`}function Be(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?ze:`${ze} CamStack holds ${e} here.`}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=q({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?J(o/r):m.fraction,g=m===null?Ie(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:`${N(s)} kept free`,owned:f===null||_===null?null:`${N(f)} of recordings (${X(_)})`,cap:v===null?null:v.reason===`drain`?`${N(v.bytes)} drain target (managed by CamStack)`:`${N(v.bytes)} cap (managed by CamStack)`},S=[`${x.freeTotal} free of ${x.total} (${x.freeTotalPercent} free)`,x.owned===null?null:`CamStack holds ${x.owned}`,x.reserve===null?null:l?`${x.reserve} — less free than that right now, the oldest data here is being deleted`:x.reserve,x.cap===null?null:b?`${x.cap} — already below what is stored here, the oldest is being deleted`:x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:`Kept free`,value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:`CamStack`,value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?`Used`:`Other data`,value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:`Free`,value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?`Drain target`:`Cap`,value:`${N(v.bytes)} · managed by CamStack`,alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:Y(c/r),ownedPercent:f===null?null:Y(f/r),usedPercent:Y(p/r),freePercent:Y(u/r),capPercent:y===null?null:Y(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var Ve={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Z={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function He(e,t){return e===`used`?Ve[t]:Z[e]}function Ue({location:e,ownedBytes:t}){let r=e.capacity??null,i=ye(he(e.config),r?.totalBytes??null),a=Be({totalBytes:r?.totalBytes??null,availableBytes:r?.availableBytes??null},i,{ownedBytes:t??null,cap:Ce(e.config,B(e))});return a.kind===`unknown`?o(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:a.summary,children:a.owned===null?`Capacity unknown`:`Capacity unknown · CamStack holds ${a.owned}`}):n(`div`,{className:`mt-1 space-y-1`,title:a.summary,children:[n(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[a.segments.reservePercent>0&&o(`div`,{className:Z.reserve,style:{width:`${String(a.segments.reservePercent)}%`}}),a.segments.ownedPercent!==null&&o(`div`,{className:Z.owned,style:{width:`${String(a.segments.ownedPercent)}%`}}),o(`div`,{className:Ve[a.severity],style:{width:`${String(a.segments.usedPercent)}%`}}),o(`div`,{className:Z.free,style:{width:`${String(a.segments.freePercent)}%`}}),a.segments.capPercent!==null&&o(`div`,{className:`absolute inset-y-0 w-px ${a.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(a.segments.capPercent)}%`}})]}),o(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:a.legend.map(e=>n(`li`,{className:`flex items-center gap-1`,children:[o(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${He(e.segment,a.severity)}`}),n(`span`,{className:`text-[10px] tabular-nums ${e.alarming?`text-danger`:`text-foreground-subtle`}`,children:[e.label,` `,e.value]})]},e.segment))})]})}var We={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ge={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Ke=`storage.discardLocation`,qe=`storage.discardLocationStatus`,Je=`storage.discardLocationCancel`;function Ye(e){return We[e]??null}function Xe(e){return Ge[e]??null}function Ze(e){return!V(B(e))}function Qe(e,t){return Ye(e.type)===null||!Ze(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var $e=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function et(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!$e.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function tt(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}t();var nt=2e3;function rt({location:e,siblings:t}){return Qe(e,t)?o(it,{location:e}):null}function it({location:e}){let t=A(),r=w(),i=Xe(e.type),[c,l]=a(null),[u,d]=a(null),[f,p]=a(!1);if(s(()=>{if(i===null)return;let e=!1,t=async()=>{try{let t=await r.mutateAsync({addonId:i,action:qe,input:{}});if(e)return;l(et(t))}catch{}};t();let n=setInterval(()=>void t(),nt);return()=>{e=!0,clearInterval(n)}},[i,e.id]),i===null)return null;let m=c!==null&&c.locationId===e.id,h=m&&c.running,_=m&&c.phase!==`idle`,v=async()=>{if(await t({title:`Discard leftovers on "${e.displayName}"?`,message:`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`,confirmLabel:`Discard leftovers`,variant:`danger`})){d(null),p(!0);try{await r.mutateAsync({addonId:i,action:Ke,input:{locationId:e.id}}),l(et(await r.mutateAsync({addonId:i,action:qe,input:{}})))}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}},y=async()=>{try{await r.mutateAsync({addonId:i,action:Je,input:{}})}catch(e){d(e instanceof Error?e.message:String(e))}};return n(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[h?n(`button`,{type:`button`,onClick:()=>void y(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[o(k,{className:`h-3 w-3`}),`Cancel`]}):n(`button`,{type:`button`,onClick:()=>void v(),disabled:f,title:`Permanently delete leftover files on this location. Other locations are not affected.`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[f?o(g,{className:`h-3 w-3 animate-spin`}):o(F,{className:`h-3 w-3`}),`Discard leftovers`]}),_&&c!==null&&n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:o(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${tt(c)}%`}})}),n(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[c.phase,c.camerasTotal>0?` · ${c.camerasDone}/${c.camerasTotal} cam`:``,c.dbRowsDeleted>0?` · ${c.dbRowsDeleted} rows`:``,c.detail?` · ${c.detail}`:``]})]}),(u||m&&c?.error)&&o(`p`,{className:`text-[10px] text-danger leading-tight`,children:u??c?.error})]})}t();var at={active:D,readonly:j,drain:M,disabled:f},ot={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function st({mode:e,open:t,onToggle:r}){let i=U(e),a=at[e];return n(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Location state`,onClick:r,title:i.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${ot[e]}`,children:[o(a,{className:`h-3 w-3`}),i.label,o(l,{className:`h-3 w-3 ${t?`rotate-180`:``}`})]})}function ct({mode:e,blockedReasons:t,onSelect:r,onDismiss:i}){return s(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[i]),n(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":`Location state choices`,children:[n(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Location state`}),o(`button`,{type:`button`,"aria-label":`Close location state choices`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3 w-3`})})]}),H.map(a=>{let s=t[a.mode],c=s!==``,l=at[a.mode],u=a.mode===e;return n(`button`,{type:`button`,role:`radio`,"aria-checked":u,"aria-label":a.label,disabled:c,onClick:()=>{c||(i(),u||r(a.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${c?`cursor-not-allowed opacity-60`:u?`bg-primary/10`:`hover:bg-primary/5`}`,children:[n(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[o(l,{className:`h-3 w-3`}),a.label,u&&o(`span`,{className:`text-[9px] uppercase text-primary`,children:`current`})]}),o(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:a.consequence}),c&&o(`span`,{className:`text-[10px] leading-snug text-warning`,children:s})]},a.mode)})]})}t();function lt(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function ut({location:e,onEdit:t,onDelete:r,onSetMode:i,blockedReasons:s,canDelete:c,siblings:l=[],drain:d,ownedBytes:f}){let[p,m]=a(!1),h=lt(e.config),g=B(e);return n(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[n(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[o(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:o(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e.providerId})}),n(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`text-xs font-medium text-foreground truncate`,children:e.displayName}),h&&o(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:h}),o(Ue,{location:e,ownedBytes:f??null}),d!==void 0&&o(Pe,{drain:d})]})]}),n(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[o(rt,{location:e,siblings:l}),o(st,{mode:g,open:p,onToggle:()=>{m(e=>!e)}}),n(`button`,{onClick:()=>t(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[o(O,{className:`h-3 w-3`}),`Edit`]}),c&&o(`button`,{onClick:()=>r(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:`Delete location`,children:o(u,{className:`h-3 w-3`})})]}),p&&o(ct,{mode:g,blockedReasons:s,onSelect:t=>i(e,t),onDismiss:()=>{m(!1)}})]})}t();function dt({type:e,displayName:t,description:i,cardinality:a,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:f,ownedBytesById:p,drainById:m}){let h=r(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return n(T,{headingId:`storage-location-${e}`,title:t,icon:_,testId:`storage-location-group-${e}`,actions:a===`multi`?n(x,{size:`sm`,type:`button`,onClick:()=>l(e),children:[o(E,{className:`h-3 w-3`}),`Add`]}):void 0,children:[n(`div`,{className:`${c} space-y-2`,children:[n(`div`,{className:`space-y-0.5`,children:[o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e}),i!==void 0&&i!==``&&o(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:i}),a===`single`&&o(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:`Single — one location per type. Edit the existing entry; it can't be split.`})]}),h.length===0&&o(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:a===`multi`?`No location registered. Click "Add" to register one.`:`No location registered yet — should be auto-seeded at next boot.`})]}),h.length>0&&o(`div`,{className:`border-t border-border`,children:h.map(e=>o(ut,{location:e,cardinality:a,canDelete:de(e,h,a),onEdit:u,onDelete:d,onSetMode:f,blockedReasons:ue(e,h),ownedBytes:p?.get(e.id)??null,drain:Ae(je(e),m?.get(e.id)),siblings:h},e.id))})]})}var ft=[`recordings`,`recordingsLow`];function pt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function mt(e,t){if(t===void 0||!ft.includes(e.type))return null;let n=t.find(t=>pt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function ht(e,t){let n=new Map;for(let r of e){let e=mt(r,t);e!==null&&n.set(r.id,e)}return n}export{Oe as a,U as c,Re as i,ce as l,dt as n,Te as o,q as r,pe as s,ht as t,z as u};
@@ -16,4 +16,4 @@ const __mfImport = (src) =>
16
16
  await __mfHostInit.__tla;
17
17
  const { initHost } = __mfHostInit;
18
18
  await initHost();
19
- })().then(() => __mfImport("./index-CBIV3kmO.js"));
19
+ })().then(() => __mfImport("./index-I1VJhtqM.js"));
@@ -1 +1 @@
1
- import{I as e,Q as t,S as n,W as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{ku as a}from"./src-BeE19PxU.js";import{$ as o}from"./index-CBIV3kmO.js";function s({staleNodeId:e,shownNodeName:t}){return e===null?null:n(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[i(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),n(`span`,{children:[`This link named node `,i(`span`,{className:`font-medium text-foreground`,children:e}),`, which is not in this cluster. Showing`,` `,i(`span`,{className:`font-medium text-foreground`,children:t}),` instead.`]})]})}t();var c=`node`;function l(e){return[...e].toSorted((e,t)=>e.isHub===t.isHub?e.isOnline===t.isOnline?e.name.localeCompare(t.name):e.isOnline?-1:1:e.isHub?-1:1)}function u(e,t){let n=l(e),r=n[0]??null;if(r===null)return{node:null,outcome:`empty`,staleNodeId:null};if(t===null||t.length===0)return{node:r,outcome:`default`,staleNodeId:null};let i=n.find(e=>e.id===t);return i===void 0?{node:r,outcome:`stale`,staleNodeId:t}:{node:i,outcome:`requested`,staleNodeId:null}}function d(t){let[n,i]=o(),a=n.get(c);return{selection:r(()=>u(t,a),[t,a]),selectNode:e(e=>{let t=new URLSearchParams(n);t.set(c,e),i(t,{replace:!0})},[n,i]),requestedNodeId:a}}export{s as n,d as t};
1
+ import{I as e,Q as t,S as n,W as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{ku as a}from"./src-BeE19PxU.js";import{$ as o}from"./index-I1VJhtqM.js";function s({staleNodeId:e,shownNodeName:t}){return e===null?null:n(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[i(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),n(`span`,{children:[`This link named node `,i(`span`,{className:`font-medium text-foreground`,children:e}),`, which is not in this cluster. Showing`,` `,i(`span`,{className:`font-medium text-foreground`,children:t}),` instead.`]})]})}t();var c=`node`;function l(e){return[...e].toSorted((e,t)=>e.isHub===t.isHub?e.isOnline===t.isOnline?e.name.localeCompare(t.name):e.isOnline?-1:1:e.isHub?-1:1)}function u(e,t){let n=l(e),r=n[0]??null;if(r===null)return{node:null,outcome:`empty`,staleNodeId:null};if(t===null||t.length===0)return{node:r,outcome:`default`,staleNodeId:null};let i=n.find(e=>e.id===t);return i===void 0?{node:r,outcome:`stale`,staleNodeId:t}:{node:i,outcome:`requested`,staleNodeId:null}}function d(t){let[n,i]=o(),a=n.get(c);return{selection:r(()=>u(t,a),[t,a]),selectNode:e(e=>{let t=new URLSearchParams(n);t.set(c,e),i(t,{replace:!0})},[n,i]),requestedNodeId:a}}export{s as n,d as t};
package/dist/index.html CHANGED
@@ -99,7 +99,7 @@
99
99
  })
100
100
  })()
101
101
  </script>
102
- <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-4804e55d.js"></script>
102
+ <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-53adc98f.js"></script>
103
103
  <link rel="modulepreload" crossorigin href="./assets/__vite-browser-external-DF8Eb0aa.js">
104
104
  <link rel="modulepreload" crossorigin href="./assets/client-D5nV-lIF.js">
105
105
  <link rel="modulepreload" crossorigin href="./assets/player-overlays-mP7nvLXZ.js">
@@ -108,7 +108,7 @@
108
108
  <link rel="modulepreload" crossorigin href="./assets/mount-irtdVS9Y.js">
109
109
  <link rel="modulepreload" crossorigin href="./assets/notification-schedule-field-B_0lw5Ql.js">
110
110
  <link rel="stylesheet" crossorigin href="./assets/index-DtcBoptX.css">
111
- <link rel="modulepreload" crossorigin href="./assets/hostInit-iPWvYWG7.js"><link rel="modulepreload" crossorigin href="./assets/index-CBIV3kmO.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-P7nyMvXh.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D6MiVNmX.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BsvPG3BX.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DtoGixA1.js"></head>
111
+ <link rel="modulepreload" crossorigin href="./assets/hostInit-iPWvYWG7.js"><link rel="modulepreload" crossorigin href="./assets/index-I1VJhtqM.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-P7nyMvXh.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D6MiVNmX.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BsvPG3BX.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DtoGixA1.js"></head>
112
112
  <body>
113
113
  <div id="root"></div>
114
114
  <!-- Lock the app shell at 1x zoom. iOS Safari ignores `user-scalable=no`
@@ -52758,7 +52758,7 @@ var AdminUIAddon = class extends BaseAddon {
52758
52758
  capability: adminUiCapability,
52759
52759
  provider: {
52760
52760
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
52761
- getVersion: async () => ({ version: "1.2.396" })
52761
+ getVersion: async () => ({ version: "1.2.397" })
52762
52762
  }
52763
52763
  }];
52764
52764
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.396",
3
+ "version": "1.2.397",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,W as i,a,b as o,o as s,q as c,t as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{ct as f,ot as p,yt as m}from"./player-overlays-mP7nvLXZ.js";import{$ as h,An as g,Cd as _,Ci as v,Ed as y,Fn as b,Hn as x,Ht as ee,In as S,Ki as C,Kn as w,L as te,Mn as T,Mr as E,Nn as D,Q as O,Ql as ne,Si as k,Tn as re,Wn as ie,Yu as A,_i as j,_u as M,bi as N,dd as P,dn as ae,dr as F,gi as I,jn as L,md as R,mf as z,od as B,rr as V,ud as H,wi as oe,xi as U,yi as W,z as se}from"./src-BeE19PxU.js";import{t as ce}from"./monitor-smartphone-CEvv3FjX.js";import{Cr as le,Nt as ue,tr as de}from"./client-D5nV-lIF.js";import{t as fe}from"./useTranslation-Bc5yH9V9.js";import{$ as pe,C as me,I as he,Z as ge,s as _e}from"./index-CBIV3kmO.js";import{t as ve}from"./AdminSectionedPage-LBOgOUcc.js";import{t as ye}from"./NodeAddonsSettingsPanel-Cowue7E1.js";import{t as be}from"./BrokerForm-BgDrpr2d.js";import{n as G,r as xe,t as Se}from"./AddonIntegrationBody-BlFQPEEQ.js";var Ce=m(`recycle`,[[`path`,{d:`M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5`,key:`x6z5xu`}],[`path`,{d:`M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12`,key:`1x4zh5`}],[`path`,{d:`m14 16-3 3 3 3`,key:`f6jyew`}],[`path`,{d:`M8.293 13.596 7.196 9.5 3.1 10.598`,key:`wf1obh`}],[`path`,{d:`m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843`,key:`9tzpgr`}],[`path`,{d:`m13.378 9.633 4.096 1.098 1.097-4.096`,key:`1oe83g`}]]);n();var K=`kind`,q=`name`,J=`restore`,Y=`restoreId`;function we(e){return{sections:[{id:`broker-identity`,title:`Broker`,columns:1,fields:[{type:`select`,key:K,label:`Kind`,options:e.map(e=>({value:e.key,label:e.label})),disabled:e.length<=1},{type:`text`,key:q,label:`Name`,placeholder:`My Home Assistant`,required:!0},{type:`boolean`,key:J,label:`Restore a broker that was removed, under its original id`,description:`Devices remember the broker id they were discovered under, so restoring the original id reconnects them instead of needing re-discovery. An id that is still in use is refused.`},{type:`text`,key:Y,label:`Original broker id`,placeholder:`ha_004`,required:!0,showWhen:{field:J,equals:!0}}]}]}}function Te(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(K);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(q);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(Y);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}var Ee={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function X(e){return Ee[e]??e}function De(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var Oe={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function ke({status:e}){return u(F,{variant:Oe[e],className:`text-[10px]`,children:e})}function Ae(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function je({title:e,subtitle:t,onClose:n,children:i}){return u(g,{open:!0,onOpenChange:e=>!e&&n(),children:r(T,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(b,{children:[u(S,{children:e}),t&&u(D,{children:t})]}),u(L,{className:`space-y-3 pr-1`,children:i})]})})}function Me({kinds:e,onClose:t,onDone:n}){let a=s(),o=i(()=>we(e.map(e=>({key:Z(e),label:e.label}))),[e]),[l,d]=c(()=>({[K]:Z(e[0]),[q]:``,[J]:!1,[Y]:``})),[f,p]=c(null),m=e.find(e=>Z(e)===l.kind)??e[0],h=m?.kind??``,g=m?.addonId,_=I({onSuccess:()=>{a.invalidateQueries({queryKey:[[`broker`,`list`]]}),n()}}),v=e=>{let t=Te(l);if(!t.ok){p(t.problem);return}p(null);let{name:n,restoreId:r}=t.identity;_.mutate({kind:h,name:n,settings:e,...r===null?{}:{id:r},...g===void 0?{}:{addonId:g}})};return r(je,{title:`Add broker`,subtitle:`Register a message broker for exporters and automations.`,onClose:_.isPending?()=>{}:t,children:[u(he,{schema:o,values:l,onChange:d}),f!==null&&u(x,{message:f}),_.isError&&u(x,{message:_.error instanceof Error?_.error.message:String(_.error)}),h&&u(be,{kind:h,...g===void 0?{}:{addonId:g},onSubmit:v,onCancel:t,submitLabel:_.isPending?`Adding…`:`Add broker`,disabled:_.isPending},Z(m))]})}function Z(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Ne({broker:e,onClose:t,onDone:n}){let a=s(),o=j({id:e.id,addonId:e.addonId}),c=v({onSuccess:()=>{a.invalidateQueries({queryKey:[[`broker`,`list`]]}),a.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),n()}}),l=i(()=>{let e=o.data;return e&&typeof e==`object`?{...e}:{}},[o.data]);return u(je,{title:`Edit ${e.name}`,subtitle:`${X(e.kind)} · ${e.id}`,onClose:c.isPending?()=>{}:t,children:o.isLoading?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(y,{className:`h-3.5 w-3.5 animate-spin`}),` Loading settings…`]}):o.isError?r(`div`,{className:`space-y-3`,children:[u(x,{message:`Failed to load settings: ${o.error instanceof Error?o.error.message:`Unknown error`}`}),u(`div`,{className:`flex justify-end`,children:u(w,{variant:`outline`,size:`sm`,onClick:t,children:`Close`})})]}):r(`div`,{className:`space-y-3`,children:[c.isError&&u(x,{message:c.error instanceof Error?c.error.message:String(c.error)}),u(be,{kind:e.kind,addonId:e.addonId,initialValues:l,onSubmit:t=>{c.mutate({id:e.id,settings:t,addonId:e.addonId})},onCancel:t,submitLabel:c.isPending?`Saving…`:`Save`,disabled:c.isPending})]})})}function Pe({broker:e,onEdit:t}){let n=s(),i=V(),[a,o]=c(null),l=oe({onSuccess:e=>o(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>o({ok:!1,error:e instanceof Error?e.message:String(e)})}),d=k({onSuccess:()=>{n.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),p=async()=>{await i({title:`Delete broker`,message:`Delete broker "${e.name}"? Integrations that depend on it will stop working.`,confirmLabel:`Delete`,variant:`danger`})&&d.mutate({id:e.id,addonId:e.addonId})};return r(`tr`,{className:`border-b border-border last:border-0`,children:[u(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:e.name}),u(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:X(e.kind)}),r(`td`,{className:`px-3 py-2`,children:[u(ke,{status:e.status}),a&&u(`span`,{className:`ml-2 text-[10px] ${a.ok?`text-success`:`text-danger`}`,children:a.ok?`OK`:a.error??`failed`})]}),u(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`flex items-center justify-end gap-1.5`,children:[r(w,{variant:`outline`,size:`sm`,onClick:()=>l.mutate({id:e.id,addonId:e.addonId}),disabled:l.isPending,title:`Test connection`,children:[l.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(M,{className:`h-3 w-3`}),`Test`]}),r(w,{variant:`outline`,size:`sm`,onClick:()=>t(e),title:`Edit`,children:[u(R,{className:`h-3 w-3`}),` Edit`]}),r(w,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{p()},disabled:d.isPending,title:`Delete`,children:[d.isPending?u(y,{className:`h-3 w-3 animate-spin`}):u(f,{className:`h-3 w-3`}),`Delete`]})]})})]})}function Fe({addonId:e}={}){let t=N({}),n=U(),a=i(()=>Ae(t.data).filter(t=>e===void 0||t.addonId===e),[t.data,e]),[o,s]=c(!1),[l,d]=c(null),f=i(()=>{let t=new Map;for(let r of De(n.data))if(!(e!==void 0&&r.addonId!==e))for(let e of r.kinds)t.set(`${r.addonId}::${e.kind}`,{addonId:r.addonId,kind:e.kind,label:e.label});for(let e of a)[...t.values()].some(t=>t.kind===e.kind)||t.set(`::${e.kind}`,{kind:e.kind,label:X(e.kind)});return[...t.values()]},[a,n.data,e]);return r(`div`,{className:`space-y-3`,children:[u(`div`,{className:`flex items-center justify-end`,children:r(w,{variant:`primary`,size:`sm`,onClick:()=>s(!0),disabled:f.length===0,title:f.length===0?`No broker providers available`:void 0,children:[u(P,{className:`h-3.5 w-3.5`}),` Add broker`]})}),u(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:r(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[u(`thead`,{children:r(`tr`,{className:`border-b border-border bg-background/50`,children:[u(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Name`}),u(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Kind`}),u(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Status`}),u(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Actions`})]})}),r(`tbody`,{children:[t.isLoading&&u(`tr`,{children:r(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[u(y,{className:`inline h-4 w-4 animate-spin`}),` Loading brokers…`]})}),t.isError&&u(`tr`,{children:r(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[`Failed to load brokers:`,` `,t.error instanceof Error?t.error.message:`Unknown error`]})}),!t.isLoading&&!t.isError&&a.length===0&&u(`tr`,{children:u(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:`No brokers registered yet. Add one to publish device events for downstream automations.`})}),a.map(e=>u(Pe,{broker:e,onEdit:d},e.id))]})]})}),o&&u(Me,{kinds:f,onClose:()=>s(!1),onDone:()=>s(!1)}),l&&u(Ne,{broker:l,onClose:()=>d(null),onDone:()=>d(null)})]})}function Ie(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function Le(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(Ie).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function Re(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function ze(e,t){return t.find(t=>e.capNames.includes(t))??null}function Be(e){switch(e){case`running`:return{state:`ok`,label:`running`};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:`stopped`};default:return{state:`unknown`,label:e??`unknown`}}}n();var Ve=[`wasteCollections`,`listSources`],He=[`wasteCollections`,`sourceFormSchema`],Q={label:`New source`,module:`ics`,argsJson:`{}`,enabled:!0},Ue=/^[a-z0-9][a-z0-9-]{0,63}$/;function We(e){return e instanceof Error?e.message:String(e)}function Ge(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function Ke(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`argsJson`),o=Reflect.get(n,`enabled`),s=Reflect.get(n,`formValues`);t.push({id:e,label:r,module:i,argsJson:typeof a==`string`?a:`{}`,enabled:typeof o==`boolean`?o:!0,formValues:typeof s==`object`&&s&&!Array.isArray(s)?s:void 0})}return t}function qe({addonId:n,capName:m}){let h=p(),g=s(),_=V(),v=te({editKey:`wasteEdit`,newKey:`wasteNew`}),[y,b]=c(!1),[x,S]=c(null),[C,T]=c(``),[E,D]=c({...Q}),O=t(null),k=e((e,t)=>h.trpcClient.addons.custom.mutate({addonId:n,action:e,input:t}),[n,h]),A=a({queryKey:[...Ve,n],queryFn:async()=>Ke(await k(`listSources`,{}))}),j=a({queryKey:[...He,n],queryFn:async()=>k(`sourceFormSchema`,{})}),M=A.data??[],N=Ge(j.data)?j.data:void 0,I=v.state,L=I.mode===`edit`?M.find(e=>e.id===I.id)??null:null;d(()=>{if(v.state.mode===`edit`&&L!==null){let e=`edit:${L.id}`;if(O.current===e)return;O.current=e,S(null),T(L.id),D(L.formValues===void 0?{...Q}:{...L.formValues});return}if(v.state.mode===`new`){if(O.current===`new`)return;O.current=`new`,S(null),T(``),D({...Q})}},[L,v.state]);let R=e(async()=>{await g.invalidateQueries({queryKey:Ve})},[g]),z=l({mutationFn:async e=>k(`deleteSource`,{id:e}),onSuccess:async()=>R()}),B=e(async e=>{await _({title:`Delete waste source?`,message:`Remove “${e.label}” (${e.id}). Its calendar under System → Calendars is dropped.`,confirmLabel:`Delete`,cancelLabel:`Cancel`,variant:`danger`})&&(await z.mutateAsync(e.id),v.state.mode===`edit`&&v.state.id===e.id&&(v.close(),O.current=null))},[_,z,v]),H=e(async()=>{let e=E.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){S(`Label is required.`);return}let n=v.state.mode===`new`,r=n?C.trim():L?.id??``;if(n&&!Ue.test(r)){S(`Source id must be a lowercase slug (e.g. ics-home, junker).`);return}if(r===``){S(`That source is no longer available.`);return}let i=E.module,a=E.argsJson,o=E.enabled;b(!0),S(null);try{n&&await k(`createSource`,{id:r,label:t}),await k(`updateSource`,{id:r,label:t,module:typeof i==`string`?i:`ics`,argsJson:typeof a==`string`?a:`{}`,enabled:typeof o==`boolean`?o:!0}),await R(),v.close(),O.current=null}catch(e){S(We(e))}finally{b(!1)}},[k,L?.id,v,E,R,C]),oe=i(()=>[{key:`id`,header:`Id`,sortValue:e=>e.id,render:e=>u(`span`,{className:`font-mono text-xs text-foreground`,children:e.id})},{key:`label`,header:`Label`,sortValue:e=>e.label,render:e=>u(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:`Module`,sortValue:e=>e.module,render:e=>u(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:`Enabled`,sortValue:e=>+!!e.enabled,render:e=>u(F,{variant:e.enabled?`success`:`default`,children:e.enabled?`On`:`Off`})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>u(w,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":`Delete ${e.label}`,"data-testid":`waste-source-delete-${e.id}`,onClick:t=>{t.stopPropagation(),B(e)},children:u(f,{className:`h-3.5 w-3.5 text-danger`})})}],[B]),U=v.state.mode===`new`,W=U||L!==null,ce=U?`new`:L===null?`closed`:`edit:${L.id}`;return r(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[r(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[u(`p`,{className:`text-sm text-foreground-muted`,children:`Each row is one HACS waste source (calendar under System → Calendars).`}),r(w,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>v.openNew(),children:[u(P,{className:`h-3.5 w-3.5`}),`Add source`]})]}),A.isError?u(`p`,{className:`text-sm text-danger`,children:`Could not load sources.`}):null,A.isPending?u(ie,{className:`h-32 w-full`}):u(ee,{columns:oe,rows:M,rowKey:e=>e.id,pageSize:25,mobileMode:`scroll`,emptyMessage:`No waste sources yet. Add one to register a HACS provider.`,onRowClick:e=>v.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),u(se,{open:W,onClose:()=>{v.close(),S(null),O.current=null},title:U?`Add waste source`:`Edit ${L?.label??`source`}`,icon:Ce,width:`xl`,testId:`waste-source-editor`,error:x,footer:u(w,{type:`button`,size:`sm`,disabled:y||U&&C.trim()===``,onClick:()=>void H(),children:y?`Saving…`:`Save`}),children:W?r(o,{children:[U?r(`div`,{children:[u(ae,{htmlFor:`waste-source-id`,children:`Source id`}),u(ne,{id:`waste-source-id`,value:C,onChange:e=>T(e.target.value),placeholder:`ics-home`,autoComplete:`off`}),u(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:`Stable calendar local id. Renaming is not supported after save.`})]}):r(`p`,{className:`text-sm text-foreground-muted`,children:[`Source id: `,u(`span`,{className:`font-mono`,children:L?.id})]}),N===void 0?u(`p`,{className:`text-sm text-foreground-muted`,children:`Loading form…`}):u(re,{schema:N,values:E,onChange:D,bare:!0},ce)]}):null}),u(ye,{nodeId:`hub`,addonIds:[n],level:`global`,capability:m,hideSectionChrome:!0})]})}n();var $=1e4,Je={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},Ye=[{sectionId:`exporters`,kind:`device-export`,label:`Exporters`,icon:A,installLabel:`Add export`,emptyTitle:`No device exporters installed`,emptyDescription:`Install an export addon to publish devices to Alexa, HomeKit, Google Home or Home Assistant.`},{sectionId:`email`,kind:`email`,label:`Email`,icon:_,installLabel:`Add email provider`,emptyTitle:`No email providers installed`,emptyDescription:`Install an SMTP or Gmail addon to send notification email from this hub.`},{sectionId:`brokers`,kind:`broker`,label:`Brokers`,icon:B,installLabel:`Add broker addon`,emptyTitle:`No message brokers installed`,emptyDescription:`Install a broker addon to connect Home Assistant, Homematic, MQTT, Matter and similar systems.`},{sectionId:`calendars`,kind:`calendar`,label:`Calendars`,icon:z,installLabel:`Add calendar source`,emptyTitle:`No calendar sources installed`,emptyDescription:`Install a calendar-source addon (Google Calendar, waste collections, …) to feed System → Calendars.`}];function Xe(e,t,n){let i=Re(ue,e.kind),a=t.flatMap(t=>{let a=ze(t,i);if(a===null)return[];let s=Be(t.processState);return[{id:t.addonId,name:t.displayName,fallbackIcon:e.icon,state:s.state,stateLabel:s.label,render:()=>u(Se,{addonId:t.addonId,displayName:t.displayName,capName:a,isActive:t.processState===`running`,badges:r(o,{children:[u(et,{processState:t.processState}),u(tt,{kind:e.kind,addonId:t.addonId})]}),lead:e.kind===`device-export`?u(h,{addonId:t.addonId}):void 0,panels:$e(e.kind,t.addonId,e=>n(`/devices/${e}`)),settingsContent:t.addonId===`waste-collections`?u(qe,{addonId:t.addonId,capName:a}):void 0})}]});return{id:e.sectionId,label:e.label,entries:a,install:{capability:i[0]??e.kind,label:e.installLabel}}}function Ze({descriptor:e,rows:t,isLoading:n}){let r=ge(),a=i(()=>Xe(e,t,r),[e,t,r]);return u(xe,{embedded:!0,icon:e.icon,title:e.label,subtitle:null,groups:[a],isLoading:n,emptyTitle:e.emptyTitle,emptyDescription:e.emptyDescription})}function Qe(){let{t:e}=fe(),t=E(void 0,{refetchInterval:$}),[n,r]=pe(),a=me(`/system/integrations`,{t:e,isAdmin:!0})??{icon:H,title:`Connectivity`};d(()=>{let e=n.get(`tab`);if(e===null)return;let t=Je[e];t===void 0||t===e||r(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[n,r]);let o=i(()=>(t.data??[]).map(Le).filter(e=>e!==null),[t.data]),s=i(()=>Ye.map(e=>({id:e.sectionId,label:e.label,ownedParams:_e,content:u(Ze,{descriptor:e,rows:o,isLoading:t.isLoading})})),[t.isLoading,o]);return u(ve,{icon:a.icon,title:a.title,subtitle:`External systems this hub talks to — exporters, email, brokers and calendar sources.`,defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:s})}function $e(e,t,n){return e===`device-export`?[{id:`devices`,title:`Devices`,icon:ce,placement:`end`,content:u(O,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:`Connections`,icon:B,content:u(Fe,{addonId:t})}]:[]}function et({processState:e}){let{state:t,label:n}=Be(e);return u(F,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${G} capitalize`,children:n})}function tt({kind:e,addonId:t}){return e===`broker`?u(nt,{addonId:t}):e===`device-export`?u(rt,{addonId:t}):null}function nt({addonId:e}){let{data:t}=W({addonId:e},{refetchInterval:$,retry:!1}),n=le.safeParse(t);if(!n.success)return null;let{brokerCount:r,connectedCount:i}=n.data;return u(F,{variant:`info`,className:G,children:`${r} connection${r===1?``:`s`}${i>0?` · ${i} connected`:``}`})}function rt({addonId:e}){let{data:t}=C({addonId:e},{refetchInterval:$,retry:!1}),n=de.safeParse(t);if(!n.success)return null;let{linkState:r,exposedDeviceCount:i}=n.data;return u(F,{variant:r===`linked`?`success`:r===`error`?`danger`:`default`,className:G,children:`${r} · ${i} exposed`})}export{Qe as IntegrationsPage};