@camstack/addon-admin-ui 1.2.480 → 1.2.482

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/assets/{AddonAssetIcon-Dl8uxsbh.js → AddonAssetIcon-5z0Vljts.js} +1 -1
  2. package/dist/assets/Addons-CZCGnQMQ.js +5 -0
  3. package/dist/assets/{AdminPage-CSXKwqkg.js → AdminPage-BGeHUp9l.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-BKgqha3i.js → AdminSectionedPage-DDyHO_ip.js} +1 -1
  5. package/dist/assets/AiProfiles--zkaLy_B.js +3 -0
  6. package/dist/assets/{BrokerForm-DXNZ4XDs.js → BrokerForm-B2kpU1t2.js} +1 -1
  7. package/dist/assets/Build-rWgY-SZM.js +40 -0
  8. package/dist/assets/{Calendars-BMYW6Lcd.js → Calendars-iNmeiE9F.js} +1 -1
  9. package/dist/assets/{Cluster-DcCFmoWl.js → Cluster-VomkBaK2.js} +1 -1
  10. package/dist/assets/{CompositionBlockEditor-CS7j_Q0n.js → CompositionBlockEditor-BkEr_zwe.js} +1 -1
  11. package/dist/assets/{CompositionEditorPage-BzXIuasc.js → CompositionEditorPage-DbJxXBa9.js} +1 -1
  12. package/dist/assets/Data-CCEKKeDE.js +2 -0
  13. package/dist/assets/{DeviceDetail-DTa2bPN4.js → DeviceDetail-D9LiDoGw.js} +2 -2
  14. package/dist/assets/{DeviceDoActionFields-C0BliAs3.js → DeviceDoActionFields-CLGT6wrU.js} +1 -1
  15. package/dist/assets/{Devices-BF451zpL.js → Devices-CeNeFo6w.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-BYk9lSle.js → EmbedPlayerPage-DhPeEblh.js} +1 -1
  17. package/dist/assets/HelperWizard-Uk1HvQ9Z.js +2 -0
  18. package/dist/assets/{History-DwCuiCyt.js → History-BSXemVAg.js} +1 -1
  19. package/dist/assets/Identity-DUUQUaLn.js +1 -0
  20. package/dist/assets/IntegrationDetail-Cg5a23zE.js +1 -0
  21. package/dist/assets/{IntegrationHub-CurQ0MIP.js → IntegrationHub-C0mqR6_4.js} +1 -1
  22. package/dist/assets/Integrations-B7G_Cpwv.js +1 -0
  23. package/dist/assets/Integrations-J8r1M--P.js +1 -0
  24. package/dist/assets/{Library-DP1Wr2c7.js → Library-B32BJFM3.js} +1 -1
  25. package/dist/assets/Locations-qBrWJ5eA.js +3 -0
  26. package/dist/assets/{Logs-Bd5V0nh-.js → Logs-Bdustfdg.js} +1 -1
  27. package/dist/assets/MyAccess-BkcUaVmh.js +2 -0
  28. package/dist/assets/Network-BrDFqhC5.js +1 -0
  29. package/dist/assets/{NodeAddonsSettingsPanel-DkJRjjUs.js → NodeAddonsSettingsPanel-DsSbHT51.js} +1 -1
  30. package/dist/assets/{Notifications-BKotbSiz.js → Notifications-BPK2WNL-.js} +1 -1
  31. package/dist/assets/{Pipeline-DdvNlpdi.js → Pipeline-CNlBiPEC.js} +1 -1
  32. package/dist/assets/Recordings-BrCuLKqt.js +1 -0
  33. package/dist/assets/{ScanNetworkModal-DoDbqBMU.js → ScanNetworkModal-tiMZttK7.js} +1 -1
  34. package/dist/assets/SessionsList-fLonifFr.js +2 -0
  35. package/dist/assets/{Showroom-DX5blOP5.js → Showroom-BuzmfCLW.js} +1 -1
  36. package/dist/assets/{System-Cj0zNzyx.js → System-B5axMnbq.js} +1 -1
  37. package/dist/assets/{Terminal-CrQfybLK.js → Terminal-BxmZLjAl.js} +3 -3
  38. package/dist/assets/{Viewer-NPWQx4Po.js → Viewer-DKhlTfCg.js} +1 -1
  39. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-vDZqJbgM.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-ChRFbBue.js} +1 -1
  40. package/dist/assets/{addon-icons-context-C_QjLbbK.js → addon-icons-context-DY_rAsap.js} +1 -1
  41. package/dist/assets/{assignment-candidates-B-td3IjI.js → assignment-candidates-BpQXQnWA.js} +1 -1
  42. package/dist/assets/{authed-media-DmqjjIKA.js → authed-media-vxjhgNZq.js} +1 -1
  43. package/dist/assets/{board-model-j7i6ZAYf.js → board-model-BpmGz42d.js} +1 -1
  44. package/dist/assets/{device-integration-icon-Ch_ZPOzM.js → device-integration-icon-CPDmGsoD.js} +1 -1
  45. package/dist/assets/device-picker-model-Z8NhIJHV.js +1 -0
  46. package/dist/assets/{format-uKtM7bQx.js → format-D4oZ2Oti.js} +1 -1
  47. package/dist/assets/{hostInit-BW_Uzp68.js → hostInit-DVizgo6V.js} +1 -1
  48. package/dist/assets/i18n-DRa6-1Ye.js +1 -0
  49. package/dist/assets/index-BO95XcLa.js +4 -0
  50. package/dist/assets/{linked-devices-model-ou0VkTvM.js → linked-devices-model-Cnqr55pr.js} +1 -1
  51. package/dist/assets/{location-owned-usage-CQzY3VS7.js → location-owned-usage-pJJy4BTC.js} +1 -1
  52. package/dist/assets/{mf-entry-bootstrap-0-a83f6fea.js → mf-entry-bootstrap-0-be603f7b.js} +2 -2
  53. package/dist/assets/mount-Z8NhIJHV.js +1 -0
  54. package/dist/assets/remoteEntry-ClU628tf.js +1 -0
  55. package/dist/assets/{src-Kh1mC91U.js → src-BZ8j9Q2T.js} +9 -9
  56. package/dist/assets/{step-inspector-model-X_yncKWE.js → step-inspector-model-BvwTAgYG.js} +1 -1
  57. package/dist/assets/{use-scenes-feed-tvKKb38m.js → use-scenes-feed-16-Xn-4f.js} +1 -1
  58. package/dist/assets/{use-stationary-objects-CXoxdg6S.js → use-stationary-objects-Dfi4P7en.js} +1 -1
  59. package/dist/assets/useEventInvalidation-Z8NhIJHV.js +1 -0
  60. package/dist/assets/{useNodeUrlSelection-BKeCycvy.js → useNodeUrlSelection-C6820-b7.js} +1 -1
  61. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-qrmMxESr.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D6C0Wijv.js} +2 -2
  62. package/dist/index.html +6 -6
  63. package/dist/server/addon.js +1 -1
  64. package/package.json +1 -1
  65. package/dist/assets/Addons-D0-Lkqak.js +0 -5
  66. package/dist/assets/AiProfiles-PVMMhQkj.js +0 -3
  67. package/dist/assets/Build-CoXA7FyI.js +0 -40
  68. package/dist/assets/Data-xdGxogBF.js +0 -2
  69. package/dist/assets/HelperWizard-Dne7XMRs.js +0 -2
  70. package/dist/assets/Identity-BxOtJf9f.js +0 -1
  71. package/dist/assets/IntegrationDetail-CNdjHgkg.js +0 -1
  72. package/dist/assets/Integrations-BDnjzX7X.js +0 -1
  73. package/dist/assets/Integrations-CkJHWfhP.js +0 -1
  74. package/dist/assets/Locations-J4ikH0b7.js +0 -3
  75. package/dist/assets/MyAccess-BjobXXGx.js +0 -2
  76. package/dist/assets/Network-xmsnvwQH.js +0 -1
  77. package/dist/assets/Recordings-Bc6TV4zS.js +0 -1
  78. package/dist/assets/SessionsList-Ci2UotT9.js +0 -2
  79. package/dist/assets/device-picker-model-Ch3e43SQ.js +0 -1
  80. package/dist/assets/i18n-D1Cc22Zf.js +0 -1
  81. package/dist/assets/index-C8EgBFV_.js +0 -4
  82. package/dist/assets/mount-Ch3e43SQ.js +0 -1
  83. package/dist/assets/remoteEntry-Bisv2xsg.js +0 -1
  84. package/dist/assets/useEventInvalidation-Ch3e43SQ.js +0 -1
