@camstack/addon-admin-ui 1.2.360 → 1.2.361
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.
- package/dist/assets/{AddonAssetIcon-YfrTWCUl.js → AddonAssetIcon-BqaHfotc.js} +1 -1
- package/dist/assets/{Addons-CBnmHNZd.js → Addons-CxtsUwd-.js} +1 -1
- package/dist/assets/{AdminTabs-FluZSCkZ.js → AdminTabs-CtepdqLQ.js} +1 -1
- package/dist/assets/{AiProfiles-C55fwqpv.js → AiProfiles-B94hwznd.js} +1 -1
- package/dist/assets/{BrokerForm-DNKfcMGY.js → BrokerForm-Czgk7niw.js} +1 -1
- package/dist/assets/{Build-B-W3MTQ_.js → Build-DJv8Q7RC.js} +1 -1
- package/dist/assets/{Cluster-CcgeafgM.js → Cluster-uFbuOt6w.js} +2 -2
- package/dist/assets/{ClusterStepModel-Dt5sbcMn.js → ClusterStepModel-CgV7U9W7.js} +1 -1
- package/dist/assets/{CompositionEditorPage-DWnecyHu.js → CompositionEditorPage-CXzhjtAY.js} +1 -1
- package/dist/assets/{Data-1Pmkjzqu.js → Data-CyCgHa4Z.js} +1 -1
- package/dist/assets/{DetectionIntelligence-BAjtF-QJ.js → DetectionIntelligence-Dz2Yg3OR.js} +1 -1
- package/dist/assets/{DeviceDetail-jUxcl2dt.js → DeviceDetail-BqCIrv2G.js} +1 -1
- package/dist/assets/{Devices-Fd7nZ5MC.js → Devices-B2n8xhU-.js} +1 -1
- package/dist/assets/{Events-Cf6mlR2q.js → Events-CPJq_UOf.js} +1 -1
- package/dist/assets/Identity-CxmCyQMb.js +1 -0
- package/dist/assets/{IntegrationDetail-ua-c941Y.js → IntegrationDetail-oI9eWrmh.js} +1 -1
- package/dist/assets/{IntegrationHub-Blksb596.js → IntegrationHub-BOS7utnP.js} +1 -1
- package/dist/assets/{Integrations-C2jeLxC2.js → Integrations-B5P-5Hg1.js} +1 -1
- package/dist/assets/{Integrations-DHz0PMI_.js → Integrations-zd6QdgbJ.js} +1 -1
- package/dist/assets/{Locations-Bz7z6CMI.js → Locations-tWuxA70d.js} +1 -1
- package/dist/assets/{Logs-D4FH_1l6.js → Logs-cJreijVA.js} +1 -1
- package/dist/assets/{MyAccess-CrOZJPf0.js → MyAccess-iKEtdx-n.js} +1 -1
- package/dist/assets/{Network-Dv-UU8In.js → Network-DHiOcYq9.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CB1W9PlU.js → NodeAddonsSettingsPanel-z1Rnf5Mv.js} +1 -1
- package/dist/assets/{Notifications-ho1y5DBh.js → Notifications-6ghyHDQv.js} +1 -1
- package/dist/assets/ReauthDialog-Bwmw8BqX.js +1 -0
- package/dist/assets/{Recordings-BDpqJ0d4.js → Recordings-DEJYb4ew.js} +1 -1
- package/dist/assets/{ScanNetworkModal-aJXdvOqO.js → ScanNetworkModal-4YoDLgmw.js} +1 -1
- package/dist/assets/{Scenes-DloxAJU0.js → Scenes-CIojBsO_.js} +1 -1
- package/dist/assets/{Showroom-q5YYwjHY.js → Showroom-DbSD_X0x.js} +1 -1
- package/dist/assets/{System-kbKQ9CVD.js → System-Ckdp79u7.js} +1 -1
- package/dist/assets/{Terminal-DKuH4tew.js → Terminal-BXRx4MCn.js} +1 -1
- package/dist/assets/{device-integration-icon-WPgnLRa8.js → device-integration-icon-YPRD4PoU.js} +1 -1
- package/dist/assets/{index-CArA6N_R.js → index-GnPOi642.js} +2 -2
- package/dist/assets/{location-owned-usage-wj2Taghd.js → location-owned-usage-BHU251Xt.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-e3bab662.js → mf-entry-bootstrap-0-4a63c292.js} +1 -1
- package/dist/assets/{useNodeUrlSelection-B4wkx7sG.js → useNodeUrlSelection-BgU9x-pG.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Identity-6bcQFaXB.js +0 -1
- package/dist/assets/ReauthDialog-DSMlzJbr.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{at as c,gt as l,ht as u,mt as d,st as f,vt as p}from"./player-overlays-rpfoGg2b.js";import{Au as m,Dd as h,F as g,Td as _,Un as v,Vd as y,_l as b,al as x,dr as S,kd as C}from"./src-BQ0U3gDQ.js";import{t as w}from"./archive-Bxuu4XK_.js";import{t as T}from"./hard-drive-download-CHmTG4FF.js";import{Zr as E}from"./client-CwOJLD7X.js";import{F as ee}from"./index-CArA6N_R.js";import{t as D}from"./format-size-DIxKXxtj.js";var O=p(`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 k(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function te(e,t){let n=k(t);return`${e}:${n.length>0?n:`default`}`}var A=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`]),j=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function M(e){let t=j.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?j.length:t}function N(e){return e.filter(e=>!e.name.startsWith(`.`)&&!A.has(e.name)).toSorted((e,t)=>{let n=M(e.name)-M(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function ne({nodeId:t,value:r,onChange:i}){let l=c().trpcClient,[u,d]=a([]),[f,p]=a(r),[m,h]=a(null),[g,_]=a(null),[v,y]=a(``),b=e(async(e,n)=>{_(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&i(r.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[l,t,i]);s(()=>{p(r),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(N(e.entries)),await b(r.startsWith(`/`)?r:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await b(r&&e.some(e=>r.startsWith(e))?r:e[0]??``,!1)}catch(e){d([]),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 l.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:u.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:f,onChange:e=>{p(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 P({initialType:e,onClose:t,onCreated:s}){let l=i(),d=c().trpcClient,[f,p]=a(`picker`),[h,_]=a(e),[v,S]=a(null),[C,w]=a({}),[T,E]=a(``),[D,O]=a(null),[k,A]=a(!1),[j,M]=a(`hub`),[N,P]=a(null),[F,I]=a(!1),L=e=>w(t=>({...t,basePath:e})),R=typeof C.basePath==`string`?C.basePath:``,z=x(),B=r(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=b({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),U=r(()=>D!==null&&D.length>0?D:te(h,T),[h,T,D]),W=async()=>{if(v){I(!0),P(null);try{P(await(e=>d.storage.testConfig.query(e))({providerId:v.providerId,config:C}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`div`,{className:`space-y-0.5`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:{picker:`Add Location — Pick provider`,config:`Add Location — ${v?.displayName??``}`,naming:`Add Location — Name`}[f]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,o(`span`,{className:`font-mono`,children:h})]})]}),o(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:o(m,{className:`h-4 w-4`})})]}),f===`picker`&&n(`div`,{className:`p-4 space-y-2`,children:[V&&o(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!V&&B.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 "`,h,`". Install a compatible addon (e.g.`,` `,o(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),B.map(e=>n(`button`,{onClick:()=>{S(e),p(`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(u,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),f===`config`&&v&&n(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,children:[o(ee,{schema:v.configSchema,values:C,onChange:w}),v.nodeLocal&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(g,{selectedNodeId:j,onSelect:M,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(ne,{nodeId:j,value:R,onChange:L})]}),N&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${N.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:N.ok?`Connection OK.`:`Test failed: ${N.error??`unknown error`}`}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`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:()=>{W()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?`Testing…`:`Test connection`}),o(`button`,{onClick:()=>p(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),f===`naming`&&v&&n(`div`,{className:`p-4 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:T,onChange:e=>E(e.target.value),placeholder:`${h} on ${v.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:U,onChange:e=>O(e.target.value),placeholder:te(h,T),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:k,onChange:e=>A(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.`})]})]}),H.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:H.error instanceof Error?H.error.message:String(H.error)}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`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),S(null),w({}),E(``),O(null),A(!1),P(null),p(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),n(`button`,{onClick:()=>{v&&H.mutate({id:U,type:h,displayName:T.trim(),providerId:v.providerId,config:C,enabled:k,nodeId:v.nodeLocal?j:void 0})},disabled:H.isPending||T.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:[H.isPending?o(y,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?`Saving…`:`Save`]})]})]})]})]})})}function F(e){return E(e)}function I(e){return e===`active`}var L=[{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 R(e){return L.find(t=>t.mode===e)??L[0]}function z(e){return R(e).requiresConfirmation}var B=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function V(e,t,n){return I(n)||!I(F(e))||t.some(t=>t.id!==e.id&&I(F(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:B}}function H(e,t){return{active:V(e,t,`active`).reason,readonly:V(e,t,`readonly`).reason,drain:V(e,t,`drain`).reason,disabled:V(e,t,`disabled`).reason}}function U(e,t,n){return!(n===`single`||t.length<=1||I(F(e))&&t.filter(e=>I(F(e))).length<=1)}function W(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function re(e,t){let n={...t.config??e.config};t.mode!==void 0&&(W(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:W(t.mode).enabled}}var ie=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ae(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 oe(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function se(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 ce(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 le(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ie;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function ue(e){return e===`gb`?`GB to keep free`:`% of the volume to keep free`}function de(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 fe(e){return G(e.maxUsedGb)}function pe(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ie,reason:t===`drain`?`drain`:`legacy`}}t();function me({config:e,defaultPercent:t=10,onChange:r}){let[i,s]=a(()=>ae(e).unit),c=oe(e,i),l={unit:i,value:c},u=fe(e),d=t=>{s(t),r(se(e,{unit:t,value:null}))},f=t=>{r(se(e,{unit:i,value:ce(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":ue(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:de(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 he({location:e,onClose:t,onSaved:s}){let l=i(),u=c().trpcClient,[d,f]=a({...e.config}),[p,h]=a(e.displayName),[_,v]=a(null),[S,C]=a(!1),w=x(),T=r(()=>{let t=w.data;return Array.isArray(t)?t.find(t=>t.providerId===e.providerId)??null:null},[w.data,e.providerId]),E=b({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),D=T?.shouldSaveDiskSpace===!0,O=T?.nodeLocal===!0,[k,te]=a(typeof e.nodeId==`string`?e.nodeId:`hub`),A=typeof d.basePath==`string`?d.basePath:``,j=e=>f(t=>({...t,basePath:e})),M=T?.minFreePercent??10,N=async()=>{C(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:e.providerId,locationId:e.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{C(!1)}};return o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`div`,{className:`space-y-0.5`,children:[n(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Edit `,e.displayName]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[o(`span`,{className:`font-mono`,children:e.id}),` ·`,` `,T?.displayName??e.providerId]})]}),o(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:o(m,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,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:p,onChange:e=>h(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`})]}),T&&o(ee,{schema:T.configSchema,values:d,onChange:f}),O&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(g,{selectedNodeId:k,onSelect:te,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(ne,{nodeId:k,value:A,onChange:j})]}),D&&o(me,{config:d,defaultPercent:M,onChange:f}),!T&&!w.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`}`}),E.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:E.error instanceof Error?E.error.message:String(E.error)})]}),n(`div`,{className:`flex items-center justify-between gap-2 border-t border-border px-4 py-3`,children:[o(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{N()},disabled:S||!T,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:S?`Testing…`:`Test connection`}),n(`button`,{onClick:()=>{E.mutate(re(e,{displayName:p.trim(),config:d,nodeId:O?k:e.nodeId}))},disabled:E.isPending||p.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:[E.isPending?o(y,{className:`h-3.5 w-3.5 animate-spin`}):null,E.isPending?`Saving…`:`Save`]})]})]})]})})}function ge(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(e){if(!ge(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 ve(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=_e(n);e!==null&&t.set(e.locationId,e)}return t}function ye(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 be(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:ye(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function xe(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Se(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ce(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function we({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:[Se(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 `,Ce(e.estimatedEmptyAtMs)]})]})}var Te=[`ok`,`warn`,`critical`];function Ee(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function De(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=De((n-t)/n);return{fraction:r,severity:Ee(r),recordingsFraction:De(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Oe(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||Te.indexOf(e.severity)>Te.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}var ke=`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 Ae(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:D(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?ke:`${ke} 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?Ee(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:D(r),freeTotal:D(a),freeTotalPercent:X(a/r),used:D(p),usedPercent:X(p/r),free:D(u),freePercent:X(u/r),reserve:s===0?null:`${D(s)} kept free`,owned:f===null||_===null?null:`${D(f)} of recordings (${X(_)})`,cap:v===null?null:v.reason===`drain`?`${D(v.bytes)} drain target (managed by CamStack)`:`${D(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:D(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:`${D(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 je={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 Me(e,t){return e===`used`?je[t]:Z[e]}function Ne({location:e,ownedBytes:t}){let r=e.capacity??null,i=le(ae(e.config),r?.totalBytes??null),a=Ae({totalBytes:r?.totalBytes??null,availableBytes:r?.availableBytes??null},i,{ownedBytes:t??null,cap:pe(e.config,F(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:je[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 ${Me(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 Pe={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Fe={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Ie=`storage.discardLocation`,Le=`storage.discardLocationStatus`,Re=`storage.discardLocationCancel`;function ze(e){return Pe[e]??null}function Be(e){return Fe[e]??null}function Ve(e){return!I(F(e))}function He(e,t){return ze(e.type)===null||!Ve(e)?!1:t.some(t=>t.id!==e.id&&I(F(t)))}var Ue=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 We(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`||!Ue.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 Ge(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 Ke=2e3;function qe({location:e,siblings:t}){return He(e,t)?o(Je,{location:e}):null}function Je({location:e}){let t=v(),r=S(),i=Be(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:Le,input:{}});if(e)return;l(We(t))}catch{}};t();let n=setInterval(()=>void t(),Ke);return()=>{e=!0,clearInterval(n)}},[i,e.id]),i===null)return null;let h=c!==null&&c.locationId===e.id,g=h&&c.running,_=h&&c.phase!==`idle`,b=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:Ie,input:{locationId:e.id}}),l(We(await r.mutateAsync({addonId:i,action:Le,input:{}})))}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}},x=async()=>{try{await r.mutateAsync({addonId:i,action:Re,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:[g?n(`button`,{type:`button`,onClick:()=>void x(),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(m,{className:`h-3 w-3`}),`Cancel`]}):n(`button`,{type:`button`,onClick:()=>void b(),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(y,{className:`h-3 w-3 animate-spin`}):o(O,{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:`${Ge(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||h&&c?.error)&&o(`p`,{className:`text-[10px] text-danger leading-tight`,children:u??c?.error})]})}t();var Ye={active:_,readonly:w,drain:T,disabled:d},Xe={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 Ze({mode:e,open:t,onToggle:r}){let i=R(e),a=Ye[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 ${Xe[e]}`,children:[o(a,{className:`h-3 w-3`}),i.label,o(l,{className:`h-3 w-3 ${t?`rotate-180`:``}`})]})}function Qe({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(m,{className:`h-3 w-3`})})]}),L.map(a=>{let s=t[a.mode],c=s!==``,l=Ye[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 $e(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 et({location:e,onEdit:t,onDelete:r,onSetMode:i,blockedReasons:s,canDelete:c,siblings:l=[],drain:u,ownedBytes:d}){let[p,m]=a(!1),h=$e(e.config),g=F(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(Ne,{location:e,ownedBytes:d??null}),u!==void 0&&o(we,{drain:u})]})]}),n(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[o(qe,{location:e,siblings:l}),o(Ze,{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(C,{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(f,{className:`h-3 w-3`})})]}),p&&o(Qe,{mode:g,blockedReasons:s,onSelect:t=>i(e,t),onDismiss:()=>{m(!1)}})]})}t();function tt({type:e,displayName:t,description:i,cardinality:a,locations:s,onAdd:c,onEdit:l,onDelete:u,onSetMode:d,ownedBytesById:f,drainById:p}){let m=r(()=>{let e=[...s];return e.sort((e,t)=>{let n=I(F(e));return n===I(F(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-3 py-2`,children:[n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`span`,{className:`text-sm font-semibold text-foreground capitalize`,children:t}),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&&o(`p`,{className:`text-[11px] 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.`})]}),a===`multi`&&n(`button`,{onClick:()=>c(e),className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90`,children:[o(h,{className:`h-3 w-3`}),`Add`]})]}),m.length===0?o(`div`,{className:`px-3 py-4 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.`}):o(`div`,{children:m.map(e=>o(et,{location:e,cardinality:a,canDelete:U(e,m,a),onEdit:l,onDelete:u,onSetMode:d,blockedReasons:H(e,m),ownedBytes:f?.get(e.id)??null,drain:be(xe(e),p?.get(e.id)),siblings:m},e.id))})]})}var nt=[`recordings`,`recordingsLow`];function rt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function it(e,t){if(t===void 0||!nt.includes(e.type))return null;let n=t.find(t=>rt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function at(e,t){let n=new Map;for(let r of e){let e=it(r,t);e!==null&&n.set(r.id,e)}return n}export{ve as a,R as c,Oe as i,z as l,tt as n,he as o,q as r,re as s,at as t,P 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{at as c,gt as l,ht as u,mt as d,st as f,vt as p}from"./player-overlays-rpfoGg2b.js";import{Au as m,Dd as h,F as g,Td as _,Un as v,Vd as y,_l as b,al as x,dr as S,kd as C}from"./src-BQ0U3gDQ.js";import{t as w}from"./archive-Bxuu4XK_.js";import{t as T}from"./hard-drive-download-CHmTG4FF.js";import{Zr as E}from"./client-CwOJLD7X.js";import{F as ee}from"./index-GnPOi642.js";import{t as D}from"./format-size-DIxKXxtj.js";var O=p(`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 k(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function te(e,t){let n=k(t);return`${e}:${n.length>0?n:`default`}`}var A=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`]),j=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function M(e){let t=j.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?j.length:t}function N(e){return e.filter(e=>!e.name.startsWith(`.`)&&!A.has(e.name)).toSorted((e,t)=>{let n=M(e.name)-M(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function ne({nodeId:t,value:r,onChange:i}){let l=c().trpcClient,[u,d]=a([]),[f,p]=a(r),[m,h]=a(null),[g,_]=a(null),[v,y]=a(``),b=e(async(e,n)=>{_(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&i(r.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[l,t,i]);s(()=>{p(r),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(N(e.entries)),await b(r.startsWith(`/`)?r:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await b(r&&e.some(e=>r.startsWith(e))?r:e[0]??``,!1)}catch(e){d([]),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 l.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:u.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:f,onChange:e=>{p(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 P({initialType:e,onClose:t,onCreated:s}){let l=i(),d=c().trpcClient,[f,p]=a(`picker`),[h,_]=a(e),[v,S]=a(null),[C,w]=a({}),[T,E]=a(``),[D,O]=a(null),[k,A]=a(!1),[j,M]=a(`hub`),[N,P]=a(null),[F,I]=a(!1),L=e=>w(t=>({...t,basePath:e})),R=typeof C.basePath==`string`?C.basePath:``,z=x(),B=r(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=b({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),U=r(()=>D!==null&&D.length>0?D:te(h,T),[h,T,D]),W=async()=>{if(v){I(!0),P(null);try{P(await(e=>d.storage.testConfig.query(e))({providerId:v.providerId,config:C}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`div`,{className:`space-y-0.5`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:{picker:`Add Location — Pick provider`,config:`Add Location — ${v?.displayName??``}`,naming:`Add Location — Name`}[f]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,o(`span`,{className:`font-mono`,children:h})]})]}),o(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:o(m,{className:`h-4 w-4`})})]}),f===`picker`&&n(`div`,{className:`p-4 space-y-2`,children:[V&&o(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!V&&B.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 "`,h,`". Install a compatible addon (e.g.`,` `,o(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),B.map(e=>n(`button`,{onClick:()=>{S(e),p(`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(u,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),f===`config`&&v&&n(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,children:[o(ee,{schema:v.configSchema,values:C,onChange:w}),v.nodeLocal&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(g,{selectedNodeId:j,onSelect:M,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(ne,{nodeId:j,value:R,onChange:L})]}),N&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${N.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:N.ok?`Connection OK.`:`Test failed: ${N.error??`unknown error`}`}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`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:()=>{W()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?`Testing…`:`Test connection`}),o(`button`,{onClick:()=>p(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),f===`naming`&&v&&n(`div`,{className:`p-4 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:T,onChange:e=>E(e.target.value),placeholder:`${h} on ${v.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:U,onChange:e=>O(e.target.value),placeholder:te(h,T),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:k,onChange:e=>A(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.`})]})]}),H.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:H.error instanceof Error?H.error.message:String(H.error)}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`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),S(null),w({}),E(``),O(null),A(!1),P(null),p(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),n(`button`,{onClick:()=>{v&&H.mutate({id:U,type:h,displayName:T.trim(),providerId:v.providerId,config:C,enabled:k,nodeId:v.nodeLocal?j:void 0})},disabled:H.isPending||T.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:[H.isPending?o(y,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?`Saving…`:`Save`]})]})]})]})]})})}function F(e){return E(e)}function I(e){return e===`active`}var L=[{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 R(e){return L.find(t=>t.mode===e)??L[0]}function z(e){return R(e).requiresConfirmation}var B=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function V(e,t,n){return I(n)||!I(F(e))||t.some(t=>t.id!==e.id&&I(F(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:B}}function H(e,t){return{active:V(e,t,`active`).reason,readonly:V(e,t,`readonly`).reason,drain:V(e,t,`drain`).reason,disabled:V(e,t,`disabled`).reason}}function U(e,t,n){return!(n===`single`||t.length<=1||I(F(e))&&t.filter(e=>I(F(e))).length<=1)}function W(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function re(e,t){let n={...t.config??e.config};t.mode!==void 0&&(W(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:W(t.mode).enabled}}var ie=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ae(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 oe(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function se(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 ce(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 le(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ie;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function ue(e){return e===`gb`?`GB to keep free`:`% of the volume to keep free`}function de(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 fe(e){return G(e.maxUsedGb)}function pe(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ie,reason:t===`drain`?`drain`:`legacy`}}t();function me({config:e,defaultPercent:t=10,onChange:r}){let[i,s]=a(()=>ae(e).unit),c=oe(e,i),l={unit:i,value:c},u=fe(e),d=t=>{s(t),r(se(e,{unit:t,value:null}))},f=t=>{r(se(e,{unit:i,value:ce(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":ue(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:de(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 he({location:e,onClose:t,onSaved:s}){let l=i(),u=c().trpcClient,[d,f]=a({...e.config}),[p,h]=a(e.displayName),[_,v]=a(null),[S,C]=a(!1),w=x(),T=r(()=>{let t=w.data;return Array.isArray(t)?t.find(t=>t.providerId===e.providerId)??null:null},[w.data,e.providerId]),E=b({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),D=T?.shouldSaveDiskSpace===!0,O=T?.nodeLocal===!0,[k,te]=a(typeof e.nodeId==`string`?e.nodeId:`hub`),A=typeof d.basePath==`string`?d.basePath:``,j=e=>f(t=>({...t,basePath:e})),M=T?.minFreePercent??10,N=async()=>{C(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:e.providerId,locationId:e.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{C(!1)}};return o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`div`,{className:`space-y-0.5`,children:[n(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Edit `,e.displayName]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[o(`span`,{className:`font-mono`,children:e.id}),` ·`,` `,T?.displayName??e.providerId]})]}),o(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:o(m,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,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:p,onChange:e=>h(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`})]}),T&&o(ee,{schema:T.configSchema,values:d,onChange:f}),O&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(g,{selectedNodeId:k,onSelect:te,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(ne,{nodeId:k,value:A,onChange:j})]}),D&&o(me,{config:d,defaultPercent:M,onChange:f}),!T&&!w.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`}`}),E.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:E.error instanceof Error?E.error.message:String(E.error)})]}),n(`div`,{className:`flex items-center justify-between gap-2 border-t border-border px-4 py-3`,children:[o(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{N()},disabled:S||!T,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:S?`Testing…`:`Test connection`}),n(`button`,{onClick:()=>{E.mutate(re(e,{displayName:p.trim(),config:d,nodeId:O?k:e.nodeId}))},disabled:E.isPending||p.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:[E.isPending?o(y,{className:`h-3.5 w-3.5 animate-spin`}):null,E.isPending?`Saving…`:`Save`]})]})]})]})})}function ge(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(e){if(!ge(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 ve(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=_e(n);e!==null&&t.set(e.locationId,e)}return t}function ye(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 be(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:ye(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function xe(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Se(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ce(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function we({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:[Se(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 `,Ce(e.estimatedEmptyAtMs)]})]})}var Te=[`ok`,`warn`,`critical`];function Ee(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function De(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=De((n-t)/n);return{fraction:r,severity:Ee(r),recordingsFraction:De(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Oe(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||Te.indexOf(e.severity)>Te.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}var ke=`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 Ae(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:D(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?ke:`${ke} 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?Ee(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:D(r),freeTotal:D(a),freeTotalPercent:X(a/r),used:D(p),usedPercent:X(p/r),free:D(u),freePercent:X(u/r),reserve:s===0?null:`${D(s)} kept free`,owned:f===null||_===null?null:`${D(f)} of recordings (${X(_)})`,cap:v===null?null:v.reason===`drain`?`${D(v.bytes)} drain target (managed by CamStack)`:`${D(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:D(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:`${D(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 je={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 Me(e,t){return e===`used`?je[t]:Z[e]}function Ne({location:e,ownedBytes:t}){let r=e.capacity??null,i=le(ae(e.config),r?.totalBytes??null),a=Ae({totalBytes:r?.totalBytes??null,availableBytes:r?.availableBytes??null},i,{ownedBytes:t??null,cap:pe(e.config,F(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:je[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 ${Me(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 Pe={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Fe={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Ie=`storage.discardLocation`,Le=`storage.discardLocationStatus`,Re=`storage.discardLocationCancel`;function ze(e){return Pe[e]??null}function Be(e){return Fe[e]??null}function Ve(e){return!I(F(e))}function He(e,t){return ze(e.type)===null||!Ve(e)?!1:t.some(t=>t.id!==e.id&&I(F(t)))}var Ue=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 We(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`||!Ue.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 Ge(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 Ke=2e3;function qe({location:e,siblings:t}){return He(e,t)?o(Je,{location:e}):null}function Je({location:e}){let t=v(),r=S(),i=Be(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:Le,input:{}});if(e)return;l(We(t))}catch{}};t();let n=setInterval(()=>void t(),Ke);return()=>{e=!0,clearInterval(n)}},[i,e.id]),i===null)return null;let h=c!==null&&c.locationId===e.id,g=h&&c.running,_=h&&c.phase!==`idle`,b=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:Ie,input:{locationId:e.id}}),l(We(await r.mutateAsync({addonId:i,action:Le,input:{}})))}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}},x=async()=>{try{await r.mutateAsync({addonId:i,action:Re,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:[g?n(`button`,{type:`button`,onClick:()=>void x(),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(m,{className:`h-3 w-3`}),`Cancel`]}):n(`button`,{type:`button`,onClick:()=>void b(),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(y,{className:`h-3 w-3 animate-spin`}):o(O,{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:`${Ge(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||h&&c?.error)&&o(`p`,{className:`text-[10px] text-danger leading-tight`,children:u??c?.error})]})}t();var Ye={active:_,readonly:w,drain:T,disabled:d},Xe={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 Ze({mode:e,open:t,onToggle:r}){let i=R(e),a=Ye[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 ${Xe[e]}`,children:[o(a,{className:`h-3 w-3`}),i.label,o(l,{className:`h-3 w-3 ${t?`rotate-180`:``}`})]})}function Qe({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(m,{className:`h-3 w-3`})})]}),L.map(a=>{let s=t[a.mode],c=s!==``,l=Ye[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 $e(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 et({location:e,onEdit:t,onDelete:r,onSetMode:i,blockedReasons:s,canDelete:c,siblings:l=[],drain:u,ownedBytes:d}){let[p,m]=a(!1),h=$e(e.config),g=F(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(Ne,{location:e,ownedBytes:d??null}),u!==void 0&&o(we,{drain:u})]})]}),n(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[o(qe,{location:e,siblings:l}),o(Ze,{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(C,{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(f,{className:`h-3 w-3`})})]}),p&&o(Qe,{mode:g,blockedReasons:s,onSelect:t=>i(e,t),onDismiss:()=>{m(!1)}})]})}t();function tt({type:e,displayName:t,description:i,cardinality:a,locations:s,onAdd:c,onEdit:l,onDelete:u,onSetMode:d,ownedBytesById:f,drainById:p}){let m=r(()=>{let e=[...s];return e.sort((e,t)=>{let n=I(F(e));return n===I(F(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-3 py-2`,children:[n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`span`,{className:`text-sm font-semibold text-foreground capitalize`,children:t}),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&&o(`p`,{className:`text-[11px] 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.`})]}),a===`multi`&&n(`button`,{onClick:()=>c(e),className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90`,children:[o(h,{className:`h-3 w-3`}),`Add`]})]}),m.length===0?o(`div`,{className:`px-3 py-4 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.`}):o(`div`,{children:m.map(e=>o(et,{location:e,cardinality:a,canDelete:U(e,m,a),onEdit:l,onDelete:u,onSetMode:d,blockedReasons:H(e,m),ownedBytes:f?.get(e.id)??null,drain:be(xe(e),p?.get(e.id)),siblings:m},e.id))})]})}var nt=[`recordings`,`recordingsLow`];function rt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function it(e,t){if(t===void 0||!nt.includes(e.type))return null;let n=t.find(t=>rt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function at(e,t){let n=new Map;for(let r of e){let e=it(r,t);e!==null&&n.set(r.id,e)}return n}export{ve as a,R as c,Oe as i,z as l,tt as n,he as o,q as r,re as s,at as t,P as u};
|
|
@@ -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{Gu as a}from"./src-BQ0U3gDQ.js";import{Z as o}from"./index-
|
|
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{Gu as a}from"./src-BQ0U3gDQ.js";import{Z as o}from"./index-GnPOi642.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{l as n,s as r,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-
|
|
102
|
+
<script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-4a63c292.js"></script>
|
|
103
103
|
<link rel="modulepreload" crossorigin href="./assets/__vite-browser-external-DF8Eb0aa.js">
|
|
104
104
|
<link rel="modulepreload" crossorigin href="./assets/client-CwOJLD7X.js">
|
|
105
105
|
<link rel="modulepreload" crossorigin href="./assets/player-overlays-rpfoGg2b.js">
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
<link rel="modulepreload" crossorigin href="./assets/mount-nn4N-kW_.js">
|
|
109
109
|
<link rel="modulepreload" crossorigin href="./assets/notification-schedule-field-BTiUXVHy.js">
|
|
110
110
|
<link rel="stylesheet" crossorigin href="./assets/index-wxcbK3CM.css">
|
|
111
|
-
<link rel="modulepreload" crossorigin href="./assets/hostInit-DtbkNESn.js"><link rel="modulepreload" crossorigin href="./assets/index-
|
|
111
|
+
<link rel="modulepreload" crossorigin href="./assets/hostInit-DtbkNESn.js"><link rel="modulepreload" crossorigin href="./assets/index-GnPOi642.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-DgvAVxEY.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CvwQbyB5.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`
|
package/dist/server/addon.js
CHANGED
|
@@ -52475,7 +52475,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
52475
52475
|
capability: adminUiCapability,
|
|
52476
52476
|
provider: {
|
|
52477
52477
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
52478
|
-
getVersion: async () => ({ version: "1.2.
|
|
52478
|
+
getVersion: async () => ({ version: "1.2.361" })
|
|
52479
52479
|
}
|
|
52480
52480
|
}];
|
|
52481
52481
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,a as r,b as i,o as a,q as o,x 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{at as c,gt as l,ht as u,st as d,vt as f}from"./player-overlays-rpfoGg2b.js";import{$l as p,Au as m,Bu as h,Cf as g,Dd as _,Df as v,Eu as y,Gd as b,Gl as x,H as S,Hl as C,Jl as w,Kd as T,Kl as E,M as D,Mn as O,N as k,Pt as ee,Ql as te,U as A,Ud as ne,Ul as re,Un as j,Vd as M,Wl as ie,Wn as ae,Xl as N,Yl as P,Zl as F,Zn as I,aa as oe,eu as L,hd as se,iu as ce,kd as R,ld as z,mf as B,nu as le,of as V,qd as H,ql as ue,rd as U,ru as de,tu as fe,ud as W,vr as pe,yr as me}from"./src-BQ0U3gDQ.js";import{t as he}from"./monitor-smartphone-BcbZNX7w.js";import{a as ge,c as _e,i as ve,n as ye,o as be,s as G,t as xe}from"./ReauthDialog-DSMlzJbr.js";import{a as Se,i as Ce,o as we,s as Te}from"./client-CwOJLD7X.js";import{J as Ee,L as K,c as De,nt as Oe,s as ke,tt as Ae}from"./index-CArA6N_R.js";import{t as q}from"./AdminPage-BSFohA3i.js";import{t as je}from"./AdminTabs-FluZSCkZ.js";import{n as Me,r as Ne,t as Pe}from"./IntegrationHub-Blksb596.js";import{n as Fe,t as Ie}from"./addon-display-names-BkwMrExv.js";var Le=f(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Re=f(`key-square`,[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]),ze=f(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]);e();function Be({userId:e,username:n,onClose:r}){let i=j(),a=y.useUtils(),o=w({userId:e}),c=y.auth.listLoginMethods.useQuery(),l=de({onSuccess:()=>void a.userManagement.listExternalIdentities.invalidate()}),u=new Map((c.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),d=o.data??[],f=async(t,r)=>{await i({title:`Remove sign-in link`,message:`"${n}" will no longer be able to sign in with this ${r} account.`,confirmLabel:`Remove`,variant:`danger`})&&l.mutate({userId:e,provider:t.provider,subject:t.subject})};return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4`,children:t(`div`,{"data-testid":`external-identities-modal`,className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl overflow-hidden`,children:[t(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[t(`div`,{className:`flex items-center gap-2`,children:[s(ne,{className:`h-4 w-4 text-primary`}),t(`div`,{children:[s(`div`,{className:`text-sm font-medium text-foreground`,children:`Linked sign-in accounts`}),t(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`User: `,s(`span`,{className:`font-mono`,children:n})]})]})]}),s(`button`,{onClick:r,"aria-label":`Close`,className:`p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle`,children:s(m,{className:`h-4 w-4`})})]}),t(`div`,{className:`p-4 space-y-3`,children:[o.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(M,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}):d.length===0?s(`p`,{className:`text-xs text-foreground-subtle`,children:`No linked accounts. Only the user can link one, from their own profile page.`}):s(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:d.map(e=>{let n=u.get(e.provider),r=n??e.provider;return t(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`font-medium text-foreground truncate`,children:[r,n===void 0&&s(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:`provider unavailable`})]}),t(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[e.label??e.subject,` ·`,` `,new Date(e.linkedAt).toLocaleDateString()]})]}),t(`button`,{onClick:()=>void f(e,r),disabled:l.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[s(_e,{className:`h-3 w-3`}),`Remove`]})]},`${e.provider}|${e.subject}`)})}),s(`div`,{className:`flex justify-end`,children:s(O,{onClick:r,variant:`secondary`,children:`Close`})})]})]})})}function Ve({userId:e,username:n,onClose:r}){let o=a(),c=j(),l=E({userId:e}),u=l.data,d=()=>o.invalidateQueries({queryKey:[[`userManagement`,`getTotpStatus`]]}),f=x({onSuccess:()=>{d(),r()}}),p=l.isLoading?`loading`:u?.enabled?`enrolled`:`not_enrolled`;return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4`,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl overflow-hidden`,children:[t(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[t(`div`,{className:`flex items-center gap-2`,children:[s(U,{className:`h-4 w-4 text-primary`}),t(`div`,{children:[s(`div`,{className:`text-sm font-medium text-foreground`,children:`Two-factor authentication`}),t(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`User: `,s(`span`,{className:`font-mono`,children:n})]})]})]}),s(`button`,{onClick:r,className:`p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle`,children:s(m,{className:`h-4 w-4`})})]}),t(`div`,{className:`p-4 space-y-4`,children:[p===`loading`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(M,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),p===`not_enrolled`&&t(`div`,{className:`rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle`,children:[s(H,{className:`h-4 w-4 mt-0.5 shrink-0`}),t(`div`,{children:[s(`div`,{className:`font-medium text-foreground`,children:`2FA not enrolled`}),s(`p`,{className:`mt-0.5`,children:`Only the user themselves can enable 2FA, from their own profile page.`})]})]}),p===`enrolled`&&u&&t(i,{children:[t(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[s(g,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),t(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[s(`div`,{className:`font-medium`,children:`2FA is active`}),t(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,u.confirmedAt?new Date(u.confirmedAt).toLocaleString():`—`]})]})]}),s(`div`,{className:`text-[11px] text-foreground-subtle`,children:`Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards.`}),t(`div`,{className:`flex justify-end gap-2`,children:[s(O,{onClick:r,variant:`secondary`,children:`Close`}),t(`button`,{onClick:async()=>{await c({title:`Remove 2FA`,message:`Remove two-factor authentication for "${n}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,confirmLabel:`Remove`,variant:`danger`})&&f.mutate({userId:e})},disabled:f.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[f.isPending?s(M,{className:`h-3 w-3 animate-spin`}):s(m,{className:`h-3 w-3`}),`Remove 2FA`]})]})]})]})]})})}function He({userId:e,username:n,onClose:r}){let{user:i,logout:a}=K(),c=i?.id===e,l=j(),u=y.useUtils(),d=y.auth.listSessions.useQuery({userId:e}),[f,p]=o(null),h=y.auth.revokeSessions.useMutation({onSuccess:(e,t)=>{if(c&&`userId`in t){a();return}u.auth.listSessions.invalidate()},onError:e=>p(`Sign out failed: ${e.message}`)}),g=async e=>{await l({title:`Sign out this session`,message:`"${n}" on ${ge(e.client).label} will have to sign in again.`,confirmLabel:`Sign out`,variant:`danger`})&&(p(null),h.mutate({id:e.id}))},_=async()=>{await l({title:`Sign out everywhere`,message:c?`Every session of your own account ends, this browser included: you will be signed out here too.`:`Every session of "${n}" ends at once; each device has to sign in again.`,confirmLabel:`Sign out everywhere`,variant:`danger`})&&(p(null),h.mutate({userId:e}))},v=h.isPending&&h.variables!==void 0&&`id`in h.variables?h.variables.id:null;return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4`,children:t(`div`,{"data-testid":`user-sessions-modal`,className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl overflow-hidden`,children:[t(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[t(`div`,{className:`flex items-center gap-2`,children:[s(he,{className:`h-4 w-4 text-primary`}),t(`div`,{children:[s(`div`,{className:`text-sm font-medium text-foreground`,children:`Active sessions`}),t(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`User: `,s(`span`,{className:`font-mono`,children:n})]})]})]}),s(`button`,{onClick:r,"aria-label":`Close`,className:`p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle`,children:s(m,{className:`h-4 w-4`})})]}),t(`div`,{className:`p-4 space-y-3 max-h-[70vh] overflow-y-auto`,children:[f!==null&&s(`div`,{className:`text-[11px] text-danger`,children:f}),s(ve,{sessions:d.data??[],isLoading:d.isLoading,loadError:d.isError?d.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void g(e),revokingId:v}),t(`div`,{className:`flex justify-between gap-2`,children:[t(`button`,{onClick:()=>void _(),disabled:h.isPending||(d.data??[]).length===0,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[h.isPending&&v===null?s(M,{className:`h-3 w-3 animate-spin`}):s(Ae,{className:`h-3 w-3`}),`Sign out everywhere`]}),s(O,{onClick:r,variant:`secondary`,children:`Close`})]})]})]})})}function Ue({icon:e,label:n,count:r,all:i,total:a}){return t(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[s(e,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),s(`span`,{className:`min-w-0 flex-1 text-foreground-subtle`,children:n}),s(`span`,{className:r===0?`text-foreground-subtle`:`font-medium text-foreground`,children:r===0?`none`:i?`all ${a}`:`${r} of ${a}`})]})}function We({scopes:e,isAdmin:n,invalidReason:a}){let o=c(),l=r({queryKey:[`auth`,`previewScope`,e,n],enabled:a===null,queryFn:()=>o.trpcClient.auth.previewScope.query({scopes:[...e],isAdmin:n})}),{data:u}=oe({projection:`slim`}),f=u?.length??0;if(a!==null)return s(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:t(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,children:[s(W,{className:`h-3 w-3 shrink-0`}),a]})});if(l.isLoading)return t(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface p-3 text-[11px] text-foreground-subtle`,children:[s(M,{className:`h-3 w-3 animate-spin`}),`Resolving…`]});if(l.isError||!l.data)return s(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:s(`p`,{className:`text-[11px] text-danger`,children:`Could not resolve this grant set. Saving is still allowed — the server enforces the same rules either way.`})});let p=l.data;return s(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:p.isAdmin?t(`p`,{className:`text-[11px] text-foreground`,children:[s(`span`,{className:`font-medium`,children:`Administrator`}),` — unrestricted. Grants are ignored for an admin.`]}):t(i,{children:[s(Ue,{icon:V,label:`Devices they can see`,count:p.device.view.deviceCount,all:p.device.view.all,total:f}),s(Ue,{icon:R,label:`Devices they can operate`,count:p.device.create.deviceCount,all:p.device.create.all,total:f}),s(Ue,{icon:d,label:`Devices they can delete`,count:p.device.delete.deviceCount,all:p.device.delete.all,total:f}),t(`div`,{className:`border-t border-border pt-2 text-[10px] text-foreground-subtle`,children:[`System access: `,p.system.length===0?`none`:p.system.join(`, `),p.capabilities.length>0&&t(i,{children:[` · Extra capabilities: `,p.capabilities.map(e=>e.name).join(`, `)]}),p.addons.length>0&&t(i,{children:[` · Addons: `,p.addons.map(e=>e.name).join(`, `)]})]}),p.device.view.deviceCount===0&&s(`p`,{className:`text-[10px] text-warning`,children:`This user will not be able to see any device.`})]})})}e();function Ge(e){let t=we(e);return t===null?{mode:e.length===0?`role`:`advanced`,roleId:null,selector:{kind:`all`},includeLinked:!0,advancedScopes:e}:{mode:`role`,roleId:t.roleId,selector:t.selector,includeLinked:t.includeLinked,advancedScopes:e}}function Ke(e){return e.mode===`advanced`?e.advancedScopes:e.roleId===null?[]:Se({roleId:e.roleId,selector:e.selector,includeLinked:e.includeLinked})}function qe({user:e,onClose:r,onSubmit:a,submitting:c,callerScopes:d}){let f=n(()=>Ge(e.scopes??[]),[e.scopes]),[p,h]=o(f),[g,_]=o(f.mode===`advanced`),v=n(()=>Ke(p),[p]),y=!e.isAdmin&&p.mode===`role`&&p.roleId===null,b=n(()=>e.isAdmin?null:p.mode===`role`&&p.roleId===null?`Pick what this user can do to see the result.`:k(v),[e.isAdmin,p.mode,p.roleId,v]),x=e=>h({...p,...e});return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 pt-[calc(1rem+env(safe-area-inset-top))] pb-[calc(1rem+env(safe-area-inset-bottom))]`,children:t(`div`,{className:`flex max-h-full w-full max-w-2xl flex-col rounded-lg border border-border bg-surface shadow-xl`,children:[t(`div`,{className:`flex shrink-0 items-start justify-between border-b border-border px-4 py-3`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-semibold text-foreground`,children:[`Access — `,e.username]}),s(`div`,{className:`text-[10px] text-foreground-subtle`,children:e.isAdmin?`This user is an administrator — they can do everything, and the settings below are ignored.`:`Choose what they can do, then which devices it applies to.`})]}),s(`button`,{onClick:r,className:`shrink-0 text-foreground-subtle hover:text-foreground`,title:`Close`,children:s(m,{className:`h-4 w-4`})})]}),t(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:[y&&t(`div`,{className:`flex items-start gap-2 rounded-lg border border-warning/40 bg-warning/10 p-3`,children:[s(W,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),t(`p`,{className:`text-[11px] text-foreground`,children:[s(`span`,{className:`font-medium`,children:`No access.`}),` `,t(`span`,{className:`text-foreground-subtle`,children:[e.username,` cannot see or do anything yet. Configure it below.`]})]})]}),t(`section`,{className:`space-y-2`,children:[s(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:`1 · What can they do`}),s(`div`,{className:`space-y-1.5`,children:Ce.map(e=>{let n=p.mode===`role`&&p.roleId===e.id;return t(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg border p-2.5 transition-colors ${n?`border-primary bg-primary/5`:`border-border hover:bg-foreground-subtle/5`}`,children:[s(`input`,{type:`radio`,name:`access-role`,checked:n,onChange:()=>x({mode:`role`,roleId:e.id}),className:`mt-0.5 border-border focus:ring-primary`}),t(`span`,{className:`min-w-0`,children:[s(`span`,{className:`block text-[12px] font-medium text-foreground`,children:e.label}),s(`span`,{className:`mt-0.5 block text-[10px] text-foreground-subtle`,children:e.description})]})]},e.id)})}),t(`button`,{type:`button`,onClick:()=>{if(!g){h({...p,mode:`advanced`,advancedScopes:v}),_(!0);return}_(!1),h(Ge(p.advancedScopes))},className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] text-foreground-subtle transition-colors hover:bg-foreground-subtle/10 hover:text-foreground`,children:[s(g?l:u,{className:`h-3 w-3`}),`Advanced — edit raw grants`]}),g&&t(`div`,{className:`rounded-lg border border-border p-2`,children:[s(`p`,{className:`mb-2 text-[10px] text-foreground-subtle`,children:`One row per grant. Anything expressible here overrides the three roles above; close this section to go back to them.`}),s(D,{value:p.advancedScopes,onChange:e=>x({mode:`advanced`,advancedScopes:e}),clampToParent:d,emptyHint:t(i,{children:[`No grants.`,` `,s(`span`,{className:`font-medium text-foreground`,children:e.username}),` cannot call any protected endpoint until one is added.`]})})]})]}),p.mode===`role`&&t(`section`,{className:`space-y-2`,children:[s(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:`2 · On which devices`}),s(S,{value:p.selector,onChange:e=>x({selector:e}),includeLinked:p.includeLinked,onIncludeLinkedChange:e=>x({includeLinked:e}),clampToDeviceIds:null})]}),t(`section`,{className:`space-y-2`,children:[s(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:p.mode===`role`?`3 · Result`:`2 · Result`}),s(We,{scopes:v,isAdmin:e.isAdmin,invalidReason:b})]})]}),t(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3`,children:[s(`button`,{onClick:r,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Cancel`}),s(`button`,{onClick:()=>a([...v]),disabled:c||b!==null,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:c?s(M,{className:`h-3 w-3 animate-spin`}):`Save access`})]})]})})}e();var Je=8;function Ye(){let e=a(),{user:n}=K(),[r,i]=o(!1),[c,l]=o(``),[u,f]=o(``),[p,h]=o(!1),[g,v]=o(null),{data:y,isLoading:x,isError:S}=F(),C=j(),w=ae(),T=()=>e.invalidateQueries({queryKey:[[`userManagement`,`listUsers`]]}),E=re({onSuccess:()=>{T(),i(!1),l(``),f(``),h(!1),v(null)},onError:e=>{v(e instanceof Error?e.message:`Failed to create user`)}}),D=ie({onSuccess:T}),O=ce({onSuccess:T}),k=te({onSuccess:T}),A=le({onSuccess:()=>{T(),P(null)}}),[N,P]=o(null),[I,oe]=o(null),[L,se]=o(null),[R,B]=o(null),V=y??[];async function H(e){await C({title:`Delete user`,message:`Permanently delete user "${e.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:`Delete`,variant:`danger`})&&D.mutate({id:e.id})}async function ue(e){let t=await w({title:`Reset password`,message:`Set a new password for "${e.username}".`,label:`New password`,inputType:`password`,placeholder:`At least 8 characters`,confirmLabel:`Continue`,validate:e=>e.length<Je?`Password must be at least ${String(Je)} characters.`:null});t===null||t.length===0||await C({title:`Reset password`,message:`Reset the password for "${e.username}"? They will need to use the new password on their next login.`,confirmLabel:`Reset`})&&k.mutate({id:e.id,newPassword:t})}function de(e,t){t!==e.isAdmin&&O.mutate({id:e.id,isAdmin:t})}function fe(e){return e?new Date(typeof e==`number`?e:String(e)).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`}):`—`}return t(q,{children:[s(`div`,{className:`flex items-center justify-end`,children:t(`button`,{onClick:()=>i(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:bg-primary/90`,children:[s(_,{className:`h-3.5 w-3.5`}),`Create User`]})}),r&&t(`div`,{className:`rounded-lg border border-border bg-surface p-4 space-y-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:[s(`span`,{className:`text-xs font-medium text-foreground`,children:`New User`}),s(`button`,{onClick:()=>i(!1),className:`text-foreground-subtle hover:text-foreground`,children:s(m,{className:`h-4 w-4`})})]}),t(`div`,{className:`grid grid-cols-3 gap-3`,children:[t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Username`}),s(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`john`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Password`}),s(`input`,{type:`password`,value:u,onChange:e=>f(e.target.value),placeholder:`••••••••`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Admin`}),t(`label`,{className:`flex items-center gap-2 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:p,onChange:e=>h(e.target.checked),className:`rounded border-border focus:ring-primary`}),s(`span`,{className:`text-foreground-subtle`,children:`Unrestricted access`})]})]})]}),g&&s(`p`,{className:`text-[10px] text-danger`,children:g}),t(`div`,{className:`flex justify-end gap-2`,children:[s(`button`,{onClick:()=>i(!1),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),s(`button`,{onClick:()=>E.mutate({username:c,password:u,isAdmin:p}),disabled:E.isPending||!c||!u,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:E.isPending?`Creating...`:`Create`})]})]}),x&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading...`}),S&&s(`div`,{className:`text-xs text-danger`,children:`Failed to load`}),!x&&!S&&V.length===0&&s(`div`,{className:`text-xs text-foreground-subtle`,children:`No data`}),(()=>{let e=e=>D.isPending&&D.variables?.id===e.id||O.isPending&&O.variables?.id===e.id||k.isPending&&k.variables?.id===e.id;return s(ee,{columns:[{key:`username`,header:`Username`,render:e=>e.username},{key:`isAdmin`,header:`Admin`,render:n=>t(`label`,{className:`inline-flex items-center gap-1.5 text-xs cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:n.isAdmin,onChange:e=>de(n,e.target.checked),disabled:e(n),className:`rounded border-border focus:ring-primary disabled:opacity-50`}),s(`span`,{className:n.isAdmin?`text-primary font-medium`:`text-foreground-subtle`,children:n.isAdmin?`Admin`:`Regular`})]})},{key:`scopes`,header:`Access`,render:e=>e.isAdmin?s(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:`everything (admin)`}):t(`button`,{onClick:()=>P(e),className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] hover:bg-foreground-subtle/10`,title:`Configure access`,children:[s(z,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),s(Xe,{scopes:e.scopes??[]})]})},{key:`createdAt`,header:`Created`,render:e=>s(`span`,{className:`text-foreground-subtle`,children:fe(e.createdAt)})},{key:`actions`,header:`Actions`,align:`right`,render:r=>{let i=e(r);return t(`div`,{className:`flex items-center justify-end gap-1`,children:[r.id!==n?.id&&r.totpEnabled&&t(`button`,{onClick:()=>oe(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50`,title:`Remove two-factor authentication`,children:[s(U,{className:`h-3 w-3`}),`Remove 2FA`]}),t(`button`,{onClick:()=>se(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50`,title:`Linked sign-in accounts`,children:[s(ne,{className:`h-3 w-3`}),`Sign-in links`]}),t(`button`,{onClick:()=>B(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50`,title:`Active sessions`,children:[s(he,{className:`h-3 w-3`}),`Sessions`]}),t(`button`,{onClick:()=>ue(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50`,title:`Reset password`,children:[s(b,{className:`h-3 w-3`}),`Reset password`]}),t(`button`,{onClick:()=>H(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete user`,children:[i?s(M,{className:`h-3 w-3 animate-spin`}):s(d,{className:`h-3 w-3`}),`Delete`]})]})}}],rows:V,rowKey:e=>e.id,minWidthPx:560})})(),I&&s(Ve,{userId:I.id,username:I.username,onClose:()=>oe(null)}),L&&s(Be,{userId:L.id,username:L.username,onClose:()=>se(null)}),R&&s(He,{userId:R.id,username:R.username,onClose:()=>B(null)}),N&&s(Ze,{user:N,onClose:()=>P(null),onSubmit:e=>A.mutate({userId:N.id,scopes:e}),submitting:A.isPending})]})}function Xe({scopes:e}){if(e.length===0)return s(`span`,{className:`font-medium text-warning`,children:`No access`});let n=we(e);return n===null?t(`span`,{className:`text-foreground-subtle`,children:[`Custom · `,e.length,` grant`,e.length===1?``:`s`]}):t(`span`,{className:`text-foreground-subtle`,children:[s(`span`,{className:`font-medium text-foreground`,children:Te(n.roleId).label}),` ·`,` `,A(n.selector)]})}function Ze(e){let{user:t}=K(),n=t?.isAdmin===!0;return s(qe,{...e,callerScopes:n?null:t?.scopes??[]})}function Qe(e,t){return e.revokedAt===null?e.expiresAt<=t?`expired`:`active`:`revoked`}var $e={active:{label:`active`,cls:`bg-danger/10 text-danger`},expired:{label:`expired`,cls:`bg-foreground-subtle/15 text-foreground-subtle`},revoked:{label:`revoked`,cls:`bg-foreground-subtle/15 text-foreground-subtle`}};function et({tokens:e,isLoading:n,loadError:r,userNameById:i,onRevoke:a,revokingId:o,now:c=Date.now()}){return n?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(M,{className:`h-3.5 w-3.5 animate-spin`}),`Loading admin tokens…`]}):r===null?e.length===0?s(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:`No admin tokens.`}):s(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>s(tt,{token:e,state:Qe(e,c),creator:i.get(e.createdBy)??e.createdBy,revoking:o===e.id,onRevoke:()=>a(e)},e.id))}):t(`div`,{className:`text-[11px] text-danger`,children:[`Could not load admin tokens: `,r]})}function tt({token:e,state:n,creator:r,revoking:i,onRevoke:a}){let o=$e[n],c=n===`active`;return t(`li`,{"data-testid":`admin-token-row`,className:`flex items-start gap-3 px-3 py-2 text-xs ${c?``:`opacity-60`}`,children:[t(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[t(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.name}),s(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${o.cls}`,children:o.label}),t(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:[e.tokenPrefix,`…`]})]}),t(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[t(`span`,{children:[`Created by `,s(`span`,{className:`text-foreground`,children:r})]}),s(`span`,{children:G(e.createdAt)}),s(`span`,{children:n===`revoked`?`Revoked ${G(e.revokedAt)}`:`Expires ${G(e.expiresAt)}`}),s(`span`,{children:e.lastUsedAt===null?`Never used`:`Last used ${G(e.lastUsedAt)}`})]})]}),c&&t(`button`,{onClick:a,disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[i?s(M,{className:`h-3 w-3 animate-spin`}):s(d,{className:`h-3 w-3`}),`Revoke`]})]})}e();function nt({token:e,label:n,onClose:r}){let[i,a]=o(!1),c=async()=>{try{await navigator.clipboard.writeText(e),a(!0)}catch{}};return t(rt,{title:`Token: ${n}`,onClose:r,children:[t(`div`,{className:`space-y-3`,children:[s(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:`Copy this token now. Once you close this dialog the secret cannot be displayed again.`}),s(`div`,{className:`rounded border border-border bg-background p-2 font-mono text-[11px] break-all select-all`,children:e})]}),t(it,{children:[t(`button`,{onClick:()=>{c()},className:`inline-flex items-center gap-1.5 rounded bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[i?s(v,{className:`h-3.5 w-3.5 text-primary`}):s(B,{className:`h-3.5 w-3.5`}),i?`Copied`:`Copy`]}),s(`button`,{onClick:r,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Done`})]})]})}function rt({title:e,onClose:n,children:r}){return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),s(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:s(m,{className:`h-4 w-4`})})]}),s(`div`,{className:`p-4`,children:r})]})})}function it({children:e}){return s(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:e})}function J({label:e,hint:n,children:r}){return t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:e}),r,n&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:n})]})}e();var at=7,ot=90,st=80,ct=`w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-danger`;function lt(e){let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=ot?t:null}function ut(){let{user:e}=K();return e?.isAdmin?s(dt,{}):null}function dt(){let e=j(),r=y.useUtils(),i=y.auth.listAdminTokens.useQuery(),{data:a}=F(),{requestProof:c,dialog:l}=xe(`Creating an admin token`),[u,d]=o(``),[f,p]=o(String(at)),[m,h]=o(null),[g,_]=o(!1),[v,b]=o(null),x=()=>{r.auth.listAdminTokens.invalidate(),r.auth.listAuthAudit.invalidate()},S=y.auth.createAdminToken.useMutation({onSuccess:({token:e,record:t})=>{x(),d(``),p(String(at)),b({token:e,label:t.name})},onError:e=>h(`Create failed: ${e.message}`)}),C=y.auth.revokeAdminToken.useMutation({onSuccess:x,onError:e=>h(`Revoke failed: ${e.message}`)}),w=n(()=>{let e=new Map;for(let t of a??[])e.set(t.id,t.username);return e},[a]),T=u.trim(),E=lt(f),D=T.length>0&&T.length<=st&&E!==null&&!S.isPending&&!g,O=async()=>{if(!D||E===null)return;h(null),_(!0);let e=await c();_(!1),e!==null&&S.mutate({name:T,expiresInDays:E,reauthToken:e})},k=async t=>{await e({title:`Revoke admin token "${t.name}"?`,message:`Every script using it loses access immediately. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&(h(null),C.mutate({id:t.id}))};return t(`div`,{"data-testid":`admin-tokens`,className:`rounded-lg border border-danger/40 bg-surface overflow-hidden`,children:[l,t(`div`,{className:`px-4 py-2.5 border-b border-danger/30 bg-danger/5 flex items-center gap-2`,children:[s(W,{className:`h-3.5 w-3.5 text-danger`}),s(`div`,{className:`text-xs font-semibold text-danger`,children:`Admin tokens`})]}),t(`div`,{className:`p-4 space-y-3`,children:[t(`div`,{className:`text-[11px] text-foreground-subtle space-y-1`,children:[t(`p`,{children:[`An admin token acts as a `,s(`strong`,{className:`text-foreground`,children:`full administrator`}),` `,`for scripts, e.g.`,` `,s(`code`,{className:`font-mono text-foreground`,children:`node scripts/hub/hub.mjs --token-file <file> …`}),`. Anyone holding it can do anything an admin can.`]}),s(`p`,{children:`It expires in at most 90 days and every use is audited. Creating one asks you to confirm it is you.`})]}),t(`form`,{className:`grid grid-cols-1 sm:grid-cols-[1fr_120px_auto] gap-2 items-end`,onSubmit:e=>{e.preventDefault(),O()},children:[t(`label`,{className:`space-y-1`,children:[s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Token name`}),s(`input`,{value:u,maxLength:st,onChange:e=>d(e.target.value),placeholder:`nightly-backup`,className:ct})]}),t(`label`,{className:`space-y-1`,children:[s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Expires in (days)`}),s(`input`,{type:`number`,min:1,max:ot,value:f,onChange:e=>p(e.target.value),className:ct})]}),t(`button`,{type:`submit`,disabled:!D,className:`inline-flex items-center justify-center gap-1.5 rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50`,children:[S.isPending||g?s(M,{className:`h-3.5 w-3.5 animate-spin`}):s(W,{className:`h-3.5 w-3.5`}),`Create admin token`]})]}),E===null&&t(`div`,{className:`text-[11px] text-danger`,children:[`Expiry must be a whole number of days, 1 to `,ot,`.`]}),m!==null&&s(`div`,{className:`text-[11px] text-danger`,children:m}),s(et,{tokens:i.data??[],isLoading:i.isLoading,loadError:i.isError?i.error?.message??`Request failed`:null,userNameById:w,onRevoke:e=>void k(e),revokingId:C.isPending?C.variables?.id??null:null})]}),v&&s(nt,{token:v.token,label:v.label,onClose:()=>b(null)})]})}function Y(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function ft(e,t){let n=Y(e,`tokenId`);return Y(e,`name`)??(n===null?void 0:t.get(n))??n??`?`}function X(e){return e.filter(e=>e!==null)}function pt(e){let t=Y(e,`prefix`);return t===null?null:`Prefix ${t}…`}function mt(e,t){let n=e.detail??{};switch(e.action){case`admin-token-created`:{let e=n.expiresAt;return{title:`Admin token "${ft(n,t)}" created`,details:X([pt(n),typeof e==`number`?`Expires ${G(e)}`:null])}}case`admin-token-used`:{let e=Y(n,`path`);return{title:`Admin token "${ft(n,t)}" used`,details:X([pt(n),e===null?null:`Call ${e}`])}}case`admin-token-revoked`:return{title:`Admin token "${ft(n,t)}" revoked`,details:X([pt(n)])};case`second-factor-skipped`:{let e=Y(n,`method`),t=Y(n,`factors`);return{title:`Second factor skipped on a trusted network`,details:X([e===null?null:`Signed in with ${be(e)}`,t===null?null:`Skipped: ${t.split(`,`).join(`, `)}`])}}default:return{title:e.action,details:Object.entries(n).map(([e,t])=>`${e}: ${String(t)}`)}}}e();var ht=100;function gt(){let{user:e}=K();return e?.isAdmin?s(vt,{}):null}function _t(){let{data:e}=F(),{data:t}=y.auth.listAdminTokens.useQuery();return n(()=>{let n=new Map;for(let t of e??[])n.set(t.id,t.username);let r=new Map;for(let e of t??[])r.set(e.id,e.name);return{userNameById:n,tokenNameById:r}},[e,t])}function vt(){let e=y.auth.listAuthAudit.useQuery({limit:ht}),{userNameById:n,tokenNameById:r}=_t(),i=e.data??[];return t(`div`,{"data-testid":`auth-audit`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[s(se,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`div`,{className:`text-xs font-semibold text-foreground`,children:`Authentication audit`}),t(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:[`Latest `,ht,`, newest first`]})]}),s(`div`,{className:`p-4`,children:e.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(M,{className:`h-3.5 w-3.5 animate-spin`}),`Loading audit trail…`]}):e.isError?t(`div`,{className:`text-[11px] text-danger`,children:[`Could not load the audit trail: `,e.error?.message??`Request failed`]}):i.length===0?s(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:`No authentication events recorded yet.`}):s(`ul`,{className:`divide-y divide-border rounded-md border border-border max-h-[420px] overflow-y-auto`,children:i.map(e=>s(yt,{record:e,userName:e.userId===void 0?null:n.get(e.userId)??e.userId,tokenNameById:r},e.id))})})]})}function yt({record:e,userName:n,tokenNameById:r}){let i=mt(e,r);return t(`li`,{"data-testid":`auth-audit-row`,className:`px-3 py-2 text-xs space-y-0.5`,children:[t(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[s(`span`,{className:`font-medium text-foreground`,children:i.title}),s(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:G(e.at)})]}),t(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n!==null&&s(`span`,{className:`text-foreground`,children:n}),e.ip!==void 0&&s(`span`,{className:`font-mono`,children:e.ip}),i.details.map(e=>s(`span`,{className:`font-mono`,children:e},e))]})]})}e();function bt({users:e,onClose:n,onSubmit:r,submitting:i}){let{user:a}=K(),c=a?.isAdmin===!0?null:a?.scopes??[],[l,u]=o(e[0]?.id??``),[d,f]=o(``),[p,m]=o([{type:`capability`,target:``,access:[`view`,`create`]}]),[h,g]=o(``),_=k(p),v=l!==``&&d.trim().length>0&&p.length>0&&_===null&&!i;return t(rt,{title:`Create scoped token`,onClose:n,children:[t(`div`,{className:`space-y-3`,children:[s(J,{label:`On behalf of user`,children:s(`select`,{value:l,onChange:e=>u(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary`,children:e.map(e=>s(`option`,{value:e.id,children:e.username},e.id))})}),s(J,{label:`Name`,children:s(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`cloudflare-tunnel-route`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary`})}),t(J,{label:`Scopes`,hint:`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`,children:[s(D,{value:p,onChange:m,clampToParent:c}),_&&s(`p`,{className:`mt-1 text-[10px] text-danger`,children:_})]}),s(J,{label:`Expires in (days)`,hint:`Leave blank for non-expiring.`,children:s(`input`,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value),placeholder:`30`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary`})})]}),t(it,{children:[s(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),t(`button`,{onClick:()=>{let e=parseInt(h,10),t=Number.isFinite(e)&&e>0?Date.now()+e*864e5:void 0;r({userId:l,name:d.trim(),scopes:p,expiresAt:t})},disabled:!v,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:[i?s(M,{className:`h-3.5 w-3.5 animate-spin`}):s(z,{className:`h-3.5 w-3.5`}),`Issue token`]})]})]})}e();var xt=`bg-primary/10 text-primary`,St=`bg-foreground-subtle/10 text-foreground-subtle`;function Z(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function Ct(e){return e?e===`*`?`*`:e.join(`, `):``}function wt(){let e=a(),r=j(),{data:i,isLoading:c}=ue(),{data:l}=F(),u=n(()=>i??[],[i]),f=n(()=>l??[],[l]),m=()=>e.invalidateQueries({queryKey:[[`userManagement`,`listApiKeys`]]}),h=()=>e.invalidateQueries({queryKey:[[`userManagement`,`listScopedTokens`]]}),[g,_]=o(!1),[v,y]=o(null),b=p({onSuccess:m}),x=C({onSuccess:({token:e,record:t})=>{h(),_(!1),y({token:e,label:t.name})}}),S=fe({onSuccess:h}),w=async(e,t)=>{await r({title:`Revoke "${t}"?`,message:`Any client using this token will lose access immediately. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&b.mutate({id:e})},T=async(e,t)=>{await r({title:`Revoke "${t}"?`,message:`The scoped token will be invalid on its next use.`,confirmLabel:`Revoke`,variant:`danger`})&&S.mutate({id:e})};return t(q,{children:[t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[s(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Issue scoped tokens to grant a user a narrow surface — a specific addon, integration, or capability. Every token MUST be scoped: revoking it has predictable blast radius.`}),t(`button`,{onClick:()=>_(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,disabled:f.length===0,title:f.length===0?`Create a user first`:`Issue a scoped token`,children:[s(z,{className:`h-3.5 w-3.5`}),`New token`]})]}),t(Tt,{title:`Scoped tokens`,subtitle:`Grouped per user`,children:[f.length===0&&s(Dt,{text:`No users yet — scoped tokens are issued on behalf of an existing user.`}),f.map(e=>s(kt,{userId:e.id,username:e.username,onRevoke:(e,t)=>{T(e,t)},revokePending:S.isPending,revokeId:S.variables?.id},e.id))]}),s(ye,{}),s(ut,{}),s(gt,{}),u.length>0&&s(Tt,{title:`Legacy API keys`,subtitle:`${u.length} pre-existing — revoke only`,children:s(Ot,{headers:[`Label`,`Admin`,`Prefix`,`Allowed providers`,`Created`,`Last used`,``],rows:u.map(e=>{let n=!!e.isAdmin,r=b.isPending&&b.variables?.id===e.id;return t(`tr`,{className:`hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-medium`,children:e.label}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:s(`span`,{className:`inline-block rounded px-2 py-0.5 text-[10px] uppercase tracking-wide ${n?xt:St}`,children:n?`admin`:`regular`})}),t(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-mono text-[11px]`,children:[e.tokenPrefix,`…`]}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border text-foreground-subtle`,children:Ct(e.allowedProviders)||`all`}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:Z(e.createdAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:Z(e.lastUsedAt)}),s(`td`,{className:`px-3 py-2 border-b border-border text-right`,children:t(`button`,{onClick:()=>{w(e.id,e.label)},disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Revoke`,children:[r?s(M,{className:`h-3 w-3 animate-spin`}):s(d,{className:`h-3 w-3`}),`Revoke`]})})]},e.id)})})}),c&&s(Et,{}),g&&s(bt,{users:f.map(e=>({id:e.id,username:e.username})),onClose:()=>_(!1),onSubmit:e=>x.mutate({userId:e.userId,name:e.name,scopes:e.scopes,...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}),submitting:x.isPending}),v&&s(nt,{token:v.token,label:v.label,onClose:()=>y(null)})]})}function Tt({title:e,subtitle:n,children:r}){return t(`div`,{className:`space-y-2`,children:[t(`div`,{className:`flex items-baseline justify-between`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),n&&s(`span`,{className:`text-[10px] text-foreground-subtle`,children:n})]}),r]})}function Et(){return s(`div`,{className:`space-y-2`,children:[1,2].map(e=>s(`div`,{className:`h-10 rounded border border-border bg-surface animate-pulse`},e))})}function Dt({text:e}){return s(`div`,{className:`rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center`,children:e})}function Ot({headers:e,rows:n}){return s(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full text-xs min-w-[640px]`,children:[s(`thead`,{children:s(`tr`,{children:e.map((t,n)=>s(`th`,{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${n===e.length-1?`text-right`:`text-left`}`,children:t},n))})}),s(`tbody`,{children:n})]})})}function kt({userId:e,username:n,onRevoke:r,revokePending:i,revokeId:a}){let{data:o,isLoading:c}=N({userId:e}),l=o??[];return c||l.length===0?null:t(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-medium text-foreground`,children:n}),s(Ot,{headers:[`Name`,`Prefix`,`Scopes`,`Expires`,`Last used`,`Created`,``],rows:l.map(e=>{let n=i&&a===e.id;return t(`tr`,{className:`hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-medium`,children:e.name}),t(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-mono text-[11px]`,children:[e.tokenPrefix,`…`]}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:s(`div`,{className:`flex flex-wrap gap-1`,children:e.scopes.map((e,n)=>t(`span`,{className:`inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono`,children:[e.type,`:`,e.type===`device`?`[${A(e.selector)}]`:e.target]},n))})}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:Z(e.expiresAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:Z(e.lastUsedAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:Z(e.createdAt)}),s(`td`,{className:`px-3 py-2 border-b border-border text-right`,children:t(`button`,{onClick:()=>r(e.id,e.name),disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[n?s(M,{className:`h-3 w-3 animate-spin`}):s(d,{className:`h-3 w-3`}),`Revoke`]})})]},e.id)})})]})}e();function At(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function jt(e){if(e.type===`category`){let t=e.target??``;return t===`device`?`all devices`:`all ${t}`}if(e.type===`device`)return`device:[${(e.targets??[]).join(`,`)}]`;let t=e;return`${t.type}:${t.target??``}`}function Mt(){return s(`div`,{className:`space-y-2`,children:[1,2].map(e=>s(`div`,{className:`h-10 rounded border border-border bg-surface animate-pulse`},e))})}function Nt({text:e}){return s(`div`,{className:`rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center`,children:e})}function Pt({headers:e,rows:n}){return s(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full text-xs min-w-[640px]`,children:[s(`thead`,{children:s(`tr`,{children:e.map((t,n)=>s(`th`,{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${n===e.length-1?`text-right`:`text-left`}`,children:t},n))})}),s(`tbody`,{children:n})]})})}function Ft(){let e=a(),r=j(),{data:i,isLoading:o}=P(),c=n(()=>i??[],[i]),l=L({onSuccess:()=>e.invalidateQueries({queryKey:[[`userManagement`,`listOauthSessions`]]})}),u=async(e,t)=>{await r({title:`Revoke "${t}" session?`,message:`This integration will lose access immediately on its next API call. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&l.mutate({id:e})};return t(q,{icon:ze,title:`Linked Sessions`,subtitle:`External integrations (Alexa, …) linked to this hub via OAuth. Revoke a session to immediately invalidate that integration's access.`,children:[o&&s(Mt,{}),!o&&c.length===0&&s(Nt,{text:`No linked sessions — once an external integration completes the OAuth flow its session will appear here.`}),!o&&c.length>0&&s(Pt,{headers:[`Integration`,`User`,`Scopes`,`Created`,`Last used`,`Status`,``],rows:c.map(e=>{let n=e.revokedAt!==null,r=(l.isPending?l.variables?.id:void 0)===e.id;return t(`tr`,{className:`hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-medium`,children:e.integrationId}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:e.username}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:s(`div`,{className:`flex flex-wrap gap-1`,children:e.scopes.map((e,t)=>s(`span`,{className:`inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono`,children:jt(e)},t))})}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:At(e.createdAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:At(e.lastUsedAt)}),s(`td`,{className:`px-3 py-2 border-b border-border`,children:n?t(`span`,{className:`inline-block rounded bg-foreground-subtle/10 px-2 py-0.5 text-[10px] text-foreground-subtle`,children:[`Revoked `,At(e.revokedAt)]}):s(`span`,{className:`inline-block rounded bg-emerald-500/15 px-2 py-0.5 text-[10px] text-emerald-700 dark:text-emerald-300`,children:`Active`})}),s(`td`,{className:`px-3 py-2 border-b border-border text-right`,children:!n&&t(`button`,{onClick:()=>{u(e.id,e.integrationId)},disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Revoke`,children:[r?s(M,{className:`h-3 w-3 animate-spin`}):s(d,{className:`h-3 w-3`}),`Revoke`]})})]},e.id)})})]})}e();var It=3e4,Q=[{capName:`auth-provider`,stageBadge:null},{capName:`user-passkeys`,stageBadge:`Second factor`}],$={title:`Authentication`,subtitle:`Login providers (local password, OIDC, SAML) and second-factor providers (passkeys / WebAuthn). They run in parallel — enable or disable each independently; disabling one only removes that method, local password login is unaffected.`,emptyTitle:`No authentication providers registered`,emptyDescription:`Local auth should always be available — if this list is empty the local-auth builtin failed to register. Check the Addons page for load errors.`,installLabel:`Add provider`};function Lt(e){return e===`local-auth`?{headline:`Username + password (local).`,icon:Re,bullets:[`Users live in the hub’s SQLite database — no IdP roundtrip.`,`TOTP / 2FA is self-enrolled: each user enables it from their own profile page (My access → Two-factor authentication).`,`API keys + scoped tokens are managed from the API Keys page.`],setupSteps:[`A fresh hub has one account, admin / changeme — the first sign-in asks for a new password. Add users from Users → New user.`,`Hand out either passwords or scoped tokens — both validate through this provider.`]}:e.startsWith(`auth-oidc`)?{headline:`OpenID Connect (Google, Microsoft, Okta, Keycloak, …).`,icon:Oe,bullets:[`Three-leg redirect flow with PKCE S256 + nonce.`,`id_token is signature-verified against the IdP’s JWKS — no implicit trust.`,`Explicit linking only: an IdP account signs in only the CamStack user who linked it from their profile (My access → Linked sign-in accounts). No auto-created users, no email matching.`,`The linked user’s role, scopes and two-factor authentication apply.`],setupSteps:[`Register a web app at your IdP and copy the client_id + client_secret.`,"Set the redirect URI to `https://<this-hub>/addon/<addon-id>/callback`.",`Paste issuer + credentials in the Settings panel below — saves on every change.`,`Each user then links their IdP account from My access → Linked sign-in accounts.`]}:e.startsWith(`auth-saml`)?{headline:`SAML 2.0 — enterprise SSO (Azure AD, Okta, OneLogin).`,icon:Oe,bullets:[`Heavier handshake than OIDC — exchange metadata XML with your IdP.`,`Group → role mapping via SAML assertions.`]}:e.startsWith(`auth-webauthn`)||e.startsWith(`auth-passkey`)?{headline:`Passkeys / WebAuthn — passwordless second factor.`,icon:U,bullets:[`Enroll a YubiKey, Touch ID, or platform passkey per user.`,`Resistant to phishing — the browser binds the credential to your hub origin.`]}:e.startsWith(`auth-totp`)?{headline:`TOTP — second factor.`,icon:U,bullets:[`Time-based codes from an authenticator app (RFC 6238).`,`Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc.`]}:{headline:`Authentication provider.`,icon:z,bullets:[`Generic authentication provider. No additional hints registered.`]}}function Rt(){let e=me({capName:Q[0].capName},{refetchInterval:It}),t=me({capName:Q[1].capName},{refetchInterval:It}),r=pe(void 0,{refetchInterval:It}),i=n(()=>Ie(r.data??[]),[r.data]),a=n(()=>{let n=[],r=[e.data??[],t.data??[]];for(let[e,t]of Q.entries())for(let a of r[e]??[])n.push({addonId:a.addonId,displayName:i.get(a.addonId)??a.addonId,isActive:a.isActive,capName:t.capName,stageBadge:t.stageBadge});return n},[e.data,t.data,i]),o=[{id:`authentication`,label:`Authentication providers`,install:{capability:Q[0].capName,label:$.installLabel},entries:a.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:z,...Fe(e.isActive),render:()=>s(Me,{addonId:e.addonId,displayName:e.displayName,capName:e.capName,isActive:e.isActive,badges:e.stageBadge===null?null:s(I,{variant:`info`,className:Ne,children:e.stageBadge}),panels:[{id:`about`,title:`About`,icon:Lt(e.addonId).icon,content:s(zt,{addonId:e.addonId})}]})}))}];return s(Pe,{icon:z,title:$.title,subtitle:$.subtitle,groups:o,isLoading:e.isLoading||t.isLoading,emptyTitle:$.emptyTitle,emptyDescription:$.emptyDescription})}function zt({addonId:e}){let n=Lt(e),r=n.icon;return t(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-2 sm:p-4`,children:[t(`div`,{className:`flex items-start gap-2.5`,children:[s(r,{className:`h-4 w-4 mt-0.5 text-primary shrink-0`}),s(`div`,{className:`text-xs text-foreground font-medium`,children:n.headline})]}),s(`ul`,{className:`text-xs text-foreground-subtle space-y-1.5 pl-6 list-disc`,children:n.bullets.map((e,t)=>s(`li`,{children:e},t))}),n.setupSteps&&n.setupSteps.length>0&&t(`div`,{className:`rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5`,children:[t(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:[s(Le,{className:`h-3 w-3`}),`Setup steps`]}),s(`ol`,{className:`text-xs text-foreground space-y-0.5 pl-4 list-decimal`,children:n.setupSteps.map((e,t)=>s(`li`,{children:e},t))})]}),e===`local-auth`&&t(`div`,{className:`rounded-md border border-blue-500/30 bg-blue-500/5 px-3 py-2 flex items-start gap-2 text-[11px] text-foreground`,children:[s(H,{className:`h-3.5 w-3.5 mt-0.5 text-blue-500 shrink-0`}),t(`span`,{children:[`TOTP / 2FA is self-service: each user enrols from their own profile page —`,` `,s(Ee,{to:`/system/my-access`,className:`underline text-primary`,children:`My access`}),` `,`→ “Two-factor authentication” → Enable 2FA. Admins can only remove a user’s active enrollment (lost device) from the`,` `,s(Ee,{to:`/system/identity?tab=users`,className:`underline text-primary`,children:`Users`}),` `,`page via Actions → “Remove 2FA”.`]})]})]})}function Bt(){return s(`div`,{className:`flex flex-col p-4`,children:s(je,{tabs:[{id:`users`,label:`Users`,icon:h,content:s(Ye,{})},{id:`api-keys`,label:`Tokens`,icon:T,content:s(wt,{})},{id:`linked-sessions`,label:`Linked Sessions`,icon:ze,content:s(Ft,{})},{id:De.authentication.tab,label:`Authentication`,icon:z,content:s(Rt,{}),ownedParams:ke}]})})}export{Bt as IdentityPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as s,st as c,ut as l,vt as u}from"./player-overlays-rpfoGg2b.js";import{Cn as d,Eu as f,Kd as p,Mn as m,Pd as h,Sn as g,Un as _,Vd as v,Zl as y,_n as b,aa as x,bn as S,dd as C,fu as w,xn as T,yn as E}from"./src-BQ0U3gDQ.js";import{L as D,a as O,tt as k}from"./index-CArA6N_R.js";var A=u(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),j=40,M=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],N=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],P=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function F(e,t){return e.find(e=>e.test.test(t))?.name??null}function I(e){return e.length<=j?e:`${e.slice(0,j)}…`}function L(e){if(e===null||e.trim().length===0)return{label:`Unknown device`,raw:null};let t=e.trim(),n=F(P,t);if(n!==null)return{label:n,raw:t};let r=F(M,t),i=F(N,t);return r!==null&&i!==null?{label:`${r} on ${i}`,raw:t}:r===null?{label:I(t),raw:t}:{label:r,raw:t}}var R={password:`Password`,passkey:`Passkey`,sso:`Single sign-on`,handoff:`App hand-off`,exchange:`Session exchange`};function z(e){return R[e]??e}function B(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function V({sessions:e,isLoading:t,loadError:n,emptyText:i,onRevoke:a,revokingId:s}){return t?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(v,{className:`h-3.5 w-3.5 animate-spin`}),`Loading sessions…`]}):n===null?e.length===0?o(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:i}):o(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(H,{session:e,revoking:s===e.id,onRevoke:()=>a(e)},e.id))}):r(`div`,{className:`text-[11px] text-danger`,children:[`Could not load sessions: `,n]})}function H({session:e,revoking:t,onRevoke:n}){let i=L(e.client);return r(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[o(h,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),r(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`span`,{className:`font-medium text-foreground truncate`,title:i.raw??void 0,children:i.label}),e.current&&o(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:`This device`})]}),r(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[o(`span`,{children:z(e.method)}),o(`span`,{className:`font-mono`,children:e.ip??`IP unknown`}),r(`span`,{children:[`Last active `,B(e.lastUsedAt)]}),r(`span`,{children:[`Expires `,B(e.expiresAt)]})]})]}),!e.current&&r(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[t?o(v,{className:`h-3 w-3 animate-spin`}):o(k,{className:`h-3 w-3`}),`Sign out`]})]})}n();var U={"grid-view":`Grid`,"events-view":`Events`};function W(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function G(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function K({links:e,isLoading:t,loadError:n,deviceNameById:i,ownerNameById:a,emptyText:s,onRevoke:c,revokingId:l,now:u=Date.now()}){return t?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(v,{className:`h-3.5 w-3.5 animate-spin`}),`Loading share links…`]}):n===null?e.length===0?o(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:s}):o(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(q,{link:e,cameras:G(e.scope.deviceIds,i),owner:a?a.get(e.userId)??e.userId:null,expired:e.expiresAt!==null&&e.expiresAt<=u,revoking:l===e.id,onRevoke:()=>c(e)},e.id))}):r(`div`,{className:`text-[11px] text-danger`,children:[`Could not load share links: `,n]})}function q({link:e,cameras:t,owner:n,expired:i,revoking:a,onRevoke:s}){return r(`li`,{"data-testid":`share-link-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[r(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:U[e.scope.kind]}),e.scope.talk===!0&&r(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-warning/15 px-1.5 py-0.5 text-[10px] font-medium text-warning`,children:[o(l,{className:`h-2.5 w-2.5`}),`talk-back`]}),n!==null&&o(`span`,{className:`font-medium text-foreground`,children:n}),r(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:[e.tokenPrefix,`…`]})]}),o(`div`,{className:`text-foreground truncate`,title:t,children:t}),r(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:[`Created `,W(e.createdAt)]}),r(`span`,{children:[`Expires`,` `,e.expiresAt===null?o(`span`,{children:`never`}):r(`span`,{className:i?`text-danger`:void 0,children:[W(e.expiresAt),i?` (expired)`:``]})]}),o(`span`,{children:e.lastUsedAt===void 0?`Never used`:`Last used ${W(e.lastUsedAt)}`})]})]}),r(`button`,{onClick:s,disabled:a,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a?o(v,{className:`h-3 w-3 animate-spin`}):o(c,{className:`h-3 w-3`}),`Revoke`]})]})}function J(e){let t=_(),n=f.useUtils(),r=f.auth.listShareTokens.useQuery({owner:e}),{data:o}=x({isCamera:!0,projection:`slim`}),[s,c]=a(null),l=f.auth.revokeShareToken.useMutation({onSuccess:()=>void n.auth.listShareTokens.invalidate(),onError:e=>c(e.message)}),u=i(()=>{let e=new Map;for(let t of o??[])e.set(t.id,t.name);return e},[o]),d=async e=>{await t({title:`Revoke share link`,message:`Anyone holding this link to ${G(e.scope.deviceIds,u)} loses access immediately. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&(c(null),l.mutate({id:e.id}))};return{links:r.data??[],isLoading:r.isLoading,loadError:r.isError?r.error?.message??`Request failed`:null,deviceNameById:u,revokeError:s,revokingId:l.isPending?l.variables?.id??null:null,onRevoke:e=>void d(e)}}function Y({title:e,description:t,children:n}){return r(`div`,{"data-testid":`share-links`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[o(C,{className:`h-3.5 w-3.5 text-foreground-subtle`}),o(`div`,{className:`text-xs font-semibold text-foreground`,children:e})]}),r(`div`,{className:`p-4 space-y-3`,children:[o(`p`,{className:`text-[11px] text-foreground-subtle`,children:t}),n]})]})}function X({message:e}){return e===null?null:r(`div`,{className:`text-[11px] text-danger`,children:[`Revoke failed: `,e]})}function Z(){let e=J(`self`);return r(Y,{title:`Share links`,description:`View-only links you created in the viewer app to share a grid or the events of some cameras. Revoking a link stops it working everywhere it was sent.`,children:[o(X,{message:e.revokeError}),o(K,{links:e.links,isLoading:e.isLoading,loadError:e.loadError,deviceNameById:e.deviceNameById,emptyText:`You have no share links.`,onRevoke:e.onRevoke,revokingId:e.revokingId})]})}function Q(){let{user:e}=D();return e?.isAdmin?o(ee,{}):null}function ee(){let e=J(`all`),{data:t}=y(),n=i(()=>{let e=new Map;for(let n of t??[])e.set(n.id,n.username);return e},[t]);return r(Y,{title:`Share links`,description:`Every user's view-only share links. Revoking one stops it working for whoever it was sent to.`,children:[o(X,{message:e.revokeError}),o(K,{links:e.links,isLoading:e.isLoading,loadError:e.loadError,deviceNameById:e.deviceNameById,ownerNameById:n,emptyText:`No user has any share links.`,onRevoke:e.onRevoke,revokingId:e.revokingId})]})}n();function $(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function te(n){let i=s(),[c,l]=a(!1),[u,f]=a(``),[h,_]=a(null),[y,x]=a(null),C=t(null),D=e(e=>{C.current?.(e),C.current=null,l(!1),f(``),_(null),x(null)},[]),k=e(()=>new Promise(e=>{C.current?.(null),C.current=e,x(null),l(!0)}),[]),A=async()=>{_(`password`),x(null);try{let{reauthToken:e}=await i.reauthenticate({password:u});D(e)}catch(e){x($(e,`Password is incorrect`)),_(null)}},j=async()=>{_(`passkey`),x(null);try{let{optionsJSON:e}=await i.reauthBeginPasskey(),t=await O({optionsJSON:e}),{reauthToken:n}=await i.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});D(n)}catch(e){x($(e,`Passkey verification failed`)),_(null)}};return{requestProof:k,dialog:o(b,{open:c,onOpenChange:e=>!e&&D(null),children:r(E,{children:[r(g,{children:[o(d,{children:`Confirm it’s you`}),r(S,{children:[n,` needs your password or a passkey, even though you are signed in.`]})]}),r(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&h===null&&A()},children:[o(w,{type:`password`,autoComplete:`current-password`,placeholder:`Current password`,value:u,onChange:e=>f(e.target.value),"aria-label":`Current password`}),y!==null&&o(`p`,{role:`alert`,className:`text-xs text-danger`,children:y}),r(T,{className:`flex flex-wrap gap-2`,children:[r(m,{type:`button`,variant:`outline`,disabled:h!==null,onClick:()=>void j(),children:[h===`passkey`?o(v,{className:`h-4 w-4 animate-spin`}):o(p,{className:`h-4 w-4`}),`Use a passkey`]}),r(m,{type:`submit`,disabled:u.length===0||h!==null,children:[h===`password`&&o(v,{className:`h-4 w-4 animate-spin`}),`Confirm`]})]})]})]})})}}export{L as a,A as c,V as i,Q as n,z as o,Z as r,B as s,te as t};
|