@camstack/addon-admin-ui 1.2.617 → 1.2.619
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 +13 -0
- package/dist/assets/Addons-qhklThGk.js +5 -0
- package/dist/assets/{AdminPage-Ebi_EBLO.js → AdminPage-p4lB5Fpe.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DXlBTxH9.js → AdminSectionedPage-BFv2Xw6N.js} +1 -1
- package/dist/assets/AiProfiles-B-dxBIKg.js +3 -0
- package/dist/assets/{Authentication-B9nMx-wk.js → Authentication-DDM_vq4S.js} +1 -1
- package/dist/assets/Build-BjneBe5B.js +39 -0
- package/dist/assets/{Calendars-DjJe7z4v.js → Calendars-Ctzy8AV9.js} +1 -1
- package/dist/assets/{CameraGrids-XG38cjso.js → CameraGrids-Cm5WKnXt.js} +1 -1
- package/dist/assets/{Cluster-3x1kCfVL.js → Cluster-CVJMfZ42.js} +1 -1
- package/dist/assets/CompositionBlockEditor-0z2mu3t6.js +2 -0
- package/dist/assets/{CompositionEditorPage-DvD76wlY.js → CompositionEditorPage-1j2sCnRu.js} +1 -1
- package/dist/assets/Data-BNNQEpcR.js +2 -0
- package/dist/assets/DeviceDetail-DSCNzE1y.js +2 -0
- package/dist/assets/{DeviceDoActionFields-C8cgbqM6.js → DeviceDoActionFields-7C1u_PJi.js} +1 -1
- package/dist/assets/{Devices-BYP2jABN.js → Devices-BgbnzzfZ.js} +1 -1
- package/dist/assets/EditTemplateButton-DuKvCool.js +1 -0
- package/dist/assets/{EmbedPlayerPage-Cc1XzE1D.js → EmbedPlayerPage-DwurG5x0.js} +1 -1
- package/dist/assets/History-DU71PLhs.js +1 -0
- package/dist/assets/Identity-CGw80A-k.js +1 -0
- package/dist/assets/InstancesTable-B6AoSbVj.js +1 -0
- package/dist/assets/IntegrationDetail-DeGBbcGH.js +1 -0
- package/dist/assets/{IntegrationHub-ppPk7tjJ.js → IntegrationHub-BIQpnYR2.js} +1 -1
- package/dist/assets/Integrations-D4mj85P9.js +2 -0
- package/dist/assets/Integrations-DF7omqiu.js +1 -0
- package/dist/assets/{Library-BDjoD4G2.js → Library-D8wV72jY.js} +1 -1
- package/dist/assets/Locations-DbhR7PDh.js +3 -0
- package/dist/assets/{Logs-CVZ0O-In.js → Logs-BOnGDTgj.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-CFO8KzKy.js → MaskShapeCanvas-Cza87RmJ.js} +1 -1
- package/dist/assets/{MotionZonesSettings-Dpl0PFO-.js → MotionZonesSettings-DKlxpVn8.js} +1 -1
- package/dist/assets/{MyAccess-DWTndP83.js → MyAccess-C4BQCgRy.js} +1 -1
- package/dist/assets/{Network-tLJKIS89.js → Network-CxKlIu5D.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-CfwzTbg9.js +1 -0
- package/dist/assets/Notifications-DtMN_68x.js +1 -0
- package/dist/assets/Pipeline-B300yepj.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-Bp3YSXwO.js → PrivacyMaskSettings-Lv0IY9ez.js} +1 -1
- package/dist/assets/Recordings-C_blIVhR.js +1 -0
- package/dist/assets/{ScanSubnetEditor-Di3ABTMO.js → ScanSubnetEditor-DGWBfvLx.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-D5xYFHyj.js → SceneMonitorEditor-PsyMFXTc.js} +1 -1
- package/dist/assets/SessionsList-B4EndC7R.js +2 -0
- package/dist/assets/{Showroom-Dl4wMm7l.js → Showroom-Dsz2mSPD.js} +1 -1
- package/dist/assets/StorageLocationsTable-CYC6XEal.js +1 -0
- package/dist/assets/System-Cy_BjinK.js +1 -0
- package/dist/assets/Templates-DEgNE2GB.js +1 -0
- package/dist/assets/{Terminal-D3-EI4tI.js → Terminal-B8bzEbwg.js} +3 -3
- package/dist/assets/{TrainingProviders-D9B7raxR.js → TrainingProviders-CQoJRka3.js} +1 -1
- package/dist/assets/{Viewer-k1S5klMG.js → Viewer-CJd3jZoq.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Dm2jyiKk.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-R2cWJ6br.js} +1 -1
- package/dist/assets/{addon-icons-context-CEvmVMB8.js → addon-icons-context-BgYAg_AS.js} +1 -1
- package/dist/assets/{ai-page.helpers-Bg-z0Uki.js → ai-page.helpers-SZGcu2Qp.js} +1 -1
- package/dist/assets/{archive-B9JKxZbf.js → archive-D6vg-wI0.js} +1 -1
- package/dist/assets/{assignment-candidates-C6Db7rsq.js → assignment-candidates-Cp7Uk_pQ.js} +1 -1
- package/dist/assets/{authed-media-CLS7sLxL.js → authed-media-B7i1lINb.js} +1 -1
- package/dist/assets/{bell-off-CGwGfVLy.js → bell-off-CsL9MH7N.js} +1 -1
- package/dist/assets/{board-model-FH0yBwxy.js → board-model-CRqpael6.js} +1 -1
- package/dist/assets/{boxes-BwDtnr_I.js → boxes-DxmpmK5V.js} +1 -1
- package/dist/assets/{calendar-clock-BBAYU6NG.js → calendar-clock-7Nojs9mt.js} +1 -1
- package/dist/assets/circle-slash-BJcDFW8_.js +1 -0
- package/dist/assets/client-BXR6ajSS.js +809 -0
- package/dist/assets/create-composition-C7Qbd1wb.js +2 -0
- package/dist/assets/crop-CIor6VRO.js +1 -0
- package/dist/assets/{database-zap-C92A2T4h.js → database-zap-CxVxIBTn.js} +1 -1
- package/dist/assets/{device-integration-icon-FWR8hQj8.js → device-integration-icon-D30NfhT9.js} +1 -1
- package/dist/assets/device-picker-model-C_ACIy4J.js +1 -0
- package/dist/assets/dist-B6QbwLbn.js +809 -0
- package/dist/assets/{dist-BcRNHWsT.js → dist-BvYpsFO_.js} +1 -1
- package/dist/assets/{eraser-BOm8ihae.js → eraser-BzkE8iXt.js} +1 -1
- package/dist/assets/{file-up-BTyDLoIP.js → file-up-DqkBcPKT.js} +1 -1
- package/dist/assets/{format-DHGtO4KV.js → format-DU3bhEVG.js} +1 -1
- package/dist/assets/{grip-vertical-BFf74GGR.js → grip-vertical-0UEXYzmF.js} +1 -1
- package/dist/assets/{hard-drive-download-DpTgAq6c.js → hard-drive-download-CqttlO8X.js} +1 -1
- package/dist/assets/{hostInit-BTM7DI5p.js → hostInit-D-ueHBbk.js} +1 -1
- package/dist/assets/{i18n-CXvYtPOo.js → i18n-CI_T7hgw.js} +1 -1
- package/dist/assets/icons-Bbof9kyX.js +1 -0
- package/dist/assets/{index-BMAzrKSU.js → index-pyp0GlvL.js} +3 -3
- package/dist/assets/{key-8iheoLtp.js → key-CvT6AW9M.js} +1 -1
- package/dist/assets/{key-square-DKJPhigE.js → key-square-BAc1dSEo.js} +1 -1
- package/dist/assets/{layers-DVi5cI_Y.js → layers-DqTwg1W2.js} +1 -1
- package/dist/assets/{link-2-off-CwQB4-4V.js → link-2-off-ZsDUEngg.js} +1 -1
- package/dist/assets/{linked-devices-model-DZEklNai.js → linked-devices-model-k8TdNJeC.js} +1 -1
- package/dist/assets/{list-ordered-Dhw63KUG.js → list-ordered-Tk3PwAeK.js} +1 -1
- package/dist/assets/{memory-stick-DeU-41u3.js → memory-stick-CD-Oqkj-.js} +1 -1
- package/dist/assets/{message-square-plus-2tqmoqEA.js → message-square-plus-D4CYrw19.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-c42fb52f.js → mf-entry-bootstrap-0-12812593.js} +2 -2
- package/dist/assets/{mic-off-CIcF7IKl.js → mic-off-BWLk6zFX.js} +1 -1
- package/dist/assets/{monitor-off-Dm87tOM6.js → monitor-off-T2-4dddP.js} +1 -1
- package/dist/assets/{monitor-smartphone-ByazEVgs.js → monitor-smartphone-CVkdYv9h.js} +1 -1
- package/dist/assets/mount-C_ACIy4J.js +1 -0
- package/dist/assets/{notification-rule-status-CBlffLX_.js → notification-rule-status-B6-wJrto.js} +1 -1
- package/dist/assets/{player-overlays-DyXjVBGT.js → player-overlays-CwGwFZ72.js} +1 -1
- package/dist/assets/remoteEntry-C9A5776R.js +1 -0
- package/dist/assets/{ruler-B__n3jg-.js → ruler-BkA262Z_.js} +1 -1
- package/dist/assets/{scissors-DjkxctyG.js → scissors-DrkuZ54s.js} +1 -1
- package/dist/assets/{search-x-DNUbomYQ.js → search-x-DK-VuUk-.js} +1 -1
- package/dist/assets/{send-CdJi-Jva.js → send-C-abBdEc.js} +1 -1
- package/dist/assets/{settings-2-Bcv2-p9v.js → settings-2-BI3FVudo.js} +1 -1
- package/dist/assets/{shapes-fSR3wuPN.js → shapes-DgKjCpym.js} +1 -1
- package/dist/assets/{sigma-C7e71nf1.js → sigma-KCXpAhXv.js} +1 -1
- package/dist/assets/{speaker-cS8JKFyy.js → speaker-Ck5eNYrC.js} +1 -1
- package/dist/assets/src-rr3LeNhN.js +100 -0
- package/dist/assets/{sso-popup-BO4Rklte.js → sso-popup-n62X0G6g.js} +1 -1
- package/dist/assets/step-inspector-model-CSyTC4Fd.js +1 -0
- package/dist/assets/{table-2-D2sE5xkE.js → table-2-Cj7xaw73.js} +1 -1
- package/dist/assets/{timer-reset-DE-Saa8j.js → timer-reset-CEn9vyrj.js} +1 -1
- package/dist/assets/tv-KMz8pUGf.js +1 -0
- package/dist/assets/{unlink-3TXI314Y.js → unlink-CLQJUZlx.js} +1 -1
- package/dist/assets/{usb-CWAElu5P.js → usb-DpTZYpPf.js} +1 -1
- package/dist/assets/{use-device-bound-caps-BIuzkSfj.js → use-device-bound-caps-D5tFsdYb.js} +1 -1
- package/dist/assets/{use-scenes-feed-sQn0LT8E.js → use-scenes-feed-BO747psi.js} +1 -1
- package/dist/assets/{use-stationary-objects-zuSJz0rd.js → use-stationary-objects-CNq1mqeR.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-Q7d8gnj3.js → useAdminDeviceRemoval-noR-50GZ.js} +1 -1
- package/dist/assets/useEventInvalidation-C_ACIy4J.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BZ8BBfPH.js → useNodeUrlSelection-ALId1l-s.js} +1 -1
- package/dist/assets/user-round-CAZ5Tl1r.js +1 -0
- package/dist/assets/{user-x-BCwqcNgr.js → user-x-D83olJnj.js} +1 -1
- package/dist/assets/{variable-u95rJnH5.js → variable-RZa2sP45.js} +1 -1
- package/dist/assets/{video-DQe86s-A.js → video-Dat56_72.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B2r8ij_v.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-lRy3hnY3.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +13283 -12425
- package/package.json +2 -2
- package/dist/assets/Addons-Bd-5BatZ.js +0 -5
- package/dist/assets/AiProfiles-DJWCjPWB.js +0 -3
- package/dist/assets/Build-qPFztpIB.js +0 -39
- package/dist/assets/CompositionBlockEditor-CpjYZdFX.js +0 -2
- package/dist/assets/Data-Dg8bKUj_.js +0 -2
- package/dist/assets/DeviceDetail-DNQyvNrH.js +0 -2
- package/dist/assets/EditTemplateButton-iR843K_w.js +0 -1
- package/dist/assets/History-BMLNSubg.js +0 -1
- package/dist/assets/Identity-CRN5-7VC.js +0 -1
- package/dist/assets/InstancesTable-DSzBTz0U.js +0 -1
- package/dist/assets/IntegrationDetail-Ui5OhCTs.js +0 -1
- package/dist/assets/Integrations-BYr92i9g.js +0 -2
- package/dist/assets/Integrations-DBGUeRV2.js +0 -1
- package/dist/assets/Locations-CofGYo_8.js +0 -3
- package/dist/assets/NodeAddonsSettingsPanel-DVrIfoG4.js +0 -1
- package/dist/assets/Notifications-Cpnee7Z2.js +0 -1
- package/dist/assets/Pipeline-Bw1Lwph_.js +0 -1
- package/dist/assets/Recordings-Y8nK9dGu.js +0 -1
- package/dist/assets/SessionsList-O39g4S1S.js +0 -2
- package/dist/assets/StorageLocationsTable-lXXrMjlK.js +0 -1
- package/dist/assets/System-DeTfeI3k.js +0 -1
- package/dist/assets/Templates-BCkcoTz2.js +0 -1
- package/dist/assets/circle-slash-DPjC8AvW.js +0 -1
- package/dist/assets/client-CblKyG0c.js +0 -809
- package/dist/assets/create-composition-DzLUvTdr.js +0 -2
- package/dist/assets/crop-lsSXpLjg.js +0 -1
- package/dist/assets/device-picker-model-BUPtZml1.js +0 -1
- package/dist/assets/dist-BB33Dg-J.js +0 -809
- package/dist/assets/icons-DAPXM3vF.js +0 -1
- package/dist/assets/mount-BUPtZml1.js +0 -1
- package/dist/assets/remoteEntry-eivQS8Bf.js +0 -1
- package/dist/assets/scan-eye-FuXamKBY.js +0 -1
- package/dist/assets/src-CDmuXEWK.js +0 -100
- package/dist/assets/step-inspector-model-DqV7fK9R.js +0 -1
- package/dist/assets/useEventInvalidation-BUPtZml1.js +0 -1
- package/dist/assets/user-round-7grs57O1.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{G as l,J as u,K as d,Kt as f,Q as p,U as m,Vi as h,c as g,ct as _,d as ee,f as te,ht as v,jn as y,jr as b,l as x,p as S,s as C,ut as w,va as T,xa as E,z as D}from"./player-overlays-DyXjVBGT.js";import{t as O}from"./settings-2-Bcv2-p9v.js";import{MaskShapeCanvas as ne}from"./MaskShapeCanvas-CFO8KzKy.js";s();var k=p(`/addon/pipeline-analytics/event-media`);function A(e){return`${k}/m/${e}`}function j(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 M(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var N=`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 P({monitor:t,disabled:n,onDelete:r}){let a=E(),o=j(t),s=M(t),c=_();return o.length===0?i(`p`,{className:`${D} 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:[S(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(F,{reference:o.reference}),i(`span`,{className:`${D} tabular-nums`,children:I(o.reference.capturedAt)}),e(`button`,{type:`button`,className:N,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:S(t.condition,a).toLowerCase(),date:I(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(f,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function F({reference:t}){let n=E(),[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(b,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:A(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function I(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var L=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,R=`text-[10px] font-medium text-foreground-subtle`,z=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,B=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,V=5,H=3600;function U(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 W(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 G(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 K({monitor:t,disabled:n,onPatch:r}){let s=E(),[l,u]=o(()=>G(t)),[d,f]=o(!1);a(()=>{d||u(G(t))},[t,d]);let p=e=>{f(!1),r(e)},m=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},h=t.confirm?.enabled===!0,g=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,label:e.target.value})),onBlur:()=>{let e=l.label.trim();e.length>0&&e!==t.label?p({label:e}):f(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.enabled,disabled:n,onChange:e=>p({enabled:e.target.checked})}),i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:D,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:R,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(w,{value:t.triggerMode,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&p({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:D,children:U(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:V,max:H,value:l.checkIntervalSec,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=q(l.checkIntervalSec,V,H);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:D,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:z,children:[i(`p`,{className:B,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:R,children:i(T,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:l.threshold.toFixed(2)}})}),i(`input`,{type:`range`,min:.3,max:.99,step:.01,value:l.threshold,disabled:n,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})},onBlur:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.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:R,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:l.hysteresisCount,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=q(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:m({hysteresisCount:e})})}})]}),i(`p`,{className:D,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:R,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.quietSeconds,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=q(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:D,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:R,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.minObservationSpacingSec,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=q(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:D,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:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(w,{value:t.onUncoveredCondition,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&p({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:D,children:W(t.onUncoveredCondition,s)})]}),e(`div`,{className:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(w,{value:t.emit,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&p({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:D,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(`input`,{type:`checkbox`,checked:t.autoRestore,disabled:n,onChange:e=>p({autoRestore:e.target.checked})}),i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:D,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:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:h,disabled:n||l.confirmPrompt.trim().length===0,onChange:e=>p(e.target.checked?{confirm:{...J(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:R,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:R,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:l.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=l.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?p({confirm:{...J(e),enabled:h}}):f(!1)}})]}),i(`p`,{className:D,children:i(T,{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 q(e,t,n){return Math.min(n,Math.max(t,e))}function J(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var Y=`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`,X=`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`,re=`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`,ie={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`},ae=.8,oe=3;function Z({deviceId:s}){let p=E(),_=d(v().trpcClient,s),b=u(_?.state.sceneMonitor),w=l(s,{width:640}),[T,k]=o(null),[A,j]=o(!1),[M,N]=o(null),[F,I]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[G,q]=o(``),J=t(!0);a(()=>(J.current=!0,()=>{J.current=!1}),[]);let Z=r(async()=>{if(_)try{let e=await _.sceneMonitor?.listScenes({});if(!J.current)return;e&&k(e)}catch(e){if(!J.current)return;m(e)?j(!0):I(e instanceof Error?e.message:String(e))}},[_]);a(()=>{k(null),j(!1),I(null),Z()},[Z]);let Q=b?.monitors??T?.monitors??[],se=Date.now(),$=r(async(e,t)=>{N(e),I(null);try{await t(),await Z()}catch(e){J.current&&I(e instanceof Error?e.message:String(e))}finally{J.current&&N(null)}},[Z]),ce=n(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:p(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,U,p]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>_?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[_,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||G.trim().length===0||(await $(`create`,async()=>{await _?.sceneMonitor?.createScene({label:G.trim(),roi:U,check:{mode:`similarity`,threshold:ae,hysteresisCount:oe}})}),W(null),q(``),H(!1))},[_,U,G,$]);return _?i(`div`,{className:`flex flex-col gap-3`,children:A?i(`p`,{className:`${D} leading-relaxed`,children:p(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${D} leading-relaxed`,children:p(`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:w.src===null?null:i(`img`,{src:w.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?X:Y,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:M!==null,children:V?p(`uiLibrary.sceneMonitor.cancel`,`Cancel`):p(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:Y,onClick:w.refresh,disabled:M!==null,children:p(`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?p(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):p(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&ee(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:p(`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=>q(e.target.value),placeholder:p(`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:X,onClick:()=>void de(),disabled:U===null||G.trim().length===0||M!==null,children:p(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),F!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:F}),Q.length===0?i(`p`,{className:`${D} leading-relaxed`,children:p(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Q.map(t=>{let n=g(t,p);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 ${ie[n.tone]}`,children:n.text})]}),i(`p`,{className:`${D} leading-relaxed`,children:te(t,se,p)}),i(`p`,{className:`${D} tabular-nums`,children:x(t,p)}),i(P,{monitor:t,disabled:M!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>_.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[C.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:Y,disabled:M!==null,title:r?p(`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.`):p(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:S(n,p).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>_.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(h,{className:`mr-1 inline h-3 w-3`}),p(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:S(n,p).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:p(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:X,disabled:M!==null||t.states.length===0,title:p(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>_.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(y,{className:`mr-1 inline h-3 w-3`}),p(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:Y,disabled:M!==null,onClick:()=>void $(`check-${t.id}`,async()=>_.sceneMonitor?.recheckNow({monitorId:t.id})),children:p(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?X:Y,"aria-pressed":z===t.id,"aria-label":p(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:M!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(O,{className:`mr-1 inline h-3 w-3`}),p(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:re,disabled:M!==null,onClick:()=>void $(`del-${t.id}`,async()=>_.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(f,{className:`h-3 w-3`})})]}),z===t.id&&i(K,{monitor:t,disabled:M!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>_.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Z 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{G as l,J as u,K as d,Kt as f,Q as p,U as m,Vi as h,c as g,ct as _,d as ee,f as te,ht as v,jn as y,jr as b,l as x,p as S,s as C,ut as w,va as T,xa as E,z as D}from"./player-overlays-CwGwFZ72.js";import{t as O}from"./settings-2-BI3FVudo.js";import{MaskShapeCanvas as ne}from"./MaskShapeCanvas-Cza87RmJ.js";s();var k=p(`/addon/pipeline-analytics/event-media`);function A(e){return`${k}/m/${e}`}function j(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 M(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var N=`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 P({monitor:t,disabled:n,onDelete:r}){let a=E(),o=j(t),s=M(t),c=_();return o.length===0?i(`p`,{className:`${D} 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:[S(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(F,{reference:o.reference}),i(`span`,{className:`${D} tabular-nums`,children:I(o.reference.capturedAt)}),e(`button`,{type:`button`,className:N,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:S(t.condition,a).toLowerCase(),date:I(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(f,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function F({reference:t}){let n=E(),[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(b,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:A(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function I(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var L=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,R=`text-[10px] font-medium text-foreground-subtle`,z=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,B=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,V=5,H=3600;function U(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 W(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 G(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 K({monitor:t,disabled:n,onPatch:r}){let s=E(),[l,u]=o(()=>G(t)),[d,f]=o(!1);a(()=>{d||u(G(t))},[t,d]);let p=e=>{f(!1),r(e)},m=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},h=t.confirm?.enabled===!0,g=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,label:e.target.value})),onBlur:()=>{let e=l.label.trim();e.length>0&&e!==t.label?p({label:e}):f(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.enabled,disabled:n,onChange:e=>p({enabled:e.target.checked})}),i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:D,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:R,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(w,{value:t.triggerMode,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&p({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:D,children:U(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:V,max:H,value:l.checkIntervalSec,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=q(l.checkIntervalSec,V,H);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:D,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:z,children:[i(`p`,{className:B,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:R,children:i(T,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:l.threshold.toFixed(2)}})}),i(`input`,{type:`range`,min:.3,max:.99,step:.01,value:l.threshold,disabled:n,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})},onBlur:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.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:R,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:l.hysteresisCount,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=q(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:m({hysteresisCount:e})})}})]}),i(`p`,{className:D,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:R,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.quietSeconds,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=q(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:D,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:R,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.minObservationSpacingSec,disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=q(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:D,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:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(w,{value:t.onUncoveredCondition,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&p({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:D,children:W(t.onUncoveredCondition,s)})]}),e(`div`,{className:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(w,{value:t.emit,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&p({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:D,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(`input`,{type:`checkbox`,checked:t.autoRestore,disabled:n,onChange:e=>p({autoRestore:e.target.checked})}),i(`span`,{className:R,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:D,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:z,children:[i(`p`,{className:B,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:h,disabled:n||l.confirmPrompt.trim().length===0,onChange:e=>p(e.target.checked?{confirm:{...J(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:R,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:R,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:l.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:L,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=l.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?p({confirm:{...J(e),enabled:h}}):f(!1)}})]}),i(`p`,{className:D,children:i(T,{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 q(e,t,n){return Math.min(n,Math.max(t,e))}function J(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var Y=`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`,X=`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`,re=`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`,ie={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`},ae=.8,oe=3;function Z({deviceId:s}){let p=E(),_=d(v().trpcClient,s),b=u(_?.state.sceneMonitor),w=l(s,{width:640}),[T,k]=o(null),[A,j]=o(!1),[M,N]=o(null),[F,I]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[G,q]=o(``),J=t(!0);a(()=>(J.current=!0,()=>{J.current=!1}),[]);let Z=r(async()=>{if(_)try{let e=await _.sceneMonitor?.listScenes({});if(!J.current)return;e&&k(e)}catch(e){if(!J.current)return;m(e)?j(!0):I(e instanceof Error?e.message:String(e))}},[_]);a(()=>{k(null),j(!1),I(null),Z()},[Z]);let Q=b?.monitors??T?.monitors??[],se=Date.now(),$=r(async(e,t)=>{N(e),I(null);try{await t(),await Z()}catch(e){J.current&&I(e instanceof Error?e.message:String(e))}finally{J.current&&N(null)}},[Z]),ce=n(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:p(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,U,p]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>_?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[_,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||G.trim().length===0||(await $(`create`,async()=>{await _?.sceneMonitor?.createScene({label:G.trim(),roi:U,check:{mode:`similarity`,threshold:ae,hysteresisCount:oe}})}),W(null),q(``),H(!1))},[_,U,G,$]);return _?i(`div`,{className:`flex flex-col gap-3`,children:A?i(`p`,{className:`${D} leading-relaxed`,children:p(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${D} leading-relaxed`,children:p(`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:w.src===null?null:i(`img`,{src:w.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?X:Y,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:M!==null,children:V?p(`uiLibrary.sceneMonitor.cancel`,`Cancel`):p(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:Y,onClick:w.refresh,disabled:M!==null,children:p(`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?p(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):p(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&ee(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:p(`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=>q(e.target.value),placeholder:p(`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:X,onClick:()=>void de(),disabled:U===null||G.trim().length===0||M!==null,children:p(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),F!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:F}),Q.length===0?i(`p`,{className:`${D} leading-relaxed`,children:p(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Q.map(t=>{let n=g(t,p);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 ${ie[n.tone]}`,children:n.text})]}),i(`p`,{className:`${D} leading-relaxed`,children:te(t,se,p)}),i(`p`,{className:`${D} tabular-nums`,children:x(t,p)}),i(P,{monitor:t,disabled:M!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>_.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[C.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:Y,disabled:M!==null,title:r?p(`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.`):p(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:S(n,p).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>_.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(h,{className:`mr-1 inline h-3 w-3`}),p(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:S(n,p).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:p(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:X,disabled:M!==null||t.states.length===0,title:p(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>_.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(y,{className:`mr-1 inline h-3 w-3`}),p(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:Y,disabled:M!==null,onClick:()=>void $(`check-${t.id}`,async()=>_.sceneMonitor?.recheckNow({monitorId:t.id})),children:p(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?X:Y,"aria-pressed":z===t.id,"aria-label":p(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:M!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(O,{className:`mr-1 inline h-3 w-3`}),p(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:re,disabled:M!==null,onClick:()=>void $(`del-${t.id}`,async()=>_.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(f,{className:`h-3 w-3`})})]}),z===t.id&&i(K,{monitor:t,disabled:M!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>_.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Z 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{D as o,Di as s,Kt as c,Qr as l,br as u,bt as d,ct as f,dt as p,lt as m,ut as h,vn as g,xa as ee,yn as _}from"./player-overlays-CwGwFZ72.js";import{a as v,c as y,f as b,o as x}from"./video-Dat56_72.js";import{Ai as S,An as te,Bn as C,Br as w,Bt as T,Di as E,Dt as ne,Ff as D,Fr as O,Gd as k,Go as re,Ir as A,Ln as j,Lr as M,Tt as N,Vr as P,Yr as F,bt as ie,cf as I,dr as L,ir as R,jn as z,kn as B,rr as V,sf as ae,tr as oe,ur as se,xt as ce,yi as H,zn as U,zr as W}from"./src-rr3LeNhN.js";import{t as G}from"./i18n-CI_T7hgw.js";import{t as K}from"./useTranslation-BJr-n0es.js";import{I as le,Pr as ue,n as de}from"./index-pyp0GlvL.js";a();function q({id:t,title:r,icon:i,description:a,actions:s,tone:c=`default`,notice:l=null,onDismissNotice:u,children:d}){return n(j,{headingId:`access-${t}`,title:r,icon:i,actions:s,testId:`access-${t}`,children:e(`div`,{className:`${o} space-y-3`,children:[n(`div`,{className:p(`text-[11px] leading-relaxed`,c===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),l!==null&&n(fe,{notice:l,onDismiss:u}),d]})})}var J={success:{icon:s,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:v,line:`border-danger/40 text-danger`,mark:`text-danger`}};function fe({notice:t,onDismiss:r}){let{t:i}=K(),a=J[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:p(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[n(o,{className:p(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),n(`span`,{className:`min-w-0 flex-1`,children:t.message}),r!==void 0&&n(I,{type:`button`,variant:`ghost`,size:`sm`,icon:d,"aria-label":i(`access.accessSection.dismiss`,`Dismiss`),onClick:r,className:`-my-1 h-5 w-5`})]})}function Y(){let{data:e}=k();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function X(e,t=null){return e===null?t:{tone:`danger`,message:e}}var pe={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function me(e){return G.t(pe[e])}var he={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ge={current:0,active:1,expired:2,revoked:3};function Z(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function _e({status:e}){return n(E,{variant:he[e],className:`text-[10px]`,children:me(e)})}function ve({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":G.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(u,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function ye(t){return[{key:`name`,header:G.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:G.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:G.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:G.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ge[e.status],render:e=>n(_e,{status:e.status})},{key:`created`,header:G.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:Z(e.createdAt,`—`)})},{key:`lastUsed`,header:G.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:Z(e.lastUsedAt,G.t(`access.credentialColumns.never`))})},{key:`expires`,header:G.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:Z(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:G.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(ve,{row:e,action:t},t.label))})}].filter(e=>e!==null)}a();var be=6,xe={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Se(e){let t=xe[e];return t===void 0?e:G.t(t)}function Ce(e,t){return G.t(t.key,{count:e})}function Q(e,t){return G.t(`access.bulk.countOf`,{count:e,noun:Ce(e,t)})}function we(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])=>G.t(`access.bulk.statusCount`,{count:t,status:me(e).toLowerCase()})).join(`, `)}function Te(e,t){let n=e.slice(0,be).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>be?[G.t(`access.bulk.previewMore`,{count:e.length-be})]:[];return[G.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:we(e)}),``,...n,...r].join(`
|
|
2
|
+
`)}async function Ee(e,t,n){let r=String(t.length),i=await e({title:G.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:Te(t,n),label:G.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:G.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:G.t(`access.bulk.confirmMismatch`,{expected:r,noun:Ce(2,n)})});return i!==null&&i.trim()===r}function De(e,t){let n=m(),r=D.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await Ee(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=>Se(e.reason));return o({tone:`success`,message:n.length>0?G.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):G.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:G.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:G.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function Oe(e,t,n){let r=m(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await Ee(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:G.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:G.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:G.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 ke={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}]},Ae={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},je=e=>e.status!==`current`,Me=[`active`,`current`];function Ne({rows:r,label:a,isLoading:o,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:d,action:f,extraActions:p,bulk:m,defaultStatus:h=Me}){let{t:g}=K(),[ee]=i(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),_=B(r,ke,ee),[v,y]=i(()=>new Set),b=d??g(`access.credentialColumns.never`),x=t(()=>ye({hideOwner:l,expiresNone:b,action:f??null,...p===void 0?{}:{extraActions:p}}),[l,b,f,p,g]),S=t(()=>m===void 0?()=>!1:e=>je(e)&&m.isSelectable(e),[m]),w=t(()=>_.rows.filter(e=>v.has(e.id)&&S(e)),[_.rows,v,S]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(u,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:a})]}):s===null?e(`div`,{className:`space-y-3`,children:[n(te,{state:_.state,facets:_.facets,groups:_.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Ae[e.id]===void 0?e.id:g(Ae[e.id]),...e.id===`status`?{facetLabel:e=>me(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:g(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:_.setSearch,onToggleFacet:_.toggleFacet,onToggleGroupFacet:_.toggleGroupFacet,onClear:_.clear}),m!==void 0&&n(Pe,{bulk:m,shown:_.rows.filter(S),targets:w,onSelect:y}),n(U,{columns:x,rows:_.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:C,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:a}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:_.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:v,onChange:y,isSelectable:S,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:Ce(1,m.noun)})}}})]}):n(F,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:s})}function Pe({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=K(),{revoke:s,noun:l}=t,f=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),p=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(H,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),f.map(t=>e(H,{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,l)})}),e(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(d,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(H,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void p(),children:[s.busy?n(u,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(c,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,l)})]})]})]})}var Fe=(e,t)=>t===null?`—`:e.get(t)??t;function Ie(e,t){return e!=null&&e<=t?`expired`:`active`}function Le(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Fe(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 Re(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 ze=`All permissions`,Be=`View link`,Ve=`Scoped`,He={"grid-view":`Grid`,"events-view":`Events`};function Ue(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function We(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Ge(e,t,n){return e===`*`?ze:We(e)?`${`${He[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Ue(e.grant.deviceIds,t)}`:n(e)}function Ke(e){return e.includes(`*`)?ze:e.some(We)?Be:Ve}function qe(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Fe(t,e.subjectId),kind:Ke(e.scopes),scope:n,status:e.revokedAt===null?Ie(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Je(e){return`${e.provider}\u0000${e.subject}`}function Ye(e,t){return{id:Je(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Fe(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var Xe=40,Ze=[{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`}],$e=[{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 et(e,t){return e.find(e=>e.test.test(t))?.name??null}function tt(e){return e.length<=Xe?e:`${e.slice(0,Xe)}…`}function nt(e){if(e===null||e.trim().length===0)return{label:G.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=et($e,t);if(n!==null)return{label:n,raw:t};let r=et(Ze,t),i=et(Qe,t);return r!==null&&i!==null?{label:G.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:tt(t),raw:t}:{label:r,raw:t}}var rt={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 it(e){let t=rt[e];return t===void 0?e:G.t(t)}function at(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function ot({token:t,label:r,onClose:i}){let{t:a}=K();return n(O,{open:!0,onOpenChange:e=>!e&&i(),children:e(M,{width:`md`,scroll:`body`,children:[n(w,{children:n(P,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(A,{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(W,{children:[n(z,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(H,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var st={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var ct=80,$=86400,lt=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],ut={type:`device-multiselect`,key:`cameras`,deviceFilter:{types:[`camera`]},maxItems:64},dt={type:`capability`,target:``,access:[`view`,`create`]};function ft({open:a,users:o,onClose:s,onSubmit:c,submitting:d,formError:f,awaitingProof:p}){let{t:m}=K(),v=ee(),{user:y}=le(),x=y?.isAdmin===!0,te=x?null:y?.scopes??[],[C,w]=i(`scopes`),[T,E]=i(y?.id??``),[D,O]=i(``),[k,re]=i([dt]),[A,j]=i([]),[M,N]=i(`grid-view`),[P,F]=i(!1),[I,z]=i(`30`);r(()=>{a||(w(`scopes`),E(y?.id??``),O(``),re([dt]),j([]),N(`grid-view`),F(!1),z(`30`))},[a,y?.id]),r(()=>{C!==`view-link`&&I===`never`&&z(`30`)},[C,I]);let B=t(()=>lt.filter(e=>e.seconds!==`never`||C===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?m(`access.createTokenModal.never`,`Never (until revoked)`):m(`access.createTokenModal.days`,{count:Number(e.value)})})),[C,m]),U=D.trim(),W=C===`scopes`?ce(k,v):null,G=A.map(Number).filter(e=>Number.isInteger(e)&&e>=0),de=lt.find(e=>e.value===I)?.seconds??30*$,q=()=>C===`all`?[`*`]:C===`view-link`?[{type:`share-view`,grant:{kind:M,deviceIds:G,...P?{talk:!0}:{}}}]:k,J=U.length>0&&U.length<=ct&&!d&&!p&&(C===`all`?x:C===`view-link`?G.length>0:k.length>0&&W===null),fe=()=>{if(!J)return;let e=x&&C!==`all`&&T!==``&&T!==y?.id;c({scopes:q(),expiresIn:de,label:U,...e?{subjectId:T}:{}})},Y=C===`all`,X=Y?_:g;return n(ne,{open:a,onClose:s,title:m(`access.createTokenModal.createToken`,`Create token`),icon:Y?_:b,error:f,width:`md`,testId:`create-token-dialog`,footer:e(H,{type:`button`,variant:Y?`danger`:`primary`,size:`sm`,onClick:fe,disabled:!J,"data-testid":`create-token-submit`,children:[d||p?n(u,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(X,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),m(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(L,{children:m(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(oe,{appearance:`pills`,value:C,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&w(e)},children:e(V,{"aria-label":m(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(R,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(g,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),m(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(R,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(l,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),m(`access.createTokenModal.reachViewLink`,`View link`)]}),x?e(R,{value:`all`,"data-testid":`token-reach-all`,children:[n(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),m(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Y?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(ue,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,x&&C!==`all`&&o.length>1?e(`div`,{className:`space-y-1`,children:[n(L,{htmlFor:`token-user`,children:m(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(h,{id:`token-user`,value:T,onChange:e=>E(e.target.value),options:o.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(L,{htmlFor:`token-name`,children:m(`access.createTokenModal.label`,`Label`)}),n(ae,{id:`token-name`,value:D,maxLength:ct,required:!0,onChange:e=>O(e.target.value),placeholder:C===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),C===`scopes`?e(`div`,{className:`space-y-1`,children:[n(L,{children:m(`access.createTokenModal.scopes`,`Scopes`)}),n(ie,{value:k,onChange:re,clampToParent:te}),W&&n(`p`,{className:`text-[10px] text-danger`,children:W}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:m(`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,C===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(L,{children:m(`access.createTokenModal.cameras`,`Cameras`)}),n(S,{field:{...ut,label:m(`access.createTokenModal.cameras`,`Cameras`)},value:A,onChange:e=>j(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])})]}),e(`div`,{className:`space-y-1`,children:[n(L,{htmlFor:`token-view-kind`,children:m(`access.createTokenModal.viewKind`,`Shows`)}),n(h,{id:`token-view-kind`,value:M,onChange:e=>N(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:m(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:m(`access.createTokenModal.viewEvents`,`Events`)}]})]}),M===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(se,{className:`mt-0.5`,checked:P,onChange:e=>F(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:m(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(L,{htmlFor:`token-lifetime`,children:m(`access.createTokenModal.expires`,`Expires after`)}),n(h,{id:`token-lifetime`,value:I,onChange:e=>z(e.target.value),options:B})]})]})})}a();var pt={key:`access.nouns.token`};function mt(e){return typeof e==`object`&&!!e&&`kind`in e}function ht(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${mt(e.selector)?T(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function gt({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:l=!1}){let{t:u}=K(),d=ee(),{user:p}=le(),m=f(),h=D.useUtils(),g=Y(),{data:_}=k(),v=t(()=>_??[],[_]),{data:y}=re({}),x=t(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),S=D.auth.listTokens.useQuery(void 0),{requestProof:te,dialog:C}=de(`Creating a token with all permissions`),{state:w,openNew:T,close:E}=N({newKey:st.token}),[ne,O]=i(null),[A,j]=i(null),[M,P]=i(!1),[F,ie]=i(null),[I,L]=i(null);r(()=>{o&&(T(),s?.())},[o,T,s]);let R=()=>{h.auth.listTokens.invalidate(),h.auth.listAuthAudit.invalidate()},z=D.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{R(),E(),j(null),P(!1),ie({token:e,label:t.label})},onError:e=>{j(`Create failed: ${e.message}`),P(!1)}}),B=D.auth.revokeToken.useMutation({onSuccess:()=>{L(null),R()},onError:e=>{L(null),O(`Revoke failed: ${e.message}`)}}),V=De(pt,R),ae=Date.now(),oe=(S.data??[]).filter(e=>!l||e.subjectId===p?.id).map(e=>qe(e,g,e.scopes.includes(`*`)?null:e.scopes.map(e=>Ge(e,x,e=>ht(e,d))).join(`, `),ae)),se=async e=>{await m({title:u(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?u(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):u(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:u(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(O(null),L(e.id),B.mutate({id:e.id}))},ce=e=>{(async()=>{O(null),j(null);let t;if(e.scopes.includes(`*`)){P(!0);let e=await te();if(P(!1),e===null)return;t=e}z.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:[C,n(q,{notice:X(ne,V.outcome),onDismissNotice:()=>{O(null),V.dismiss()},id:l?`my-tokens`:`tokens`,title:l?u(`access.tokensSection.myTokens`,`My tokens`):u(`access.tokensSection.tokens`,`Tokens`),icon:b,actions:a?void 0:e(H,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:T,children:[n(b,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),u(`system.access.newToken`,`New token`)]}),description:u(`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(Ne,{rows:oe,label:u(`common.tokensLabel`),isLoading:S.isLoading,loadError:S.isError?S.error?.message??`Request failed`:null,emptyText:u(`access.tokensSection.noTokens`,`No tokens.`),action:{label:u(`access.tokensSection.revoke2`,`Revoke`),icon:c,isAvailable:e=>e.status===`active`,onRun:e=>void se(e),busyId:I,disabled:V.busy||I!==null},...p?.isAdmin===!0?{bulk:{revoke:V,noun:pt,isSelectable:e=>e.status===`active`}}:{}})}),n(ft,{open:w.mode===`new`,users:v.map(e=>({id:e.id,username:e.username})),onClose:()=>{E(),j(null),P(!1)},submitting:z.isPending,formError:A,awaitingProof:M,onSubmit:ce}),F&&n(ot,{token:F.token,label:F.label,onClose:()=>ie(null)})]})}var _t=864e5,vt={qr:`QR (by an admin)`,self:`Self-enrolled`},yt={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function bt(e){return e.status===`revoked`}function xt(e){return e.status!==`revoked`}function St(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function Ct(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/_t)}function wt(e,t){let n=Ct(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function Tt(e,t){let n=Ct(e,t);return n===null?G.t(`helpers.certificateModel.unknown`):n===0?G.t(`helpers.certificateModel.today`):n>0?G.t(`helpers.certificateModel.inDays`,{count:n}):G.t(`helpers.certificateModel.daysAgo`,{count:-n})}function Et(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Dt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Ot(e){return e.length<=10?e:`${e.slice(0,10)}…`}function kt(e){if(!e.online)return{allowed:!1,reason:G.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:G.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:G.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var At={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 jt(e){if(e.ok)return{tone:`success`,message:G.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Ot(e.newSerial)})};let t=e.keptPreviousLeaf?G.t(`helpers.certificateModel.keptPrevious`):G.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:G.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:G.t(At[e.stage]),reason:e.reason,kept:t})}}function Mt(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 Nt=11;function Pt(e,t){let n=e.slice(0,Nt);return t===null?n:`${n} · ${t}`}function Ft(e){return{id:e.id,name:e.deviceName,detail:Pt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:yt[e.platform],scope:vt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function It(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:yt[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Lt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=K();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(u,{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(Rt,{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 Rt({session:t,revoking:r,onRevoke:i}){let{t:a}=K(),o=nt(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(x,{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:o.raw??void 0,children:o.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:it(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:at(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:at(t.expiresAt)})})]})]}),!t.current&&e(H,{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(u,{className:`h-3 w-3 animate-spin`}):n(y,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Le as C,q as D,Oe as E,X as O,Re as S,De as T,nt as _,xt as a,Je as b,Tt as c,St as d,kt as f,st as g,gt as h,bt as i,Y as k,jt as l,Ot as m,Ft as n,Mt as o,Dt as p,It as r,Et as s,Lt as t,wt as u,it as v,Ne as w,Ye as x,at 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{ut as i}from"./player-overlays-DyXjVBGT.js";import{_t as a,cr as o,if as s,lr as c,sr as l,vi as u}from"./src-CDmuXEWK.js";import{G as d,W as f,ut as p}from"./index-BMAzrKSU.js";r();function m({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 h({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 g={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 _(){let[r,_]=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(m,{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(m,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(h,{name:`primary`,cssVar:`--color-primary`}),t(h,{name:`background`,cssVar:`--color-background`}),t(h,{name:`surface`,cssVar:`--color-surface`}),t(h,{name:`foreground`,cssVar:`--color-foreground`}),t(h,{name:`success`,cssVar:`--color-success`}),t(h,{name:`warning`,cssVar:`--color-warning`}),t(h,{name:`danger`,cssVar:`--color-danger`}),t(h,{name:`info`,cssVar:`--color-info`}),t(h,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(h,{name:`onvif`,hex:`#3b82f6`}),t(h,{name:`hikvision`,hex:`#a855f7`}),t(h,{name:`reolink`,hex:`#06b6d4`}),t(h,{name:`ha`,hex:`#22d3ee`}),t(h,{name:`rtsp`,hex:`#78716c`})]})}),t(m,{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(m,{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(i,{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(o,{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(c,{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(v,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(l,{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))})]})]})}),t(m,{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(a,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(d,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(m,{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(m,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(f,{type:e,size:`lg`,showLabel:!0},e))})}),e(m,{title:`Form Builder Demo`,children:[t(p,{schema:g,values:r,onChange:_}),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(r,null,2)})]})]}),t(m,{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 v(){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{_ 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{ut as i}from"./player-overlays-CwGwFZ72.js";import{cr as a,lr as o,sf as s,ur as c,vt as l,yi as u}from"./src-rr3LeNhN.js";import{G as d,W as f,ut as p}from"./index-pyp0GlvL.js";r();function m({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 h({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 g={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 _(){let[r,_]=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(m,{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(m,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(h,{name:`primary`,cssVar:`--color-primary`}),t(h,{name:`background`,cssVar:`--color-background`}),t(h,{name:`surface`,cssVar:`--color-surface`}),t(h,{name:`foreground`,cssVar:`--color-foreground`}),t(h,{name:`success`,cssVar:`--color-success`}),t(h,{name:`warning`,cssVar:`--color-warning`}),t(h,{name:`danger`,cssVar:`--color-danger`}),t(h,{name:`info`,cssVar:`--color-info`}),t(h,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(h,{name:`onvif`,hex:`#3b82f6`}),t(h,{name:`hikvision`,hex:`#a855f7`}),t(h,{name:`reolink`,hex:`#06b6d4`}),t(h,{name:`ha`,hex:`#22d3ee`}),t(h,{name:`rtsp`,hex:`#78716c`})]})}),t(m,{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(m,{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(i,{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(o,{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(c,{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(v,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(a,{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))})]})]})}),t(m,{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(l,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(d,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(m,{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(m,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(f,{type:e,size:`lg`,showLabel:!0},e))})}),e(m,{title:`Form Builder Demo`,children:[t(p,{schema:g,values:r,onChange:_}),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(r,null,2)})]})]}),t(m,{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 v(){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{_ as ShowroomPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,et as a,o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$r as s,Bn as c,Fi as l,Ir as u,_n as d,br as f,bt as p,ct as m}from"./player-overlays-CwGwFZ72.js";import{Zo as h}from"./client-BXR6ajSS.js";import{t as g}from"./archive-D6vg-wI0.js";import{t as _}from"./eraser-BzkE8iXt.js";import{t as v}from"./hard-drive-download-CqttlO8X.js";import{Di as y,Ks as b,Qi as x,Tu as S,cf as C,ed as w,nd as ee,td as te,yi as T}from"./src-rr3LeNhN.js";import{t as E}from"./i18n-CI_T7hgw.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{J as O,st as k}from"./index-pyp0GlvL.js";import{t as A}from"./format-size-DIxKXxtj.js";import{t as ne}from"./InstancesTable-B6AoSbVj.js";a();var re=`forceDeleteLocation`;function ie({row:e}){let{t}=D(),r=m(),i=o(),a=x(),s=async()=>{if(await r({title:t(`system.storage.forceDeleteTitle`,`Force delete "{{name}}"?`,{name:e.name}),message:t(`system.storage.forceDeleteNote`,`Removes the record only, without checking what is on the location. Anything still stored there becomes unreachable — index rows naming it stop resolving, and playback of those segments goes silently black rather than erroring.`),confirmLabel:t(`system.storage.forceDelete`,`Force delete`),variant:`danger`}))try{await a.mutateAsync({addonId:e.addonId,action:re,input:{id:e.id}}),await i.invalidateQueries({queryKey:[O]}),await i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}catch(n){k({title:t(`providerInstances.deleteFailed`,`Could not delete`),message:`${e.name}: ${n instanceof Error?n.message:String(n)}`,severity:`critical`})}};return n(C,{icon:d,variant:`ghost`,size:`sm`,disabled:a.isPending,"aria-label":t(`system.storage.forceDeleteRow`,`Force delete {{name}}`,{name:e.name}),onClick:()=>void s()})}function ae(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function oe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function j({drain:t}){let{t:r}=D();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return n(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:r(`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:r(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return n(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:r(`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:r(`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&&n(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":r(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:n(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[r(`storage.drainProgressLine.left`,{size:ae(t.bytesRemaining)}),i!==null&&` · ${r(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?n(`span`,{"data-testid":`drain-eta-absent`,title:r(`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:r(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,r(`storage.drainProgressLine.empty`,{when:oe(t.estimatedEmptyAtMs)})]})]})}var M=[`ok`,`warn`,`critical`];function N(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function P(e){return Math.min(1,Math.max(0,e))}function F(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=P((n-t)/n);return{fraction:r,severity:N(r),recordingsFraction:P(e.usedBytes/n),freeBytes:t,totalBytes:n}}function se(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=F(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||M.indexOf(e.severity)>M.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function I(e){return Math.min(1,Math.max(0,e))}function L(e){return Math.round(I(e)*1e3)/10}function R(e){return`${String(Math.round(I(e)*100))}%`}function ce(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=F({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?I(o/r):m.fraction,g=m===null?N(h):m.severity,_=f===null?null:m===null?I(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:I((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:A(r),freeTotal:A(a),freeTotalPercent:R(a/r),used:A(p),usedPercent:R(p/r),free:A(u),freePercent:R(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:R(_)}),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:L(c/r),ownedPercent:f===null?null:L(f/r),usedPercent:L(p/r),freePercent:L(u/r),capPercent:y===null?null:L(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}function z(e){return h(e)}function B(e){return e===`active`}var V=[{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 H(e){return V.find(t=>t.mode===e)??V[0]}function le(e){return H(e).requiresConfirmation}var ue=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function U(e,t,n){return B(n)||!B(z(e))||t.some(t=>t.id!==e.id&&B(z(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:ue}}function de(e,t){return{active:U(e,t,`active`).reason,readonly:U(e,t,`readonly`).reason,drain:U(e,t,`drain`).reason,disabled:U(e,t,`disabled`).reason}}var W=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function fe(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function pe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*W;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function me(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*W,reason:t===`drain`?`drain`:`legacy`}}var K={ok:`bg-primary`,warn:`bg-warning`,critical:`bg-danger`},q={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function he(e,t){return e===`used`?K[t]:q[e]}function J({location:t,ownedBytes:r}){let{t:i}=D(),a=t.capacity??null,o=pe(fe(t.config),a?.totalBytes??null),s=ce({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:r??null,cap:me(t.config,z(t))});return s.kind===`unknown`?n(`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&&n(`div`,{className:q.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&n(`div`,{className:q.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),n(`div`,{className:K[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),n(`div`,{className:q.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&n(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:q.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),n(`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:[n(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${he(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var ge={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},_e={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},ve=`storage.discardLocation`,Y=`storage.discardLocationStatus`,ye=`storage.discardLocationCancel`;function be(e){return ge[e]??null}function xe(e){return _e[e]??null}function Se(e){return!B(z(e))}function Ce(e,t){return be(e.type)===null||!Se(e)?!1:t.some(t=>t.id!==e.id&&B(z(t)))}var we=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function X(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Z(e){return typeof e==`string`?e:null}function Te(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`||!we.has(n))return null;let r=X(t.camerasTotal),i=X(t.camerasDone),a=X(t.foldersRemoved),o=X(t.dbRowsDeleted),s=X(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:Z(t.locationId),jobId:Z(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:Z(t.detail)??``,startedAtMs:X(t.startedAtMs),finishedAtMs:X(t.finishedAtMs),error:Z(t.error)}}function Ee(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 De=2e3;function Oe({location:e,siblings:t}){return Ce(e,t)?n(ke,{location:e}):null}function ke({location:t}){let{t:a}=D(),o=m(),s=x(),c=xe(t.type),[l,u]=i(null),[d,h]=i(null),[g,v]=i(!1);if(r(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Y,input:{}});if(e)return;u(Te(t))}catch{}};t();let n=setInterval(()=>void t(),De);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let y=l!==null&&l.locationId===t.id,b=y&&l.running,S=y&&l.phase!==`idle`,C=async()=>{if(await o({title:a(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:a(`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:a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){h(null),v(!0);try{await s.mutateAsync({addonId:c,action:ve,input:{locationId:t.id}}),u(Te(await s.mutateAsync({addonId:c,action:Y,input:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{v(!1)}}},w=async()=>{try{await s.mutateAsync({addonId:c,action:ye,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(T,{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:[n(p,{className:`h-3 w-3`}),a(`common.cancel`,`Cancel`)]}):e(T,{variant:`unstyled`,type:`button`,onClick:()=>void C(),disabled:g,title:a(`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?n(f,{className:`h-3 w-3 animate-spin`}):n(_,{className:`h-3 w-3`}),a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),S&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:n(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${Ee(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${a(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${a(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||y&&l?.error)&&n(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}a();var Ae={active:c,readonly:g,drain:v,disabled:s},je={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 Me({mode:t,open:r,onToggle:i}){let{t:a}=D(),o=H(t),s=Ae[t];return e(T,{variant:`unstyled`,type:`button`,"aria-expanded":r,"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 ${je[t]}`,children:[n(s,{className:`h-3 w-3`}),o.label,n(l,{className:`h-3 w-3 ${r?`rotate-180`:``}`})]})}function Ne({mode:t,blockedReasons:i,onSelect:a,onDismiss:o}){let{t:s}=D();return r(()=>{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:[n(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),n(T,{variant:`unstyled`,type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:n(p,{className:`h-3 w-3`})})]}),V.map(r=>{let c=i[r.mode],l=c!==``,u=Ae[r.mode],d=r.mode===t;return e(T,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":d,"aria-label":r.label,disabled:l,onClick:()=>{l||(o(),d||a(r.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:[n(u,{className:`h-3 w-3`}),r.label,d&&n(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),n(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:r.consequence}),l&&n(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},r.mode)})]})}function Pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Fe(e){if(!Pe(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 Ie(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Fe(n);e!==null&&t.set(e.locationId,e)}return t}function Le(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 Re(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Le(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function ze(e){return e.mode===`drain`?!0:e.config.readOnly===!0}var Be=[`recordings`,`recordingsLow`];function Ve(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function He(e,t){if(t===void 0||!Be.includes(e.type))return null;let n=t.find(t=>Ve(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function Ue(e,t){let n=new Map;for(let r of e){let e=He(r,t);e!==null&&n.set(r.id,e)}return n}a();var We=[];function $(){let e=ee({}),n=S({},{refetchOnWindowFocus:!1}),r=w({},{refetchOnWindowFocus:!1}),i=e.data??We,a=t(()=>Ue(i,n.data?.locations),[i,n.data?.locations]),o=t(()=>Ie(r.data),[r.data]);return t(()=>({locations:i,ownedBytesById:a,drainOf:e=>Re(ze(e),o.get(e.id))}),[i,a,o])}a();function Ge({row:t}){let{t:r}=D(),a=m(),s=o(),c=$(),[l,u]=i(!1),d=b({onSuccess:()=>{s.invalidateQueries({queryKey:[O]}),s.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),u(!1)},onError:e=>k({title:r(`system.storage.modeFailed`,`Could not change the state`),message:`${t.name}: ${e.message}`,severity:`critical`})}),f=c.locations.find(e=>e.id===t.id);if(f===void 0)return null;let p=c.locations.filter(e=>e.type===f.type),h=z(f),g=c.drainOf(f),_=async e=>{le(e)&&!await a({title:r(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:f.displayName}),message:r(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:H(e).consequence}),confirmLabel:r(`common.disable`,`Disable`),variant:`danger`})||d.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:[n(J,{location:f,ownedBytes:c.ownedBytesById.get(f.id)??null}),g.kind!==`idle`&&n(j,{drain:g})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n(Oe,{location:f,siblings:p}),n(Me,{mode:h,open:l,onToggle:()=>u(e=>!e)})]}),l&&n(Ne,{mode:h,blockedReasons:de(f,p),onSelect:e=>void _(e),onDismiss:()=>u(!1)})]})}function Ke({row:t}){let r=$();if(t.kind!==`instance`)return null;let i=r.locations.find(e=>e.id===t.id);if(i===void 0)return null;let a=r.drainOf(i);return e(`div`,{className:`min-w-48`,children:[n(J,{location:i,ownedBytes:r.ownedBytesById.get(i.id)??null}),a.kind!==`idle`&&n(j,{drain:a})]})}function qe({row:e}){let t=$();if(e.kind!==`instance`)return null;let r=t.locations.find(t=>t.id===e.id);if(r===void 0)return null;let i=z(r);return n(y,{variant:i===`active`?`success`:i===`disabled`?`danger`:`default`,children:H(i).label})}function Je(e){return[{key:`capacity`,header:e.capacity,notSortableReason:e.capacity,render:e=>n(Ke,{row:e})},{key:`mode`,header:e.mode,nowrap:!0,notSortableReason:e.mode,render:e=>n(qe,{row:e})}]}function Ye(e,t,n){return!(n===`single`||t.length<=1||B(z(e))&&t.filter(e=>B(z(e))).length<=1)}a();var Xe=`storage`;function Ze({kinds:e}){let{t:r}=D(),{locations:i}=$(),a=te({}).data,o=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:Ye(t,i.filter(e=>e.type===t.type),n.cardinality)},s=t(()=>Je({capacity:r(`system.storage.colCapacity`,`Capacity`),mode:r(`system.storage.colMode`,`State`)}),[r]),c=t(()=>e===void 0?void 0:t=>t.kind===`instance`&&t.kindId!==void 0&&e.includes(t.kindId),[e]);return n(ne,{functionCap:Xe,icon:u,title:r(`system.storage.title`,`Storage locations`),subtitle:r(`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:r(`system.storage.emptyTitle`,`No storage locations yet`),emptyDescription:r(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`),addLabel:r(`system.storage.addLocation`,`Add location`),extraColumns:s,lead:e=>n(Ge,{row:e}),canDelete:o,rowActions:e=>o(e)?n(ie,{row:e}):null,...c===void 0?{}:{rowFilter:c}})}export{F as n,se as r,Ze as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,a,et as o,o as s,t as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Oi as u,Pn as d,br as f,hr as p,ht as m,ki as h,un as g,ut as _,xn as v}from"./player-overlays-CwGwFZ72.js";import{cs as y}from"./client-BXR6ajSS.js";import{n as b,t as x}from"./ruler-BkA262Z_.js";import{Af as S,Cd as C,Di as w,Ln as T,Rn as E,Wr as D,Xr as ee,Yr as O,_d as k,bd as A,bf as j,m as te,mn as ne,sf as M,ur as N,xf as P,yf as F,yi as I}from"./src-rr3LeNhN.js";import{t as L}from"./i18n-CI_T7hgw.js";import{t as R}from"./useTranslation-BJr-n0es.js";import{Ir as z,Lr as B,S as V,T as H}from"./index-pyp0GlvL.js";import{t as U}from"./AdminSectionedPage-BFv2Xw6N.js";import{t as W}from"./AdminPage-p4lB5Fpe.js";import{t as G}from"./NodeAddonsSettingsPanel-CfwzTbg9.js";import{i as K,r as q,t as J}from"./Authentication-DDM_vq4S.js";o();var re={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`},Y={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 X({entry:t,actions:r}){let i=t.name.toLowerCase(),a=re[i]??`border-primary`,o=Y[i]??`bg-primary/5`,s=t.providers.find(e=>e.active),c=r?.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&&n(f,{className:`h-3 w-3 animate-spin text-primary`})]}),n(`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`?n(ie,{entry:t,actions:r,activeProvider:s,isPending:c}):n(ae,{entry:t,actions:r,isPending:c})]})}function ie({entry:t,actions:r,activeProvider:i,isPending:a}){let{t:o}=R();if(!r)return n(`div`,{children:i?e(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[n(u,{className:`h-3 w-3 text-green-400 shrink-0`}),n(`span`,{className:`font-medium`,children:i.addonName}),n(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):n(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noActiveProvider`,`No active provider`)})});if(t.providers.length===0)return n(`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:[n(`div`,{className:`space-y-1`,children:t.providers.map(i=>{let o=i.active;return e(I,{variant:`unstyled`,type:`button`,disabled:a||o,onClick:()=>r.onSelectSingleton(t.name,i.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:[n(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${o?`border-green-400 bg-green-400`:`border-border`}`}),n(`span`,{className:`font-medium truncate`,children:i.addonName}),o&&n(`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`})]},i.addonId)})}),t.perNode&&t.perNode.length>0&&n(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:t.perNode.map(i=>{let c=i.hasOverride&&i.resolvedActive?i.resolvedActive:s,l=[{value:s,label:i.resolvedActive?o(`addons.capabilityMap.inheritGlobalWith`,{provider:i.resolvedActive}):o(`addons.capabilityMap.inheritGlobal`)},...i.providers.map(e=>({value:e,label:e}))],u=e=>{e===s?r.onClearNodeSingleton(t.name,i.nodeId):r.onSelectNodeSingleton(t.name,i.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:[i.nodeId,i.hasOverride&&n(`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 r=c===t.value;return e(I,{variant:`unstyled`,type:`button`,disabled:d||r,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 ${r?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[n(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${r?`border-green-400 bg-green-400`:`border-border`}`}),n(`span`,{className:`font-medium truncate`,children:t.label}),r&&t.value!==s&&n(`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)})]},i.nodeId)})})]})}function ae({entry:t,actions:r,isPending:i}){let{t:a}=R();if(t.providers.length===0)return n(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:a(`addons.capabilityMap.noProviders`,`No providers`)});if(!r)return n(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[n(`span`,{className:`text-foreground-subtle`,children:t.addonName}),t.active&&n(`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,n)=>{let i=n?[...new Set([...o,e])]:o.filter(t=>t!==e);r.onToggleCollection(t.name,i)};return n(`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 ${i?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[e(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[n(N,{checked:t.active,disabled:i,onChange:e=>s(t.addonId,e.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),n(`span`,{className:`text-foreground truncate`,children:t.addonName})]}),t.active&&n(`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 Z({capabilities:e,actions:t}){let{t:r}=R();return e.length===0?n(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:r(`addons.capabilityMap.noCapabilitiesRegistered`,`No capabilities registered`)}):n(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>n(X,{entry:e,actions:t},e.name))})}var oe=[`capabilities`,`listCapabilities`];function se(e){return e===`singleton`||e===`collection`}function ce(e){let t=e.indexOf(`@`);return t===-1?L.t(`system.capabilities.providerHub`,{addonId:e}):`${e.slice(0,t)} (${e.slice(t+1)})`}function le(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:ce(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function ue(){let{t:r}=R(),o=m(),[s,l]=i(null),[d,f]=i(null),p=a({queryKey:oe,queryFn:()=>o.trpcClient.capabilities.listCapabilities.query()}),_=t(()=>{let e=(p.data??[]).flatMap(e=>se(e.mode)?[le(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]),v=t(()=>_.filter(e=>e.mode===`singleton`),[_]),y=t(()=>_.filter(e=>e.mode===`collection`),[_]),b=c({mutationFn:e=>o.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{l(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:r(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:t.capName,addonId:t.addonId})}),await p.refetch()},onError:(e,t)=>{f({kind:`error`,message:r(`system.capabilities.failedToSet`,{cap:t.capName,error:e instanceof Error?e.message:r(`common.unknownError`)})})},onSettled:()=>l(null)}),x=c({mutationFn:e=>o.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{l(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await p.refetch()},onError:(e,t)=>{f({kind:`error`,message:r(`system.capabilities.failedToSetOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:r(`common.unknownError`)})})},onSettled:()=>l(null)}),S=c({mutationFn:e=>o.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{l(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:r(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:t.capName,nodeId:t.nodeId})}),await p.refetch()},onError:(e,t)=>{f({kind:`error`,message:r(`system.capabilities.failedToClearOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:r(`common.unknownError`)})})},onSettled:()=>l(null)}),C=c({mutationFn:e=>o.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{l(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:r(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:t.capName,length:t.enabledAddonIds.length})}),await p.refetch()},onError:(e,t)=>{f({kind:`error`,message:r(`system.capabilities.failedToUpdate`,{cap:t.capName,error:e instanceof Error?e.message:r(`common.unknownError`)})})},onSettled:()=>l(null)}),w={onSelectSingleton:(e,t)=>b.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>x.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>S.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>C.mutate({capName:e,enabledAddonIds:t}),pendingCapability:s};return e(W,{embedded:!0,icon:g,title:r(`system.capabilities.capabilities`,`Capabilities`),subtitle:r(`system.capabilities.chooseWhichProviderIsActive`,`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`),children:[d&&e(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${d.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[d.kind===`success`?n(u,{className:`h-3.5 w-3.5 shrink-0`}):n(h,{className:`h-3.5 w-3.5 shrink-0`}),n(`span`,{children:d.message})]}),p.isLoading&&n(`div`,{className:`flex items-center justify-center py-16`,children:n(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),p.isError&&!p.isLoading&&n(O,{title:r(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:p.error instanceof Error?p.error.message:r(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void p.refetch()}),!p.isLoading&&!p.isError&&_.length===0&&n(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:r(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!p.isLoading&&!p.isError&&_.length>0&&e(`div`,{className:`space-y-6`,children:[v.length>0&&e(`section`,{className:`space-y-2`,children:[n(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:r(`system.capabilities.singletonPickOneProvider`,`Singleton — pick one provider`)}),n(Z,{capabilities:v,actions:w})]}),y.length>0&&e(`section`,{className:`space-y-2`,children:[n(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:r(`system.capabilities.collectionEnableASet`,`Collection — enable a set`)}),n(Z,{capabilities:y,actions:w})]})]})]})}var de={escape:`Esc`,enter:`Enter`};function fe(e,t){let n=P(e),r=de[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 pe(){let{t}=R(),r=F(),i=j();return n(T,{headingId:`settings-hotkeys`,title:t(`systemPage.settings.hotkeys.title`,`Keyboard shortcuts`),icon:b,testId:`settings-hotkeys`,children:e(`div`,{className:`space-y-2 p-3`,children:[n(`p`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.settings.hotkeys.description`,`The shortcuts active on this page. They cannot be changed.`)}),r.length===0?n(ee,{title:t(`systemPage.settings.hotkeys.empty`,`No shortcuts are active on this page.`)}):r.map(e=>n(E,{label:e.label??t(`systemPage.settings.hotkeys.unnamed`,`Shortcut`),children:n(`kbd`,{className:`rounded-md border border-border bg-surface px-1.5 py-0.5 font-mono text-xs text-foreground`,children:fe(e.combo,i)})},`${e.scope}|${e.combo}`))]})})}o();var me=[[`system`]];function Q(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function he(){let{t}=R(),a=s(),o=A(),c=C(),l=k(),[u,f]=i(``),[m,h]=i(``),[g,_]=i(null),v=o.data?.location??null;r(()=>{f(v===null?``:Q(v.latitude)),h(v===null?``:Q(v.longitude))},[v]);let y=async()=>{await a.invalidateQueries({queryKey:me})},b=async e=>{e.preventDefault();let t=Number(u),n=Number(m);if(u.trim()===``||m.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 c.mutateAsync({latitude:t,longitude:n}),await y()},x=async()=>{_(null),await c.mutateAsync(null),await y()},S=async()=>{_(null),await l.mutateAsync(),await y()},T=c.isPending||l.isPending||o.isLoading;return e(D,{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:[n(p,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),n(`div`,{children:n(`h3`,{className:`text-sm font-medium`,children:t(`settings.siteLocationCard.siteLocation`,`Site location`)})})]}),v===null?n(w,{variant:`warning`,children:t(`settings.siteLocationCard.notConfigured`,`Not configured`)}):n(w,{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!==``?n(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.detectedNear`,{place:v.label})}):null,v===null&&o.data?.derivationAttemptedAt!==null?e(`p`,{className:`text-xs text-warning`,children:[t(`settings.siteLocationCard.automaticDetectionFromThePublic`,`Automatic detection from the public IP did not succeed`),o.data?.derivationError!==null&&o.data?.derivationError!==void 0?`: ${o.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:[n(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.latitude`,`Latitude`)}),n(M,{className:`w-40`,value:u,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>f(e.target.value),"aria-label":t(`settings.siteLocationCard.latitude`,`Latitude`)})]}),e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[n(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.longitude`,`Longitude`)}),n(M,{className:`w-40`,value:m,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>h(e.target.value),"aria-label":t(`settings.siteLocationCard.longitude`,`Longitude`)})]}),n(I,{type:`submit`,disabled:T,children:t(`common.save`,`Save`)}),e(I,{type:`button`,variant:`ghost`,disabled:T,onClick:S,children:[n(d,{className:`h-3.5 w-3.5 mr-1`}),t(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),v===null?null:n(I,{type:`button`,variant:`ghost`,disabled:T,onClick:x,children:t(`settings.siteLocationCard.clear`,`Clear`)})]}),g===null?null:n(`p`,{className:`text-xs text-danger`,children:g}),n(`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.`)})]})}o();function ge(e){return y.some(t=>t===e)}function $(e){return ne.some(t=>t===e)}function _e(){let{t}=R(),r=te(),[a,o]=i(!1),[s,c]=i(null),l=e=>{o(!0),c(null),r.update(e).catch(e=>c(e instanceof Error?e.message:String(e))).finally(()=>o(!1))},u=r.status!==`ok`||!r.writable||a;return n(T,{headingId:`settings-units`,title:t(`systemPage.myAccess.units.title`,`Units`),icon:x,testId:`settings-units`,children:e(`div`,{className:`space-y-2 p-3`,children:[n(`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.`)}),r.status===`error`&&n(O,{message:t(`systemPage.myAccess.units.loadError`,`Your unit preferences could not be read.`)}),r.status===`ok`&&!r.writable&&n(O,{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&&n(O,{message:s}),n(E,{label:t(`systemPage.myAccess.units.temperature`,`Temperature`),children:n(_,{"aria-label":t(`systemPage.myAccess.units.temperature`,`Temperature`),value:r.value.temperature,disabled:u,onChange:e=>{let t=e.target.value;$(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)`)}]})}),n(E,{label:t(`systemPage.myAccess.units.system`,`Other measurements`),children:n(_,{"aria-label":t(`systemPage.myAccess.units.system`,`Other measurements`),value:r.value.system,disabled:u,onChange:e=>{let t=e.target.value;ge(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)`)}]})})]})})}var ve=`system-config`;function ye(){let{t}=R(),{nodes:r,isLoading:i}=S(),a=r.find(e=>e.isHub&&e.isOnline),o=(a?.addons.map(e=>e.addonId)??[]).filter(e=>e!==ve);return e(W,{embedded:!0,children:[n(he,{}),i?n(`div`,{className:`text-foreground-subtle text-sm py-12 text-center`,children:t(`admin.system.settings.loadingHubTopology`,`Loading hub topology…`)}):a?e(l,{children:[n(K,{omitSectionIds:[J],emptyMessage:t(`admin.system.settings.bootstrapUnavailable`,`Not available — the addon that owns the server settings did not answer.`)}),o.length===0?n(`div`,{className:`text-foreground-subtle text-sm py-12 text-center`,children:t(`admin.system.settings.noAddonsInstalledOnThe`,`No addons installed on the hub yet.`)}):n(G,{nodeId:a.id,addonIds:o,level:`global`,omitSectionIds:[J,q]})]}):e(`div`,{className:`flex flex-col items-center justify-center text-foreground-subtle text-sm gap-2 py-12`,children:[n(v,{className:`h-8 w-8 opacity-30`}),n(`p`,{children:t(`admin.system.settings.noOnlineHubNodeFound`,`No online hub node found.`)}),n(`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:[n(`h2`,{id:`settings-per-user`,className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:t(`systemPage.settings.perUser`,`Your settings`)}),n(_e,{}),n(pe,{})]})]})}function be(){let{t:e}=R(),t=V(`/system/settings`,{t:e,isAdmin:!0})??{icon:v,title:e(`system.systemNav`,`System`)},{search:r,hash:i}=B();return new URLSearchParams(r).get(`tab`)===`secrets`?n(z,{replace:!0,to:`${H(r)}${i}`}):n(U,{icon:t.icon,title:t.title,defaultSection:`settings`,sectionsLabel:`${t.title} sections`,sections:[{id:`settings`,label:e(`system.system.settings`,`Settings`),content:n(ye,{})},{id:`capabilities`,label:e(`system.system.capabilities`,`Capabilities`),content:n(ue,{})}]})}export{be 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,et as s,o as c,q as l,x 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{Bt as d,Cn as f,Kt as p,Un as m,Yn as h,ct as g,da as _,di as v,la as y,ot as b,sa as x,ua as S,ut as C}from"./player-overlays-CwGwFZ72.js";import{$i as w,Ar as T,Er as E,Qi as D,Tr as O,_r as k,ea as ee,gr as te,hr as ne,jr as A,xo as re}from"./client-BXR6ajSS.js";import{d as ie}from"./video-Dat56_72.js";import{n as ae,t as oe}from"./shapes-DgKjCpym.js";import{t as se}from"./unlink-CLQJUZlx.js";import{Bn as ce,Br as le,Dd as ue,Di as de,Ed as fe,Fr as pe,Ft as j,Ir as me,Lr as he,Nt as ge,Pu as _e,Qr as M,Si as ve,Td as ye,Vr as be,Xr as xe,Yr as Se,cf as N,hn as P,lf as Ce,sf as F,ur as we,vf as Te,wd as Ee,yi as I,zn as De,zr as Oe}from"./src-rr3LeNhN.js";import{t as L}from"./useTranslation-BJr-n0es.js";import{Br as ke}from"./index-pyp0GlvL.js";import{t as Ae}from"./AdminPage-p4lB5Fpe.js";import{A as je,C as Me,D as Ne,E as Pe,M as R,O as z,S as Fe,T as Ie,b as B,c as V,d as Le,f as H,g as Re,h as ze,j as Be,k as Ve,l as He,m as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,u as Ye,v as Xe,w as Ze,x as Qe,y as $e}from"./EditTemplateButton-DuKvCool.js";s();function et(e){return{past:[],present:e,future:[]}}var tt=e=>e.past.length>0,nt=e=>e.future.length>0;function rt(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}}}}var U=12,W=4,G=3,K=(e,t,n,r,i,a={})=>({id:e,role:t,row:n,col:r,colSpan:i,...a}),q=e=>`custom:${e}`;function J(e,t,n=[]){return t.map((t,r)=>K(`r${e}c${r}`,t,e,r*W,W,{...n[r]===void 0?{}:{label:n[r]}}))}function Y(e){return[K(`up`,`up`,e,W,W),K(`left`,`left`,e+1,0,W),K(`ok`,`ok`,e+1,W,W),K(`right`,`right`,e+1,2*W,W),K(`down`,`down`,e+2,W,W)]}function it(e,t){return t.map((t,n)=>K(`app_${t}`,q(`app_${t}`),e,n*G,G,{icon:V(t)}))}var X=(e,t)=>({id:`core:section-divider`,row:e,col:0,options:{scale:{cols:U},title:t}});function at(e,t,n){let r=H(U,e,t);for(let e of n){let t=k(r,ne(e.id),{row:e.row,col:e.col},e.options);if(!t.ok)throw Error(`preset component ${e.id} at ${e.row}:${e.col}: ${t.reason}`);r=t.layout}return r}var Z={scale:{cols:W}},ot={scale:{rows:2,cols:W}},st=(e,t,n,r)=>({idSuffix:e,row:3,col:t,rowSpan:1,colSpan:1,role:n,label:r}),ct=at(23,[K(`input`,`input`,0,2*W,W),K(`mute`,`mute`,7,W,W),K(`ch_list`,q(`ch_list`),8,W,W,{label:`CH LIST`}),K(`settings`,q(`settings`),9,W,W,{label:`Settings`}),K(`home`,`home`,10,W,W),K(`guide`,`guide`,12,0,W),K(`e_manual`,q(`e_manual`),12,W,W,{label:`e-Manual`}),K(`info`,`info`,12,2*W,W),K(`back`,`back`,17,0,W),K(`exit`,`exit`,17,2*W,W),K(`color_a`,q(`color_a`),19,0,G,{label:`A`}),K(`color_b`,q(`color_b`),19,G,G,{label:`B`}),K(`color_c`,q(`color_c`),19,2*G,G,{label:`C`}),K(`color_d`,q(`color_d`),19,3*G,G,{label:`D`}),K(`pic_size`,q(`pic_size`),20,0,W,{label:`P.SIZE`}),K(`picture`,q(`picture`),20,W,W,{label:`Picture`}),K(`ad_subt`,q(`ad_subt`),20,2*W,W,{label:`AD/SUBT`})],[{id:`core:power`,row:0,col:0,options:{scale:{cols:2}}},X(1,`Numbers`),{id:`core:keypad`,row:2,col:0,options:{scale:Z.scale,extras:[st(`ttx`,0,q(`ttx_mix`),`TTX/MIX`),st(`prech`,2,q(`pre_ch`),`PRE-CH`)]}},X(6,`Volume and channels`),{id:`core:rocker-volume-v`,row:7,col:0,options:ot},{id:`core:rocker-channel-v`,row:7,col:2*W,options:ot},X(11,`Menus`),X(13,`Navigation`),{id:`core:dpad`,row:14,col:0,options:Z},X(18,`Colour and picture`),X(21,`Playback`),{id:`core:media-transport`,row:22,col:1,options:{scale:{cols:2}}}]),lt=[`netflix`,`youtube`,`primevideo`,`disneyplus`,`dazn`,`raiplay`],ut=at(20,[K(`input`,`input`,0,2*W,W),...J(4,[`menu`,`home`,`exit`]),K(`guide`,`guide`,6,0,W),K(`info`,`info`,6,2*W,W),K(`back`,`back`,10,0,W),K(`play_pause`,`play_pause`,10,2*W,W),K(`mute`,`mute`,12,W,W),K(`ch_list`,q(`ch_list`),13,W,W,{label:`CH.LIST`}),K(`subtitle`,q(`subtitle`),14,0,6,{label:`Subtitle`}),K(`text`,q(`text`),14,6,6,{label:`Text`})],[{id:`core:power`,row:0,col:0,options:{scale:{cols:2}}},{id:`core:panel`,row:1,col:0,options:{scale:Z.scale,title:`Apps`,extras:lt.map((e,t)=>({idSuffix:e,row:Math.floor(t/3),col:t%3,rowSpan:1,colSpan:1,role:q(`app_${e}`),icon:V(e)}))}},{id:`core:colour-keys`,row:3,col:0,options:{scale:{cols:G}}},X(5,`Navigation`),{id:`core:dpad`,row:7,col:0,options:Z},X(11,`Volume and channels`),{id:`core:rocker-volume-v`,row:12,col:0,options:Z},{id:`core:rocker-channel-v`,row:12,col:2*W,options:Z},X(15,`Numbers`),{id:`core:keypad`,row:16,col:0,options:Z}]),dt=H(U,8,[K(`power`,`power`,0,0,W),K(`input`,`input`,0,2*W,W),...Y(1),...J(4,[`back`,`home`,`play_pause`]),K(`vol_up`,`volume_up`,5,0,W),K(`mute`,`mute`,5,W,W,{rowSpan:2}),K(`ch_up`,`channel_up`,5,2*W,W),K(`vol_down`,`volume_down`,6,0,W),K(`ch_down`,`channel_down`,6,2*W,W),...it(7,[`netflix`,`primevideo`,`disneyplus`,`youtube`])]),ft=H(U,9,[K(`power`,`power`,0,0,W),K(`input`,`input`,0,2*W,W),K(`settings`,q(`settings`),1,0,W,{label:`Settings`}),K(`up`,`up`,1,W,W),K(`guide`,`guide`,1,2*W,W),K(`left`,`left`,2,0,W),K(`ok`,`ok`,2,W,W),K(`right`,`right`,2,2*W,W),K(`back`,`back`,3,0,W),K(`down`,`down`,3,W,W),K(`home`,`home`,3,2*W,W),K(`vol_up`,`volume_up`,4,0,W,{rowSpan:2}),K(`vol_down`,`volume_down`,6,0,W,{rowSpan:2}),K(`mute`,`mute`,4,W,W),K(`info`,`info`,5,W,W),K(`menu`,`menu`,6,W,W),K(`exit`,`exit`,7,W,W),K(`ch_up`,`channel_up`,4,2*W,W,{rowSpan:2}),K(`ch_down`,`channel_down`,6,2*W,W,{rowSpan:2}),...it(8,[`netflix`,`primevideo`,`disneyplus`,`youtube`])]),pt=H(U,8,[K(`assistant`,q(`assistant`),0,0,W,{label:`Assistant`}),K(`input`,`input`,0,W,W),K(`power`,`power`,0,2*W,W),...Y(1),...J(4,[`back`,`home`,`guide`]),K(`vol_up`,`volume_up`,5,0,W),K(`mute`,`mute`,5,W,W),K(`ch_up`,`channel_up`,5,2*W,W),K(`vol_down`,`volume_down`,6,0,W),K(`play_pause`,`play_pause`,6,W,W),K(`ch_down`,`channel_down`,6,2*W,W),...it(7,[`youtube`,`netflix`,`primevideo`,`disneyplus`])]),mt=H(U,7,[K(`siri`,q(`siri`),0,0,W,{label:`Siri`}),K(`power`,`power`,0,2*W,W),...Y(1),...J(4,[`back`,`play_pause`,`home`]),K(`vol_up`,`volume_up`,5,0,6),K(`vol_down`,`volume_down`,5,6,6),K(`mute`,`mute`,6,W,W)]);function ht(e){return J(e,[`digit_1`,`digit_2`,`digit_3`]).concat(J(e+1,[`digit_4`,`digit_5`,`digit_6`]),J(e+2,[`digit_7`,`digit_8`,`digit_9`]))}function gt(e){return[`a`,`b`,`c`,`d`].map((t,n)=>K(`color_${t}`,q(`color_${t}`),e,n*G,G,{label:t.toUpperCase()}))}var _t=H(U,18,[K(`power`,`power`,0,0,W),K(`input`,`input`,0,2*W,W),...ht(1),K(`ttx_mix`,q(`ttx_mix`),4,0,W,{label:`TTX/MIX`}),K(`digit_0`,`digit_0`,4,W,W),K(`pre_ch`,q(`pre_ch`),4,2*W,W,{label:`PRE-CH`}),K(`vol_up`,`volume_up`,5,0,W),K(`mute`,`mute`,5,W,W,{rowSpan:2}),K(`ch_up`,`channel_up`,5,2*W,W),K(`vol_down`,`volume_down`,6,0,W),K(`ch_down`,`channel_down`,6,2*W,W),K(`ch_list`,q(`ch_list`),7,W,W,{label:`CH LIST`}),K(`settings`,q(`settings`),8,0,W,{label:`Settings`}),K(`home`,`home`,8,W,W),K(`guide`,`guide`,8,2*W,W),...Y(9),K(`back`,`back`,12,0,W),K(`info`,`info`,12,W,W),K(`exit`,`exit`,12,2*W,W),...J(13,[`rewind`,`play`,`fast_forward`]),K(`pause`,`pause`,14,0,6),K(`stop`,`stop`,14,6,6),...gt(15),K(`ad_subt`,q(`ad_subt`),16,0,12,{label:`AD/SUBT`}),K(`app_netflix`,q(`netflix`),17,0,W,{icon:V(`netflix`)}),K(`app_prime`,q(`prime_video`),17,W,W,{icon:V(`primevideo`)}),K(`samsung_tv_plus`,q(`samsung_tv_plus`),17,2*W,W,{label:`TV Plus`})]),vt=H(U,18,[K(`power`,`power`,0,0,W),K(`input`,`input`,0,2*W,W),K(`app_youtube`,q(`youtube`),1,0,6,{icon:V(`youtube`)}),K(`app_netflix`,q(`netflix`),1,6,6,{icon:V(`netflix`)}),...J(2,[`menu`,`home`,`exit`]),K(`settings`,q(`settings`),3,0,W,{label:`Settings`}),K(`guide`,`guide`,3,W,W),K(`info`,`info`,3,2*W,W),...Y(4),K(`back`,`back`,7,0,W),K(`ch_list`,q(`ch_list`),7,W,W,{label:`CH.LIST`}),K(`media`,q(`media`),7,2*W,W,{label:`Media`}),K(`vol_up`,`volume_up`,8,0,W),K(`mute`,`mute`,8,W,W,{rowSpan:2}),K(`ch_up`,`channel_up`,8,2*W,W),K(`vol_down`,`volume_down`,9,0,W),K(`ch_down`,`channel_down`,9,2*W,W),...ht(10),K(`sleep`,q(`sleep`),13,0,W,{label:`Sleep`}),K(`digit_0`,`digit_0`,13,W,W),K(`subtitle`,q(`subtitle`),13,2*W,W,{label:`Subtitle`}),K(`txt`,q(`txt`),14,0,6,{label:`Text`}),K(`rec`,q(`rec`),14,6,6,{label:`Rec`}),...J(15,[`rewind`,`play`,`fast_forward`]),K(`pause`,`pause`,16,0,6),K(`stop`,`stop`,16,6,6),...gt(17)]),yt=[{id:`samsung-classic`,layout:ct},{id:`hisense-vidaa`,layout:ut},{id:`samsung-bn59-01315`,layout:_t},{id:`hisense-erf3-vidaa`,layout:vt},{id:`samsung-smart`,layout:dt},{id:`lg-magic`,layout:ft},{id:`google-tv`,layout:pt},{id:`apple-tv`,layout:mt}];function bt(e){let t=yt.find(t=>t.id===e);return t===void 0?null:{...t.layout,buttons:t.layout.buttons.map(e=>({...e}))}}function xt(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 St(e,t){let n=e.nameI18n;return n===void 0?e.name:t.startsWith(`it`)?n.it:n.en}function Ct(e){let t=k({columns:e.size.cols,rows:e.size.rows,buttons:[]},e,{row:0,col:0});return t.ok?t.layout:null}function wt(e,t,n,r){let i=t.trim().toLowerCase();return i===``?[...e]:e.filter(e=>St(e,n).toLowerCase().includes(i)||r(e.category).toLowerCase().includes(i))}function Tt(e,t){let n=te(e,t);return n!==null&&n>1}function Et(e,t,n={}){let r=n.fillWidth===!0?te(e,t):null,i=r===null||r<2?{}:{scale:{cols:r}};if(n.at!==void 0)return k(e,t,n.at,i);let a=k(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=k(e,t,{row:n,col:r},i);if(a.ok)return a}return a}function Dt({open:t,grid:n,onOpenChange:r,onPick:a}){let{t:o,i18n:s}=L();return i(pe,{open:t,onOpenChange:r,children:e(he,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(le,{children:i(be,{children:o(`remote.palette.title`)})}),i(me,{children:t&&i(Ot,{grid:n,language:s.language,onPick:a})})]})})}function Ot({grid:t,language:r,onPick:a}){let{t:s}=L(),c=_e({}),[l,u]=o(``),[d,p]=o(!1),[m,h]=o(null),g=e=>s(`remote.palette.category.${e}`,e),_=wt(n(()=>xt(c.data===void 0?[]:[c.data]),[c.data]),l,r,g),v=_.some(e=>Tt(t,e));return c.isError?i(Se,{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(M,{className:`h-24`}),i(M,{className:`h-24`}),i(M,{className:`h-24`}),i(M,{className:`h-24`})]}):e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(f,{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(F,{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`})]}),v&&e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-muted`,children:[i(we,{checked:d,onChange:e=>p(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})}),_.length===0?i(xe,{icon:oe,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:_.map(e=>i(`li`,{children:i(kt,{component:e,language:r,category:g(e.category),onPick:()=>{a(e,{fillWidth:d}),h(St(e,r))}})},e.id))})]})}function kt({component:t,language:r,category:a,onPick:o}){let{t:s}=L(),c=n(()=>Ct(t),[t]),l=St(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(qe,{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`?Re(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 At(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 jt(e,t,n){return{row:n.row-(t.row-e.row),col:n.col-(t.col-e.col)}}function Mt(e,t,n){return t.kind===`group`?Me(e,t.id,n.row,n.col):Fe(e,t.id,n.row,n.col)}function Nt(e,t,n){let r=Q(e,t);if(r===void 0)return null;let i=Mt(e,t,n);return{rect:{...r,row:n.row,col:n.col},valid:i.status===`ok`,reason:i.status===`ok`?null:i.reason}}function Pt(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 Ft(e,t,n,r){let i=Q(e,t);return i===void 0?{status:`refused`,reason:`unknown-button`}:Mt(e,t,{row:i.row+n,col:i.col+r})}s();var It=4;function Lt(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:At(i,l.current.grid,t.clientX,t.clientY,Ne(l.current.grid)),active:!1,target:null},o=e=>{if(!a.active){if(Math.hypot(e.clientX-a.startX,e.clientY-a.startY)<It)return;a.active=!0}let t=l.current.grid,n=At(r.getBoundingClientRect(),t,e.clientX,e.clientY,Ne(t)),i=Q(t,a.item);i!==void 0&&(a.target=jt(i,a.grabbed,n),c({item:a.item,preview:Nt(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(Mt(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},[])}}s();var Rt=`__custom__`;function zt({value:n,onChange:r}){let{t:a}=L(),[s,c]=o(null),[l,u]=o(null),[d,f]=o(!1),p=t(null),h=s?.kind===`button`?s.id:null,g=s?.kind===`group`?s.id:null,_=n.buttons.find(e=>e.id===h)??null,v=g===null?void 0:Re(n,g),y=(e,t)=>{if(e.status===`ok`){u(null),r(e.grid),t?.(e.grid);return}u(a(`remote.layout.refusal.${e.reason}`))},b=Lt(n,p,e=>y(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(j,{label:a(`remote.layout.columns`),children:i(P,{value:n.columns,onDelta:e=>y(Pe(n,n.columns+e,n.rows))})}),i(j,{label:a(`remote.layout.rows`),children:i(P,{value:n.rows,onDelta:e=>y(Pe(n,n.columns,n.rows+e))})})]}),i(qe,{grid:n,label:a(`remote.layout.previewLabel`),selectedId:h,selectedGroupId:g,onSelect:e=>{b.consumeDragClick()||c({kind:`button`,id:e})},onSelectGroup:e=>{b.consumeDragClick()||c({kind:`group`,id:e})},showEmptyCells:!0,gridRef:p,drag:b.drag,onItemPointerDown:b.onItemPointerDown,onItemKeyDown:(e,t)=>{let r=Pt(t.key);r!==null&&(t.preventDefault(),y(Ft(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(I,{variant:`outline`,size:`sm`,onClick:()=>f(!0),"data-testid":`remote-add-component`,children:[i(oe,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`remote.layout.addComponent`)]}),e(I,{variant:`outline`,size:`sm`,onClick:()=>y(Le(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(m,{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:_===null?v===void 0?i(`p`,{className:`text-xs text-foreground-subtle`,children:a(`remote.layout.selectHint`)}):i(Ht,{grid:n,groupId:v.id,apply:y,onGone:()=>c(null)}):i(Vt,{grid:n,buttonId:_.id,apply:y,onRemove:()=>{r(Ze(n,_.id)),c(null),u(null)}})}),i(Dt,{open:d,grid:n,onOpenChange:f,onPick:(e,t)=>{let i=Et(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 Bt(e,t){return[...Ye.flatMap(n=>$e(n).map(r=>({value:r,label:Ge(r,t),group:e(`remote.roleGroup.${n}`)}))),{value:Rt,label:e(`remote.layout.customRole`),group:e(`remote.roleGroup.custom`)}]}function Vt({grid:t,buttonId:n,apply:r,onRemove:a}){let{t:s,i18n:c}=L(),l=t.buttons.find(e=>e.id===n),u=l===void 0?null:D(l.role),[d,f]=o(null);if(l===void 0)return null;let m=Xe(l.role)||d!==null,h=d??u??``,g=ee(h),v={trigger:s(`remote.layout.pickIcon`),panel:s(`remote.layout.iconPanel`),searchPlaceholder:s(`deviceDisplay.iconSearchPlaceholder`),clear:s(`remote.layout.noIcon`),noMatches:s(`deviceDisplay.iconNoMatches`)},b=e=>s(`deviceDisplay.iconCategory.${e}`,{defaultValue:re(e)});return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,"data-testid":`remote-inspector`,children:[i(ve,{mode:`single`,singleDisplay:`field`,label:s(`remote.layout.role`),options:Bt((e,t)=>s(e,t??e),c.language),value:m?Rt:l.role,onChange:e=>{if(e===Rt){f(u??``);return}f(null),r(z(t,l.id,{role:e}))}}),m&&i(j,{label:s(`remote.layout.customKey`),...h!==``&&!g?{error:s(`remote.layout.customKeyInvalid`)}:{},children:i(F,{value:h,placeholder:`hdmi_1`,onChange:e=>{let n=e.target.value;f(n),ee(n)&&r(z(t,l.id,{role:w(n)}))}})}),e(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)] items-end gap-2`,children:[i(j,{label:s(`remote.layout.icon`),children:i(Ce,{value:l.icon??null,onPick:e=>r(z(t,l.id,{icon:e})),fallbackGlyph:oe,categoryLabel:b,labels:v})}),i(j,{label:s(`remote.layout.label`),children:i(F,{value:l.label??``,maxLength:40,onChange:e=>r(z(t,l.id,{label:e.target.value}))})})]}),i(j,{label:s(`remote.layout.appIcon`),children:i(C,{value:He(l.icon)?.key??``,options:[{value:``,label:s(`remote.layout.noApp`)},...Je.map(e=>({value:e.key,label:e.label}))],onChange:e=>{let n=e.target.value;n===``?He(l.icon)!==void 0&&r(z(t,l.id,{icon:null})):r(z(t,l.id,{icon:V(n)}))},"data-testid":`remote-app-icon`})}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(j,{label:s(`remote.layout.shape`),children:i(C,{value:l.shape??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...T.map(e=>({value:e,label:s(`remote.layout.shapes.${e}`)}))],onChange:e=>{let n=T.find(t=>t===e.target.value);r(Ve(t,l.id,{shape:n??null}))},"data-testid":`remote-shape`})}),i(j,{label:s(`remote.layout.tone`),children:i(C,{value:l.tone??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...A.map(e=>({value:e,label:s(`remote.layout.tones.${e}`)}))],onChange:e=>{let n=A.find(t=>t===e.target.value);r(Ve(t,l.id,{tone:n??null}))},"data-testid":`remote-tone`})})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(j,{label:s(`remote.layout.move`),children:e(`div`,{className:`flex items-center gap-1`,children:[i(N,{icon:S,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveLeft`),onClick:()=>r(R(t,l.id,0,-1))}),i(N,{icon:x,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveUp`),onClick:()=>r(R(t,l.id,-1,0))}),i(N,{icon:_,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveDown`),onClick:()=>r(R(t,l.id,1,0))}),i(N,{icon:y,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveRight`),onClick:()=>r(R(t,l.id,0,1))})]})}),i(j,{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(j,{label:s(`remote.layout.height`),children:i(P,{value:l.rowSpan,onDelta:e=>r(Ie(t,l.id,l.rowSpan+e,l.colSpan))})}),i(j,{label:s(`remote.layout.width`),children:i(P,{value:l.colSpan,onDelta:e=>r(Ie(t,l.id,l.rowSpan,l.colSpan+e))})})]}),e(I,{variant:`danger`,size:`sm`,onClick:a,children:[i(p,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),s(`remote.layout.removeButton`)]})]})}function Ht({grid:t,groupId:n,apply:r,onGone:a}){let{t:o}=L(),s=Re(t,n);if(s===void 0)return null;let c=Qe(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(j,{label:o(`remote.layout.groupTitle`),children:i(F,{value:s.title??``,maxLength:40,onChange:e=>r(je(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(j,{label:o(`remote.layout.separatorSize`),children:i(C,{value:s.size??`compact`,options:[{value:`compact`,label:o(`remote.layout.separatorSizeCompact`)},{value:`normal`,label:o(`remote.layout.separatorSizeNormal`)}],onChange:e=>r(Be(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(we,{checked:s.hideTitle===!0,onChange:e=>r(Be(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(I,{variant:`outline`,size:`sm`,"data-testid":`remote-group-ungroup`,onClick:()=>{r(Ue(t,s.id,!0)),a()},children:[i(se,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.ungroup`)]}),e(I,{variant:`danger`,size:`sm`,"data-testid":`remote-group-delete`,onClick:()=>{r(Ue(t,s.id,!1)),a()},children:[i(p,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.deleteGroup`)]})]})]})}var Ut={remote:{label:e=>e(`remote.templates.kind.remote`),emptyPayload:ze,summary:(e,t)=>{let n=B(e);return t(`remote.templates.layoutSummary`,{columns:n.columns,rows:n.rows,count:n.buttons.length})},renderEditor:(e,t)=>i(zt,{value:B(e),onChange:t}),isSavable:e=>Ke(B(e))!==null,presets:e=>yt.map(t=>({id:t.id,label:e(`remote.templates.preset.${t.id}`),payload:()=>bt(t.id)}))}};function $(e){return Ut[e]}var Wt=O;function Gt(e,t){let n=E(e,t);return n.ok?n.payload:null}s();function Kt({draft:e,saving:t,error:n,onSave:r,onClose:a}){return i(pe,{open:e!==null,onOpenChange:e=>!e&&a(),children:i(he,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:e!==null&&i(qt,{draft:e,saving:t,error:n,onSave:r,onClose:a},e.id??`new`)})})}function qt({draft:t,saving:n,error:r,onSave:a,onClose:s}){let{t:c}=L(),[f,p]=o(t.name),[m,h]=l(rt,{kind:t.kind,presetId:``,payload:t.payload},et),{kind:g,presetId:_,payload:v}=m.present,y=e=>h({type:`edit`,value:{...m.present,payload:e}}),b=()=>h({type:`undo`}),x=()=>h({type:`redo`});Te(`mod+z`,b,{allowInInput:!1,label:`Undo`}),Te(`mod+shift+z`,x,{allowInInput:!1,label:`Redo`});let S=$(g),w=S.presets(c),T=Gt(g,v),E=f.trim()!==``&&T!==null&&S.isSavable(v)&&!n;return e(u,{children:[e(le,{className:`flex-row items-center justify-between gap-2`,children:[i(be,{children:t.id===null?c(`remote.templates.newTitle`):c(`remote.templates.editTitle`)}),e(`div`,{className:`flex shrink-0 items-center gap-1`,children:[i(N,{icon:d,size:`sm`,variant:`ghost`,"aria-label":c(`remote.history.undo`),title:c(`remote.history.undo`),disabled:!tt(m),onClick:b,"data-testid":`template-undo`}),i(N,{icon:ae,size:`sm`,variant:`ghost`,"aria-label":c(`remote.history.redo`),title:c(`remote.history.redo`),disabled:!nt(m),onClick:x,"data-testid":`template-redo`})]})]}),e(me,{className:`space-y-4`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[i(j,{label:c(`remote.templates.name`),children:i(F,{value:f,maxLength:120,onChange:e=>p(e.target.value),"data-testid":`template-name`})}),t.id===null&&Wt.length>1&&i(j,{label:c(`remote.templates.kind.label`),children:i(C,{value:g,options:Wt.map(e=>({value:e,label:$(e).label(c)})),onChange:e=>{let t=Wt.find(t=>t===e.target.value);t!==void 0&&h({type:`edit`,value:{kind:t,presetId:``,payload:$(t).emptyPayload()}})}})}),t.id===null&&w.length>0&&i(j,{label:c(`remote.templates.startFrom`),children:i(C,{value:_,options:[{value:``,label:c(`remote.templates.startBlank`)},...w.map(e=>({value:e.id,label:e.label}))],onChange:e=>{let t=w.find(t=>t.id===e.target.value);h({type:`edit`,value:{kind:g,presetId:t?.id??``,payload:t===void 0?S.emptyPayload():t.payload()}}),t!==void 0&&f.trim()===``&&p(t.label)},"data-testid":`template-preset`})})]}),S.renderEditor(v,y),r!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]}),e(Oe,{children:[i(I,{variant:`ghost`,onClick:s,children:c(`common.cancel`)}),i(I,{disabled:!E,onClick:()=>a({id:t.id,kind:g,name:f.trim(),payload:T}),"data-testid":`template-save`,children:c(`common.save`)})]})]})}s();var Jt=O[0];function Yt(){let{t}=L(),r=c(),s=fe({}),l=Ee(),u=ue(),d=ye(),f=g(),_=b(),[y,x]=o(null),[S,C]=o(null),[w,T]=ke(),E=w.get(We);a(()=>{if(E===null||s.data===void 0)return;let e=s.data.find(e=>e.id===E);e!==void 0&&x({id:e.id,kind:e.kind,name:e.name,payload:e.payload}),T(e=>{let t=new URLSearchParams(e);return t.delete(We),t},{replace:!0})},[E,s.data,T]);let D=()=>void r.invalidateQueries({queryKey:[[`template`]]}),O=async e=>{C(null);try{let t=e.id===null?await l.mutateAsync({kind:e.kind,name:e.name,payload:e.payload}):await u.mutateAsync({id:e.id,name:e.name,payload:e.payload});if(t.status===`refused`){C(t.detail);return}D(),x(null)}catch(e){C(e instanceof Error?e.message:String(e))}},k=async e=>{try{await l.mutateAsync({kind:e.kind,name:t(`remote.templates.copyName`,{name:e.name}),payload:e.payload}),D()}catch(e){await _({title:t(`remote.templates.duplicateFailed`),message:e instanceof Error?e.message:String(e),variant:`danger`})}},ee=async e=>{if(await f({title:t(`remote.templates.deleteTitle`,{name:e.name}),message:t(`remote.templates.deleteMessage`),confirmLabel:t(`common.delete`),variant:`danger`}))try{let n=await d.mutateAsync({id:e.id});if(n.status===`in-use`){await _({title:t(`remote.templates.inUseTitle`,{name:e.name}),message:t(`remote.templates.inUseMessage`,{devices:n.devices.map(e=>e.name).join(`, `)}),variant:`warning`});return}D()}catch(e){await _({title:t(`remote.templates.deleteFailed`),message:e instanceof Error?e.message:String(e),variant:`danger`})}},te=n(()=>[{key:`name`,header:t(`remote.templates.name`),sortValue:e=>e.name.toLowerCase(),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.name})},{key:`kind`,header:t(`remote.templates.kind.label`),sortValue:e=>e.kind,render:e=>i(de,{variant:`neutral`,children:$(e.kind).label(t)})},{key:`summary`,header:t(`remote.templates.summary`),notSortableReason:`A sentence built from the payload.`,render:e=>i(`span`,{className:`text-foreground-muted`,children:$(e.kind).summary(e.payload,t)})},{key:`updated`,header:t(`remote.templates.updated`),sortValue:e=>e.updatedAt,render:e=>i(`span`,{className:`text-foreground-muted`,children:new Date(e.updatedAt).toLocaleDateString()})},{key:`actions`,align:`right`,notSortableReason:`Row actions.`,render:e=>i(ge,{title:t(`remote.templates.actionsFor`,{name:e.name}),items:[{id:`edit`,label:t(`common.edit`),icon:h,onClick:()=>{C(null),x({id:e.id,kind:e.kind,name:e.name,payload:e.payload})}},{id:`duplicate`,label:t(`remote.templates.duplicate`),icon:v,onClick:()=>void k(e)},{id:`delete`,label:t(`common.delete`),icon:p,danger:!0,onClick:()=>void ee(e)}]})}],[t]),ne=s.data??[],A=()=>{C(null),x({id:null,kind:Jt,name:``,payload:$(Jt).emptyPayload()})};return e(Ae,{icon:ie,title:t(`remote.templates.title`),subtitle:t(`remote.templates.subtitle`),actions:e(I,{size:`sm`,onClick:A,"data-testid":`template-new`,children:[i(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`remote.templates.new`)]}),children:[s.status===`error`?i(Se,{title:t(`remote.templates.loadFailed`),message:s.error.message,onRetry:()=>void s.refetch()}):s.data===void 0?i(M,{className:`h-32 w-full`}):ne.length===0?i(xe,{icon:ie,title:t(`remote.templates.emptyTitle`),description:t(`remote.templates.emptyDescription`),action:i(I,{size:`sm`,onClick:A,children:t(`remote.templates.new`)})}):i(De,{columns:te,rows:ne,rowKey:e=>e.id,maxBodyHeight:ce,defaultSort:{columnKey:`name`,dir:`asc`},onRowClick:e=>{C(null),x({id:e.id,kind:e.kind,name:e.name,payload:e.payload})}}),i(Kt,{draft:y,saving:l.isPending||u.isPending,error:S,onSave:e=>void O(e),onClose:()=>x(null)})]})}export{Yt as TemplatesPage};
|