@@ -1 +1 @@
1
- import{t as e}from"./i18n-D1Cc22Zf.js";import{t}from"./assignment-candidates-B-td3IjI.js";function n(e){return e.slot===`linked-devices`}function r(t){if(t.status===`error`)return{kind:`unknown`,reason:t.error?.message??e.t(`helpers.customize.requestFailed`)};if(t.status===`pending`||t.data===void 0)return{kind:`pending`};for(let e of t.data)if(e.state===`ok`&&e.slot===`linked-devices`&&n(e.value))return{kind:`present`,slot:e,value:e.value};let r=t.data.find(e=>e.state===`unreachable`);return r!==void 0&&r.state===`unreachable`?{kind:`unknown`,reason:r.reason}:{kind:`absent`}}function i(e,t){let n=t.trackedDeviceIds??[],r=e=>t=>({deviceId:t.deviceId,name:t.name,health:t.health,implied:e,tracked:n.includes(t.deviceId)});return[...e.sources.map(r(!1)),...(e.impliedSources??[]).map(r(!0))]}function a(e,t){let n=new Set([...e.sources,...e.impliedSources??[]].map(e=>e.deviceId));return(t.trackedDeviceIds??[]).filter(e=>!n.has(e))}function o(e,t){return{...e,deviceIds:[...e.deviceIds,...t.filter(t=>!e.deviceIds.includes(t))]}}function s(e,t){return{...e,deviceIds:e.deviceIds.filter(e=>e!==t),...e.trackedDeviceIds===void 0?{}:{trackedDeviceIds:e.trackedDeviceIds.filter(e=>e!==t)}}}function c(e,t,n){let r=e.trackedDeviceIds??[],i=n?[...r.filter(e=>e!==t),t]:r.filter(e=>e!==t);return{...e,trackedDeviceIds:i}}function l(e,n,r){return e.flatMap(e=>{let i=n.get(e.deviceId);return r.has(e.deviceId)||i===void 0?[]:[{deviceId:e.deviceId,ref:{addonId:i.addonId,stableId:i.stableId},name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,detail:t(i.integration,e.location),meta:e.type,caps:[],value:null}]})}export{o as a,a as i,i as n,c as o,r,s,l as t};
1
+ import{t as e}from"./i18n-DRa6-1Ye.js";import{t}from"./assignment-candidates-BpQXQnWA.js";function n(e){return e.slot===`linked-devices`}function r(t){if(t.status===`error`)return{kind:`unknown`,reason:t.error?.message??e.t(`helpers.customize.requestFailed`)};if(t.status===`pending`||t.data===void 0)return{kind:`pending`};for(let e of t.data)if(e.state===`ok`&&e.slot===`linked-devices`&&n(e.value))return{kind:`present`,slot:e,value:e.value};let r=t.data.find(e=>e.state===`unreachable`);return r!==void 0&&r.state===`unreachable`?{kind:`unknown`,reason:r.reason}:{kind:`absent`}}function i(e,t){let n=t.trackedDeviceIds??[],r=e=>t=>({deviceId:t.deviceId,name:t.name,health:t.health,implied:e,tracked:n.includes(t.deviceId)});return[...e.sources.map(r(!1)),...(e.impliedSources??[]).map(r(!0))]}function a(e,t){let n=new Set([...e.sources,...e.impliedSources??[]].map(e=>e.deviceId));return(t.trackedDeviceIds??[]).filter(e=>!n.has(e))}function o(e,t){return{...e,deviceIds:[...e.deviceIds,...t.filter(t=>!e.deviceIds.includes(t))]}}function s(e,t){return{...e,deviceIds:e.deviceIds.filter(e=>e!==t),...e.trackedDeviceIds===void 0?{}:{trackedDeviceIds:e.trackedDeviceIds.filter(e=>e!==t)}}}function c(e,t,n){let r=e.trackedDeviceIds??[],i=n?[...r.filter(e=>e!==t),t]:r.filter(e=>e!==t);return{...e,trackedDeviceIds:i}}function l(e,n,r){return e.flatMap(e=>{let i=n.get(e.deviceId);return r.has(e.deviceId)||i===void 0?[]:[{deviceId:e.deviceId,ref:{addonId:i.addonId,stableId:i.stableId},name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,detail:t(i.integration,e.location),meta:e.type,caps:[],value:null}]})}export{o as a,a as i,i as n,c as o,r,s,l as t};
@@ -1 +1 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,En as l,Fn as u,It as d,Sr as f,dt as p,kn as m,or as h,ot as g,xi as _,yi as v,zr as y}from"./player-overlays-By2E2OWX.js";import{aa as b}from"./client-COfGFdJB.js";import{t as x}from"./archive-W1ZaOIy6.js";import{t as S}from"./eraser-C0EhIwNf.js";import{t as C}from"./hard-drive-download-CrDu4V4S.js";import{Jl as ee,Kr as w,Sn as T,Wr as E,_r as D,bt as te,hr as ne,mi as O,mr as re,ou as ie,pr as ae,vr as k,yr as A}from"./src-Kh1mC91U.js";import{t as j}from"./i18n-D1Cc22Zf.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{F as oe,ur as se}from"./index-C8EgBFV_.js";import{t as N}from"./format-size-DIxKXxtj.js";o();function P(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function F(e,t){let n=P(t);return`${e}:${n.length>0?n:`default`}`}var I=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`]),L=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function R(e){let t=L.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?L.length:t}function ce(e){return e.filter(e=>!e.name.startsWith(`.`)&&!I.has(e.name)).toSorted((e,t)=>{let n=R(e.name)-R(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function le({nodeId:t,value:o,onChange:s}){let{t:c}=M(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(ce(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(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 S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function z({initialType:n,onClose:i,onCreated:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[_,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,j]=a(`hub`),[N,P]=a(null),[I,L]=a(!1),R=e=>x(t=>({...t,basePath:e})),ce=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=t(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),U=t(()=>w!==null&&w.length>0?w:F(p,S),[p,S,w]),ue=async()=>{if(_){L(!0),P(null);try{P(await(e=>u.storage.testConfig.query(e))({providerId:_.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{L(!1)}}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[d]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:p})]})]}),e(re,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[V&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!V&&B.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(se,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),B.map(t=>e(`button`,{onClick:()=>{y(t),f(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(v,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(oe,{schema:_.configSchema,values:b,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(le,{nodeId:O,value:ce,onChange:R})]}),N&&r(`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?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:N.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{ue()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),d===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:p,displayName:_.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`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:U,onChange:e=>T(e.target.value),placeholder:F(p,S),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`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`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&&r(`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)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{m(n),y(null),x({}),C(``),T(null),D(!1),P(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&H.mutate({id:U,type:p,displayName:S.trim(),providerId:_.providerId,config:b,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:H.isPending||S.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?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function B(e){return b(e)}function V(e){return e===`active`}var H=[{mode:`active`,get label(){return j.t(`helpers.locationMode.activeLabel`)},get consequence(){return j.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return j.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return j.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return j.t(`helpers.locationMode.drainLabel`)},get consequence(){return j.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return j.t(`helpers.locationMode.disabledLabel`)},get consequence(){return j.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ue(e){return U(e).requiresConfirmation}var de=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function pe(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function me(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function he(e,t){let n={...t.config??e.config};t.mode!==void 0&&(me(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:me(t.mode).enabled}}var ge=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(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 ve(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function ye(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 be(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 xe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ge;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Se(e){return e===`gb`?j.t(`helpers.locationProtection.unitGb`):j.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?j.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?j.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):j.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return j.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function we(e){return G(e.maxUsedGb)}function Te(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ge,reason:t===`drain`?`drain`:`legacy`}}o();function Ee({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=M(),[s,c]=a(()=>_e(t).unit),l=ve(t,s),u={unit:s,value:l},d=we(t),f=e=>{c(e),i(ye(t,{unit:e,value:null}))},p=e=>{i(ye(t,{unit:s,value:be(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(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:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Se(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(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`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ce(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function De({location:n,onClose:i,onSaved:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[_,v]=a(null),[y,b]=a(!1),x=ee(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),T=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[O,j]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),N=typeof d.basePath==`string`?d.basePath:``,P=e=>f(t=>({...t,basePath:e})),F=S?.minFreePercent??10,I=async()=>{b(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(re,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),S&&r(oe,{schema:S.configSchema,values:d,onChange:f}),E&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(le,{nodeId:O,value:N,onChange:P})]}),T&&r(Ee,{config:d,defaultPercent:F,onChange:f}),!S&&!x.isLoading&&r(`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:r(se,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),_&&r(`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?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:_.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(D,{className:`justify-between`,children:[r(w,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(w,{variant:`outline`,size:`sm`,onClick:()=>{I()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(w,{size:`sm`,onClick:()=>{C.mutate(he(n,{displayName:p.trim(),config:d,nodeId:E?O:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function Oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ke(e){if(!Oe(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 Ae(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=ke(n);e!==null&&t.set(e.locationId,e)}return t}function je(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 Me(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:je(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ne(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Pe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Fe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Ie({drain:t}){let{t:n}=M();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`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:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Pe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`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:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Fe(t.estimatedEmptyAtMs)})]})]})}var Le=[`ok`,`warn`,`critical`];function Re(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function ze(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=ze((n-t)/n);return{fraction:r,severity:Re(r),recordingsFraction:ze(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Be(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||Le.indexOf(e.severity)>Le.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}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 Ve(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?j.t(`helpers.locationCapacityBar.unknownSummary`):j.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}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?Re(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:j.t(`helpers.locationCapacityBar.reserveKept`,{size:N(s)}),owned:f===null||_===null?null:j.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:N(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?j.t(`helpers.locationCapacityBar.capDrain`,{size:N(v.bytes)}):j.t(`helpers.locationCapacityBar.capCap`,{size:N(v.bytes)})},S=[j.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:j.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?j.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?j.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:j.t(`helpers.locationCapacityBar.legendKeptFree`),value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:j.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?j.t(`helpers.locationCapacityBar.legendUsed`):j.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:j.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?j.t(`helpers.locationCapacityBar.legendDrainTarget`):j.t(`helpers.locationCapacityBar.legendCap`),value:j.t(`helpers.locationCapacityBar.legendCapValue`,{size:N(v.bytes)}),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 He={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 Ue(e,t){return e===`used`?He[t]:Z[e]}function We({location:t,ownedBytes:n}){let{t:i}=M(),a=t.capacity??null,o=xe(_e(t.config),a?.totalBytes??null),s=Ve({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Te(t.config,B(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:Z.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:Z.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:He[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:Z.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${Ue(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ge={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ke={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},qe=`storage.discardLocation`,Je=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ge[e]??null}function Ze(e){return Ke[e]??null}function Qe(e){return!V(B(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var et=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 tt(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`||!et.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 nt(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}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=M(),o=E(),s=O(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,g]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Je,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let _=l!==null&&l.locationId===t.id,v=_&&l.running,y=_&&l.phase!==`idle`,b=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),g(!0);try{await s.mutateAsync({addonId:c,action:qe,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Je,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}}},x=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`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:[r(p,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void b(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`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:[m?r(h,{className:`h-3 w-3 animate-spin`}):r(S,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||_&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:l,readonly:x,drain:C,disabled:y},st={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 ct({mode:t,open:n,onToggle:i}){let{t:a}=M(),o=U(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(_,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=M();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(p,{className:`h-3 w-3`})})]}),H.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(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 dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=M(),[h,g]=a(!1),_=ut(t.config),v=B(t);return e(`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:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`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:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(We,{location:t,ownedBytes:p??null}),f!==void 0&&r(Ie,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),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:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=M(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:f,testId:`storage-location-group-${n}`,actions:o===`multi`?e(w,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(m,{className:`h-3 w-3`}),_(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`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:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:_(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),v.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?_(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):_(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),v.length>0&&r(`div`,{className:`border-t border-border`,children:v.map(e=>r(dt,{location:e,cardinality:o,canDelete:pe(e,v,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:fe(e,v),ownedBytes:h?.get(e.id)??null,drain:Me(Ne(e),g?.get(e.id)),siblings:v},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{Ae as a,U as c,Be as i,ue as l,ft as n,De as o,q as r,he as s,gt as t,z as u};
1
+ import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,En as l,Fn as u,It as d,Sr as f,dt as p,kn as m,or as h,ot as g,xi as _,yi as v,zr as y}from"./player-overlays-By2E2OWX.js";import{aa as b}from"./client-COfGFdJB.js";import{t as x}from"./archive-W1ZaOIy6.js";import{t as S}from"./eraser-C0EhIwNf.js";import{t as C}from"./hard-drive-download-CrDu4V4S.js";import{Kr as w,Sn as T,Wr as E,Xl as ee,_r as D,bt as te,cu as ne,hr as re,mi as O,mr as ie,pr as ae,vr as k,yr as A}from"./src-BZ8j9Q2T.js";import{t as j}from"./i18n-DRa6-1Ye.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{F as oe,ur as se}from"./index-BO95XcLa.js";import{t as N}from"./format-size-DIxKXxtj.js";o();function P(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function F(e,t){let n=P(t);return`${e}:${n.length>0?n:`default`}`}var I=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`]),L=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function R(e){let t=L.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?L.length:t}function ce(e){return e.filter(e=>!e.name.startsWith(`.`)&&!I.has(e.name)).toSorted((e,t)=>{let n=R(e.name)-R(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function le({nodeId:t,value:o,onChange:s}){let{t:c}=M(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(ce(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(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 S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function z({initialType:n,onClose:i,onCreated:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[_,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,j]=a(`hub`),[N,P]=a(null),[I,L]=a(!1),R=e=>x(t=>({...t,basePath:e})),ce=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=t(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=ne({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),U=t(()=>w!==null&&w.length>0?w:F(p,S),[p,S,w]),ue=async()=>{if(_){L(!0),P(null);try{P(await(e=>u.storage.testConfig.query(e))({providerId:_.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{L(!1)}}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(re,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[d]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:p})]})]}),e(ie,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[V&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!V&&B.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(se,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),B.map(t=>e(`button`,{onClick:()=>{y(t),f(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(v,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(oe,{schema:_.configSchema,values:b,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(le,{nodeId:O,value:ce,onChange:R})]}),N&&r(`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?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:N.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{ue()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),d===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:p,displayName:_.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`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:U,onChange:e=>T(e.target.value),placeholder:F(p,S),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`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`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&&r(`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)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{m(n),y(null),x({}),C(``),T(null),D(!1),P(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&H.mutate({id:U,type:p,displayName:S.trim(),providerId:_.providerId,config:b,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:H.isPending||S.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?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function B(e){return b(e)}function V(e){return e===`active`}var H=[{mode:`active`,get label(){return j.t(`helpers.locationMode.activeLabel`)},get consequence(){return j.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return j.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return j.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return j.t(`helpers.locationMode.drainLabel`)},get consequence(){return j.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return j.t(`helpers.locationMode.disabledLabel`)},get consequence(){return j.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ue(e){return U(e).requiresConfirmation}var de=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function pe(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function me(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function he(e,t){let n={...t.config??e.config};t.mode!==void 0&&(me(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:me(t.mode).enabled}}var ge=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(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 ve(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function ye(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 be(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 xe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ge;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Se(e){return e===`gb`?j.t(`helpers.locationProtection.unitGb`):j.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?j.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?j.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):j.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return j.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function we(e){return G(e.maxUsedGb)}function Te(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ge,reason:t===`drain`?`drain`:`legacy`}}o();function Ee({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=M(),[s,c]=a(()=>_e(t).unit),l=ve(t,s),u={unit:s,value:l},d=we(t),f=e=>{c(e),i(ye(t,{unit:e,value:null}))},p=e=>{i(ye(t,{unit:s,value:be(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(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:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Se(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(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`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ce(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function De({location:n,onClose:i,onSaved:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[_,v]=a(null),[y,b]=a(!1),x=ee(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ne({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),T=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[O,j]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),N=typeof d.basePath==`string`?d.basePath:``,P=e=>f(t=>({...t,basePath:e})),F=S?.minFreePercent??10,I=async()=>{b(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(re,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(ie,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),S&&r(oe,{schema:S.configSchema,values:d,onChange:f}),E&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(le,{nodeId:O,value:N,onChange:P})]}),T&&r(Ee,{config:d,defaultPercent:F,onChange:f}),!S&&!x.isLoading&&r(`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:r(se,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),_&&r(`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?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:_.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(D,{className:`justify-between`,children:[r(w,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(w,{variant:`outline`,size:`sm`,onClick:()=>{I()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(w,{size:`sm`,onClick:()=>{C.mutate(he(n,{displayName:p.trim(),config:d,nodeId:E?O:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function Oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ke(e){if(!Oe(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 Ae(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=ke(n);e!==null&&t.set(e.locationId,e)}return t}function je(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 Me(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:je(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ne(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Pe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Fe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Ie({drain:t}){let{t:n}=M();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`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:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Pe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`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:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Fe(t.estimatedEmptyAtMs)})]})]})}var Le=[`ok`,`warn`,`critical`];function Re(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function ze(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=ze((n-t)/n);return{fraction:r,severity:Re(r),recordingsFraction:ze(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Be(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||Le.indexOf(e.severity)>Le.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}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 Ve(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?j.t(`helpers.locationCapacityBar.unknownSummary`):j.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}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?Re(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:j.t(`helpers.locationCapacityBar.reserveKept`,{size:N(s)}),owned:f===null||_===null?null:j.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:N(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?j.t(`helpers.locationCapacityBar.capDrain`,{size:N(v.bytes)}):j.t(`helpers.locationCapacityBar.capCap`,{size:N(v.bytes)})},S=[j.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:j.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?j.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?j.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:j.t(`helpers.locationCapacityBar.legendKeptFree`),value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:j.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?j.t(`helpers.locationCapacityBar.legendUsed`):j.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:j.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?j.t(`helpers.locationCapacityBar.legendDrainTarget`):j.t(`helpers.locationCapacityBar.legendCap`),value:j.t(`helpers.locationCapacityBar.legendCapValue`,{size:N(v.bytes)}),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 He={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 Ue(e,t){return e===`used`?He[t]:Z[e]}function We({location:t,ownedBytes:n}){let{t:i}=M(),a=t.capacity??null,o=xe(_e(t.config),a?.totalBytes??null),s=Ve({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Te(t.config,B(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:Z.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:Z.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:He[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:Z.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${Ue(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ge={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ke={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},qe=`storage.discardLocation`,Je=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ge[e]??null}function Ze(e){return Ke[e]??null}function Qe(e){return!V(B(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var et=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 tt(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`||!et.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 nt(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}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=M(),o=E(),s=O(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,g]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Je,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let _=l!==null&&l.locationId===t.id,v=_&&l.running,y=_&&l.phase!==`idle`,b=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),g(!0);try{await s.mutateAsync({addonId:c,action:qe,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Je,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}}},x=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`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:[r(p,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void b(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`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:[m?r(h,{className:`h-3 w-3 animate-spin`}):r(S,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||_&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:l,readonly:x,drain:C,disabled:y},st={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 ct({mode:t,open:n,onToggle:i}){let{t:a}=M(),o=U(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(_,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=M();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(p,{className:`h-3 w-3`})})]}),H.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(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 dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=M(),[h,g]=a(!1),_=ut(t.config),v=B(t);return e(`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:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`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:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(We,{location:t,ownedBytes:p??null}),f!==void 0&&r(Ie,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),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:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=M(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:f,testId:`storage-location-group-${n}`,actions:o===`multi`?e(w,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(m,{className:`h-3 w-3`}),_(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`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:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:_(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),v.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?_(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):_(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),v.length>0&&r(`div`,{className:`border-t border-border`,children:v.map(e=>r(dt,{location:e,cardinality:o,canDelete:pe(e,v,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:fe(e,v),ownedBytes:h?.get(e.id)??null,drain:Me(Ne(e),g?.get(e.id)),siblings:v},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{Ae as a,U as c,Be as i,ue as l,ft as n,De as o,q as r,he as s,gt as t,z as u};
@@ -12,8 +12,8 @@ const __mfImport = (src) =>
12
12
 
13
13
 
14
14
  (async () => {
15
- const __mfHostInit = await __mfImport("./hostInit-BW_Uzp68.js");
15
+ const __mfHostInit = await __mfImport("./hostInit-DVizgo6V.js");
16
16
  await __mfHostInit.__tla;
17
17
  const { initHost } = __mfHostInit;
18
18
  await initHost();
19
- })().then(() => __mfImport("./index-C8EgBFV_.js"));
19
+ })().then(() => __mfImport("./index-BO95XcLa.js"));
@@ -0,0 +1 @@
1
+ import"./src-BZ8j9Q2T.js";
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D6C0Wijv.js";export{t as get,e as init};