@camstack/addon-admin-ui 1.2.702 → 1.2.704
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -2
- package/dist/assets/{AccessSection-CNgvvC6Q.js → AccessSection-Bbp4vCnK.js} +1 -1
- package/dist/assets/Addons-BfskS1ar.js +5 -0
- package/dist/assets/{AdminPage-BkxgjFWW.js → AdminPage-Dyd6hYl8.js} +1 -1
- package/dist/assets/{AdminSectionedPage-bGVBepbw.js → AdminSectionedPage-DvahmWYI.js} +1 -1
- package/dist/assets/AiProfiles-Di4CMSTf.js +3 -0
- package/dist/assets/Archive-B10-SsQm.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-jBRoUiPn.js → BootstrapSettingsForm-Cm4-eDgP.js} +1 -1
- package/dist/assets/Build-CG3kxG-Q.js +40 -0
- package/dist/assets/{Calendars-BBTnm6OG.js → Calendars-BDDqqhdh.js} +1 -1
- package/dist/assets/Cluster-BQ_N__Tz.js +1 -0
- package/dist/assets/CompositionBlockEditor-CAYxLM7D.js +2 -0
- package/dist/assets/{CompositionEditorPage-C5pNxu2M.js → CompositionEditorPage-DX3tmg77.js} +1 -1
- package/dist/assets/Data-DdKvcS20.js +2 -0
- package/dist/assets/DeviceDetail-DHBkE6sd.js +1 -0
- package/dist/assets/{Devices-BJRvDHiT.js → Devices-BzdO_WfX.js} +1 -1
- package/dist/assets/EmbedDevicePage-Cyos8BBm.js +1 -0
- package/dist/assets/{EmbedPlayerPage-BsxSpEcY.js → EmbedPlayerPage-Cl2Qja7R.js} +1 -1
- package/dist/assets/History-CDCxEudX.js +1 -0
- package/dist/assets/Identity-C-NUjzGa.js +1 -0
- package/dist/assets/InstancesTable-CLf8XbQo.js +1 -0
- package/dist/assets/IntegrationDetail-BLtGoHv4.js +1 -0
- package/dist/assets/{Integrations-Dpb2V2yu.js → Integrations-D0p7b6sg.js} +1 -1
- package/dist/assets/{Integrations-BUOpFqfh.js → Integrations-DKh9soI8.js} +2 -2
- package/dist/assets/Library-C5NOjKCt.js +1 -0
- package/dist/assets/Locations-CIm3Q3i3.js +3 -0
- package/dist/assets/{Logs-CUV00qxb.js → Logs-BdYjeDAx.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-D57fCIme.js → MaskShapeCanvas-drW0ZeaQ.js} +1 -1
- package/dist/assets/{MotionZonesSettings-w1kFM_O4.js → MotionZonesSettings-VF9WJZWR.js} +1 -1
- package/dist/assets/{MyAccess-D87gqxHt.js → MyAccess-bBE9o8UP.js} +1 -1
- package/dist/assets/{Network-L7e5c9RP.js → Network-CgYpqnsc.js} +1 -1
- package/dist/assets/{NewExportModal-CHwUJ26P.js → NewExportModal-CsSL-XDz.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-DNmMoeS5.js +1 -0
- package/dist/assets/Notifications-CAl9PqU3.js +1 -0
- package/dist/assets/{PanelContent-PhbemYUY.js → PanelContent-Cg1LPl_m.js} +2 -2
- package/dist/assets/Pipeline-ffZklufq.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-BS29zGkX.js → PrivacyMaskSettings-D-43rQlu.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CosxkmPM.js → SceneMonitorEditor-CIMZOhg6.js} +1 -1
- package/dist/assets/SessionsList-BPJsMXCC.js +2 -0
- package/dist/assets/{Showroom-0iJ0CCe5.js → Showroom-DrnOtUc4.js} +1 -1
- package/dist/assets/StorageLocationsTable-CBvJJKcK.js +1 -0
- package/dist/assets/System-CiNhZGIk.js +2 -0
- package/dist/assets/TemplateEditorDialog-CPEjtVgr.js +1 -0
- package/dist/assets/{Terminal-Cvw2rPrb.js → Terminal-CVqdDb0A.js} +4 -4
- package/dist/assets/{TrainingProviders-DcThiLnE.js → TrainingProviders-dcBFMHwS.js} +1 -1
- package/dist/assets/{Viewer-BUfnqb0c.js → Viewer-D5ct12iH.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CNNET8uz.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DO_LtV7q.js} +1 -1
- package/dist/assets/{action-draft-BTVZLATm.js → action-draft-C0aEYbbJ.js} +1 -1
- package/dist/assets/{ai-page.helpers-qxf7BP-v.js → ai-page.helpers-5EBfVv-0.js} +1 -1
- package/dist/assets/{assignment-candidates-d-6NU8po.js → assignment-candidates-Cu7cpUBu.js} +1 -1
- package/dist/assets/{authed-media-Bqh0pB9D.js → authed-media-CU1WIjD1.js} +1 -1
- package/dist/assets/{board-model-CPA2IZpg.js → board-model-Cwi5O7EF.js} +1 -1
- package/dist/assets/{camera-block-model-CJ0e2m0o.js → camera-block-model-Dll1DsHk.js} +1 -1
- package/dist/assets/client-BDuXx1QP.js +1122 -0
- package/dist/assets/{command-vocab-BzBhzE7i.js → command-vocab-BvTOW30-.js} +1 -1
- package/dist/assets/{device-integration-icon-VMxiVsqd.js → device-integration-icon-DyN7a2xu.js} +1 -1
- package/dist/assets/device-picker-model-CB3W-Dnv.js +1 -0
- package/dist/assets/{dist-D7Gew3v3.js → dist-UoOeKkgf.js} +1 -1
- package/dist/assets/dist-i_V6azZ-.js +1122 -0
- package/dist/assets/{format-BopmTOzZ.js → format-BkE2SPtY.js} +1 -1
- package/dist/assets/{hostInit-DuH1KOuD.js → hostInit-Bl-sNtRa.js} +1 -1
- package/dist/assets/i18n-CjRpxC0U.js +1 -0
- package/dist/assets/{icons-bi-mcO5N.js → icons-BLYFUXaZ.js} +1 -1
- package/dist/assets/{index-4KLN9ueQ.css → index-BHfNOQzs.css} +1 -1
- package/dist/assets/index-Dx4xn5Ud.js +6 -0
- package/dist/assets/{linked-devices-model-Bnz1douR.js → linked-devices-model-BheLRl2H.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ddbe056c.js → mf-entry-bootstrap-0-4f6c0152.js} +2 -2
- package/dist/assets/mount-CB3W-Dnv.js +1 -0
- package/dist/assets/{notification-rule-status-ai5zWyzt.js → notification-rule-status-CqF6M-em.js} +1 -1
- package/dist/assets/{player-overlays-fpbPSPqT.js → player-overlays-BKR7fWEx.js} +1 -1
- package/dist/assets/remoteEntry-DDpSLsem.js +1 -0
- package/dist/assets/src-BnZKlAAn.js +279 -0
- package/dist/assets/{sso-popup-Za4GwQBP.js → sso-popup-CZ9VM6-3.js} +1 -1
- package/dist/assets/{step-inspector-model-BAgxIyNV.js → step-inspector-model-42AP-SPE.js} +1 -1
- package/dist/assets/{use-scenes-feed-BTNdL7JV.js → use-scenes-feed-Ch3TUt2m.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-COlTnaF7.js → useAdminDeviceRemoval-CJytKQAy.js} +1 -1
- package/dist/assets/useEventInvalidation-CB3W-Dnv.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DhtJZEtx.js → useNodeUrlSelection-D6xWhfvx.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-R-1W8c6C.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-QyglrCCc.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +157 -19
- package/package.json +2 -2
- package/dist/assets/Addons-Dtx3xcZ2.js +0 -5
- package/dist/assets/AiProfiles-BLj-ic5N.js +0 -3
- package/dist/assets/Archive-y1aPYCx8.js +0 -1
- package/dist/assets/Build-BoiB-nPA.js +0 -40
- package/dist/assets/Cluster-DN0Cwciw.js +0 -1
- package/dist/assets/CompositionBlockEditor-BloGManS.js +0 -2
- package/dist/assets/Data-LT-PQ05n.js +0 -2
- package/dist/assets/DeviceDetail-DAvmtNN2.js +0 -1
- package/dist/assets/EmbedDevicePage-CyKS-rmB.js +0 -1
- package/dist/assets/History-BPF9alct.js +0 -1
- package/dist/assets/Identity-dLFVHYZR.js +0 -1
- package/dist/assets/InstancesTable-LVQWfz07.js +0 -1
- package/dist/assets/IntegrationDetail-C_vN9X7q.js +0 -1
- package/dist/assets/Library-D4-BDy54.js +0 -1
- package/dist/assets/Locations-DGZ_lrp3.js +0 -3
- package/dist/assets/NodeAddonsSettingsPanel-Kqe8X8RH.js +0 -1
- package/dist/assets/Notifications-CucZNxjj.js +0 -1
- package/dist/assets/Pipeline-9O3YfaWk.js +0 -1
- package/dist/assets/SessionsList-OHo3GJ72.js +0 -2
- package/dist/assets/StorageLocationsTable-DqTWO4k1.js +0 -1
- package/dist/assets/System-DZXA2QSs.js +0 -2
- package/dist/assets/TemplateEditorDialog-8D78AUfO.js +0 -1
- package/dist/assets/client-Cng2SeYA.js +0 -1122
- package/dist/assets/device-detail-Cg2Zt8FL.js +0 -1
- package/dist/assets/device-picker-model-B-FI9413.js +0 -1
- package/dist/assets/dist-CxrdebAP.js +0 -1122
- package/dist/assets/i18n--GTAj4mB.js +0 -1
- package/dist/assets/index-DbXFHmBJ.js +0 -6
- package/dist/assets/mount-B-FI9413.js +0 -1
- package/dist/assets/remoteEntry-g0NfB_lk.js +0 -1
- package/dist/assets/src-eL0OacoB.js +0 -279
- package/dist/assets/useEventInvalidation-B-FI9413.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as l,G as u,J as d,Jn as f,K as p,Ln as m,Q as h,Qa as g,U as _,Xr as v,c as ee,ct as y,d as te,f as b,fa as x,ft as S,l as C,oo as w,p as T,ro as E,s as D,tn as O,yt as k,z as A}from"./player-overlays-fpbPSPqT.js";import{MaskShapeCanvas as ne}from"./MaskShapeCanvas-D57fCIme.js";s();var j=h(`/addon/pipeline-analytics/event-media`);function M(e){return`${j}/m/${e}`}function N(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function P(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var F=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function I({monitor:t,disabled:n,onDelete:r}){let a=w(),o=N(t),s=P(t),c=y();return o.length===0?i(`p`,{className:`${A} leading-relaxed`,children:a(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):i(`div`,{className:`flex flex-col gap-2`,children:o.map(t=>e(`div`,{className:`flex flex-col gap-1`,children:[e(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[T(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let l=`${o.stateId}:${String(o.index)}`,u=s===1;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(L,{reference:o.reference}),i(`span`,{className:`${A} tabular-nums`,children:R(o.reference.capturedAt)}),e(`button`,{type:`button`,className:F,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:T(t.condition,a).toLowerCase(),date:R(o.reference.capturedAt)}),onClick:()=>{(async()=>{u&&!await c({title:a(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:a(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:o.stateId,index:o.index})})()},children:[i(O,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function L({reference:t}){let n=w(),[r,a]=o(!1),s=t.thumbnailMediaId;return s===void 0||r?e(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[i(v,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:M(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function R(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var z=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,B=`text-[10px] font-medium text-foreground-subtle`,V=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,H=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,U=5,W=3600;function G(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function K(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function q(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function re({monitor:t,disabled:n,onPatch:r}){let s=w(),[u,d]=o(()=>q(t)),[f,p]=o(!1);a(()=>{f||d(q(t))},[t,f]);let m=e=>{p(!1),r(e)},h=e=>t.check.mode===`similarity`?{mode:`similarity`,threshold:e.threshold??t.check.threshold,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount}:{...t.check,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount},_=t.confirm?.enabled===!0,v=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:u.label,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,label:e.target.value})),onBlur:()=>{let e=u.label.trim();e.length>0&&e!==t.label?m({label:e}):p(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(g,{checked:t.enabled,disabled:n,onChange:e=>m({enabled:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(S,{value:t.triggerMode,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&m({triggerMode:t})},children:[i(`option`,{value:`both`,children:s(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),i(`option`,{value:`periodic`,children:s(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),i(`option`,{value:`on-motion`,children:s(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),i(`p`,{className:A,children:G(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:U,max:W,value:u.checkIntervalSec,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.checkIntervalSec,U,W);e===t.checkIntervalSec?p(!1):m({checkIntervalSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),t.check.mode===`similarity`&&e(c,{children:[e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:i(E,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:u.threshold.toFixed(2)}})}),i(l,{min:.3,max:.99,step:.01,value:u.threshold,disabled:n,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{u.threshold===v?p(!1):m({check:h({threshold:u.threshold})})},onBlur:()=>{u.threshold===v?p(!1):m({check:h({threshold:u.threshold})})}})]}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:u.hysteresisCount,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=J(u.hysteresisCount,1,10);e===t.check.hysteresisCount?p(!1):m({check:h({hysteresisCount:e})})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:u.quietSeconds,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.quietSeconds,0,3600);e===t.quietSeconds?p(!1):m({quietSeconds:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:u.minObservationSpacingSec,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?p(!1):m({minObservationSpacingSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(S,{value:t.onUncoveredCondition,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&m({onUncoveredCondition:t})},children:[i(`option`,{value:`skip`,children:s(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),i(`option`,{value:`judge-anyway`,children:s(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),i(`p`,{className:A,children:K(t.onUncoveredCondition,s)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(S,{value:t.emit,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&m({emit:t})},children:[i(`option`,{value:`latched`,children:s(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),i(`option`,{value:`live`,children:s(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(g,{checked:t.autoRestore,disabled:n,onChange:e=>m({autoRestore:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(g,{checked:_,disabled:n||u.confirmPrompt.trim().length===0,onChange:e=>m(e.target.checked?{confirm:{...Y(u.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:u.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=u.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?m({confirm:{...Y(e),enabled:_}}):p(!1)}})]}),i(`p`,{className:A,children:i(E,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[i(`strong`,{},`only`)]})})]})]})}function J(e,t,n){return Math.min(n,Math.max(t,e))}function Y(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var X=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,Z=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,ie=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,ae={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},oe=.8,se=3;function Q({deviceId:s}){let l=w(),h=p(k().trpcClient,s),g=d(h?.state.sceneMonitor),v=u(s,{width:640}),[y,S]=o(null),[E,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[G,K]=o(``),q=t(!0);a(()=>(q.current=!0,()=>{q.current=!1}),[]);let J=r(async()=>{if(h)try{let e=await h.sceneMonitor?.listScenes({});if(!q.current)return;e&&S(e)}catch(e){if(!q.current)return;_(e)?j(!0):F(e instanceof Error?e.message:String(e))}},[h]);a(()=>{S(null),j(!1),F(null),J()},[J]);let Y=g?.monitors??y?.monitors??[],Q=Date.now(),$=r(async(e,t)=>{N(e),F(null);try{await t(),await J()}catch(e){q.current&&F(e instanceof Error?e.message:String(e))}finally{q.current&&N(null)}},[J]),ce=n(()=>{let e=Y.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:l(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Y,U,l]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>h?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[h,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||G.trim().length===0||(await $(`create`,async()=>{await h?.sceneMonitor?.createScene({label:G.trim(),roi:U,check:{mode:`similarity`,threshold:oe,hysteresisCount:se}})}),W(null),K(``),H(!1))},[h,U,G,$]);return h?i(`div`,{className:`flex flex-col gap-3`,children:E?i(`p`,{className:`${A} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${A} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),i(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:i(ne,{items:ce,supportedShapes:[`rect`],selectedId:L??(U===null?null:`__draft__`),onSelect:e=>R(e===null?null:String(e)),onShapeChange:le,onDrawComplete:ue,drawingKind:V&&U===null?`rect`:null,backdrop:v.src===null?null:i(`img`,{src:v.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`button`,{type:`button`,className:V?Z:X,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:M!==null,children:V?l(`uiLibrary.sceneMonitor.cancel`,`Cancel`):l(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:X,onClick:v.refresh,disabled:M!==null,children:l(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),V&&e(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U===null?l(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):l(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&te(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:l(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`text`,value:G,onChange:e=>K(e.target.value),placeholder:l(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),i(`button`,{type:`button`,className:Z,onClick:()=>void de(),disabled:U===null||G.trim().length===0||M!==null,children:l(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),P!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:P}),Y.length===0?i(`p`,{className:`${A} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Y.map(t=>{let n=ee(t,l);return e(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${L===t.id?`border-primary/50`:`border-border`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>R(t.id),children:t.label}),i(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${ae[n.tone]}`,children:n.text})]}),i(`p`,{className:`${A} leading-relaxed`,children:b(t,Q,l)}),i(`p`,{className:`${A} tabular-nums`,children:C(t,l)}),i(I,{monitor:t,disabled:M!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>h.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[D.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:X,disabled:M!==null,title:r?l(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):l(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:T(n,l).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>h.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(x,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:T(n,l).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:l(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:Z,disabled:M!==null||t.states.length===0,title:l(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>h.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(f,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:X,disabled:M!==null,onClick:()=>void $(`check-${t.id}`,async()=>h.sceneMonitor?.recheckNow({monitorId:t.id})),children:l(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?Z:X,"aria-pressed":z===t.id,"aria-label":l(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:M!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(m,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:ie,disabled:M!==null,onClick:()=>void $(`del-${t.id}`,async()=>h.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(O,{className:`h-3 w-3`})})]}),z===t.id&&i(re,{monitor:t,disabled:M!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>h.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Q as SceneMonitorEditor};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as l,G as u,J as d,Jn as f,K as p,Ln as m,Q as h,Qa as g,U as _,Xr as v,c as ee,ct as y,d as te,f as b,fa as x,ft as S,l as C,oo as w,p as T,ro as E,s as D,tn as O,yt as k,z as A}from"./player-overlays-BKR7fWEx.js";import{MaskShapeCanvas as ne}from"./MaskShapeCanvas-drW0ZeaQ.js";s();var j=h(`/addon/pipeline-analytics/event-media`);function M(e){return`${j}/m/${e}`}function N(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function P(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var F=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function I({monitor:t,disabled:n,onDelete:r}){let a=w(),o=N(t),s=P(t),c=y();return o.length===0?i(`p`,{className:`${A} leading-relaxed`,children:a(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):i(`div`,{className:`flex flex-col gap-2`,children:o.map(t=>e(`div`,{className:`flex flex-col gap-1`,children:[e(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[T(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let l=`${o.stateId}:${String(o.index)}`,u=s===1;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(L,{reference:o.reference}),i(`span`,{className:`${A} tabular-nums`,children:R(o.reference.capturedAt)}),e(`button`,{type:`button`,className:F,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:T(t.condition,a).toLowerCase(),date:R(o.reference.capturedAt)}),onClick:()=>{(async()=>{u&&!await c({title:a(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:a(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:o.stateId,index:o.index})})()},children:[i(O,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function L({reference:t}){let n=w(),[r,a]=o(!1),s=t.thumbnailMediaId;return s===void 0||r?e(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[i(v,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:M(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function R(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var z=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,B=`text-[10px] font-medium text-foreground-subtle`,V=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,H=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,U=5,W=3600;function G(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function K(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function q(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function re({monitor:t,disabled:n,onPatch:r}){let s=w(),[u,d]=o(()=>q(t)),[f,p]=o(!1);a(()=>{f||d(q(t))},[t,f]);let m=e=>{p(!1),r(e)},h=e=>t.check.mode===`similarity`?{mode:`similarity`,threshold:e.threshold??t.check.threshold,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount}:{...t.check,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount},_=t.confirm?.enabled===!0,v=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:u.label,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,label:e.target.value})),onBlur:()=>{let e=u.label.trim();e.length>0&&e!==t.label?m({label:e}):p(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(g,{checked:t.enabled,disabled:n,onChange:e=>m({enabled:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(S,{value:t.triggerMode,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&m({triggerMode:t})},children:[i(`option`,{value:`both`,children:s(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),i(`option`,{value:`periodic`,children:s(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),i(`option`,{value:`on-motion`,children:s(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),i(`p`,{className:A,children:G(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:U,max:W,value:u.checkIntervalSec,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.checkIntervalSec,U,W);e===t.checkIntervalSec?p(!1):m({checkIntervalSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),t.check.mode===`similarity`&&e(c,{children:[e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:i(E,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:u.threshold.toFixed(2)}})}),i(l,{min:.3,max:.99,step:.01,value:u.threshold,disabled:n,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{u.threshold===v?p(!1):m({check:h({threshold:u.threshold})})},onBlur:()=>{u.threshold===v?p(!1):m({check:h({threshold:u.threshold})})}})]}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:u.hysteresisCount,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=J(u.hysteresisCount,1,10);e===t.check.hysteresisCount?p(!1):m({check:h({hysteresisCount:e})})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:u.quietSeconds,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.quietSeconds,0,3600);e===t.quietSeconds?p(!1):m({quietSeconds:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:u.minObservationSpacingSec,disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=J(u.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?p(!1):m({minObservationSpacingSec:e})}})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(S,{value:t.onUncoveredCondition,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&m({onUncoveredCondition:t})},children:[i(`option`,{value:`skip`,children:s(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),i(`option`,{value:`judge-anyway`,children:s(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),i(`p`,{className:A,children:K(t.onUncoveredCondition,s)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(S,{value:t.emit,disabled:n,className:z,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&m({emit:t})},children:[i(`option`,{value:`latched`,children:s(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),i(`option`,{value:`live`,children:s(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(g,{checked:t.autoRestore,disabled:n,onChange:e=>m({autoRestore:e.target.checked})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:A,children:s(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),e(`div`,{className:V,children:[i(`p`,{className:H,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(g,{checked:_,disabled:n||u.confirmPrompt.trim().length===0,onChange:e=>m(e.target.checked?{confirm:{...Y(u.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:B,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:u.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:z,onFocus:()=>p(!0),onChange:e=>d(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=u.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?m({confirm:{...Y(e),enabled:_}}):p(!1)}})]}),i(`p`,{className:A,children:i(E,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[i(`strong`,{},`only`)]})})]})]})}function J(e,t,n){return Math.min(n,Math.max(t,e))}function Y(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var X=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,Z=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,ie=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,ae={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},oe=.8,se=3;function Q({deviceId:s}){let l=w(),h=p(k().trpcClient,s),g=d(h?.state.sceneMonitor),v=u(s,{width:640}),[y,S]=o(null),[E,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[G,K]=o(``),q=t(!0);a(()=>(q.current=!0,()=>{q.current=!1}),[]);let J=r(async()=>{if(h)try{let e=await h.sceneMonitor?.listScenes({});if(!q.current)return;e&&S(e)}catch(e){if(!q.current)return;_(e)?j(!0):F(e instanceof Error?e.message:String(e))}},[h]);a(()=>{S(null),j(!1),F(null),J()},[J]);let Y=g?.monitors??y?.monitors??[],Q=Date.now(),$=r(async(e,t)=>{N(e),F(null);try{await t(),await J()}catch(e){q.current&&F(e instanceof Error?e.message:String(e))}finally{q.current&&N(null)}},[J]),ce=n(()=>{let e=Y.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:l(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Y,U,l]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>h?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[h,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||G.trim().length===0||(await $(`create`,async()=>{await h?.sceneMonitor?.createScene({label:G.trim(),roi:U,check:{mode:`similarity`,threshold:oe,hysteresisCount:se}})}),W(null),K(``),H(!1))},[h,U,G,$]);return h?i(`div`,{className:`flex flex-col gap-3`,children:E?i(`p`,{className:`${A} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${A} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),i(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:i(ne,{items:ce,supportedShapes:[`rect`],selectedId:L??(U===null?null:`__draft__`),onSelect:e=>R(e===null?null:String(e)),onShapeChange:le,onDrawComplete:ue,drawingKind:V&&U===null?`rect`:null,backdrop:v.src===null?null:i(`img`,{src:v.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`button`,{type:`button`,className:V?Z:X,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:M!==null,children:V?l(`uiLibrary.sceneMonitor.cancel`,`Cancel`):l(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:X,onClick:v.refresh,disabled:M!==null,children:l(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),V&&e(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U===null?l(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):l(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&te(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:l(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`text`,value:G,onChange:e=>K(e.target.value),placeholder:l(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),i(`button`,{type:`button`,className:Z,onClick:()=>void de(),disabled:U===null||G.trim().length===0||M!==null,children:l(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),P!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:P}),Y.length===0?i(`p`,{className:`${A} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Y.map(t=>{let n=ee(t,l);return e(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${L===t.id?`border-primary/50`:`border-border`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>R(t.id),children:t.label}),i(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${ae[n.tone]}`,children:n.text})]}),i(`p`,{className:`${A} leading-relaxed`,children:b(t,Q,l)}),i(`p`,{className:`${A} tabular-nums`,children:C(t,l)}),i(I,{monitor:t,disabled:M!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>h.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[D.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:X,disabled:M!==null,title:r?l(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):l(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:T(n,l).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>h.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(x,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:T(n,l).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:l(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:Z,disabled:M!==null||t.states.length===0,title:l(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>h.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(f,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:X,disabled:M!==null,onClick:()=>void $(`check-${t.id}`,async()=>h.sceneMonitor?.recheckNow({monitorId:t.id})),children:l(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?Z:X,"aria-pressed":z===t.id,"aria-label":l(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:M!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(m,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:ie,disabled:M!==null,onClick:()=>void $(`del-${t.id}`,async()=>h.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(O,{className:`h-3 w-3`})})]}),z===t.id&&i(re,{monitor:t,disabled:M!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>h.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Q as SceneMonitorEditor};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cr as o,Nn as s,Pn as c,Qa as l,Tt as u,_i as d,ct as f,ft as p,oo as m,tn as h,ut as g,zr as _}from"./player-overlays-BKR7fWEx.js";import{Zs as v}from"./client-BDuXx1QP.js";import{a as y,l as b}from"./terminal-DZ5OZpgC.js";import{Ca as x,Dr as ee,Ea as S,Er as C,Hi as w,Ji as T,Ki as E,Oa as D,Q as te,Rr as O,Tp as ne,Ui as k,Wi as A,Xi as j,Xs as M,Z as N,Zi as re,_p as P,hi as F,ii as I,ip as ie,mt as L,nt as ae,oi as oe,qi as R,rt as z,si as B,tm as V,wr as H,zr as U}from"./src-BnZKlAAn.js";import{t as W}from"./i18n-CjRpxC0U.js";import{t as G}from"./useTranslation-BJr-n0es.js";import{n as K,vi as se,z as ce}from"./index-Dx4xn5Ud.js";import{n as le,r as q,t as J}from"./AccessSection-Bbp4vCnK.js";a();var ue={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function Y(e){return W.t(ue[e])}var de={active:`success`,expired:`warning`,revoked:`default`,current:`info`},fe={current:0,active:1,expired:2,revoked:3};function X(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function Z({status:e}){return n(D,{variant:de[e],className:`text-[10px]`,children:Y(e)})}function pe({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(P,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":W.t(`access.credentialColumns.actionOn`,{action:r.label,name:t.name}),className:r.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function me(t){return[{key:`name`,header:W.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[n(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&n(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:W.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:W.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[n(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&n(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:W.t(`access.credentialColumns.status`,`Status`),sortValue:e=>fe[e.status],render:e=>n(Z,{status:e.status})},{key:`created`,header:W.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.createdAt,`—`)})},{key:`lastUsed`,header:W.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.lastUsedAt,W.t(`access.credentialColumns.never`))})},{key:`expires`,header:W.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:W.t(`access.credentialColumns.actionsHeader`),render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:n(pe,{row:e,action:t},t.label))})}].filter(e=>e!==null)}var he=6,ge={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function _e(e){let t=ge[e];return t===void 0?e:W.t(t)}function ve(e,t){return W.t(t.key,{count:e})}function Q(e,t){return W.t(`access.bulk.countOf`,{count:e,noun:ve(e,t)})}function ye(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>W.t(`access.bulk.statusCount`,{count:t,status:Y(e).toLowerCase()})).join(`, `)}function be(e,t){let n=e.slice(0,he).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>he?[W.t(`access.bulk.previewMore`,{count:e.length-he})]:[];return[W.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:ye(e)}),``,...n,...r].join(`
|
|
2
|
+
`)}async function xe(e,t,n){let r=String(t.length),i=await e({title:W.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:be(t,n),label:W.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:W.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:W.t(`access.bulk.confirmMismatch`,{expected:r,noun:ve(2,n)})});return i!==null&&i.trim()===r}function Se(e,t){let n=g(),r=V.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await xe(n,i,e))return!1;o(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>_e(e.reason));return o({tone:`success`,message:n.length>0?W.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):W.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:W.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:W.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function Ce(e,t,n){let r=g(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await xe(r,i,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:W.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:W.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:W.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}a();var we={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Te={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Ee=e=>e.status!==`current`,De=[`active`,`current`];function Oe({rows:r,label:a,isLoading:o,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:p,defaultStatus:m=De}){let{t:h}=G(),[g]=i(()=>m.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...m]}}),v=H(r,we,g),[y,b]=i(()=>new Set),x=u??h(`access.credentialColumns.never`),ee=t(()=>me({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,h]),w=t(()=>p===void 0?()=>!1:e=>Ee(e)&&p.isSelectable(e),[p]),T=t(()=>v.rows.filter(e=>y.has(e.id)&&w(e)),[v.rows,y,w]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),h(`access.credentialTable.loading`,{label:a})]}):s===null?e(`div`,{className:`space-y-3`,children:[n(C,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Te[e.id]===void 0?e.id:h(Te[e.id]),...e.id===`status`?{facetLabel:e=>Y(e)}:{}})),labels:{searchPlaceholder:h(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:h(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:h(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:h(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),p!==void 0&&n(ke,{bulk:p,shown:v.rows.filter(w),targets:T,onSelect:b}),n(O,{columns:ee,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:U,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:h(`access.credentialTable.pagesLabel`,{label:a}),previous:h(`access.credentialTable.previousPage`),next:h(`access.credentialTable.nextPage`),range:(e,t,n)=>h(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?h(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...p===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:w,rowLabel:e=>h(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:h(`access.credentialTable.pageLabel`,{noun:ve(1,p.noun)})}}})]}):n(S,{title:h(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:s})}function ke({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=G(),{revoke:s,noun:c}=t,l=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(i)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[r.length>0&&n(P,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),l.map(t=>e(P,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),i.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(i.length,c)})}),e(P,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(u,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(P,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(h,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,c)})]})]})]})}var Ae=(e,t)=>t===null?`—`:e.get(t)??t;function je(e,t){return e!=null&&e<=t?`expired`:`active`}function Me(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Ae(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ne(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Pe=`All permissions`,Fe=`View link`,Ie=`Scoped`,Le={"grid-view":`Grid`,"events-view":`Events`};function Re(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function ze(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Be(e,t,n){return e===`*`?Pe:ze(e)?`${`${Le[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Re(e.grant.deviceIds,t)}`:n(e)}function Ve(e){return e.includes(`*`)?Pe:e.some(ze)?Fe:Ie}function He(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Ae(t,e.subjectId),kind:Ve(e.scopes),scope:n,status:e.revokedAt===null?je(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ue(e){return`${e.provider}\u0000${e.subject}`}function We(e,t){return{id:Ue(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Ae(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var Ge=40,Ke=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],qe=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],Je=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function Ye(e,t){return e.find(e=>e.test.test(t))?.name??null}function Xe(e){return e.length<=Ge?e:`${e.slice(0,Ge)}…`}function Ze(e){if(e===null||e.trim().length===0)return{label:W.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=Ye(Je,t);if(n!==null)return{label:n,raw:t};let r=Ye(Ke,t),i=Ye(qe,t);return r!==null&&i!==null?{label:W.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:Xe(t),raw:t}:{label:r,raw:t}}var Qe={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,"cli-approval":`helpers.sessionClient.method.cliApproval`,exchange:`helpers.sessionClient.method.exchange`};function $e(e){let t=Qe[e];return t===void 0?e:W.t(t)}function et(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function tt({token:t,label:r,onClose:i}){let{t:a}=G();return n(w,{open:!0,onOpenChange:e=>!e&&i(),children:e(A,{width:`md`,scroll:`body`,children:[n(R,{children:n(T,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(k,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),n(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(E,{children:[n(ee,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(P,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var nt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var rt=80,$=86400,it=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],at=[v.Camera],ot=64,st={type:`capability`,target:``,access:[`view`,`create`]};function ct({open:a,users:o,onClose:u,onSubmit:f,submitting:h,formError:g,awaitingProof:v}){let{t:y}=G(),ee=m(),{user:S}=ce(),C=S?.isAdmin===!0,w=C?null:S?.scopes??[],[T,E]=i(`scopes`),[D,O]=i(S?.id??``),[k,A]=i(``),[M,ie]=i([st]),[L,ae]=i([]),[R,V]=i(`grid-view`),[H,U]=i(!1),[W,K]=i(`30`);r(()=>{a||(E(`scopes`),O(S?.id??``),A(``),ie([st]),ae([]),V(`grid-view`),U(!1),K(`30`))},[a,S?.id]),r(()=>{T!==`view-link`&&W===`never`&&K(`30`)},[T,W]);let le=t(()=>it.filter(e=>e.seconds!==`never`||T===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?y(`access.createTokenModal.never`,`Never (until revoked)`):y(`access.createTokenModal.days`,{count:Number(e.value)})})),[T,y]),q=k.trim(),J=T===`scopes`?te(M,ee):null,ue=[...L],Y=it.find(e=>e.value===W)?.seconds??30*$,de=()=>T===`all`?[`*`]:T===`view-link`?[{type:`share-view`,grant:{kind:R,deviceIds:ue,...H?{talk:!0}:{}}}]:M,fe=q.length>0&&q.length<=rt&&!h&&!v&&(T===`all`?C:T===`view-link`?ue.length>0:M.length>0&&J===null),X=()=>{if(!fe)return;let e=C&&T!==`all`&&D!==``&&D!==S?.id;f({scopes:de(),expiresIn:Y,label:q,...e?{subjectId:D}:{}})},Z=T===`all`,pe=Z?c:s;return n(z,{open:a,onClose:u,title:y(`access.createTokenModal.createToken`,`Create token`),icon:Z?c:b,error:g,width:`md`,testId:`create-token-dialog`,footer:e(P,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:X,disabled:!fe,"data-testid":`create-token-submit`,children:[h||v?n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(pe,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),y(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(F,{children:y(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(I,{appearance:`pills`,value:T,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&E(e)},children:e(oe,{"aria-label":y(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(B,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(s,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(B,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachViewLink`,`View link`)]}),C?e(B,{value:`all`,"data-testid":`token-reach-all`,children:[n(c,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?n(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:n(`p`,{children:n(se,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,C&&T!==`all`&&o.length>1?e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-user`,children:y(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(p,{id:`token-user`,value:D,onChange:e=>O(e.target.value),options:o.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-name`,children:y(`access.createTokenModal.label`,`Label`)}),n(ne,{id:`token-name`,value:k,maxLength:rt,required:!0,onChange:e=>A(e.target.value),placeholder:T===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),T===`scopes`?e(`div`,{className:`space-y-1`,children:[n(F,{children:y(`access.createTokenModal.scopes`,`Scopes`)}),n(N,{value:M,onChange:ie,clampToParent:w}),J&&n(`p`,{className:`text-[10px] text-danger`,children:J}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:y(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,T===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-view-cameras`,children:y(`access.createTokenModal.cameras`,`Cameras`)}),n(x,{id:`token-view-cameras`,multiple:!0,pick:`device`,noun:`camera`,fixedTypes:at,maxItems:ot,recentKey:`token-view-cameras`,testId:`token-view-cameras`,value:re(L),onChange:e=>ae(j(e))})]}),e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-view-kind`,children:y(`access.createTokenModal.viewKind`,`Shows`)}),n(p,{id:`token-view-kind`,value:R,onChange:e=>V(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:y(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:y(`access.createTokenModal.viewEvents`,`Events`)}]})]}),R===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(l,{className:`mt-0.5`,checked:H,onChange:e=>U(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:y(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-lifetime`,children:y(`access.createTokenModal.expires`,`Expires after`)}),n(p,{id:`token-lifetime`,value:W,onChange:e=>K(e.target.value),options:le})]})]})})}a();var lt={key:`access.nouns.token`};function ut(e){return typeof e==`object`&&!!e&&`kind`in e}function dt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${ut(e.selector)?L(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function ft({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:l}=G(),u=m(),{user:d}=ce(),p=f(),g=V.useUtils(),_=q(),{data:v}=ie(),y=t(()=>v??[],[v]),{data:x}=M({}),ee=t(()=>{let e=new Map;for(let t of x??[])e.set(t.id,t.name);return e},[x]),S=V.auth.listTokens.useQuery(void 0),{requestProof:C,dialog:w}=K(`Creating a token with all permissions`),{state:T,openNew:E,close:D}=ae({newKey:nt.token}),[te,O]=i(null),[ne,k]=i(null),[A,j]=i(!1),[N,re]=i(null),[F,I]=i(null);r(()=>{o&&(E(),s?.())},[o,E,s]);let L=()=>{g.auth.listTokens.invalidate(),g.auth.listAuthAudit.invalidate()},oe=V.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{L(),D(),k(null),j(!1),re({token:e,label:t.label})},onError:e=>{k(`Create failed: ${e.message}`),j(!1)}}),R=V.auth.revokeToken.useMutation({onSuccess:()=>{I(null),L()},onError:e=>{I(null),O(`Revoke failed: ${e.message}`)}}),z=Se(lt,L),B=Date.now(),H=(S.data??[]).filter(e=>!c||e.subjectId===d?.id).map(e=>He(e,_,e.scopes.includes(`*`)?null:e.scopes.map(e=>Be(e,ee,e=>dt(e,u))).join(`, `),B)),U=async e=>{await p({title:l(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?l(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):l(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:l(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(O(null),I(e.id),R.mutate({id:e.id}))},W=e=>{(async()=>{O(null),k(null);let t;if(e.scopes.includes(`*`)){j(!0);let e=await C();if(j(!1),e===null)return;t=e}oe.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[w,n(J,{notice:le(te,z.outcome),onDismissNotice:()=>{O(null),z.dismiss()},id:c?`my-tokens`:`tokens`,title:c?l(`access.tokensSection.myTokens`,`My tokens`):l(`access.tokensSection.tokens`,`Tokens`),icon:b,actions:a?void 0:e(P,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:E,children:[n(b,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),l(`system.access.newToken`,`New token`)]}),description:l(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:n(Oe,{rows:H,label:l(`common.tokensLabel`),isLoading:S.isLoading,loadError:S.isError?S.error?.message??`Request failed`:null,emptyText:l(`access.tokensSection.noTokens`,`No tokens.`),action:{label:l(`access.tokensSection.revoke2`,`Revoke`),icon:h,isAvailable:e=>e.status===`active`,onRun:e=>void U(e),busyId:F,disabled:z.busy||F!==null},...d?.isAdmin===!0?{bulk:{revoke:z,noun:lt,isSelectable:e=>e.status===`active`}}:{}})}),n(ct,{open:T.mode===`new`,users:y.map(e=>({id:e.id,username:e.username})),onClose:()=>{D(),k(null),j(!1)},submitting:oe.isPending,formError:ne,awaitingProof:A,onSubmit:W}),N&&n(tt,{token:N.token,label:N.label,onClose:()=>re(null)})]})}var pt=864e5,mt={qr:`QR (by an admin)`,self:`Self-enrolled`},ht={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function gt(e){return e.status===`revoked`}function _t(e){return e.status!==`revoked`}function vt(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function yt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/pt)}function bt(e,t){let n=yt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function xt(e,t){let n=yt(e,t);return n===null?W.t(`helpers.certificateModel.unknown`):n===0?W.t(`helpers.certificateModel.today`):n>0?W.t(`helpers.certificateModel.inDays`,{count:n}):W.t(`helpers.certificateModel.daysAgo`,{count:-n})}function St(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Ct(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function wt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Tt(e){if(!e.online)return{allowed:!1,reason:W.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:W.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:W.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var Et={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Dt(e){if(e.ok)return{tone:`success`,message:W.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:wt(e.newSerial)})};let t=e.keptPreviousLeaf?W.t(`helpers.certificateModel.keptPrevious`):W.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:W.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:W.t(Et[e.stage]),reason:e.reason,kept:t})}}function Ot(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var kt=11;function At(e,t){let n=e.slice(0,kt);return t===null?n:`${n} · ${t}`}function jt(e){return{id:e.id,name:e.deviceName,detail:At(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:ht[e.platform],scope:mt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Mt(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:ht[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Nt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=G();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):i===null?t.length===0?n(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):n(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(Pt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,i]})}function Pt({session:t,revoking:r,onRevoke:i}){let{t:a}=G(),s=Ze(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(o,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`span`,{className:`font-medium text-foreground truncate`,title:s.raw??void 0,children:s.label}),t.current&&n(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:$e(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:et(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:et(t.expiresAt)})})]})]}),!t.current&&e(P,{variant:`unstyled`,onClick:i,disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r?n(_,{className:`h-3 w-3 animate-spin`}):n(y,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Me as C,Ce as E,Ne as S,Se as T,Ze as _,_t as a,Ue as b,xt as c,vt as d,Tt as f,nt as g,ft as h,gt as i,Dt as l,wt as m,jt as n,Ot as o,Ct as p,Mt as r,St as s,Nt as t,bt as u,$e as v,Oe as w,We as x,et as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as i,Qa as a,ft as o}from"./player-overlays-fpbPSPqT.js";import{Sp as s,Y as c,hi as l,mp as u,y as d}from"./src-eL0OacoB.js";import{Vt as f,Z as p,ut as m}from"./index-DbXFHmBJ.js";r();function h({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function g({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}var _={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function v(){let[r,v]=n(!1),[b,x]=n(null),[S,C]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(h,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(h,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(g,{name:`primary`,cssVar:`--color-primary`}),t(g,{name:`background`,cssVar:`--color-background`}),t(g,{name:`surface`,cssVar:`--color-surface`}),t(g,{name:`foreground`,cssVar:`--color-foreground`}),t(g,{name:`success`,cssVar:`--color-success`}),t(g,{name:`warning`,cssVar:`--color-warning`}),t(g,{name:`danger`,cssVar:`--color-danger`}),t(g,{name:`info`,cssVar:`--color-info`}),t(g,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(g,{name:`onvif`,hex:`#3b82f6`}),t(g,{name:`hikvision`,hex:`#a855f7`}),t(g,{name:`reolink`,hex:`#06b6d4`}),t(g,{name:`ha`,hex:`#22d3ee`}),t(g,{name:`rtsp`,hex:`#78716c`})]})}),t(h,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(u,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),t(u,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),t(u,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),t(u,{variant:`unstyled`,disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),t(u,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),t(u,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),t(h,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(s,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(s,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(s,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(o,{className:`w-full`,children:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(l,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(a,{className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(y,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(i,{className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),e(h,{title:`ConditionKindPicker`,children:[e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(u,{variant:`outline`,onClick:()=>v(!0),children:`Add a condition`}),t(`span`,{className:`text-xs text-foreground-subtle`,children:b??`Nothing picked`})]}),t(d,{open:r,onOpenChange:v,title:`Add a condition`,context:`trigger`,underNot:!1,treeFull:!1,recentKey:`showroom`,textsOf:e=>({label:e,description:`A ${e} row`,example:e}),categoryLabelOf:e=>e,reasonOf:e=>e,onPick:e=>{x(e),v(!1)}})]}),t(h,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(c,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(p,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(h,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(h,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(m,{type:e,size:`lg`,showLabel:!0},e))})}),e(h,{title:`Form Builder Demo`,children:[t(f,{schema:_,values:S,onChange:C}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(S,null,2)})]})]}),t(h,{title:`Info Boxes`,children:t(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:n,label:r,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function y(){let[e,r]=n(!0);return t(u,{variant:`unstyled`,type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:t(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{v as ShowroomPage};
|
|
1
|
+
import{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as i,Qa as a,ft as o}from"./player-overlays-BKR7fWEx.js";import{Tp as s,Y as c,_p as l,mi as u,y as d}from"./src-BnZKlAAn.js";import{Q as f,Vt as p,ut as m}from"./index-Dx4xn5Ud.js";r();function h({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function g({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}var _={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function v(){let[r,v]=n(!1),[b,x]=n(null),[S,C]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(h,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(h,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(g,{name:`primary`,cssVar:`--color-primary`}),t(g,{name:`background`,cssVar:`--color-background`}),t(g,{name:`surface`,cssVar:`--color-surface`}),t(g,{name:`foreground`,cssVar:`--color-foreground`}),t(g,{name:`success`,cssVar:`--color-success`}),t(g,{name:`warning`,cssVar:`--color-warning`}),t(g,{name:`danger`,cssVar:`--color-danger`}),t(g,{name:`info`,cssVar:`--color-info`}),t(g,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(g,{name:`onvif`,hex:`#3b82f6`}),t(g,{name:`hikvision`,hex:`#a855f7`}),t(g,{name:`reolink`,hex:`#06b6d4`}),t(g,{name:`ha`,hex:`#22d3ee`}),t(g,{name:`rtsp`,hex:`#78716c`})]})}),t(h,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(l,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),t(l,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),t(l,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),t(l,{variant:`unstyled`,disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),t(l,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),t(l,{variant:`unstyled`,className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),t(h,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(s,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(s,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(s,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(o,{className:`w-full`,children:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(u,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(a,{className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(y,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(i,{className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),e(h,{title:`ConditionKindPicker`,children:[e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(l,{variant:`outline`,onClick:()=>v(!0),children:`Add a condition`}),t(`span`,{className:`text-xs text-foreground-subtle`,children:b??`Nothing picked`})]}),t(d,{open:r,onOpenChange:v,title:`Add a condition`,context:`trigger`,underNot:!1,treeFull:!1,recentKey:`showroom`,textsOf:e=>({label:e,description:`A ${e} row`,example:e}),categoryLabelOf:e=>e,reasonOf:e=>e,onPick:e=>{x(e),v(!1)}})]}),t(h,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(c,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(f,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(h,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(h,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(m,{type:e,size:`lg`,showLabel:!0},e))})}),e(h,{title:`Form Builder Demo`,children:[t(p,{schema:_,values:S,onChange:C}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(S,null,2)})]})]}),t(h,{title:`Info Boxes`,children:t(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:n,label:r,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function y(){let[e,r]=n(!0);return t(l,{variant:`unstyled`,type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:t(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{v as ShowroomPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Tt as c,ct as l,ti as u,tr as d,vi as f,zr as p}from"./player-overlays-BKR7fWEx.js";import{jc as m}from"./client-BDuXx1QP.js";import{t as h}from"./chevron-down-CBb-F8DT.js";import{_ as g}from"./terminal-DZ5OZpgC.js";import{t as _}from"./eraser-B3lnG9yK.js";import{t as v}from"./hard-drive-download-C6N6tovA.js";import{Bd as y,Oa as b,_p as x,gf as S,hf as C,il as w,mf as ee,no as T}from"./src-BnZKlAAn.js";import{t as E}from"./i18n-CjRpxC0U.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{Rt as O,St as k}from"./index-Dx4xn5Ud.js";import{t as A}from"./format-size-DIxKXxtj.js";import{t as te}from"./InstancesTable-CLf8XbQo.js";o();var j=[`ok`,`warn`,`critical`];function ne(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function M(e){return Math.min(1,Math.max(0,e))}function N(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=M((n-t)/n);return{fraction:r,severity:ne(r),recordingsFraction:M(e.usedBytes/n),freeBytes:t,totalBytes:n}}function re(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=N(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||j.indexOf(e.severity)>j.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function ie(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function ae(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function P({drain:t}){let{t:n}=D();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:ie(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:ae(t.estimatedEmptyAtMs)})]})]})}function F(e){return Math.min(1,Math.max(0,e))}function I(e){return Math.round(F(e)*1e3)/10}function L(e){return`${String(Math.round(F(e)*100))}%`}function oe(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:A(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?E.t(`helpers.locationCapacityBar.unknownSummary`):E.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=N({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?F(o/r):m.fraction,g=m===null?ne(h):m.severity,_=f===null?null:m===null?F(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:F((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:A(r),freeTotal:A(a),freeTotalPercent:L(a/r),used:A(p),usedPercent:L(p/r),free:A(u),freePercent:L(u/r),reserve:s===0?null:E.t(`helpers.locationCapacityBar.reserveKept`,{size:A(s)}),owned:f===null||_===null?null:E.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:A(f),percent:L(_)}),cap:v===null?null:v.reason===`drain`?E.t(`helpers.locationCapacityBar.capDrain`,{size:A(v.bytes)}):E.t(`helpers.locationCapacityBar.capCap`,{size:A(v.bytes)})},S=[E.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:E.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?E.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?E.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:E.t(`helpers.locationCapacityBar.legendKeptFree`),value:A(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:E.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?E.t(`helpers.locationCapacityBar.legendUsed`):E.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:E.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?E.t(`helpers.locationCapacityBar.legendDrainTarget`):E.t(`helpers.locationCapacityBar.legendCap`),value:E.t(`helpers.locationCapacityBar.legendCapValue`,{size:A(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:I(c/r),ownedPercent:f===null?null:I(f/r),usedPercent:I(p/r),freePercent:I(u/r),capPercent:y===null?null:I(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}function R(e){return m(e)}function z(e){return e===`active`}var B=[{mode:`active`,get label(){return E.t(`helpers.locationMode.activeLabel`)},get consequence(){return E.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return E.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return E.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return E.t(`helpers.locationMode.drainLabel`)},get consequence(){return E.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return E.t(`helpers.locationMode.disabledLabel`)},get consequence(){return E.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function V(e){return B.find(t=>t.mode===e)??B[0]}function se(e){return V(e).requiresConfirmation}var ce=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function H(e,t,n){return z(n)||!z(R(e))||t.some(t=>t.id!==e.id&&z(R(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:ce}}function le(e,t){return{active:H(e,t,`active`).reason,readonly:H(e,t,`readonly`).reason,drain:H(e,t,`drain`).reason,disabled:H(e,t,`disabled`).reason}}var ue=1024**3;function U(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function de(e){let t=U(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=U(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function fe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ue;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function pe(e,t){let n=U(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ue,reason:t===`drain`?`drain`:`legacy`}}var W={ok:`bg-primary`,warn:`bg-warning`,critical:`bg-danger`},G={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function me(e,t){return e===`used`?W[t]:G[e]}function K({location:t,ownedBytes:n}){let{t:i}=D(),a=t.capacity??null,o=fe(de(t.config),a?.totalBytes??null),s=oe({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:pe(t.config,R(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:G.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:G.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:W[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:G.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:G.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${me(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var he={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},ge={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},_e=`storage.discardLocation`,q=`storage.discardLocationStatus`,ve=`storage.discardLocationCancel`;function ye(e){return he[e]??null}function be(e){return ge[e]??null}function xe(e){return!z(R(e))}function Se(e,t){return ye(e.type)===null||!xe(e)?!1:t.some(t=>t.id!==e.id&&z(R(t)))}var Ce=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function J(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Y(e){return typeof e==`string`?e:null}function X(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!Ce.has(n))return null;let r=J(t.camerasTotal),i=J(t.camerasDone),a=J(t.foldersRemoved),o=J(t.dbRowsDeleted),s=J(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:Y(t.locationId),jobId:Y(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:Y(t.detail)??``,startedAtMs:J(t.startedAtMs),finishedAtMs:J(t.finishedAtMs),error:Y(t.error)}}function we(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}var Te=2e3;function Ee({location:e,siblings:t}){return Se(e,t)?r(De,{location:e}):null}function De({location:t}){let{t:n}=D(),o=l(),s=T(),u=be(t.type),[d,f]=a(null),[m,h]=a(null),[g,v]=a(!1);if(i(()=>{if(u===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:u,action:q,input:{}});if(e)return;f(X(t))}catch{}};t();let n=setInterval(()=>void t(),Te);return()=>{e=!0,clearInterval(n)}},[u,t.id]),u===null)return null;let y=d!==null&&d.locationId===t.id,b=y&&d.running,S=y&&d.phase!==`idle`,C=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){h(null),v(!0);try{await s.mutateAsync({addonId:u,action:_e,input:{locationId:t.id}}),f(X(await s.mutateAsync({addonId:u,action:q,input:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{v(!1)}}},w=async()=>{try{await s.mutateAsync({addonId:u,action:ve,input:{}})}catch(e){h(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[b?e(x,{variant:`unstyled`,type:`button`,onClick:()=>void w(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[r(c,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(x,{variant:`unstyled`,type:`button`,onClick:()=>void C(),disabled:g,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[g?r(p,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),S&&d!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${we(d)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[d.phase,d.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:d.camerasDone,total:d.camerasTotal})}`:``,d.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:d.dbRowsDeleted})}`:``,d.detail?` · ${d.detail}`:``]})]}),(m||y&&d?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:m??d?.error})]})}o();var Z={active:d,readonly:g,drain:v,disabled:f},Oe={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function ke({mode:t,open:n,onToggle:i}){let{t:a}=D(),o=V(t),s=Z[t];return e(x,{variant:`unstyled`,type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${Oe[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(h,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function Ae({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=D();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(x,{variant:`unstyled`,type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(c,{className:`h-3 w-3`})})]}),B.map(i=>{let c=n[i.mode],l=c!==``,u=Z[i.mode],d=i.mode===t;return e(x,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}function je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Me(e){if(!je(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=Q(e.startedAtMs),r=Q(e.startBytes),i=Q(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:Q(e.estimatedEmptyAtMs)}}function Ne(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Me(n);e!==null&&t.set(e.locationId,e)}return t}function Pe(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Fe(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Pe(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ie(e){return m(e)===`drain`}var Le=[`recordings`,`recordingsLow`];function Re(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ze(e,t){if(t===void 0||!Le.includes(e.type))return null;let n=t.find(t=>Re(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function Be(e,t){let n=new Map;for(let r of e){let e=ze(r,t);e!==null&&n.set(r.id,e)}return n}o();var Ve=[];function $(){let e=S({}),n=y({},{refetchOnWindowFocus:!1}),r=ee({},{refetchOnWindowFocus:!1}),i=e.data??Ve,a=t(()=>Be(i,n.data?.locations),[i,n.data?.locations]),o=t(()=>Ne(r.data),[r.data]);return t(()=>({locations:i,ownedBytesById:a,drainOf:e=>Fe(Ie(e),o.get(e.id))}),[i,a,o])}o();function He({row:t}){let{t:n}=D(),i=l(),o=s(),c=$(),[u,d]=a(!1),f=w({onSuccess:()=>{o.invalidateQueries({queryKey:[k]}),o.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(!1)},onError:e=>O({title:n(`system.storage.modeFailed`,`Could not change the state`),message:`${t.name}: ${e.message}`,severity:`critical`})}),p=c.locations.find(e=>e.id===t.id);if(p===void 0)return null;let m=c.locations.filter(e=>e.type===p.type),h=R(p),g=c.drainOf(p),_=async e=>{se(e)&&!await i({title:n(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:p.displayName}),message:n(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:V(e).consequence}),confirmLabel:n(`common.disable`,`Disable`),variant:`danger`})||f.mutate({addonId:t.addonId,id:t.id,values:{mode:e}})};return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`min-w-0 flex-1 basis-60`,children:[r(K,{location:p,ownedBytes:c.ownedBytesById.get(p.id)??null}),g.kind!==`idle`&&r(P,{drain:g})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[r(Ee,{location:p,siblings:m}),r(ke,{mode:h,open:u,onToggle:()=>d(e=>!e)})]}),u&&r(Ae,{mode:h,blockedReasons:le(p,m),onSelect:e=>void _(e),onDismiss:()=>d(!1)})]})}function Ue({row:t}){let n=$();if(t.kind!==`instance`)return null;let i=n.locations.find(e=>e.id===t.id);if(i===void 0)return null;let a=n.drainOf(i);return e(`div`,{className:`min-w-48`,children:[r(K,{location:i,ownedBytes:n.ownedBytesById.get(i.id)??null}),a.kind!==`idle`&&r(P,{drain:a})]})}function We({row:e}){let t=$();if(e.kind!==`instance`)return null;let n=t.locations.find(t=>t.id===e.id);if(n===void 0)return null;let i=R(n);return r(b,{variant:i===`active`?`success`:i===`disabled`?`danger`:`default`,children:V(i).label})}function Ge(e){return[{key:`capacity`,header:e.capacity,notSortableReason:e.capacity,render:e=>r(Ue,{row:e})},{key:`mode`,header:e.mode,nowrap:!0,notSortableReason:e.mode,render:e=>r(We,{row:e})}]}function Ke(e,t,n){return!(n===`single`||t.length<=1||z(R(e))&&t.filter(e=>z(R(e))).length<=1)}function qe(e){let t=e instanceof Error?e.message:String(e);return/still holds data — drain it first/.test(t)?`holds-data`:/could not be checked for remaining data/.test(t)?`unverifiable`:null}o();var Je=`forceDeleteLocation`;function Ye(){let{t:e}=D(),t=l(),r=s(),i=T();return n(async(n,a)=>{let o=qe(a);if(o===null)return!1;let s=o===`holds-data`?e(`system.storage.deleteBlockedHoldsData`,`This location still holds data. Drain it first (storage migration or relocate), or force the delete.`):e(`system.storage.deleteBlockedUnverifiable`,`What is stored on this location could not be checked (unreachable provider, another node or an unmounted root). Force the delete only if you are sure it is empty or no longer needed.`);if(!await t({title:e(`system.storage.deleteBlockedTitle`,`Cannot delete {{name}}`,{name:n.name}),message:s,confirmLabel:e(`system.storage.forceDelete`,`Force delete`),variant:`danger`})||!await t({title:e(`system.storage.forceDeleteTitle`,`Force delete "{{name}}"?`,{name:n.name}),message:e(`system.storage.forceDeleteStrands`,`Recordings and media stored on this location will be stranded: the record is deleted, the files stay on disk, and playback of the segments on it stops working.`),confirmLabel:e(`system.storage.forceDeleteConfirm`,`Delete and strand data`),variant:`danger`}))return!0;try{await i.mutateAsync({addonId:n.addonId,action:Je,input:{id:n.id}}),await r.invalidateQueries({queryKey:[k]}),await r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}catch(t){O({title:e(`providerInstances.deleteFailed`,`Could not delete`),message:`${n.name}: ${t instanceof Error?t.message:String(t)}`,severity:`critical`})}return!0},[t,i,r,e])}o();var Xe=`storage`;function Ze({kinds:e}){let{t:n}=D(),{locations:i}=$(),a=C({}).data,o=Ye(),s=e=>{let t=i.find(t=>t.id===e.id),n=a?.find(e=>e.id===t?.type);return t===void 0||n===void 0?!1:Ke(t,i.filter(e=>e.type===t.type),n.cardinality)},c=t(()=>Ge({capacity:n(`system.storage.colCapacity`,`Capacity`),mode:n(`system.storage.colMode`,`State`)}),[n]),l=t(()=>e===void 0?void 0:t=>t.kind===`instance`&&t.kindId!==void 0&&e.includes(t.kindId),[e]);return r(te,{functionCap:Xe,icon:u,title:n(`system.storage.title`,`Storage locations`),subtitle:n(`system.storage.subtitle`,`Where recordings, event media, artifacts and backups are kept. Each location is one kind on one provider; the state decides whether it takes writes, is only read, drains or is left alone.`),emptyTitle:n(`system.storage.emptyTitle`,`No storage locations yet`),emptyDescription:n(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`),addLabel:n(`system.storage.addLocation`,`Add location`),extraColumns:c,lead:e=>r(He,{row:e}),canDelete:s,onDeleteRefused:o,...l===void 0?{}:{rowFilter:l}})}export{R as a,V as i,$ as n,P as o,K as r,re as s,Ze as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as d,In as f,Jn as p,Nr as m,Qa as h,Yn as g,Z as _,Zi as v,ar as y,ct as b,ft as x,va as S,wn as C,xr as w,yt as T,zr as E}from"./player-overlays-BKR7fWEx.js";import{Hc as D}from"./client-BDuXx1QP.js";import{n as O,t as ee}from"./ruler-Buxogset.js";import{r as te}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js";import{Bp as ne,Dr as re,Ea as k,Er as ie,Fr as A,Ir as j,Lf as ae,Lr as M,Oa as N,On as oe,Pf as se,Rp as ce,Rr as le,Tp as ue,Xp as de,_p as P,ca as F,jf as fe,ka as I,kr as L,mi as pe,p as me,ra as he,tm as R,wr as ge,zp as _e,zr as ve}from"./src-BnZKlAAn.js";import{t as ye}from"./i18n-CjRpxC0U.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-CB3W-Dnv.js";import{S as be,b as xe,bi as Se,wi as Ce,xi as we}from"./index-Dx4xn5Ud.js";import{t as Te}from"./AdminSectionedPage-DvahmWYI.js";import{t as B}from"./AdminPage-Dyd6hYl8.js";import{t as Ee}from"./BootstrapSettingsForm-Cm4-eDgP.js";c();var V=`method`,H=8;function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function W(e){return Array.isArray(e)?e.filter(U):[]}function G(e,t){let n=e.$ref;if(typeof n!=`string`||!n.startsWith(`#/`))return e;let r=t;for(let e of n.slice(2).split(`/`))r=U(r)?r[e]:void 0;return U(r)?r:e}function K(e){let t=e.type;return typeof t==`string`?[t]:Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function q(e){let t=e.required;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function J(e,t,n){let r=G(e,t);if(n>H)return null;if(`default`in r)return r.default;if(`const`in r)return r.const;let i=r.enum;if(Array.isArray(i)&&i.length>0)return i[0];let a=[...W(r.anyOf),...W(r.oneOf)];if(a.length>0){let e=a.find(e=>!K(G(e,t)).includes(`null`))??a[0];return e===void 0?null:J(e,t,n+1)}let o=W(r.allOf);if(o.length>0)return o.reduce((e,r)=>{let i=J(r,t,n+1);return U(e)&&U(i)?{...e,...i}:i},{});switch(K(r).find(e=>e!==`null`)){case`object`:return Y(r,t,n);case`array`:return[];case`string`:return``;case`number`:case`integer`:return typeof r.minimum==`number`?r.minimum:0;case`boolean`:return!1;default:return U(r.properties)?Y(r,t,n):null}}function Y(e,t,n){let r=U(e.properties)?e.properties:{},i={};for(let a of q(e)){let e=r[a];i[a]=U(e)?J(e,t,n+1):null}return i}function De(e){if(e!==null)return J(e,e,0)}function Oe(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e==`number`?Number.isInteger(e)?`integer`:`number`:typeof e}function ke(e,t){let n=Oe(e);return n===t||t===`number`&&n===`integer`}function X(e,t){return e===``?String(t):`${e}.${t}`}function Z(e,t,n,r,i){let a=G(t,n);if(i>H*2)return[];let o=[...W(a.anyOf),...W(a.oneOf)];if(o.length>0&&!o.some(t=>Z(e,t,n,r,i+1).length===0))return[{path:r,code:`no-branch`,expected:`${o.length}`}];let s=[];for(let t of W(a.allOf))s.push(...Z(e,t,n,r,i+1));let c=K(a);if(c.length>0&&!c.some(t=>ke(e,t)))return[...s,{path:r,code:`type`,expected:c.join(` | `)}];`const`in a&&JSON.stringify(a.const)!==JSON.stringify(e)&&s.push({path:r,code:`const`,expected:JSON.stringify(a.const)});let l=a.enum;if(Array.isArray(l)){let t=l.map(e=>JSON.stringify(e));t.includes(JSON.stringify(e))||s.push({path:r,code:`enum`,expected:t.join(`, `)})}if(typeof e==`number`&&s.push(...Ae(e,a,r)),typeof e==`string`&&s.push(...je(e,a,r)),Array.isArray(e)&&U(a.items)){let t=a.items;e.forEach((e,a)=>s.push(...Z(e,t,n,X(r,a),i+1)))}return U(e)&&s.push(...Me(e,a,n,r,i)),s}function Ae(e,t,n){let r=[],i=t.minimum,a=t.maximum;return typeof i==`number`&&e<i&&r.push({path:n,code:`minimum`,expected:`${i}`}),typeof a==`number`&&e>a&&r.push({path:n,code:`maximum`,expected:`${a}`}),r}function je(e,t,n){let r=[],i=t.minLength,a=t.maxLength;return typeof i==`number`&&e.length<i&&r.push({path:n,code:`min-length`,expected:`${i}`}),typeof a==`number`&&e.length>a&&r.push({path:n,code:`max-length`,expected:`${a}`}),r}function Me(e,t,n,r,i){let a=[],o=U(t.properties)?t.properties:{};for(let n of q(t))n in e||a.push({path:X(r,n),code:`required`,expected:n});for(let[s,c]of Object.entries(e)){let e=o[s];U(e)?a.push(...Z(c,e,n,X(r,s),i+1)):t.additionalProperties===!1&&a.push({path:X(r,s),code:`unknown-field`,expected:s})}return a}function Ne(e,t){return t===null?[]:Z(e,t,t,``,0)}function Pe(e){if(e.trim()===``)return{ok:!0,value:void 0};try{return{ok:!0,value:JSON.parse(e)}}catch(e){return{ok:!1,message:e instanceof Error?e.message:String(e)}}}function Q(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Fe(e){let t=`${e.hubBase}/trpc/${e.path}`,n=`-H "Authorization: Bearer $CAMSTACK_TOKEN"`,r=e.input===void 0?null:JSON.stringify({json:e.input});if(e.kind===`mutation`){let e=r??JSON.stringify({json:null});return[`curl -sS -X POST ${n} \\`,` -H 'Content-Type: application/json' \\`,` --data ${Q(e)} \\`,` ${Q(t)}`].join(`
|
|
2
|
+
`)}return`curl -sS ${n} \\\n ${Q(`${t}${r===null?``:`?input=${encodeURIComponent(r)}`}`)}`}function $(e,t){let n=e[t];return typeof n==`string`?n:null}function Ie(e){let t=e instanceof Error?e.message:String(e),n=U(e)||e instanceof Error?Reflect.get(e,`data`):void 0;if(!U(n))return{message:t,code:null,httpStatus:null,path:null,capRouteReason:null};let r=n.httpStatus;return{message:t,code:$(n,`code`),httpStatus:typeof r==`number`?r:null,path:$(n,`path`),capRouteReason:$(n,`capRouteReason`)}}function Le(e){if(e===void 0)return`undefined`;try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}var Re={searchText:e=>[e.path,e.scope?.capName??``],facetGroups:[{id:`router`,value:e=>e.router},{id:`kind`,value:e=>e.kind},{id:`tier`,value:e=>e.tier},{id:`source`,value:e=>e.source}]},ze={query:`info`,mutation:`warning`,subscription:`neutral`},Be={public:`success`,protected:`neutral`,admin:`primary`};function Ve({kind:e}){let{t}=z();return i(N,{variant:ze[e],size:`sm`,children:t(`system.apiExplorer.kind.${e}`)})}function He({tier:e}){let{t}=z();return i(N,{variant:Be[e],style:`outline`,size:`sm`,children:t(`system.apiExplorer.tier.${e}`)})}function Ue({methods:t,selectedPath:n,onSelect:r}){let{t:a}=z(),o=ge(t,Re),s=e=>a(`system.apiExplorer.group.${e}`),c=e=>t=>e===`router`?t:a(`system.apiExplorer.${e}.${t}`),l=[{key:`path`,header:a(`system.apiExplorer.column.method`),sortValue:e=>e.path,render:t=>e(`span`,{className:`font-mono text-xs`,children:[e(`span`,{className:`text-foreground-muted`,children:[t.router,`.`]}),i(`span`,{className:`text-foreground`,children:t.method})]})},{key:`kind`,header:a(`system.apiExplorer.column.kind`),sortValue:e=>e.kind,render:e=>i(Ve,{kind:e.kind})},{key:`tier`,header:a(`system.apiExplorer.column.tier`),sortValue:e=>e.tier,render:e=>i(He,{tier:e.tier})},{key:`scope`,header:a(`system.apiExplorer.column.scope`),sortValue:e=>e.scope===null?null:`${e.scope.capName}:${e.scope.access}`,render:t=>t.scope===null?i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`system.apiExplorer.coreRoute`)}):e(`span`,{className:`font-mono text-xs text-foreground-muted`,children:[t.scope.capName,` · `,t.scope.access]})}];return e(`div`,{className:`space-y-3`,children:[i(ie,{state:o.state,facets:o.facets,groups:o.groups.map(e=>({...e,label:s(e.id),facetLabel:c(e.id),...e.id===`router`?{display:`menu`}:{}})),labels:{searchPlaceholder:a(`system.apiExplorer.searchPlaceholder`),searchLabel:a(`system.apiExplorer.searchLabel`),facetsLabel:a(`system.apiExplorer.facetsLabel`),clearLabel:a(`system.apiExplorer.clearFilters`)},onSearch:o.setSearch,onToggleFacet:o.toggleFacet,onToggleGroupFacet:o.toggleGroupFacet,onClear:o.clear}),i(le,{columns:l,rows:o.rows,rowKey:e=>e.path,onRowClick:e=>r(e.path),rowClassName:e=>e.path===n?`bg-primary/10`:void 0,minWidthPx:560,maxBodyHeight:ve,defaultSort:{columnKey:`path`,dir:`asc`},emptyMessage:o.active?a(`system.apiExplorer.noMatch`):a(`system.apiExplorer.noMethods`)})]})}var We={yes:`success`,"per-device":`warning`,no:`danger`},Ge={yes:`system.apiExplorer.callableYes`,"per-device":`system.apiExplorer.callablePerDevice`,no:`system.apiExplorer.callableNo`};function Ke(e){let t=De(e);return t===void 0?``:JSON.stringify(t,null,2)}function qe({method:t}){let{t:r}=z(),s=b(),c=te(R.useUtils().client),l=R.apiCatalog.inputSchema.useQuery({path:t.path},{enabled:t.hasInput,staleTime:1/0}),u=l.data?.schema??null,[d,f]=o(``),[m,h]=o(null),[g,v]=o(!1);a(()=>{f(Ke(u))},[u]);let x=n(()=>Pe(d),[d]),C=x.ok?Ne(x.value,u):[],w=t.kind!==`subscription`&&t.callable!==`no`,T=w&&x.ok&&C.length===0&&!g,E=t.kind===`mutation`?`mutation`:`query`,D=Fe({hubBase:_(),path:t.path,kind:E,input:x.ok?x.value:void 0}),O=async()=>{if(!x.ok||t.kind===`mutation`&&!await s({title:r(`system.apiExplorer.confirmTitle`),message:r(`system.apiExplorer.confirmMessage`,{method:t.path}),confirmLabel:r(`system.apiExplorer.run`),variant:`danger`}))return;v(!0);let e=performance.now();try{h({kind:`ok`,value:E===`mutation`?await c.mutation(t.path,x.value):await c.query(t.path,x.value),ms:performance.now()-e})}catch(t){h({kind:`error`,error:Ie(t),ms:performance.now()-e})}finally{v(!1)}};return i(A,{headingId:`api-explorer-method`,title:r(`system.apiExplorer.column.method`),icon:S,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(Ve,{kind:t.kind}),i(He,{tier:t.tier})]}),children:e(`div`,{className:`space-y-4 p-3 sm:p-4`,children:[i(`p`,{className:`break-all font-mono text-sm text-foreground`,children:t.path}),i(j,{items:[{key:r(`system.apiExplorer.column.scope`),value:t.scope===null?r(`system.apiExplorer.coreRouteLong`):r(`system.apiExplorer.scopeValue`,{cap:t.scope.capName,access:t.scope.access,capScope:t.scope.capScope})},{key:r(`system.apiExplorer.callable`),value:i(N,{variant:We[t.callable],size:`sm`,children:r(Ge[t.callable])})}]}),t.kind===`subscription`&&i(`p`,{className:`text-sm text-foreground-muted`,children:r(`system.apiExplorer.subscriptionNote`)}),t.hasInput&&i(Je,{loading:l.isPending,error:l.error?.message??l.data?.error??null,schema:u}),w&&e(`div`,{className:`space-y-2`,children:[i(`label`,{htmlFor:`api-explorer-input`,className:`text-xs font-medium text-foreground-muted`,children:r(`system.apiExplorer.input`)}),i(pe,{id:`api-explorer-input`,value:d,onChange:e=>f(e.target.value),rows:t.hasInput?8:2,spellCheck:!1,placeholder:t.hasInput?void 0:r(`system.apiExplorer.noInput`),state:x.ok&&C.length===0?`default`:`error`,className:`font-mono text-xs`}),i(Ye,{parseError:x.ok?null:x.message,issues:C}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(P,{onClick:()=>void O(),disabled:!T,children:[i(y,{className:`h-3.5 w-3.5`}),r(g?`system.apiExplorer.running`:`system.apiExplorer.run`)]}),t.hasInput&&e(P,{variant:`ghost`,onClick:()=>f(Ke(u)),children:[i(p,{className:`h-3.5 w-3.5`}),r(`system.apiExplorer.resetInput`)]})]})]}),m!==null&&i(Xe,{outcome:m}),t.kind!==`subscription`&&e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground-muted`,children:r(`system.apiExplorer.curl`)}),i(re,{value:D,label:r(`system.apiExplorer.copy`),srLabel:r(`system.apiExplorer.curl`)})]}),i(L,{maxHeight:200,children:D}),i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`system.apiExplorer.curlHint`)})]})]})})}function Je({loading:t,error:n,schema:r}){let{t:a}=z();return e(`div`,{className:`space-y-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground-muted`,children:a(`system.apiExplorer.inputSchema`)}),t?i(I,{className:`h-24 w-full`}):n===null?i(L,{maxHeight:240,children:Le(r)}):i(k,{variant:`warning`,message:a(`system.apiExplorer.schemaUnavailable`,{error:n})})]})}function Ye({parseError:t,issues:n}){let{t:r}=z();return t===null&&n.length===0?null:e(`ul`,{className:`space-y-0.5 text-xs text-danger`,role:`alert`,children:[t!==null&&i(`li`,{children:r(`system.apiExplorer.invalidJson`,{error:t})}),n.map(e=>i(`li`,{children:r(`system.apiExplorer.issue.${e.code}`,{path:e.path===``?r(`system.apiExplorer.rootPath`):e.path,expected:e.expected})},`${e.path}:${e.code}`))]})}function Xe({outcome:t}){let{t:n}=z(),r=n(`system.apiExplorer.duration`,{ms:Math.round(t.ms)});if(t.kind===`ok`)return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground-muted`,children:n(`system.apiExplorer.result`)}),i(N,{variant:`success`,size:`sm`,children:r})]}),i(L,{maxHeight:400,children:Le(t.value)})]});let{error:a}=t,o=[{key:n(`system.apiExplorer.errorCode`),value:a.code},{key:n(`system.apiExplorer.errorStatus`),value:a.httpStatus},{key:n(`system.apiExplorer.errorPath`),value:a.path},{key:n(`system.apiExplorer.errorCapRoute`),value:a.capRouteReason}].flatMap(e=>e.value===null?[]:[{key:e.key,value:String(e.value)}]);return i(k,{title:`${n(`system.apiExplorer.callFailed`)} · ${r}`,message:e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`break-words`,children:a.message}),o.length>0&&i(j,{items:o})]})})}c();function Ze(){let{t:n}=z(),[o,s]=Ce(),c=o.get(V),l=R.apiCatalog.list.useQuery(void 0,{staleTime:1/0}),u=t(null),d=l.data?.methods.find(e=>e.path===c)??null,f=r(e=>{s(t=>{let n=new URLSearchParams(t);return n.set(V,e),n},{replace:!0})},[s]),p=d?.path??null;return a(()=>{p!==null&&u.current?.scrollIntoView?.({block:`start`,behavior:`smooth`})},[p]),i(B,{embedded:!0,icon:S,title:n(`system.apiExplorer.title`),subtitle:n(`system.apiExplorer.subtitle`),children:l.isPending?i(I,{className:`h-64 w-full`}):l.error===null?e(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[i(A,{headingId:`api-explorer-methods`,title:n(`system.apiExplorer.methodsTitle`,{count:l.data.methods.length}),children:i(`div`,{className:`p-3 sm:p-4`,children:i(Ue,{methods:l.data.methods,selectedPath:c,onSelect:f})})}),i(`div`,{ref:u,className:`min-w-0 scroll-mt-4`,children:d===null?c===null?i(F,{icon:w,title:n(`system.apiExplorer.pickTitle`),description:n(`system.apiExplorer.pickDescription`)}):i(k,{variant:`warning`,message:n(`system.apiExplorer.unknownMethod`,{method:c})}):i(qe,{method:d},d.path)})]}):i(k,{title:n(`system.apiExplorer.couldNotLoad`),message:l.error.message,onRetry:()=>void l.refetch()})})}var Qe={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},$e={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function et({entry:t,actions:n}){let r=t.name.toLowerCase(),a=Qe[r]??`border-primary`,o=$e[r]??`bg-primary/5`,s=t.providers.find(e=>e.active),c=n?.pendingCapability===t.name;return e(`div`,{className:`rounded-lg border-t-2 border border-border ${a} ${o} p-3 space-y-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[e(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[t.name,c&&i(E,{className:`h-3 w-3 animate-spin text-primary`})]}),i(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${t.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:t.mode})]}),t.mode===`singleton`?i(tt,{entry:t,actions:n,activeProvider:s,isPending:c}):i(nt,{entry:t,actions:n,isPending:c})]})}function tt({entry:t,actions:n,activeProvider:r,isPending:a}){let{t:o}=z();if(!n)return i(`div`,{children:r?e(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[i(v,{className:`h-3 w-3 text-green-400 shrink-0`}),i(`span`,{className:`font-medium`,children:r.addonName}),i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):i(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noActiveProvider`,`No active provider`)})});if(t.providers.length===0)return i(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noProviders`,`No providers`)});let s=`__inherit__`;return e(`div`,{className:`space-y-2`,children:[i(`div`,{className:`space-y-1`,children:t.providers.map(r=>{let o=r.active;return e(P,{variant:`unstyled`,type:`button`,disabled:a||o,onClick:()=>n.onSelectSingleton(t.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${o?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[i(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${o?`border-green-400 bg-green-400`:`border-border`}`}),i(`span`,{className:`font-medium truncate`,children:r.addonName}),o&&i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},r.addonId)})}),t.perNode&&t.perNode.length>0&&i(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:t.perNode.map(r=>{let c=r.hasOverride&&r.resolvedActive?r.resolvedActive:s,l=[{value:s,label:r.resolvedActive?o(`addons.capabilityMap.inheritGlobalWith`,{provider:r.resolvedActive}):o(`addons.capabilityMap.inheritGlobal`)},...r.providers.map(e=>({value:e,label:e}))],u=e=>{e===s?n.onClearNodeSingleton(t.name,r.nodeId):n.onSelectNodeSingleton(t.name,r.nodeId,e)},d=a;return e(`div`,{className:`space-y-0.5`,children:[e(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&i(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:o(`common.override`)})]}),l.map(t=>{let n=c===t.value;return e(P,{variant:`unstyled`,type:`button`,disabled:d||n,onClick:()=>u(t.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[i(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),i(`span`,{className:`font-medium truncate`,children:t.label}),n&&t.value!==s&&i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},t.value)})]},r.nodeId)})})]})}function nt({entry:t,actions:n,isPending:r}){let{t:a}=z();if(t.providers.length===0)return i(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:a(`addons.capabilityMap.noProviders`,`No providers`)});if(!n)return i(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[i(`span`,{className:`text-foreground-subtle`,children:t.addonName}),t.active&&i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},t.addonId))});let o=t.providers.filter(e=>e.active).map(e=>e.addonId),s=(e,r)=>{let i=r?[...new Set([...o,e])]:o.filter(t=>t!==e);n.onToggleCollection(t.name,i)};return i(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${r?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[e(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[i(h,{checked:t.active,disabled:r,onChange:e=>s(t.addonId,e.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),i(`span`,{className:`text-foreground truncate`,children:t.addonName})]}),t.active&&i(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},t.addonId))})}function rt({capabilities:e,actions:t}){let{t:n}=z();return e.length===0?i(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:n(`addons.capabilityMap.noCapabilitiesRegistered`,`No capabilities registered`)}):i(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>i(et,{entry:e,actions:t},e.name))})}c();var it=[`capabilities`,`listCapabilities`];function at(e){return e===`singleton`||e===`collection`}function ot(e){let t=e.indexOf(`@`);return t===-1?ye.t(`system.capabilities.providerHub`,{addonId:e}):`${e.slice(0,t)} (${e.slice(t+1)})`}function st(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:ot(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function ct(){let{t}=z(),r=T(),[a,c]=o(null),[l,f]=o(null),p=s({queryKey:it,queryFn:()=>r.trpcClient.capabilities.listCapabilities.query()}),m=n(()=>{let e=(p.data??[]).flatMap(e=>at(e.mode)?[st(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[p.data]),h=n(()=>m.filter(e=>e.mode===`singleton`),[m]),g=n(()=>m.filter(e=>e.mode===`collection`),[m]),_=u({mutationFn:e=>r.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,n)=>{f({kind:`success`,message:t(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:n.capName,addonId:n.addonId})}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToSet`,{cap:n.capName,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),y=u({mutationFn:e=>r.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToSetOnNode`,{cap:n.capName,node:n.nodeId,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),b=u({mutationFn:e=>r.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,n)=>{f({kind:`success`,message:t(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:n.capName,nodeId:n.nodeId})}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToClearOnNode`,{cap:n.capName,node:n.nodeId,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),x=u({mutationFn:e=>r.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,n)=>{f({kind:`success`,message:t(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:n.capName,length:n.enabledAddonIds.length})}),await p.refetch()},onError:(e,n)=>{f({kind:`error`,message:t(`system.capabilities.failedToUpdate`,{cap:n.capName,error:e instanceof Error?e.message:t(`common.unknownError`)})})},onSettled:()=>c(null)}),S={onSelectSingleton:(e,t)=>_.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>y.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>b.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>x.mutate({capName:e,enabledAddonIds:t}),pendingCapability:a};return e(B,{embedded:!0,icon:C,title:t(`system.capabilities.capabilities`,`Capabilities`),subtitle:t(`system.capabilities.chooseWhichProviderIsActive`,`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`),children:[l&&e(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${l.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[l.kind===`success`?i(v,{className:`h-3.5 w-3.5 shrink-0`}):i(d,{className:`h-3.5 w-3.5 shrink-0`}),i(`span`,{children:l.message})]}),p.isLoading&&i(`div`,{className:`flex items-center justify-center py-16`,children:i(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),p.isError&&!p.isLoading&&i(k,{title:t(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:p.error instanceof Error?p.error.message:t(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void p.refetch()}),!p.isLoading&&!p.isError&&m.length===0&&i(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:t(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!p.isLoading&&!p.isError&&m.length>0&&e(`div`,{className:`space-y-6`,children:[h.length>0&&e(`section`,{className:`space-y-2`,children:[i(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:t(`system.capabilities.singletonPickOneProvider`,`Singleton — pick one provider`)}),i(rt,{capabilities:h,actions:S})]}),g.length>0&&e(`section`,{className:`space-y-2`,children:[i(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:t(`system.capabilities.collectionEnableASet`,`Collection — enable a set`)}),i(rt,{capabilities:g,actions:S})]})]})]})}var lt={escape:`Esc`,enter:`Enter`};function ut(e,t){let n=ne(e),r=lt[n.key]??n.key.toUpperCase();return t===`mac`?`${n.alt?`⌥`:``}${n.shift?`⇧`:``}${n.mod?`⌘`:``}${r}`:[...n.mod?[`Ctrl`]:[],...n.alt?[`Alt`]:[],...n.shift?[`Shift`]:[],r].join(`+`)}function dt(){let{t}=z(),n=ce(),r=_e();return i(A,{headingId:`settings-hotkeys`,title:t(`systemPage.settings.hotkeys.title`,`Keyboard shortcuts`),icon:O,testId:`settings-hotkeys`,children:e(`div`,{className:`space-y-2 p-3`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.settings.hotkeys.description`,`The shortcuts active on this page. They cannot be changed.`)}),n.length===0?i(F,{title:t(`systemPage.settings.hotkeys.empty`,`No shortcuts are active on this page.`)}):n.map(e=>i(M,{label:e.label??t(`systemPage.settings.hotkeys.unnamed`,`Shortcut`),children:i(`kbd`,{className:`rounded-md border border-border bg-surface px-1.5 py-0.5 font-mono text-xs text-foreground`,children:ut(e.combo,r)})},`${e.scope}|${e.combo}`))]})})}c();var ft=[[`system`]];function pt(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function mt(){let{t}=z(),n=l(),r=se(),s=ae(),c=fe(),[u,d]=o(``),[f,p]=o(``),[h,_]=o(null),v=r.data?.location??null;a(()=>{d(v===null?``:pt(v.latitude)),p(v===null?``:pt(v.longitude))},[v]);let y=async()=>{await n.invalidateQueries({queryKey:ft})},b=async e=>{e.preventDefault();let t=Number(u),n=Number(f);if(u.trim()===``||f.trim()===``){_(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){_(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){_(`Longitude must be between -180 and 180 decimal degrees.`);return}_(null),await s.mutateAsync({latitude:t,longitude:n}),await y()},x=async()=>{_(null),await s.mutateAsync(null),await y()},S=async()=>{_(null),await c.mutateAsync(),await y()},C=s.isPending||c.isPending||r.isLoading;return e(he,{className:`space-y-3`,children:[e(`div`,{className:`flex items-start justify-between gap-3`,children:[e(`div`,{className:`flex items-start gap-2`,children:[i(m,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),i(`div`,{children:i(`h3`,{className:`text-sm font-medium`,children:t(`settings.siteLocationCard.siteLocation`,`Site location`)})})]}),v===null?i(N,{variant:`warning`,children:t(`settings.siteLocationCard.notConfigured`,`Not configured`)}):i(N,{variant:v.source===`operator-set`?`success`:`info`,children:v.source===`operator-set`?t(`settings.siteLocationCard.setByYou`,`Set by you`):t(`settings.siteLocationCard.derivedFromIp`,`Derived from IP`)})]}),v?.label!==void 0&&v.label!==``?i(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.detectedNear`,{place:v.label})}):null,v===null&&r.data?.derivationAttemptedAt!==null?e(`p`,{className:`text-xs text-warning`,children:[t(`settings.siteLocationCard.automaticDetectionFromThePublic`,`Automatic detection from the public IP did not succeed`),r.data?.derivationError!==null&&r.data?.derivationError!==void 0?`: ${r.data.derivationError}`:`.`,` `,t(`settings.siteLocationCard.itIsNotRetriedOn`,`It is not retried on its own — enter the coordinates, or press Detect.`)]}):null,e(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:b,children:[e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[i(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.latitude`,`Latitude`)}),i(ue,{className:`w-40`,value:u,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>d(e.target.value),"aria-label":t(`settings.siteLocationCard.latitude`,`Latitude`)})]}),e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[i(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.longitude`,`Longitude`)}),i(ue,{className:`w-40`,value:f,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>p(e.target.value),"aria-label":t(`settings.siteLocationCard.longitude`,`Longitude`)})]}),i(P,{type:`submit`,disabled:C,children:t(`common.save`,`Save`)}),e(P,{type:`button`,variant:`ghost`,disabled:C,onClick:S,children:[i(g,{className:`h-3.5 w-3.5 mr-1`}),t(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),v===null?null:i(P,{type:`button`,variant:`ghost`,disabled:C,onClick:x,children:t(`settings.siteLocationCard.clear`,`Clear`)})]}),h===null?null:i(`p`,{className:`text-xs text-danger`,children:h}),i(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.wgs84DecimalDegreesDetectAsks`,`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`)})]})}c();function ht(e){return D.some(t=>t===e)}function gt(e){return oe.some(t=>t===e)}function _t(){let{t}=z(),n=me(),[r,a]=o(!1),[s,c]=o(null),l=e=>{a(!0),c(null),n.update(e).catch(e=>c(e instanceof Error?e.message:String(e))).finally(()=>a(!1))},u=n.status!==`ok`||!n.writable||r;return i(A,{headingId:`settings-units`,title:t(`systemPage.myAccess.units.title`,`Units`),icon:ee,testId:`settings-units`,children:e(`div`,{className:`space-y-2 p-3`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.units.description`,`How readings are shown to you, on every device you sign in on. Stored values do not change.`)}),n.status===`error`&&i(k,{message:t(`systemPage.myAccess.units.loadError`,`Your unit preferences could not be read.`)}),n.status===`ok`&&!n.writable&&i(k,{message:t(`systemPage.myAccess.units.unreadable`,`The saved unit preferences are in a format this version cannot read, so they are left untouched.`)}),s!==null&&i(k,{message:s}),i(M,{label:t(`systemPage.myAccess.units.temperature`,`Temperature`),children:i(x,{"aria-label":t(`systemPage.myAccess.units.temperature`,`Temperature`),value:n.value.temperature,disabled:u,onChange:e=>{let t=e.target.value;gt(t)&&l({temperature:t})},options:[{value:`celsius`,label:t(`systemPage.myAccess.units.celsius`,`Celsius (°C)`)},{value:`fahrenheit`,label:t(`systemPage.myAccess.units.fahrenheit`,`Fahrenheit (°F)`)}]})}),i(M,{label:t(`systemPage.myAccess.units.system`,`Other measurements`),children:i(x,{"aria-label":t(`systemPage.myAccess.units.system`,`Other measurements`),value:n.value.system,disabled:u,onChange:e=>{let t=e.target.value;ht(t)&&l({system:t})},options:[{value:`metric`,label:t(`systemPage.myAccess.units.metric`,`Metric (km/h, hPa, mm)`)},{value:`imperial`,label:t(`systemPage.myAccess.units.imperial`,`Imperial (mph, inHg, in)`)}]})})]})})}function vt(){let{t}=z(),{nodes:n,isLoading:r}=de(),a=n.find(e=>e.isHub&&e.isOnline);return e(B,{embedded:!0,children:[i(mt,{}),r?i(`div`,{className:`text-foreground-subtle text-sm py-12 text-center`,children:t(`admin.system.settings.loadingHubTopology`,`Loading hub topology…`)}):a?i(Ee,{emptyMessage:t(`admin.system.settings.bootstrapUnavailable`,`Not available — the addon that owns the server settings did not answer.`)}):e(`div`,{className:`flex flex-col items-center justify-center text-foreground-subtle text-sm gap-2 py-12`,children:[i(f,{className:`h-8 w-8 opacity-30`}),i(`p`,{children:t(`admin.system.settings.noOnlineHubNodeFound`,`No online hub node found.`)}),i(`p`,{className:`text-xs`,children:t(`admin.system.settings.settingsWillAppearOnceThe`,`Settings will appear once the hub is reachable.`)})]}),e(`section`,{"aria-labelledby":`settings-per-user`,className:`mt-3 sm:mt-4 space-y-3 sm:space-y-4`,children:[i(`h2`,{id:`settings-per-user`,className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:t(`systemPage.settings.perUser`,`Your settings`)}),i(_t,{}),i(dt,{})]})]})}function yt(){let{t:e}=z(),t=xe(`/system/settings`,{t:e,isAdmin:!0})??{icon:f,title:e(`system.systemNav`,`System`)},{search:n,hash:r}=we();return new URLSearchParams(n).get(`tab`)===`secrets`?i(Se,{replace:!0,to:`${be(n)}${r}`}):i(Te,{icon:t.icon,title:t.title,defaultSection:`settings`,sectionsLabel:`${t.title} sections`,sections:[{id:`settings`,label:e(`system.system.settings`,`Settings`),content:i(vt,{})},{id:`capabilities`,label:e(`system.system.capabilities`,`Capabilities`),content:i(ct,{})},{id:`api-explorer`,label:e(`system.system.apiExplorer`),content:i(Ze,{}),ownedParams:[`method`]}]})}export{yt as SystemPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,i as l,o as u,q as d,x as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as p,Ga as m,Qa as h,Ra as g,Ua as _,Va as v,ft as y,ir as b,qt as x,tn as S,yt as C}from"./player-overlays-BKR7fWEx.js";import{An as w,Dr as T,Er as E,Ga as ee,Jr as D,Ka as te,Lr as ne,On as re,Pn as ie,Rr as ae,Vs as oe,Wa as se,Zs as O,es as k,gc as A,jn as ce,kn as j,qr as M,zr as N}from"./client-BDuXx1QP.js";import{n as le,t as P}from"./shapes-D4IRNSXI.js";import{t as ue}from"./unlink-D3-IGpS8.js";import{$n as de,Bn as fe,D as pe,Da as me,Dp as he,Ea as ge,Ep as F,Fn as _e,Gn as ve,Hf as ye,Hi as be,Hn as xe,In as Se,Ji as Ce,Jn as we,Ki as Te,Kn as Ee,Kt as I,Ln as De,Lp as Oe,O as ke,Pn as Ae,Qn as je,Rf as Me,Rn as Ne,T as Pe,Ta as Fe,Tp as L,Ui as Ie,Un as R,Vn as Le,Wi as Re,Xn as ze,Xs as Be,Yd as Ve,Yn as He,Zn as Ue,_p as z,ar as B,ba as We,ca as Ge,ci as Ke,cr as qe,di as Je,er as Ye,ir as Xe,k as Ze,ka as V,li as Qe,nr as $e,or as et,pp as tt,q as nt,qi as rt,qn as it,rr as at,rt as ot,sr as st,tr as H,ts as ct,ui as lt,ut as U,v as ut,wa as dt,zn as ft}from"./src-BnZKlAAn.js";import{t as W}from"./useTranslation-BJr-n0es.js";import{a as pt,c as mt,d as ht,f as gt,i as _t,l as vt,n as yt,o as bt,r as xt,u as St}from"./command-vocab-BvTOW30-.js";import{At as Ct,Ct as wt,St as Tt,kt as Et,wt as Dt,xt as Ot}from"./CompositionBlockEditor-CAYxLM7D.js";c();function G(e){return e.kind===`dynamic`}function kt(e){return e.replace(/-([a-z0-9])/g,(e,t)=>t.toUpperCase())}function K(e,t){return t.from===`status`&&t.cap!==void 0?t.cap:e}function q(e){return e.from===`method`?e.method:`getStatus`}function J(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function At(e){return typeof e==`string`||typeof e==`number`}function jt(e,t){let n=t.from===`status`?J(e,t.field):e;if(!Array.isArray(n))return[];let r=[];for(let e of n){if(t.where!==void 0&&J(e,t.where.key)!==t.where.equals)continue;let n=t.valueKey===void 0?e:J(e,t.valueKey);if(!At(n))continue;let i=t.labelKey===void 0?n:J(e,t.labelKey);r.push({value:n,label:At(i)?String(i):String(n)})}return r}function Mt(e,t){let n=t.from===`status`?J(e,t.field):e;return Array.isArray(n)?{kind:`answered`,choiceCount:jt(e,t).length}:{kind:`failed`}}var Nt=3e4;function Pt(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`query`)==`function`}function Ft(e,t,n,r){return{queryKey:[`build`,`dynamic-offer`,t,n,r],staleTime:Nt,retry:!1,queryFn:async()=>{let i=typeof e==`object`&&e?Reflect.get(e,kt(n)):void 0,a=typeof i==`object`&&i?Reflect.get(i,r):void 0;if(!Pt(a)||t===null)throw Error(`no readable ${n}.${r}`);return a.query({deviceId:t})}}}function Y(e,t){return`${e}.${t}`}function It(e){let t=new Map;for(let n of e)for(let e of n.openArgs){if(!G(e.offer))continue;let r=K(n.cap,e.offer),i=q(e.offer),a=Y(r,i);t.has(a)||t.set(a,{key:a,readCap:r,read:i,offer:e.offer})}return[...t.values()]}function Lt(e,t){let n=C(),r=It(t),i=l({queries:r.map(t=>({...Ft(n.trpcClient,e,t.readCap,t.read),enabled:e!==null&&e>0}))}),a=new Map;return r.forEach((e,t)=>{let n=i[t];n===void 0||n.isPending?a.set(e.key,{kind:`pending`}):n.isError?a.set(e.key,{kind:`failed`}):a.set(e.key,Mt(n.data,e.offer))}),(e,t)=>a.get(Y(K(e,t),q(t)))??{kind:`pending`}}function Rt(e){let t=new Map;for(let n of e){if(n.offeredWhen===null)continue;let e=`${Y(n.cap,n.offeredWhen.method)}#${n.offeredWhen.field}`;t.has(e)||t.set(e,{key:e,cap:n.cap,gate:n.offeredWhen})}return[...t.values()]}function zt(e,t){let n=C(),r=Rt(t),i=l({queries:r.map(t=>({...Ft(n.trpcClient,e,t.cap,t.gate.method),enabled:e!==null&&e>0}))}),a=new Map;return r.forEach((e,t)=>{let n=i[t];n===void 0||n.isPending?a.set(e.key,{kind:`pending`}):n.isError?a.set(e.key,{kind:`failed`}):a.set(e.key,re(n.data,e.gate))}),(e,t)=>a.get(`${Y(e,t.method)}#${t.field}`)??{kind:`pending`}}function Bt(e,t,n){let r=C(),i=n===null?``:q(n),a=n===null?t:K(t,n),o=s({...Ft(r.trpcClient,e,a,i),enabled:e!==null&&e>0&&n!==null});if(n===null||e===null)return{state:`unavailable`};if(o.isPending)return{state:`loading`};if(o.isError)return{state:`unavailable`};let c=jt(o.data,n);return c.length===0?{state:`unavailable`}:{state:`ready`,choices:c}}var Vt=`deviceId`;function Ht(e){return j(e.caps,e.type)}function Ut(e){let[t,...n]=e;if(t===void 0)return[];let r=n.map(e=>new Set(e.map(e=>e.id)));return t.filter(e=>r.every(t=>t.has(e.id))&&(n.length===0||!Wt(e)))}function Wt(e){return e.openArgs.some(e=>e.offer.kind===`dynamic`)}function Gt(e){let t=new Map;for(let n of e)for(let e of Ht(n))t.has(e.id)||t.set(e.id,e);return[...t.values()]}function Kt(e,t){return e.filter(e=>w(e.caps,[t],`any`,e.type))}function qt(e,t){return e.find(e=>e.id===t)??{id:t,caps:[]}}function Jt(e,t,n){if(t===null)return[];if(t.kind===`devices`)return t.ids.length===0?[]:Ut(t.ids.map(t=>Ht(qt(e,t))));if(t.kind===`var`&&t.name===`deviceId`)return Gt(e).filter(e=>!Wt(e));if(t.kind===`var`&&t.name===`item`){let t=n.roundDevices??[];return t.length===0?[]:Ut(t.map(t=>Ht(qt(e,t))))}return[]}function Yt(e){let t=new Map;for(let n of e)t.set(n.cap,[...t.get(n.cap)??[],n]);return[...t.entries()].map(([e,t])=>({cap:e,actions:t}))}function Xt(e,t,n,r){let i=Zt(r.trim());return i===``?!0:[e.label[t],e.phrase[t],n,e.id].some(e=>Zt(e).includes(i))}function Zt(e){return e.normalize(`NFD`).replace(/\p{Diacritic}/gu,``).toLowerCase()}function X(e){return e?.kind===`devices`?e.ids:[]}function Qt(e,t,n,r){return n===null?null:Jt(e,t,r).some(e=>e.id===n)?n:null}function $t(e,t,n){if(t?.kind!==`devices`)return t;let r=new Set(Kt(e,n).map(e=>e.id)),i=t.ids.filter(e=>r.has(e));return i.length===0?null:{kind:`devices`,ids:i}}function en(e){return e.toLowerCase().startsWith(`it`)?`it`:`en`}function tn(e,t){return e===`error`||t===`error`?`failed`:e===`pending`||t===`pending`?`pending`:`answered`}function nn(e){let t=Be({projection:`slim`}),r=n(()=>{let n=t.status===`success`?Et(t.data):[],r=new Set(e??[]);return n.filter(e=>!r.has(e.type))},[t.status,t.data,e]),i=Ct(r.map(e=>e.id)),a=n(()=>r.map(e=>({id:e.id,type:e.type,caps:i.data?.get(e.id)??[]})),[r,i.data]),o=r.length===0&&t.status===`success`?`success`:i.status;return{rows:r,fleet:a,listState:tn(t.status,o)}}function rn(e,t,n){return Yt(e).map(e=>({cap:e.cap,title:Dt(e.cap,n),rows:e.actions.map(e=>({cap:e.cap,path:e.id,label:e.label[t],valueText:``}))}))}function an({target:t,allowTriggerDevice:n,round:r,onPick:a}){let{t:o}=W(),s=[...n?[{name:Vt,label:o(`customize.sourceSelector.action.triggerDevice`)}]:[],...r?[{name:k,label:o(`customize.sourceSelector.action.roundDevice`)}]:[]];return s.length===0?null:i(`ul`,{className:`flex flex-col gap-1`,"data-testid":`action-pseudo-targets`,children:s.map(n=>i(`li`,{children:e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground`,children:[i(me,{name:`action-pseudo-target`,checked:t?.kind===`var`&&t.name===n.name,"data-testid":`action-target-var-${n.name}`,onChange:()=>a({kind:`var`,name:n.name})}),i(`span`,{children:n.label})]})},n.name))})}function on(e,t){if(e?.kind!==`devices`||e.ids.length<=1||t===void 0||!t.openArgs.some(e=>e.offer.kind===`dynamic`))return e;let n=e.ids[e.ids.length-1];return n===void 0?e:{kind:`devices`,ids:[n]}}function sn({value:t,onChange:r,allowTriggerDevice:a=!1,roundDevices:s,multiple:c=!0,excludeTypes:l,args:u,fillHeight:d=!1}){let{t:f,i18n:p}=W(),m=en(p.language),[h,g]=o(`by-device`),[_,v]=o(`devices`),[y,b]=o(``),{fleet:x,listState:S}=nn(l),C=dt(`command-devices`),w=n(()=>s===void 0?{}:{roundDevices:s},[s]),T=n(()=>Jt(x,t.target,w),[x,t.target,w]),E=t.target?.kind===`devices`&&t.target.ids.length===1?t.target.ids[0]??null:null,ee=Lt(E,T),D=zt(E,T),te=E===null?T:ce(T,ee,D),ne=n(()=>Gt(x),[x]),re=ne.find(e=>e.id===t.actionId),ie=e=>{let n=on(e,h===`by-action`?re:void 0);r({target:n,actionId:h===`by-device`?Qt(x,n,t.actionId,w):t.actionId})},ae=e=>{r({target:h===`by-action`?$t(x,t.target,e):t.target,actionId:e})},oe=h===`by-action`&&t.actionId!==null?{actions:[t.actionId]}:void 0,se=X(t.target).map(e=>({deviceId:e})),O=e(`div`,{className:d?`flex min-h-0 flex-1 flex-col gap-2`:`flex min-h-0 flex-col gap-2`,"data-testid":`action-device-column`,children:[i(`h3`,{className:`text-[11px] font-medium text-foreground-muted`,children:f(`customize.sourceSelector.action.devicesHeading`)}),i(an,{target:t.target,allowTriggerDevice:a&&(h===`by-device`||t.actionId!==null),round:s!==void 0,onPick:ie}),h===`by-action`&&t.actionId===null?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:f(`customize.sourceSelector.action.pickActionFirst`)}):i(Fe,{requires:oe,excludeTypes:l,kind:`device`,multiple:c,picked:se,onSelect:e=>{C.push(e.deviceId);let n=X(t.target),r=c?n.includes(e.deviceId)?n.filter(t=>t!==e.deviceId):[...n,e.deviceId]:n.length===1&&n[0]===e.deviceId?[]:[e.deviceId];ie(r.length===0?null:{kind:`devices`,ids:r})},railFirst:!1,recentIds:C.ids,autoFocus:h===`by-device`,fill:d})]}),k=h===`by-device`?te:ne,A=k.filter(e=>Xt(e,m,Dt(e.cap,p.language),y)),j=e(`div`,{className:`flex min-h-0 flex-col gap-2`,"data-testid":`action-command-column`,children:[i(`h3`,{className:`text-[11px] font-medium text-foreground-muted`,children:f(`customize.sourceSelector.action.actionsHeading`)}),(h===`by-action`||k.length>=8)&&i(L,{type:`search`,value:y,"aria-label":f(`customize.sourceSelector.action.search`),placeholder:f(`customize.sourceSelector.action.search`),"data-testid":`action-search`,onChange:e=>b(e.target.value)}),h===`by-device`&&t.target===null?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:f(`customize.sourceSelector.action.pickDeviceFirst`)}):S===`pending`?i(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:f(`customize.sourceSelector.action.loading`)}):A.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,"data-testid":`action-none`,children:y.trim()===``?X(t.target).length>1?f(`customize.sourceSelector.action.noCommon`):f(`customize.sourceSelector.action.none`):f(`customize.sourceSelector.action.noMatch`,{query:y})}):i(Pe,{name:`action-command`,groups:rn(A,m,p.language),value:t.actionId===null?null:{cap:k.find(e=>e.id===t.actionId)?.cap??``,path:t.actionId},rowTestId:e=>`action-row-${e.path}`,onPick:e=>ae(e.path)})]}),M=h===`by-device`?t.target!==null:t.actionId!==null,N=h===`by-device`?t.target?.kind===`devices`?t.target.ids.length:t.target===null?0:1:t.actionId===null?0:1;return e(`div`,{className:d?`flex min-h-0 flex-1 flex-col gap-3`:`flex flex-col gap-3`,children:[i(nt,{label:f(`customize.sourceSelector.action.mode`),value:h,options:[{value:`by-device`,label:f(`customize.sourceSelector.action.byDevice`)},{value:`by-action`,label:f(`customize.sourceSelector.action.byAction`)}],onChange:e=>{if(e===`by-device`){let e=Qt(x,t.target,t.actionId,w);e!==t.actionId&&r({target:t.target,actionId:e})}g(e),v(`devices`),b(``)}}),i(Ot,{step:_,devices:h===`by-device`?O:j,values:h===`by-device`?j:O,back:M?{label:f(`customize.sourceSelector.backToDevices`),ariaLabel:f(`customize.sourceSelector.backToDevices`)}:null,onBack:()=>v(Tt()),done:{countLabel:f(`customize.sourceSelector.pickedCount`,{count:N}),label:f(`customize.sourceSelector.done`),disabled:!M},onDone:()=>{let e=wt(N);e!==null&&v(e)},fillHeight:d}),u!=null&&t.actionId!==null&&t.target!==null&&i(`div`,{"data-testid":`action-args`,className:`flex max-h-[40%] shrink-0 flex-col gap-2 overflow-y-auto border-t border-border pt-3`,children:u})]})}c();function cn(e){return e===void 0||!Number.isFinite(e)?``:String(e)}function ln({value:e,onValue:t,onBrace:n,onBlur:r,...a}){let[s,c]=o(null);return i(L,{...a,inputMode:`decimal`,value:s??cn(e),onChange:e=>{let r=e.target.value;if(r.includes(`{`)){n?.();return}c(r);let i=r.trim()===``?NaN:Number(r);t(Number.isFinite(i)?i:null)},onBlur:e=>{c(null),r?.(e)}})}function Z({widthClass:e,...t}){return i(`span`,{className:`block max-w-full ${e}`,children:i(y,{...t})})}c();function un(e){return e.kind===`fixed`?String(e.value):``}function dn({arg:t,locale:n,variables:r,value:a,onChange:s,choices:c}){let{t:l}=W(),[u,d]=o(!1),f=t.label[n],p=yt(t,a),m=a.kind===`var`?i(tt,{label:a.name,onRemove:()=>s(_t(t))}):i(fn,{arg:t,locale:n,value:a,onChange:s,onBrace:()=>d(!0),choices:c});return e(`span`,{className:`inline-flex flex-col gap-0.5 align-top`,"data-testid":`arg-${t.key}`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[m,r.length>0&&e(Ke,{open:u,onOpenChange:d,children:[i(Je,{"aria-label":l(`flow.arg.useVariable`,`Use a variable for {{label}}`,{label:f}),className:`h-8 rounded-md border border-border bg-surface px-2 font-mono text-xs text-foreground hover:bg-surface-hover`,children:`{x}`}),i(Qe,{children:r.map(e=>i(lt,{onClick:()=>s({kind:`var`,name:e.name}),children:`${e.name} · ${e.hint}`},e.name))})]})]}),i(mn,{arg:t,value:a,issue:p})]})}function fn({arg:e,locale:t,value:n,onChange:r,onBrace:a,choices:o}){let{t:s}=W(),c=e.offer,l=e.label[t];if(G(c)&&o?.state===`ready`){let t=o.choices.some(e=>e.value===n.value);return i(Z,{widthClass:`w-48`,"aria-label":l,"data-testid":`dynamic-${e.key}`,value:String(n.value),onChange:e=>{let t=o.choices.find(t=>String(t.value)===e.target.value);t!==void 0&&r({kind:`fixed`,value:t.value})},options:[...t?[]:[{value:String(n.value),label:n.value===``?s(`flow.arg.choose`,`Choose…`):String(n.value)}],...o.choices.map(e=>({value:String(e.value),label:e.label}))]})}if(c.kind===`enum`)return i(Z,{widthClass:`w-40`,"aria-label":l,value:String(n.value),onChange:e=>{let t=c.values.find(t=>String(t.value)===e.target.value);t!==void 0&&r({kind:`fixed`,value:t.value})},options:c.values.map(e=>({value:String(e.value),label:e.label[t]}))});if(c.kind===`boolean`)return i(Z,{widthClass:`w-28`,"aria-label":l,value:n.value===!0?`yes`:`no`,onChange:e=>r({kind:`fixed`,value:e.target.value===`yes`}),options:[{value:`yes`,label:s(`common.yes`,`Yes`)},{value:`no`,label:s(`common.no`,`No`)}]});let u=vt(e);return u===void 0?c.kind===`number`?i(pn,{label:l,unit:c.unit,value:n,onChange:r,onBrace:a}):c.kind===`text`&&c.secret===!0?i(L,{"aria-label":l,type:`password`,className:`w-40`,value:un(n),onChange:e=>r({kind:`fixed`,value:e.target.value})}):i(ut,{label:l,className:`flex w-56 flex-col gap-1`,testId:`arg-text-${e.key}`,value:un(n),onChange:e=>r({kind:`fixed`,value:e})}):i(pe,{quantity:u.quantity,storedUnit:u.unit,value:typeof n.value==`number`?n.value:void 0,unit:n.unit,min:u.min,max:u.max,"aria-label":l,onBrace:a,onChange:e=>{let t=Ze(e,u.unit);r({kind:`fixed`,value:t.value,unit:t.unit})}})}function pn({label:t,unit:n,value:r,onChange:a,onBrace:o}){return e(f,{children:[i(ln,{"aria-label":t,className:`w-20`,value:typeof r.value==`number`?r.value:void 0,onValue:e=>a({kind:`fixed`,value:e??NaN}),onBrace:o}),n!==void 0&&i(`span`,{className:`text-sm text-foreground-muted`,children:n})]})}function mn({arg:e,value:t,issue:n}){let{t:r}=W(),a=e.offer;if(t.kind!==`fixed`||a.kind!==`number`||a.min===void 0&&a.max===void 0)return null;let o=vt(e),s=o===void 0?a.unit:t.unit??o.unit,c=o===void 0?{min:a.min,max:a.max}:ke({min:a.min,max:a.max},o.unit,s??o.unit),l=s??``,u=e=>e===void 0||o===void 0?e:Number(e.toPrecision(4)),d={min:u(c.min),max:u(c.max)},f=d.min!==void 0&&d.max!==void 0?r(`flow.arg.range`,`{{min}} to {{max}} {{unit}}`,{min:d.min,max:d.max,unit:l}):d.min===void 0?r(`flow.arg.atMost`,`at most {{max}} {{unit}}`,{max:d.max,unit:l}):r(`flow.arg.atLeast`,`at least {{min}} {{unit}}`,{min:d.min,unit:l});return i(`span`,{className:`text-[11px] ${n===null?`text-foreground-subtle`:`text-danger`}`,role:n===null?void 0:`alert`,children:f.trim()})}var hn=[O.Container],gn=[O.Camera];function _n(e,t){let n=oe(e);if(n!==void 0)return j([n.cap],t).find(t=>t.id===e)}function vn(e,t){return e.kind===`devices`?e.ids.map(t.deviceName).join(`, `):e.kind===`var`?e.name===`deviceId`?t.triggerDevice:e.name===`item`?t.roundDevice:`{${e.name}}`:t.someDevices}function yn(e,t,n){if(t.kind===`var`)return`{${t.name}}`;let r=e.offer;if(r.kind===`enum`){let e=r.values.find(e=>e.value===t.value);return e===void 0?String(t.value):e.label[n]}return String(t.value)}function bn(e,t,n,r){if(e.actionId===``)return null;let i=_n(e.actionId,r);if(i===void 0)return null;let a=mt([i],e),o=vn(e.target,n);return ht(i.phrase[t]).map(e=>{if(e.kind===`text`)return e.text;if(e.key===`device`)return o;let n=i.openArgs.find(t=>t.key===e.key),r=a?.values[e.key];return n===void 0||r===void 0?`{${e.key}}`:yn(n,r,t)}).join(``)}function xn({deviceId:e,cap:t,arg:n,...r}){return i(dn,{arg:n,choices:Bt(e,t,G(n.offer)?n.offer:null),...r})}c();function Sn(e){let{t}=W();return{deviceName:t=>e.find(e=>e.id===t)?.name??`#${String(t)}`,triggerDevice:t(`flow.command.triggerDevice`),roundDevice:t(`automation.repeat.itemHint`,`the device of this round`),someDevices:t(`flow.command.domainDevices`)}}function Cn({step:t,devices:n,variables:r,roundDevices:a,singleTarget:s=!1,autoOpen:c=!0,onChange:l}){let{t:u,i18n:d}=W(),f=gt(d.language),p=Sn(n),[m,h]=o(c&&t.actionId===``);return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`command-step`,children:[i(`p`,{className:`min-w-0 flex-1 text-sm text-foreground`,"data-testid":`command-step-phrase`,children:bn(t,f,p,wn(t.target,n))??i(`span`,{className:`text-foreground-subtle`,children:u(`flow.command.pickCommand`)})}),i(z,{variant:`outline`,size:`sm`,"data-testid":`command-step-change`,onClick:()=>h(!0),children:t.actionId===``?u(`flow.command.choose`):u(`flow.command.change`)}),m&&i(En,{step:t,devices:n,variables:r,singleTarget:s,...a===void 0?{}:{roundDevices:a},onCancel:()=>h(!1),onConfirm:e=>{h(!1),l(e)}})]})}function wn(e,t){if(e?.kind!==`devices`)return;let n=e.ids[0];return t.find(e=>e.id===n)?.type}function Tn(e){return{target:e.target.kind===`devices`&&e.target.ids.length===0?null:e.target,actionId:e.actionId===``?null:e.actionId}}function En({step:t,devices:n,variables:r,roundDevices:a,singleTarget:s,onCancel:c,onConfirm:l}){let{t:u,i18n:d}=W(),p=gt(d.language),[m,h]=o(()=>Tn(t)),g=m.actionId===null?void 0:_n(m.actionId,wn(m.target,n)),[_,v]=o(()=>g===void 0?{}:mt([g],t)?.values??pt(g)),y=g===void 0?null:bt(g,_),b=m.target!==null&&g!==void 0&&y===null;return i(ot,{open:!0,onClose:c,title:u(`flow.command.dialogTitle`),width:`xl`,fill:!0,testId:`command-picker-dialog`,footer:e(f,{children:[i(z,{variant:`ghost`,onClick:c,children:u(`common.cancel`,`Cancel`)}),i(z,{disabled:!b,"data-testid":`command-picker-confirm`,onClick:()=>{m.target===null||g===void 0||y!==null||l(xt(g,m.target,_))},children:u(`flow.command.use`)})]}),children:i(sn,{value:m,onChange:e=>{if(e.actionId!==m.actionId){let t=e.actionId===null?void 0:_n(e.actionId,wn(e.target,n));v(t===void 0?{}:pt(t))}h(e)},allowTriggerDevice:!s,multiple:!s,excludeTypes:hn,fillHeight:!0,...a===void 0?{}:{roundDevices:a},args:g!==void 0&&g.openArgs.length>0?i(Dn,{action:g,deviceId:m.target===null?null:St({target:m.target}),values:_,locale:p,variables:r,onChange:v}):null})})}function Dn({action:t,deviceId:n,values:r,locale:a,variables:o,onChange:s}){return i(`div`,{className:`flex flex-wrap items-start gap-3`,"data-testid":`command-args`,children:t.openArgs.map(c=>{let l=r[c.key];if(l===void 0)return null;let u=e=>s({...r,[c.key]:e});return e(`label`,{className:`flex flex-col gap-1 text-[11px] text-foreground`,children:[c.label[a],n===null?i(dn,{arg:c,locale:a,variables:o,value:l,onChange:u}):i(xn,{deviceId:n,cap:t.cap,arg:c,locale:a,variables:o,value:l,onChange:u})]},c.key)})})}c();var On=6e4;function kn(){let e=Be({projection:`slim`});return n(()=>{let t=new Map((e.data??[]).map(e=>[e.id,e.name]));return(e.data??[]).filter(e=>ie(String(e.type))).map(e=>({id:e.id,name:e.name,stableId:e.stableId,addonId:e.addonId,type:String(e.type),location:e.location??null,parentName:e.parentDeviceId===null?null:t.get(e.parentDeviceId)??null})).toSorted((e,t)=>e.name.localeCompare(t.name))},[e.data])}function An(e){let t=C();return s({queryKey:[`automation`,`wireable-fields`,e],enabled:e>0,staleTime:On,queryFn:async()=>(await t.trpcClient.deviceManager.getWireableFields.query({deviceId:e})).caps})}function jn(e,t){return e.find(e=>e.cap===t)?.fields??[]}function Mn(){return ct()}function Nn(e){let t=new Map;for(let n of e)for(let e of n)t.has(e.id)||t.set(e.id,e);let n=[...t.values()];return[...n.filter(e=>e.id.startsWith(`core:`)),...n.filter(e=>!e.id.startsWith(`core:`))]}function Pn(e,t){let n=e.nameI18n;return n===void 0?e.name:t.startsWith(`it`)?n.it:n.en}function Fn(e){let t=T({columns:e.size.cols,rows:e.size.rows,buttons:[]},e,{row:0,col:0});return t.ok?t.layout:null}function In(e,t,n,r){let i=t.trim().toLowerCase();return i===``?[...e]:e.filter(e=>Pn(e,n).toLowerCase().includes(i)||r(e.category).toLowerCase().includes(i))}function Ln(e,t){let n=E(e,t);return n!==null&&n>1}function Rn(e,t,n={}){let r=n.fillWidth===!0?E(e,t):null,i=r===null||r<2?{}:{scale:{cols:r}};if(n.at!==void 0)return T(e,t,n.at,i);let a=T(e,t,{row:0,col:0},i);if(a.ok||a.reason===`outside`||a.reason===`too-many`)return a;for(let n=0;n<e.rows;n+=1)for(let r=0;r<e.columns;r+=1){let a=T(e,t,{row:n,col:r},i);if(a.ok)return a}return a}c();function zn({open:t,grid:n,onOpenChange:r,onPick:a}){let{t:o,i18n:s}=W();return i(be,{open:t,onOpenChange:r,children:e(Re,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(rt,{children:i(Ce,{children:o(`remote.palette.title`)})}),i(Ie,{children:t&&i(Bn,{grid:n,language:s.language,onPick:a})})]})})}function Bn({grid:t,language:r,onPick:a}){let{t:s}=W(),c=Ve({}),[l,u]=o(``),[d,f]=o(!1),[m,g]=o(null),_=e=>s(`remote.palette.category.${e}`,e),v=In(n(()=>Nn(c.data===void 0?[]:[c.data]),[c.data]),l,r,_),y=v.some(e=>Ln(t,e));return c.isError?i(ge,{title:s(`remote.palette.errorTitle`),message:c.error.message,onRetry:()=>void c.refetch()}):c.data===void 0?e(`div`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`palette-loading`,children:[i(V,{className:`h-24`}),i(V,{className:`h-24`}),i(V,{className:`h-24`}),i(V,{className:`h-24`})]}):e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(p,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(L,{value:l,className:`pl-8`,placeholder:s(`remote.palette.search`),"aria-label":s(`remote.palette.search`),onChange:e=>u(e.target.value),"data-testid":`palette-search`})]}),y&&e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-muted`,children:[i(h,{checked:d,onChange:e=>f(e.target.checked),"data-testid":`palette-fill-width`}),s(`remote.palette.fillWidth`)]}),m!==null&&i(`p`,{role:`status`,className:`text-xs text-success`,"data-testid":`palette-added`,children:s(`remote.palette.added`,{name:m})}),v.length===0?i(Ge,{icon:P,title:s(`remote.palette.emptyTitle`),description:s(`remote.palette.emptyDescription`)}):i(`ul`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`palette-list`,children:v.map(e=>i(`li`,{children:i(Vn,{component:e,language:r,category:_(e.category),onPick:()=>{a(e,{fillWidth:d}),g(Pn(e,r))}})},e.id))})]})}function Vn({component:t,language:r,category:a,onPick:o}){let{t:s}=W(),c=n(()=>Fn(t),[t]),l=Pn(t,r);return e(`button`,{type:`button`,className:`flex h-full w-full items-center gap-3 rounded-lg border border-border bg-surface p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"data-testid":`palette-item-${t.id}`,onClick:o,children:[i(`span`,{className:`w-20 shrink-0`,children:c!==null&&i(Ae,{grid:c,label:l,compact:!0})}),e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:l}),e(`span`,{className:`block truncate text-xs text-foreground-muted`,children:[a,` ·`,` `,s(`remote.palette.size`,{cols:t.size.cols,rows:t.size.rows})]})]})]})}function Q(e,t){let n=t.kind===`group`?R(e,t.id):e.buttons.find(e=>e.id===t.id);return n===void 0?void 0:{row:n.row,col:n.col,rowSpan:n.rowSpan,colSpan:n.colSpan}}function Hn(e,t,n,r,i){if(e.width<=0||e.height<=0)return{row:0,col:0};let a=Math.floor((n-e.left)/e.width*t.columns),o=(r-e.top)/e.height;if(i===void 0||i.length!==t.rows||o<0)return{col:a,row:Math.floor(o*t.rows)};let s=i.reduce((e,t)=>e+t,0),c=0;for(let[e,t]of i.entries())if(c+=t/s,o<c)return{col:a,row:e};return{col:a,row:Math.max(t.rows,Math.floor(o*t.rows))}}function Un(e,t,n){return{row:n.row-(t.row-e.row),col:n.col-(t.col-e.col)}}function Wn(e,t,n){return t.kind===`group`?ze(e,t.id,n.row,n.col):He(e,t.id,n.row,n.col)}function Gn(e,t,n){let r=Q(e,t);if(r===void 0)return null;let i=Wn(e,t,n);return{rect:{...r,row:n.row,col:n.col},valid:i.status===`ok`,reason:i.status===`ok`?null:i.reason}}function Kn(e){switch(e){case`ArrowUp`:return{dRow:-1,dCol:0};case`ArrowDown`:return{dRow:1,dCol:0};case`ArrowLeft`:return{dRow:0,dCol:-1};case`ArrowRight`:return{dRow:0,dCol:1};default:return null}}function qn(e,t,n,r){let i=Q(e,t);return i===void 0?{status:`refused`,reason:`unknown-button`}:Wn(e,t,{row:i.row+n,col:i.col+r})}c();var Jn=4;function Yn(e,n,i){let[s,c]=o(null),l=t({grid:e,onDrop:i});l.current={grid:e,onDrop:i};let u=t(null),d=t(!1);return a(()=>()=>u.current?.(),[]),{drag:s,onItemPointerDown:r((e,t)=>{let r=n.current;if(r===null||t.button!==0)return;let i=r.getBoundingClientRect();if(Q(l.current.grid,e)===void 0)return;let a={item:e,startX:t.clientX,startY:t.clientY,grabbed:Hn(i,l.current.grid,t.clientX,t.clientY,Ye(l.current.grid)),active:!1,target:null},o=e=>{if(!a.active){if(Math.hypot(e.clientX-a.startX,e.clientY-a.startY)<Jn)return;a.active=!0}let t=l.current.grid,n=Hn(r.getBoundingClientRect(),t,e.clientX,e.clientY,Ye(t)),i=Q(t,a.item);i!==void 0&&(a.target=Un(i,a.grabbed,n),c({item:a.item,preview:Gn(t,a.item,a.target)}))},s=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,p),window.removeEventListener(`keydown`,m),u.current=null,c(null),a.active&&(d.current=!0,window.setTimeout(()=>{d.current=!1},0),e&&a.target!==null&&l.current.onDrop(Wn(l.current.grid,a.item,a.target)))},f=()=>s(!0),p=()=>s(!1),m=e=>{e.key===`Escape`&&s(!1)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,p),window.addEventListener(`keydown`,m),u.current=()=>s(!1)},[n]),consumeDragClick:r(()=>{let e=d.current;return d.current=!1,e},[])}}c();var Xn=`__custom__`;function Zn({value:n,onChange:r}){let{t:a}=W(),[s,c]=o(null),[l,u]=o(null),[d,f]=o(!1),p=t(null),m=s?.kind===`button`?s.id:null,h=s?.kind===`group`?s.id:null,g=n.buttons.find(e=>e.id===m)??null,_=h===null?void 0:R(n,h),v=(e,t)=>{if(e.status===`ok`){u(null),r(e.grid),t?.(e.grid);return}u(a(`remote.layout.refusal.${e.reason}`))},y=Yn(n,p,e=>v(e));return e(`div`,{className:`grid gap-4 md:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-2`,children:[i(U,{label:a(`remote.layout.columns`),children:i(I,{value:n.columns,onDelta:e=>v(de(n,n.columns+e,n.rows))})}),i(U,{label:a(`remote.layout.rows`),children:i(I,{value:n.rows,onDelta:e=>v(de(n,n.columns,n.rows+e))})})]}),i(Ae,{grid:n,label:a(`remote.layout.previewLabel`),selectedId:m,selectedGroupId:h,onSelect:e=>{y.consumeDragClick()||c({kind:`button`,id:e})},onSelectGroup:e=>{y.consumeDragClick()||c({kind:`group`,id:e})},showEmptyCells:!0,gridRef:p,drag:y.drag,onItemPointerDown:y.onItemPointerDown,onItemKeyDown:(e,t)=>{let r=Kn(t.key);r!==null&&(t.preventDefault(),v(qn(n,e,r.dRow,r.dCol)))}}),i(`p`,{className:`text-xs text-foreground-subtle`,children:a(`remote.layout.dragHint`)}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(z,{variant:`outline`,size:`sm`,onClick:()=>f(!0),"data-testid":`remote-add-component`,children:[i(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`remote.layout.addComponent`)]}),e(z,{variant:`outline`,size:`sm`,onClick:()=>v(ft(n,`ok`),e=>{let t=e.buttons.at(-1);c(t===void 0?null:{kind:`button`,id:t.id})}),"data-testid":`remote-add-button`,children:[i(b,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`remote.layout.addButton`)]})]}),l!==null&&i(`p`,{role:`alert`,className:`text-xs text-warning`,"data-testid":`remote-layout-refusal`,children:l})]}),i(`div`,{className:`min-w-0`,children:g===null?_===void 0?i(`p`,{className:`text-xs text-foreground-subtle`,children:a(`remote.layout.selectHint`)}):i(er,{grid:n,groupId:_.id,apply:v,onGone:()=>c(null)}):i($n,{grid:n,buttonId:g.id,apply:v,onRemove:()=>{r(Ue(n,g.id)),c(null),u(null)}})}),i(zn,{open:d,grid:n,onOpenChange:f,onPick:(e,t)=>{let i=Rn(n,e,t);if(!i.ok){u(a(`remote.layout.refusal.${i.reason}`));return}u(null),r(i.layout);let o=i.buttonIds[0];c(i.groupId===null?o===void 0?null:{kind:`button`,id:o}:{kind:`group`,id:i.groupId})}})]})}function Qn(e,t){return[...Ne.flatMap(n=>Ee(n).map(r=>({value:r,label:_e(r,t),group:e(`remote.roleGroup.${n}`)}))),{value:Xn,label:e(`remote.layout.customRole`),group:e(`remote.roleGroup.custom`)}]}function $n({grid:t,buttonId:n,apply:r,onRemove:a}){let{t:s,i18n:c}=W(),l=t.buttons.find(e=>e.id===n),u=l===void 0?null:se(l.role),[d,f]=o(null);if(l===void 0)return null;let p=ve(l.role)||d!==null,b=d??u??``,x=te(b),C={trigger:s(`remote.layout.pickIcon`),panel:s(`remote.layout.iconPanel`),searchPlaceholder:s(`deviceDisplay.iconSearchPlaceholder`),clear:s(`remote.layout.noIcon`),noMatches:s(`deviceDisplay.iconNoMatches`)},w=e=>s(`deviceDisplay.iconCategory.${e}`,{defaultValue:A(e)});return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,"data-testid":`remote-inspector`,children:[i(We,{mode:`single`,singleDisplay:`field`,label:s(`remote.layout.role`),options:Qn((e,t)=>s(e,t??e),c.language),value:p?Xn:l.role,onChange:e=>{if(e===Xn){f(u??``);return}f(null),r(H(t,l.id,{role:e}))}}),p&&i(U,{label:s(`remote.layout.customKey`),...b!==``&&!x?{error:s(`remote.layout.customKeyInvalid`)}:{},children:i(L,{value:b,placeholder:`hdmi_1`,onChange:e=>{let n=e.target.value;f(n),te(n)&&r(H(t,l.id,{role:ee(n)}))}})}),e(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)] items-end gap-2`,children:[i(U,{label:s(`remote.layout.icon`),children:i(he,{value:l.icon??null,onPick:e=>r(H(t,l.id,{icon:e})),fallbackGlyph:P,categoryLabel:w,labels:C})}),i(U,{label:s(`remote.layout.label`),children:i(L,{value:l.label??``,maxLength:40,onChange:e=>r(H(t,l.id,{label:e.target.value}))})})]}),i(U,{label:s(`remote.layout.appIcon`),children:i(y,{value:qe(l.icon)?.key??``,options:[{value:``,label:s(`remote.layout.noApp`)},...et.map(e=>({value:e.key,label:e.label}))],onChange:e=>{let n=e.target.value;n===``?qe(l.icon)!==void 0&&r(H(t,l.id,{icon:null})):r(H(t,l.id,{icon:st(n)}))},"data-testid":`remote-app-icon`})}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(U,{label:s(`remote.layout.shape`),children:i(y,{value:l.shape??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...M.map(e=>({value:e,label:s(`remote.layout.shapes.${e}`)}))],onChange:e=>{let n=M.find(t=>t===e.target.value);r($e(t,l.id,{shape:n??null}))},"data-testid":`remote-shape`})}),i(U,{label:s(`remote.layout.tone`),children:i(y,{value:l.tone??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...D.map(e=>({value:e,label:s(`remote.layout.tones.${e}`)}))],onChange:e=>{let n=D.find(t=>t===e.target.value);r($e(t,l.id,{tone:n??null}))},"data-testid":`remote-tone`})})]}),l.tone!==void 0&&[`red`,`green`,`yellow`,`blue`].includes(l.tone)&&e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-muted`,children:[i(h,{checked:l.showLegend===!0,onChange:e=>r($e(t,l.id,{showLegend:e.target.checked})),"data-testid":`remote-show-legend`}),s(`remote.layout.showLegend`)]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(U,{label:s(`remote.layout.move`),children:e(`div`,{className:`flex items-center gap-1`,children:[i(F,{icon:_,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveLeft`),onClick:()=>r(B(t,l.id,0,-1))}),i(F,{icon:g,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveUp`),onClick:()=>r(B(t,l.id,-1,0))}),i(F,{icon:m,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveDown`),onClick:()=>r(B(t,l.id,1,0))}),i(F,{icon:v,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveRight`),onClick:()=>r(B(t,l.id,0,1))})]})}),i(U,{label:s(`remote.layout.position`),children:i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`remote-position`,children:s(`remote.layout.positionValue`,{row:l.row+1,col:l.col+1})})}),i(U,{label:s(`remote.layout.height`),children:i(I,{value:l.rowSpan,onDelta:e=>r(je(t,l.id,l.rowSpan+e,l.colSpan))})}),i(U,{label:s(`remote.layout.width`),children:i(I,{value:l.colSpan,onDelta:e=>r(je(t,l.id,l.rowSpan,l.colSpan+e))})})]}),e(z,{variant:`danger`,size:`sm`,onClick:a,children:[i(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),s(`remote.layout.removeButton`)]})]})}function er({grid:t,groupId:n,apply:r,onGone:a}){let{t:o}=W(),s=R(t,n);if(s===void 0)return null;let c=we(t,n).length;return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,"data-testid":`remote-group-inspector`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:o(`remote.layout.groupSummary`,{frame:o(`remote.layout.frames.${s.frame}`,s.frame),count:c,row:s.row+1,col:s.col+1})}),i(U,{label:o(`remote.layout.groupTitle`),children:i(L,{value:s.title??``,maxLength:40,onChange:e=>r(at(t,s.id,e.target.value)),"data-testid":`remote-group-title`})}),s.frame===`divider`&&e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[i(U,{label:o(`remote.layout.separatorSize`),children:i(y,{value:s.size??`compact`,options:[{value:`compact`,label:o(`remote.layout.separatorSizeCompact`)},{value:`normal`,label:o(`remote.layout.separatorSizeNormal`)}],onChange:e=>r(Xe(t,s.id,{size:e.target.value===`normal`?`normal`:`compact`})),"data-testid":`remote-separator-size`})}),e(`label`,{className:`flex items-center gap-2 self-end pb-2 text-xs text-foreground-muted`,children:[i(h,{checked:s.hideTitle===!0,onChange:e=>r(Xe(t,s.id,{hideTitle:e.target.checked})),"data-testid":`remote-separator-hide-title`}),o(`remote.layout.separatorHideLabel`)]})]}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(z,{variant:`outline`,size:`sm`,"data-testid":`remote-group-ungroup`,onClick:()=>{r(Le(t,s.id,!0)),a()},children:[i(ue,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.ungroup`)]}),e(z,{variant:`danger`,size:`sm`,"data-testid":`remote-group-delete`,onClick:()=>{r(Le(t,s.id,!1)),a()},children:[i(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.deleteGroup`)]})]})]})}var tr={remote:{label:e=>e(`remote.templates.kind.remote`),emptyPayload:xe,summary:(e,t)=>{let n=it(e);return t(`remote.templates.layoutSummary`,{columns:n.columns,rows:n.rows,count:n.buttons.length})},renderEditor:(e,t)=>i(Zn,{value:it(e),onChange:t}),isSavable:e=>fe(it(e))!==null,presets:e=>Se.map(t=>({id:t.id,label:e(`remote.templates.preset.${t.id}`),payload:()=>De(t.id)}))},automation:{label:e=>e(`build.templates.kindAutomation`,`Automation`),emptyPayload:()=>({version:1,body:{when:{kind:`any`,children:[]},actions:[]},inputs:[],bindings:[]}),summary:(e,t)=>{let n=N.safeParse(e);return n.success?t(`build.templates.inputsSummary`,{count:n.data.inputs.length}):``},renderEditor:()=>null,isSavable:e=>N.safeParse(e).success,presets:()=>[]}};function $(e){return tr[e]}var nr=ne.filter(e=>e!==`automation`);function rr(e,t){let n=ae(e,t);return n.ok?n.payload:null}c();function ir(e={}){let t=u(),n=Me(),r=ye(),[i,a]=o(null);return{save:async i=>{a(null);try{let o=i.id===null?await n.mutateAsync({kind:i.kind,name:i.name,payload:i.payload,...ar(i)}):await r.mutateAsync({id:i.id,name:i.name,payload:i.payload,...ar(i)});return o.status===`refused`?(a(o.detail),!1):(await t.invalidateQueries({queryKey:[[`template`]]}),i.id===null&&e.onCreated?.(o.template.id),!0)}catch(e){return a(e instanceof Error?e.message:String(e)),!1}},saving:n.isPending||r.isPending,error:i,clearError:()=>a(null)}}function ar(e){return e.tags===void 0?{}:{tags:[...e.tags]}}function or(e){return{past:[],present:e,future:[]}}var sr=e=>e.past.length>0,cr=e=>e.future.length>0;function lr(e,t){switch(t.type){case`edit`:return Object.is(t.value,e.present)?e:{past:[...e.past,e.present].slice(-100),present:t.value,future:[]};case`undo`:{let t=e.past.at(-1);return t===void 0?e:{past:e.past.slice(0,-1),present:t,future:[e.present,...e.future]}}case`redo`:{let[t,...n]=e.future;return t===void 0?e:{past:[...e.past,e.present],present:t,future:n}}}}c();function ur(e,t){let[n,r]=o(e.name);a(()=>r(e.name),[e.name]);let[i,s]=d(lr,{kind:e.kind,presetId:``,payload:e.payload},or),{kind:c,presetId:l,payload:u}=i.present,f=e=>s({type:`edit`,value:{...i.present,payload:e}}),p=()=>s({type:`undo`}),m=()=>s({type:`redo`});Oe(`mod+z`,p,{allowInInput:!1,label:`Undo`}),Oe(`mod+shift+z`,m,{allowInInput:!1,label:`Redo`});let h=$(c),g=rr(c,u),_=n.trim()!==``&&g!==null&&h.isSavable(u)&&!t;return{name:n,setName:r,kind:c,presetId:l,payload:u,setPayload:f,undo:p,redo:m,canUndo:sr(i),canRedo:cr(i),canSave:_,dispatch:s,toDraft:()=>g===null?null:{id:e.id,kind:c,name:n.trim(),payload:g,...e.tags===void 0?{}:{tags:e.tags}}}}function dr({editor:t}){let{t:n}=W();return e(f,{children:[i(F,{icon:x,size:`sm`,variant:`ghost`,"aria-label":n(`remote.history.undo`),title:n(`remote.history.undo`),disabled:!t.canUndo,onClick:t.undo,"data-testid":`template-undo`}),i(F,{icon:le,size:`sm`,variant:`ghost`,"aria-label":n(`remote.history.redo`),title:n(`remote.history.redo`),disabled:!t.canRedo,onClick:t.redo,"data-testid":`template-redo`})]})}function fr({editor:t,draftId:n,error:r}){let{t:a}=W(),{kind:o,presetId:s,payload:c,name:l,dispatch:u}=t,d=$(o),p=d.presets(a);return e(f,{children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[i(U,{label:a(`remote.templates.name`),children:i(L,{value:l,maxLength:120,onChange:e=>t.setName(e.target.value),"data-testid":`template-name`})}),n===null&&nr.length>1&&i(U,{label:a(`remote.templates.kind.label`),children:i(y,{value:o,options:nr.map(e=>({value:e,label:$(e).label(a)})),onChange:e=>{let t=nr.find(t=>t===e.target.value);t!==void 0&&u({type:`edit`,value:{kind:t,presetId:``,payload:$(t).emptyPayload()}})}})}),n===null&&p.length>0&&i(U,{label:a(`remote.templates.startFrom`),children:i(y,{value:s,options:[{value:``,label:a(`remote.templates.startBlank`)},...p.map(e=>({value:e.id,label:e.label}))],onChange:e=>{let n=p.find(t=>t.id===e.target.value);u({type:`edit`,value:{kind:o,presetId:n?.id??``,payload:n===void 0?d.emptyPayload():n.payload()}}),n!==void 0&&l.trim()===``&&t.setName(n.label)},"data-testid":`template-preset`})})]}),d.renderEditor(c,t.setPayload),r!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}function pr({draft:t,saving:n,error:r,onSave:a,onClose:o,back:s}){let{t:c}=W(),l=ur(t,n);return e(f,{children:[e(rt,{className:`flex-row items-center justify-between gap-2`,children:[e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s!==void 0&&e(z,{size:`sm`,variant:`ghost`,onClick:s.onBack,"data-testid":`template-back`,children:[i(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`span`,{className:`truncate`,children:s.label})]}),i(Ce,{className:`truncate`,children:s===void 0?t.id===null?c(`remote.templates.newTitle`):c(`remote.templates.editTitle`):s.title})]}),i(`div`,{className:`flex shrink-0 items-center gap-1`,children:i(dr,{editor:l})})]}),i(Ie,{className:`space-y-4`,children:i(fr,{editor:l,draftId:t.id,error:r})}),e(Te,{children:[i(z,{variant:`ghost`,onClick:o,children:c(`common.cancel`)}),i(z,{disabled:!l.canSave,onClick:()=>{let e=l.toDraft();e!==null&&a(e)},"data-testid":`template-save`,children:c(`common.save`)})]})]})}export{Gt as _,ir as a,jn as c,Dn as d,Cn as f,ln as g,Z as h,ur as i,kn as l,gn as m,fr as n,$ as o,hn as p,dr as r,Mn as s,pr as t,An as u,Wt as v,Jt as y};
|