@camstack/addon-admin-ui 1.2.13 → 1.2.15

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 (95) hide show
  1. package/dist/assets/AddLocationWizard-BzfZuUFE.js +1 -0
  2. package/dist/assets/{AddonCollectionPage-DYquwbFT.js → AddonCollectionPage-D4dNkjD9.js} +1 -1
  3. package/dist/assets/Addons-KlOfEhx8.js +1 -0
  4. package/dist/assets/{AdminTabs-zSfrI6J9.js → AdminTabs-B6qnIaak.js} +1 -1
  5. package/dist/assets/{AiProfiles-Cx4S2Xkn.js → AiProfiles-DnuLTZqB.js} +1 -1
  6. package/dist/assets/{BrokerForm-1PckGyVt.js → BrokerForm-C99fSuRo.js} +1 -1
  7. package/dist/assets/{Capabilities-DAgsQGgg.js → Capabilities-B8SGK49R.js} +1 -1
  8. package/dist/assets/{CapabilityBadges-DNN-Wcn_.js → CapabilityBadges-BTZKlfM2.js} +1 -1
  9. package/dist/assets/{Cluster-tHXKC3rK.js → Cluster-COcBiWpg.js} +1 -1
  10. package/dist/assets/{ClusterRecordingTab-CSv5S75g.js → ClusterRecordingTab-BPSdzcK3.js} +1 -1
  11. package/dist/assets/{Dashboard-hoLQH06K.js → Dashboard-DCFIPV11.js} +1 -1
  12. package/dist/assets/{Data-BG8m8LaL.js → Data-_pY_q5xu.js} +1 -1
  13. package/dist/assets/{DetectionIntelligence-MFZJV9-v.js → DetectionIntelligence-B6Dj5dVX.js} +1 -1
  14. package/dist/assets/DeviceDetail-N6WvCekZ.js +2 -0
  15. package/dist/assets/{Devices-5G2YiKkY.js → Devices-Dzpvq_f7.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-jG_j7yUQ.js → EmbedPlayerPage-CNBEeRdP.js} +1 -1
  17. package/dist/assets/Events-B5T59IPR.js +1 -0
  18. package/dist/assets/{FormBuilder-CiMiy3vQ.js → FormBuilder-CMFZXwvq.js} +1 -1
  19. package/dist/assets/{Identity-pmhb-jIF.js → Identity-BbNZdgPf.js} +1 -1
  20. package/dist/assets/IntegrationDetail-DEPSilP_.js +1 -0
  21. package/dist/assets/{Integrations-CLYqdNHv.js → Integrations-B1Ld1HH1.js} +1 -1
  22. package/dist/assets/{Integrations-83V72pmh.js → Integrations-B3rD6hIo.js} +1 -1
  23. package/dist/assets/{Logs-B0w1rIre.js → Logs-CYpS3BpR.js} +1 -1
  24. package/dist/assets/{MotionZonesSettings-DbtzjXBB.js → MotionZonesSettings-2auRIiQ1.js} +1 -1
  25. package/dist/assets/{MyAccess-nniMr2oJ.js → MyAccess-D3_q9-33.js} +1 -1
  26. package/dist/assets/Network-DIVAg_f5.js +1 -0
  27. package/dist/assets/{NodeAddonsSettingsPanel-CDNzzco1.js → NodeAddonsSettingsPanel-CgGvimGW.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-CJmWaPa6.js → NodeInferenceDevices-COSPUL-L.js} +1 -1
  29. package/dist/assets/{Notifications-CjH_7Mrn.js → Notifications-Bv4whDil.js} +1 -1
  30. package/dist/assets/Pipeline-l_vZ2VML.js +1 -0
  31. package/dist/assets/{Plates-Dy8Uqgga.js → Plates-C96Mahmu.js} +1 -1
  32. package/dist/assets/{PrivacyMaskSettings-D7rqLqim.js → PrivacyMaskSettings-C2PIvv63.js} +1 -1
  33. package/dist/assets/{ProviderIcon-B-fRGGgK.js → ProviderIcon-DQ9yuo_L.js} +1 -1
  34. package/dist/assets/{Recordings-BV351EeV.js → Recordings-C2R7zGta.js} +1 -1
  35. package/dist/assets/{ScanNetworkModal-Uw3hg1ai.js → ScanNetworkModal-Cl1Mdjki.js} +1 -1
  36. package/dist/assets/{Settings-CVkG5Y5G.js → Settings-CvCaq_zC.js} +1 -1
  37. package/dist/assets/{Showroom-B-d2WdW_.js → Showroom-BCsIYYwv.js} +1 -1
  38. package/dist/assets/Terminal-BpPIZ0or.js +13 -0
  39. package/dist/assets/Terminal-kHJ-D0s7.css +1 -0
  40. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D02gABkF.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BALp_9qY.js} +1 -1
  41. package/dist/assets/{build-cluster-graph-vmA5yA4M.js → build-cluster-graph-cp3KQH-1.js} +1 -1
  42. package/dist/assets/circle-check-big-4_1SeqzL.js +1 -0
  43. package/dist/assets/clock-CmbYDH1e.js +1 -0
  44. package/dist/assets/{copy-DGD_D0fl.js → copy-UBfFgSz-.js} +1 -1
  45. package/dist/assets/{debounced-invalidate-OsMHAbLS.js → debounced-invalidate-BsGZbF6v.js} +1 -1
  46. package/dist/assets/dist-CphRM5WA.js +7 -0
  47. package/dist/assets/{dist-DO_uCRhe.js → dist-CvIYYU5j.js} +1 -1
  48. package/dist/assets/{download-DAdvlREf.js → download-BpNiVwyM.js} +1 -1
  49. package/dist/assets/{face-bbox-D-tm4cNu.js → face-bbox-BScALk_z.js} +1 -1
  50. package/dist/assets/{hostInit-DJqsmyYG.js → hostInit-DFZvs0Jw.js} +1 -1
  51. package/dist/assets/index-0YJ-haW4.css +2 -0
  52. package/dist/assets/index-Cl-M8KBA.js +4 -0
  53. package/dist/assets/{key-round-pEZFmYxy.js → key-round-BPb5gRuL.js} +1 -1
  54. package/dist/assets/{mf-entry-bootstrap-0-81564783.js → mf-entry-bootstrap-0-1f1c06da.js} +2 -2
  55. package/dist/assets/{pencil-CQfM-gfd.js → pencil-Bcfk7YmX.js} +1 -1
  56. package/dist/assets/{player-overlays-Z3KIJoY4.js → player-overlays-CpNYQPHP.js} +1 -1
  57. package/dist/assets/plus-z-WZstU2.js +1 -0
  58. package/dist/assets/{radio-xNJ7grGy.js → radio-BH-ZU1HE.js} +1 -1
  59. package/dist/assets/{refresh-cw-D6O4UC61.js → refresh-cw-hhKexEfo.js} +1 -1
  60. package/dist/assets/remoteEntry-C6sBv4xP.js +1 -0
  61. package/dist/assets/{rotate-ccw--NZkK553.js → rotate-ccw-CbpUNSqs.js} +1 -1
  62. package/dist/assets/rotate-cw-CQj7EyBl.js +1 -0
  63. package/dist/assets/search-DqoMv21b.js +1 -0
  64. package/dist/assets/{send-5-cXx4t3.js → send-Cyy_G5i9.js} +1 -1
  65. package/dist/assets/{server-CejZYHBK.js → server-BxRe5xIW.js} +1 -1
  66. package/dist/assets/square-CEBWDX93.js +1 -0
  67. package/dist/assets/{square-check-big-vugmEemF.js → square-check-big-hPLl5NdC.js} +1 -1
  68. package/dist/assets/src-Cv9CvT8c.js +7 -0
  69. package/dist/assets/{src-DmOEfaLx.js → src-DHFCkQHW.js} +10 -10
  70. package/dist/assets/{upload-C59L2Wdl.js → upload-C6Q1-uQx.js} +1 -1
  71. package/dist/assets/{useEventInvalidation-D-pUhceB.js → useEventInvalidation-Bh_CgFlD.js} +1 -1
  72. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BLiSxcpg.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C9LrTlPE.js} +2 -2
  73. package/dist/assets/{wifi-Dl3Y5-yO.js → wifi-CL8vr9lV.js} +1 -1
  74. package/dist/assets/{zap-DDoGra5X.js → zap-DZXxY1Hy.js} +1 -1
  75. package/dist/index.html +6 -6
  76. package/dist/server/addon.js +2247 -2079
  77. package/package.json +3 -1
  78. package/dist/assets/AddLocationWizard-DbYmoWjx.js +0 -1
  79. package/dist/assets/Addons-B21MzGyu.js +0 -1
  80. package/dist/assets/DeviceDetail-Cb_hP9AH.js +0 -2
  81. package/dist/assets/Events-DuWWYRlK.js +0 -1
  82. package/dist/assets/IntegrationDetail-BjegrPYt.js +0 -1
  83. package/dist/assets/Network-xntFbRy8.js +0 -1
  84. package/dist/assets/Pipeline-Cn32tJhF.js +0 -1
  85. package/dist/assets/circle-check-big-CbpJhu8J.js +0 -1
  86. package/dist/assets/clock-D8VWqfVX.js +0 -1
  87. package/dist/assets/dist-hhplA-xw.js +0 -7
  88. package/dist/assets/index-DO10ga5L.css +0 -2
  89. package/dist/assets/index-dCklXrvt.js +0 -4
  90. package/dist/assets/plus-CqnkUqMJ.js +0 -1
  91. package/dist/assets/remoteEntry-C2M3CZjx.js +0 -1
  92. package/dist/assets/rotate-cw-CJNm_D4O.js +0 -1
  93. package/dist/assets/search-YJw6yJPL.js +0 -1
  94. package/dist/assets/square-DGtpAb1Z.js +0 -1
  95. package/dist/assets/src-4xaQB5RZ.js +0 -7
