@camstack/addon-admin-ui 1.2.86 → 1.2.88

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 (111) hide show
  1. package/dist/assets/{AddLocationWizard-CVvsaNYx.js → AddLocationWizard-BntkKU2V.js} +1 -1
  2. package/dist/assets/{AddonCollectionPage-JA8tzL7q.js → AddonCollectionPage-DfZQjIPJ.js} +1 -1
  3. package/dist/assets/Addons-Cof7W-Ym.js +1 -0
  4. package/dist/assets/{AdminTabs-B-UL_iuP.js → AdminTabs-FswV6m19.js} +1 -1
  5. package/dist/assets/{AiProfiles-DI31JvyZ.js → AiProfiles-Bol2xzPZ.js} +1 -1
  6. package/dist/assets/{BrokerForm-CFTyH54D.js → BrokerForm-rlgpgB9M.js} +1 -1
  7. package/dist/assets/{Build-BP0Mx9FT.js → Build--P11mU0s.js} +3 -3
  8. package/dist/assets/{Capabilities-BvxWbN6u.js → Capabilities-Di_wIznW.js} +1 -1
  9. package/dist/assets/CapabilityBadges-BOwdQNDH.js +1 -0
  10. package/dist/assets/{Cluster-CsEHMgVp.js → Cluster-B58mM4Kr.js} +1 -1
  11. package/dist/assets/{Data-Bt2o6J7H.js → Data-uwnl2ZR0.js} +1 -1
  12. package/dist/assets/{DetectionIntelligence-CeunXPtW.js → DetectionIntelligence-wpF45dZl.js} +1 -1
  13. package/dist/assets/{DeviceAggregateSection-DLNzCtMs.js → DeviceAggregateSection-r5_ljoI1.js} +1 -1
  14. package/dist/assets/DeviceDetail-Bf3FJFNv.js +2 -0
  15. package/dist/assets/{Devices-fMM-N9UK.js → Devices-D3k50BRl.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-D8LRITOt.js → EmbedPlayerPage-C2EWx5XY.js} +1 -1
  17. package/dist/assets/Events-DuXVjBmB.js +1 -0
  18. package/dist/assets/{FormBuilder-ChyOUw_O.js → FormBuilder-QY4tah4S.js} +1 -1
  19. package/dist/assets/{Identity-kjnupMGz.js → Identity-BV8WXb2H.js} +1 -1
  20. package/dist/assets/{IntegrationDetail-683FxnPV.js → IntegrationDetail-ClwD7H7W.js} +1 -1
  21. package/dist/assets/{Integrations-BAa7Hx8I.js → Integrations-BGbVMFT4.js} +1 -1
  22. package/dist/assets/{Integrations-Bvz5KiZt.js → Integrations-Dy_WWWKK.js} +1 -1
  23. package/dist/assets/{Logs-CPMTc4WW.js → Logs-Dr2j0QZR.js} +1 -1
  24. package/dist/assets/{MotionZonesSettings-DhO5kuER.js → MotionZonesSettings-Ds8nYWoN.js} +1 -1
  25. package/dist/assets/{MyAccess-C5kfikXk.js → MyAccess-Bsf24wbg.js} +1 -1
  26. package/dist/assets/Network-D_OMCOsR.js +1 -0
  27. package/dist/assets/{NodeAddonsSettingsPanel-BdP5wGIu.js → NodeAddonsSettingsPanel-B3-jgI6Y.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-CubcmlvI.js → NodeInferenceDevices-vixWXUkV.js} +1 -1
  29. package/dist/assets/Notifications-DbYpUqwt.js +1 -0
  30. package/dist/assets/Pipeline-m823fIKM.js +1 -0
  31. package/dist/assets/{Plates-DiVTWUKg.js → Plates-BIkYeFJp.js} +1 -1
  32. package/dist/assets/{PrivacyMaskSettings-zKU6VZ4G.js → PrivacyMaskSettings-C2nmPqsf.js} +1 -1
  33. package/dist/assets/{ProviderIcon-JxmOoO_O.js → ProviderIcon-yuhuUjyO.js} +1 -1
  34. package/dist/assets/Recordings-ChPRJj_w.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-DkqUu2Xc.js → ScanNetworkModal-B6Dhtqhv.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-DZucoVrl.js → SceneMonitorEditor-CpU_-6iK.js} +1 -1
  37. package/dist/assets/{Scenes-DMSYbhd1.js → Scenes-Bp-HU3HC.js} +1 -1
  38. package/dist/assets/{Settings-olnTIAze.js → Settings-CxNCTStH.js} +1 -1
  39. package/dist/assets/{Showroom-CdPGD4R4.js → Showroom-BfQj_ruk.js} +1 -1
  40. package/dist/assets/{Terminal-Ck0I64eZ.js → Terminal-COkGK9Eu.js} +5 -3
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BpY1fOVD.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CtfWG-B0.js} +1 -1
  42. package/dist/assets/{bell-ring-BgQsFN7F.js → bell-ring-BIkgL1EI.js} +1 -1
  43. package/dist/assets/{boxes-BnOBLNz5.js → boxes-EqdcdFpg.js} +1 -1
  44. package/dist/assets/{build-cluster-graph-BwHdP82z.js → build-cluster-graph-C0MeCzJZ.js} +1 -1
  45. package/dist/assets/circle-check-big-DGl1OsLR.js +1 -0
  46. package/dist/assets/{circle-x-DAqnOyA6.js → circle-x-CBZPec7u.js} +1 -1
  47. package/dist/assets/clock-M4NiOyl_.js +1 -0
  48. package/dist/assets/{copy-Dl5E5of_.js → copy-BPgY4Eey.js} +1 -1
  49. package/dist/assets/{debounced-invalidate-BIRVvqvY.js → debounced-invalidate-B1bc5kFD.js} +1 -1
  50. package/dist/assets/{dist-CUfLXJC3.js → dist-DjbCvztb.js} +1 -1
  51. package/dist/assets/dist-IEXliP3K.js +349 -0
  52. package/dist/assets/{download-AfoMEWCf.js → download-Dq2bfdRX.js} +1 -1
  53. package/dist/assets/{face-bbox-BFT7iMc1.js → face-bbox-DUGyLE43.js} +1 -1
  54. package/dist/assets/{hard-drive-C9zTEogy.js → hard-drive-COdkuHqf.js} +1 -1
  55. package/dist/assets/{hostInit-Cw_l9Xfz.js → hostInit-BSakAGif.js} +1 -1
  56. package/dist/assets/index-LPwis6Rq.js +4 -0
  57. package/dist/assets/{key-round-sF-8oSo7.js → key-round-CfAFZkMw.js} +1 -1
  58. package/dist/assets/{mf-entry-bootstrap-0-8f39d7c2.js → mf-entry-bootstrap-0-e9ffa7b9.js} +2 -2
  59. package/dist/assets/{pencil-DsWgW1cM.js → pencil-CfoKCBNv.js} +1 -1
  60. package/dist/assets/play-CqrjGyv7.js +1 -0
  61. package/dist/assets/{player-overlays-BGbLKvcn.js → player-overlays-CBKaIBph.js} +1 -1
  62. package/dist/assets/plus-DHRgxEWi.js +1 -0
  63. package/dist/assets/power-DGhEdOiQ.js +1 -0
  64. package/dist/assets/{radio-CWn4dw9L.js → radio-BOUTlTbE.js} +1 -1
  65. package/dist/assets/{refresh-cw-Cly4MRhi.js → refresh-cw-CllqntzE.js} +1 -1
  66. package/dist/assets/remoteEntry-BsYVmvk8.js +1 -0
  67. package/dist/assets/rotate-ccw-CdTrnBTI.js +1 -0
  68. package/dist/assets/rotate-cw-Dre2EA6E.js +1 -0
  69. package/dist/assets/search-Dx_k5G37.js +1 -0
  70. package/dist/assets/{send-yaKZ1tHd.js → send-DcXtHjaz.js} +1 -1
  71. package/dist/assets/{server-CLOtA1S4.js → server-DbU7BgZv.js} +1 -1
  72. package/dist/assets/shield-BojVNBVL.js +1 -0
  73. package/dist/assets/square-DynbJcCj.js +1 -0
  74. package/dist/assets/{square-check-big-DsiPGDCA.js → square-check-big-Ch-X3CcM.js} +1 -1
  75. package/dist/assets/src-0pbBUmTo.js +349 -0
  76. package/dist/assets/src-BLHY9yig.js +67 -0
  77. package/dist/assets/{star-fUCw1hyi.js → star-BotqSaGv.js} +1 -1
  78. package/dist/assets/{undo-2-DXcExZt9.js → undo-2-CXIWJrgH.js} +1 -1
  79. package/dist/assets/{upload-CLT-rIe6.js → upload-CafOTsXz.js} +1 -1
  80. package/dist/assets/{use-scenes-feed-CvesyXw2.js → use-scenes-feed-DTuzztEP.js} +1 -1
  81. package/dist/assets/useEventInvalidation-BDOhX3vo.js +1 -0
  82. package/dist/assets/{video-CFtTGKiz.js → video-GQHe9bLG.js} +1 -1
  83. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BwIIU_83.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-7s6IgvIP.js} +2 -2
  84. package/dist/assets/{wifi-Glpx3AkR.js → wifi-MOwlhPpo.js} +1 -1
  85. package/dist/assets/{zap-aTn3GS-l.js → zap-BiojyRpM.js} +1 -1
  86. package/dist/index.html +5 -5
  87. package/dist/server/addon.js +135 -7
  88. package/package.json +1 -1
  89. package/dist/assets/Addons-BOYMP0uf.js +0 -1
  90. package/dist/assets/CapabilityBadges-DjOvNnpp.js +0 -1
  91. package/dist/assets/DeviceDetail-DCh8ydpY.js +0 -2
  92. package/dist/assets/Events-Drj6ybP0.js +0 -1
  93. package/dist/assets/Network-DBtVDYGt.js +0 -1
  94. package/dist/assets/Notifications-DBH3QGle.js +0 -1
  95. package/dist/assets/Pipeline-DgZbCwcO.js +0 -1
  96. package/dist/assets/Recordings-DTGdM6Ip.js +0 -1
  97. package/dist/assets/circle-check-big-FvfSWrhR.js +0 -1
  98. package/dist/assets/clock-BpmU9WHJ.js +0 -1
  99. package/dist/assets/dist-C2l22cSJ.js +0 -349
  100. package/dist/assets/index-vZPXzSPK.js +0 -4
  101. package/dist/assets/play-BkPr3HPj.js +0 -1
  102. package/dist/assets/plus-zSkh3oEn.js +0 -1
  103. package/dist/assets/power-C4yi0usE.js +0 -1
  104. package/dist/assets/remoteEntry-BwhR6qpk.js +0 -1
  105. package/dist/assets/rotate-ccw-D0bM0VXI.js +0 -1
  106. package/dist/assets/rotate-cw-CNTEn7nJ.js +0 -1
  107. package/dist/assets/search-Bq3ZLayo.js +0 -1
  108. package/dist/assets/square-BlSn3fsr.js +0 -1
  109. package/dist/assets/src-Buv5KpAz.js +0 -67
  110. package/dist/assets/src-CQVcBp6b.js +0 -349
  111. package/dist/assets/useEventInvalidation-B-Cb5-ry.js +0 -1
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-BHo8W_uH.js","assets/rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-zJ_50EbN.js";import{Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as d}from"./player-overlays-BGbLKvcn.js";import{Jt as f,S as p,rn as m}from"./src-Buv5KpAz.js";import{t as h}from"./circle-check-big-FvfSWrhR.js";import{t as g}from"./copy-Dl5E5of_.js";import{t as _}from"./key-round-sF-8oSo7.js";import{t as v}from"./pencil-DsWgW1cM.js";import{C as y,F as b,S as x,k as S,r as C,s as w,u as T,w as E,x as D}from"./index-vZPXzSPK.js";import{t as O}from"./AdminPage-CCD07UMs.js";n();function k({value:n,size:i=192}){let[a,o]=s(null),[c,d]=s(null);if(u(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){d(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||d(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1])).catch(()=>{r||d(`qrcode library not installed`)}),()=>{r=!0}},[n]),c)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:`QR rendering unavailable — use the secret below.`});if(!a)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:`Generating…`});let f=a.modules.size,p=i/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)a.modules.data[e*f+t]&&m.push(l(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return r(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[l(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),m]})}n();var A={view:{icon:S,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:v,cls:`bg-primary/15 text-primary`},delete:{icon:w,cls:`bg-danger/15 text-danger`}};function j(){let{user:e,logout:t}=C();if(!e)return l(O,{children:l(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,i=e.scopes??[];return r(O,{children:[r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[l(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),r(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,r(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&r(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[l(E,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),r(`div`,{children:[l(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),l(`p`,{className:`text-foreground-subtle mt-0.5`,children:`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`})]})]}),l(M,{}),l(P,{username:e.username}),l(F,{}),i.length>0&&r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2 border-b border-border`,children:[l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),r(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[l(`div`,{children:`Type`}),l(`div`,{children:`Target`}),l(`div`,{children:`Access`})]}),l(`ul`,{className:`divide-y divide-border`,children:i.map((e,t)=>r(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[l(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),l(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?p(e.selector):e.target}),l(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:i,cls:a}=A[t];return r(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:n?`Can ${t}`:`Cannot ${t}`,children:[l(i,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:t,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[l(D,{className:`h-3 w-3`}),`Sign out`]})})]})}function M(){let e=d(),[t,n]=s(``),[i,a]=s(``),[o,u]=s(``),[f,p]=s(null),m=c({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),n(``),a(``),u(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=i.length>0&&o.length>0&&i!==o,v=i.length>0&&i.length<8,S=t.length>=1&&i.length>=8&&i===o;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),r(`div`,{className:`p-4 space-y-3`,children:[l(N,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),l(N,{label:`New password`,value:i,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),l(N,{label:`Confirm new password`,value:o,onChange:u,autoComplete:`new-password`}),(g||v)&&l(`div`,{className:`text-[11px] text-danger`,children:g?`Passwords do not match.`:`New password must be at least 8 characters.`}),f&&r(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[f.kind===`success`?l(h,{className:`h-3 w-3`}):l(b,{className:`h-3 w-3`}),f.msg]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{p(null),m.mutate({currentPassword:t,newPassword:i})},disabled:!S||m.isPending,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:[m.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(x,{className:`h-3 w-3`}),`Update password`]})})]})]})}function N({label:e,value:t,onChange:n,autoComplete:i,hint:a}){return r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),l(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:i,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`}),a&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:a})]})}function P({username:e}){let t=d(),n=a({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),f=n.data,[p,m]=s(null),[_,v]=s(``),[x,S]=s(null),[C,w]=s(!1),E=c({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),D=c({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{m(null),v(``),S(null),n.refetch()},onError:e=>S(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=c({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{S(null),n.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});u(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let A=i(()=>n.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,f?.enabled,p]);return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(T,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),r(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[l(y,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&r(o,{children:[l(`div`,{className:`text-xs text-foreground-subtle`,children:`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{S(null),E.mutate()},disabled:E.isPending,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:[E.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(T,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&p&&r(o,{children:[r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,l(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),r(`div`,{className:`flex flex-col items-center gap-3`,children:[l(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:l(k,{value:p.otpauthUrl,size:180})}),r(`div`,{className:`w-full`,children:[l(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),r(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[l(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),r(`button`,{onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[C?l(h,{className:`h-3 w-3 text-emerald-500`}):l(g,{className:`h-3 w-3`}),C?`Copied`:`Copy`]})]})]})]}),r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),l(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:_,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),x&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(b,{className:`h-3 w-3`}),x]}),r(`div`,{className:`flex justify-end gap-2`,children:[l(`button`,{onClick:()=>{m(null),S(null),v(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),r(`button`,{onClick:()=>{S(null),D.mutate({code:_})},disabled:D.isPending||_.length!==6,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:[D.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(h,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&f&&r(o,{children:[r(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[l(h,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),r(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[l(`div`,{className:`font-medium`,children:`2FA is active`}),r(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`]})]})]}),x&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(b,{className:`h-3 w-3`}),x]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{S(null),O.mutate()},disabled:O.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[O.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(T,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function F(){return m(`auth-webauthn/passkey-enrollment`)?l(f,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{j as MyAccessPage};
2
+ import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-zJ_50EbN.js";import{Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as d}from"./player-overlays-CBKaIBph.js";import{Jt as f,S as p,rn as m}from"./src-BLHY9yig.js";import{t as h}from"./circle-check-big-DGl1OsLR.js";import{t as g}from"./copy-BPgY4Eey.js";import{t as _}from"./key-round-CfAFZkMw.js";import{t as v}from"./pencil-CfoKCBNv.js";import{C as y,F as b,S as x,k as S,r as C,s as w,u as T,w as E,x as D}from"./index-LPwis6Rq.js";import{t as O}from"./AdminPage-CCD07UMs.js";n();function k({value:n,size:i=192}){let[a,o]=s(null),[c,d]=s(null);if(u(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){d(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||d(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1])).catch(()=>{r||d(`qrcode library not installed`)}),()=>{r=!0}},[n]),c)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:`QR rendering unavailable — use the secret below.`});if(!a)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:`Generating…`});let f=a.modules.size,p=i/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)a.modules.data[e*f+t]&&m.push(l(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return r(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[l(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),m]})}n();var A={view:{icon:S,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:v,cls:`bg-primary/15 text-primary`},delete:{icon:w,cls:`bg-danger/15 text-danger`}};function j(){let{user:e,logout:t}=C();if(!e)return l(O,{children:l(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,i=e.scopes??[];return r(O,{children:[r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[l(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),r(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,r(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&r(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[l(E,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),r(`div`,{children:[l(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),l(`p`,{className:`text-foreground-subtle mt-0.5`,children:`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`})]})]}),l(M,{}),l(P,{username:e.username}),l(F,{}),i.length>0&&r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2 border-b border-border`,children:[l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),r(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[l(`div`,{children:`Type`}),l(`div`,{children:`Target`}),l(`div`,{children:`Access`})]}),l(`ul`,{className:`divide-y divide-border`,children:i.map((e,t)=>r(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[l(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),l(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?p(e.selector):e.target}),l(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:i,cls:a}=A[t];return r(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:n?`Can ${t}`:`Cannot ${t}`,children:[l(i,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:t,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[l(D,{className:`h-3 w-3`}),`Sign out`]})})]})}function M(){let e=d(),[t,n]=s(``),[i,a]=s(``),[o,u]=s(``),[f,p]=s(null),m=c({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),n(``),a(``),u(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=i.length>0&&o.length>0&&i!==o,v=i.length>0&&i.length<8,S=t.length>=1&&i.length>=8&&i===o;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),r(`div`,{className:`p-4 space-y-3`,children:[l(N,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),l(N,{label:`New password`,value:i,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),l(N,{label:`Confirm new password`,value:o,onChange:u,autoComplete:`new-password`}),(g||v)&&l(`div`,{className:`text-[11px] text-danger`,children:g?`Passwords do not match.`:`New password must be at least 8 characters.`}),f&&r(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[f.kind===`success`?l(h,{className:`h-3 w-3`}):l(b,{className:`h-3 w-3`}),f.msg]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{p(null),m.mutate({currentPassword:t,newPassword:i})},disabled:!S||m.isPending,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:[m.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(x,{className:`h-3 w-3`}),`Update password`]})})]})]})}function N({label:e,value:t,onChange:n,autoComplete:i,hint:a}){return r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),l(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:i,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`}),a&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:a})]})}function P({username:e}){let t=d(),n=a({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),f=n.data,[p,m]=s(null),[_,v]=s(``),[x,S]=s(null),[C,w]=s(!1),E=c({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),D=c({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{m(null),v(``),S(null),n.refetch()},onError:e=>S(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=c({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{S(null),n.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});u(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let A=i(()=>n.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,f?.enabled,p]);return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(T,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),r(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[l(y,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&r(o,{children:[l(`div`,{className:`text-xs text-foreground-subtle`,children:`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{S(null),E.mutate()},disabled:E.isPending,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:[E.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(T,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&p&&r(o,{children:[r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,l(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),r(`div`,{className:`flex flex-col items-center gap-3`,children:[l(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:l(k,{value:p.otpauthUrl,size:180})}),r(`div`,{className:`w-full`,children:[l(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),r(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[l(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),r(`button`,{onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[C?l(h,{className:`h-3 w-3 text-emerald-500`}):l(g,{className:`h-3 w-3`}),C?`Copied`:`Copy`]})]})]})]}),r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),l(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:_,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),x&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(b,{className:`h-3 w-3`}),x]}),r(`div`,{className:`flex justify-end gap-2`,children:[l(`button`,{onClick:()=>{m(null),S(null),v(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),r(`button`,{onClick:()=>{S(null),D.mutate({code:_})},disabled:D.isPending||_.length!==6,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:[D.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(h,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&f&&r(o,{children:[r(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[l(h,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),r(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[l(`div`,{className:`font-medium`,children:`2FA is active`}),r(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`]})]})]}),x&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(b,{className:`h-3 w-3`}),x]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{S(null),O.mutate()},disabled:O.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[O.isPending?l(y,{className:`h-3 w-3 animate-spin`}):l(T,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function F(){return m(`auth-webauthn/passkey-enrollment`)?l(f,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{j as MyAccessPage};
@@ -0,0 +1 @@
1
+ import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as l}from"./player-overlays-CBKaIBph.js";import{Ai as u,Bi as d,Di as f,Dn as p,En as m,Fi as h,Ft as g,Gi as _,Hi as v,Ii as y,It as b,Ki as x,Li as S,Lt as C,Mi as w,Ni as ee,Oi as te,Pi as T,Ri as E,Vi as D,Yt as O,_s as k,et as A,ji as ne,ki as re,nt as j,qi as M,zi as N}from"./src-BLHY9yig.js";import{at as P,et as F}from"./src-0pbBUmTo.js";import{t as I}from"./boxes-EqdcdFpg.js";import{t as L}from"./copy-BPgY4Eey.js";import{t as ie}from"./play-CqrjGyv7.js";import{t as ae}from"./refresh-cw-CllqntzE.js";import{t as oe}from"./rotate-ccw-CdTrnBTI.js";import{t as R}from"./server-DbU7BgZv.js";import{t as se}from"./shield-BojVNBVL.js";import{t as ce}from"./square-DynbJcCj.js";import{t as z}from"./wifi-MOwlhPpo.js";import{C as B,E as V,K as H,S as le,U as ue,i as de,j as U,l as fe,o as W,x as pe,y as G,z as me}from"./index-LPwis6Rq.js";import{t as he}from"./AdminPage-CCD07UMs.js";import{t as ge}from"./AdminTabs-FswV6m19.js";import{t as _e}from"./NodeAddonsSettingsPanel-B3-jgI6Y.js";import{t as K}from"./AddonCollectionPage-DfZQjIPJ.js";import{t as q}from"./addon-display-names-DvSEQty-.js";var ve=H(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),ye=H(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),J=H(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]);t();var Y=5e3,be={connected:!1,endpoint:null};function xe(){let e=a(),t=p({capName:`network-access`},{refetchInterval:Y}),n=m(void 0,{refetchInterval:Y}),i=r(()=>q(n.data??[]),[n.data]),c=r(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),[l,u]=o(null),[d,f]=o({}),h=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),u(null),f(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},g=(e,t)=>{u(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);f(e=>({...e,[n]:r}))},_=x({onSuccess:h,onError:g}),v=M({onSuccess:h,onError:g});return s(K,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:V,itemIcon:V,capability:`network-access`,installButtonLabel:`Add tunnel`,items:c,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>s(Se,{addonId:e.addonId}),itemError:e=>d[e.addonId]??null,renderPrimaryAction:e=>s(Ce,{addonId:e.addonId,busyId:l,onStart:e=>{u(e),_.mutate({addonId:e})},onStop:e=>{u(e),v.mutate({addonId:e})}})})}function X(e){let{data:t}=_({addonId:e},{refetchInterval:Y,retry:!1}),n=t?P.safeParse(t):null;return n?.success?n.data:be}function Se({addonId:e}){let t=X(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&n(`a`,{href:t.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1`,children:[s(U,{className:`h-3 w-3`}),t.endpoint.url]})]})}function Ce({addonId:e,busyId:t,onStart:r,onStop:i}){let a=X(e),o=t===e;return a.connected?n(C,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?s(B,{className:`h-3 w-3 animate-spin`}):s(ce,{className:`h-3 w-3`}),`Stop`]}):n(C,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>r(e),children:[o?s(B,{className:`h-3 w-3 animate-spin`}):s(ie,{className:`h-3 w-3`}),`Start`]})}t();var Z=3e4;function we(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Te(){let e=p({capName:`turn-provider`},{refetchInterval:Z}),t=m(void 0,{refetchInterval:Z}),i=k(),a=i.data??[],o=r(()=>q(t.data??[]),[t.data]);return s(K,{title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,pageIcon:G,itemIcon:G,capability:`turn-provider`,installButtonLabel:`Add provider`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,o]),isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,renderExpandedPanel:e=>s(Ee,{addonId:e.addonId,enabled:e.isActive}),trailing:n(g,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),s(C,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:`Refresh`})]}),s(`div`,{className:`p-4`,children:a.length===0?s(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):s(`div`,{className:`flex flex-col gap-3`,children:a.map((e,t)=>{let r=Array.isArray(e.urls)?e.urls:[e.urls];return n(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&n(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,s(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,s(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(e=>s(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function Ee({addonId:e,enabled:t}){let i=k({addonId:e},{enabled:t,retry:!1}),a=r(()=>we(i.data??[]),[i.data]);return!t||a.length===0?null:n(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[n(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,a.length,`)`]}),s(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>s(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}t();var De={lan:G,wifi:z,docker:I,vpn:le,loopback:R,other:R},Oe={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},ke=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Ae(e){let{interfaces:t,disabled:i,hideLoopback:a,ipv4Only:o,emptyMessage:c}=e,l=r(()=>t.filter(e=>!(a&&e.kind===`loopback`||o&&e.family!==`IPv4`)),[t,a,o]),u=r(()=>{let e=new Map;for(let t of l){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return ke.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[l]),d=t=>e.mode===`single`?e.value===t:e.value.includes(t),f=t=>{if(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return l.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic`,children:c??`No addresses available.`}):s(`div`,{className:`flex flex-col gap-3`,children:u.map(({kind:t,items:r})=>n(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[s(De[t]??R,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Oe[t]??t}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=d(t.address),a=t.kind===`loopback`,o=!t.plausible&&!a;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 ${a?`opacity-60 cursor-not-allowed`:i?`opacity-60`:o?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>f(t),children:[s(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&s(me,{className:`h-3 w-3`})}),n(`div`,{className:`flex-1 min-w-0 ${o?`text-foreground-subtle`:``}`,children:[n(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`span`,{className:`font-mono text-xs font-semibold ${o?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),s(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),a&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),o&&n(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[s(W,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),n(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}t();var je={"lan-ipv4":`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,"lan-ipv6":`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`,loopback:`bg-foreground-subtle/15 text-foreground-subtle`};function Me(){let e=a(),t=l(),i=ne(void 0,{refetchInterval:3e4}),u=f(void 0),d=h({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),p=ee({onSuccess:t=>{b(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),m=r(()=>i.data?.interfaces??[],[i.data]),_=te({port:typeof window<`u`?Number(window.location.port)||(window.location.protocol===`https:`?443:80):4e3,scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),[v,b]=o([]),[x,S]=o(!1);c(()=>{!x&&u.data&&(b(u.data.addresses),S(!0))},[u.data,x]);let w=u.data?.addresses??[],T=r(()=>{if(v.length!==w.length)return!0;let e=[...v].toSorted(),t=[...w].toSorted();return e.some((e,n)=>e!==t[n])},[v,w]),E=()=>{d.mutate({addresses:[...v]})},D=()=>{b(w)},O=()=>{b([])},k=()=>{i.refetch(),_.refetch(),u.refetch()},A=async()=>{try{let e=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info(`[network-addresses] race result`,e)}catch(e){console.warn(`[network-addresses] race failed`,e)}},j=re(),M=y({onSuccess:()=>void j.refetch()}),N=_.data?.endpoints??[],P=j.data?.baseUrl??null,F=j.data?.resolved??null;return n(he,{children:[n(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[s(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Pick the local addresses SDK clients should race for the fastest path to this hub. Empty selection (auto) lets every non-loopback / non-link-local interface participate.`}),n(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n(C,{size:`sm`,variant:`secondary`,onClick:k,disabled:i.isLoading,children:[s(ae,{className:`h-3 w-3 ${i.isLoading?`animate-spin`:``}`}),`Refresh`]}),s(C,{size:`sm`,variant:`secondary`,onClick:A,children:`Probe race`})]})]}),n(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[n(g,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:v.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${v.length} pinned`})]}),n(`div`,{className:`flex items-center gap-1`,children:[n(C,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||d.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[s(fe,{className:`h-3 w-3`}),p.isPending?`Detecting…`:`Best match`]}),n(C,{size:`sm`,variant:`secondary`,onClick:O,disabled:v.length===0||d.isPending,children:[s(oe,{className:`h-3 w-3`}),`Clear`]}),T&&s(C,{size:`sm`,variant:`secondary`,onClick:D,disabled:d.isPending,children:`Discard`}),n(C,{size:`sm`,variant:`primary`,onClick:E,disabled:!T||d.isPending,children:[s(ye,{className:`h-3 w-3`}),d.isPending?`Saving…`:`Save`]})]})]}),s(`div`,{className:`p-4`,children:s(Ae,{mode:`multiple`,interfaces:m,value:v,onChange:b,disabled:d.isPending,emptyMessage:i.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),n(g,{children:[n(`div`,{className:`px-4 py-3 border-b border-border`,children:[s(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints — priority order`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`Live preview of the ranked candidate list the SDK would race against. Updates with each Save.`}),n(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2 text-xs`,children:[s(`span`,{className:`text-foreground-subtle`,children:`Notification links use:`}),s(`span`,{className:`font-mono text-foreground`,children:P??`${F??`nothing reachable`} (auto)`}),P!==null&&s(`button`,{type:`button`,disabled:M.isPending,onClick:()=>M.mutate({baseUrl:null}),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:`reset to auto`})]}),P===null&&F===null&&s(`p`,{className:`mt-1 text-[11px] text-amber-600 dark:text-amber-400`,children:`No public address is reachable, so notification media ships as bytes only — a backend that can only take links (WhatsApp, gotify) receives none.`})]}),s(`div`,{className:`p-4`,children:N.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic`,children:_.isLoading?`Loading…`:`No endpoints available.`}):s(`ul`,{className:`space-y-1 text-xs`,children:N.map(e=>n(`li`,{className:`flex items-center gap-2 flex-wrap ${e.plausible?``:`opacity-80`}`,children:[s(`span`,{className:`font-mono text-[10px] w-10 text-foreground-subtle`,children:String(e.priority).padStart(4,`0`)}),s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${je[e.kind]??je.loopback}`,children:e.kind}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&s(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-medium uppercase`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&n(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:e.plausibleReason||void 0,children:[s(W,{className:`h-2.5 w-2.5`}),`Unlikely usable`]}),s(`span`,{className:`font-mono break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),n(`span`,{className:`text-foreground-subtle`,children:[`— `,e.label]}),e.kind===`loopback`?null:P===e.baseUrl?n(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-primary/15 px-2 py-0.5 text-[10px] font-medium text-primary`,children:[s(ue,{className:`h-2.5 w-2.5`}),` notifications`]}):s(`button`,{type:`button`,disabled:M.isPending,onClick:()=>M.mutate({baseUrl:e.baseUrl}),className:`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:`use for notifications`})]},`${e.priority}-${e.baseUrl}`))})})]})]})]})}t();var Ne={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Q=5e3,Pe=3e4,Fe={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Ie(){let e=p({capName:`mesh-network`},{refetchInterval:Q}),t=m(void 0,{refetchInterval:Q}),n=r(()=>q(t.data??[]),[t.data]);return s(K,{title:`Mesh Networks`,subtitle:`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`,pageIcon:I,itemIcon:G,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]),isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`,renderStatusBadges:e=>s(Le,{addonId:e.addonId}),renderPrimaryAction:e=>s(Re,{addonId:e.addonId}),renderExpandedPanel:e=>s(ze,{addonId:e.addonId})})}function $(e){let{data:t,isLoading:n}=E({addonId:e},{refetchInterval:Q,retry:!1}),r=t?F.safeParse(t):null;return{status:r?.success?r.data:Fe,isLoading:n}}function Le({addonId:e}){let{status:t}=$(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.joined?`Joined`:`Not joined`}),t.joined&&n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function Re({addonId:t}){let r=a(),[c,u]=o(!1),[d,f]=o(null),p=l(),{status:m}=$(t),h=e(()=>{r.invalidateQueries({queryKey:[[`meshNetwork`]]})},[r]),g=v(),_=N({onSuccess:h}),y=D({onSuccess:h}),b=e(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await g.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await Ke(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?F.safeParse(e):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,h,g,p]),x=e(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return s(i,{children:m.joined?n(i,{children:[n(C,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:t}),children:[_.isPending?s(B,{className:`h-3 w-3 animate-spin`}):s(pe,{className:`h-3 w-3`}),`Disconnect`]}),n(C,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(B,{className:`h-3 w-3 animate-spin`}):s(J,{className:`h-3 w-3`}),`Log out`]})]}):c?n(C,{size:`sm`,variant:`ghost`,onClick:x,children:[s(de,{className:`h-3 w-3 mr-1`}),` Cancel`]}):n(i,{children:[n(C,{size:`sm`,variant:`primary`,onClick:()=>void b(),children:[s(ve,{className:`h-3 w-3`}),`Connect`]}),n(C,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(B,{className:`h-3 w-3 animate-spin`}):s(J,{className:`h-3 w-3`}),`Log out`]})]})})}function ze({addonId:e}){let{status:t}=$(e),r=d({addonId:e},{refetchInterval:Pe,retry:!1});return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`p-4 space-y-4`,children:[t.error&&s(O,{message:t.error}),s(Be,{status:t}),t.endpoints.length>0&&n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),t.endpoints.map(e=>n(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Ne[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?s(V,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),n(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[s(U,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),s(`div`,{className:`border-t border-border`,children:s(He,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Be({status:e}){return s(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:`Tenant`,value:e.tenantName||`—`},{label:`User`,value:e.userLogin??`—`},{label:`Control plane`,value:e.controlPlaneUrl||`—`},{label:`Mesh IP`,value:e.meshIp||`—`,mono:!0},{label:`MagicDNS`,value:e.magicDnsHostname||`—`,mono:!0},{label:`DNS suffix`,value:e.magicDnsSuffix||`—`,mono:!0},{label:`Peers`,value:String(e.peerCount)},{label:`Key expiry`,value:e.keyExpiry?Ve(e.keyExpiry):`—`}].map(e=>n(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[s(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),s(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Ve(e){let t=e-Date.now();if(t<0)return`Expired ${Ge(e)}`;let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;let r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function He({peers:t,loading:i}){let a=r(()=>t.map(e=>({...e,_id:e.id})),[t]),o=e(e=>{e&&navigator.clipboard?.writeText(e)},[]),c=r(()=>[{key:`hostname`,header:`Hostname`,render:e=>n(`div`,{className:`flex flex-col`,children:[n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&s(b,{variant:`info`,children:`self`}),e.exitNodeOption&&s(b,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&s(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),s(`button`,{onClick:()=>o(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:s(L,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs`,children:t}),s(`button`,{onClick:()=>o(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:s(L,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>n(`div`,{className:`flex items-center gap-1.5`,children:[s(b,{variant:Ue(e.connection),children:e.connection}),e.relay&&s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?s(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>n(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,We(e.txBytes),` · ↓ `,We(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>s(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Ge(e.lastSeenMs):`—`})}],[o]);return i&&t.length===0?n(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[s(B,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):t.length===0?s(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):s(`div`,{className:`p-4`,children:s(A,{columns:c,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function Ue(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function We(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function Ge(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function Ke(e){return new Promise(t=>setTimeout(t,e))}t();function qe(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Je(){let e=a(),t=u(void 0,{refetchInterval:15e3}),r=w({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),i=T({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),c=S({onSuccess:()=>{f(!1),m(``),_(``),y(``),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),l=t.data,[d,f]=o(!1),[p,m]=o(``),[h,_]=o(``),[v,y]=o(``),b=()=>{if(!l?.caCertPem)return;let e=new Blob([l.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},x=l?.mode===`uploaded`?`Uploaded`:l?.mode===`generated`?`Generated local CA`:`TLS disabled`;return n(`div`,{className:`flex flex-col gap-4`,children:[s(_e,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:`LAN HTTP`,description:`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`}),n(g,{className:`p-4 space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(se,{className:`h-4 w-4 text-foreground-subtle`}),s(`h3`,{className:`text-sm font-semibold`,children:`Certificate`})]}),t.isError&&s(`p`,{className:`text-xs text-danger`,children:`Could not read TLS status.`}),l?.reissueError&&s(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:l.reissueError}),l?.restartRequired&&s(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Restart the hub to apply the new certificate.`}),n(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Mode`}),s(`dd`,{className:`font-medium`,children:x})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Valid to`}),s(`dd`,{className:`font-mono`,children:l?.validTo?new Date(l.validTo).toLocaleString():`—`})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Leaf SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.leafFingerprintSha256??void 0,children:qe(l?.leafFingerprintSha256??null)})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`CA SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.caFingerprintSha256??void 0,children:qe(l?.caFingerprintSha256??null)})]})]}),l&&l.sans.length>0&&s(`div`,{className:`flex flex-wrap gap-1`,children:l.sans.map(e=>s(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),n(`div`,{className:`flex flex-wrap gap-2`,children:[s(j,{label:`Regenerate`,title:`Issue a new leaf?`,description:`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`,confirmLabel:`Regenerate`,disabled:l?.mode===`uploaded`||r.isPending,action:()=>r.mutateAsync({})}),s(C,{size:`sm`,variant:`outline`,onClick:()=>f(e=>!e),children:`Upload`}),l?.caCertPem&&s(C,{size:`sm`,variant:`outline`,onClick:b,children:`Download CA`}),l?.mode===`uploaded`&&s(j,{label:`Revert to generated`,title:`Drop the uploaded certificate?`,description:`Deletes the uploaded pair and returns to the generated local CA.`,confirmLabel:`Revert`,confirmVariant:`danger`,disabled:i.isPending,action:()=>i.mutateAsync({})})]}),d&&n(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Certificate PEM`,s(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Private key PEM`,s(`textarea`,{value:h,onChange:e=>_(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`CA PEM (optional)`,s(`textarea`,{value:v,onChange:e=>y(e.target.value),rows:4,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),s(C,{size:`sm`,disabled:!p.trim()||!h.trim()||c.isPending,onClick:()=>c.mutate({certPem:p,keyPem:h,...v.trim()?{caPem:v}:{}}),children:`Save certificate`}),c.isError&&s(`p`,{className:`text-xs text-danger`,children:c.error instanceof Error?c.error.message:`Upload failed`})]})]})]})}function Ye(){return s(`div`,{className:`flex flex-col p-4`,children:s(ge,{defaultTab:`addresses`,tabs:[{id:`local-access`,label:`Local access`,icon:z,content:s(Je,{})},{id:`addresses`,label:`Network Addresses`,icon:R,content:s(Me,{})},{id:`remote-access`,label:`Remote Access`,icon:V,content:s(xe,{})},{id:`mesh`,label:`Mesh Networks`,icon:I,content:s(Ie,{})},{id:`turn`,label:`TURN Servers`,icon:G,content:s(Te,{})}]})})}export{Ye as NetworkPage};
@@ -1 +1 @@
1
- import{H as e,I as t,K as n,Q as r,S as i,W as a,i as o,k as s,o as c,p as l,q as u,t as d,x as f,z as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as m}from"./player-overlays-BGbLKvcn.js";import{En as h,Kn as g,_n as _,mr as v,vn as y}from"./src-Buv5KpAz.js";import{Ft as b}from"./src-CQVcBp6b.js";import{t as x}from"./FormBuilder-ChyOUw_O.js";import{n as ee,r as S,t as te}from"./SchemaTabBar-DC28nb9j.js";import{t as ne}from"./StableTabPanel-Dc954AQl.js";r();var C=s(function({addonId:r,schema:i,serverValues:o,onImmediateSave:s,onStateChange:c,onAction:l,disabled:u},d){let m=S({schema:i,serverValues:o,onImmediateSave:t(e=>s(r,e),[r,s]),onDeferredSave:t(()=>{},[])});e(d,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=a(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=n(c);p(()=>{v.current=c},[c]),p(()=>{let e={};for(let t of h)e[t]=m.values[t];v.current({addonId:r,pendingKeys:h,pendingValues:e})},[r,g,_]);let y=a(()=>{if(l)return(e,t,n)=>l(r,e,t,n)},[r,l]);return f(x,{schema:i,values:m.values,onChange:m.handleChange,disabled:u,onAction:y})});r();function w(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>w(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function T(e,t){return{...e,fields:e.fields.map(e=>w(e,t))}}function re(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>T(e,t))},values:t}}function E({nodeId:e,addonIds:r,level:s,deviceId:p,capability:x,sectionIds:S,sectionTab:C,extraTabs:w,schemaTabExtras:T,title:E,description:D,selfTabbed:ae}){let O=c(),k=m().trpcClient,A=y(),j=_(),M=v(),N=g(),P=ae===!0||!!(w&&w.length>0),[F,oe]=u(null);if(s===`device`&&!p)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let I=e??`hub`,L=o({queries:r.map(e=>({queryKey:[[`addonSettings`,s===`global`?`getGlobalSettings`:`getDeviceSettings`],{addonId:e,nodeId:I,deviceId:p??null,cap:x??null}],queryFn:async()=>s===`global`?{addonId:e,result:await k.addonSettings.getGlobalSettings.query({addonId:e,nodeId:I,...x?{cap:x}:{}})}:{addonId:e,result:await k.addonSettings.getDeviceSettings.query({addonId:e,deviceId:p,nodeId:I})},placeholderData:l}))}),R=L.some(e=>e.isLoading),z=L.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),B=a(()=>{let e=new Set;for(let t of L){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(t.tab??`general`)}return[...e]},[z+`::`+L.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),V=a(()=>new Map((w??[]).map(e=>[e.id,e])),[w]),H=a(()=>{if(!P)return[];let e=[...new Set([...B,...(w??[]).map(e=>e.id),...(T??[]).map(e=>e.tabId)])],t=e=>{let t=V.get(e);if(t?.order!==void 0)return t.order;let n=b[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[P,B,w,V,T]),se=a(()=>{let e=new Map,t=e=>b[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of B)e.set(n,t(n));for(let n of T??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of w??[])e.set(t.id,t.label);return e},[B,w,T]),U=P?F&&H.includes(F)?F:H[0]??null:null,W=U!==null&&V.has(U),G=P?U&&!W?U:void 0:C,{data:K}=h(void 0),ce=a(()=>{let e=new Map;for(let t of K??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[K]),q=n(new Map),J=a(()=>{let e=S?new Set(S):null,t=[];for(let n of L){if(!n.data)continue;let r=n.data.result??q.current.get(n.data.addonId)??null;if(n.data.result!==null&&q.current.set(n.data.addonId,n.data.result),r===null)continue;let{schema:i,values:a}=re(r),o=i.sections.filter(t=>e?e.has(t.id):!0);if(o.length===0)continue;let s={...r,sections:r.sections.filter(t=>e?e.has(t.id):!0)},c={...i,sections:o};t.push({addonId:n.data.addonId,schemaWithValues:s,schema:c,serverValues:a})}return t},[z,S]),[Y,le]=u(new Map),ue=t(e=>{le(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=n(new Map),de=t(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=t(async(e,t)=>{s===`global`?await A.mutateAsync({addonId:e,nodeId:I,patch:t}):await j.mutateAsync({addonId:e,deviceId:p,nodeId:I,patch:t}),O.invalidateQueries({queryKey:[[`addonSettings`]]})},[A,j,I,s,p,O]),fe=t(async(e,t,n,r)=>{let i=I;try{switch(t){case`reprobe-hwaccel`:await M.mutateAsync({nodeId:i}),O.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await N.mutateAsync({nodeId:i}),O.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await k.addons.custom.mutate({addonId:e,action:t,input:r});return O.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[M,N,I,O,k]),pe=t((e,t)=>{Z(e,t)},[Z]),Q=d({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(s===`global`?await A.mutateAsync({addonId:e,nodeId:I,patch:t}):await j.mutateAsync({addonId:e,deviceId:p,nodeId:I,patch:t}),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();O.invalidateQueries({queryKey:[[`addonSettings`]]})}}),me=t(()=>{for(let e of X.current.values())e.discard()},[]),he=a(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),ge=a(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(R)return f(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let $=U&&W?V.get(U):void 0;if(!P&&J.length===0)return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:[`No addons in `,r.length>0?`[${r.join(`, `)}]`:`the current selection`,` `,`expose `,s,`-level settings on this node.`]});let _e=Q.isPending;return i(`div`,{className:`space-y-4`,children:[(E||D)&&i(`div`,{className:`border-b border-border pb-2`,children:[E&&f(`h2`,{className:`text-sm font-semibold text-foreground`,children:E}),D&&f(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:D})]}),P&&f(te,{tabs:H.map(e=>({id:e,label:se.get(e)??e})),activeId:U,onChange:oe,pendingByTab:ge}),Q.isError&&i(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed: `,String(Q.error?.message??Q.error)]}),f(ne,{tabKey:$?`extra:${U??``}`:`tab:${U??``}`,children:$?$.content:(()=>{let e=G?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===G).length,0):0,t=G!==null&&e<=1,n=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>G?(e.tab??`general`)===G:!0).map(e=>t?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),r=(T??[]).filter(e=>e.tabId===G),a=r.filter(e=>(e.placement??`before`)===`before`),o=r.filter(e=>e.placement===`after`);return n.length===0&&r.length===0?f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:`Nothing to configure here for this node.`}):i(`div`,{className:`space-y-6`,children:[a.map((e,t)=>f(`div`,{children:e.content},`extra-before-${t}`)),n.length>0&&f(ie,{entries:n,paneStates:Y,displayNames:ce,disabled:_e,setPaneRef:de,onPaneStateChange:ue,onImmediateSave:pe,onAction:fe,inline:P||!!C}),o.map((e,t)=>f(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!R&&f(ee,{pendingCount:he,onSave:()=>Q.mutate(),onDiscard:me,saving:_e})]})}function ie({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:o,onPaneStateChange:s,onImmediateSave:c,onAction:l,inline:d}){let m=a(()=>[...e].toSorted((e,t)=>{if(e.addonId===`system-config`)return-1;if(t.addonId===`system-config`)return 1;let r=n.get(e.addonId)??e.addonId,i=n.get(t.addonId)??t.addonId;return r.localeCompare(i)}),[e,n]),[h,g]=u(m[0]?.addonId??``);p(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=a(()=>l?(e,t,n,r)=>l(e,t,n,r):void 0,[l]),y=e=>f(C,{ref:o(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:c,onStateChange:s,onAction:v,disabled:r},e.addonId);return m.length===1||d?f(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):i(`div`,{className:`flex flex-col gap-3`,children:[f(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(e=>{let r=n.get(e.addonId)??e.addonId,a=e.addonId===_.addonId,o=(t.get(e.addonId)?.pendingKeys.length??0)>0;return i(`button`,{type:`button`,onClick:()=>g(e.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[r,o&&f(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},e.addonId)})}),f(`div`,{className:`space-y-2`,children:m.map(e=>f(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{E as t};
1
+ import{H as e,I as t,K as n,Q as r,S as i,W as a,i as o,k as s,o as c,p as l,q as u,t as d,x as f,z as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as m}from"./player-overlays-CBKaIBph.js";import{En as h,Kn as g,_n as _,mr as v,vn as y}from"./src-BLHY9yig.js";import{It as b}from"./src-0pbBUmTo.js";import{t as x}from"./FormBuilder-QY4tah4S.js";import{n as ee,r as S,t as te}from"./SchemaTabBar-DC28nb9j.js";import{t as ne}from"./StableTabPanel-Dc954AQl.js";r();var C=s(function({addonId:r,schema:i,serverValues:o,onImmediateSave:s,onStateChange:c,onAction:l,disabled:u},d){let m=S({schema:i,serverValues:o,onImmediateSave:t(e=>s(r,e),[r,s]),onDeferredSave:t(()=>{},[])});e(d,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=a(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=n(c);p(()=>{v.current=c},[c]),p(()=>{let e={};for(let t of h)e[t]=m.values[t];v.current({addonId:r,pendingKeys:h,pendingValues:e})},[r,g,_]);let y=a(()=>{if(l)return(e,t,n)=>l(r,e,t,n)},[r,l]);return f(x,{schema:i,values:m.values,onChange:m.handleChange,disabled:u,onAction:y})});r();function w(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>w(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function T(e,t){return{...e,fields:e.fields.map(e=>w(e,t))}}function re(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>T(e,t))},values:t}}function E({nodeId:e,addonIds:r,level:s,deviceId:p,capability:x,sectionIds:S,sectionTab:C,extraTabs:w,schemaTabExtras:T,title:E,description:D,selfTabbed:ae}){let O=c(),k=m().trpcClient,A=y(),j=_(),M=v(),N=g(),P=ae===!0||!!(w&&w.length>0),[F,oe]=u(null);if(s===`device`&&!p)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let I=e??`hub`,L=o({queries:r.map(e=>({queryKey:[[`addonSettings`,s===`global`?`getGlobalSettings`:`getDeviceSettings`],{addonId:e,nodeId:I,deviceId:p??null,cap:x??null}],queryFn:async()=>s===`global`?{addonId:e,result:await k.addonSettings.getGlobalSettings.query({addonId:e,nodeId:I,...x?{cap:x}:{}})}:{addonId:e,result:await k.addonSettings.getDeviceSettings.query({addonId:e,deviceId:p,nodeId:I})},placeholderData:l}))}),R=L.some(e=>e.isLoading),z=L.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),B=a(()=>{let e=new Set;for(let t of L){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(t.tab??`general`)}return[...e]},[z+`::`+L.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),V=a(()=>new Map((w??[]).map(e=>[e.id,e])),[w]),H=a(()=>{if(!P)return[];let e=[...new Set([...B,...(w??[]).map(e=>e.id),...(T??[]).map(e=>e.tabId)])],t=e=>{let t=V.get(e);if(t?.order!==void 0)return t.order;let n=b[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[P,B,w,V,T]),se=a(()=>{let e=new Map,t=e=>b[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of B)e.set(n,t(n));for(let n of T??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of w??[])e.set(t.id,t.label);return e},[B,w,T]),U=P?F&&H.includes(F)?F:H[0]??null:null,W=U!==null&&V.has(U),G=P?U&&!W?U:void 0:C,{data:K}=h(void 0),ce=a(()=>{let e=new Map;for(let t of K??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[K]),q=n(new Map),J=a(()=>{let e=S?new Set(S):null,t=[];for(let n of L){if(!n.data)continue;let r=n.data.result??q.current.get(n.data.addonId)??null;if(n.data.result!==null&&q.current.set(n.data.addonId,n.data.result),r===null)continue;let{schema:i,values:a}=re(r),o=i.sections.filter(t=>e?e.has(t.id):!0);if(o.length===0)continue;let s={...r,sections:r.sections.filter(t=>e?e.has(t.id):!0)},c={...i,sections:o};t.push({addonId:n.data.addonId,schemaWithValues:s,schema:c,serverValues:a})}return t},[z,S]),[Y,le]=u(new Map),ue=t(e=>{le(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=n(new Map),de=t(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=t(async(e,t)=>{s===`global`?await A.mutateAsync({addonId:e,nodeId:I,patch:t}):await j.mutateAsync({addonId:e,deviceId:p,nodeId:I,patch:t}),O.invalidateQueries({queryKey:[[`addonSettings`]]})},[A,j,I,s,p,O]),fe=t(async(e,t,n,r)=>{let i=I;try{switch(t){case`reprobe-hwaccel`:await M.mutateAsync({nodeId:i}),O.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await N.mutateAsync({nodeId:i}),O.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await k.addons.custom.mutate({addonId:e,action:t,input:r});return O.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[M,N,I,O,k]),pe=t((e,t)=>{Z(e,t)},[Z]),Q=d({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(s===`global`?await A.mutateAsync({addonId:e,nodeId:I,patch:t}):await j.mutateAsync({addonId:e,deviceId:p,nodeId:I,patch:t}),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();O.invalidateQueries({queryKey:[[`addonSettings`]]})}}),me=t(()=>{for(let e of X.current.values())e.discard()},[]),he=a(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),ge=a(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(R)return f(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let $=U&&W?V.get(U):void 0;if(!P&&J.length===0)return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:[`No addons in `,r.length>0?`[${r.join(`, `)}]`:`the current selection`,` `,`expose `,s,`-level settings on this node.`]});let _e=Q.isPending;return i(`div`,{className:`space-y-4`,children:[(E||D)&&i(`div`,{className:`border-b border-border pb-2`,children:[E&&f(`h2`,{className:`text-sm font-semibold text-foreground`,children:E}),D&&f(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:D})]}),P&&f(te,{tabs:H.map(e=>({id:e,label:se.get(e)??e})),activeId:U,onChange:oe,pendingByTab:ge}),Q.isError&&i(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed: `,String(Q.error?.message??Q.error)]}),f(ne,{tabKey:$?`extra:${U??``}`:`tab:${U??``}`,children:$?$.content:(()=>{let e=G?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===G).length,0):0,t=G!==null&&e<=1,n=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>G?(e.tab??`general`)===G:!0).map(e=>t?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),r=(T??[]).filter(e=>e.tabId===G),a=r.filter(e=>(e.placement??`before`)===`before`),o=r.filter(e=>e.placement===`after`);return n.length===0&&r.length===0?f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:`Nothing to configure here for this node.`}):i(`div`,{className:`space-y-6`,children:[a.map((e,t)=>f(`div`,{children:e.content},`extra-before-${t}`)),n.length>0&&f(ie,{entries:n,paneStates:Y,displayNames:ce,disabled:_e,setPaneRef:de,onPaneStateChange:ue,onImmediateSave:pe,onAction:fe,inline:P||!!C}),o.map((e,t)=>f(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!R&&f(ee,{pendingCount:he,onSave:()=>Q.mutate(),onDiscard:me,saving:_e})]})}function ie({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:o,onPaneStateChange:s,onImmediateSave:c,onAction:l,inline:d}){let m=a(()=>[...e].toSorted((e,t)=>{if(e.addonId===`system-config`)return-1;if(t.addonId===`system-config`)return 1;let r=n.get(e.addonId)??e.addonId,i=n.get(t.addonId)??t.addonId;return r.localeCompare(i)}),[e,n]),[h,g]=u(m[0]?.addonId??``);p(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=a(()=>l?(e,t,n,r)=>l(e,t,n,r):void 0,[l]),y=e=>f(C,{ref:o(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:c,onStateChange:s,onAction:v,disabled:r},e.addonId);return m.length===1||d?f(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):i(`div`,{className:`flex flex-col gap-3`,children:[f(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(e=>{let r=n.get(e.addonId)??e.addonId,a=e.addonId===_.addonId,o=(t.get(e.addonId)?.pendingKeys.length??0)>0;return i(`button`,{type:`button`,onClick:()=>g(e.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[r,o&&f(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},e.addonId)})}),f(`div`,{className:`space-y-2`,children:m.map(e=>f(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{E as t};
@@ -1 +1 @@
1
- import{K as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Br as l,Ir as u,It as d,Pr as f,Qa as p,jt as m,za as h}from"./src-Buv5KpAz.js";import{t as g}from"./zap-aTn3GS-l.js";import{I as _,K as v,N as y,S as b,a as x}from"./index-vZPXzSPK.js";var S=v(`circuit-board`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M11 9h4a2 2 0 0 0 2-2V3`,key:`1ve2rv`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`M7 21v-4a2 2 0 0 1 2-2h4`,key:`1fwkro`}],[`circle`,{cx:`15`,cy:`15`,r:`2`,key:`3i40o0`}]]),C=v(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),w=v(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),T=v(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),E=v(`scale`,[[`path`,{d:`m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`7g6ntu`}],[`path`,{d:`m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`ijws7r`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2`,key:`3gwbw2`}]]),D=v(`usb`,[[`circle`,{cx:`10`,cy:`7`,r:`1`,key:`dypaad`}],[`circle`,{cx:`4`,cy:`20`,r:`1`,key:`22iqad`}],[`path`,{d:`M4.7 19.3 19 5`,key:`1enqfc`}],[`path`,{d:`m21 3-3 1 2 2Z`,key:`d3ov82`}],[`path`,{d:`M9.26 7.68 5 12l2 5`,key:`1esawj`}],[`path`,{d:`m10 14 5 2 3.5-3.5`,key:`v8oal5`}],[`path`,{d:`m18 12 1-1 1 1-1 1Z`,key:`1bh22v`}]]);t();function O(e){return l({addonId:e})}function k(e){return u({deviceId:e},{enabled:Number.isFinite(e)})}var A=3e4,j=2e3;function M(t){let n=e(0);return n.current===0&&(n.current=Date.now()),f({parentDeviceId:t},{enabled:Number.isFinite(t),staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-n.current>=A?!1:j}})}function N(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function P(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function F(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}t();function I(e,t,n){return Math.min(Math.max(e,t),n)}function L(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function R(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:I(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function z(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function B({nodes:e,pending:t,onCommitWeights:r,weightLabel:a=`Detection weight`,emptyHint:l,footnote:u}){let[d,f]=o(()=>L(e)),[p,m]=o(new Set);c(()=>{f(L(e)),m(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let h=e.map(e=>e.id),g=e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=(e,t)=>{f(n=>R(n,e,t,p,h))},v=()=>{let t=z(d,h,p),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...p]);r(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:l??`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`});let y=e.length===1;return n(`div`,{className:`space-y-3`,children:[e.map(e=>{let r=d[e.id]??0,i=p.has(e.id);return n(`div`,{className:`flex items-center gap-3`,children:[s(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),s(`input`,{"aria-label":`${a} for ${e.name}`,type:`range`,min:0,max:100,step:1,value:Math.round(r),disabled:t||i||y,onChange:t=>_(e.id,Number(t.target.value)),onPointerUp:()=>v(),onKeyUp:()=>v(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),s(`button`,{type:`button`,onClick:()=>g(e.id),disabled:t||y,"aria-pressed":i,title:i?`Unlock — allow rebalancing`:`Lock this share when others change`,className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${i?`text-amber-400`:`text-foreground-subtle`}`,children:s(i?b:w,{className:`h-3.5 w-3.5`})})]},e.id)}),s(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:u??s(i,{children:`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`})})]})}t();function V(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?{label:`CPU`,Icon:y,hue:`slate`}:t===`openvino`&&n===`npu`?{label:`Intel NPU (AI Boost)`,Icon:g,hue:`sky`}:t===`openvino`&&(n===`gpu`||n===`igpu`)?{label:`Intel iGPU`,Icon:S,hue:`violet`}:t===`edgetpu`?{label:`Coral Edge TPU`,Icon:D,hue:`emerald`}:{label:`${e.backend} ${e.device}`.replace(/\b\w/g,e=>e.toUpperCase()).trim(),Icon:y,hue:`slate`}}var H={sky:`bg-sky-500/12 text-sky-400 ring-sky-500/25`,violet:`bg-violet-500/12 text-violet-400 ring-violet-500/25`,emerald:`bg-emerald-500/12 text-emerald-400 ring-emerald-500/25`,slate:`bg-surface-hover text-foreground-subtle ring-border`};function U({nodeId:e,nodeName:t,isOnline:l}){let u=a(),{data:f,isLoading:g}=h({nodeId:e},{refetchInterval:15e3}),v=p({onSettled:()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),y=f?.devices??[],b=f?.reachable??l,[S,w]=o({});c(()=>{w(Object.fromEntries(y.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[y.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let T=r(()=>y.filter(e=>S[e.key]?.enabled??e.enabled).length,[y,S]),[D,O]=o(null),k=D??T>0,A=t=>{let n=y.map(e=>{let n=t[e.key]??j(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});v.mutate({agentNodeId:e,inferenceDevices:F(n)})},j=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),M=e=>{if(!e.available)return;let t=S[e.key]??j(e),n={...S,[e.key]:{...t,enabled:!t.enabled}};w(n),A(n)},N=(e,t)=>{let n=S[e.key]??j(e),r={...S,[e.key]:{...n,maxSessions:t}};w(r),A(r)},P=r(()=>y.filter(e=>(S[e.key]?.enabled??e.enabled)&&e.available),[y,S]),I=r(()=>P.map(e=>({id:e.key,name:V(e).label,weight:S[e.key]?.weight??e.weight})),[P,S]);return n(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[n(`button`,{type:`button`,onClick:()=>O(!k),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":k,children:[s(_,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${k?`rotate-90`:``}`}),s(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t}),s(`span`,{className:`ml-auto flex items-center gap-2 text-[11px]`,children:b?T>=2?n(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[s(C,{className:`h-3.5 w-3.5`}),T,` accelerators`]}):T===1?s(`span`,{className:`text-foreground-subtle`,children:`single default`}):s(`span`,{className:`text-foreground-subtle/70`,children:`auto default`}):n(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[s(x,{className:`h-3.5 w-3.5`}),` unreachable`]})})]}),k&&n(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[b?g&&y.length===0?s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`Probing accelerators…`}):y.length===0?s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`}):s(`ul`,{className:`space-y-2`,children:y.map(e=>{let t=V(e),r=S[e.key]??j(e),a=r.enabled&&e.available;return n(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?a?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[s(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${H[t.hue]}`,children:s(t.Icon,{className:`h-4.5 w-4.5`})}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),s(d,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&s(d,{variant:`warning`,className:`text-[9px]`,children:`unavailable`})]}),n(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[s(`span`,{className:`font-mono`,children:e.key}),!a&&n(i,{children:[s(`span`,{"aria-hidden":!0,children:`·`}),n(`span`,{children:[`default model`,` `,s(`span`,{className:`font-mono text-foreground/80`,children:e.defaultModelId})]})]})]})]}),a&&n(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[s(`span`,{className:`hidden @sm/clustertab:inline`,children:`cap`}),s(`input`,{type:`number`,min:1,placeholder:`∞`,value:r.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);N(e,r!=null&&r>0?r:null)},disabled:v.isPending,"aria-label":`Max concurrent sessions for ${t.label}`,className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),s(m,{checked:a,onCheckedChange:()=>M(e),disabled:!e.available||v.isPending,"aria-label":`Enable ${t.label}`,className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):s(W,{}),b&&P.length>=2&&n(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[n(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[s(E,{className:`h-3.5 w-3.5`}),`Balancer weight`]}),s(B,{nodes:I,pending:v.isPending,onCommitWeights:e=>{let t={...S};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}w(t),A(t)},weightLabel:`Balancer weight`,footnote:s(i,{children:`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`})})]}),v.isError&&n(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[`Failed to save inference devices:`,` `,v.error instanceof Error?v.error.message:`unknown error`]})]})]})}function W(){return n(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[s(x,{className:`h-6 w-6 text-foreground-subtle/60`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:`Node unreachable`}),s(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`})]})}export{P as a,M as c,C as d,F as i,O as l,V as n,N as o,B as r,k as s,U as t,T as u};
1
+ import{K as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Br as l,Ir as u,It as d,Pr as f,Ua as p,jt as m,no as h}from"./src-BLHY9yig.js";import{t as g}from"./zap-BiojyRpM.js";import{I as _,K as v,N as y,S as b,a as x}from"./index-LPwis6Rq.js";var S=v(`circuit-board`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M11 9h4a2 2 0 0 0 2-2V3`,key:`1ve2rv`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`M7 21v-4a2 2 0 0 1 2-2h4`,key:`1fwkro`}],[`circle`,{cx:`15`,cy:`15`,r:`2`,key:`3i40o0`}]]),C=v(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),w=v(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),T=v(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),E=v(`scale`,[[`path`,{d:`m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`7g6ntu`}],[`path`,{d:`m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`ijws7r`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2`,key:`3gwbw2`}]]),D=v(`usb`,[[`circle`,{cx:`10`,cy:`7`,r:`1`,key:`dypaad`}],[`circle`,{cx:`4`,cy:`20`,r:`1`,key:`22iqad`}],[`path`,{d:`M4.7 19.3 19 5`,key:`1enqfc`}],[`path`,{d:`m21 3-3 1 2 2Z`,key:`d3ov82`}],[`path`,{d:`M9.26 7.68 5 12l2 5`,key:`1esawj`}],[`path`,{d:`m10 14 5 2 3.5-3.5`,key:`v8oal5`}],[`path`,{d:`m18 12 1-1 1 1-1 1Z`,key:`1bh22v`}]]);t();function O(e){return l({addonId:e})}function k(e){return u({deviceId:e},{enabled:Number.isFinite(e)})}var A=3e4,j=2e3;function M(t){let n=e(0);return n.current===0&&(n.current=Date.now()),f({parentDeviceId:t},{enabled:Number.isFinite(t),staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-n.current>=A?!1:j}})}function N(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function P(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function F(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}t();function I(e,t,n){return Math.min(Math.max(e,t),n)}function L(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function R(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:I(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function z(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function B({nodes:e,pending:t,onCommitWeights:r,weightLabel:a=`Detection weight`,emptyHint:l,footnote:u}){let[d,f]=o(()=>L(e)),[p,m]=o(new Set);c(()=>{f(L(e)),m(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let h=e.map(e=>e.id),g=e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=(e,t)=>{f(n=>R(n,e,t,p,h))},v=()=>{let t=z(d,h,p),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...p]);r(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:l??`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`});let y=e.length===1;return n(`div`,{className:`space-y-3`,children:[e.map(e=>{let r=d[e.id]??0,i=p.has(e.id);return n(`div`,{className:`flex items-center gap-3`,children:[s(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),s(`input`,{"aria-label":`${a} for ${e.name}`,type:`range`,min:0,max:100,step:1,value:Math.round(r),disabled:t||i||y,onChange:t=>_(e.id,Number(t.target.value)),onPointerUp:()=>v(),onKeyUp:()=>v(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),s(`button`,{type:`button`,onClick:()=>g(e.id),disabled:t||y,"aria-pressed":i,title:i?`Unlock — allow rebalancing`:`Lock this share when others change`,className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${i?`text-amber-400`:`text-foreground-subtle`}`,children:s(i?b:w,{className:`h-3.5 w-3.5`})})]},e.id)}),s(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:u??s(i,{children:`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`})})]})}t();function V(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?{label:`CPU`,Icon:y,hue:`slate`}:t===`openvino`&&n===`npu`?{label:`Intel NPU (AI Boost)`,Icon:g,hue:`sky`}:t===`openvino`&&(n===`gpu`||n===`igpu`)?{label:`Intel iGPU`,Icon:S,hue:`violet`}:t===`edgetpu`?{label:`Coral Edge TPU`,Icon:D,hue:`emerald`}:{label:`${e.backend} ${e.device}`.replace(/\b\w/g,e=>e.toUpperCase()).trim(),Icon:y,hue:`slate`}}var H={sky:`bg-sky-500/12 text-sky-400 ring-sky-500/25`,violet:`bg-violet-500/12 text-violet-400 ring-violet-500/25`,emerald:`bg-emerald-500/12 text-emerald-400 ring-emerald-500/25`,slate:`bg-surface-hover text-foreground-subtle ring-border`};function U({nodeId:e,nodeName:t,isOnline:l}){let u=a(),{data:f,isLoading:g}=p({nodeId:e},{refetchInterval:15e3}),v=h({onSettled:()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),y=f?.devices??[],b=f?.reachable??l,[S,w]=o({});c(()=>{w(Object.fromEntries(y.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[y.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let T=r(()=>y.filter(e=>S[e.key]?.enabled??e.enabled).length,[y,S]),[D,O]=o(null),k=D??T>0,A=t=>{let n=y.map(e=>{let n=t[e.key]??j(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});v.mutate({agentNodeId:e,inferenceDevices:F(n)})},j=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),M=e=>{if(!e.available)return;let t=S[e.key]??j(e),n={...S,[e.key]:{...t,enabled:!t.enabled}};w(n),A(n)},N=(e,t)=>{let n=S[e.key]??j(e),r={...S,[e.key]:{...n,maxSessions:t}};w(r),A(r)},P=r(()=>y.filter(e=>(S[e.key]?.enabled??e.enabled)&&e.available),[y,S]),I=r(()=>P.map(e=>({id:e.key,name:V(e).label,weight:S[e.key]?.weight??e.weight})),[P,S]);return n(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[n(`button`,{type:`button`,onClick:()=>O(!k),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":k,children:[s(_,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${k?`rotate-90`:``}`}),s(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t}),s(`span`,{className:`ml-auto flex items-center gap-2 text-[11px]`,children:b?T>=2?n(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[s(C,{className:`h-3.5 w-3.5`}),T,` accelerators`]}):T===1?s(`span`,{className:`text-foreground-subtle`,children:`single default`}):s(`span`,{className:`text-foreground-subtle/70`,children:`auto default`}):n(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[s(x,{className:`h-3.5 w-3.5`}),` unreachable`]})})]}),k&&n(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[b?g&&y.length===0?s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`Probing accelerators…`}):y.length===0?s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`}):s(`ul`,{className:`space-y-2`,children:y.map(e=>{let t=V(e),r=S[e.key]??j(e),a=r.enabled&&e.available;return n(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?a?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[s(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${H[t.hue]}`,children:s(t.Icon,{className:`h-4.5 w-4.5`})}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),s(d,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&s(d,{variant:`warning`,className:`text-[9px]`,children:`unavailable`})]}),n(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[s(`span`,{className:`font-mono`,children:e.key}),!a&&n(i,{children:[s(`span`,{"aria-hidden":!0,children:`·`}),n(`span`,{children:[`default model`,` `,s(`span`,{className:`font-mono text-foreground/80`,children:e.defaultModelId})]})]})]})]}),a&&n(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[s(`span`,{className:`hidden @sm/clustertab:inline`,children:`cap`}),s(`input`,{type:`number`,min:1,placeholder:`∞`,value:r.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);N(e,r!=null&&r>0?r:null)},disabled:v.isPending,"aria-label":`Max concurrent sessions for ${t.label}`,className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),s(m,{checked:a,onCheckedChange:()=>M(e),disabled:!e.available||v.isPending,"aria-label":`Enable ${t.label}`,className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):s(W,{}),b&&P.length>=2&&n(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[n(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[s(E,{className:`h-3.5 w-3.5`}),`Balancer weight`]}),s(B,{nodes:I,pending:v.isPending,onCommitWeights:e=>{let t={...S};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}w(t),A(t)},weightLabel:`Balancer weight`,footnote:s(i,{children:`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`})})]}),v.isError&&n(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[`Failed to save inference devices:`,` `,v.error instanceof Error?v.error.message:`unknown error`]})]})]})}function W(){return n(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[s(x,{className:`h-6 w-6 text-foreground-subtle/60`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:`Node unreachable`}),s(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`})]})}export{P as a,M as c,C as d,F as i,O as l,V as n,N as o,B as r,k as s,U as t,T as u};