@@ -1 +1 @@
1
- import{A as e,T as t,jn as n}from"./src-DmOEfaLx.js";import{I as r,Q as i,S as a,W as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as l}from"./plus-CqnkUqMJ.js";import{C as u,i as d}from"./index-dCklXrvt.js";i();var f=`camstack:dashboard-layout`,p={version:1,widgets:[]};function m(){try{let e=localStorage.getItem(f);if(!e)return p;let t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:p}catch{return p}}function h(e){try{localStorage.setItem(f,JSON.stringify(e))}catch{}}function g(){let e=typeof crypto<`u`?crypto:void 0;return e?.randomUUID?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`}function _(){let[t,n]=s(m),[i,u]=s(!1),d=e(),f=o(()=>d.filter(e=>e.hosts.includes(`dashboard`)),[d]),p=r(e=>{n(e),h(e)},[]),g=r(e=>{p({version:1,widgets:[...t.widgets,e]})},[t,p]),_=r(e=>{p({version:1,widgets:t.widgets.filter(t=>t.instanceId!==e)})},[t,p]);return a(`div`,{className:`p-4`,children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Dashboard`}),a(`button`,{onClick:()=>u(!0),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add widget`]})]}),t.widgets.length===0?c(v,{onAdd:()=>u(!0)}):c(`div`,{className:`grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]`,children:t.widgets.map(e=>c(y,{entry:e,onRemove:()=>_(e.instanceId)},e.instanceId))}),i&&c(x,{widgets:f,onClose:()=>u(!1),onAdd:e=>{g(e),u(!1)}})]})}function v({onAdd:e}){return a(`div`,{className:`flex flex-col items-center justify-center py-24 text-foreground-subtle`,children:[c(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4`,children:c(u,{className:`h-8 w-8 text-foreground-subtle/40`})}),c(`p`,{className:`text-sm font-medium text-foreground/70`,children:`Your dashboard is empty`}),c(`p`,{className:`text-xs text-foreground-subtle mt-1 mb-4`,children:`Add widgets to monitor your cameras and system`}),a(`button`,{onClick:e,className:`flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add your first widget`]})]})}function y({entry:e,onRemove:n}){let r=b(e.columns),i=Math.max(1,Math.min(12,e.rows));return a(`div`,{className:`relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col`,style:{gridColumn:`span ${r} / span ${r}`,gridRow:`span ${i} / span ${i}`},children:[c(`button`,{type:`button`,onClick:n,title:`Remove widget`,className:`absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all`,children:c(d,{className:`h-3 w-3`})}),c(`div`,{className:`flex-1 min-h-0 overflow-auto p-2`,children:c(t,{widgetId:e.widgetId,host:`dashboard`,instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function b(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function x({widgets:e,onClose:t,onAdd:n}){let[r,i]=s(null);return c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:a(`div`,{className:`w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20`,onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:r?`Configure: ${r.label}`:`Add widget`}),c(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,children:c(d,{className:`h-4 w-4`})})]}),r===null?c(S,{widgets:e,onSelect:i}):c(C,{widget:r,onCancel:()=>i(null),onAdd:n})]})})}function S({widgets:e,onSelect:t}){return e.length===0?c(`div`,{className:`text-center py-8 text-xs text-foreground-subtle italic`,children:`No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles.`}):c(`div`,{className:`grid grid-cols-2 gap-2 max-h-96 overflow-auto`,children:e.map(e=>a(`button`,{onClick:()=>t(e),className:`flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group`,children:[c(`span`,{className:`text-xs font-medium text-foreground block`,children:e.label}),c(`span`,{className:`text-[10px] text-foreground-subtle truncate`,title:e.widgetId,children:e.widgetId}),e.description&&c(`span`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-2`,children:e.description})]},e.widgetId))})}function C({widget:e,onCancel:t,onAdd:r}){let[i,o]=s(e.defaultSize),[l,u]=s(e.defaultColumns),[d,f]=s(e.defaultRows),[p,m]=s(null),{data:h}=n({},{enabled:e.requires.deviceContext}),_=!e.requires.deviceContext||p!==null&&p>0;return a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Size`}),c(`div`,{className:`flex items-center gap-1`,children:e.allowedSizes.map(e=>c(`button`,{onClick:()=>o(e),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${i===e?`bg-primary/10 text-primary border-primary/30`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.toUpperCase()},e))})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[c(w,{label:`Columns (1-12)`,value:l,min:1,max:12,onChange:u}),c(w,{label:`Rows (1-12)`,value:d,min:1,max:12,onChange:f})]}),e.requires.deviceContext&&a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Device`}),a(`select`,{value:p??``,onChange:e=>m(e.target.value===``?null:Number(e.target.value)),className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`,children:[c(`option`,{value:``,children:`— select a device —`}),(h??[]).map(e=>a(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),a(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[c(`button`,{onClick:t,className:`px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:`Back`}),c(`button`,{disabled:!_,onClick:()=>{_&&r({instanceId:g(),widgetId:e.widgetId,size:i,columns:l,rows:d,...e.requires.deviceContext&&p!==null?{deviceId:p}:{}})},className:`px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:`Add to dashboard`})]})]})}function w({label:e,value:t,min:n,max:r,onChange:i}){return a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:e}),c(`input`,{type:`number`,min:n,max:r,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(n,Math.min(r,Math.floor(t))))},className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`})]})}function T(){return c(_,{})}export{T as DashboardPage};
1
+ import{A as e,T as t,jn as n}from"./src-DHFCkQHW.js";import{I as r,Q as i,S as a,W as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as l}from"./plus-z-WZstU2.js";import{C as u,i as d}from"./index-Cl-M8KBA.js";i();var f=`camstack:dashboard-layout`,p={version:1,widgets:[]};function m(){try{let e=localStorage.getItem(f);if(!e)return p;let t=JSON.parse(e);return t&&t.version===1&&Array.isArray(t.widgets)?{version:1,widgets:t.widgets}:p}catch{return p}}function h(e){try{localStorage.setItem(f,JSON.stringify(e))}catch{}}function g(){let e=typeof crypto<`u`?crypto:void 0;return e?.randomUUID?e.randomUUID():`widget-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`}function _(){let[t,n]=s(m),[i,u]=s(!1),d=e(),f=o(()=>d.filter(e=>e.hosts.includes(`dashboard`)),[d]),p=r(e=>{n(e),h(e)},[]),g=r(e=>{p({version:1,widgets:[...t.widgets,e]})},[t,p]),_=r(e=>{p({version:1,widgets:t.widgets.filter(t=>t.instanceId!==e)})},[t,p]);return a(`div`,{className:`p-4`,children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Dashboard`}),a(`button`,{onClick:()=>u(!0),className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add widget`]})]}),t.widgets.length===0?c(v,{onAdd:()=>u(!0)}):c(`div`,{className:`grid grid-cols-12 gap-3 auto-rows-[minmax(80px,_auto)]`,children:t.widgets.map(e=>c(y,{entry:e,onRemove:()=>_(e.instanceId)},e.instanceId))}),i&&c(x,{widgets:f,onClose:()=>u(!1),onAdd:e=>{g(e),u(!1)}})]})}function v({onAdd:e}){return a(`div`,{className:`flex flex-col items-center justify-center py-24 text-foreground-subtle`,children:[c(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl bg-surface border border-border mb-4`,children:c(u,{className:`h-8 w-8 text-foreground-subtle/40`})}),c(`p`,{className:`text-sm font-medium text-foreground/70`,children:`Your dashboard is empty`}),c(`p`,{className:`text-xs text-foreground-subtle mt-1 mb-4`,children:`Add widgets to monitor your cameras and system`}),a(`button`,{onClick:e,className:`flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground shadow-md shadow-primary/20 hover:shadow-lg transition-all`,children:[c(l,{className:`h-3.5 w-3.5`}),`Add your first widget`]})]})}function y({entry:e,onRemove:n}){let r=b(e.columns),i=Math.max(1,Math.min(12,e.rows));return a(`div`,{className:`relative group rounded-lg border border-border bg-surface overflow-hidden flex flex-col`,style:{gridColumn:`span ${r} / span ${r}`,gridRow:`span ${i} / span ${i}`},children:[c(`button`,{type:`button`,onClick:n,title:`Remove widget`,className:`absolute right-1.5 top-1.5 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border border-border/60 bg-surface/80 text-foreground-subtle opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger hover:border-danger/40 transition-all`,children:c(d,{className:`h-3 w-3`})}),c(`div`,{className:`flex-1 min-h-0 overflow-auto p-2`,children:c(t,{widgetId:e.widgetId,host:`dashboard`,instanceId:e.instanceId,config:e.config,deviceId:e.deviceId,size:e.size,columns:e.columns,rows:e.rows})})]})}function b(e){return!Number.isFinite(e)||e<1?6:Math.min(12,Math.floor(e))}function x({widgets:e,onClose:t,onAdd:n}){let[r,i]=s(null);return c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:a(`div`,{className:`w-full max-w-2xl rounded-xl border border-border bg-surface p-5 shadow-2xl shadow-black/20`,onClick:e=>e.stopPropagation(),children:[a(`div`,{className:`flex items-center justify-between mb-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:r?`Configure: ${r.label}`:`Add widget`}),c(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,children:c(d,{className:`h-4 w-4`})})]}),r===null?c(S,{widgets:e,onSelect:i}):c(C,{widget:r,onCancel:()=>i(null),onAdd:n})]})})}function S({widgets:e,onSelect:t}){return e.length===0?c(`div`,{className:`text-center py-8 text-xs text-foreground-subtle italic`,children:`No dashboard-host widgets registered. Make sure the contributing addons are enabled and have rebuilt their widget bundles.`}):c(`div`,{className:`grid grid-cols-2 gap-2 max-h-96 overflow-auto`,children:e.map(e=>a(`button`,{onClick:()=>t(e),className:`flex flex-col rounded-lg border border-border p-3 text-left hover:bg-surface-hover hover:border-primary/30 transition-all group`,children:[c(`span`,{className:`text-xs font-medium text-foreground block`,children:e.label}),c(`span`,{className:`text-[10px] text-foreground-subtle truncate`,title:e.widgetId,children:e.widgetId}),e.description&&c(`span`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-2`,children:e.description})]},e.widgetId))})}function C({widget:e,onCancel:t,onAdd:r}){let[i,o]=s(e.defaultSize),[l,u]=s(e.defaultColumns),[d,f]=s(e.defaultRows),[p,m]=s(null),{data:h}=n({},{enabled:e.requires.deviceContext}),_=!e.requires.deviceContext||p!==null&&p>0;return a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Size`}),c(`div`,{className:`flex items-center gap-1`,children:e.allowedSizes.map(e=>c(`button`,{onClick:()=>o(e),className:`px-3 py-1 rounded-md text-[11px] font-medium border transition-colors ${i===e?`bg-primary/10 text-primary border-primary/30`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.toUpperCase()},e))})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[c(w,{label:`Columns (1-12)`,value:l,min:1,max:12,onChange:u}),c(w,{label:`Rows (1-12)`,value:d,min:1,max:12,onChange:f})]}),e.requires.deviceContext&&a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Device`}),a(`select`,{value:p??``,onChange:e=>m(e.target.value===``?null:Number(e.target.value)),className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`,children:[c(`option`,{value:``,children:`— select a device —`}),(h??[]).map(e=>a(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),a(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[c(`button`,{onClick:t,className:`px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:`Back`}),c(`button`,{disabled:!_,onClick:()=>{_&&r({instanceId:g(),widgetId:e.widgetId,size:i,columns:l,rows:d,...e.requires.deviceContext&&p!==null?{deviceId:p}:{}})},className:`px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:`Add to dashboard`})]})]})}function w({label:e,value:t,min:n,max:r,onChange:i}){return a(`div`,{children:[c(`label`,{className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:e}),c(`input`,{type:`number`,min:n,max:r,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&i(Math.max(n,Math.min(r,Math.floor(t))))},className:`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none`})]})}function T(){return c(_,{})}export{T as DashboardPage};
@@ -1 +1 @@
1
- import{Et as e,Gt as t,Ha as n,Ht as r,Ia as i,Jt as a,Kt as o,Ut as s,Vt as c,Wt as l,Yt as u,bt as d,ca as f,fa as p,la as m,qt as h,ua as g,xt as _}from"./src-DmOEfaLx.js";import{I as v,Q as y,S as b,W as x,b as S,o as C,q as w,x as T,z as E}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as D}from"./src-4xaQB5RZ.js";import{t as O}from"./download-DAdvlREf.js";import{i as k,n as A,r as j,t as M}from"./AddLocationWizard-DbYmoWjx.js";import{t as N}from"./AddonCollectionPage-DYquwbFT.js";import{t as P}from"./plus-CqnkUqMJ.js";import{t as F}from"./rotate-cw-CJNm_D4O.js";import{H as ee,I,P as te,S as L,W as R,i as z,m as B,s as V}from"./index-dCklXrvt.js";import{t as H}from"./AdminPage-Dq33XE9j.js";import{n as ne}from"./authed-media-XfBD4Ma-.js";import{t as U}from"./format-size-CO9d3C3-.js";import{t as re}from"./AdminTabs-zSfrI6J9.js";import{t as ie}from"./addon-display-names-DvSEQty-.js";var W=R(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),G=R(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),K=R(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),q=R(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);y();function J(){let e=C(),t=i(),{data:n,isLoading:r,isError:a}=g({}),o=m(),s=x(()=>o.data??[],[o.data]),[c,l]=w(null),[u,d]=w(null),h=f({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),_=p({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),v=e=>{e.isDefault||_.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},y=async e=>{if(e.isDefault){await t({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await t({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&h.mutate({id:e.id})},S=x(()=>{let e=new Map;for(let t of n??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[n]),E=r||o.isLoading,D=a||o.isError;return b(H,{children:[E&&T(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),D&&T(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!E&&!D&&b(`div`,{className:`space-y-3`,children:[s.length===0&&T(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),s.map(e=>T(j,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:S.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{y(e)},onSetDefault:e=>v(e)},e.id))]}),c!==null&&T(M,{initialType:c,onClose:()=>l(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),l(null)}}),u!==null&&T(A,{location:u,onClose:()=>d(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(null)}})]})}y();var Y=[[`backup`,`listDestinations`]],ae=[`backup`,`listArchives`];function oe({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){let r=C(),a=i(),{data:o,isLoading:l,isError:u}=s({destinationId:e}),d=o??[],f=c({onSuccess:()=>{r.invalidateQueries({queryKey:[[...ae]]}),r.invalidateQueries({queryKey:Y})}}),p=v(async t=>{await a({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${U(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({destinationId:e,backupId:t.id})},[a,e,f]),[m,h]=w(null),g=v(async t=>{h(t.id);try{let n=await ne(se(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{h(null)}},[e]),_=x(()=>[...d].toSorted((e,t)=>t.createdAt-e.createdAt),[d]);return l?T(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):u?T(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):_.length===0?T(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):T(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[640px]`,children:[T(`thead`,{children:b(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[T(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),T(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),T(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),T(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),T(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),T(`tbody`,{children:_.map(r=>b(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[T(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:ce(r.createdAt)}),T(`td`,{className:`px-3 py-1.5 text-foreground`,children:r.label??T(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),T(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:r.locations.join(`, `)}),T(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:U(r.sizeBytes)}),T(`td`,{className:`px-3 py-1.5`,children:b(`div`,{className:`flex items-center justify-end gap-1`,children:[b(`button`,{onClick:()=>{g(r)},disabled:m===r.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[m===r.id?T(L,{className:`h-3 w-3 animate-spin`}):T(O,{className:`h-3 w-3`}),`Download`]}),t&&n&&b(`button`,{onClick:()=>n({destinationId:e,archiveId:r.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[T(F,{className:`h-3 w-3`}),`Restore`]}),T(`button`,{onClick:()=>{p(r)},disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:f.isPending?T(L,{className:`h-3 w-3 animate-spin`}):T(V,{className:`h-3 w-3`})})]})})]},r.id))})]})})}function se(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function ce(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}y();var X=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function le(e){let t=e.trim();for(let e of X)if(e.cron===t)return e.id;return`custom`}function ue({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let i=le(e),[a,s]=w(i===`custom`);E(()=>{i!==`custom`&&s(!1)},[i]);let c=pe(e,250),l=o({cron:c,count:n},{enabled:c.trim().length>0}),u=l.data??null,d=e=>{s(!1),t(e.cron)},f=a||i===`custom`;return b(`div`,{className:`space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[T(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),b(`div`,{className:`flex flex-wrap gap-1.5`,children:[X.map(e=>T(`button`,{type:`button`,onClick:()=>d(e),disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!a&&i===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),T(`button`,{type:`button`,onClick:()=>{s(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(f?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),f&&b(`div`,{className:`space-y-1`,children:[T(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),T(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:r,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),b(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,T(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),T(de,{cron:c,preview:u,loading:l.isFetching})]})}function de({cron:e,preview:t,loading:n}){return n&&t===null?b(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[T(L,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?T(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):b(`div`,{className:`space-y-1`,children:[T(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),T(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>b(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[T(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),T(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:fe(e)})]},`${e}-${t}`))})]}):T(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function fe(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function pe(e,t){let[n,r]=w(e),i=x(()=>e,[e]);return E(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}y();var me=[[`backup`,`listDestinations`]];function he({onCreateAt:e,onOpenRestoreWizard:t}){let{data:n,isLoading:r,isError:i}=l(),a=n??[],[o,s]=w(null),c=e=>{s(t=>t===e?null:e)},u=be();return r?T(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading destinations…`}):i?T(`div`,{className:`text-xs text-danger`,children:`Failed to load destinations`}):a.length===0?T(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:T(`p`,{className:`text-xs text-foreground-subtle`,children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):T(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[720px]`,children:[T(`thead`,{children:b(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[T(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),T(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Destination`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-28`,children:`Retention`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-56`,children:`Schedule`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-44`,children:`Last success`}),T(`th`,{className:`text-right px-3 py-2 font-medium w-44`,children:`Actions`})]})}),T(`tbody`,{children:a.map(n=>{let r=u.get(n.id);return T(ge,{row:n,isOpen:o===n.id,onToggle:()=>c(n.id),onCreateAt:e,liveLastSuccessAt:r?.at,liveLastSuccessSizeBytes:r?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},n.id)})})]})})}function ge({row:e,isOpen:t,onToggle:n,onCreateAt:r,onOpenRestoreWizard:i,liveLastSuccessAt:a,liveLastSuccessSizeBytes:o}){let s=C(),c=u({onSuccess:()=>{s.invalidateQueries({queryKey:me})}}),[l,d]=w(String(e.retentionCount));E(()=>{d(String(e.retentionCount))},[e.retentionCount]);let[f,p]=w(!1),m=v(t=>{c.mutate({locationId:e.id,enabled:t,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[c,e.id,e.retentionCount,e.label,e.cron]),h=v(()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){d(String(e.retentionCount));return}t!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:t,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[c,l,e.id,e.enabled,e.retentionCount,e.label,e.cron]),g=v(t=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},cron:t},{onSuccess:()=>{p(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return b(S,{children:[b(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[T(`td`,{className:`px-2 py-2`,children:T(`button`,{onClick:n,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:t?`Hide archives`:`Show archives`,children:T(t?I:te,{className:`h-3.5 w-3.5`})})}),T(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:n,className:`text-left hover:underline focus:outline-none`,title:`View archives`,children:[T(`div`,{className:`text-foreground font-medium`,children:e.displayName}),b(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[T(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5`,children:e.kind}),T(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]})}),T(`td`,{className:`px-3 py-2`,children:T(`label`,{className:`inline-flex items-center cursor-pointer`,children:T(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:c.isPending,onChange:e=>m(e.target.checked)})})}),T(`td`,{className:`px-3 py-2`,children:T(`input`,{type:`number`,min:1,max:1e3,value:l,disabled:c.isPending,onChange:e=>d(e.target.value),onBlur:h,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&d(String(e.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),T(`td`,{className:`px-3 py-2`,children:T(_e,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>p(!0),disabled:c.isPending})}),T(`td`,{className:`px-3 py-2 text-foreground-subtle`,children:(()=>{let t=xe(a,e.lastSuccessAt),n=t===a?o:e.lastSuccessSizeBytes;return t===void 0?T(`span`,{className:`italic`,children:`Never`}):T(Se,{at:t,sizeBytes:n})})()}),T(`td`,{className:`px-3 py-2`,children:T(`div`,{className:`flex items-center justify-end gap-1.5`,children:e.triggerSupported&&b(`button`,{onClick:()=>r(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:[T(P,{className:`h-3 w-3`}),`Create here`]})})})]}),t&&T(`tr`,{className:`border-t border-border bg-background/30`,children:T(`td`,{colSpan:7,className:`px-4 py-3`,children:T(oe,{destinationId:e.id,restoreSupported:e.restoreSupported,...i?{onOpenRestoreWizard:i}:{}})})}),f&&T(ye,{destinationName:e.displayName,currentCron:e.cron??``,onSave:g,onClose:()=>p(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function _e({cron:e,nextRunAt:t,onEdit:n,disabled:r}){let i=typeof e==`string`&&e.trim().length>0;return b(`button`,{type:`button`,onClick:n,disabled:r,className:`group flex flex-col items-start gap-0.5 text-left rounded px-1.5 py-1 -mx-1.5 hover:bg-primary/5 disabled:opacity-50`,title:`Edit schedule`,children:[b(`div`,{className:`flex items-center gap-1.5`,children:[T(K,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),T(`span`,{className:i?`font-mono text-foreground`:`italic text-foreground-subtle`,children:i?e:`Manual`})]}),i&&t!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[`next `,ve(t)]})]})}function ve(e){let t=e-Date.now();if(t<=0)return`imminent`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function ye({destinationName:e,currentCron:t,onSave:n,onClose:r,saving:i,saveError:a}){let[o,s]=w(t);return T(`tr`,{children:T(`td`,{colSpan:7,className:`p-0`,children:T(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:b(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[T(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Schedule`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e]})]}),T(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,title:`Close`,children:T(z,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4`,children:[T(ue,{value:o,onChange:s,disabled:i}),a!==null&&T(`div`,{className:`mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:a})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[T(`button`,{onClick:r,disabled:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground disabled:opacity-50`,children:`Cancel`}),T(`button`,{onClick:()=>n(o.trim()),disabled:i||o.trim()===t.trim(),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?`Saving…`:`Save`})]})]})})})})}function be(){let{map:e}=n(D.BackupCompleted,e=>e.destinationId);return x(()=>{let t=new Map;for(let[n,r]of e)t.set(n,{at:Date.now(),sizeBytes:r.sizeMB*1024*1024});return t},[e])}function xe(e,t){return e===void 0?t:t===void 0||e>t?e:t}function Se({at:e,sizeBytes:t}){let n=Ce(e);return b(`span`,{title:x(()=>new Date(e).toLocaleString(),[e]),className:`text-foreground tabular-nums`,children:[n,t!==void 0&&b(`span`,{className:`ml-1 text-foreground-subtle`,children:[`· `,U(t)]})]})}function Ce(e){let[,t]=w(0);return E(()=>{let e=setInterval(()=>t(e=>e+1),3e4);return()=>clearInterval(e)},[]),we(e)}function we(e){let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(a/365)}y ago`}y();var Te=[[`backup`,`list`]];function Ee({initialDestinationId:e,initialArchiveId:t,onClose:n,onScheduled:i}){let a=C(),[o,c]=w(e&&t?2:1),[u,d]=w(e),[f,p]=w(t),[m,g]=w(new Set),{data:_}=l(),v=_??[],{data:y,isLoading:S}=s({destinationId:u??``},{enabled:!!u}),D=y??[];E(()=>{if(u!==void 0)return;let e=v.filter(e=>e.restoreSupported);e.length===1&&d(e[0].id)},[u,v]);let{data:O}=r({destinationId:u??``,backupId:f??``},{enabled:!!u&&!!f}),k=x(()=>O?.locations??[],[O]);E(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=h({onSuccess:()=>{a.invalidateQueries({queryKey:Te}),i(),n()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=!!u&&!!f,N=m.size>0,P=M&&N&&!A.isPending,I=()=>{!u||!f||A.mutate({destinationId:u,backupId:f,locations:[...m]})};return T(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[T(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,o,` of 3 —`,` `,o===1?`pick source`:o===2?`pick locations`:`confirm`]})]}),T(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:T(z,{className:`h-4 w-4`})})]}),o===1&&T(De,{destinations:v,destinationId:u,onPickDestination:e=>{d(e),p(void 0),g(new Set)},archives:D,archivesLoading:S,archiveId:f,onPickArchive:p}),o===2&&T(Oe,{locations:k,picked:m,onToggle:j}),o===3&&T(ke,{destinationName:v.find(e=>e.id===u)?.displayName??u??``,archive:D.find(e=>e.id===f),picked:[...m]}),b(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[T(`div`,{children:o>1&&b(`button`,{onClick:()=>c(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[T(ee,{className:`h-3 w-3`}),`Back`]})}),b(`div`,{className:`flex items-center gap-2`,children:[T(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),o<3?b(`button`,{disabled:o===1&&!M||o===2&&!N,onClick:()=>c(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,T(G,{className:`h-3 w-3`})]}):b(`button`,{onClick:I,disabled:!P,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:[A.isPending?T(L,{className:`h-3.5 w-3.5 animate-spin`}):T(F,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function De({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),b(`select`,{value:t??``,onChange:e=>n(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`,children:[T(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&T(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&T(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&T(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&T(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=a===e.id;return b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[b(`div`,{className:`flex items-center gap-2`,children:[T(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),b(`div`,{children:[T(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),T(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),T(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:U(e.sizeBytes)})]},e.id)})})]})]})}function Oe({locations:e,picked:t,onToggle:n}){return e.length===0?T(`div`,{className:`p-4`,children:T(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):b(`div`,{className:`p-4 space-y-3`,children:[T(`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:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),T(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>b(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[T(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),T(`span`,{className:`font-mono text-foreground`,children:e}),T(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:je(e)})]},e))})]})]})}function ke({destinationName:e,archive:t,picked:n}){return b(`div`,{className:`p-4 space-y-3 text-xs`,children:[T(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),b(`dl`,{className:`space-y-1.5`,children:[T(Z,{term:`Destination`,value:e}),T(Z,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&T(Z,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${U(t.sizeBytes)}`}),T(Z,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Z({term:e,value:t}){return b(`div`,{className:`flex justify-between gap-3`,children:[T(`dt`,{className:`text-foreground-subtle`,children:e}),T(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Ae={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function je(e){return Ae[e]??``}y();var Q=[[`backup`,`list`]],Me=[[`backup`,`listLocations`]];function Ne(){let n=C(),r=i(),o=a({onSuccess:()=>{n.invalidateQueries({queryKey:Q}),n.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),n.invalidateQueries({queryKey:[[`backup`,`listArchives`]]})}}),s=e(),[c,l]=w(null),{data:u}=t(void 0,{enabled:c!==null,retry:1}),[d,f]=w(null),[p,m]=w(!1),[h,g]=w(!1),[_,v]=w(!1),y=async()=>{await r({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&s.mutate({confirm:!0})};return b(H,{children:[b(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[b(`button`,{onClick:()=>m(!0),className:`inline-flex items-center gap-1.5 rounded-lg 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:[T(F,{className:`h-3.5 w-3.5`}),`Restore…`]}),b(`button`,{onClick:()=>v(!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`,children:[T(P,{className:`h-3.5 w-3.5`}),`Add destination`]})]}),h&&T(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:b(`div`,{className:`flex items-center justify-between gap-3`,children:[b(`div`,{className:`flex items-center gap-2`,children:[T(F,{className:`h-3.5 w-3.5`}),T(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),b(`button`,{onClick:()=>{y()},disabled:s.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[s.isPending?T(L,{className:`h-3.5 w-3.5 animate-spin`}):T(F,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),T(he,{onCreateAt:e=>l(e),onOpenRestoreWizard:e=>f(e)}),c&&T(Pe,{destination:c,locations:u,onClose:()=>l(null),onSubmit:(e,t)=>{o.mutate({destinations:[c.id],locations:e,label:t||void 0},{onSuccess:()=>{l(null),n.invalidateQueries({queryKey:Me})}})},submitting:o.isPending}),(d||p)&&T(Ee,{...d?{initialDestinationId:d.destinationId,initialArchiveId:d.archiveId}:{},onClose:()=>{f(null),m(!1)},onScheduled:()=>g(!0)}),_&&T(M,{initialType:`backups`,onClose:()=>v(!1),onCreated:()=>{v(!1),n.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}})]})}function Pe({destination:e,locations:t,onClose:n,onSubmit:r,submitting:i}){let a=(t??[]).filter(e=>e.present),[o,s]=w(``),[c,l]=w(null),u=c??new Set(a.map(e=>e.name)),d=e=>{l(t=>{let n=new Set(t??a.map(e=>e.name));return n.has(e)?n.delete(e):n.add(e),n})};return T(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[T(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Create Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e.displayName]})]}),T(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:T(z,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Label (optional)`}),T(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`pre-upgrade`,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`})]}),b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Include`}),b(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:[t===void 0&&b(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[T(L,{className:`h-3.5 w-3.5 animate-spin`}),`Calculating sizes…`]}),t!==void 0&&a.length===0&&T(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle italic`,children:`Nothing to back up.`}),a.map(e=>b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[b(`div`,{className:`flex items-center gap-2`,children:[T(`input`,{type:`checkbox`,checked:u.has(e.name),onChange:()=>d(e.name),className:`accent-primary`}),T(`span`,{className:`font-mono text-foreground`,children:e.name})]}),b(`div`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[U(e.sizeBytes),` · `,e.fileCount,` files`]})]},e.name))]})]})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[T(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),b(`button`,{onClick:()=>r(Array.from(u),o.trim()),disabled:i||t===void 0||u.size===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:[i?T(L,{className:`h-3.5 w-3.5 animate-spin`}):T(W,{className:`h-3.5 w-3.5`}),i?`Creating…`:`Create`]})]})]})})}y();var $=5e3,Fe={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function Ie(){let e=_({capName:`log-destination`},{refetchInterval:$}),t=d(void 0,{refetchInterval:$}),n=x(()=>ie(t.data??[]),[t.data]),r=x(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return T(N,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:B,itemIcon:q,capability:`log-destination`,installButtonLabel:`Add destination`,items:x(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive,caption:r.get(e.addonId)??Fe[e.addonId]??``})),[e.data,n,r]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?T(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}function Le(){return T(`div`,{className:`flex flex-col p-4`,children:T(re,{tabs:[{id:`storage`,label:`Storage`,icon:k,content:T(J,{})},{id:`backup`,label:`Backup`,icon:W,content:T(Ne,{})},{id:`logging`,label:`Logging`,icon:B,content:T(Ie,{})}]})})}export{Le as DataPage};
1
+ import{Et as e,Gt as t,Ht as n,Jt as r,Kt as i,Ut as a,Va as o,Vt as s,Wt as c,Yt as l,bt as u,ca as d,fa as f,la as p,qa as m,qt as h,ua as g,xt as _}from"./src-DHFCkQHW.js";import{I as v,Q as y,S as b,W as x,b as S,o as C,q as w,x as T,z as E}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as D}from"./src-Cv9CvT8c.js";import{t as O}from"./download-BpNiVwyM.js";import{i as k,n as A,r as j,t as M}from"./AddLocationWizard-BzfZuUFE.js";import{t as N}from"./AddonCollectionPage-D4dNkjD9.js";import{t as P}from"./plus-z-WZstU2.js";import{t as F}from"./rotate-cw-CQj7EyBl.js";import{H as ee,I,P as te,S as L,W as R,i as z,m as B,s as V}from"./index-Cl-M8KBA.js";import{t as H}from"./AdminPage-Dq33XE9j.js";import{n as ne}from"./authed-media-XfBD4Ma-.js";import{t as U}from"./format-size-CO9d3C3-.js";import{t as re}from"./AdminTabs-B6qnIaak.js";import{t as ie}from"./addon-display-names-DvSEQty-.js";var W=R(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),G=R(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),K=R(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),q=R(`file-text`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);y();function J(){let e=C(),t=o(),{data:n,isLoading:r,isError:i}=g({}),a=p(),s=x(()=>a.data??[],[a.data]),[c,l]=w(null),[u,m]=w(null),h=d({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),_=f({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),v=e=>{e.isDefault||_.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},y=async e=>{if(e.isDefault){await t({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await t({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&h.mutate({id:e.id})},S=x(()=>{let e=new Map;for(let t of n??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[n]),E=r||a.isLoading,D=i||a.isError;return b(H,{children:[E&&T(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),D&&T(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!E&&!D&&b(`div`,{className:`space-y-3`,children:[s.length===0&&T(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),s.map(e=>T(j,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:S.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>m(e),onDelete:e=>{y(e)},onSetDefault:e=>v(e)},e.id))]}),c!==null&&T(M,{initialType:c,onClose:()=>l(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),l(null)}}),u!==null&&T(A,{location:u,onClose:()=>m(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),m(null)}})]})}y();var Y=[[`backup`,`listDestinations`]],ae=[`backup`,`listArchives`];function oe({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){let r=C(),i=o(),{data:c,isLoading:l,isError:u}=a({destinationId:e}),d=c??[],f=s({onSuccess:()=>{r.invalidateQueries({queryKey:[[...ae]]}),r.invalidateQueries({queryKey:Y})}}),p=v(async t=>{await i({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${U(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({destinationId:e,backupId:t.id})},[i,e,f]),[m,h]=w(null),g=v(async t=>{h(t.id);try{let n=await ne(se(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{h(null)}},[e]),_=x(()=>[...d].toSorted((e,t)=>t.createdAt-e.createdAt),[d]);return l?T(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):u?T(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):_.length===0?T(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):T(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[640px]`,children:[T(`thead`,{children:b(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[T(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),T(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),T(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),T(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),T(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),T(`tbody`,{children:_.map(r=>b(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[T(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:ce(r.createdAt)}),T(`td`,{className:`px-3 py-1.5 text-foreground`,children:r.label??T(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),T(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:r.locations.join(`, `)}),T(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:U(r.sizeBytes)}),T(`td`,{className:`px-3 py-1.5`,children:b(`div`,{className:`flex items-center justify-end gap-1`,children:[b(`button`,{onClick:()=>{g(r)},disabled:m===r.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[m===r.id?T(L,{className:`h-3 w-3 animate-spin`}):T(O,{className:`h-3 w-3`}),`Download`]}),t&&n&&b(`button`,{onClick:()=>n({destinationId:e,archiveId:r.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[T(F,{className:`h-3 w-3`}),`Restore`]}),T(`button`,{onClick:()=>{p(r)},disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:f.isPending?T(L,{className:`h-3 w-3 animate-spin`}):T(V,{className:`h-3 w-3`})})]})})]},r.id))})]})})}function se(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function ce(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}y();var X=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function le(e){let t=e.trim();for(let e of X)if(e.cron===t)return e.id;return`custom`}function ue({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let a=le(e),[o,s]=w(a===`custom`);E(()=>{a!==`custom`&&s(!1)},[a]);let c=pe(e,250),l=i({cron:c,count:n},{enabled:c.trim().length>0}),u=l.data??null,d=e=>{s(!1),t(e.cron)},f=o||a===`custom`;return b(`div`,{className:`space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[T(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),b(`div`,{className:`flex flex-wrap gap-1.5`,children:[X.map(e=>T(`button`,{type:`button`,onClick:()=>d(e),disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!o&&a===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),T(`button`,{type:`button`,onClick:()=>{s(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(f?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),f&&b(`div`,{className:`space-y-1`,children:[T(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),T(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:r,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),b(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,T(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),T(de,{cron:c,preview:u,loading:l.isFetching})]})}function de({cron:e,preview:t,loading:n}){return n&&t===null?b(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[T(L,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?T(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):b(`div`,{className:`space-y-1`,children:[T(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),T(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>b(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[T(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),T(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:fe(e)})]},`${e}-${t}`))})]}):T(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function fe(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function pe(e,t){let[n,r]=w(e),i=x(()=>e,[e]);return E(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}y();var me=[[`backup`,`listDestinations`]];function he({onCreateAt:e,onOpenRestoreWizard:t}){let{data:n,isLoading:r,isError:i}=c(),a=n??[],[o,s]=w(null),l=e=>{s(t=>t===e?null:e)},u=be();return r?T(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading destinations…`}):i?T(`div`,{className:`text-xs text-danger`,children:`Failed to load destinations`}):a.length===0?T(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:T(`p`,{className:`text-xs text-foreground-subtle`,children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):T(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:b(`table`,{className:`w-full text-xs min-w-[720px]`,children:[T(`thead`,{children:b(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[T(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),T(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Destination`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-28`,children:`Retention`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-56`,children:`Schedule`}),T(`th`,{className:`text-left px-3 py-2 font-medium w-44`,children:`Last success`}),T(`th`,{className:`text-right px-3 py-2 font-medium w-44`,children:`Actions`})]})}),T(`tbody`,{children:a.map(n=>{let r=u.get(n.id);return T(ge,{row:n,isOpen:o===n.id,onToggle:()=>l(n.id),onCreateAt:e,liveLastSuccessAt:r?.at,liveLastSuccessSizeBytes:r?.sizeBytes,...t?{onOpenRestoreWizard:t}:{}},n.id)})})]})})}function ge({row:e,isOpen:t,onToggle:n,onCreateAt:r,onOpenRestoreWizard:i,liveLastSuccessAt:a,liveLastSuccessSizeBytes:o}){let s=C(),c=l({onSuccess:()=>{s.invalidateQueries({queryKey:me})}}),[u,d]=w(String(e.retentionCount));E(()=>{d(String(e.retentionCount))},[e.retentionCount]);let[f,p]=w(!1),m=v(t=>{c.mutate({locationId:e.id,enabled:t,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[c,e.id,e.retentionCount,e.label,e.cron]),h=v(()=>{let t=Number.parseInt(u,10);if(Number.isNaN(t)||t<1){d(String(e.retentionCount));return}t!==e.retentionCount&&c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:t,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[c,u,e.id,e.enabled,e.retentionCount,e.label,e.cron]),g=v(t=>{c.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},cron:t},{onSuccess:()=>{p(!1)}})},[c,e.id,e.enabled,e.retentionCount,e.label]);return b(S,{children:[b(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[T(`td`,{className:`px-2 py-2`,children:T(`button`,{onClick:n,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:t?`Hide archives`:`Show archives`,children:T(t?I:te,{className:`h-3.5 w-3.5`})})}),T(`td`,{className:`px-3 py-2`,children:b(`button`,{onClick:n,className:`text-left hover:underline focus:outline-none`,title:`View archives`,children:[T(`div`,{className:`text-foreground font-medium`,children:e.displayName}),b(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[T(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5`,children:e.kind}),T(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]})}),T(`td`,{className:`px-3 py-2`,children:T(`label`,{className:`inline-flex items-center cursor-pointer`,children:T(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:c.isPending,onChange:e=>m(e.target.checked)})})}),T(`td`,{className:`px-3 py-2`,children:T(`input`,{type:`number`,min:1,max:1e3,value:u,disabled:c.isPending,onChange:e=>d(e.target.value),onBlur:h,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&d(String(e.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),T(`td`,{className:`px-3 py-2`,children:T(_e,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>p(!0),disabled:c.isPending})}),T(`td`,{className:`px-3 py-2 text-foreground-subtle`,children:(()=>{let t=xe(a,e.lastSuccessAt),n=t===a?o:e.lastSuccessSizeBytes;return t===void 0?T(`span`,{className:`italic`,children:`Never`}):T(Se,{at:t,sizeBytes:n})})()}),T(`td`,{className:`px-3 py-2`,children:T(`div`,{className:`flex items-center justify-end gap-1.5`,children:e.triggerSupported&&b(`button`,{onClick:()=>r(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:[T(P,{className:`h-3 w-3`}),`Create here`]})})})]}),t&&T(`tr`,{className:`border-t border-border bg-background/30`,children:T(`td`,{colSpan:7,className:`px-4 py-3`,children:T(oe,{destinationId:e.id,restoreSupported:e.restoreSupported,...i?{onOpenRestoreWizard:i}:{}})})}),f&&T(ye,{destinationName:e.displayName,currentCron:e.cron??``,onSave:g,onClose:()=>p(!1),saving:c.isPending,saveError:c.error instanceof Error?c.error.message:null})]})}function _e({cron:e,nextRunAt:t,onEdit:n,disabled:r}){let i=typeof e==`string`&&e.trim().length>0;return b(`button`,{type:`button`,onClick:n,disabled:r,className:`group flex flex-col items-start gap-0.5 text-left rounded px-1.5 py-1 -mx-1.5 hover:bg-primary/5 disabled:opacity-50`,title:`Edit schedule`,children:[b(`div`,{className:`flex items-center gap-1.5`,children:[T(K,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),T(`span`,{className:i?`font-mono text-foreground`:`italic text-foreground-subtle`,children:i?e:`Manual`})]}),i&&t!==void 0&&b(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[`next `,ve(t)]})]})}function ve(e){let t=e-Date.now();if(t<=0)return`imminent`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function ye({destinationName:e,currentCron:t,onSave:n,onClose:r,saving:i,saveError:a}){let[o,s]=w(t);return T(`tr`,{children:T(`td`,{colSpan:7,className:`p-0`,children:T(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:b(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[T(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Schedule`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e]})]}),T(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,title:`Close`,children:T(z,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4`,children:[T(ue,{value:o,onChange:s,disabled:i}),a!==null&&T(`div`,{className:`mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:a})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[T(`button`,{onClick:r,disabled:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground disabled:opacity-50`,children:`Cancel`}),T(`button`,{onClick:()=>n(o.trim()),disabled:i||o.trim()===t.trim(),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?`Saving…`:`Save`})]})]})})})})}function be(){let{map:e}=m(D.BackupCompleted,e=>e.destinationId);return x(()=>{let t=new Map;for(let[n,r]of e)t.set(n,{at:Date.now(),sizeBytes:r.sizeMB*1024*1024});return t},[e])}function xe(e,t){return e===void 0?t:t===void 0||e>t?e:t}function Se({at:e,sizeBytes:t}){let n=Ce(e);return b(`span`,{title:x(()=>new Date(e).toLocaleString(),[e]),className:`text-foreground tabular-nums`,children:[n,t!==void 0&&b(`span`,{className:`ml-1 text-foreground-subtle`,children:[`· `,U(t)]})]})}function Ce(e){let[,t]=w(0);return E(()=>{let e=setInterval(()=>t(e=>e+1),3e4);return()=>clearInterval(e)},[]),we(e)}function we(e){let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(a/365)}y ago`}y();var Te=[[`backup`,`list`]];function Ee({initialDestinationId:e,initialArchiveId:t,onClose:r,onScheduled:i}){let o=C(),[s,l]=w(e&&t?2:1),[u,d]=w(e),[f,p]=w(t),[m,g]=w(new Set),{data:_}=c(),v=_??[],{data:y,isLoading:S}=a({destinationId:u??``},{enabled:!!u}),D=y??[];E(()=>{if(u!==void 0)return;let e=v.filter(e=>e.restoreSupported);e.length===1&&d(e[0].id)},[u,v]);let{data:O}=n({destinationId:u??``,backupId:f??``},{enabled:!!u&&!!f}),k=x(()=>O?.locations??[],[O]);E(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=h({onSuccess:()=>{o.invalidateQueries({queryKey:Te}),i(),r()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=!!u&&!!f,N=m.size>0,P=M&&N&&!A.isPending,I=()=>{!u||!f||A.mutate({destinationId:u,backupId:f,locations:[...m]})};return T(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[T(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,s,` of 3 —`,` `,s===1?`pick source`:s===2?`pick locations`:`confirm`]})]}),T(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:T(z,{className:`h-4 w-4`})})]}),s===1&&T(De,{destinations:v,destinationId:u,onPickDestination:e=>{d(e),p(void 0),g(new Set)},archives:D,archivesLoading:S,archiveId:f,onPickArchive:p}),s===2&&T(Oe,{locations:k,picked:m,onToggle:j}),s===3&&T(ke,{destinationName:v.find(e=>e.id===u)?.displayName??u??``,archive:D.find(e=>e.id===f),picked:[...m]}),b(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[T(`div`,{children:s>1&&b(`button`,{onClick:()=>l(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[T(ee,{className:`h-3 w-3`}),`Back`]})}),b(`div`,{className:`flex items-center gap-2`,children:[T(`button`,{onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),s<3?b(`button`,{disabled:s===1&&!M||s===2&&!N,onClick:()=>l(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,T(G,{className:`h-3 w-3`})]}):b(`button`,{onClick:I,disabled:!P,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:[A.isPending?T(L,{className:`h-3.5 w-3.5 animate-spin`}):T(F,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function De({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),b(`select`,{value:t??``,onChange:e=>n(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`,children:[T(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>b(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&T(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&T(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&T(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&T(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=a===e.id;return b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[b(`div`,{className:`flex items-center gap-2`,children:[T(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),b(`div`,{children:[T(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),T(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),T(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:U(e.sizeBytes)})]},e.id)})})]})]})}function Oe({locations:e,picked:t,onToggle:n}){return e.length===0?T(`div`,{className:`p-4`,children:T(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):b(`div`,{className:`p-4 space-y-3`,children:[T(`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:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),T(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>b(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[T(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),T(`span`,{className:`font-mono text-foreground`,children:e}),T(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:je(e)})]},e))})]})]})}function ke({destinationName:e,archive:t,picked:n}){return b(`div`,{className:`p-4 space-y-3 text-xs`,children:[T(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),b(`dl`,{className:`space-y-1.5`,children:[T(Z,{term:`Destination`,value:e}),T(Z,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&T(Z,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${U(t.sizeBytes)}`}),T(Z,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Z({term:e,value:t}){return b(`div`,{className:`flex justify-between gap-3`,children:[T(`dt`,{className:`text-foreground-subtle`,children:e}),T(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Ae={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function je(e){return Ae[e]??``}y();var Q=[[`backup`,`list`]],Me=[[`backup`,`listLocations`]];function Ne(){let n=C(),i=o(),a=r({onSuccess:()=>{n.invalidateQueries({queryKey:Q}),n.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),n.invalidateQueries({queryKey:[[`backup`,`listArchives`]]})}}),s=e(),[c,l]=w(null),{data:u}=t(void 0,{enabled:c!==null,retry:1}),[d,f]=w(null),[p,m]=w(!1),[h,g]=w(!1),[_,v]=w(!1),y=async()=>{await i({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&s.mutate({confirm:!0})};return b(H,{children:[b(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[b(`button`,{onClick:()=>m(!0),className:`inline-flex items-center gap-1.5 rounded-lg 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:[T(F,{className:`h-3.5 w-3.5`}),`Restore…`]}),b(`button`,{onClick:()=>v(!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`,children:[T(P,{className:`h-3.5 w-3.5`}),`Add destination`]})]}),h&&T(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:b(`div`,{className:`flex items-center justify-between gap-3`,children:[b(`div`,{className:`flex items-center gap-2`,children:[T(F,{className:`h-3.5 w-3.5`}),T(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),b(`button`,{onClick:()=>{y()},disabled:s.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[s.isPending?T(L,{className:`h-3.5 w-3.5 animate-spin`}):T(F,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),T(he,{onCreateAt:e=>l(e),onOpenRestoreWizard:e=>f(e)}),c&&T(Pe,{destination:c,locations:u,onClose:()=>l(null),onSubmit:(e,t)=>{a.mutate({destinations:[c.id],locations:e,label:t||void 0},{onSuccess:()=>{l(null),n.invalidateQueries({queryKey:Me})}})},submitting:a.isPending}),(d||p)&&T(Ee,{...d?{initialDestinationId:d.destinationId,initialArchiveId:d.archiveId}:{},onClose:()=>{f(null),m(!1)},onScheduled:()=>g(!0)}),_&&T(M,{initialType:`backups`,onClose:()=>v(!1),onCreated:()=>{v(!1),n.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}})]})}function Pe({destination:e,locations:t,onClose:n,onSubmit:r,submitting:i}){let a=(t??[]).filter(e=>e.present),[o,s]=w(``),[c,l]=w(null),u=c??new Set(a.map(e=>e.name)),d=e=>{l(t=>{let n=new Set(t??a.map(e=>e.name));return n.has(e)?n.delete(e):n.add(e),n})};return T(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:b(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[b(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[b(`div`,{className:`space-y-0.5`,children:[T(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Create Backup`}),b(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e.displayName]})]}),T(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:T(z,{className:`h-4 w-4`})})]}),b(`div`,{className:`p-4 space-y-3`,children:[b(`div`,{className:`space-y-1`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Label (optional)`}),T(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`pre-upgrade`,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`})]}),b(`div`,{className:`space-y-1.5`,children:[T(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Include`}),b(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:[t===void 0&&b(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[T(L,{className:`h-3.5 w-3.5 animate-spin`}),`Calculating sizes…`]}),t!==void 0&&a.length===0&&T(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle italic`,children:`Nothing to back up.`}),a.map(e=>b(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[b(`div`,{className:`flex items-center gap-2`,children:[T(`input`,{type:`checkbox`,checked:u.has(e.name),onChange:()=>d(e.name),className:`accent-primary`}),T(`span`,{className:`font-mono text-foreground`,children:e.name})]}),b(`div`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[U(e.sizeBytes),` · `,e.fileCount,` files`]})]},e.name))]})]})]}),b(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[T(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),b(`button`,{onClick:()=>r(Array.from(u),o.trim()),disabled:i||t===void 0||u.size===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:[i?T(L,{className:`h-3.5 w-3.5 animate-spin`}):T(W,{className:`h-3.5 w-3.5`}),i?`Creating…`:`Create`]})]})]})})}y();var $=5e3,Fe={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function Ie(){let e=_({capName:`log-destination`},{refetchInterval:$}),t=u(void 0,{refetchInterval:$}),n=x(()=>ie(t.data??[]),[t.data]),r=x(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return T(N,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:B,itemIcon:q,capability:`log-destination`,installButtonLabel:`Add destination`,items:x(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive,caption:r.get(e.addonId)??Fe[e.addonId]??``})),[e.data,n,r]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?T(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}function Le(){return T(`div`,{className:`flex flex-col p-4`,children:T(re,{tabs:[{id:`storage`,label:`Storage`,icon:k,content:T(J,{})},{id:`backup`,label:`Backup`,icon:W,content:T(Ne,{})},{id:`logging`,label:`Logging`,icon:B,content:T(Ie,{})}]})})}export{Le as DataPage};
@@ -1 +1 @@
1
- import{$n as e,Ia as t,Jn as n,Qn as r,Ua as i,Xn as a,Yn as o,Zn as s,ar as c,bo as l,do as u,er as d,fo as f,ho as p,ir as m,jn as h,mo as g,nr as _,po as v,qn as y,rr as b,tr as x,uo as S,vo as C,xo as w}from"./src-DmOEfaLx.js";import{K as T,Q as E,S as D,W as O,b as k,o as A,q as j,x as M,z as N}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as P}from"./src-4xaQB5RZ.js";import{a as F,i as I,n as L,r as ee,t as R}from"./face-bbox-D-tm4cNu.js";import{a as z,c as te,f as B,i as V,l as ne,m as H,n as re,o as ie,p as U,r as ae,s as oe,t as se,u as ce}from"./debounced-invalidate-OsMHAbLS.js";import{t as W}from"./pencil-CQfM-gfd.js";import{t as G}from"./plus-CqnkUqMJ.js";import{t as le}from"./refresh-cw-D6O4UC61.js";import{t as ue}from"./square-check-big-vugmEemF.js";import{t as de}from"./square-DGtpAb1Z.js";import{I as K,L as q,P as fe,S as J,W as pe,h as me,i as Y,l as he,s as X}from"./index-dCklXrvt.js";import{t as Z}from"./AdminPage-Dq33XE9j.js";import{n as Q,t as ge}from"./authed-media-XfBD4Ma-.js";var _e=pe(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),ve=pe(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);E();var $=[[`faceGallery`]];function ye({identityId:t}){let n=A(),{data:r,isLoading:i}=e({identityId:t}),a=x();function o(e){a.mutate({identityId:t,sampleId:e.id},{onSettled:()=>{n.invalidateQueries({queryKey:$})}})}return i?D(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!r||r.length===0?M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):M(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:r.map(e=>D(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?M(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:M(ve,{className:`h-6 w-6`})}),M(`button`,{type:`button`,onClick:()=>o(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:M(Y,{className:`h-4 w-4 text-white`})})]},e.id))})}function be({identity:e,expanded:t,onToggle:n}){let r=A(),[i,o]=j(``),[s,c]=j(!1),[d,m]=j(!1),h=_(),y=a();function b(){o(e.name),c(!0)}function x(){c(!1),o(``)}function T(){let t=i.trim();if(!t||t===e.name){x();return}h.mutate({id:e.id,name:t},{onSettled:()=>{r.invalidateQueries({queryKey:$}),x()}})}function E(){y.mutate({id:e.id},{onSettled:()=>{r.invalidateQueries({queryKey:$}),m(!1)}})}return D(`div`,{className:`rounded-md border border-border bg-surface`,children:[D(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[M(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?M(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center`,children:M(ve,{className:`h-4 w-4 text-foreground-subtle`})})}),M(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:s?D(k,{children:[M(C,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&x()},className:`h-6 text-xs`,autoFocus:!0}),M(`button`,{type:`button`,onClick:T,disabled:h.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:M(q,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:x,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:M(Y,{className:`h-3.5 w-3.5`})})]}):M(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),M(l,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!s&&D(`div`,{className:`flex items-center gap-1`,children:[M(`button`,{type:`button`,onClick:b,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:M(W,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:()=>m(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:M(X,{className:`h-3.5 w-3.5`})})]}),M(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:M(t?K:fe,{className:`h-3.5 w-3.5`})})]}),t&&M(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:M(ye,{identityId:e.id})}),M(S,{open:d,onOpenChange:e=>!e&&m(!1),children:D(u,{children:[D(g,{children:[M(p,{children:`Delete person`}),D(f,{children:[`Delete `,M(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),D(v,{children:[M(w,{variant:`secondary`,onClick:()=>m(!1),children:`Cancel`}),D(w,{variant:`danger`,onClick:E,disabled:y.isPending,children:[y.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function xe(){let e=A(),[t,r]=j(``),i=n();function a(){let n=t.trim();n&&i.mutate({name:n},{onSettled:()=>{e.invalidateQueries({queryKey:$}),r(``)}})}return D(`div`,{className:`flex items-center gap-2 pt-2`,children:[M(C,{placeholder:`New person name…`,value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a()},className:`h-7 text-xs flex-1`}),D(w,{variant:`primary`,size:`sm`,onClick:a,disabled:i.isPending||!t.trim(),children:[i.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(G,{className:`h-3.5 w-3.5`}),`Add`]})]})}function Se(){let{data:e,isLoading:t}=r(),[n,i]=j(null);function a(e){i(t=>t===e?null:e)}return t?D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):D(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>M(be,{identity:e,expanded:n===e.id,onToggle:()=>a(e.id)},e.id)),M(xe,{})]})}function Ce(e){return e.base64===void 0||e.base64.length===0}function we(e){return e.filter(Ce).map(e=>e.faceId)}function Te(e){let t=0;for(let n of e)Ce(n)&&(t+=1);return t}E();function Ee(e){let[t,n]=j(null),[r,i]=j(null),[a,o]=j(!1);return N(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await Q(`${ge}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),N(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function De(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function Oe({label:e,value:t}){return D(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[M(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),M(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function ke({box:e}){return M(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:M(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function Ae({face:e,cameraName:t,onClose:n,onAssign:r,onUnassign:i,onDelete:a,actionsPending:o}){let{data:c,isFetching:l}=s({faceId:e?.faceId??``},{enabled:e!==null}),[d,f]=j(`frame`),{frameSrc:p,naturalWidth:m,naturalHeight:h,failed:g}=Ee(e?.keyFrameMediaKey),_=O(()=>{let t=De(c??[]);return t?`data:image/jpeg;base64,${t.base64}`:e?.base64?`data:image/jpeg;base64,${e.base64}`:null},[c,e]),v=O(()=>!e?.faceBbox||m===null||h===null?null:R(e.faceBbox,m,h),[e?.faceBbox,m,h]);if(e===null)return null;let y=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!g,b=y&&d===`frame`,x=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return M(S,{open:!0,onOpenChange:e=>!e&&n(),children:D(u,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[D(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`min-w-0`,children:[M(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),M(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),M(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(Y,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[y&&D(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[D(`button`,{type:`button`,onClick:()=>f(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${d===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(I,{className:`h-3.5 w-3.5`}),` Full frame`]}),D(`button`,{type:`button`,onClick:()=>f(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${d===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(F,{className:`h-3.5 w-3.5`}),` Crop`]})]}),b&&p?M(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:M(V,{src:p,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:v?M(ke,{box:v}):void 0})}):_?D(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[M(V,{src:_,alt:`Detected face`,className:`h-full w-full`}),l&&M(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:M(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):D(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[M(H,{className:`h-8 w-8 text-warning/70`}),M(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),M(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),D(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[M(Oe,{label:`Camera`,value:t}),M(Oe,{label:`Captured`,value:U(e.timestamp)}),M(Oe,{label:`Track`,value:e.trackId}),M(Oe,{label:`Identity`,value:x})]})]}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?D(w,{variant:`secondary`,onClick:()=>i(e.faceId),disabled:o,children:[M(L,{className:`h-3.5 w-3.5`}),` Detach`]}):D(w,{variant:`primary`,onClick:()=>r(e.faceId),disabled:o,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(w,{variant:`secondary`,onClick:()=>a(e.faceId),disabled:o,children:[M(X,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}E();var je=[[`faceGallery`]];function Me({faceIds:e,identities:t,onDone:r}){let i=A(),a=y(),o=n(),[s,c]=j(``),[l,d]=j(!1),[m,h]=j(null),_=e!==null&&e.length>0,b=e?.length??0;function x(){d(!1),c(``),h(null)}function T(){x(),r()}function E(t){!e||e.length===0||a.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{i.invalidateQueries({queryKey:je}),T()}})}function O(){!e||!s.trim()||o.mutate({name:s.trim()},{onSuccess:e=>{e?.id&&E(e.id)},onError:()=>{i.invalidateQueries({queryKey:je}),T()}})}let k=a.isPending||o.isPending;return M(S,{open:_,onOpenChange:e=>!e&&T(),children:D(u,{children:[D(g,{children:[M(p,{children:b>1?`Assign ${String(b)} faces to person`:`Assign face to person`}),M(f,{children:`Select an existing person or create a new one.`})]}),M(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>D(`button`,{type:`button`,onClick:()=>h(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${m===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[M(`span`,{className:`font-medium`,children:e.name}),D(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),l?M(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:M(C,{placeholder:`New person name…`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):M(`button`,{type:`button`,onClick:()=>{h(null),d(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),D(v,{children:[M(w,{variant:`secondary`,onClick:T,disabled:k,children:`Cancel`}),l?D(w,{variant:`primary`,onClick:O,disabled:k||!s.trim(),children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):D(w,{variant:`primary`,onClick:()=>m&&E(m),disabled:k||!m,children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,b>1?` ${String(b)}`:``]})]})]})})}function Ne(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Pe(e,t){return e.faceIds.filter(e=>!t.has(e))}function Fe(e,t){return e.faceIds.filter(e=>t(e))}E();var Ie=[[`faceGallery`]],Le=20,Re=.3,ze=.9,Be=.05,Ve=.5,He=2,Ue=10,We=2;function Ge({cluster:e,face:t,active:n,onSelect:r}){return D(`button`,{type:`button`,onClick:r,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[M(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:t?.base64?M(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:``,className:`h-24 w-24 object-cover`}):M(H,{className:`h-24 w-24 p-6 text-foreground-subtle`})}),D(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function Ke({face:e,cameraName:t,nowMs:n,excluded:r,onToggleExclude:i,onDelete:a,deletePending:o}){return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${r?`border-border opacity-40 grayscale`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?M(V,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face from ${t}`,className:`h-full w-full`}):D(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[M(H,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Include face`:`Exclude face`,title:r?`Include`:`Exclude`,children:M(r?_e:Y,{className:`h-3.5 w-3.5`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:B(e.timestamp,n)})]}),M(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},disabled:o,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:o?M(J,{className:`h-4 w-4 animate-spin`}):M(X,{className:`h-4 w-4`})})})]})}function qe({open:e,onClose:n,byId:r,cameraName:i,nowMs:a,identities:s,selectMany:c}){let l=A(),d=t(),f=o(),[p,m]=j(Ve),[h,g]=j(We),[_,v]=j(null),[y,x]=j({}),[C,T]=j(null),{data:E,isFetching:P,refetch:F}=b({threshold:p,minClusterSize:h,limit:Le},{enabled:e}),I=E??[];N(()=>{x({})},[p,h]),N(()=>{if(I.length===0){v(null);return}I.some(e=>e.representativeFaceId===_)||v(I[0]?.representativeFaceId??null)},[I]);let L=O(()=>I.find(e=>e.representativeFaceId===_)??null,[I,_]),R=L?y[L.representativeFaceId]??new Set:new Set,z=O(()=>L?Fe(L,e=>r.has(e)):[],[L,r]),te=L?L.faceIds.length-z.length:0,B=L?Pe({...L,faceIds:z},R):[];function V(e){if(!L)return;let t=L.representativeFaceId;x(n=>({...n,[t]:Ne(n[t]??new Set,e)}))}function ne(){l.invalidateQueries({queryKey:Ie})}async function H(e){await d({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({faceId:e},{onSettled:ne})}function re(){T(null),n()}function ie(){B.length!==0&&(c(B),re())}return D(S,{open:e,onOpenChange:e=>!e&&re(),children:[D(u,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[D(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[M(he,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),M(`button`,{type:`button`,onClick:re,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(Y,{className:`h-4 w-4`})})]}),D(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,M(`input`,{type:`range`,min:Re,max:ze,step:Be,value:p,onChange:e=>m(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),M(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:p.toFixed(2)})]}),D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,M(`input`,{type:`number`,min:He,max:Ue,step:1,value:h,onChange:e=>g(Math.min(Ue,Math.max(He,Number(e.target.value)||He))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),D(w,{variant:`secondary`,onClick:()=>{x({}),F()},disabled:P,children:[P?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(le,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),M(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:P&&I.length===0?D(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):I.length===0?M(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):D(k,{children:[M(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:I.map(e=>M(Ge,{cluster:e,face:r.get(e.representativeFaceId),active:e.representativeFaceId===_,onSelect:()=>v(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:I.map(e=>M(Ge,{cluster:e,face:r.get(e.representativeFaceId),active:e.representativeFaceId===_,onSelect:()=>v(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:L&&D(k,{children:[te>0&&D(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[te,` not loaded — excluded from actions`]}),M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:z.map(e=>{let t=r.get(e);return t?M(Ke,{face:t,cameraName:i(t.deviceId),nowMs:a,excluded:R.has(e),onToggleExclude:()=>V(e),onDelete:()=>void H(e),deletePending:f.isPending&&f.variables?.faceId===e},e):null})})]})})]})}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[M(w,{variant:`secondary`,onClick:ie,disabled:B.length===0,children:`Select in gallery`}),D(w,{variant:`primary`,onClick:()=>T(B),disabled:B.length===0,children:[M(ee,{className:`h-3.5 w-3.5`}),` Adopt (`,B.length,`)`]})]})]}),M(Me,{faceIds:C,identities:s,onDone:()=>T(null)})]})}E();var Je=[[`faceGallery`]],Ye=500,Xe=120;function Ze({face:e,cameraName:t,nowMs:n,selected:r,onToggleSelect:i,onAssign:a,onOpenDetail:s}){let c=A(),l=m(),u=o(),d=()=>{c.invalidateQueries({queryKey:Je})},f=()=>s(e.faceId);return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${r?`border-primary ring-1 ring-primary`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?M(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face from ${t}`,onClick:f,className:`h-full w-full cursor-zoom-in object-cover`}):D(`button`,{type:`button`,onClick:f,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[M(H,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Deselect`:`Select`,children:r?M(ue,{className:`h-4 w-4 text-primary`}):M(de,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:B(e.timestamp,n)}),e.identityName&&M(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),D(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l.mutate({faceId:e.faceId},{onSettled:d})},disabled:l.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:l.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(L,{className:`h-4 w-4`})}):M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:M(ee,{className:`h-4 w-4`})}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),u.mutate({faceId:e.faceId},{onSettled:d})},disabled:u.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:u.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(X,{className:`h-4 w-4`})})]})]})}var Qe=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function $e(){let e=A(),[t,n]=j(`all`),[i,a]=j(oe),[s,l]=j(new Set),[u,f]=j(new Set),[p,g]=j(null),[_,v]=j(!1),[b,x]=j(null),{data:S,isLoading:C}=d({limit:Ye,filter:t},{refetchInterval:3e4}),{data:T=[]}=r(),{data:E}=h({}),N=y(),P=m(),F=c(),I=o(),R=Date.now(),B=S??[],V=O(()=>{let e=new Map;for(let t of E??[])e.set(t.id,t.name);return e},[E]),U=e=>V.get(e)??`Camera #${String(e)}`,se=O(()=>te(B).map(e=>({id:e,name:U(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[B,V]),W=O(()=>ne(ce(B,i),s),[B,i,s]),G=re(W,Xe,O(()=>JSON.stringify([t,i.fromMs,i.toMs,[...s].sort((e,t)=>e-t)]),[t,i.fromMs,i.toMs,s])),le=O(()=>new Map(B.map(e=>[e.faceId,e])),[B]),ue=O(()=>Te(W),[W]),de=b===null?null:le.get(b)??null,K=()=>{e.invalidateQueries({queryKey:Je})},q=()=>f(new Set);function fe(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){f(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(we(W))}let Z=[...u],Q=N.isPending||F.isPending||I.isPending,ge=P.isPending||I.isPending;function _e(){Z.length!==0&&F.mutate({faceIds:Z},{onSettled:()=>{K(),q()}})}function ve(){Z.length!==0&&Promise.allSettled(Z.map(e=>I.mutateAsync({faceId:e}))).then(()=>{K(),q()})}function $(e){x(null),g([e])}function ye(e){P.mutate({faceId:e},{onSettled:K}),x(null)}function be(e){I.mutate({faceId:e},{onSettled:K}),x(null)}let xe=W.length!==B.length;return D(`div`,{className:`relative space-y-3`,children:[D(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[M(`div`,{className:`flex items-center gap-1`,children:Qe.map(e=>M(`button`,{type:`button`,onClick:()=>n(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),M(z,{onChange:a}),M(ie,{cameras:se,selected:s,onChange:l}),D(`button`,{type:`button`,onClick:()=>v(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${_?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(he,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!C&&ue>0&&D(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[M(H,{className:`h-3.5 w-3.5`}),` Select `,ue,` crop-less`]}),!C&&M(`span`,{className:`text-[10px] text-foreground-subtle ${ue>0?`ml-2`:`ml-auto`}`,children:xe?`${String(W.length)} of ${String(B.length)} faces`:`${String(W.length)} face${W.length===1?``:`s`}`})]}),u.size>0&&D(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[D(`span`,{className:`text-xs font-medium text-foreground`,children:[u.size,` selected`]}),D(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[D(w,{variant:`primary`,onClick:()=>g(Z),disabled:Q,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(w,{variant:`secondary`,onClick:_e,disabled:Q,children:[F.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(L,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),D(w,{variant:`secondary`,onClick:ve,disabled:Q,children:[M(X,{className:`h-3.5 w-3.5`}),` Delete`]}),M(w,{variant:`ghost`,onClick:q,disabled:Q,children:M(Y,{className:`h-3.5 w-3.5`})})]})]}),C&&D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!C&&W.length===0&&M(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:B.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!C&&W.length>0&&D(k,{children:[M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:G.pageItems.map(e=>M(Ze,{face:e,cameraName:U(e.deviceId),nowMs:R,selected:u.has(e.faceId),onToggleSelect:fe,onAssign:e=>g([e]),onOpenDetail:x},e.faceId))}),M(ae,{currentPage:G.page,totalItems:G.totalItems,pageSize:G.pageSize,onPageChange:G.setPage,itemNoun:`faces`})]}),M(Ae,{face:de,cameraName:de?U(de.deviceId):``,onClose:()=>x(null),onAssign:$,onUnassign:ye,onDelete:be,actionsPending:ge}),M(Me,{faceIds:p,identities:T,onDone:()=>{g(null),q()}}),M(qe,{open:_,onClose:()=>v(!1),byId:le,cameraName:U,nowMs:R,identities:T,selectMany:pe})]})}E();var et=[[`faceGallery`]],tt=2e3;function nt(){let e=A(),t=T(e);t.current=e;let n=T(void 0);n.current||=se({delayMs:tt,invalidate:()=>{t.current.invalidateQueries({queryKey:et})}}),N(()=>()=>n.current?.cancel(),[]),i(P.PipelineAnalyticsFaceGalleryChanged,()=>{n.current?.trigger()})}function rt(){return nt(),M(Z,{icon:me,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:D(`section`,{className:`space-y-3`,children:[D(`div`,{children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),M(Se,{})]}),D(`div`,{className:`pt-4 border-t border-border`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),M($e,{})]})]})})}export{rt as DetectionIntelligencePage};
1
+ import{$n as e,Co as t,Eo as n,Ja as r,Jn as i,Qn as a,To as o,Va as s,Xn as c,Yn as l,Zn as u,_o as d,ar as f,bo as p,er as m,go as h,ho as g,ir as _,jn as v,nr as y,qn as b,rr as x,tr as S,vo as C,yo as w}from"./src-DHFCkQHW.js";import{K as T,Q as E,S as D,W as O,b as k,o as A,q as j,x as M,z as N}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as P}from"./src-Cv9CvT8c.js";import{a as F,i as I,n as L,r as ee,t as R}from"./face-bbox-BScALk_z.js";import{a as z,c as te,f as B,i as V,l as ne,m as H,n as re,o as ie,p as U,r as ae,s as oe,t as se,u as ce}from"./debounced-invalidate-BsGZbF6v.js";import{t as W}from"./pencil-Bcfk7YmX.js";import{t as G}from"./plus-z-WZstU2.js";import{t as le}from"./refresh-cw-hhKexEfo.js";import{t as ue}from"./square-check-big-hPLl5NdC.js";import{t as de}from"./square-CEBWDX93.js";import{I as K,L as q,P as fe,S as J,W as pe,h as me,i as Y,l as he,s as X}from"./index-Cl-M8KBA.js";import{t as Z}from"./AdminPage-Dq33XE9j.js";import{n as Q,t as ge}from"./authed-media-XfBD4Ma-.js";var _e=pe(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),ve=pe(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);E();var $=[[`faceGallery`]];function ye({identityId:t}){let n=A(),{data:r,isLoading:i}=e({identityId:t}),a=S();function o(e){a.mutate({identityId:t,sampleId:e.id},{onSettled:()=>{n.invalidateQueries({queryKey:$})}})}return i?D(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!r||r.length===0?M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):M(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:r.map(e=>D(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?M(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:M(ve,{className:`h-6 w-6`})}),M(`button`,{type:`button`,onClick:()=>o(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:M(Y,{className:`h-4 w-4 text-white`})})]},e.id))})}function be({identity:e,expanded:r,onToggle:i}){let a=A(),[s,l]=j(``),[u,f]=j(!1),[m,_]=j(!1),v=y(),b=c();function x(){l(e.name),f(!0)}function S(){f(!1),l(``)}function T(){let t=s.trim();if(!t||t===e.name){S();return}v.mutate({id:e.id,name:t},{onSettled:()=>{a.invalidateQueries({queryKey:$}),S()}})}function E(){b.mutate({id:e.id},{onSettled:()=>{a.invalidateQueries({queryKey:$}),_(!1)}})}return D(`div`,{className:`rounded-md border border-border bg-surface`,children:[D(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[M(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?M(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center`,children:M(ve,{className:`h-4 w-4 text-foreground-subtle`})})}),M(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:u?D(k,{children:[M(t,{value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&S()},className:`h-6 text-xs`,autoFocus:!0}),M(`button`,{type:`button`,onClick:T,disabled:v.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:M(q,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:S,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:M(Y,{className:`h-3.5 w-3.5`})})]}):M(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),M(o,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!u&&D(`div`,{className:`flex items-center gap-1`,children:[M(`button`,{type:`button`,onClick:x,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:M(W,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:()=>_(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:M(X,{className:`h-3.5 w-3.5`})})]}),M(`button`,{type:`button`,onClick:i,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":r?`Collapse`:`Expand`,children:M(r?K:fe,{className:`h-3.5 w-3.5`})})]}),r&&M(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:M(ye,{identityId:e.id})}),M(g,{open:m,onOpenChange:e=>!e&&_(!1),children:D(h,{children:[D(w,{children:[M(p,{children:`Delete person`}),D(d,{children:[`Delete `,M(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),D(C,{children:[M(n,{variant:`secondary`,onClick:()=>_(!1),children:`Cancel`}),D(n,{variant:`danger`,onClick:E,disabled:b.isPending,children:[b.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function xe(){let e=A(),[r,a]=j(``),o=i();function s(){let t=r.trim();t&&o.mutate({name:t},{onSettled:()=>{e.invalidateQueries({queryKey:$}),a(``)}})}return D(`div`,{className:`flex items-center gap-2 pt-2`,children:[M(t,{placeholder:`New person name…`,value:r,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s()},className:`h-7 text-xs flex-1`}),D(n,{variant:`primary`,size:`sm`,onClick:s,disabled:o.isPending||!r.trim(),children:[o.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(G,{className:`h-3.5 w-3.5`}),`Add`]})]})}function Se(){let{data:e,isLoading:t}=a(),[n,r]=j(null);function i(e){r(t=>t===e?null:e)}return t?D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):D(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>M(be,{identity:e,expanded:n===e.id,onToggle:()=>i(e.id)},e.id)),M(xe,{})]})}function Ce(e){return e.base64===void 0||e.base64.length===0}function we(e){return e.filter(Ce).map(e=>e.faceId)}function Te(e){let t=0;for(let n of e)Ce(n)&&(t+=1);return t}E();function Ee(e){let[t,n]=j(null),[r,i]=j(null),[a,o]=j(!1);return N(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await Q(`${ge}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),N(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function De(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function Oe({label:e,value:t}){return D(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[M(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),M(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function ke({box:e}){return M(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:M(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function Ae({face:e,cameraName:t,onClose:r,onAssign:i,onUnassign:a,onDelete:o,actionsPending:s}){let{data:c,isFetching:l}=u({faceId:e?.faceId??``},{enabled:e!==null}),[d,f]=j(`frame`),{frameSrc:p,naturalWidth:m,naturalHeight:_,failed:v}=Ee(e?.keyFrameMediaKey),y=O(()=>{let t=De(c??[]);return t?`data:image/jpeg;base64,${t.base64}`:e?.base64?`data:image/jpeg;base64,${e.base64}`:null},[c,e]),b=O(()=>!e?.faceBbox||m===null||_===null?null:R(e.faceBbox,m,_),[e?.faceBbox,m,_]);if(e===null)return null;let x=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!v,S=x&&d===`frame`,C=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return M(g,{open:!0,onOpenChange:e=>!e&&r(),children:D(h,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[D(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`min-w-0`,children:[M(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),M(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),M(`button`,{type:`button`,onClick:r,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(Y,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[x&&D(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[D(`button`,{type:`button`,onClick:()=>f(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${d===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(I,{className:`h-3.5 w-3.5`}),` Full frame`]}),D(`button`,{type:`button`,onClick:()=>f(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${d===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(F,{className:`h-3.5 w-3.5`}),` Crop`]})]}),S&&p?M(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:M(V,{src:p,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:b?M(ke,{box:b}):void 0})}):y?D(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[M(V,{src:y,alt:`Detected face`,className:`h-full w-full`}),l&&M(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:M(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):D(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[M(H,{className:`h-8 w-8 text-warning/70`}),M(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),M(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),D(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[M(Oe,{label:`Camera`,value:t}),M(Oe,{label:`Captured`,value:U(e.timestamp)}),M(Oe,{label:`Track`,value:e.trackId}),M(Oe,{label:`Identity`,value:C})]})]}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?D(n,{variant:`secondary`,onClick:()=>a(e.faceId),disabled:s,children:[M(L,{className:`h-3.5 w-3.5`}),` Detach`]}):D(n,{variant:`primary`,onClick:()=>i(e.faceId),disabled:s,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(n,{variant:`secondary`,onClick:()=>o(e.faceId),disabled:s,children:[M(X,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}E();var je=[[`faceGallery`]];function Me({faceIds:e,identities:r,onDone:a}){let o=A(),s=b(),c=i(),[l,u]=j(``),[f,m]=j(!1),[_,v]=j(null),y=e!==null&&e.length>0,x=e?.length??0;function S(){m(!1),u(``),v(null)}function T(){S(),a()}function E(t){!e||e.length===0||s.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{o.invalidateQueries({queryKey:je}),T()}})}function O(){!e||!l.trim()||c.mutate({name:l.trim()},{onSuccess:e=>{e?.id&&E(e.id)},onError:()=>{o.invalidateQueries({queryKey:je}),T()}})}let k=s.isPending||c.isPending;return M(g,{open:y,onOpenChange:e=>!e&&T(),children:D(h,{children:[D(w,{children:[M(p,{children:x>1?`Assign ${String(x)} faces to person`:`Assign face to person`}),M(d,{children:`Select an existing person or create a new one.`})]}),M(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:r.map(e=>D(`button`,{type:`button`,onClick:()=>v(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${_===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[M(`span`,{className:`font-medium`,children:e.name}),D(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),f?M(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:M(t,{placeholder:`New person name…`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):M(`button`,{type:`button`,onClick:()=>{v(null),m(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),D(C,{children:[M(n,{variant:`secondary`,onClick:T,disabled:k,children:`Cancel`}),f?D(n,{variant:`primary`,onClick:O,disabled:k||!l.trim(),children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):D(n,{variant:`primary`,onClick:()=>_&&E(_),disabled:k||!_,children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,x>1?` ${String(x)}`:``]})]})]})})}function Ne(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Pe(e,t){return e.faceIds.filter(e=>!t.has(e))}function Fe(e,t){return e.faceIds.filter(e=>t(e))}E();var Ie=[[`faceGallery`]],Le=20,Re=.3,ze=.9,Be=.05,Ve=.5,He=2,Ue=10,We=2;function Ge({cluster:e,face:t,active:n,onSelect:r}){return D(`button`,{type:`button`,onClick:r,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[M(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:t?.base64?M(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:``,className:`h-24 w-24 object-cover`}):M(H,{className:`h-24 w-24 p-6 text-foreground-subtle`})}),D(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function Ke({face:e,cameraName:t,nowMs:n,excluded:r,onToggleExclude:i,onDelete:a,deletePending:o}){return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${r?`border-border opacity-40 grayscale`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?M(V,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face from ${t}`,className:`h-full w-full`}):D(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[M(H,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Include face`:`Exclude face`,title:r?`Include`:`Exclude`,children:M(r?_e:Y,{className:`h-3.5 w-3.5`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:B(e.timestamp,n)})]}),M(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},disabled:o,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:o?M(J,{className:`h-4 w-4 animate-spin`}):M(X,{className:`h-4 w-4`})})})]})}function qe({open:e,onClose:t,byId:r,cameraName:i,nowMs:a,identities:o,selectMany:c}){let u=A(),d=s(),f=l(),[p,m]=j(Ve),[_,v]=j(We),[y,b]=j(null),[S,C]=j({}),[w,T]=j(null),{data:E,isFetching:P,refetch:F}=x({threshold:p,minClusterSize:_,limit:Le},{enabled:e}),I=E??[];N(()=>{C({})},[p,_]),N(()=>{if(I.length===0){b(null);return}I.some(e=>e.representativeFaceId===y)||b(I[0]?.representativeFaceId??null)},[I]);let L=O(()=>I.find(e=>e.representativeFaceId===y)??null,[I,y]),R=L?S[L.representativeFaceId]??new Set:new Set,z=O(()=>L?Fe(L,e=>r.has(e)):[],[L,r]),te=L?L.faceIds.length-z.length:0,B=L?Pe({...L,faceIds:z},R):[];function V(e){if(!L)return;let t=L.representativeFaceId;C(n=>({...n,[t]:Ne(n[t]??new Set,e)}))}function ne(){u.invalidateQueries({queryKey:Ie})}async function H(e){await d({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&f.mutate({faceId:e},{onSettled:ne})}function re(){T(null),t()}function ie(){B.length!==0&&(c(B),re())}return D(g,{open:e,onOpenChange:e=>!e&&re(),children:[D(h,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[D(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[M(he,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),M(`button`,{type:`button`,onClick:re,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(Y,{className:`h-4 w-4`})})]}),D(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,M(`input`,{type:`range`,min:Re,max:ze,step:Be,value:p,onChange:e=>m(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),M(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:p.toFixed(2)})]}),D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,M(`input`,{type:`number`,min:He,max:Ue,step:1,value:_,onChange:e=>v(Math.min(Ue,Math.max(He,Number(e.target.value)||He))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),D(n,{variant:`secondary`,onClick:()=>{C({}),F()},disabled:P,children:[P?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(le,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),M(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:P&&I.length===0?D(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):I.length===0?M(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):D(k,{children:[M(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:I.map(e=>M(Ge,{cluster:e,face:r.get(e.representativeFaceId),active:e.representativeFaceId===y,onSelect:()=>b(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:I.map(e=>M(Ge,{cluster:e,face:r.get(e.representativeFaceId),active:e.representativeFaceId===y,onSelect:()=>b(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:L&&D(k,{children:[te>0&&D(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[te,` not loaded — excluded from actions`]}),M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:z.map(e=>{let t=r.get(e);return t?M(Ke,{face:t,cameraName:i(t.deviceId),nowMs:a,excluded:R.has(e),onToggleExclude:()=>V(e),onDelete:()=>void H(e),deletePending:f.isPending&&f.variables?.faceId===e},e):null})})]})})]})}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[M(n,{variant:`secondary`,onClick:ie,disabled:B.length===0,children:`Select in gallery`}),D(n,{variant:`primary`,onClick:()=>T(B),disabled:B.length===0,children:[M(ee,{className:`h-3.5 w-3.5`}),` Adopt (`,B.length,`)`]})]})]}),M(Me,{faceIds:w,identities:o,onDone:()=>T(null)})]})}E();var Je=[[`faceGallery`]],Ye=500,Xe=120;function Ze({face:e,cameraName:t,nowMs:n,selected:r,onToggleSelect:i,onAssign:a,onOpenDetail:o}){let s=A(),c=_(),u=l(),d=()=>{s.invalidateQueries({queryKey:Je})},f=()=>o(e.faceId);return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${r?`border-primary ring-1 ring-primary`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?M(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face from ${t}`,onClick:f,className:`h-full w-full cursor-zoom-in object-cover`}):D(`button`,{type:`button`,onClick:f,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[M(H,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Deselect`:`Select`,children:r?M(ue,{className:`h-4 w-4 text-primary`}):M(de,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:B(e.timestamp,n)}),e.identityName&&M(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),D(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),c.mutate({faceId:e.faceId},{onSettled:d})},disabled:c.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:c.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(L,{className:`h-4 w-4`})}):M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:M(ee,{className:`h-4 w-4`})}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),u.mutate({faceId:e.faceId},{onSettled:d})},disabled:u.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:u.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(X,{className:`h-4 w-4`})})]})]})}var Qe=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function $e(){let e=A(),[t,r]=j(`all`),[i,o]=j(oe),[s,c]=j(new Set),[u,d]=j(new Set),[p,h]=j(null),[g,y]=j(!1),[x,S]=j(null),{data:C,isLoading:w}=m({limit:Ye,filter:t},{refetchInterval:3e4}),{data:T=[]}=a(),{data:E}=v({}),N=b(),P=_(),F=f(),I=l(),R=Date.now(),B=C??[],V=O(()=>{let e=new Map;for(let t of E??[])e.set(t.id,t.name);return e},[E]),U=e=>V.get(e)??`Camera #${String(e)}`,se=O(()=>te(B).map(e=>({id:e,name:U(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[B,V]),W=O(()=>ne(ce(B,i),s),[B,i,s]),G=re(W,Xe,O(()=>JSON.stringify([t,i.fromMs,i.toMs,[...s].sort((e,t)=>e-t)]),[t,i.fromMs,i.toMs,s])),le=O(()=>new Map(B.map(e=>[e.faceId,e])),[B]),ue=O(()=>Te(W),[W]),de=x===null?null:le.get(x)??null,K=()=>{e.invalidateQueries({queryKey:Je})},q=()=>d(new Set);function fe(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){d(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(we(W))}let Z=[...u],Q=N.isPending||F.isPending||I.isPending,ge=P.isPending||I.isPending;function _e(){Z.length!==0&&F.mutate({faceIds:Z},{onSettled:()=>{K(),q()}})}function ve(){Z.length!==0&&Promise.allSettled(Z.map(e=>I.mutateAsync({faceId:e}))).then(()=>{K(),q()})}function $(e){S(null),h([e])}function ye(e){P.mutate({faceId:e},{onSettled:K}),S(null)}function be(e){I.mutate({faceId:e},{onSettled:K}),S(null)}let xe=W.length!==B.length;return D(`div`,{className:`relative space-y-3`,children:[D(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[M(`div`,{className:`flex items-center gap-1`,children:Qe.map(e=>M(`button`,{type:`button`,onClick:()=>r(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),M(z,{onChange:o}),M(ie,{cameras:se,selected:s,onChange:c}),D(`button`,{type:`button`,onClick:()=>y(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${g?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(he,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!w&&ue>0&&D(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[M(H,{className:`h-3.5 w-3.5`}),` Select `,ue,` crop-less`]}),!w&&M(`span`,{className:`text-[10px] text-foreground-subtle ${ue>0?`ml-2`:`ml-auto`}`,children:xe?`${String(W.length)} of ${String(B.length)} faces`:`${String(W.length)} face${W.length===1?``:`s`}`})]}),u.size>0&&D(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[D(`span`,{className:`text-xs font-medium text-foreground`,children:[u.size,` selected`]}),D(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[D(n,{variant:`primary`,onClick:()=>h(Z),disabled:Q,children:[M(ee,{className:`h-3.5 w-3.5`}),` Assign`]}),D(n,{variant:`secondary`,onClick:_e,disabled:Q,children:[F.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(L,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),D(n,{variant:`secondary`,onClick:ve,disabled:Q,children:[M(X,{className:`h-3.5 w-3.5`}),` Delete`]}),M(n,{variant:`ghost`,onClick:q,disabled:Q,children:M(Y,{className:`h-3.5 w-3.5`})})]})]}),w&&D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!w&&W.length===0&&M(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:B.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!w&&W.length>0&&D(k,{children:[M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:G.pageItems.map(e=>M(Ze,{face:e,cameraName:U(e.deviceId),nowMs:R,selected:u.has(e.faceId),onToggleSelect:fe,onAssign:e=>h([e]),onOpenDetail:S},e.faceId))}),M(ae,{currentPage:G.page,totalItems:G.totalItems,pageSize:G.pageSize,onPageChange:G.setPage,itemNoun:`faces`})]}),M(Ae,{face:de,cameraName:de?U(de.deviceId):``,onClose:()=>S(null),onAssign:$,onUnassign:ye,onDelete:be,actionsPending:ge}),M(Me,{faceIds:p,identities:T,onDone:()=>{h(null),q()}}),M(qe,{open:g,onClose:()=>y(!1),byId:le,cameraName:U,nowMs:R,identities:T,selectMany:pe})]})}E();var et=[[`faceGallery`]],tt=2e3;function nt(){let e=A(),t=T(e);t.current=e;let n=T(void 0);n.current||=se({delayMs:tt,invalidate:()=>{t.current.invalidateQueries({queryKey:et})}}),N(()=>()=>n.current?.cancel(),[]),r(P.PipelineAnalyticsFaceGalleryChanged,()=>{n.current?.trigger()})}function rt(){return nt(),M(Z,{icon:me,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:D(`section`,{className:`space-y-3`,children:[D(`div`,{children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),M(Se,{})]}),D(`div`,{className:`pt-4 border-t border-border`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),M($e,{})]})]})})}export{rt as DetectionIntelligencePage};