@camstack/addon-admin-ui 1.2.701 → 1.2.702
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 +8 -0
- package/dist/assets/{AccessSection-CmGUVN2c.js → AccessSection-CNgvvC6Q.js} +1 -1
- package/dist/assets/Addons-Dtx3xcZ2.js +5 -0
- package/dist/assets/{AdminPage-Dvziohv2.js → AdminPage-BkxgjFWW.js} +1 -1
- package/dist/assets/{AdminSectionedPage-3F0XiS4h.js → AdminSectionedPage-bGVBepbw.js} +1 -1
- package/dist/assets/AiProfiles-BLj-ic5N.js +3 -0
- package/dist/assets/Archive-y1aPYCx8.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-D5_YCsD2.js → BootstrapSettingsForm-jBRoUiPn.js} +1 -1
- package/dist/assets/{Build-DgzW58SZ.js → Build-BoiB-nPA.js} +4 -4
- package/dist/assets/{Calendars-BzFF94EV.js → Calendars-BBTnm6OG.js} +1 -1
- package/dist/assets/Cluster-DN0Cwciw.js +1 -0
- package/dist/assets/{CompositionBlockEditor-BUQTd-UR.js → CompositionBlockEditor-BloGManS.js} +2 -2
- package/dist/assets/{CompositionEditorPage-BTvOMFXc.js → CompositionEditorPage-C5pNxu2M.js} +1 -1
- package/dist/assets/Data-LT-PQ05n.js +2 -0
- package/dist/assets/{DeviceDetail-C09lWDie.js → DeviceDetail-DAvmtNN2.js} +1 -1
- package/dist/assets/{Devices-DsS5GkXt.js → Devices-BJRvDHiT.js} +1 -1
- package/dist/assets/{EmbedDevicePage-BkW36-q-.js → EmbedDevicePage-CyKS-rmB.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BD43fNk-.js → EmbedPlayerPage-BsxSpEcY.js} +1 -1
- package/dist/assets/History-BPF9alct.js +1 -0
- package/dist/assets/{Identity-DXfvzQIG.js → Identity-dLFVHYZR.js} +1 -1
- package/dist/assets/InstancesTable-LVQWfz07.js +1 -0
- package/dist/assets/IntegrationDetail-C_vN9X7q.js +1 -0
- package/dist/assets/{Integrations-BOc2LGfc.js → Integrations-BUOpFqfh.js} +1 -1
- package/dist/assets/{Integrations-BgRTT3i6.js → Integrations-Dpb2V2yu.js} +1 -1
- package/dist/assets/Library-D4-BDy54.js +1 -0
- package/dist/assets/Locations-DGZ_lrp3.js +3 -0
- package/dist/assets/Logs-CUV00qxb.js +1 -0
- package/dist/assets/{MaskShapeCanvas-BwjxoZHj.js → MaskShapeCanvas-D57fCIme.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CgruOSjK.js → MotionZonesSettings-w1kFM_O4.js} +1 -1
- package/dist/assets/MyAccess-D87gqxHt.js +2 -0
- package/dist/assets/{Network-Dxm48n1Y.js → Network-L7e5c9RP.js} +1 -1
- package/dist/assets/{NewExportModal-DQLl3C3Q.js → NewExportModal-CHwUJ26P.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-H8ruMWFP.js → NodeAddonsSettingsPanel-Kqe8X8RH.js} +1 -1
- package/dist/assets/{Notifications-B44Sd1jg.js → Notifications-CucZNxjj.js} +1 -1
- package/dist/assets/{PanelContent-DnT2f8Cc.js → PanelContent-PhbemYUY.js} +2 -2
- package/dist/assets/Pipeline-9O3YfaWk.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-B6WFh3P4.js → PrivacyMaskSettings-BS29zGkX.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-M-wzPHRE.js → SceneMonitorEditor-CosxkmPM.js} +1 -1
- package/dist/assets/{SessionsList-D0tv-91a.js → SessionsList-OHo3GJ72.js} +2 -2
- package/dist/assets/{Showroom-BlMk46Us.js → Showroom-0iJ0CCe5.js} +1 -1
- package/dist/assets/{StorageLocationsTable-13scCxNp.js → StorageLocationsTable-DqTWO4k1.js} +1 -1
- package/dist/assets/System-DZXA2QSs.js +2 -0
- package/dist/assets/TemplateEditorDialog-8D78AUfO.js +1 -0
- package/dist/assets/{Terminal-BwEVkhLM.js → Terminal-Cvw2rPrb.js} +3 -3
- package/dist/assets/{TrainingProviders-CPc4S7AF.js → TrainingProviders-DcThiLnE.js} +1 -1
- package/dist/assets/{Viewer-B4D9Uq2-.js → Viewer-BUfnqb0c.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D6FI5YpS.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CNNET8uz.js} +1 -1
- package/dist/assets/{action-draft-BIhSMudC.js → action-draft-BTVZLATm.js} +1 -1
- package/dist/assets/{ai-page.helpers-BfJpXMnt.js → ai-page.helpers-qxf7BP-v.js} +1 -1
- package/dist/assets/{assignment-candidates-BfJhT0tz.js → assignment-candidates-d-6NU8po.js} +1 -1
- package/dist/assets/{authed-media-ChKbSmi3.js → authed-media-Bqh0pB9D.js} +1 -1
- package/dist/assets/{board-model-CyseSL_y.js → board-model-CPA2IZpg.js} +1 -1
- package/dist/assets/{camera-block-model-BKFq-3HR.js → camera-block-model-CJ0e2m0o.js} +1 -1
- package/dist/assets/client-Cng2SeYA.js +1122 -0
- package/dist/assets/{command-vocab-CeQ0ypHW.js → command-vocab-BzBhzE7i.js} +1 -1
- package/dist/assets/{device-detail-CFJoqbEo.js → device-detail-Cg2Zt8FL.js} +1 -1
- package/dist/assets/{device-integration-icon-BwgC8WB_.js → device-integration-icon-VMxiVsqd.js} +1 -1
- package/dist/assets/device-picker-model-B-FI9413.js +1 -0
- package/dist/assets/dist-CxrdebAP.js +1122 -0
- package/dist/assets/{dist-Bgy0yfXq.js → dist-D7Gew3v3.js} +1 -1
- package/dist/assets/{format-D9ROMB42.js → format-BopmTOzZ.js} +1 -1
- package/dist/assets/{hostInit-DO8vSCT5.js → hostInit-DuH1KOuD.js} +1 -1
- package/dist/assets/i18n--GTAj4mB.js +1 -0
- package/dist/assets/{icons-DrHUdyj-.js → icons-bi-mcO5N.js} +1 -1
- package/dist/assets/index-DbXFHmBJ.js +6 -0
- package/dist/assets/{linked-devices-model-bymuMeaF.js → linked-devices-model-Bnz1douR.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-dc995488.js → mf-entry-bootstrap-0-ddbe056c.js} +2 -2
- package/dist/assets/mount-B-FI9413.js +1 -0
- package/dist/assets/{notification-rule-status-CyADOgAm.js → notification-rule-status-ai5zWyzt.js} +1 -1
- package/dist/assets/{player-overlays-D546iNTv.js → player-overlays-fpbPSPqT.js} +1 -1
- package/dist/assets/remoteEntry-g0NfB_lk.js +1 -0
- package/dist/assets/{src-C9_yKHH3.js → src-eL0OacoB.js} +18 -18
- package/dist/assets/{sso-popup--gCyd56l.js → sso-popup-Za4GwQBP.js} +1 -1
- package/dist/assets/{step-inspector-model-B_OOCp6Z.js → step-inspector-model-BAgxIyNV.js} +1 -1
- package/dist/assets/{use-scenes-feed-D9kXSeA2.js → use-scenes-feed-BTNdL7JV.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-CF8lG06z.js → useAdminDeviceRemoval-COlTnaF7.js} +1 -1
- package/dist/assets/useEventInvalidation-B-FI9413.js +1 -0
- package/dist/assets/{useNodeUrlSelection-ju70FIba.js → useNodeUrlSelection-DhtJZEtx.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BSgZU_Z3.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-R-1W8c6C.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +205 -19
- package/package.json +2 -2
- package/dist/assets/Addons-CgCQDQsS.js +0 -5
- package/dist/assets/AiProfiles-BAdfHll3.js +0 -3
- package/dist/assets/Archive-tBDnGn2J.js +0 -1
- package/dist/assets/Cluster-Chna0Sjs.js +0 -1
- package/dist/assets/Data-Ge58RjOD.js +0 -2
- package/dist/assets/History-D-ERNFKB.js +0 -1
- package/dist/assets/InstancesTable-BzPfQPuA.js +0 -1
- package/dist/assets/IntegrationDetail-CEcOLviw.js +0 -1
- package/dist/assets/Library-DUI94NI6.js +0 -1
- package/dist/assets/Locations-DkcchiHh.js +0 -3
- package/dist/assets/Logs-DS49QhkO.js +0 -1
- package/dist/assets/MyAccess-TXMLevZM.js +0 -2
- package/dist/assets/Pipeline-XpW32I39.js +0 -1
- package/dist/assets/System-CkjsA5xm.js +0 -2
- package/dist/assets/TemplateEditorDialog-fJjZNx16.js +0 -1
- package/dist/assets/client-DQzHwaNb.js +0 -1122
- package/dist/assets/device-picker-model-CVOfqhXA.js +0 -1
- package/dist/assets/dist-B6zcGpdS.js +0 -1122
- package/dist/assets/i18n-HSlX-YO0.js +0 -1
- package/dist/assets/index-BN2PojUq.js +0 -6
- package/dist/assets/mount-CVOfqhXA.js +0 -1
- package/dist/assets/remoteEntry-CeXhbAxp.js +0 -1
- package/dist/assets/useEventInvalidation-CVOfqhXA.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o 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{In as d,Qa as f,Qn as p,Ua as m,Vn as h,Wi as g,Xi as _,Yn as v,Zt as y,_i as b,aa as x,ir as S,kt as C,oo as w,qn as T,sa as E,tn as D,vi as O,wi as k,yt as A,zr as j}from"./player-overlays-fpbPSPqT.js";import{Qc as M,Xs as N}from"./client-Cng2SeYA.js";import{t as P}from"./chevron-down-CBb-F8DT.js";import{t as F}from"./search-x-C5ra3Aft.js";import{$c as ee,As as I,Bs as L,Da as R,Ds as z,Es as B,Fs as V,Gi as te,Hr as ne,Is as H,Ji as re,Ks as U,Ms as ie,Nt as ae,Oc as W,Os as oe,Sp as G,Ts as K,Ui as se,Us as ce,Vp as q,Wi as J,Wp as le,Xo as Y,Yi as ue,Zo as de,Zs as fe,_o as pe,ai as X,bt as me,cc as he,ci as ge,cl as _e,ec as ve,el as ye,fo as be,gi as Z,i as xe,kr as Se,ks as Ce,lc as we,ll as Te,mp as Q,mr as Ee,oi as De,ol as Oe,pi as ke,qi as Ae,r as je,rl as Me,si as Ne,sl as Pe,tl as Fe,ul as Ie,wt as Le,xa as Re,xt as ze,zs as Be}from"./src-eL0OacoB.js";import{t as $}from"./useTranslation-BJr-n0es.js";import{Ci as Ve,Si as He,Vt as Ue,_t as We,at as Ge,bt as Ke,dt as qe,it as Je,kt as Ye,tt as Xe,vi as Ze,vt as Qe,wi as $e,xt as et,yt as tt}from"./index-DbXFHmBJ.js";import{t as nt}from"./useAdminDeviceRemoval-COlTnaF7.js";import{t as rt}from"./device-integration-icon-VMxiVsqd.js";c();function it(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...it(n.fields));return t}function at(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...it(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}c();function ot(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...ot(n.fields));return t}function st(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function ct(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){ct(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function lt(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ut(e,t){let n=he({addonId:e,integrationId:t}),r=n.data?.deviceType??null,i=U({addonId:e,integrationId:t,type:r??N.Camera},{enabled:n.isSuccess&&r!==null});return n.isError?`unavailable`:n.isLoading?`loading`:r===null||i.isError?`unavailable`:i.isLoading||!i.isSuccess?`loading`:((i.data??null)?.sections??[]).some(e=>e.fields.length>0)?`available`:`unavailable`}function dt({integrationId:t,addonId:s,onClose:c}){let{t:d}=$(),f=l(),[p,m]=o({}),[g,_]=o(!1),[v,b]=o(null),[x,S]=o(lt),w=he({addonId:s,integrationId:t},{enabled:!0}),T=w.data?.deviceType??null,E=U({addonId:s,integrationId:t,type:T??N.Camera},{enabled:w.isSuccess&&T!==null}),D=E.data??null;a(()=>{m(D?ct(D.sections.flatMap(e=>e.fields)):{}),S(lt()),_(!1),b(null)},[!0,t,D]);let O=n(()=>({...p,_probeRequestId:x}),[p,x]),k=V({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),A=W(),M=r(async(e,t)=>{_(!0);let n=await A.mutateAsync({addonId:s,type:T??N.Camera,key:e,value:t,formValues:O});return n.status===`ok`&&n.suggestedValues&&m(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))st(e[i])&&!st(a)&&(r[i]=a,t=!0);return t?r:e}),n},[A,s,O,T]),{testAllStatus:F,hasProbeFields:ee,probeResults:I,handleTestAll:L,clearProbeResult:R}=at(D??{sections:[]},p,M);async function z(e){b(null);try{await k.mutateAsync({addonId:s,type:T??N.Camera,config:p,integrationId:t}),e?m(D?ct(D.sections.flatMap(e=>e.fields)):{}):c()}catch(e){b(e instanceof Error?e.message:String(e))}}let B=ot((D?.sections??[]).flatMap(e=>e.fields)).filter(e=>st(p[e])),te=B.length===0,ne=w.isLoading||T!==null&&E.isLoading,H=w.isError||w.isSuccess&&T===null||E.isError||E.isSuccess&&D===null;return e(u,{children:[i(J,{className:`space-y-3`,children:ne?i(`div`,{className:`flex items-center justify-center py-8`,children:i(j,{className:`h-5 w-5 animate-spin text-primary`})}):H?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[i(y,{className:`h-4 w-4 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:d(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(Ze,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:s},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ue,{schema:D,values:p,onChange:m,onTestField:M,probeResults:I,onClearProbe:R})}),!H&&!ne&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(Q,{variant:`unstyled`,type:`button`,onClick:()=>_(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(h,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:x.slice(0,14)})]}),i(P,{className:`h-3.5 w-3.5 transition-transform ${g?`rotate-180`:``}`})]}),g&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(Ee,{addonId:s,requestId:x,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!H&&!ne&&(v||B.length>0)&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(y,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:v||d(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:B.join(`, `)})})]})}),e(Ae,{className:`justify-between`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(Q,{variant:`unstyled`,onClick:c,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:d(`integrations.cancel`)}),!H&&ee&&e(Q,{variant:`unstyled`,type:`button`,onClick:L,disabled:F===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[F===`testing`?i(j,{className:`h-3.5 w-3.5 animate-spin`}):i(C,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(Q,{variant:`unstyled`,onClick:()=>z(!0),disabled:H||!te||k.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:d(`integrations.saveAndNew`)}),i(Q,{variant:`unstyled`,onClick:()=>z(!1),disabled:H||!te||k.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:k.isPending?d(`integrations.saving`):d(`integrations.save`)})]})]})]})}var ft=1500;function pt({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=$(),s=B(),c=(Ce({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?ft:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let p=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(j,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(y,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(g,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(_,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:p}),l&&i(Q,{variant:`unstyled`,onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function mt(e){let t=e.map(e=>({...e,stableId:e.childNativeId})),n=new Map(e.map(e=>[e.childNativeId,e])),r=(e,t,i)=>e.flatMap(e=>{let a=n.get(e.candidate.childNativeId);return a===void 0?[]:[{candidate:a,depth:t,...i===void 0?{}:{parentName:i}},...r(e.children,t+1,a.name)]});return r(Je(t),0)}function ht(e){let t=e.metadata?.model,n=e.childNativeId.split(`:`).pop()??``;return[typeof t==`string`?t:``,n].filter(e=>e.length>0).join(` · `)}function gt(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}c();var _t=`devices`;function vt(e){return{id:_t,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var yt=2e4,bt=100;function xt({addonId:s,integrationId:c,onClose:d}){let p=w(),{t:m}=$(),h=l(),[g,_]=o(new Set),[v,b]=o(new Set),[x,S]=o(new Map),[C,D]=o(null),{data:O}=_e(),k=(O??[]).find(e=>e.addonId===s)?.supportsLocationImport??!1,[A,M]=o(!0),N=z({addonId:s,integrationId:c}).data?.filters,P=N&&N.length>0?N:[vt(m)],[F,ee]=o(P.find(e=>e.isDefault)?.id??(P.some(e=>e.id===_t)?_t:P[0].id)),L=F!==_t,R=I(),B=oe({addonId:s,integrationId:c,page:1,pageSize:yt,filter:F}),V=B.refetch,te=R.mutate,ne=r(()=>{te({addonId:s,integrationId:c},{onSettled:()=>{V()}})},[te,s,c,V]),H=t(null);a(()=>{let e=`${s}::${c}`;H.current===e||B.isLoading||(H.current=e,(B.data?.candidates.length??0)===0&&ne())},[s,c,B.isLoading,B.data,ne]);let re=R.isPending,U=R.isError?R.error instanceof Error?R.error.message:String(R.error):null,ae=typeof R.data?.lastError==`string`&&R.data.lastError.length>0?R.data.lastError:null,W=B.data?.candidates??[],G=n(()=>mt(W),[W]),K=n(()=>new Map(G.map(e=>[e.candidate.childNativeId,e.depth])),[G]),se=n(()=>new Map(G.map(e=>[e.candidate.childNativeId,e.parentName])),[G]),ce=B.isError?B.error instanceof Error?B.error.message:String(B.error):null,J=ie(),[Y,ue]=o(null),de=r(e=>{e.alreadyAdopted||_(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),fe=r(e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pe=r((e,t)=>{S(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),X=r(e=>{let t={};for(let n of e){let e=x.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[x]),he=r(async()=>{D(null);let e=[...g];if(e.length!==0)try{let t=X(e),{jobId:n}=await J.mutateAsync({addonId:s,integrationId:c,filter:F,childNativeIds:e,...t?{perCandidate:t}:{},...k?{importLocations:A}:{}});ue(n),_(new Set),S(new Map)}catch(e){D(e instanceof Error?e.message:String(e))}},[g,X,J,s,c,F,k,A]),ge=t(null),ve=r(()=>{Y===null||ge.current===Y||(ge.current=Y,V(),h.invalidateQueries({queryKey:[[`integrations`]]}),h.invalidateQueries({queryKey:[[`deviceManager`]]}))},[Y,V,h]),ye=r(e=>{ee(e),_(new Set),b(new Set),S(new Map),D(null)},[]),be=g.size,Z=Y!==null&&be===0&&!J.isPending;return e(u,{children:[k&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(f,{checked:A,onChange:e=>M(e.target.checked),className:`accent-primary`}),m(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),e(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2 overflow-hidden`,children:[(U??ce??ae)&&W.length===0&&i(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(y,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:m(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-danger/90 mt-0.5`,children:U??ce??ae})]})]})}),P.length>1&&i(St,{filters:P,activeFilter:F,onSelect:ye}),i(`div`,{className:`flex-1 min-h-0`,children:i(me,{mode:`generic`,items:G.map(e=>e.candidate),pageSize:bt,getKey:e=>e.childNativeId,getSearchText:gt,getFilterType:e=>e.type,filterOptions:q(p),filterLabel:m(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:B.isLoading||re&&W.length===0,searchPlaceholder:m(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(U??ce??ae)&&W.length===0?``:m(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(Q,{variant:`unstyled`,type:`button`,onClick:ne,disabled:re,title:m(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(T,{className:`h-3.5 w-3.5 ${re?`animate-spin`:``}`}),m(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:m(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-full sm:w-[55%]`,cellClassName:`max-w-0`,cell:e=>i(Ct,{candidate:e,depth:K.get(e.childNativeId)??0,...se.get(e.childNativeId)===void 0?{}:{containerName:se.get(e.childNativeId)},expandable:!L,expanded:v.has(e.childNativeId),onToggleExpand:()=>fe(e.childNativeId),adoptedLabel:m(`integrations.adoptAlready`,{defaultValue:`Adopted`}),typeLabel:le(e.type,p).label})},{key:`type`,header:m(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=le(t.type,p),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-10 sm:w-[15%] text-right`,cellClassName:`text-right`,cell:e=>i(`div`,{className:`flex items-center justify-end`,children:i(Q,{variant:`unstyled`,onClick:()=>de(e),disabled:e.alreadyAdopted,"aria-label":g.has(e.childNativeId)?m(`integrations.adoptDevicesModal.deselect`,`Deselect`):m(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${g.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:g.has(e.childNativeId)&&i(E,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!L&&v.has(e.childNativeId),renderExpanded:L?void 0:e=>i(wt,{candidate:e,hiddenChildIds:x.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>pe(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:g.has(e.childNativeId)?`bg-primary/5`:``})})]}),C&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(y,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:C})]})}),Y!==null&&i(pt,{addonId:s,integrationId:c,jobId:Y,onFinished:ve}),e(Ae,{children:[i(Q,{variant:`outline`,size:`sm`,onClick:d,children:m(`integrations.cancel`,{defaultValue:`Cancel`})}),e(Q,{variant:`primary`,size:`sm`,onClick:Z?d:he,disabled:!Z&&(be===0||J.isPending),children:[J.isPending&&i(j,{className:`h-3.5 w-3.5 animate-spin`}),Z?m(`integrations.close`,{defaultValue:`Close`}):m(`integrations.addSelected`,{defaultValue:`Add selected`}),!Z&&be>0?` (${be})`:``]})]})]})}function St({filters:e,activeFilter:t,onSelect:n}){let{t:r}=$();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(Q,{variant:`unstyled`,type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function Ct({candidate:t,depth:n,containerName:r,expandable:a,expanded:o,onToggleExpand:s,adoptedLabel:c,typeLabel:l}){let{t:u}=$(),d=(t.children??[]).length,f=ht(t);return e(`div`,{className:`flex items-center gap-2.5 min-w-0 ${n>0?`pl-5`:``}`,children:[a&&d>0?e(Q,{variant:`unstyled`,type:`button`,onClick:s,"aria-label":o?u(`integrations.adoptDevicesModal.collapse`,`Collapse`):u(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":o,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(o?P:x,{className:`h-3.5 w-3.5`}),d]}):a?i(`span`,{className:`h-5 w-5 flex-shrink-0`,"aria-hidden":`true`}):null,e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`truncate text-xs font-medium text-foreground`,"data-testid":`candidate-name`,children:t.name}),f.length>0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-subtitle`,children:f}),r!==void 0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-container`,children:u(`integrations.adoptDevicesModal.inContainer`,`in {{name}}`,{name:r})}),i(`div`,{className:`truncate text-[10px] text-foreground-subtle sm:hidden`,children:l})]}),t.alreadyAdopted&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:c})]})}function wt({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=$(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(Q,{variant:`unstyled`,onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?O:b,{className:`h-3 w-3`})})]},t.childNativeId)})})}function Tt(e){let t=e.host;return typeof t==`string`&&t.length>0?t.toLowerCase():null}function Et(e){return e===null?[]:[`host:${e}`]}function Dt(e){let t=[],n=new Map,r=(e,r)=>{let i=e.map(e=>n.get(e)).find(e=>e!==void 0),a=i??r();i===void 0&&t.push(a);for(let t of e)a.ids.add(t),n.set(t,a);return a},i=(e,t)=>{e.sources.includes(t)||e.sources.push(t)};for(let t of e.adoption){let e=r([t.childNativeId],()=>({key:t.childNativeId,ids:new Set,name:t.name,address:null,sources:[],hit:null,adoptionId:t.childNativeId,proposalId:null,alreadyAdded:!1,addedName:null,needsParams:[],parentId:t.parentStableId??null}));i(e,`adoption`),e.adoptionId=t.childNativeId,t.alreadyAdopted===!0&&(e.alreadyAdded=!0)}let a=(t,n,a)=>{let o=Tt(t.prefilledConfig),s=r([t.stableId,...Et(o)],()=>({key:t.stableId,ids:new Set,name:t.suggestedName,address:o,sources:[],hit:null,adoptionId:null,proposalId:null,alreadyAdded:!1,addedName:null,needsParams:[],parentId:null}));i(s,n),(s.hit===null||n===`scan`)&&(s.hit=t),s.name=t.suggestedName,s.address=o??s.address,a!==null&&(s.proposalId=a),s.parentId=t.parentStableId??s.parentId,s.needsParams=t.needsParams??s.needsParams,(t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0||e.existingStableIds.has(t.stableId))&&(s.alreadyAdded=!0,s.addedName=t.onboardedName??s.addedName)};for(let t of e.scan)a(t,`scan`,null);for(let t of e.proposals)a(t.candidate,`proposal`,t.id);for(let n of t)[...n.ids].some(t=>e.existingStableIds.has(t))&&(n.alreadyAdded=!0);return t.map(e=>{let t=e.parentId===null?void 0:n.get(e.parentId);return{key:e.key,name:e.name,address:e.address,sources:e.sources,hit:e.hit,adoptionId:e.adoptionId,proposalId:e.proposalId,alreadyAdded:e.alreadyAdded,addedName:e.addedName,needsParams:e.needsParams,parentKey:t!==void 0&&t!==e?t.key:null}})}c();var Ot=500;function kt(e){return e instanceof Error?e.message:String(e)}function At(e,t){let n={};for(let t of e?.sections??[])for(let e of t.fields)`key`in e&&e.key&&`default`in e&&e.default!==void 0&&(n[e.key]=e.default);return{...n,...t}}function jt({addonId:t,integrationId:a,onClose:s,alongsideAdoption:c=!1}){let{t:d}=$(),f=l(),m=we({addonId:t}).data??null,[h,g]=o({}),_=Be(),v=ve({}),y=oe({addonId:t,integrationId:a,page:1,pageSize:Ot},{retry:!1}),{data:b}=fe({projection:`slim`}),x=K(),S=ie(),[C,w]=o(new Set),[T,E]=o(new Set),[D,O]=o(null),[k,A]=o(null),M=n(()=>{let e=(y.data?.candidates??[]).map(e=>({childNativeId:e.childNativeId,name:e.name,alreadyAdopted:e.alreadyAdopted,parentStableId:e.parentStableId})),n=(v.data?.proposals??[]).filter(e=>e.addonId===t&&!Ge(e.candidate)).map(e=>({id:e.id,candidate:e.candidate}));return Dt({adoption:e,scan:(_.data?.candidates??[]).filter(e=>!Ge(e)),proposals:n,existingStableIds:new Set((b??[]).map(e=>e.stableId))})},[y.data,v.data,_.data,b,t]),N=e=>e.hit!==null&&e.needsParams.length>0,P=n(()=>c?M.filter(e=>!e.sources.includes(`adoption`)||N(e)):M,[M,c]),F=c?M.filter(e=>e.sources.includes(`adoption`)&&e.hit!==null&&!P.includes(e)).length:0,ee=r(e=>{let t=new Map(P.map(e=>[e.key,e])),n=0,r=e;for(;r?.parentKey!=null&&n<8&&(r=t.get(r.parentKey),r!==void 0);)n+=1;return n},[P]),I=r(()=>{O(null),_.mutate({addonId:t,params:h})},[_,t,h]),L=r(async(e,t)=>{w(t=>new Set(t).add(e)),O(null);try{await t(),E(t=>new Set(t).add(e)),f.invalidateQueries({queryKey:[[`deviceManager`]]}),f.invalidateQueries({queryKey:[[`integrations`]]})}catch(e){O(kt(e))}finally{w(t=>{let n=new Set(t);return n.delete(e),n})}},[f]),R=r(async(e,n)=>{let r=e.hit;if(r!==null){await L(e.key,async()=>{await x.mutateAsync({addonId:t,integrationId:a,candidate:{...r,prefilledConfig:{...r.prefilledConfig,...n}}}),A(null)});return}if(e.adoptionId!==null){let n=e.adoptionId;await L(e.key,async()=>{await S.mutateAsync({addonId:t,integrationId:a,childNativeIds:[n]})})}},[x,S,t,a,L]),z=r(e=>{if(e.needsParams.length>0&&e.hit!==null){O(null),A(e);return}R(e)},[R]);if(k!==null&&k.hit!==null)return i(Pt,{addonId:t,integrationId:a,row:k,found:k.hit.prefilledConfig,busy:C.has(k.key),error:D,embedded:c,onBack:()=>A(null),onSubmit:e=>void R(k,e)});let B=P.length===0,V=e(u,{children:[i(Xe,{}),m&&i(Ue,{schema:m,values:h,onChange:g}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`p`,{className:`text-xs text-foreground-subtle`,children:[_.isPending?d(`integrations.addDeviceModal.scanning`,`Scanning the local network…`):P.length>0?d(`integrations.addDeviceModal.found`,{defaultValue_one:`{{count}} device found`,defaultValue_other:`{{count}} devices found`,count:P.length}):``,!_.isPending&&F>0?` · ${d(`integrations.addDeviceModal.alsoAdopted`,{defaultValue_one:`{{count}} also in the adoption list`,defaultValue_other:`{{count}} also in the adoption list`,count:F})}`:``]}),e(Q,{variant:`outline`,size:`sm`,onClick:I,disabled:_.isPending,children:[_.isPending?i(j,{className:`h-3.5 w-3.5 animate-spin`}):i(p,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceModal.scanNow`,`Scan now`)]})]}),_.isError&&i(Mt,{text:d(`integrations.addDeviceModal.scanFailed`,`The scan failed. Try again.`)}),D!==null&&i(Mt,{text:D}),B&&!_.isPending&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:_.data?d(`integrations.addDeviceModal.nothingFound`,`No devices responded to the scan.`):d(`integrations.addDeviceModal.scanHint`,`Scan the network to find devices to add.`)}),i(`div`,{className:c?`max-h-48 space-y-1.5 overflow-y-auto`:`space-y-1.5`,"data-testid":`network-candidates`,children:P.map(e=>i(Nt,{row:e,depth:ee(e),busy:C.has(e.key),added:T.has(e.key),onPick:z},e.key))})]});return c?i(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:V}):e(u,{children:[i(J,{className:`space-y-3`,children:V}),i(Ae,{children:i(Q,{variant:`outline`,size:`sm`,onClick:s,children:d(`integrations.close`,`Close`)})})]})}function Mt({text:t}){return e(`div`,{className:`flex items-start gap-2 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2`,children:[i(y,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-danger`}),i(`p`,{className:`text-xs text-danger`,children:t})]})}function Nt({row:t,depth:n,busy:r,added:a,onPick:o}){let{t:s}=$(),c=t.alreadyAdded||a,l=t.hit?.selectable!==!1,u=t.needsParams.length>0;return e(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2 ${n>0?`ml-4`:``}`,"data-testid":`network-row-${t.key}`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),t.address!==null&&i(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:t.address}),c&&t.addedName!==null&&i(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addedName})]}),c?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(E,{className:`h-3.5 w-3.5`}),t.alreadyAdded?s(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):s(`integrations.scanNetworkModal.added`,`Added`)]}):l?e(Q,{size:`sm`,variant:u?`outline`:`primary`,onClick:()=>o(t),disabled:r,children:[r?i(j,{className:`h-3.5 w-3.5 animate-spin`}):u?null:i(k,{className:`h-3.5 w-3.5`}),u?s(`integrations.addDeviceModal.enterDetails`,`Enter details`):s(`common.add`,`Add`)]}):null]})}function Pt({addonId:t,integrationId:n,row:r,found:a,busy:s,error:c,onBack:l,onSubmit:d,embedded:f}){let{t:p}=$(),h=he({addonId:t,integrationId:n}),g=h.data?.deviceType??null,_=U({addonId:t,integrationId:n,type:g??N.Camera},{enabled:h.isSuccess&&g!==null}),v=_.data??null,[y,b]=o(null),x=y??At(v,a),S=h.error??_.error,C=h.isSuccess&&g===null,w=v!==null,T=w?i(Ue,{schema:v,values:x,onChange:b}):S?i(Mt,{text:kt(S)}):C?i(`p`,{className:`text-xs text-foreground-muted`,children:p(`integrations.addDeviceModal.noCreationType`,`This integration cannot create a device from this candidate.`)}):i(j,{className:`mx-auto h-5 w-5 animate-spin text-primary`}),E=e(u,{children:[e(Q,{variant:`ghost`,size:`sm`,onClick:l,children:[i(m,{className:`h-3.5 w-3.5`}),p(`integrations.addDeviceModal.back`,`Back to the list`)]}),i(`p`,{className:`text-xs font-medium text-foreground`,children:r.name}),T,c!==null&&i(Mt,{text:c})]}),D=e(u,{children:[i(Q,{variant:`outline`,size:`sm`,onClick:l,children:p(`integrations.cancel`,`Cancel`)}),e(Q,{variant:`primary`,size:`sm`,onClick:()=>d(x),disabled:s||!w,children:[s&&i(j,{className:`h-3.5 w-3.5 animate-spin`}),p(`common.add`,`Add`)]})]});return f?e(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:[E,i(`div`,{className:`flex justify-end gap-2`,children:D})]}):e(u,{children:[i(J,{className:`space-y-3`,children:E}),i(Ae,{children:D})]})}c();function Ft(e){return e===`manual`?`manual`:e===`pairing`?`pairing`:`network`}function It({reason:e}){let{t}=$();return i(J,{children:i(R,{message:t(`integrations.addDeviceModal.scanUnavailable`,{defaultValue:`The network scan is unavailable for this integration: {{reason}}`,reason:e})})})}function Lt({addonId:t,integrationId:n,kind:r,canScan:a,scanFailure:s=null,onClose:c,pairing:l}){let{t:d}=$(),f=ut(t,n),p=r===`device-adoption`&&a===null,m=r===`device-adoption`||a===!0||s!==null,h=f===`available`,[g,_]=o(null),v=g??(l===void 0?m?`network`:`manual`:`pairing`),y=[m,h,l!==void 0].filter(Boolean).length,b=p?i(J,{children:i(j,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):r===`device-adoption`?e(u,{children:[s!==null&&i(It,{reason:s}),a===!0&&i(jt,{addonId:t,integrationId:n,onClose:c,alongsideAdoption:!0}),i(xt,{addonId:t,integrationId:n,onClose:c})]}):s===null?i(jt,{addonId:t,integrationId:n,onClose:c}):i(It,{reason:s}),x=i(dt,{integrationId:n,addonId:t,onClose:c});return i(se,{open:!0,onOpenChange:e=>{e||c()},children:e(te,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,className:r===`device-adoption`?`md:h-[85vh]`:void 0,children:[i(re,{children:i(ue,{children:d(`integrations.addDevice`,`Add device`)})}),y>1?e(X,{value:v,onValueChange:e=>_(Ft(e)),children:[e(Ne,{children:[m&&i(ge,{value:`network`,children:d(`integrations.addDeviceModal.tabNetwork`,`Found on the network`)}),h&&i(ge,{value:`manual`,children:d(`integrations.addDeviceModal.tabManual`,`Enter parameters`)}),l!==void 0&&i(ge,{value:`pairing`,children:l.label})]}),m&&i(De,{value:`network`,children:b}),h&&i(De,{value:`manual`,children:x}),l!==void 0&&i(`div`,{role:`tabpanel`,id:`tabpanel-pairing`,hidden:v!==`pairing`,className:`pt-3`,children:l.render({onPaired:()=>_(`network`)})})]}):l!==void 0&&!m&&!h?l.render({onPaired:()=>_(`network`)}):m?b:h?x:f===`loading`?i(J,{children:i(j,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):i(J,{children:i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:d(`integrations.addDeviceModal.nothingToAdd`,`This integration has no way to add a device from here.`)})})]})})}c();var Rt=`matter`,zt=[`discovering`,`pase`,`commissioning`,`done`];function Bt(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function Vt(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function Ht({onClose:t,onCommissioned:n}){let{t:r}=$(),s=xe({kind:Rt}),[c,l]=o(null),d=je(s.data??[],c),f=d.length,p=c??d[0]?.id??null,m=de(),[h,g]=o(``),[_,v]=o({phase:`idle`,failure:null,message:null}),y=_.phase===`discovering`||_.phase===`pase`||_.phase===`commissioning`,b=Y({brokerId:p??``,key:`commission`},{enabled:p!==null&&y,refetchInterval:y?400:!1});a(()=>{y&&Bt(b.data)&&b.data.phase!==`idle`&&v({phase:b.data.phase,failure:typeof b.data.failure==`string`?b.data.failure:null,message:typeof b.data.message==`string`?b.data.message:null})},[y,b.data]);let x=()=>{p!==null&&(v({phase:`discovering`,failure:null,message:null}),m.mutate({brokerId:p,target:{action:`commissionNode`},payload:{pairingCode:h.trim()}},{onSuccess:()=>v({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;v({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},S=_.phase===`failed`?Vt(_.failure,_.message):null,C=S===null?null:r(S.key,{defaultValue:S.defaultValue}),w=(s.isSuccess===!0||s.data!==void 0)&&p===null;return e(u,{children:[e(J,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.addMatter.help`,{defaultValue:`In Home Assistant, open the device and choose Share device. Paste the numeric code or the MT: code here. The device stays in Home Assistant.`})}),(w||f>1)&&!y&&_.phase!==`done`&&e(`div`,{className:`space-y-1.5`,children:[i(Z,{children:r(`integrations.addMatter.broker`,{defaultValue:`Matter fabric`})}),i(Ke,{kind:Rt,value:p,onChange:l})]}),!w&&e(`div`,{className:`space-y-1.5`,children:[i(Z,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(G,{id:`matter-pairing-code`,value:h,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:y||_.phase===`done`,onChange:e=>g(e.target.value)})]}),_.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":r(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:zt.map(t=>{let n=_.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&y?i(j,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,r(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),C!==null&&i(R,{message:C})]}),e(Ae,{children:[i(Q,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),_.phase===`done`?i(Q,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(Q,{size:`sm`,disabled:y||w||h.trim().length===0,onClick:x,children:y?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})}function Ut({addonId:t,integrationId:n,name:r,onClose:a,onSaved:o}){let{t:c}=$(),l=A(),u=s({queryKey:[`integration-instance-describe`,t],queryFn:()=>l.trpcClient.integrationInstances.describe.query({addonId:t})}),d=s({queryKey:[`integration-instance`,t,n],queryFn:()=>l.trpcClient.integrationInstances.getInstance.query({addonId:t,id:n})});if(u.isSuccess&&d.isSuccess&&d.data!==null)return i(et,{addonId:t,providerName:r,description:u.data,instance:d.data,onClose:a,onSaved:()=>o()});let f=u.isError||d.isError||d.isSuccess&&!d.data;return i(se,{open:!0,onOpenChange:e=>!e&&a(),children:e(te,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(re,{children:e(ue,{children:[c(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,r]})}),i(J,{children:f?i(`p`,{className:`text-[11px] text-danger`,children:c(`integrations.loadFailed`,{defaultValue:`Could not load this integration.`})}):e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(j,{className:`h-3 w-3 animate-spin`}),c(`integrations.loading`,{defaultValue:`Loading…`})]})})]})})}c();function Wt(){let{addonId:e=``}=Ve();return i(Kt,{addonId:e})}function Gt(){return e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]})}function Kt({addonId:t}){let{t:c}=$(),u=l(),f=He(),[p,g]=$e(),_=A(),[y,b]=o(!1),[x,C]=o(!1),[w,T]=o(!1),{data:E}=Te(void 0),O=n(()=>(E??[]).filter(e=>e.addonId===t),[E,t]),k=tt(p.get(We),O)??``,N=r(e=>{g(t=>{let n=new URLSearchParams(t);return n.set(We,e),n},{replace:!0})},[g]),P=n(()=>O.map(e=>({value:e.id,label:e.name})),[O]),{data:I,isLoading:R}=Pe({id:k},{enabled:!!k}),{data:z,isSuccess:B}=_e(),V=n(()=>{let e=I?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[z,I?.addonId,B]),{data:U,isPending:ie}=L({}),{data:W,isPending:oe}=be({capName:`integration-instances`}),G=(W??[]).some(e=>e.addonId===t),K=ye({addonId:t},{retry:!1,enabled:G}),q=Fe({addonId:t,id:k},{retry:!1,enabled:G&&k!==``}),{canScan:le,scanFailure:Y}=n(()=>{if(ie||oe||G&&(K.isPending||q.isPending))return{canScan:null,scanFailure:null};if(!(U?.providers??[]).some(e=>e.addonId===I?.addonId))return{canScan:!1,scanFailure:null};if(!G)return{canScan:!0,scanFailure:null};let e=K.isError?K.error:q.isError?q.error:null;if(K.isError||q.isError){let t=e instanceof Error?e.message:``;return{canScan:!1,scanFailure:t.length>0?t:`unknown error`}}return{canScan:(q.data?.addDevice??(K.data===void 0?`none`:M(K.data)))===`scan`,scanFailure:null}},[ie,oe,G,K.isPending,K.isError,K.error,K.data,q.isPending,q.isError,q.error,q.data,U,I?.addonId]),de=V!==null,X=I?.info?.fixed===!0,he=n(()=>{let e=I?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.brokerKind??null},[z,I?.addonId,B])===`matter`,ge=de?c(`integrations.addDevice`,`Add device`):c(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),ve=n(()=>{let e=I?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.mode??null},[z,I?.addonId,B]);a(()=>{p.get(`add`)===`1`&&de&&(b(!0),g(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[p,de,g]);let{data:Z}=s({queryKey:[`integration-instance-form`,I?.addonId,I?.id],enabled:!!I?.addonId&&!!I?.id,queryFn:()=>_.trpcClient.integrationInstances.instanceFormSchema.query({addonId:I?.addonId??``,id:I?.id??``})}),xe=Z!=null&&Array.isArray(Z.sections)&&Z.sections.some(e=>e.fields.length>0),{data:Ce}=fe({projection:`slim`},{refetchInterval:3e4}),we=[[`integrations`,`get`],{input:{id:k},type:`query`}],De={onMutate:async e=>{await u.cancelQueries({queryKey:we});let t=u.getQueryData(we);return t!=null&&u.setQueryData(we,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&u.setQueryData(we,r.previous)},onSettled:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}},Ae=Me(De),je=Ie(De),Ne={isPending:Ae.isPending||je.isPending,mutate:e=>X&&I?.processState!==`running`?je.mutate({id:e.id,enabled:e.enabled}):Ae.mutate(e)},Be=I?.switchUnknown===!0,Ve=Ye(I?.processState),Ue=Be||!X&&Ve,Ge={onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]}),f(O.length>1?Qe(t):`/integrations`)}},Ke=ee(Ge),qe=Oe(Ge),Je=I?.processState===`running`,Xe={isPending:Ke.isPending||qe.isPending,mutateAsync:async e=>{Je?await Ke.mutateAsync(e):await qe.mutateAsync({id:e.id})}},Ze=pe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),et=nt(),it=H({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),at=ce({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ot=n(()=>Ce??[],[Ce]),st=n(()=>ae(ot),[ot]),ct=r(e=>st.get(e)??null,[st]),lt=n(()=>ze(E),[E]),ut=r(e=>f(`/devices/${String(e)}`),[f]),dt=n(()=>ot.filter(e=>{let t=lt(e);return t.kind===`resolved`&&t.integration.id===k}),[ot,k,lt]),ft=n(()=>E===void 0?null:Le(dt).length,[E,dt])??`…`;if(R||E===void 0)return i(Gt,{});let pt=(z??[]).find(e=>e.addonId===t)?.name??I?.name??t,mt=Ue&&Ve?c(`providerInstances.addonNotRunning`,`{{addon}} is not running: start it first`,{addon:pt}):null;return I?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(ne,{items:[{label:c(`integrationDetail.integrations`,`Integrations`),onClick:()=>f(`/integrations`)},{label:pt}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(qt,{addonId:I.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:pt}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[ft,` `,c(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!X&&e(Q,{variant:`unstyled`,onClick:()=>{b(!0)},disabled:!de,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:ge,children:[i(S,{className:`h-3.5 w-3.5`}),ge]}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ne.isPending?`opacity-60`:``} ${I.enabled&&!Be?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:mt??c(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(ke,{checked:I.enabled&&!Be,onCheckedChange:e=>Ne.mutate({id:k,addonId:I?.addonId,enabled:e}),disabled:Ne.isPending||Ue,"aria-label":Be?c(`integrationDetail.switchUnknown`,`Unknown`):I.enabled?c(`integrationDetail.disableIntegration`,`Disable integration`):c(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${I.enabled&&!Be?`text-success`:`text-foreground-subtle`}`,children:Be?c(`integrationDetail.switchUnknown`,`Unknown`):I.enabled?c(`integrationDetail.enabled`,`Enabled`):c(`integrationDetail.disabled`,`Disabled`)}),Ne.isPending&&i(j,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),mt!==null&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:mt})]}),ve!==`standalone`&&(xe||V===`device-adoption`)&&e(Q,{variant:`unstyled`,onClick:()=>C(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[i(d,{className:`h-3 w-3`}),c(`integrations.config`)]}),e(Q,{variant:`unstyled`,onClick:()=>T(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:c(`integrations.logs`,{defaultValue:`View logs`}),children:[i(h,{className:`h-3 w-3`}),c(`integrations.logs`,{defaultValue:`Logs`})]}),i(Se,{label:c(`integrationDetail.restart`,`Restart`),icon:v,title:c(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:I.name}),description:c(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:ft}),confirmLabel:c(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Ze.isPending,action:()=>Ze.mutateAsync({addonId:I.addonId})}),!X&&k&&i(Se,{label:c(`integrations.delete`,{defaultValue:`Delete`}),icon:D,title:c(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:c(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:I.name,count:ft}),confirmLabel:c(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Xe.isPending,action:()=>Xe.mutateAsync({addonId:t,id:k})})]})]}),O.length>1&&i(`div`,{className:`max-w-sm`,children:i(Re,{mode:`single`,singleDisplay:`field`,label:c(`integrationDetail.instances`,`Integration`),options:P,value:k,onChange:N,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),i(me,{context:`integration-detail`,devices:ot,trpc:_.trpcClient,integrationOf:lt,forceIntegrationId:k,urlScope:`root`,lsKey:`integration-detail:${I.addonId}`,resolveIntegrationIcon:rt,resolveParent:ct,onNavigate:ut,rowOperation:et.rowOperation,batchActions:{remove:et.remove,disable:it.mutate,enable:at.mutate},...X?{}:{onDeleteDevice:e=>et.remove({deviceId:e.id})}}),y&&k&&V!==null&&i(Lt,{addonId:I.addonId,integrationId:k,kind:V,canScan:le,scanFailure:Y,...he?{pairing:{label:c(`integrations.addMatter.tab`,`Pairing code`),render:({onPaired:e})=>i(Ht,{onClose:()=>b(!1),onCommissioned:e})}}:{},onClose:()=>b(!1)}),x&&k&&i(Ut,{addonId:I.addonId,integrationId:k,name:I.name,onClose:()=>C(!1),onSaved:()=>{u.invalidateQueries()}}),w&&i(se,{open:!0,onOpenChange:e=>!e&&T(!1),children:e(te,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(re,{className:`mb-0`,children:e(ue,{className:`flex items-center gap-2 min-w-0`,children:[i(h,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:I.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[I.addonId,k?` · ${k}`:``]})]})}),i(J,{className:`min-h-0 overflow-hidden p-0`,children:i(Ee,{addonId:I.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(F,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:c(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:c(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t})})]}),e(Q,{variant:`unstyled`,onClick:()=>f(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(m,{className:`h-3 w-3`}),c(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function qt({addonId:e}){let t=qe(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{Wt as IntegrationDetailPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fn as c,Pr as l,Xn as u,ot as d,pa as f,rr as p,wi as m}from"./player-overlays-
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fn as c,Pr as l,Xn as u,ot as d,pa as f,rr as p,wi as m}from"./player-overlays-fpbPSPqT.js";import{Oo as h}from"./client-Cng2SeYA.js";import{A as g,I as _,j as v,y}from"./__vite-browser-external-DIbVKiho.js";import{Cp as b,Gi as x,Ji as S,Ui as C,Wi as w,Yi as T,_t as E,mp as D,ro as O,vs as k,vt as A,yt as j}from"./src-eL0OacoB.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{St as N,b as P,wi as F}from"./index-DbXFHmBJ.js";import{t as I}from"./AdminSectionedPage-bGVBepbw.js";import{t as L}from"./InstancesTable-LVQWfz07.js";a();var R=1e4;function z({row:t}){let{t:r}=M(),[a,o]=i(!1),c=t.kind===`instance`?t.id:void 0,{data:l}=k({addonId:t.addonId,...c===void 0?{}:{instanceId:c}},{refetchInterval:R,retry:!1}),u=h.safeParse(l);if(!u.success||t.kind===`instance`&&!t.enabled)return null;let d=u.data.exposedDeviceCount;return e(s,{children:[n(D,{variant:`ghost`,size:`sm`,type:`button`,onClick:()=>o(!0),children:r(`system.connectivity.devicesExported`,`{{count}} devices exported`,{count:d})}),a&&n(C,{open:!0,onOpenChange:o,children:e(x,{width:`full`,scroll:`body`,children:[n(S,{children:n(T,{children:r(`system.connectivity.devicesDialogTitle`,`Devices of {{name}}`,{name:t.name})})}),n(w,{children:c===void 0?n(A,{addonId:t.addonId,showSetup:!1}):n(E,{addonId:t.addonId,instance:{instanceId:c,name:t.name,enabled:!0},showSetup:!1})})]})})]})}function B(e){return{key:`devices`,header:e(`system.connectivity.devicesColumn`,`Devices`),notSortableReason:e(`system.connectivity.devicesNotSortable`,`A button that opens the list is not a value to order by.`),render:e=>n(z,{row:e})}}function V({addonId:e,instanceId:t}){return n(j,{addonId:e,instanceId:t})}var H=`waste-collections`,U=v({refreshed:y(v({sourceId:_(),entryCount:g().int(),error:_().optional()}))});function W({row:e}){let{t}=M(),r=d(),i=o(),a=O({onSuccess:async n=>{let a=U.safeParse(n),o=a.success?a.data.refreshed[0]:void 0;if(i.invalidateQueries({queryKey:[N]}),o===void 0){await r({title:t(`wasteFetchNow.nothingFetched`,`Nothing to fetch`),message:t(`wasteFetchNow.sourceIsOff`,`{{name}} is switched off, so it was not fetched.`,{name:e.name})});return}await r({title:o.error===void 0?t(`wasteFetchNow.fetched`,`{{name}} fetched`,{name:e.name}):t(`wasteFetchNow.failed`,`{{name}} could not be fetched`,{name:e.name}),message:o.error??t(`wasteFetchNow.collections`,`{{count}} collections read.`,{count:o.entryCount}),variant:o.error===void 0?`default`:`danger`})},onError:async n=>{await r({title:t(`wasteFetchNow.failed`,`{{name}} could not be fetched`,{name:e.name}),message:n.message,variant:`danger`})}});return n(b,{icon:m,variant:`ghost`,size:`sm`,"aria-label":t(`wasteFetchNow.label`,`Fetch {{name}} now`,{name:e.name}),disabled:a.isPending,onClick:()=>a.mutate({addonId:H,action:`fetchNow`,input:{sourceId:e.id}})})}function G(e){return e.addonId===H?n(W,{row:e}):null}function K(){let{t}=M(),r=d(),i=o(),a=O({onSuccess:async e=>{let n=U.safeParse(e);i.invalidateQueries({queryKey:[N]});let a=n.success?n.data.refreshed:[],o=a.filter(e=>e.error!==void 0);await r({title:o.length===0?t(`wasteFetchNow.allFetched`,`Calendars fetched`):t(`wasteFetchNow.allFailed`,`{{count}} calendars could not be fetched`,{count:o.length}),message:o.length===0?t(`wasteFetchNow.allCollections`,`{{count}} sources refreshed.`,{count:a.length}):o.map(e=>`${e.sourceId}: ${e.error}`).join(`
|
|
2
2
|
`),variant:o.length===0?`default`:`danger`})},onError:async e=>{await r({title:t(`wasteFetchNow.allNotFetched`,`The calendars could not be fetched`),message:e.message,variant:`danger`})}});return e(D,{size:`sm`,variant:`secondary`,disabled:a.isPending,onClick:()=>a.mutate({addonId:H,action:`fetchNow`,input:{}}),children:[n(m,{className:`h-3.5 w-3.5`}),t(`wasteFetchNow.all`,`Fetch all now`)]})}function q(e){return e.some(e=>e.addonId===H)?n(K,{}):null}a();var J={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},Y=[{sectionId:`exporters`,labelKey:`system.connectivity.exporters`,icon:c,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`,instances:{functionCap:`device-export`,subtitleKey:`system.connectivity.exportersSubtitle`,subtitleDefault:`The ecosystems and hubs this hub publishes its devices to.`,addLabelKey:`system.connectivity.exportersAdd`,addLabelDefault:`Add export`,extraColumns:e=>[B(e)],lead:e=>n(V,{addonId:e.addonId,instanceId:e.id})}},{sectionId:`email`,labelKey:`system.connectivity.email`,icon:l,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`,instances:{functionCap:`smtp-provider`,subtitleKey:`system.connectivity.emailSubtitle`,subtitleDefault:`The SMTP relays that notification targets send mail through.`,addLabelKey:`system.connectivity.emailAdd`,addLabelDefault:`Add relay`}},{sectionId:`brokers`,labelKey:`system.connectivity.brokers`,icon:u,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`,instances:{functionCap:`broker`,subtitleKey:`system.connectivity.brokersSubtitle`,subtitleDefault:`The accounts and connections this hub reaches its devices through.`,addLabelKey:`system.connectivity.brokersAdd`,addLabelDefault:`Add connection`}},{sectionId:`calendars`,labelKey:`system.connectivity.calendars`,icon:f,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`,instances:{functionCap:`calendar-source`,subtitleKey:`system.connectivity.calendarsSubtitle`,subtitleDefault:`The calendars this hub reads events from.`,addLabelKey:`system.connectivity.calendarsAdd`,addLabelDefault:`Add calendar`,rowActions:G,pageActions:q}}];function X(){let{t:e}=M(),[i,a]=F(),o=P(`/system/integrations`,{t:e,isAdmin:!0})??{icon:p,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};r(()=>{let e=i.get(`tab`);if(e===null)return;let t=J[e];t===void 0||t===e||a(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[i,a]);let s=t(()=>Y.map(t=>{let r=t.instances;return{id:t.sectionId,label:e(t.labelKey),content:n(L,{functionCap:r.functionCap,icon:t.icon,title:e(t.labelKey),subtitle:e(r.subtitleKey,r.subtitleDefault),emptyTitle:e(t.emptyTitleKey),emptyDescription:e(t.emptyDescriptionKey),addLabel:e(r.addLabelKey,r.addLabelDefault),install:{capability:r.functionCap,label:e(t.installLabelKey)},...r.extraColumns===void 0?{}:{extraColumns:r.extraColumns(e)},...r.lead===void 0?{}:{lead:r.lead},...r.rowActions===void 0?{}:{rowActions:r.rowActions},...r.pageActions===void 0?{}:{pageActions:r.pageActions}})}}),[e]);return n(I,{icon:o.icon,title:o.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:s})}export{X as IntegrationsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as c,Qn as ee,Wr as l,Yn as u,aa as d,eo as f,ir as te,rr as ne,yt as re}from"./player-overlays-D546iNTv.js";import{t as p}from"./chevron-down-CBb-F8DT.js";import{t as ie}from"./table-2-DMxm3oyu.js";import{Da as ae,Nt as oe,Y as m,Zs as se,a as h,bt as g,cl as ce,do as le,pp as _,sl as ue,ur as de,wt as fe,xp as v,xt as pe}from"./src-C9_yKHH3.js";import{t as y}from"./i18n-HSlX-YO0.js";import{t as b}from"./useTranslation-BJr-n0es.js";import{$ as me,Si as he,ct as ge,et as _e,ft as x,lt as ve,mt as ye,nt as be,ot as xe,pt as S,rt as Se,st as C,ut as w,vt as T,wi as Ce,xi as we}from"./index-BN2PojUq.js";import{t as Te}from"./AdminPage-Dvziohv2.js";import"./useEventInvalidation-CVOfqhXA.js";import{t as Ee}from"./device-integration-icon-BwgC8WB_.js";o();function E(e){return e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`stopped`)?`stopped`:`disabled`}function De(e,t){let n=new Map;for(let t of e){let e=n.get(t.addonId);e===void 0?n.set(t.addonId,[t]):e.push(t)}return[...n.entries()].map(([e,n])=>{let r=t.get(e)?.trim()??``;return{addonId:e,name:r.length>0?r:n[0]?.name??e,instances:n,instanceCount:n.length,deviceCount:n.reduce((e,t)=>e+t.deviceCount,0),status:E(n)}})}var D=3e3,O=new Set([`no-provider`,`node-offline`,`transport-failed`]),k=[`provider not available`,`failed to fetch`,`networkerror`,`load failed`];function A(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t!=`object`||!t)return null;let n=Reflect.get(t,`capRouteReason`);return typeof n==`string`?n:null}function j(e,t){if(e==null||t>10)return!1;let n=A(e);if(n!==null)return O.has(n);let r=(e instanceof Error?e.message:String(e)).toLowerCase();return k.some(e=>r.includes(e))}function M(e){return j(e.state.error,e.state.errorUpdateCount)?D:!1}function Oe({providers:n,system:i,onOpen:o,searchPlaceholder:s,emptyLabel:ee}){let[l,u]=a(``),d=t(()=>{let e=l.trim().toLowerCase(),t=t=>e.length===0||`${t.name} ${t.addonId} ${t.instances.map(e=>e.name).join(` `)}`.toLowerCase().includes(e);return{providers:n.filter(t),system:i.filter(t)}},[l,n,i]),f=d.providers.length===0&&d.system.length===0;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[r(c,{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}),r(v,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:s,"aria-label":s,className:`pl-8`})]}),f?r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:ee}):e(`div`,{className:`space-y-4`,children:[d.providers.length>0&&r(C,{kind:`providers`,children:r(N,{groups:d.providers,onOpen:o})}),d.system.length>0&&r(C,{kind:`system`,children:r(N,{groups:d.system,onOpen:o})})]})]})}function N({groups:e,onOpen:n}){let{t:i,i18n:a}=b();return r(ve,{children:t(()=>x(e,a.language),[e,a.language]).map(e=>r(ge,{testId:`integration-card-${e.addonId}`,addonId:e.addonId,name:e.name,openLabel:i(`integrations.openNamed`,{name:e.name,defaultValue:`Open {{name}}`}),onOpen:()=>n(e),body:r(`p`,{className:`text-xs text-foreground-muted`,children:i(`integrations.addonCard.summary`,{integrations:i(`integrations.addonCard.integrationCount`,{count:e.instanceCount}),devices:i(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount}),defaultValue:`{{integrations}} · {{devices}}`})}),footer:r(m,{status:e.status,className:`shrink-0`})},e.addonId))})}o();var P=`camstack.admin.integrations.view`;function F(e){return e===`table`||e===`grid`}function I(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function L(e=I()){if(e===null)return`table`;try{let t=e.getItem(P);return F(t)?t:`table`}catch{return`table`}}function R(e,t=I()){if(t!==null)try{t.setItem(P,e)}catch{}}function ke(){let[e,t]=a(()=>L());return[e,n(e=>{t(e),R(e)},[])]}function z({integration:t,expanded:n,onToggleExpand:i}){let{t:a}=b();return e(`div`,{className:`flex items-center gap-2.5`,children:[r(_,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),i(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:r(n?p:d,{className:`h-3.5 w-3.5`})}),r(w,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),r(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Ae(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:y.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>r(z,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:y.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>y.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:y.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>r(m,{status:e.status})}]}o();function je(e){if(!e.enabled&&e.switchUnknown!==!0)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var B=`expand`;function V(){let{t:o}=b(),c=he(),d=we(),p=re(),[m]=Ce(),[v,y]=ke(),[ge,x]=a(!1),[ve,w]=a(null),E=n(()=>{w(null),x(!0)},[]),D=n(()=>{x(!1),w(null)},[]),O=n(e=>{A(!1),w(e),x(!0)},[]),[k,A]=a(!1),{count:N,refresh:P}=Se();i(()=>{let e=xe(d.state);e!==null&&(w(e),x(!0),c(`/integrations`,{replace:!0,state:null}))},[d.state,c]);let F=m.get(`setup`);i(()=>{F===null||F.length===0||(w({addonId:F,name:F,config:{}}),x(!0))},[F]);let I=n(()=>A(!0),[]),L=n(()=>A(!1),[]);h([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),h([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:R,isLoading:z,isError:V,error:Me,errorUpdateCount:Ne,refetch:Pe}=ce(void 0,{refetchInterval:M}),{data:H,isLoading:Fe,isError:Ie,error:Le,errorUpdateCount:Re,refetch:ze}=se({projection:`slim`},{refetchInterval:M}),U=t(()=>H??[],[H]),W=t(()=>R??[],[R]),Be=t(()=>oe(U),[U]),G=t(()=>pe(R),[R]),Ve=t(()=>{let e=new Map;for(let t of fe(U)){let n=G(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[U,G]),K=t(()=>W.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:je(e),deviceCount:Ve.get(e.id)??0})),[W,Ve]),{data:He}=ue(),Ue=t(()=>new Map((He??[]).map(e=>[e.addonId,e.name])),[He]),We=m.get(B),Ge=n(e=>{let t=new URLSearchParams(window.location.search);t.get(B)===e?t.delete(B):t.set(B,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),{data:Ke}=le(void 0),q=t(()=>ye(Ke),[Ke]),J=t(()=>S(K,q),[K,q]),qe=t(()=>S(De(K,Ue),q),[K,Ue,q]),Je=n(e=>c(T(e.addonId)),[c]),Ye=n(e=>c(T(e.addonId,e.id)),[c]),Xe=n(e=>Be.get(e)??null,[Be]),Ze=n(e=>c(`/devices/${String(e)}`),[c]),Qe=n(e=>r(g,{context:`integration-detail`,devices:U,trpc:p.trpcClient,integrationOf:G,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:Ee,resolveParent:Xe,onNavigate:Ze}),[U,p.trpcClient,G,Xe,Ze]),Y=n(e=>We===e.addonId,[We]),$e=t(()=>Ae({isExpanded:Y,onToggleExpand:Ge}),[Y,Ge]),et=n(e=>`${e.name} ${e.addonId}`,[]),tt=n(e=>e.id,[]),nt=e=>r(g,{mode:`generic`,items:e,getKey:tt,getSearchText:et,columns:$e,onRowClick:Ye,isExpanded:Y,renderExpanded:Qe,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),rt=n(()=>{Pe(),ze()},[Pe,ze]),it=V===!0&&j(Me,Ne),at=Ie===!0&&j(Le,Re),X=it||at,Z=V===!0&&!it||Ie===!0&&!at,Q=!Z&&!X&&(z||Fe||R===void 0||H===void 0),$=W.length>0,ot=[{id:`table`,label:o(`integrations.viewTable`,`Table`),icon:ie},{id:`grid`,label:o(`integrations.viewGrid`,`Grid`),icon:l}];return e(Te,{icon:ne,title:o(`nav.integrations`,`Integrations`),actions:e(s,{children:[r(de,{ariaLabel:o(`integrations.viewLabel`,`Layout`),value:v,onChange:y,options:ot,testId:`integrations-view`}),r(_,{variant:`unstyled`,onClick:rt,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:o(`common.refresh`,`Refresh`),children:r(u,{className:f(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),e(_,{variant:`unstyled`,onClick:I,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:o(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[r(ee,{className:`h-3.5 w-3.5`}),o(`integrations.scanNetwork`,`Scan network`),r(be,{count:N})]}),e(_,{variant:`unstyled`,onClick:E,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[r(te,{className:`h-3.5 w-3.5`}),o(`integrations.newIntegration`,`New Integration`)]})]}),children:[Z&&r(ae,{message:o(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:rt}),X&&!Z&&e(`div`,{role:`status`,"data-testid":`integrations-reconnecting`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle`,children:[r(u,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),o(`integrations.reconnecting`,`An integration is restarting. The list will refresh on its own.`)]}),Q&&r(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>r(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&!X&&!$&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[r(`p`,{className:`text-sm`,children:o(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),r(`p`,{className:`text-xs mt-1`,children:o(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Z&&!Q&&$&&v===`table`&&e(`div`,{className:`space-y-4`,children:[J.providers.length>0&&r(C,{kind:`providers`,children:nt(J.providers)}),J.system.length>0&&r(C,{kind:`system`,children:nt(J.system)})]}),!Z&&!Q&&$&&v===`grid`&&r(Oe,{providers:qe.providers,system:qe.system,onOpen:Je,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),r(me,{open:ge,onClose:D,seed:ve}),r(_e,{open:k,onClose:L,onSetupIntegration:O,onAdopted:P})]})}export{V as IntegrationsPage};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as c,Qn as ee,Wr as l,Yn as u,aa as d,eo as f,ir as te,rr as ne,yt as re}from"./player-overlays-fpbPSPqT.js";import{t as p}from"./chevron-down-CBb-F8DT.js";import{t as ie}from"./table-2-DMxm3oyu.js";import{Da as ae,Nt as oe,Sp as m,Y as h,Zs as se,a as g,bt as _,cl as ce,do as le,ll as ue,mp as v,ur as de,wt as fe,xt as pe}from"./src-eL0OacoB.js";import{t as y}from"./i18n--GTAj4mB.js";import{t as b}from"./useTranslation-BJr-n0es.js";import{$ as me,Si as he,ct as ge,et as _e,ft as x,lt as ve,mt as ye,nt as be,ot as xe,pt as S,rt as Se,st as C,ut as w,vt as T,wi as Ce,xi as we}from"./index-DbXFHmBJ.js";import{t as Te}from"./AdminPage-BkxgjFWW.js";import"./useEventInvalidation-B-FI9413.js";import{t as Ee}from"./device-integration-icon-VMxiVsqd.js";o();function E(e){return e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`stopped`)?`stopped`:`disabled`}function De(e,t){let n=new Map;for(let t of e){let e=n.get(t.addonId);e===void 0?n.set(t.addonId,[t]):e.push(t)}return[...n.entries()].map(([e,n])=>{let r=t.get(e)?.trim()??``;return{addonId:e,name:r.length>0?r:n[0]?.name??e,instances:n,instanceCount:n.length,deviceCount:n.reduce((e,t)=>e+t.deviceCount,0),status:E(n)}})}var D=3e3,O=new Set([`no-provider`,`node-offline`,`transport-failed`]),k=[`provider not available`,`failed to fetch`,`networkerror`,`load failed`];function A(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t!=`object`||!t)return null;let n=Reflect.get(t,`capRouteReason`);return typeof n==`string`?n:null}function j(e,t){if(e==null||t>10)return!1;let n=A(e);if(n!==null)return O.has(n);let r=(e instanceof Error?e.message:String(e)).toLowerCase();return k.some(e=>r.includes(e))}function M(e){return j(e.state.error,e.state.errorUpdateCount)?D:!1}function Oe({providers:n,system:i,onOpen:o,searchPlaceholder:s,emptyLabel:ee}){let[l,u]=a(``),d=t(()=>{let e=l.trim().toLowerCase(),t=t=>e.length===0||`${t.name} ${t.addonId} ${t.instances.map(e=>e.name).join(` `)}`.toLowerCase().includes(e);return{providers:n.filter(t),system:i.filter(t)}},[l,n,i]),f=d.providers.length===0&&d.system.length===0;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[r(c,{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}),r(m,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:s,"aria-label":s,className:`pl-8`})]}),f?r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:ee}):e(`div`,{className:`space-y-4`,children:[d.providers.length>0&&r(C,{kind:`providers`,children:r(N,{groups:d.providers,onOpen:o})}),d.system.length>0&&r(C,{kind:`system`,children:r(N,{groups:d.system,onOpen:o})})]})]})}function N({groups:e,onOpen:n}){let{t:i,i18n:a}=b();return r(ve,{children:t(()=>x(e,a.language),[e,a.language]).map(e=>r(ge,{testId:`integration-card-${e.addonId}`,addonId:e.addonId,name:e.name,openLabel:i(`integrations.openNamed`,{name:e.name,defaultValue:`Open {{name}}`}),onOpen:()=>n(e),body:r(`p`,{className:`text-xs text-foreground-muted`,children:i(`integrations.addonCard.summary`,{integrations:i(`integrations.addonCard.integrationCount`,{count:e.instanceCount}),devices:i(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount}),defaultValue:`{{integrations}} · {{devices}}`})}),footer:r(h,{status:e.status,className:`shrink-0`})},e.addonId))})}o();var P=`camstack.admin.integrations.view`;function F(e){return e===`table`||e===`grid`}function I(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function L(e=I()){if(e===null)return`table`;try{let t=e.getItem(P);return F(t)?t:`table`}catch{return`table`}}function R(e,t=I()){if(t!==null)try{t.setItem(P,e)}catch{}}function ke(){let[e,t]=a(()=>L());return[e,n(e=>{t(e),R(e)},[])]}function z({integration:t,expanded:n,onToggleExpand:i}){let{t:a}=b();return e(`div`,{className:`flex items-center gap-2.5`,children:[r(v,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),i(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:r(n?p:d,{className:`h-3.5 w-3.5`})}),r(w,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),r(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Ae(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:y.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>r(z,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:y.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>y.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:y.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>r(h,{status:e.status})}]}o();function je(e){if(!e.enabled&&e.switchUnknown!==!0)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var B=`expand`;function V(){let{t:o}=b(),c=he(),d=we(),p=re(),[m]=Ce(),[h,y]=ke(),[ge,x]=a(!1),[ve,w]=a(null),E=n(()=>{w(null),x(!0)},[]),D=n(()=>{x(!1),w(null)},[]),O=n(e=>{A(!1),w(e),x(!0)},[]),[k,A]=a(!1),{count:N,refresh:P}=Se();i(()=>{let e=xe(d.state);e!==null&&(w(e),x(!0),c(`/integrations`,{replace:!0,state:null}))},[d.state,c]);let F=m.get(`setup`);i(()=>{F===null||F.length===0||(w({addonId:F,name:F,config:{}}),x(!0))},[F]);let I=n(()=>A(!0),[]),L=n(()=>A(!1),[]);g([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),g([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:R,isLoading:z,isError:V,error:Me,errorUpdateCount:Ne,refetch:Pe}=ue(void 0,{refetchInterval:M}),{data:H,isLoading:Fe,isError:Ie,error:Le,errorUpdateCount:Re,refetch:ze}=se({projection:`slim`},{refetchInterval:M}),U=t(()=>H??[],[H]),W=t(()=>R??[],[R]),Be=t(()=>oe(U),[U]),G=t(()=>pe(R),[R]),Ve=t(()=>{let e=new Map;for(let t of fe(U)){let n=G(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[U,G]),K=t(()=>W.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:je(e),deviceCount:Ve.get(e.id)??0})),[W,Ve]),{data:He}=ce(),Ue=t(()=>new Map((He??[]).map(e=>[e.addonId,e.name])),[He]),We=m.get(B),Ge=n(e=>{let t=new URLSearchParams(window.location.search);t.get(B)===e?t.delete(B):t.set(B,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),{data:Ke}=le(void 0),q=t(()=>ye(Ke),[Ke]),J=t(()=>S(K,q),[K,q]),qe=t(()=>S(De(K,Ue),q),[K,Ue,q]),Je=n(e=>c(T(e.addonId)),[c]),Ye=n(e=>c(T(e.addonId,e.id)),[c]),Xe=n(e=>Be.get(e)??null,[Be]),Ze=n(e=>c(`/devices/${String(e)}`),[c]),Qe=n(e=>r(_,{context:`integration-detail`,devices:U,trpc:p.trpcClient,integrationOf:G,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:Ee,resolveParent:Xe,onNavigate:Ze}),[U,p.trpcClient,G,Xe,Ze]),Y=n(e=>We===e.addonId,[We]),$e=t(()=>Ae({isExpanded:Y,onToggleExpand:Ge}),[Y,Ge]),et=n(e=>`${e.name} ${e.addonId}`,[]),tt=n(e=>e.id,[]),nt=e=>r(_,{mode:`generic`,items:e,getKey:tt,getSearchText:et,columns:$e,onRowClick:Ye,isExpanded:Y,renderExpanded:Qe,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),rt=n(()=>{Pe(),ze()},[Pe,ze]),it=V===!0&&j(Me,Ne),at=Ie===!0&&j(Le,Re),X=it||at,Z=V===!0&&!it||Ie===!0&&!at,Q=!Z&&!X&&(z||Fe||R===void 0||H===void 0),$=W.length>0,ot=[{id:`table`,label:o(`integrations.viewTable`,`Table`),icon:ie},{id:`grid`,label:o(`integrations.viewGrid`,`Grid`),icon:l}];return e(Te,{icon:ne,title:o(`nav.integrations`,`Integrations`),actions:e(s,{children:[r(de,{ariaLabel:o(`integrations.viewLabel`,`Layout`),value:h,onChange:y,options:ot,testId:`integrations-view`}),r(v,{variant:`unstyled`,onClick:rt,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:o(`common.refresh`,`Refresh`),children:r(u,{className:f(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),e(v,{variant:`unstyled`,onClick:I,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:o(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[r(ee,{className:`h-3.5 w-3.5`}),o(`integrations.scanNetwork`,`Scan network`),r(be,{count:N})]}),e(v,{variant:`unstyled`,onClick:E,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[r(te,{className:`h-3.5 w-3.5`}),o(`integrations.newIntegration`,`New Integration`)]})]}),children:[Z&&r(ae,{message:o(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:rt}),X&&!Z&&e(`div`,{role:`status`,"data-testid":`integrations-reconnecting`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle`,children:[r(u,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),o(`integrations.reconnecting`,`An integration is restarting. The list will refresh on its own.`)]}),Q&&r(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>r(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&!X&&!$&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[r(`p`,{className:`text-sm`,children:o(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),r(`p`,{className:`text-xs mt-1`,children:o(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Z&&!Q&&$&&h===`table`&&e(`div`,{className:`space-y-4`,children:[J.providers.length>0&&r(C,{kind:`providers`,children:nt(J.providers)}),J.system.length>0&&r(C,{kind:`system`,children:nt(J.system)})]}),!Z&&!Q&&$&&h===`grid`&&r(Oe,{providers:qe.providers,system:qe.system,onOpen:Je,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),r(me,{open:ge,onClose:D,seed:ve}),r(_e,{open:k,onClose:L,onSetupIntegration:O,onAdopted:P})]})}export{V as IntegrationsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,Q as r,R as i,S as a,V as o,Y as s,et as c,o 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{$a as d,D as f,Hn as p,Tt as m,Wi as h,Wt as g,Xr as _,Yn as v,Zt as y,c as b,ct as x,da as S,f as C,fa as w,ft as T,hi as E,ir as D,l as O,mn as k,qn as A,qt as j,sa as M,tn as N,u as P,ur as F,wi as I,yn as L,yt as R,zr as z}from"./player-overlays-fpbPSPqT.js";import{ul as B}from"./client-Cng2SeYA.js";import{s as V}from"./terminal-DZ5OZpgC.js";import{a as H,i as ee,n as U,o as W,r as G,t as te}from"./user-x-DkWcmF99.js";import{t as K}from"./crop-B-t0rzRY.js";import{t as ne}from"./square-check-big-DAcFGNUN.js";import{Ad as re,Bc as ie,Bd as q,Br as J,Cd as ae,Cp as oe,Dd as se,Dr as ce,Ed as le,Gc as ue,Gi as de,Hc as fe,Hd as pe,Ic as me,Ir as he,Jc as ge,Ji as _e,Kc as ve,Ki as ye,Lc as be,Od as xe,Rc as Se,Sd as Ce,Sp as we,Td as Te,Tr as Ee,Uc as De,Ud as Oe,Ui as ke,Vc as Ae,Wc as je,Xp as Me,Yi as Ne,Zp as Pe,Zs as Fe,bd as Ie,ia as Le,ka as Re,kd as ze,la as Be,mi as Ve,mp as Y,nt as He,qc as Ue,qi as We,rt as Ge,t as Ke,tt as qe,ut as Je,vd as Ye,wd as Xe,xd as Ze,yd as Qe,zc as $e,zr as et}from"./src-eL0OacoB.js";import{t as X}from"./i18n--GTAj4mB.js";import{t as Z}from"./useTranslation-BJr-n0es.js";import{Ai as tt,Mi as nt,Ni as rt,b as it,ji as at,vi as ot,wi as st}from"./index-DbXFHmBJ.js";import{t as ct}from"./AdminSectionedPage-bGVBepbw.js";import{a as lt,c as ut,d as dt,f as ft,i as pt,l as mt,m as ht,n as gt,o as _t,p as vt,r as yt,s as bt,t as xt}from"./NewExportModal-CHwUJ26P.js";import{a as St,n as Ct,r as wt}from"./authed-media-Bqh0pB9D.js";import{t as Tt}from"./format-size-DIxKXxtj.js";import{t as Et}from"./use-scenes-feed-BTNdL7JV.js";c();function Dt(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function Ot(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function kt(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${Ot(e)} · ${o}`}function At(e,t){let n=e-t;if(n<=0)return X.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return X.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?X.t(`helpers.exportFormat.inHours`,{n:String(i)}):X.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function jt(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}var Mt=[[`recordingExport`]],Nt={queued:{cls:`bg-surface-hover text-foreground-subtle`,labelKey:`recordings.exportsSection.queued`},rendering:{cls:`bg-primary/10 text-primary`,labelKey:`recordings.exportsSection.rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,labelKey:`recordings.exportsSection.ready`},failed:{cls:`bg-danger/10 text-danger`,labelKey:`recordings.exportsSection.failed`},expired:{cls:`bg-surface-hover text-foreground-subtle`,labelKey:`recordings.exportsSection.expired`},deleted:{cls:`bg-surface-hover text-foreground-subtle`,labelKey:`recordings.exportsSection.deleted`}};function Pt(){let{data:e,isLoading:t}=Oe({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=Me(B.RecordingExportProgress,e=>e.exportId),{map:i}=Me(B.RecordingExportCompleted,e=>e.exportId),{map:a}=Me(B.RecordingExportFailed,e=>e.exportId);return{rows:n(()=>jt(e??[],r,i,a),[e,r,i,a]),isLoading:t}}function Ft(e){let[t,n]=s(()=>Date.now());return o(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function It(){let{t}=Z(),r=l(),[o,c]=s(!1),u=()=>{r.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},d=x(),f=R().trpcClient,p=Ft(6e4),{rows:m,isLoading:g}=Pt(),[_,v]=st(),y=rt(_.get(tt)),b=n(()=>nt(m,y),[m,y]),S=n(()=>at(m,y),[m,y]),C=e=>{v(t=>{let n=new URLSearchParams(t);return e===``?n.delete(tt):n.set(tt,e),n},{replace:!0})},{data:w}=Fe({isCamera:!0,projection:`slim`}),D=n(()=>{let e=new Map;for(let t of w??[])e.set(t.id,t.name);return e},[w]),O=i(()=>{r.invalidateQueries({queryKey:Mt})},[r]),k=q({onSuccess:O}),A=pe({onSuccess:O}),[j,M]=s(null),P=i(async e=>{M(e.id);try{let{url:t}=await f.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Ct(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),O()}finally{M(null)}},[f,O]),F=i(async e=>{await d({title:t(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:t(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:t(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&k.mutate({exportId:e.id})},[d,k,t]),L=i(async e=>{await d({title:t(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:t(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&A.mutate({exportId:e.id})},[d,A,t]),B=n(()=>[{key:`camera`,header:t(`recordings.exportsSection.camera`,`Camera`),render:e=>a(`span`,{className:`text-foreground`,children:D.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`created`,header:t(`recordings.exportsSection.created`,`Created`),nowrap:!0,sortValue:e=>e.createdAt,render:n=>e(`span`,{className:`text-foreground-subtle tabular-nums`,children:[new Date(n.createdAt).toLocaleString(),a(`span`,{className:`ml-1`,children:t(`recordings.exportsSection.by`,`by {{who}}`,{who:n.createdBy})})]})},{key:`title`,header:t(`recordings.exportsSection.title`,`Title`),render:e=>a(`span`,{className:`text-foreground`,children:e.options.title??`—`})},{key:`range`,header:t(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>a(`span`,{className:`tabular-nums`,children:kt(e.fromMs,e.toMs)})},{key:`variant`,header:t(`recordings.exportsSection.variant`,`Variant`),render:e=>a(`span`,{className:`text-foreground-subtle`,children:Dt(e.options)})},{key:`state`,header:t(`recordings.exportsSection.state`,`State`),render:n=>{let r=Nt[n.state];return e(`div`,{className:`flex flex-col gap-0.5`,children:[e(`span`,{className:`inline-flex w-fit items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${r.cls}`,children:[r.spin&&a(z,{className:`h-2.5 w-2.5 animate-spin`}),t(r.labelKey),n.state===`rendering`&&n.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[n.progressPct,`%`]})]}),n.error!==null&&a(`span`,{className:`text-[10px] text-danger`,children:n.error})]})}},{key:`expiry`,header:t(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?a(`span`,{className:`text-foreground-subtle`,children:`—`}):a(`span`,{className:`text-foreground-subtle tabular-nums`,children:At(e.expiresAt,p)})},{key:`downloaded`,header:t(`recordings.exportsSection.downloaded`,`Downloaded`),nowrap:!0,render:e=>a(`span`,{className:`text-foreground-subtle tabular-nums`,children:e.downloadedAt===null?`—`:new Date(e.downloadedAt).toLocaleString()})},{key:`size`,header:t(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>a(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:Tt(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:n=>{let r=n.state===`ready`,i=n.state===`queued`||n.state===`rendering`,o=n.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[r&&e(Y,{variant:`unstyled`,onClick:()=>{P(n)},disabled:j===n.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:t(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[j===n.id?a(z,{className:`h-3 w-3 animate-spin`}):a(I,{className:`h-3 w-3`}),t(`recordings.exportsSection.download`,`Download`)]}),i&&e(Y,{variant:`unstyled`,onClick:()=>{F(n)},disabled:k.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-warning/10 hover:text-warning disabled:opacity-50`,title:t(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[a(h,{className:`h-3 w-3`}),t(`common.cancel`,`Cancel`)]}),o&&a(Y,{variant:`unstyled`,onClick:()=>{L(n)},disabled:A.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:t(`recordings.exportsSection.deleteExport`,`Delete export`),children:a(N,{className:`h-3 w-3`})})]})}}],[D,p,j,k.isPending,A.isPending,P,F,L,t]);return g&&b.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[a(z,{className:`h-4 w-4 animate-spin`}),t(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[S.length>1||y!==null?e(T,{wrapperClassName:`mr-auto inline-block w-auto`,"aria-label":t(`recordings.exportsSection.camera`,`Camera`),value:y===null?``:String(y),onChange:e=>C(e.target.value),children:[a(`option`,{value:``,children:t(`recordings.exportsSection.allCameras`,`All cameras`)}),S.map(e=>a(`option`,{value:String(e),children:D.get(e)??`#${String(e)}`},e))]}):null,e(Y,{variant:`unstyled`,onClick:()=>c(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[a(E,{className:`h-3.5 w-3.5`}),t(`recordings.exportsSection.newExport`,`New export`)]})]}),b.length===0&&m.length>0?a(Be,{icon:E,title:t(`recordings.exportsSection.noExportsForCamera`,`No exports for this camera`),description:t(`recordings.exportsSection.noExportsForCameraHint`,`Pick All cameras to see every export, or create one with New export.`)}):b.length===0?a(Be,{icon:E,title:t(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:t(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):a(et,{columns:B,rows:b,rowKey:e=>e.id,minWidthPx:720}),o&&a(xt,{onClose:()=>c(!1),onCreated:u,...y===null?{}:{initialDeviceId:y}})]})}function Lt({mediaId:e,base64:t,alt:n,className:r,placeholder:i}){let{src:o,failed:s}=St(e===void 0?void 0:wt(e));return o===null?(e===void 0||s)&&t!==void 0&&t!==``?a(`img`,{src:`data:image/jpeg;base64,${t}`,alt:n,className:r}):i:a(`img`,{src:o,alt:n,className:r})}var Rt=`pipeline-analytics`,zt=`photo.analyze`,Bt=`photo.enroll`,Vt=`photo.discard`,Ht=18*1024*1024;function Ut(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function $(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function Wt(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Gt(e){if(!Ut(e))return null;let t=$(e,`x`),n=$(e,`y`),r=$(e,`width`),i=$(e,`height`);return t===null||n===null||r===null||i===null?null:{x:t,y:n,width:r,height:i}}function Kt(e){if(!Ut(e))return null;let t=$(e,`detectionShortSidePx`),n=$(e,`score`);if(t===null||n===null)return null;let r=$(e,`magnitude`);return{detectionShortSidePx:t,score:n,...r===null?{}:{magnitude:r}}}function qt(e){if(!Ut(e))return null;let t=$(e,`faceIndex`),n=$(e,`score`),r=Wt(e,`enrollable`),i=Gt(e.bbox),a=Kt(e.quality);if(t===null||n===null||r===null||i===null||a===null)return null;let o=Q(e,`refusedReason`),s=Q(e,`alignedCropBase64`),c=Q(e,`modelId`);return{faceIndex:t,bbox:i,score:n,enrollable:r,quality:a,...o===null?{}:{refusedReason:o},...s===null?{}:{alignedCropBase64:s},...c===null?{}:{modelId:c}}}function Jt(e){if(!Ut(e))return null;let t=Q(e,`sessionId`),n=Q(e,`ranOnNodeId`),r=e.faces;if(t===null||n===null||!Array.isArray(r))return null;let i=[];for(let e of r){let t=qt(e);t!==null&&i.push(t)}return{sessionId:t,ranOnNodeId:n,faces:i}}function Yt(e){if(!Ut(e))return null;let t=Q(e,`sampleId`),n=Q(e,`identityId`),r=Q(e,`modelId`);return t===null||n===null||r===null?null:{sampleId:t,identityId:n,modelId:r}}function Xt(e,t,n){let r={...e};return n===null||n===``?delete r[t]:r[t]=n,r}function Zt(e,t){return e.filter(e=>e.enrollable&&t[e.faceIndex]!==void 0).length}function Qt(e,t,n){let r=[];for(let i of t){if(!i.enrollable)continue;let t=n[i.faceIndex];t!==void 0&&r.push({sessionId:e,faceIndex:i.faceIndex,identityId:t})}return r}function $t(e){switch(e){case`no-embedding`:return X.t(`helpers.photoEnroll.refusal.noEmbedding`);case`no-model-id`:return X.t(`helpers.photoEnroll.refusal.noModelId`);case`no-aligned-crop`:return X.t(`helpers.photoEnroll.refusal.noAlignedCrop`);case`magnitude`:return X.t(`helpers.photoEnroll.refusal.magnitude`);default:return X.t(`helpers.photoEnroll.refusal.default`)}}function en(e,t){let n=[],r=[];for(let i of e)i.size>t.maxBytes?n.push(i.name):r.push(i);return{accepted:r.slice(0,t.maxCount),oversize:n,overflow:r.slice(t.maxCount).map(e=>e.name)}}async function tn(e,t,n){let r=Array(e.length),i=e.map((e,t)=>({item:e,index:t})),a=0,o=async()=>{for(;;){let e=i[a];if(a+=1,e===void 0)return;r[e.index]=await n(e.item,e.index)}},s=Array.from({length:Math.max(1,Math.min(t,e.length))},()=>o());return await Promise.all(s),r}function nn(e,t,n){return e.map(e=>e.photoIndex===t?{...e,...n}:e)}function rn(e,t){return`${e}:${t}`}function an(e,t,n,r){let i=Xt(e[t]??{},n,r),a={...e};return Object.keys(i).length===0?delete a[t]:a[t]=i,a}function on(e,t){let n=0;for(let r of e)r.analysis!==void 0&&(n+=Zt(r.analysis.faces,t[r.photoIndex]??{}));return n}var sn=`__new__`;function cn(e,t,n){let r=[];for(let i of e){if(i.analysis===void 0)continue;let e=t[i.photoIndex]??{};for(let t of i.analysis.faces){if(!t.enrollable||e[t.faceIndex]!==`__new__`)continue;let a=(n[rn(i.photoIndex,t.faceIndex)]??``).trim();if(a===``)return{kind:`error`,message:X.t(`helpers.photoEnrollBatch.newPersonNoName`,{filename:i.filename,face:t.faceIndex+1})};r.includes(a)||r.push(a)}}return{kind:`ok`,names:r}}function ln(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let e=Number(i),o={};for(let[r,i]of Object.entries(a)){let a=Number(r);if(i!==`__new__`){o[a]=i;continue}let s=n[(t[rn(e,a)]??``).trim()];s!==void 0&&(o[a]=s)}r[e]=o}return r}function un(e,t){let n=[];for(let r of e){if(r.analysis===void 0)continue;let e=Qt(r.analysis.sessionId,r.analysis.faces,t[r.photoIndex]??{});for(let t of e)n.push({photoIndex:r.photoIndex,request:t})}return n}function dn(e){return/expired/i.test(e)}function fn(e){return e instanceof Error?e.message:String(e)}async function pn(e,t,n){let r=new Map(e.map(e=>[e.photoIndex,e])),i={},a=[],o=0,s=null,c=(e,t)=>{let n=r.get(e)?.filename??X.t(`helpers.photoEnrollBatch.photoFallback`,{n:e+1});return X.t(`helpers.photoEnrollBatch.faceLabel`,{filename:n,face:t+1})};for(let l of un(e,t)){let e=i[l.photoIndex],t=e===void 0?l.request:{...l.request,sessionId:e.sessionId};try{let e=await n.enroll(t);o+=1,s=e.modelId}catch(t){let u=fn(t);if(!dn(u)||e!==void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${u}`);continue}let d=r.get(l.photoIndex);if(d===void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${u}`);continue}let f;try{f=await n.reanalyze(d)}catch(e){a.push(`${c(l.photoIndex,l.request.faceIndex)}: the analysis expired and re-analysing failed (${fn(e)})`);continue}if(i[l.photoIndex]=f,f.faces.find(e=>e.faceIndex===l.request.faceIndex&&e.enrollable)===void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: the analysis expired, and re-analysing no longer finds this face — assign it again from the fresh result`);continue}try{let e=await n.enroll({...l.request,sessionId:f.sessionId});o+=1,s=e.modelId}catch(e){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${fn(e)}`)}}}return{enrolled:o,stampedModelId:s,failures:a,refreshedAnalyses:i}}c();var mn=[[`faceGallery`]],hn=``;function gn(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`error`,()=>n(Error(`the file could not be read`)),{once:!0}),r.addEventListener(`load`,()=>{let e=r.result;if(typeof e!=`string`){n(Error(`the file could not be read`));return}let i=e.indexOf(`,`);t(i>=0?e.slice(i+1):e)},{once:!0}),r.readAsDataURL(e)})}function _n(e){return e instanceof Error?e.message:String(e)}function vn({face:t,identities:r,value:i,onChange:o,disabled:s}){let{t:c}=Z(),l=n(()=>[{value:hn,label:c(`detectionIntelligence.photoEnrollDialog.ignoreThisFace`,`Ignore this face`)},...r.map(e=>({value:e.id,label:e.name})),{value:sn,label:c(`detectionIntelligence.photoEnrollDialog.newPerson`,`+ New person…`)}],[r,c]);return e(`div`,{className:`rounded-md border border-border bg-surface p-2`,children:[a(`div`,{className:`mb-2 aspect-square w-full overflow-hidden rounded border border-border bg-surface-hover`,children:t.alignedCropBase64?a(`img`,{src:`data:image/jpeg;base64,${t.alignedCropBase64}`,alt:c(`detectionIntelligence.photoEnrollDialog.face`,`Face {{value1}}`,{value1:t.faceIndex+1}),className:`h-full w-full object-cover`}):a(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:a(U,{className:`h-8 w-8`})})}),a(`div`,{className:`min-h-[4.75rem]`,children:t.enrollable?e(u,{children:[a(T,{options:l,value:i,disabled:s,onChange:e=>o(e.target.value),"aria-label":c(`detectionIntelligence.photoEnrollDialog.assignFace`,`Assign face {{value1}}`,{value1:t.faceIndex+1})}),e(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:[Math.round(t.quality.detectionShortSidePx),` px`,t.modelId?` · ${t.modelId}`:``]})]}):e(`div`,{className:`space-y-1`,children:[a(Re,{variant:`warning`,className:`text-[10px]`,children:c(`detectionIntelligence.photoEnrollDialog.notUsable`,`Not usable`)}),a(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:$t(t.refusedReason)})]})})]})}function yn({photo:t,identities:n,draft:r,newNames:i,disabled:o,onAssign:s,onNameChange:c,onRetry:l}){let{t:u}=Z(),d=t.analysis?.faces??[],f=r[t.photoIndex]??{};return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex items-center gap-2 border-b border-border pb-1`,children:[a(`span`,{className:`truncate text-xs font-medium text-foreground`,children:t.filename}),t.status===`analyzing`||t.status===`queued`?e(`span`,{className:`flex items-center gap-1 text-xs text-foreground-subtle`,children:[a(z,{className:`h-3 w-3 animate-spin`}),` `,u(`detectionIntelligence.photoEnrollDialog.analysing`)]}):null,t.status===`analyzed`&&t.analysis!==void 0&&a(`span`,{className:`text-xs text-foreground-subtle`,children:u(`detectionIntelligence.photoEnrollDialog.facesAnalysedOn`,{count:d.length,node:t.analysis.ranOnNodeId})}),t.status===`failed`&&e(Y,{variant:`secondary`,size:`sm`,disabled:o,onClick:l,children:[a(A,{className:`h-3 w-3`}),` `,u(`common.retry`)]})]}),t.status===`failed`&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(y,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),e(`span`,{children:[u(`detectionIntelligence.photoEnrollDialog.thisPhotoCouldNotBe`,`This photo could not be analysed:`),` `,t.error??u(`detectionIntelligence.photoEnrollDialog.unknownError`,`unknown error`),`. The other photos are unaffected.`]})]}),t.status===`analyzed`&&d.length===0&&a(`p`,{className:`text-xs text-foreground-subtle`,children:u(`detectionIntelligence.photoEnrollDialog.noFacesWereFoundIn`,`No faces were found in this photo. A face has to be reasonably large and facing the camera for the detector to measure it.`)}),d.length>0&&a(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(7rem,7rem))] justify-start gap-3`,children:d.map(e=>a(vn,{face:e,identities:n,value:f[e.faceIndex]??hn,disabled:o,onChange:t=>s(e.faceIndex,t)},e.faceIndex))}),d.filter(e=>f[e.faceIndex]===sn).map(n=>e(`div`,{className:`flex items-center gap-2`,children:[a(`span`,{className:`w-28 shrink-0 truncate text-xs text-foreground-subtle`,children:u(`detectionIntelligence.photoEnrollDialog.faceN`,{n:n.faceIndex+1})}),a(we,{className:`h-7 flex-1 rounded-md border border-border bg-surface px-2.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,placeholder:u(`detectionIntelligence.photoEnrollDialog.newPersonNameTypeThe`,`New person name… (type the same name under another face to reuse it)`),value:i[rn(t.photoIndex,n.faceIndex)]??``,onChange:e=>c(n.faceIndex,e.target.value)})]},n.faceIndex))]})}function bn({open:r,onOpenChange:o}){let{t:c}=Z(),u=R(),d=l(),f=t(null),{data:p}=Ae(),m=be(),[h,g]=s([]),[_,v]=s(!1),[b,x]=s(null),[S,C]=s({}),[w,T]=s({}),[E,D]=s(null),O=n(()=>(p??[]).map(e=>({id:e.id,name:e.name})),[p]),k=h.some(e=>e.status===`queued`||e.status===`analyzing`),A=k||_,j=i(e=>{for(let t of e){let e=t.analysis?.sessionId;e!==void 0&&u.trpcClient.addons.custom.mutate({addonId:Rt,action:Vt,input:{sessionId:e}}).catch(()=>void 0)}},[u]),M=i(()=>{g([]),C({}),T({}),x(null),D(null),f.current&&(f.current.value=``)},[]),N=i(()=>{j(h),M(),o(!1)},[j,o,h,M]),P=i(async e=>{let t=Jt(await u.trpcClient.addons.custom.mutate({addonId:Rt,action:zt,input:{photoBase64:e.photoBase64,filename:e.filename}}));if(t===null)throw Error(`the server replied with something this page could not read`);return t},[u]),F=i(async e=>{g(t=>nn(t,e.photoIndex,{status:`analyzing`,error:void 0}));try{let t=await P(e);g(n=>nn(n,e.photoIndex,{status:`analyzed`,analysis:t}))}catch(t){g(n=>nn(n,e.photoIndex,{status:`failed`,error:_n(t)}))}},[P]),I=i(async e=>{if(e.length===0)return;j(h),M();let t=en(e,{maxCount:12,maxBytes:Ht}),n=[];t.oversize.length>0&&n.push(`Over the ${Math.round(Ht/(1024*1024))} MB limit and skipped: ${t.oversize.join(`, `)}.`),t.overflow.length>0&&n.push(`A batch holds at most 12 photos — not analysed: ${t.overflow.join(`, `)}. Enrol them in a second round.`),n.length>0&&x(n.join(` `));let r;try{r=await Promise.all(t.accepted.map(async(e,t)=>({photoIndex:t,filename:e.name,photoBase64:await gn(e),status:`queued`})))}catch(e){x(_n(e));return}g(r),await tn(r,2,e=>F(e))},[j,h,M,F]),L=on(h,S),B=i(async()=>{v(!0),x(null),D(null);try{let e=cn(h,S,w);if(e.kind===`error`){x(e.message);return}let t={};for(let n of e.names)t[n]=(await m.mutateAsync({name:n})).id;let n=await pn(h,ln(S,w,t),{enroll:async e=>{let t=Yt(await u.trpcClient.addons.custom.mutate({addonId:Rt,action:Bt,input:e}));if(t===null)throw Error(`unreadable reply`);return t},reanalyze:e=>P(e)});Object.keys(n.refreshedAnalyses).length>0&&g(e=>e.map(e=>{let t=n.refreshedAnalyses[e.photoIndex];return t===void 0?e:{...e,status:`analyzed`,analysis:t}})),d.invalidateQueries({queryKey:mn}),n.failures.length>0&&x(n.failures.join(` · `)),D(n.enrolled===0?`Nothing was enrolled.`:`Enrolled ${n.enrolled} sample${n.enrolled===1?``:`s`}${n.stampedModelId===null?``:` with ${n.stampedModelId}`}.`)}catch(e){x(_n(e))}finally{v(!1)}},[P,m,S,w,h,d,u]),V=h.filter(e=>e.status===`analyzed`).length;return a(ke,{open:r,onOpenChange:e=>e?o(!0):N(),children:e(de,{className:`max-w-3xl`,children:[e(_e,{children:[a(Ne,{children:c(`detectionIntelligence.photoEnrollDialog.enrolFromPhotos`,`Enrol from photos`)}),a(ye,{children:c(`detectionIntelligence.photoEnrollDialog.everyPhotoIsAnalysedWith`,`Every photo is analysed with the same face detector the cameras use, and all the faces found are reviewed below in one pass, grouped by photo. Assign each face to a person, or leave it ignored.`)})]}),a(`div`,{className:`rounded-md border border-border bg-surface-hover px-3 py-2 text-xs text-foreground-subtle`,children:a(ot,{i18nKey:`detectionIntelligence.photoEnrollDialog.reliableRecognition`,components:{strong:a(`strong`,{})}})}),e(`div`,{className:`flex items-center gap-2`,children:[a(Ve,{ref:f,accept:`image/jpeg,image/png,image/webp`,multiple:!0,className:`hidden`,onChange:e=>void I(Array.from(e.target.files??[]))}),e(Y,{variant:`secondary`,size:`sm`,disabled:A,onClick:()=>f.current?.click(),children:[k?a(z,{className:`h-3.5 w-3.5 animate-spin`}):a(H,{className:`h-3.5 w-3.5`}),c(`detectionIntelligence.photoEnrollDialog.choosePhotos`,`Choose photos`)]}),h.length>0&&a(`span`,{className:`text-xs text-foreground-subtle`,children:c(`detectionIntelligence.photoEnrollDialog.photosAnalysed`,{done:V,count:h.length})})]}),a(`div`,{className:`min-h-11`,"aria-live":`polite`,children:b===null?E===null?null:a(`div`,{className:`rounded-md border border-success/40 bg-success/10 px-3 py-2 text-xs text-success`,children:E}):e(`div`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(y,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),a(`span`,{children:b})]})}),h.length>0&&a(`div`,{className:`max-h-[50vh] space-y-4 overflow-y-auto pr-1`,children:h.map(e=>a(yn,{photo:e,identities:O,draft:S,newNames:w,disabled:A,onAssign:(t,n)=>C(r=>an(r,e.photoIndex,t,n===hn?null:n)),onNameChange:(t,n)=>T(r=>({...r,[rn(e.photoIndex,t)]:n})),onRetry:()=>void F(e)},e.photoIndex))}),e(We,{children:[a(Y,{variant:`secondary`,onClick:N,disabled:_,children:c(`common.close`,`Close`)}),e(Y,{variant:`primary`,onClick:()=>void B(),disabled:A||L===0,children:[_?a(z,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`detectionIntelligence.photoEnrollDialog.enrolFaces`,{count:L})]})]})]})})}c();var xn=[[`faceGallery`]];function Sn({identityId:t}){let{t:n}=Z(),r=l(),{data:i,isLoading:o}=fe({identityId:t}),s=je();function c(e){s.mutate({identityId:t,sampleId:e.id},{onSettled:()=>{r.invalidateQueries({queryKey:xn})}})}return o?e(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[a(z,{className:`h-3.5 w-3.5 animate-spin`}),n(`detectionIntelligence.peopleList.loadingSamples`,`Loading samples…`)]}):!i||i.length===0?a(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:n(`detectionIntelligence.peopleList.noSamplesYet`,`No samples yet.`)}):a(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:i.map(t=>e(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[t.base64?a(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:n(`detectionIntelligence.peopleList.sample`,`Sample`),className:`h-full w-full object-cover`}):a(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:a(U,{className:`h-6 w-6`})}),t.source===`photo`&&a(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 p-0.5 text-white`,title:n(`detectionIntelligence.peopleList.enrolledFromAnUploadedPhoto`,`Enrolled from an uploaded photo`),children:a(H,{className:`h-3 w-3`})}),a(`button`,{type:`button`,onClick:()=>c(t),disabled:s.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":n(`detectionIntelligence.peopleList.removeSample`,`Remove sample`),children:a(m,{className:`h-4 w-4 text-white`})})]},t.id))})}function Cn(t){return[{key:`person`,header:X.t(`detectionIntelligence.peopleList.person`,`Person`),sortValue:e=>e.name,render:t=>e(`span`,{className:`flex min-w-0 items-center gap-2`,children:[a(`span`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:a(Lt,{mediaId:t.coverMediaId,base64:t.coverBase64,alt:t.name,className:`h-full w-full object-cover`,placeholder:a(`span`,{className:`flex h-full w-full items-center justify-center`,children:a(U,{className:`h-4 w-4 text-foreground-subtle`})})})}),a(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.name})]})},{key:`samples`,header:X.t(`detectionIntelligence.peopleList.samples`,`Samples`),align:`center`,nowrap:!0,sortValue:e=>e.sampleCount,render:e=>a(Re,{variant:`default`,className:`text-[10px]`,children:e.sampleCount})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:n=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[a(oe,{variant:`ghost`,size:`sm`,icon:F,"aria-label":X.t(`detectionIntelligence.peopleList.edit`,`Edit {{name}}`,{name:n.name}),onClick:e=>{e.stopPropagation(),t.onEdit(n)}}),a(oe,{variant:`ghost`,size:`sm`,icon:N,"aria-label":X.t(`detectionIntelligence.peopleList.delete`,`Delete {{name}}`,{name:n.name}),onClick:e=>{e.stopPropagation(),t.onDelete(n)}})]})}]}function wn({mode:t,identity:n,onClose:r}){let{t:i}=Z(),c=l(),[u,d]=s(t===`edit`?n?.name??``:``),f=be(),p=ue();o(()=>{d(t===`edit`?n?.name??``:``)},[t,n?.id,n?.name]);let m=f.isPending||p.isPending,h=u.trim(),g=t===`edit`&&n!==null&&h===n.name,_=m||h.length===0||g;function v(){c.invalidateQueries({queryKey:xn})}function y(){if(!_){if(t===`new`){f.mutate({name:h},{onSuccess:()=>{v(),r()}});return}if(n===null){r();return}p.mutate({id:n.id,name:h},{onSuccess:()=>{v(),r()}})}}return a(Ge,{open:!0,onClose:r,title:t===`new`?`Add person`:`Edit ${n?.name??`person`}`,icon:U,width:t===`edit`?`xl`:`lg`,testId:`people-person-form`,footer:e(Y,{variant:`primary`,size:`sm`,type:`button`,onClick:y,disabled:_,children:[m?a(z,{className:`h-3.5 w-3.5 animate-spin`}):null,t===`new`?i(`common.add`,`Add`):i(`common.save`,`Save`)]}),children:e(`div`,{className:`space-y-4`,children:[a(Je,{label:i(`detectionIntelligence.peopleList.name`,`Name`),required:!0,children:a(we,{value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&y()},placeholder:i(`detectionIntelligence.peopleList.personName`,`Person name…`),autoFocus:!0})}),t===`edit`&&n!==null&&e(`div`,{children:[a(`p`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:i(`detectionIntelligence.peopleList.trainingSamples`,`Training samples`)}),a(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:i(`detectionIntelligence.peopleList.removeASampleToDrop`,`Remove a sample to drop it from recognition training for this person.`)}),a(Sn,{identityId:n.id})]})]})})}function Tn(){let{t}=Z(),r=l(),i=x(),{data:c,isLoading:u}=Ae(),d=$e(),{state:f,openNew:p,openEdit:m,close:h}=He(),[g,_]=s(!1),v=c??[],y=Ee(v,{searchText:e=>[e.name]}),b=f.mode===`edit`?v.find(e=>e.id===f.id)??null:null;o(()=>{f.mode===`edit`&&!u&&b===null&&h()},[f.mode,u,b,h]);let S=n(()=>Cn({onEdit:e=>m(e.id),onDelete:e=>{(async()=>{await i({title:t(`detectionIntelligence.peopleList.deletePerson`,`Delete person`),message:t(`detectionIntelligence.peopleList.deleteAndAllTheirSamples`,`Delete {{name}} and all their samples? This cannot be undone.`,{name:e.name}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&d.mutate({id:e.id},{onSettled:()=>{r.invalidateQueries({queryKey:xn}),f.mode===`edit`&&f.id===e.id&&h()}})})()}}),[i,h,d,f,m,r,t]);if(u)return e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[a(z,{className:`h-4 w-4 animate-spin`}),t(`detectionIntelligence.peopleList.loadingPeople`,`Loading people…`)]});let C=f.mode===`new`||f.mode===`edit`&&b!==null;return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(Y,{variant:`primary`,size:`sm`,type:`button`,onClick:p,children:[a(D,{className:`h-3.5 w-3.5`}),t(`detectionIntelligence.peopleList.addPerson`,`Add person`)]}),e(Y,{variant:`secondary`,size:`sm`,type:`button`,onClick:()=>_(!0),children:[a(H,{className:`h-3.5 w-3.5`}),t(`detectionIntelligence.peopleList.enrolFromAPhoto`,`Enrol from a photo`)]})]}),(v.length>0||y.active)&&a(ce,{state:y.state,facets:y.facets,labels:{searchPlaceholder:`Search people…`,searchLabel:`Search people`,facetsLabel:`Filter`,clearLabel:`Clear`},onSearch:y.setSearch,onToggleFacet:y.toggleFacet,onClear:y.clear}),y.rows.length===0?a(Be,{icon:U,title:y.active?t(`detectionIntelligence.peopleList.nothingMatchesTheFilter`,`Nothing matches the filter`):t(`detectionIntelligence.peopleList.noPeopleEnrolledYet`,`No people enrolled yet`),description:y.active?t(`detectionIntelligence.peopleList.clearTheSearchOrTry`,`Clear the search or try another name.`):t(`detectionIntelligence.peopleList.addAPersonOrEnrol`,`Add a person, or enrol faces from a photo.`)}):a(et,{columns:S,rows:y.rows,rowKey:e=>e.id,maxBodyHeight:J,emptyMessage:t(`detectionIntelligence.peopleList.noPeopleEnrolledYet2`,`No people enrolled yet.`),onRowClick:e=>m(e.id)}),C&&a(wn,{mode:f.mode===`new`?`new`:`edit`,identity:b,onClose:h}),a(bn,{open:g,onOpenChange:_})]})}function En(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function Dn(e){return e.filter(En).map(e=>e.faceId)}function On(e){let t=0;for(let n of e)En(n)&&(t+=1);return t}function kn(e){return e==null?null:e.cropUrl!==void 0&&e.cropUrl.length>0?e.cropUrl:e.base64!==void 0&&e.base64.length>0?`data:image/jpeg;base64,${e.base64}`:null}c();var An=[[`faceGallery`]];function jn({faceIds:t,identities:n,onDone:r}){let{t:i}=Z(),o=l(),c=me(),u=be(),[d,f]=s(``),[p,m]=s(!1),[h,g]=s(null),_=t!==null&&t.length>0,v=t?.length??0;function y(){m(!1),f(``),g(null)}function b(){y(),r()}function x(e){!t||t.length===0||c.mutate({faceIds:[...t],identityId:e},{onSettled:()=>{o.invalidateQueries({queryKey:An}),b()}})}function S(){!t||!d.trim()||u.mutate({name:d.trim()},{onSuccess:e=>{e?.id&&x(e.id)},onError:()=>{o.invalidateQueries({queryKey:An}),b()}})}let C=c.isPending||u.isPending;return a(ke,{open:_,onOpenChange:e=>!e&&b(),children:e(de,{children:[e(_e,{children:[a(Ne,{children:v>1?i(`detectionIntelligence.assignDialog.assignFacesToPerson`,`Assign {{value1}} faces to person`,{value1:String(v)}):i(`detectionIntelligence.assignDialog.assignFaceToPerson`,`Assign face to person`)}),a(ye,{children:i(`detectionIntelligence.assignDialog.selectAnExistingPersonOr`,`Select an existing person or create a new one.`)})]}),a(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:n.map(t=>e(Y,{variant:`unstyled`,type:`button`,onClick:()=>g(t.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${h===t.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[a(`span`,{className:`font-medium`,children:t.name}),a(`span`,{className:`ml-2 text-foreground-subtle`,children:i(`detectionIntelligence.assignDialog.samples`,{count:t.sampleCount})})]},t.id))}),a(`div`,{className:`min-h-[2.75rem] border-t border-border pt-2`,children:p?a(`div`,{className:`flex items-center gap-2`,children:a(we,{placeholder:i(`detectionIntelligence.assignDialog.newPersonName`,`New person name…`),value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},autoFocus:!0,className:`flex-1`})}):a(Y,{variant:`unstyled`,type:`button`,onClick:()=>{g(null),m(!0)},className:`w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle transition-colors hover:border-primary hover:text-primary`,children:i(`detectionIntelligence.assignDialog.newPerson`,`+ New person…`)})}),e(We,{className:`min-h-[2.75rem]`,children:[a(Y,{variant:`secondary`,onClick:b,disabled:C,children:i(`common.cancel`,`Cancel`)}),p?e(Y,{variant:`primary`,onClick:S,disabled:C||!d.trim(),children:[C&&a(z,{className:`h-3.5 w-3.5 animate-spin`}),i(`detectionIntelligence.assignDialog.createAssign`,`Create & assign`)]}):e(Y,{variant:`primary`,onClick:()=>h&&x(h),disabled:C||!h,children:[C&&a(z,{className:`h-3.5 w-3.5 animate-spin`}),v>1?i(`detectionIntelligence.assignCount`,{count:v}):i(`common.assign`)]})]})]})})}function Mn(e){return e<0?0:e>1?1:e}function Nn(e,t,n){if(!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0)return null;let r=Mn(e.x/t),i=Mn(e.y/n),a=Mn((e.x+e.w)/t),o=Mn((e.y+e.h)/n);return{x:r,y:i,width:Math.max(0,a-r),height:Math.max(0,o-i)}}c();function Pn(e){let[t,n]=s(null),[r,i]=s(null),[a,c]=s(!1);return o(()=>{if(n(null),i(null),c(!1),e===void 0)return;let t=!1,r=null;return(async()=>{try{let i=await Ct(wt(e));if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||c(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),o(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>c(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function Fn(e){let t=e.filter(e=>e.url.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function In({label:t,value:n}){return e(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[a(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:t}),a(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:n})]})}function Ln({box:e}){let{t}=Z();return a(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:a(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:t(`detectionIntelligence.faceDetailPanel.face`,`Face`)})})}function Rn({face:t,cameraName:r,onClose:i,onAssign:o,onUnassign:c,onDelete:l,actionsPending:u}){let{t:d}=Z(),{data:f,isFetching:m}=ie({faceId:t?.faceId??``},{enabled:t!==null}),[h,v]=s(`frame`),{frameSrc:y,naturalWidth:b,naturalHeight:x,failed:S}=Pn(t?.keyFrameMediaId),C=n(()=>{let e=Fn(f??[]);return e?e.url:kn(t)},[f,t]),w=n(()=>!t?.faceBbox||b===null||x===null?null:Nn(t.faceBbox,b,x),[t?.faceBbox,b,x]);if(t===null)return null;let T=t.keyFrameMediaId!==void 0&&!S,E=T&&h===`frame`,D=t.assigned?t.identityName??`Assigned`:t.recognizedIdentityId?`${t.identityName??`Recognized`} (suggested)`:`Unassigned`;return a(ke,{open:!0,onOpenChange:e=>!e&&i(),children:e(de,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":d(`detectionIntelligence.faceDetailPanel.faceDetail`,`Face detail`),className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[a(`header`,{className:`flex shrink-0 items-start gap-2 border-b border-border py-3 pl-4 pr-10`,children:e(`div`,{className:`min-w-0`,children:[a(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:d(`detectionIntelligence.faceDetailPanel.faceDetail`,`Face detail`)}),a(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:r})]})}),e(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[T&&e(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[e(Y,{variant:`unstyled`,type:`button`,onClick:()=>v(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${h===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(p,{className:`h-3.5 w-3.5`}),` `,d(`detectionIntelligence.detailPanel.fullFrame`)]}),e(Y,{variant:`unstyled`,type:`button`,onClick:()=>v(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${h===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(K,{className:`h-3.5 w-3.5`}),` `,d(`detectionIntelligence.detailPanel.crop`)]})]}),E&&y?a(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:a(pt,{src:y,alt:d(`detectionIntelligence.faceDetailPanel.fullFrameWithDetectedFace`,`Full frame with detected face`),fit:`natural`,className:`w-full`,overlay:w?a(Ln,{box:w}):void 0})}):C?e(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[a(pt,{src:C,alt:d(`detectionIntelligence.faceDetailPanel.detectedFace`,`Detected face`),className:`h-full w-full`}),m&&a(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:a(z,{className:`h-3.5 w-3.5 animate-spin`})})]}):e(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[a(_,{className:`h-8 w-8 text-warning/70`}),a(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:d(`detectionIntelligence.faceDetailPanel.noImage`,`No image`)}),a(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:d(`detectionIntelligence.faceDetailPanel.theCropMediaForThis`,`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`)})]}),e(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[a(In,{label:d(`detectionIntelligence.faceDetailPanel.camera`,`Camera`),value:r}),a(In,{label:d(`detectionIntelligence.faceDetailPanel.captured`,`Captured`),value:ft(t.timestamp)}),a(In,{label:d(`detectionIntelligence.faceDetailPanel.track`,`Track`),value:t.trackId}),a(In,{label:d(`detectionIntelligence.faceDetailPanel.identity`,`Identity`),value:D})]})]}),e(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[t.assigned?e(Y,{variant:`secondary`,onClick:()=>c(t.faceId),disabled:u,children:[a(te,{className:`h-3.5 w-3.5`}),` `,d(`detectionIntelligence.detailPanel.detach`)]}):e(Y,{variant:`primary`,onClick:()=>o(t.faceId),disabled:u,children:[a(g,{className:`h-3.5 w-3.5`}),` `,d(`common.assign`)]}),e(Y,{variant:`secondary`,onClick:()=>l(t.faceId),disabled:u,children:[a(N,{className:`h-3.5 w-3.5`}),` `,d(`common.delete`)]})]})]})})}function zn(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Bn(e,t){return e.faceIds.filter(e=>!t.has(e))}function Vn(e,t){return e.faceIds.filter(e=>t(e))}c();var Hn=[[`faceGallery`]],Un=20,Wn=.3,Gn=.9,Kn=.05,qn=.5,Jn=2,Yn=10,Xn=2;function Zn({cluster:t,face:n,active:r,onSelect:i}){let{t:o}=Z(),s=kn(n);return e(Y,{variant:`unstyled`,type:`button`,onClick:i,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${r?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[a(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:s===null?a(_,{className:`h-24 w-24 p-6 text-foreground-subtle`}):a(`img`,{src:s,alt:``,loading:`lazy`,decoding:`async`,className:`h-24 w-24 object-cover`})}),a(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:o(`detectionIntelligence.similarGroupsModal.clusterMeta`,{count:t.size,percent:Math.round(t.cohesion*100)})})]})}function Qn({face:t,cameraName:n,nowMs:r,excluded:i,onToggleExclude:o,onDelete:s,deletePending:c}){let{t:l}=Z(),u=kn(t);return e(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${i?`border-border opacity-40 grayscale`:`border-border`}`,children:[e(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[u===null?e(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[a(_,{className:`h-7 w-7 text-warning/70`}),a(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:l(`detectionIntelligence.similarGroupsModal.noCrop`,`No crop`)})]}):a(pt,{src:u,alt:l(`detectionIntelligence.similarGroupsModal.faceFrom`,`Face from {{cameraName}}`,{cameraName:n}),className:`h-full w-full`}),a(Y,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),o()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?l(`detectionIntelligence.similarGroupsModal.includeFace`,`Include face`):l(`detectionIntelligence.similarGroupsModal.excludeFace`,`Exclude face`),title:i?l(`detectionIntelligence.similarGroupsModal.include`,`Include`):l(`detectionIntelligence.similarGroupsModal.exclude`,`Exclude`),children:a(i?j:m,{className:`h-3.5 w-3.5`})})]}),e(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[a(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:n,children:n}),a(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:dt(t.timestamp,r)})]}),a(`div`,{className:`mt-1 flex min-h-[2rem] items-center justify-end border-t border-border/60 px-1 py-0.5`,children:a(Y,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:c,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":l(`detectionIntelligence.similarGroupsModal.deleteFace`,`Delete face`),title:l(`detectionIntelligence.similarGroupsModal.deleteFace`,`Delete face`),children:c?a(z,{className:`h-4 w-4 animate-spin`}):a(N,{className:`h-4 w-4`})})})]})}function $n({open:t,onClose:r,byId:i,cameraName:c,nowMs:f,identities:p,selectMany:m}){let{t:h}=Z(),_=l(),y=x(),b=Se(),[S,C]=s(qn),[w,T]=s(Xn),[E,D]=s(null),[O,k]=s({}),[A,j]=s(null),{data:M,isFetching:N,refetch:P}=ve({threshold:S,minClusterSize:w,limit:Un},{enabled:t}),F=M??[];o(()=>{k({})},[S,w]),o(()=>{if(F.length===0){D(null);return}F.some(e=>e.representativeFaceId===E)||D(F[0]?.representativeFaceId??null)},[F]);let I=n(()=>F.find(e=>e.representativeFaceId===E)??null,[F,E]),R=I?O[I.representativeFaceId]??new Set:new Set,B=n(()=>I?Vn(I,e=>i.has(e)):[],[I,i]),V=I?I.faceIds.length-B.length:0,H=I?Bn({...I,faceIds:B},R):[];function ee(e){if(!I)return;let t=I.representativeFaceId;k(n=>({...n,[t]:zn(n[t]??new Set,e)}))}function U(){_.invalidateQueries({queryKey:Hn})}async function W(e){await y({title:h(`detectionIntelligence.similarGroupsModal.deleteFace`,`Delete face`),message:h(`detectionIntelligence.similarGroupsModal.permanentlyDeletesThisFaceCrop`,`Permanently deletes this face crop. This cannot be undone.`),confirmLabel:h(`common.delete`,`Delete`),variant:`danger`})&&b.mutate({faceId:e},{onSettled:U})}function G(){j(null),r()}function te(){H.length!==0&&(m(H),G())}return e(ke,{open:t,onOpenChange:e=>!e&&G(),children:[e(de,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":h(`detectionIntelligence.similarGroupsModal.lookAlikeGroups`,`Look-alike groups`),className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[e(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border py-3 pl-4 pr-10`,children:[e(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[a(L,{className:`h-4 w-4 text-primary`}),` `,h(`detectionIntelligence.similarGroupsModal.title`)]}),e(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[h(`detectionIntelligence.similarGroupsModal.threshold`,`Threshold`),a(d,{min:Wn,max:Gn,step:Kn,value:S,onChange:e=>C(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),a(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:S.toFixed(2)})]}),e(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[h(`detectionIntelligence.similarGroupsModal.minSize`,`Min size`),a(we,{type:`number`,min:Jn,max:Yn,step:1,value:w,onChange:e=>T(Math.min(Yn,Math.max(Jn,Number(e.target.value)||Jn))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),e(Y,{variant:`secondary`,onClick:()=>{k({}),P()},disabled:N,children:[N?a(z,{className:`h-3.5 w-3.5 animate-spin`}):a(v,{className:`h-3.5 w-3.5`}),h(`detectionIntelligence.similarGroupsModal.reAnalyze`,`Re-analyze`)]})]})]}),a(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:N&&F.length===0?e(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[a(z,{className:`h-4 w-4 animate-spin`}),` `,h(`detectionIntelligence.similarGroupsModal.finding`)]}):F.length===0?a(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:h(`detectionIntelligence.similarGroupsModal.noLookAlikeGroupsAt`,`No look-alike groups at this threshold.`)}):e(u,{children:[a(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:F.map(e=>a(Zn,{cluster:e,face:i.get(e.representativeFaceId),active:e.representativeFaceId===E,onSelect:()=>D(e.representativeFaceId)},e.representativeFaceId))}),a(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:F.map(e=>a(Zn,{cluster:e,face:i.get(e.representativeFaceId),active:e.representativeFaceId===E,onSelect:()=>D(e.representativeFaceId)},e.representativeFaceId))}),a(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:I&&e(u,{children:[V>0&&a(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:h(`detectionIntelligence.similarGroupsModal.hiddenCount`,{count:V})}),a(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,13rem))] justify-start gap-2`,children:B.map(e=>{let t=i.get(e);return t?a(Qn,{face:t,cameraName:c(t.deviceId),nowMs:f,excluded:R.has(e),onToggleExclude:()=>ee(e),onDelete:()=>void W(e),deletePending:b.isPending&&b.variables?.faceId===e},e):null})})]})})]})}),e(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[a(Y,{variant:`secondary`,onClick:te,disabled:H.length===0,children:h(`detectionIntelligence.similarGroupsModal.selectInGallery`,`Select in gallery`)}),e(Y,{variant:`primary`,onClick:()=>j(H),disabled:H.length===0,children:[a(g,{className:`h-3.5 w-3.5`}),` `,h(`detectionIntelligence.similarGroupsModal.adopt`,{count:H.length})]})]})]}),a(jn,{faceIds:A,identities:p,onDone:()=>j(null)})]})}c();var er=[[`faceGallery`]],tr=500,nr=120;function rr({face:t,cameraName:n,nowMs:r,selected:i,onToggleSelect:o,onAssign:s,onOpenDetail:c}){let{t:u}=Z(),d=l(),f=Ue(),p=Se(),m=()=>{d.invalidateQueries({queryKey:er})},h=()=>c(t.faceId),v=kn(t);return e(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[e(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[v===null?e(`button`,{type:`button`,onClick:h,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:u(`detectionIntelligence.unassignedFaces.noCropImageTheFace`,`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`),children:[a(_,{className:`h-7 w-7 text-warning/70`}),a(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:u(`detectionIntelligence.unassignedFaces.noCrop`,`No crop`)})]}):a(`img`,{src:v,alt:u(`detectionIntelligence.unassignedFaces.faceFrom`,`Face from {{cameraName}}`,{cameraName:n}),onClick:h,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(t.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?u(`detectionIntelligence.unassignedFaces.deselect`,`Deselect`):u(`detectionIntelligence.unassignedFaces.select`,`Select`),children:i?a(ne,{className:`h-4 w-4 text-primary`}):a(k,{className:`h-4 w-4`})})]}),e(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[a(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:n,children:n}),a(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:dt(t.timestamp,r)}),a(`p`,{className:`min-h-[0.875rem] truncate text-[10px] font-medium leading-tight ${t.identityName?`text-primary`:`invisible`}`,title:t.identityName,children:t.identityName??`\xA0`})]}),e(`div`,{className:`mt-1 flex min-h-[2rem] items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[t.assigned?a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f.mutate({faceId:t.faceId},{onSettled:m})},disabled:f.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":u(`detectionIntelligence.unassignedFaces.detachFace`,`Detach face`),title:u(`detectionIntelligence.unassignedFaces.detach`,`Detach`),children:f.isPending?a(z,{className:`h-4 w-4 animate-spin`}):a(te,{className:`h-4 w-4`})}):a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(t.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":u(`detectionIntelligence.unassignedFaces.assignFaceToPerson`,`Assign face to person`),title:u(`detectionIntelligence.unassignedFaces.assignToPerson`,`Assign to person`),children:a(g,{className:`h-4 w-4`})}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p.mutate({faceId:t.faceId},{onSettled:m})},disabled:p.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":u(`detectionIntelligence.unassignedFaces.deleteFace`,`Delete face`),title:u(`detectionIntelligence.unassignedFaces.deleteFace`,`Delete face`),children:p.isPending?a(z,{className:`h-4 w-4 animate-spin`}):a(N,{className:`h-4 w-4`})})]})]})}var ir=[{labelKey:`common.all`,value:`all`},{labelKey:`detectionIntelligence.unassignedFaces.filterUnassigned`,value:`unassigned`},{labelKey:`detectionIntelligence.unassignedFaces.filterRecognized`,value:`recognized`}];function ar(){let{t}=Z(),r=l(),[i,o]=s(`all`),[c,d]=s(_t),[f,p]=s(new Set),[h,v]=s(new Set),[y,b]=s(null),[x,S]=s(!1),[C,w]=s(null),{data:T,isLoading:E}=De({limit:tr,filter:i,includeCrops:!1},{refetchInterval:3e4}),{data:D=[]}=Ae(),{data:O}=Fe({isCamera:!0,projection:`slim`}),k=me(),A=Ue(),j=ge(),M=Se(),P=Date.now(),F=T??[],I=n(()=>{let e=new Map;for(let t of O??[])e.set(t.id,t.name);return e},[O]),R=e=>I.get(e)??t(`detectionIntelligence.cameraFallback`,{id:String(e)}),B=n(()=>bt(F).map(e=>({id:e,name:R(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[F,I]),V=n(()=>ut(mt(F,c),f),[F,c,f]),H=gt(V,nr,n(()=>JSON.stringify([i,c.fromMs,c.toMs,[...f].sort((e,t)=>e-t)]),[i,c.fromMs,c.toMs,f])),ee=n(()=>new Map(F.map(e=>[e.faceId,e])),[F]),U=n(()=>On(V),[V]),W=C===null?null:ee.get(C)??null,G=()=>{r.invalidateQueries({queryKey:er})},K=()=>v(new Set);function ne(e){v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function re(e){v(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function ie(){re(Dn(V))}let q=[...h],J=k.isPending||j.isPending||M.isPending,ae=A.isPending||M.isPending;function oe(){q.length!==0&&j.mutate({faceIds:q},{onSettled:()=>{G(),K()}})}function se(){q.length!==0&&Promise.allSettled(q.map(e=>M.mutateAsync({faceId:e}))).then(()=>{G(),K()})}function ce(e){w(null),b([e])}function le(e){A.mutate({faceId:e},{onSettled:G}),w(null)}function ue(e){M.mutate({faceId:e},{onSettled:G}),w(null)}let de=V.length!==F.length;return e(`div`,{className:`relative space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[a(`div`,{className:`flex items-center gap-1`,children:ir.map(e=>a(`button`,{type:`button`,onClick:()=>o(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:t(e.labelKey)},e.value))}),a(lt,{onChange:d}),a(vt,{cameras:B,selected:f,onChange:p}),e(`button`,{type:`button`,onClick:()=>S(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${x?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(L,{className:`h-3.5 w-3.5`}),` `,t(`detectionIntelligence.unassignedFaces.similarGroups`)]}),!E&&U>0&&e(`button`,{type:`button`,onClick:ie,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:t(`detectionIntelligence.unassignedFaces.selectEveryVisibleFaceWhose`,`Select every visible face whose crop image is missing so you can delete the orphans in one pass`),children:[a(_,{className:`h-3.5 w-3.5`}),` `,t(`detectionIntelligence.unassignedFaces.selectCropless`,{count:U})]}),!E&&a(`span`,{className:`text-[10px] text-foreground-subtle ${U>0?`ml-2`:`ml-auto`}`,children:de?t(`detectionIntelligence.unassignedFaces.ofFaces`,`{{value1}} of {{value2}} faces`,{value1:String(V.length),value2:String(F.length)}):t(`detectionIntelligence.unassignedFaces.faceCount`,{count:V.length})})]}),h.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[a(`span`,{className:`text-xs font-medium text-foreground`,children:t(`common.selectedCount`,{count:h.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[e(Y,{variant:`primary`,onClick:()=>b(q),disabled:J,children:[a(g,{className:`h-3.5 w-3.5`}),` `,t(`common.assign`)]}),e(Y,{variant:`secondary`,onClick:oe,disabled:J,children:[j.isPending?a(z,{className:`h-3.5 w-3.5 animate-spin`}):a(te,{className:`h-3.5 w-3.5`}),` `,t(`detectionIntelligence.unassignedFaces.detach`,`Detach`)]}),e(Y,{variant:`secondary`,onClick:se,disabled:J,children:[a(N,{className:`h-3.5 w-3.5`}),` `,t(`common.delete`)]}),a(Y,{variant:`ghost`,onClick:K,disabled:J,children:a(m,{className:`h-3.5 w-3.5`})})]})]}),E?a(qe,{status:`pending`,pendingMessage:`Loading faces…`,testId:`faces-grid`}):V.length===0?a(Be,{icon:_,title:F.length>0?t(`detectionIntelligence.unassignedFaces.nothingMatchesTheFilter`,`Nothing matches the filter`):t(`detectionIntelligence.unassignedFaces.noFacesFoundForThis`,`No faces found for this filter`),description:F.length>0?t(`detectionIntelligence.unassignedFaces.widenTheDateRangeOr`,`Widen the date range or clear the camera filter.`):t(`detectionIntelligence.unassignedFaces.faceCropsAppearHereWhen`,`Face crops appear here when the detection pipeline captures them.`)}):e(u,{children:[a(qe,{status:`ready`,testId:`faces-grid`,className:`grid-cols-[repeat(auto-fill,minmax(6.5rem,6.5rem))] justify-start`,children:H.pageItems.map(e=>a(rr,{face:e,cameraName:R(e.deviceId),nowMs:P,selected:h.has(e.faceId),onToggleSelect:ne,onAssign:e=>b([e]),onOpenDetail:w},e.faceId))}),a(yt,{currentPage:H.page,totalItems:H.totalItems,pageSize:H.pageSize,onPageChange:H.setPage,itemNoun:`faces`})]}),a(Rn,{face:W,cameraName:W?R(W.deviceId):``,onClose:()=>w(null),onAssign:ce,onUnassign:le,onDelete:ue,actionsPending:ae}),a(jn,{faceIds:y,identities:D,onDone:()=>{b(null),K()}}),a($n,{open:x,onClose:()=>S(!1),byId:ee,cameraName:R,nowMs:P,identities:D,selectMany:re})]})}c();var or=[[`faceGallery`]],sr=2e3;function cr(){let e=l(),n=t(e);n.current=e;let r=t(void 0);r.current||=ht({delayMs:sr,invalidate:()=>{n.current.invalidateQueries({queryKey:or})}}),o(()=>()=>r.current?.cancel(),[]),Pe(B.PipelineAnalyticsFaceGalleryChanged,()=>{r.current?.trigger()})}function lr(){let{t}=Z();return cr(),e(`div`,{className:`space-y-3`,children:[a(he,{headingId:`library-people`,title:t(`detectionIntelligence.people`,`People`),icon:U,testId:`library-section-people`,children:e(`div`,{className:`${f} space-y-3`,children:[a(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:t(`detectionIntelligence.enrolledIdentitiesUsedForFace`,`Enrolled identities used for face recognition. Open a person to rename them or remove training samples.`)}),a(Tn,{})]})}),a(he,{headingId:`library-recent-faces`,title:t(`detectionIntelligence.recentDetectedFaces`,`Recent detected faces`),icon:ee,testId:`library-section-recent-faces`,children:e(`div`,{className:`${f} space-y-3`,children:[a(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:t(`detectionIntelligence.faceCropsCapturedByThe`,`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`)}),a(ar,{})]})})]})}function ur(e){return e==null?null:e.cropUrl!==void 0&&e.cropUrl.length>0?e.cropUrl:e.base64!==void 0&&e.base64.length>0?`data:image/jpeg;base64,${e.base64}`:null}c();var dr=[[`plateGallery`]];function fr({plateIds:t,vehicles:n,onDone:r}){let{t:i}=Z(),o=l(),c=Ye(),u=Ie(),[d,f]=s(``),[p,m]=s(!1),[h,g]=s(null),_=t!==null&&t.length>0,v=t?.length??0;function y(){m(!1),f(``),g(null)}function b(){y(),r()}function x(e){!t||t.length===0||c.mutate({plateIds:[...t],vehicleId:e},{onSettled:()=>{o.invalidateQueries({queryKey:dr}),b()}})}function S(){!t||!d.trim()||u.mutate({name:d.trim()},{onSuccess:e=>{e?.id&&x(e.id)},onError:()=>{o.invalidateQueries({queryKey:dr}),b()}})}let C=c.isPending||u.isPending;return a(ke,{open:_,onOpenChange:e=>!e&&b(),children:e(de,{children:[e(_e,{children:[a(Ne,{children:v>1?i(`detectionIntelligence.assignPlateDialog.assignPlatesToVehicle`,`Assign {{value1}} plates to vehicle`,{value1:String(v)}):i(`detectionIntelligence.assignPlateDialog.assignPlateToVehicle`,`Assign plate to vehicle`)}),a(ye,{children:i(`detectionIntelligence.assignPlateDialog.selectAnExistingVehicleOr`,`Select an existing vehicle or create a new one.`)})]}),a(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:n.map(t=>e(Y,{variant:`unstyled`,type:`button`,onClick:()=>g(t.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${h===t.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[a(`span`,{className:`font-medium`,children:t.name}),a(`span`,{className:`ml-2 text-foreground-subtle`,children:i(`detectionIntelligence.assignPlateDialog.plates`,{count:t.sampleCount})})]},t.id))}),p?a(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:a(we,{placeholder:i(`detectionIntelligence.assignPlateDialog.newVehicleName`,`New vehicle name…`),value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},autoFocus:!0,className:`flex-1`})}):a(Y,{variant:`unstyled`,type:`button`,onClick:()=>{g(null),m(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:i(`detectionIntelligence.assignPlateDialog.newVehicle`,`+ New vehicle…`)}),e(We,{children:[a(Y,{variant:`secondary`,onClick:b,disabled:C,children:i(`common.cancel`,`Cancel`)}),p?e(Y,{variant:`primary`,onClick:S,disabled:C||!d.trim(),children:[C&&a(z,{className:`h-3.5 w-3.5 animate-spin`}),i(`detectionIntelligence.assignPlateDialog.createAssign`,`Create & assign`)]}):e(Y,{variant:`primary`,onClick:()=>h&&x(h),disabled:C||!h,children:[C&&a(z,{className:`h-3.5 w-3.5 animate-spin`}),v>1?i(`detectionIntelligence.assignCount`,{count:v}):i(`common.assign`)]})]})]})})}c();var pr=[[`plateGallery`]];function mr(e){let[t,n]=s(null),[r,i]=s(null),[a,c]=s(!1);return o(()=>{if(n(null),i(null),c(!1),e===void 0)return;let t=!1,r=null;return(async()=>{try{let i=await Ct(wt(e));if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||c(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),o(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>c(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function hr(e){let t=e.filter(e=>e.url.length>0);return t.length===0?null:t.find(e=>/crop|plate/i.test(e.kind))??t[0]}function gr({label:t,value:n,mono:r}){return e(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[a(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:t}),a(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground ${r?`font-mono`:``}`,title:n,children:n})]})}function _r({box:e}){let{t}=Z();return a(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:a(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:t(`detectionIntelligence.plateDetailPanel.plate`,`Plate`)})})}function vr({plate:t,cameraName:r,onClose:i,onAssign:c,onUnassign:u,onDelete:d,actionsPending:f}){let{t:h}=Z(),v=l(),{data:y,isFetching:b}=ae({plateId:t?.plateId??``},{enabled:t!==null}),x=Qe(),[S,C]=s(`frame`),[w,T]=s(!1),[E,D]=s(``),{frameSrc:O,naturalWidth:k,naturalHeight:A,failed:j}=mr(t?.keyFrameMediaId);o(()=>{T(!1),D(``),C(`frame`)},[t?.plateId]);let P=n(()=>{let e=hr(y??[]);return e?e.url:ur(t)},[y,t]),I=n(()=>!t?.plateBbox||k===null||A===null?null:Nn(t.plateBbox,k,A),[t?.plateBbox,k,A]);if(t===null)return null;let L=t.keyFrameMediaId!==void 0&&!j,R=L&&S===`frame`,B=t.assigned?t.vehicleName??`Assigned`:t.recognizedVehicleId?`${t.vehicleName??`Recognized`} (suggested)`:`Unassigned`,V=`${String(Math.round(t.score*100))}%${t.corrected?` · corrected`:``}`;function H(){t&&(D(t.text),T(!0))}function ee(){if(!t)return;let e=E.trim().toUpperCase();if(!e||e===t.text){T(!1);return}x.mutate({plateId:t.plateId,text:e},{onSettled:()=>{v.invalidateQueries({queryKey:pr}),T(!1)}})}return a(ke,{open:!0,onOpenChange:e=>!e&&i(),children:e(de,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":h(`detectionIntelligence.plateDetailPanel.plateDetail`,`Plate detail`),className:`flex h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:h-auto md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[a(`header`,{className:`flex shrink-0 items-start gap-2 border-b border-border py-3 pl-4 pr-10`,children:e(`div`,{className:`min-w-0`,children:[a(`div`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:t.text||h(`detectionIntelligence.plateDetailPanel.plateDetail`,`Plate detail`)}),a(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:r})]})}),e(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[L&&e(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[e(Y,{variant:`unstyled`,type:`button`,onClick:()=>C(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${S===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(p,{className:`h-3.5 w-3.5`}),` `,h(`detectionIntelligence.detailPanel.fullFrame`)]}),e(Y,{variant:`unstyled`,type:`button`,onClick:()=>C(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${S===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(K,{className:`h-3.5 w-3.5`}),` `,h(`detectionIntelligence.detailPanel.crop`)]})]}),R&&O?a(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:a(pt,{src:O,alt:h(`detectionIntelligence.plateDetailPanel.fullFrameWithDetectedPlate`,`Full frame with detected plate`),fit:`natural`,className:`w-full`,overlay:I?a(_r,{box:I}):void 0})}):P?e(`div`,{className:`relative aspect-[2/1] w-full overflow-hidden rounded-lg border border-border bg-background`,children:[a(pt,{src:P,alt:h(`detectionIntelligence.plateDetailPanel.detectedPlate`,`Detected plate`),className:`h-full w-full`}),b&&a(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:a(z,{className:`h-3.5 w-3.5 animate-spin`})})]}):e(`div`,{className:`flex aspect-[2/1] w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[a(_,{className:`h-8 w-8 text-warning/70`}),a(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:h(`detectionIntelligence.plateDetailPanel.noImage`,`No image`)}),a(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:h(`detectionIntelligence.plateDetailPanel.theCropMediaForThis`,`The crop media for this plate could not be resolved. Safe to delete.`)})]}),a(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-2`,children:e(`div`,{className:`flex items-center justify-between gap-3`,children:[a(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:h(`detectionIntelligence.plateDetailPanel.plateText`,`Plate text`)}),w?e(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-1.5`,children:[a(we,{value:E,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ee(),e.key===`Escape`&&T(!1)},className:`h-7 max-w-[10rem] text-right font-mono text-xs uppercase`,autoFocus:!0}),a(Y,{variant:`unstyled`,type:`button`,onClick:ee,disabled:x.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":h(`detectionIntelligence.plateDetailPanel.saveCorrectedText`,`Save corrected text`),children:x.isPending?a(z,{className:`h-3.5 w-3.5 animate-spin`}):a(M,{className:`h-3.5 w-3.5`})}),a(Y,{variant:`unstyled`,type:`button`,onClick:()=>T(!1),className:`text-foreground-subtle hover:text-foreground`,"aria-label":h(`common.cancel`,`Cancel`),children:a(m,{className:`h-3.5 w-3.5`})})]}):e(Y,{variant:`unstyled`,type:`button`,onClick:H,className:`group flex min-w-0 items-center gap-1.5`,title:h(`detectionIntelligence.plateDetailPanel.correctTheOcrReading`,`Correct the OCR reading`),children:[a(`span`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:t.text||`—`}),a(F,{className:`h-3 w-3 shrink-0 text-foreground-subtle group-hover:text-foreground`})]})]})}),e(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[a(gr,{label:h(`detectionIntelligence.plateDetailPanel.camera`,`Camera`),value:r}),a(gr,{label:h(`detectionIntelligence.plateDetailPanel.captured`,`Captured`),value:ft(t.timestamp)}),a(gr,{label:h(`detectionIntelligence.plateDetailPanel.confidence`,`Confidence`),value:V}),a(gr,{label:h(`detectionIntelligence.plateDetailPanel.vehicle`,`Vehicle`),value:B}),a(gr,{label:h(`detectionIntelligence.plateDetailPanel.track`,`Track`),value:t.trackId,mono:!0})]})]}),e(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[t.assigned?e(Y,{variant:`secondary`,onClick:()=>u(t.plateId),disabled:f,children:[a(te,{className:`h-3.5 w-3.5`}),` `,h(`detectionIntelligence.detailPanel.detach`)]}):e(Y,{variant:`primary`,onClick:()=>c(t.plateId),disabled:f,children:[a(g,{className:`h-3.5 w-3.5`}),` `,h(`common.assign`)]}),e(Y,{variant:`secondary`,onClick:()=>d(t.plateId),disabled:f,children:[a(N,{className:`h-3.5 w-3.5`}),` `,h(`common.delete`)]})]})]})})}c();var yr=[[`plateGallery`]],br=500,xr=120;function Sr({plate:t,cameraName:n,nowMs:r,selected:i,onToggleSelect:o,onAssign:s,onOpenDetail:c}){let{t:u}=Z(),d=l(),f=ze(),p=Ze(),m=()=>{d.invalidateQueries({queryKey:yr})},h=()=>c(t.plateId),v=ur(t);return e(`div`,{className:`relative flex flex-col overflow-hidden rounded-md border bg-surface ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[e(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[v===null?e(`button`,{type:`button`,onClick:h,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:u(`detectionIntelligence.recentPlates.noCropImageThePlate`,`No crop image — the plate's crop media is missing. Safe to delete.`),children:[a(_,{className:`h-7 w-7 text-warning/70`}),a(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:u(`detectionIntelligence.recentPlates.noCrop`,`No crop`)})]}):a(`img`,{src:v,alt:u(`detectionIntelligence.recentPlates.plateFrom`,`Plate {{text}} from {{cameraName}}`,{text:t.text,cameraName:n}),onClick:h,className:`h-full w-full cursor-zoom-in object-cover`}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(t.plateId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?u(`detectionIntelligence.recentPlates.deselect`,`Deselect`):u(`detectionIntelligence.recentPlates.select`,`Select`),children:i?a(ne,{className:`h-4 w-4 text-primary`}):a(k,{className:`h-4 w-4`})}),t.corrected&&e(`span`,{className:`absolute right-0 top-0 z-10 flex items-center gap-0.5 rounded-bl-md bg-primary/80 px-1 py-0.5 text-[8px] font-semibold uppercase tracking-wide text-white`,title:u(`detectionIntelligence.recentPlates.manuallyCorrected`,`Manually corrected`),children:[a(W,{className:`h-3 w-3`}),` `,u(`detectionIntelligence.recentPlates.fixed`)]})]}),e(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[a(`p`,{className:`truncate font-mono text-xs font-bold tracking-wide text-foreground`,title:t.text,children:t.text||`—`}),a(`p`,{className:`truncate text-[10px] text-foreground-subtle`,title:n,children:n}),a(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:dt(t.timestamp,r)}),t.vehicleName&&a(`p`,{className:`truncate text-[10px] font-medium text-primary`,title:t.vehicleName,children:t.vehicleName})]}),e(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[t.assigned?a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f.mutate({plateId:t.plateId},{onSettled:m})},disabled:f.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":u(`detectionIntelligence.recentPlates.detachPlate`,`Detach plate`),title:u(`detectionIntelligence.recentPlates.detach`,`Detach`),children:f.isPending?a(z,{className:`h-4 w-4 animate-spin`}):a(te,{className:`h-4 w-4`})}):a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(t.plateId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":u(`detectionIntelligence.recentPlates.assignPlateToVehicle`,`Assign plate to vehicle`),title:u(`detectionIntelligence.recentPlates.assignToVehicle`,`Assign to vehicle`),children:a(g,{className:`h-4 w-4`})}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p.mutate({plateId:t.plateId},{onSettled:m})},disabled:p.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":u(`detectionIntelligence.recentPlates.deletePlate`,`Delete plate`),title:u(`detectionIntelligence.recentPlates.deletePlate`,`Delete plate`),children:p.isPending?a(z,{className:`h-4 w-4 animate-spin`}):a(N,{className:`h-4 w-4`})})]})]})}var Cr=[{labelKey:`common.all`,value:`all`},{labelKey:`detectionIntelligence.recentPlates.filterUnassigned`,value:`unassigned`},{labelKey:`detectionIntelligence.recentPlates.filterAssigned`,value:`assigned`}];function wr(e,t){return t===`unassigned`?e.filter(e=>!e.assigned):t===`assigned`?e.filter(e=>e.assigned):e}function Tr(){let{t}=Z(),r=l(),[i,o]=s(`all`),[c,d]=s(_t),[f,p]=s(new Set),[h,v]=s(new Set),[y,b]=s(null),[x,S]=s(null),{data:C,isLoading:w}=Xe({limit:br,includeCrops:!1},{refetchInterval:3e4}),{data:T=[]}=le(),{data:E}=Fe({isCamera:!0,projection:`slim`}),D=ze(),O=re(),k=Ze(),A=Date.now(),j=C??[],M=n(()=>{let e=new Map;for(let t of E??[])e.set(t.id,t.name);return e},[E]),P=e=>M.get(e)??t(`detectionIntelligence.cameraFallback`,{id:String(e)}),F=n(()=>bt(j).map(e=>({id:e,name:P(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[j,M]),I=n(()=>ut(mt(wr(j,i),c),f),[j,i,c,f]),L=gt(I,xr,n(()=>JSON.stringify([i,c.fromMs,c.toMs,[...f].sort((e,t)=>e-t)]),[i,c.fromMs,c.toMs,f])),R=n(()=>new Map(j.map(e=>[e.plateId,e])),[j]),B=x===null?null:R.get(x)??null,V=()=>{r.invalidateQueries({queryKey:yr})},H=()=>v(new Set);function ee(e){v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let U=[...h],W=O.isPending||k.isPending,G=D.isPending||k.isPending;function K(){U.length!==0&&O.mutate({plateIds:U},{onSettled:()=>{V(),H()}})}function ne(){U.length!==0&&Promise.allSettled(U.map(e=>k.mutateAsync({plateId:e}))).then(()=>{V(),H()})}function ie(e){S(null),b([e])}function q(e){D.mutate({plateId:e},{onSettled:V}),S(null)}function J(e){k.mutate({plateId:e},{onSettled:V}),S(null)}let ae=I.length!==j.length;return e(`div`,{className:`relative space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[a(`div`,{className:`flex items-center gap-1`,children:Cr.map(e=>a(`button`,{type:`button`,onClick:()=>o(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:t(e.labelKey)},e.value))}),a(lt,{onChange:d}),a(vt,{cameras:F,selected:f,onChange:p}),!w&&a(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:ae?t(`detectionIntelligence.recentPlates.ofPlates`,`{{value1}} of {{value2}} plates`,{value1:String(I.length),value2:String(j.length)}):t(`detectionIntelligence.recentPlates.plateCount`,{count:I.length})})]}),h.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[a(`span`,{className:`text-xs font-medium text-foreground`,children:t(`common.selectedCount`,{count:h.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[e(Y,{variant:`primary`,onClick:()=>b(U),disabled:W,children:[a(g,{className:`h-3.5 w-3.5`}),` `,t(`common.assign`)]}),e(Y,{variant:`secondary`,onClick:K,disabled:W,children:[O.isPending?a(z,{className:`h-3.5 w-3.5 animate-spin`}):a(te,{className:`h-3.5 w-3.5`}),` `,t(`detectionIntelligence.recentPlates.detach`,`Detach`)]}),e(Y,{variant:`secondary`,onClick:ne,disabled:W,children:[a(N,{className:`h-3.5 w-3.5`}),` `,t(`common.delete`)]}),a(Y,{variant:`ghost`,onClick:H,disabled:W,children:a(m,{className:`h-3.5 w-3.5`})})]})]}),w?a(qe,{status:`pending`,pendingMessage:`Loading plates…`,testId:`plates-grid`}):I.length===0?a(Be,{icon:_,title:j.length>0?t(`detectionIntelligence.recentPlates.nothingMatchesTheFilter`,`Nothing matches the filter`):t(`detectionIntelligence.recentPlates.noPlatesRecognizedYet`,`No plates recognized yet`),description:j.length>0?t(`detectionIntelligence.recentPlates.widenTheDateRangeOr`,`Widen the date range or clear the camera filter.`):t(`detectionIntelligence.recentPlates.plateReadsAppearHereWhen`,`Plate reads appear here when the detection pipeline OCRs a vehicle.`)}):e(u,{children:[a(qe,{status:`ready`,testId:`plates-grid`,children:L.pageItems.map(e=>a(Sr,{plate:e,cameraName:P(e.deviceId),nowMs:A,selected:h.has(e.plateId),onToggleSelect:ee,onAssign:e=>b([e]),onOpenDetail:S},e.plateId))}),a(yt,{currentPage:L.page,totalItems:L.totalItems,pageSize:L.pageSize,onPageChange:L.setPage,itemNoun:`plates`})]}),a(vr,{plate:B,cameraName:B?P(B.deviceId):``,onClose:()=>S(null),onAssign:ie,onUnassign:q,onDelete:J,actionsPending:G}),a(fr,{plateIds:y,vehicles:T,onDone:()=>{b(null),H()}})]})}c();var Er=[[`plateGallery`]];function Dr({vehicleId:t}){let{t:n}=Z(),r=l(),{data:i,isLoading:o}=Te({vehicleId:t}),s=se();function c(e){s.mutate({vehicleId:t,sampleId:e.id},{onSettled:()=>{r.invalidateQueries({queryKey:Er})}})}return o?e(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[a(z,{className:`h-3.5 w-3.5 animate-spin`}),n(`detectionIntelligence.vehiclesList.loadingPlates`,`Loading plates…`)]}):!i||i.length===0?a(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:n(`detectionIntelligence.vehiclesList.noPlatesYet`,`No plates yet.`)}):a(`div`,{className:`mt-2 grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-6`,children:i.map(t=>e(`div`,{className:`group relative overflow-hidden rounded-md border border-border bg-surface`,children:[e(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[t.base64?a(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:t.text,className:`h-full w-full object-cover`}):a(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:a(S,{className:`h-6 w-6`})}),a(`button`,{type:`button`,onClick:()=>c(t),disabled:s.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":n(`detectionIntelligence.vehiclesList.removePlateSample`,`Remove plate sample`),children:a(m,{className:`h-4 w-4 text-white`})})]}),a(`p`,{className:`truncate px-1.5 py-1 text-center font-mono text-[11px] font-semibold tracking-wide text-foreground`,title:t.text,children:t.text})]},t.id))})}function Or(t){return[{key:`vehicle`,header:X.t(`detectionIntelligence.vehiclesList.vehicle`,`Vehicle`),sortValue:e=>e.name,render:t=>e(`span`,{className:`flex min-w-0 items-center gap-2`,children:[a(`span`,{className:`h-8 w-12 shrink-0 overflow-hidden rounded border border-border bg-surface-hover`,children:a(Lt,{mediaId:t.coverMediaId,base64:t.coverBase64,alt:t.name,className:`h-full w-full object-cover`,placeholder:a(`span`,{className:`flex h-full w-full items-center justify-center`,children:a(S,{className:`h-4 w-4 text-foreground-subtle`})})})}),a(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.name})]})},{key:`samples`,header:X.t(`detectionIntelligence.vehiclesList.plates`,`Plates`),align:`center`,nowrap:!0,sortValue:e=>e.sampleCount,render:e=>a(Re,{variant:`default`,className:`text-[10px]`,children:e.sampleCount})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:n=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[a(oe,{variant:`ghost`,size:`sm`,icon:F,"aria-label":X.t(`detectionIntelligence.vehiclesList.edit`,`Edit {{name}}`,{name:n.name}),onClick:e=>{e.stopPropagation(),t.onEdit(n)}}),a(oe,{variant:`ghost`,size:`sm`,icon:N,"aria-label":X.t(`detectionIntelligence.vehiclesList.delete`,`Delete {{name}}`,{name:n.name}),onClick:e=>{e.stopPropagation(),t.onDelete(n)}})]})}]}function kr({mode:t,vehicle:n,onClose:r}){let{t:i}=Z(),c=l(),[u,d]=s(t===`edit`?n?.name??``:``),f=Ie(),p=xe();o(()=>{d(t===`edit`?n?.name??``:``)},[t,n?.id,n?.name]);let m=f.isPending||p.isPending,h=u.trim(),g=t===`edit`&&n!==null&&h===n.name,_=m||h.length===0||g;function v(){c.invalidateQueries({queryKey:Er})}function y(){if(!_){if(t===`new`){f.mutate({name:h},{onSuccess:()=>{v(),r()}});return}if(n===null){r();return}p.mutate({id:n.id,name:h},{onSuccess:()=>{v(),r()}})}}return a(Ge,{open:!0,onClose:r,title:t===`new`?`Add vehicle`:`Edit ${n?.name??`vehicle`}`,icon:S,width:t===`edit`?`xl`:`lg`,testId:`vehicles-vehicle-form`,footer:e(Y,{variant:`primary`,size:`sm`,type:`button`,onClick:y,disabled:_,children:[m?a(z,{className:`h-3.5 w-3.5 animate-spin`}):null,t===`new`?i(`common.add`,`Add`):i(`common.save`,`Save`)]}),children:e(`div`,{className:`space-y-4`,children:[a(Je,{label:i(`detectionIntelligence.vehiclesList.name`,`Name`),required:!0,children:a(we,{value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&y()},placeholder:i(`detectionIntelligence.vehiclesList.vehicleName`,`Vehicle name…`),autoFocus:!0})}),t===`edit`&&n!==null&&e(`div`,{children:[a(`p`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:i(`detectionIntelligence.vehiclesList.plateSamples`,`Plate samples`)}),a(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:i(`detectionIntelligence.vehiclesList.removeAPlateCropTo`,`Remove a plate crop to drop it from recognition for this vehicle. Assign new plates from Recent recognized plates.`)}),a(Dr,{vehicleId:n.id})]})]})})}function Ar(){let{t}=Z(),r=l(),i=x(),{data:s,isLoading:c}=le(),u=Ce(),{state:d,openNew:f,openEdit:p,close:m}=He(),h=s??[],g=Ee(h,{searchText:e=>[e.name]}),_=d.mode===`edit`?h.find(e=>e.id===d.id)??null:null;o(()=>{d.mode===`edit`&&!c&&_===null&&m()},[d.mode,c,_,m]);let v=n(()=>Or({onEdit:e=>p(e.id),onDelete:e=>{(async()=>{await i({title:t(`detectionIntelligence.vehiclesList.deleteVehicle`,`Delete vehicle`),message:t(`detectionIntelligence.vehiclesList.deleteAndAllItsPlate`,`Delete {{name}} and all its plate samples? This cannot be undone.`,{name:e.name}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&u.mutate({id:e.id},{onSettled:()=>{r.invalidateQueries({queryKey:Er}),d.mode===`edit`&&d.id===e.id&&m()}})})()}}),[i,m,u,d,p,r,t]);if(c)return e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[a(z,{className:`h-4 w-4 animate-spin`}),t(`detectionIntelligence.vehiclesList.loadingVehicles`,`Loading vehicles…`)]});let y=d.mode===`new`||d.mode===`edit`&&_!==null;return e(`div`,{className:`space-y-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:e(Y,{variant:`primary`,size:`sm`,type:`button`,onClick:f,children:[a(D,{className:`h-3.5 w-3.5`}),t(`detectionIntelligence.vehiclesList.addVehicle`,`Add vehicle`)]})}),(h.length>0||g.active)&&a(ce,{state:g.state,facets:g.facets,labels:{searchPlaceholder:`Search vehicles…`,searchLabel:`Search vehicles`,facetsLabel:`Filter`,clearLabel:`Clear`},onSearch:g.setSearch,onToggleFacet:g.toggleFacet,onClear:g.clear}),g.rows.length===0?a(Be,{icon:S,title:g.active?t(`detectionIntelligence.vehiclesList.nothingMatchesTheFilter`,`Nothing matches the filter`):t(`detectionIntelligence.vehiclesList.noVehiclesEnrolledYet`,`No vehicles enrolled yet`),description:g.active?t(`detectionIntelligence.vehiclesList.clearTheSearchOrTry`,`Clear the search or try another name.`):t(`detectionIntelligence.vehiclesList.addAVehicleThenAssign`,`Add a vehicle, then assign plate crops from Recent recognized plates.`)}):a(et,{columns:v,rows:g.rows,rowKey:e=>e.id,maxBodyHeight:J,emptyMessage:t(`detectionIntelligence.vehiclesList.noVehiclesEnrolledYet2`,`No vehicles enrolled yet.`),onRowClick:e=>p(e.id)}),y&&a(kr,{mode:d.mode===`new`?`new`:`edit`,vehicle:_,onClose:m})]})}c();var jr=[[`plateGallery`]],Mr=2e3;function Nr(){let e=l(),n=t(e);n.current=e;let r=t(void 0);r.current||=ht({delayMs:Mr,invalidate:()=>{n.current.invalidateQueries({queryKey:jr})}}),o(()=>()=>r.current?.cancel(),[]),Pe(B.PipelineAnalyticsPlateGalleryChanged,()=>{r.current?.trigger()})}function Pr(){let{t}=Z();return Nr(),e(`div`,{className:`space-y-3`,children:[a(he,{headingId:`library-vehicles`,title:t(`plates.vehicles`,`Vehicles`),icon:S,testId:`library-section-vehicles`,children:e(`div`,{className:`${f} space-y-3`,children:[a(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:t(`plates.enrolledVehicleIdentitiesUsedFor`,`Enrolled vehicle identities used for plate recognition. Open a vehicle to rename it or remove plate samples.`)}),a(Ar,{})]})}),a(he,{headingId:`library-recent-plates`,title:t(`plates.recentRecognizedPlates`,`Recent recognized plates`),icon:G,testId:`library-section-recent-plates`,children:e(`div`,{className:`${f} space-y-3`,children:[a(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:t(`plates.licensePlatesReadByThe`,`License plates read by the detection pipeline. Assign them to a vehicle, correct the OCR text, or delete.`)}),a(Tr,{})]})})]})}function Fr(e){return e.states.length===0?3:e.latched?0:e.verdict===`diverged`?1:e.verdict===`unknown`?2:4}function Ir(e){let t=[e.divergedAt,e.restoredAt].filter(e=>typeof e==`number`);return t.length===0?null:Math.max(...t)}function Lr(e,t){let n=new Map(e.map(e=>[e.deviceId,e.deviceName])),r=[];for(let e of t)for(let t of e.monitors)r.push({deviceId:e.deviceId,deviceName:n.get(e.deviceId)??`Camera ${e.deviceId}`,monitor:t});return r.toSorted((e,t)=>{let n=Fr(e.monitor)-Fr(t.monitor);if(n!==0)return n;let r=Ir(e.monitor)??-1,i=Ir(t.monitor)??-1;if(r!==i)return i-r;let a=e.deviceName.localeCompare(t.deviceName);return a===0?e.monitor.label.localeCompare(t.monitor.label):a})}c();var Rr={alarm:`danger`,ok:`success`,unknown:`default`},zr={alarm:`Alarm`,ok:`OK`,unknown:`Unknown`};function Br(e,t){let n=Ir(e);return n===null?`—`:X.t(`scenes.transitionAgo`,{duration:P(Math.max(0,t-n))})}function Vr(e){return b(e.monitor).tone}function Hr(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:null}function Ur(){let{t}=Z(),i=Fe({isCamera:!0,projection:`slim`}),c=n(()=>(i.data??[]).map(e=>({deviceId:e.id,deviceName:e.name})).sort((e,t)=>e.deviceName.localeCompare(t.deviceName)),[i.data]),l=n(()=>c.map(e=>e.deviceId),[c]),u=Et(l),d=n(()=>Lr(c,u.results),[c,u.results]),f=Ee(d,{searchText:e=>[e.monitor.label,e.deviceName],facetValue:Vr}),{state:p,openNew:m,openEdit:h,close:g}=He(),[_,v]=s(null);o(()=>{if(p.mode===`new`){v(e=>e??l[0]??null);return}v(null)},[p.mode,l]);let y=p.mode===`edit`?Hr(p.id):null,x=y===null?``:c.find(e=>e.deviceId===y)?.deviceName??`#${y}`,S=Date.now(),E=[{key:`label`,header:t(`scenes.scene`,`Scene`),sortValue:e=>e.monitor.label,render:e=>a(`span`,{className:`font-medium`,children:e.monitor.label})},{key:`camera`,header:t(`scenes.camera`,`Camera`),nowrap:!0,sortValue:e=>e.deviceName,render:e=>e.deviceName},{key:`state`,header:t(`scenes.state`,`State`),nowrap:!0,sortValue:e=>Vr(e),render:e=>{let t=b(e.monitor);return a(Re,{variant:Rr[t.tone],children:t.text})}},{key:`status`,header:t(`scenes.whatItSays`,`What it says`),notSortableReason:`Status is a live sentence, not a comparable value`,render:e=>a(`span`,{className:`text-xs text-foreground-muted`,children:C(e.monitor,S)})},{key:`coverage`,header:t(`scenes.variants`,`Variants`),notSortableReason:`Coverage is a summary string`,render:e=>a(`span`,{className:`text-xs text-foreground-muted`,children:O(e.monitor)})},{key:`transition`,header:t(`scenes.lastChange`,`Last change`),align:`right`,nowrap:!0,sortValue:e=>Ir(e.monitor)??0,render:e=>a(`span`,{className:`text-xs tabular-nums text-foreground-muted`,children:Br(e.monitor,S)})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>a(Y,{variant:`ghost`,onClick:()=>h(String(e.deviceId)),children:t(`scenes.open`,`Open`)})}];return e(`section`,{className:`space-y-3`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4`,children:[a(`p`,{className:`text-xs text-foreground-subtle`,children:t(`scenes.aSceneWatchesOneRegion`,`A scene watches one region of one camera and tells you when it stops looking like the picture you captured — a wheelie bin, a gate, a parking space.`)}),e(Y,{onClick:m,disabled:c.length===0,className:`shrink-0`,children:[a(D,{className:`mr-1 h-3.5 w-3.5`}),t(`scenes.newScene`,`New scene`)]})]}),u.unreachableCount>0?a(`p`,{className:`text-xs text-warning`,children:t(`scenes.unreachable`,{count:u.unreachableCount})}):null,(d.length>0||f.active)&&a(ce,{state:f.state,facets:f.facets,labels:{searchPlaceholder:`Search scenes…`,searchLabel:`Search scenes`,facetsLabel:`State`,clearLabel:`Clear`},facetLabel:e=>zr[e]??e,onSearch:f.setSearch,onToggleFacet:f.toggleFacet,onClear:f.clear}),a(Le,{variant:`flat`,className:`p-0`,children:a(et,{columns:E,rows:f.rows,rowKey:e=>`${e.deviceId}:${e.monitor.id}`,minWidthPx:880,bordered:!1,maxBodyHeight:J,emptyMessage:u.isLoading?t(`scenes.loadingScenes`,`Loading scenes…`):f.active?t(`scenes.nothingMatchesTheFilter`,`Nothing matches the filter`):t(`scenes.noScenesYetPressNew`,`No scenes yet. Press “New scene”, pick a camera, then draw a box around the thing you want watched.`)})}),p.mode===`new`?e(Ge,{open:!0,onClose:g,title:t(`scenes.whichCamera`,`Which camera?`),icon:w,width:`sm`,testId:`scenes-camera-picker`,footer:a(Y,{onClick:()=>{_!==null&&h(String(_))},disabled:_===null,children:t(`scenes.continue`,`Continue`)}),children:[a(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:t(`scenes.aSceneLivesOnOne`,`A scene lives on one camera. Pick the one that can see the thing.`)}),a(T,{value:_===null?``:String(_),onChange:e=>v(Number(e.target.value)),"aria-label":t(`scenes.camera`,`Camera`),options:c.map(e=>({value:String(e.deviceId),label:e.deviceName}))})]}):null,y===null?null:e(Ge,{open:!0,onClose:g,title:t(`scenes.scenes`,`Scenes — {{editingName}}`,{editingName:x}),icon:w,width:`lg`,testId:`scenes-editor`,children:[a(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:t(`scenes.drawABoxNameIt`,`Draw a box, name it, then capture what “normal” looks like. Daylight is enough — the night reference is optional, and “Settings” on each scene tunes how fussy and how often it checks.`)}),a(r,{fallback:a(`p`,{className:`text-xs text-foreground-muted`,children:t(`scenes.loadingTheEditor`,`Loading the editor…`)}),children:a(Ke,{deviceId:y})})]})]})}function Wr(){let{t:e}=Z(),t=it(`/library`,{t:e,isAdmin:!0})??{icon:V,title:e(`nav.library`,`Library`)};return a(ct,{icon:t.icon,title:t.title,subtitle:e(`library.subtitleWithExports`,`People, vehicles, scenes and exports — what detection has recognised, and the clips you rendered.`),defaultSection:`people`,sectionsLabel:`${t.title} sections`,sections:[{id:`people`,label:e(`library.people`,`People`),content:a(lr,{})},{id:`vehicles`,label:e(`library.vehicles`,`Vehicles`),content:a(Pr,{})},{id:`scenes`,label:e(`library.scenes`,`Scenes`),content:a(Ur,{})},{id:`exports`,label:e(`library.exports`,`Exports`),content:a(It,{}),ownedParams:[tt]}]})}export{Wr as LibraryPage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hr as c,Ia as l,Nr as u,O as d,Qa as f,Tt as p,V as m,Yn as h,aa as g,ct as _,ft as v,ir as y,k as b,tn as x,ur as S,z as C}from"./player-overlays-fpbPSPqT.js";import{Bn as w,mc as T,zs as E}from"./client-Cng2SeYA.js";import{t as D}from"./chevron-down-CBb-F8DT.js";import{An as O,Cp as k,Dr as A,Fa as j,Gi as M,Ha as N,Hp as P,Ia as F,Ji as I,M as L,Ra as R,Sp as z,Tc as ee,Tr as B,Ui as V,Wi as H,Yi as U,Zs as te,_c as ne,bc as re,bs as ie,da as W,dc as ae,fc as oe,gi as G,hi as se,ic as ce,ka as le,mc as ue,mp as K,nc as de,oc as fe,pc as pe,qi as me,rc as he,vc as ge,wp as _e,ws as ve,xa as ye,xs as be,yc as xe,ys as Se,zr as q}from"./src-eL0OacoB.js";import{t as J}from"./i18n--GTAj4mB.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import{J as Ce,Si as we,wi as Te,yi as X}from"./index-DbXFHmBJ.js";import{t as Ee}from"./AdminSectionedPage-bGVBepbw.js";import{c as De,n as Oe,r as ke}from"./linked-devices-model-Bnz1douR.js";a();function Z(e){return{id:e.id,name:e.name,type:e.type,stableId:e.stableId??``,parentDeviceId:e.parentDeviceId,location:e.location,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.primaryChildEntityId!==void 0&&e.primaryChildEntityId!==null?{primaryChildEntityId:e.primaryChildEntityId}:{},...e.primaryChildPreference!==void 0&&e.primaryChildPreference!==null?{primaryChildPreference:e.primaryChildPreference}:{}}}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function Ae(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function je(e,t){let n=Ae(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function Me(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function Ne(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function Pe(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>Ne(e,n)).map(e=>e.id));return e.filter(e=>!(Ne(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function Fe(e,t){return Pe(e,t).filter(e=>e.parentDeviceId===null)}function Ie(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function Le(e,t){return Ie(e,t).length}function Re(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function ze(e,t){return t.map(t=>({name:t,members:je(e,t)}))}function $({type:e,role:t,className:r}){return n(P(e,t),{"aria-hidden":`true`,className:r??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Be({device:t}){let r=F(Z(t),`compact`);if(t.online)return n(`span`,{"aria-hidden":`true`,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`,"data-status":`online`});let i=J.t(`common.offline`);return e(`span`,{className:`flex items-center gap-1.5`,children:[n(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,"data-status":`offline`,role:`img`,"aria-label":J.t(`locations.deviceGlyphs.aria`,{name:r,state:i}),title:i}),n(`span`,{className:`text-xs text-foreground-muted`,children:i})]})}function Ve({open:t,title:a,items:o,listState:s,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=Y(),[h,g]=i([]);r(()=>{t||g([])},[t]);let _=new Map(o.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return n(V,{open:t,onOpenChange:e=>e?void 0:p(),children:e(M,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":a,children:[n(I,{children:n(U,{children:a})}),e(H,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[t&&u!==null&&v.length>0&&e(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[n(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),n(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>n(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),t&&n(L,{devices:o,listState:s,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),e(me,{children:[n(K,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),n(K,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}a();function He({room:e,cameras:r,fleet:i}){let{t:a}=Y(),o=t(()=>new Map(i.map(e=>[e.id,e])),[i]);return e===null?n(`p`,{className:`text-xs text-foreground-subtle`,children:a(`locations.links.noRoom`)}):n(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:r.length===0?n(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:a(`locations.links.noCameras`,{room:e})}):r.map(e=>n(We,{camera:e,byId:o},e.id))})}function Ue(e){return{id:e.deviceId,name:e.name,type:e.type,location:e.location}}function We({camera:t,byId:r}){let{t:a}=Y(),s=F(Z(t),`full`),l=o(),u=we(),[f,p]=i(!1),[m,h]=i(null),g=ie({deviceId:t.id}),_=ke({status:g.status,data:g.data,error:g.error===null||g.error===void 0?null:g.error}),v=be(),y=_.kind===`present`?_:null,x=Se({deviceId:t.id,slotRef:y?.slot.slotRef??``},{enabled:f&&y!==null}),S=y===null?[]:Oe(y.slot,y.value),C=S.map(e=>e.deviceId),w=(x.data?.candidates??[]).map(Ue),T=new Set(w.map(e=>e.id)),E=C.filter(e=>!T.has(e)).map(e=>{let t=r.get(e);return{id:e,name:t?.name??`#${String(e)}`,...t===void 0?{}:{type:t.type,location:t.location}}}),D=[...w,...E],O=(x.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),k=async e=>{if(y!==null){h(null);try{await v.mutateAsync({deviceId:t.id,slotRef:y.slot.slotRef,value:De(y.value,e)}),await g.refetch(),await l.invalidateQueries({queryKey:[[`deviceManager`]]}),p(!1)}catch(e){h(e instanceof Error?e.message:String(e))}}},A=[{key:`device`,header:a(`locations.columns.device`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId),o=t.name??i?.name??`#${String(t.deviceId)}`;return e(`span`,{className:`flex items-center gap-1.5`,children:[i!==void 0&&n($,{type:i.type,role:i.role}),n(X,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:i===void 0?o:n(W,{device:Z(i),form:`compact`})}),t.implied&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`locations.links.implied`)})]})}},{key:`type`,header:a(`locations.columns.type`),notSortableReason:a(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:r.get(e.deviceId)?.type??`—`})},{key:`status`,header:a(`locations.columns.status`),notSortableReason:a(`locations.columns.noSort`),render:e=>{let t=r.get(e.deviceId);return t===void 0?n(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):n(Be,{device:t})}}];return e(`section`,{className:`min-w-0 ${d}`,"data-testid":`camera-links-${String(t.id)}`,children:[e(`header`,{className:`${b} flex min-h-9 items-center gap-1.5`,children:[n($,{type:t.type,role:t.role}),n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:n(W,{device:Z(t),form:`full`})}),e(K,{variant:`ghost`,size:`sm`,onClick:()=>u(Ce(t.id)),children:[n(c,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`locations.links.edit`)]}),n(K,{variant:`outline`,size:`sm`,disabled:y===null,onClick:()=>p(!0),"aria-label":a(`locations.links.addNamed`,{camera:s}),children:a(`locations.room.add`)})]}),_.kind===`pending`&&n(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.loading`)}),_.kind===`unknown`&&n(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:a(`locations.links.unreadable`,{reason:_.reason})}),_.kind===`absent`&&n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.unsupported`)}),m!==null&&n(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:m}),y!==null&&(S.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.none`)}):n(q,{columns:A,rows:S,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),n(Ve,{open:f,title:a(`locations.links.pickTitle`,{camera:s}),items:D,listState:x.status===`error`?`failed`:x.data===void 0?`pending`:`answered`,lockedIds:C,lockedNote:a(`locations.links.alreadyLinked`),suggestions:t.location===null?null:{heading:a(`locations.links.suggested`,{room:t.location}),ids:O},busy:v.isPending,onConfirm:e=>void k(e),onClose:()=>p(!1)})]})}a();function Ge({name:t,description:a,busy:o,onSave:s}){let{t:c}=Y(),[l,u]=i(a??``);return r(()=>{u(a??``)},[a]),e(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[n(G,{htmlFor:`location-description-${t}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),n(se,{id:`location-description-${t}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(a??``)&&s(e.length===0?null:e)},disabled:o,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`p`,{className:`mt-1 ${C}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function Ke(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var qe=` none`;function Je({name:t,zones:r,zoneKey:i,busy:a,onChange:o}){let{t:s}=Y();if(r.length===0)return null;let c=[{value:qe,label:s(`locations.locationZoneField.none`,`— none —`)},...r.map(e=>({value:e.zoneKey,label:e.label}))];return e(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[n(G,{htmlFor:`location-zone-${t}`,children:s(`locations.locationZoneField.zone`,`Zone`)}),n(v,{id:`location-zone-${t}`,value:i??qe,disabled:a,onChange:e=>{let t=e.target.value;if(t===qe){o(null);return}let n=r.find(e=>e.zoneKey===t);n!==void 0&&o(n.label)},options:c})]})}function Ye(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Xe({name:e,icon:t,busy:r,onPick:i}){return n(_e,{value:t,onPick:i,fallbackGlyph:u,clearGlyph:l,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:r})}function Ze(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:T(n.icon)??`map-pin`}function Qe(e){return`${e.kind}:${String(e.device.id)}`}function $e(e,t,n){return e.flatMap(e=>{let r=Re(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}a();function et({name:r,members:a,devices:o,busy:c,icon:l,description:u,onRename:f,onDelete:m,onRebuildLinks:g,onAddDevices:_,onPickIcon:v,onSaveDescription:y,zones:C,zoneKey:w,onChangeZone:T}){let{t:E}=Y(),[D,j]=i(!1),[M,N]=i(r),P=B(a,t(()=>({searchText:e=>[e.name,...Re(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[F,I]=i(()=>new Set),L=e=>I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),R=t(()=>$e(P.rows,o,F),[P.rows,o,F]),ee=[{key:`name`,header:E(`locations.columns.device`),notSortableReason:E(`locations.columns.noSort`),render:e=>e.kind===`member`?n(tt,{row:e,onToggle:()=>L(e.device.id)}):n(nt,{row:e})},{key:`type`,header:E(`locations.columns.type`),notSortableReason:E(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:E(`locations.columns.status`),notSortableReason:E(`locations.columns.noSort`),render:e=>n(Be,{device:e.device})}],V=()=>{N(r),j(!1)},H=async()=>{let e=M.trim();if(e.length===0||e===r){V();return}await f(e),j(!1)},U=[{id:`rename`,label:E(`locations.locationCard.rename`,`Rename`),icon:S,disabled:c,onClick:()=>{N(r),j(!0)}},{id:`rebuild-links`,label:E(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:h,separatorBefore:!0,disabled:c,onClick:()=>void g()},{id:`delete`,label:E(`common.delete`,`Delete`),icon:x,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void m()}];return e(`section`,{className:`min-w-0 ${d}`,children:[e(`header`,{className:`${b} flex min-h-9 items-center gap-1.5`,children:[n(Xe,{name:r,icon:l,busy:c,onPick:v}),D?e(s,{children:[n(z,{value:M,onChange:e=>N(e.target.value),onKeyDown:e=>{e.key===`Enter`&&H(),e.key===`Escape`&&V()},"aria-label":E(`locations.locationCard.rename2`,`Rename {{name}}`,{name:r}),className:`min-w-0 flex-1`,autoFocus:!0}),n(K,{type:`button`,size:`sm`,onClick:()=>void H(),children:E(`common.save`,`Save`)}),n(k,{type:`button`,variant:`ghost`,icon:p,onClick:V,"aria-label":E(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):e(s,{children:[n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:r}),n(K,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:_,"aria-label":E(`locations.room.addTo`,{room:r}),children:E(`locations.room.add`)}),n(O,{items:U,title:E(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:r}),triggerClassName:`p-1`})]})]}),n(Je,{name:r,zones:C,zoneKey:w,busy:c,onChange:T}),n(Ge,{name:r,description:u,busy:c,onSave:y}),a.length>0&&n(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:n(A,{state:P.state,facets:P.facets,labels:{searchPlaceholder:E(`locations.filter.searchPlaceholder`),searchLabel:E(`locations.room.searchLabel`,{room:r}),facetsLabel:E(`locations.filter.typesLabel`),clearLabel:E(`locations.filter.clear`)},onSearch:P.setSearch,onToggleFacet:P.toggleFacet,onClear:P.clear})}),a.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:E(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):n(q,{columns:ee,rows:R,rowKey:Qe,bordered:!1,minWidthPx:360,emptyMessage:E(`locations.filter.noMatch`)})]})}function tt({row:t,onToggle:r}){let{t:i}=Y(),{device:a,accessories:o,open:s}=t,c=F(Z(a),`compact`),l=s?D:g;return e(`span`,{className:`flex items-center gap-1.5`,children:[o.length>0?e(K,{type:`button`,variant:`ghost`,onClick:r,"aria-expanded":s,"aria-label":i(s?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:o.length,name:c}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[n(l,{className:`h-3 w-3`}),n(`span`,{className:`text-[10px] tabular-nums`,children:o.length})]}):n(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),n($,{type:a.type,role:a.role}),n(X,{to:`/devices/${String(a.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(a),form:`compact`})})]})}function nt({row:t}){let{device:r,parent:i}=t;return e(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[n(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),n($,{type:r.type,role:r.role,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),n(X,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:n(W,{device:Z(r),form:`nested`,parent:Z(i)})})]})}a();function rt({zones:e,busy:t,onRename:r,onDelete:a,onPickIcon:o}){let{t:s}=Y(),[c,l]=i(null),[u,d]=i(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await r(e,t)};return n(q,{columns:[{key:`icon`,header:s(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>n(Xe,{name:e.label,icon:e.icon,busy:t,onPick:t=>o(e.label,t)})},{key:`name`,header:s(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?n(z,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":s(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):n(K,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:s(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:s(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>n(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?s(`common.empty`):s(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:s(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>n(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void a(e.label),disabled:t,"aria-label":s(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:s(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:n(x,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:s(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Night zone” for the bedrooms — and shows up before them in the app’s camera filter.`)})}a();function it({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(z,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":a(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(y,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:n(p,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-location-button`,children:[n(y,{className:`h-3.5 w-3.5`}),a(`locations.newLocationButton.newLocation`,`New location`)]})}a();function at({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(z,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":a(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(y,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:n(p,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-zone-button`,children:[n(y,{className:`h-3.5 w-3.5`}),a(`locations.newZoneButton.newZone`,`New zone`)]})}a();function ot(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function st({rooms:e,unassignedCount:r,value:i,unassignedValue:a,onChange:o}){let{t:s}=Y(),c=t(()=>ot(e,r,a,s(`locations.roomPicker.unassigned`)),[e,r,a,s]);return n(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:n(ye,{mode:`single`,singleDisplay:`field`,label:s(`locations.roomPicker.label`),placeholder:s(`locations.roomPicker.placeholder`),options:c,value:i,onChange:o,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}a();var ct={searchText:e=>[e.name],facetValue:e=>e.type};function lt({rows:r,fleet:a,locations:o,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Y(),d=N(),p=R(),h=e=>d===null?e.name:j(Z(e),`compact`,d,p),[g,_]=i([]),[y,b]=i(``),x=B(r,ct),S=x.rows,w=t(()=>S.map(e=>e.id),[S]),T=t(()=>g.filter(e=>w.includes(e)),[g,w]),E=S.length>0&&T.length===S.length,D=t(()=>{let e=new Map;for(let t of r)e.set(t.id,Le(a,t.id));return e},[r,a]),O=T.reduce((e,t)=>e+(D.get(t)??0),0),k=e=>_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),M=()=>_(E?[]:w),P=()=>{y.length===0||T.length===0||(l(T,y),_([]),b(``))},F=o.map(e=>({value:e,label:e})),I=[{key:`select`,width:`w-8`,headerRender:()=>n(f,{checked:E,onChange:M,"aria-label":E?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>n(f,{checked:T.includes(e.id),onChange:()=>k(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:h(e)})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:t=>{let r=Me(t,o);return e(`span`,{className:`flex items-center gap-1.5`,children:[n($,{type:t.type,role:t.role}),n(X,{to:`/devices/${String(t.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(t),form:`compact`})}),r!==null&&n(le,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:r})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:e=>n(Be,{device:e})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>D.get(e.id)??0,render:e=>n(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:D.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>n(v,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:h(e)}),value:``,disabled:s||o.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...F]})}];return e(`section`,{className:`space-y-2`,children:[e(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[n(`h2`,{className:m,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),n(`p`,{className:C,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),r.length>0&&n(A,{state:x.state,facets:x.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:x.setSearch,onToggleFacet:x.toggleFacet,onClear:x.clear}),T.length>0&&e(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[e(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:T.length}),O>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:O})}`]}),n(v,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:y,onChange:e=>b(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...F]}),n(K,{type:`button`,size:`sm`,onClick:P,disabled:s||y.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),n(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>_([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),n(q,{columns:I,rows:S,rowKey:e=>e.id,minWidthPx:720,emptyMessage:x.active?u(`locations.filter.noMatch`):c})]})}function ut(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.primaryChildPreference===void 0?{}:{primaryChildPreference:e.primaryChildPreference},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function dt(e,t){let n=t.map(ut),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:w({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var ft=`device-manager:linked-devices`;function pt(e){return{deviceId:e.deviceId,slotRef:ft,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}a();var mt=`__unassigned__`;function ht(){let{t:r}=Y(),a=o(),s=_(),{data:c,isLoading:l}=ce(),{data:d}=he(),{data:f}=de(),{data:p}=fe(),{data:m,isLoading:h}=te({projection:`slim`}),g=()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},v=ve({onSuccess:g}),y=ae({onSuccess:g}),b=ne({onSuccess:g}),x=pe({onSuccess:g}),S=xe({onSuccess:g}),C=ge({onSuccess:g}),w=ee({onSuccess:g}),T=oe({onSuccess:g}),D=ue({onSuccess:g}),O=re({onSuccess:g}),k=be(),A=t(()=>(m??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null,primaryChildPreference:e.primaryChildPreference??null})),[m]),j=c??[],M=t(()=>ze(A,j),[A,j]),[N,P]=Te(),F=N.get(`tab`),I=F===`zones`||F===`camera-links`?F:`locations`,L=N.get(`room`),R=t(()=>Fe(A,j),[A,j]),z=L===mt,B=z?null:L!==null&&M.some(e=>e.name===L)?L:M[0]?.name??null,V=B===null?null:M.find(e=>e.name===B)??null,H=z?mt:B??`__unassigned__`,U=B??M[0]?.name??null,ie=t(()=>M.map(e=>({name:e.name,count:e.members.length})),[M]),W=e=>{P(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},G=l||h,se=b.isPending||y.isPending||v.isPending||S.isPending,le=async e=>{await v.mutateAsync({name:e})},K=async(e,t)=>{let n=t.trim();n.length===0||n===e||await x.mutateAsync({from:e,to:n})},me=async e=>{let t=dt(e,A);if(t.entries.length===0){await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:e}),confirmLabel:`OK`});return}let n=t.entries.map(e=>r(`locations.rebuildEntry`,{name:e.name,count:e.ids.length})).join(`
|
|
2
|
+
`);if(!await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:e,lines:n}),confirmLabel:r(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of t.entries)try{await k.mutateAsync(pt(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}g(),i.length>0&&await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
|
|
3
|
+
`)}),confirmLabel:`OK`})},_e=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;await s({title:r(`locations.deleteLocation`,`Delete location`),message:r(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:e,extra:n}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await y.mutateAsync({name:e,cascade:!0})},ye=async e=>{await s({title:r(`locations.deleteZone`,`Delete zone`),message:r(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:e}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await T.mutateAsync({name:e})},Se=async(e,t)=>{await S.mutateAsync({location:e,icon:t})},q=async(e,t)=>{await C.mutateAsync({location:e,description:t})},J=p??[],Ce=async(e,t)=>{await O.mutateAsync({location:e,zone:t})},we=(e,t)=>{for(let n of e)b.mutate({deviceId:n,location:t})},[X,De]=i(null),Oe=t(()=>A.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[A]),ke=n(st,{rooms:ie,...I===`locations`?{unassignedCount:R.length}:{},value:I===`locations`?H:U??``,unassignedValue:mt,onChange:W}),Z=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[G&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),ke,z||V===null?n(lt,{rows:R,fleet:A,locations:j,busy:se,emptyMessage:G?r(`common.loading`,`Loading…`):r(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:we}):n(et,{name:V.name,members:V.members,devices:A,busy:se,icon:Ze(d,E(V.name)),onPickIcon:e=>Se(V.name,e),description:Ke(f,E(V.name)),onSaveDescription:e=>q(V.name,e),zones:J,zoneKey:Ye(J,E(V.name)),onChangeZone:e=>Ce(V.name,e),onRename:e=>K(V.name,e),onDelete:()=>_e(V.name,Ae(A,V.name).length),onRebuildLinks:()=>me(V.name),onAddDevices:()=>De(V.name)},V.name),j.length===0&&!G&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.noLocationsYetAddFrontDoor`,`No locations yet. Add Front door, Hall, Kitchen…`)}),n(Ve,{open:X!==null,title:r(`locations.room.addDialogTitle`,{room:X??``}),items:Oe,listState:h?`pending`:`answered`,lockedIds:X===null?[]:(M.find(e=>e.name===X)?.members??[]).map(e=>e.id),lockedNote:r(`locations.room.alreadyHere`),suggestions:{heading:r(`locations.room.suggestedUnassigned`),ids:R.map(e=>e.id)},busy:b.isPending,onConfirm:e=>{X!==null&&we(e,X),De(null)},onClose:()=>De(null)})]}),Q=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[ke,n(He,{room:U,cameras:U===null?[]:Ae(A,U).filter(e=>e.isCamera),fleet:A})]});return n(Ee,{icon:u,title:r(`locations.locations`,`Locations`),subtitle:r(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:I===`zones`?n(at,{busy:w.isPending,onCreate:e=>w.mutateAsync({name:e})}):n(it,{busy:v.isPending,onCreate:le}),sections:[{id:`locations`,label:r(`locations.locations`,`Locations`),content:Z},{id:`camera-links`,label:r(`locations.cameraLinks`,`Camera links`),content:Q},{id:`zones`,label:r(`locations.zones`,`Zones`),content:n(rt,{zones:J,busy:se,onRename:(e,t)=>D.mutateAsync({from:e,to:t}),onDelete:ye,onPickIcon:(e,t)=>w.mutateAsync({name:e,icon:t})})}]})}export{ht as LocationsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Qa as s,Vn as c,Za as l,_i as u,fa as d,ft as f,mn as p,sa as m,zr as h}from"./player-overlays-fpbPSPqT.js";import{Ec as g,Xs as _}from"./client-Cng2SeYA.js";import{t as v}from"./layers-BH9u1mrE.js";import{t as y}from"./timer-reset-5221y6Jb.js";import{Af as b,Df as x,Ir as S,Nf as C,Qi as w,Sp as T,Zi as E,mp as D,mr as O,qp as k,wa as A}from"./src-eL0OacoB.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{a as M,b as N,i as P,wi as F}from"./index-DbXFHmBJ.js";import{t as I}from"./AdminSectionedPage-bGVBepbw.js";import{t as L}from"./InstancesTable-LVQWfz07.js";import{t as R}from"./AdminPage-BkxgjFWW.js";o();var z=[12e4,3e5,6e5,18e5],B={"request-census":`Counts every tRPC call by TRANSPORT PLANE — http, ws, mesh — and by procedure, caller, address and user-agent. Subscriptions are counted apart from calls, so a long-lived stream cannot pass for a storm. Arm it, then restart: the deadline is persisted, so the window is still running when clients reconnect.`};function V(){let{t}=j(),n=b({},{refetchInterval:5e3}),i=C(),[o,s]=a(null),c=(e,t)=>{s(e),i.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{s(null),n.refetch()}})},u=n.data?.activeWindows??[],d=(n.data?.channels??[]).filter(e=>e.kind!==`debug`),f=n.data?.activeChannels??[],p=(e,t,r)=>{s(e),i.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:r}]}},{onSettled:()=>{s(null),n.refetch()}})};return e(R,{embedded:!0,icon:l,title:t(`logging.diagnostics.title`,`Diagnostics`),subtitle:t(`logging.diagnostics.subtitle`,`Diagnostics are armed for a window, never switched on. Each carries a deadline and expires by itself — one left running is an incident of its own.`),children:[n.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(h,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}):r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:u.map(e=>r(U,{window:e,busy:o===e.id,onArm:t=>c(e.id,t)},e.id))}),r(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:t(`logging.diagnostics.channels`,`Component channels`)}),r(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.channelsSubtitle`,`Declared by the addons that own them — this list is not maintained by hand. Arming a channel opens a window with a deadline; it closes by itself.`)}),d.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>r(H,{channel:e,state:f.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>p(e.name,t,n)},e.name))})]})}function H({channel:t,state:n,busy:i,onArm:o}){let{t:s}=j(),[c,l]=a(``),u=n?.armed===!0,f=()=>{let e=c.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),u?e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),s(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:W(n?.remainingMs??0)})]}):r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.disarmed`,`disarmed`)}),u&&n?.deviceIds!==null&&n?.deviceIds!==void 0&&e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[r(d,{className:`h-3 w-3`}),n.deviceIds.join(`, `)]}),!t.perDevice&&r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),r(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:t.description})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[t.perDevice&&r(T,{type:`text`,inputMode:`numeric`,value:c,disabled:i,onChange:e=>l(e.target.value),placeholder:s(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),z.map(e=>r(D,{variant:`unstyled`,type:`button`,disabled:i,onClick:()=>o(e,f()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:W(e)},e)),r(D,{variant:`unstyled`,type:`button`,disabled:i||!u,onClick:()=>o(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:s(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function U({window:t,busy:n,onArm:i}){let{t:a}=j();return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.id}),t.armed?e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:W(t.remainingMs)})]}):r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),t.armed&&!t.persisted&&r(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),r(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:B[t.id]??``})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[z.map(e=>r(D,{variant:`unstyled`,type:`button`,disabled:n,onClick:()=>i(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:W(e)},e)),r(D,{variant:`unstyled`,type:`button`,disabled:n||!t.armed,onClick:()=>i(0),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:a(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function W(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}function G(){let{t:e}=j();return r(L,{functionCap:`log-destination`,icon:c,title:e(`system.logging.destinations`,`Destinations`),subtitle:e(`system.logging.everyRegisteredLogDestinationEntries`,`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another.`),emptyTitle:e(`system.logging.noLogDestinationsRegistered`,`No log destinations registered`),emptyDescription:e(`system.logging.thisShouldNotHappenThe`,`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`),defaultKindLabel:e(`system.logging.kindDestination`,`Log destination`),addLabel:e(`system.logging.addDestination`,`Add destination`),install:{capability:`log-destination`,label:e(`system.logging.installDestination`,`Install a destination`)}})}o();var K=[`debug`,`info`,`warn`,`error`],q=``,J=``;function Y(){let{t:n}=j(),[i,o]=a(q),[s,c]=a(J),{nodes:l}=k(),u=t(()=>l.map(e=>({id:e.id,label:e.name||e.id})),[l]),d=b({...i===q?{}:{scopeNodeId:i},...s===J?{}:{scopeComponent:s}},{refetchInterval:15e3}),p=C(),m=d.data,g=p.isPending||d.isFetching,_=(m?.channels??[]).filter(e=>e.kind!==`debug`),y=(e,t)=>{p.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void d.refetch()})};return r(R,{embedded:!0,icon:v,title:n(`logging.levels.title`,`Levels`),subtitle:n(`logging.levels.subtitle`,`Cluster → node, most specific wins. The floor gates what reaches the log destinations; the in-memory viewer keeps every line either way.`),actions:e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(`logging.levels.scope`,`Scope`),e(f,{wrapperClassName:`inline-block w-auto`,value:i,disabled:s!==J,onChange:e=>o(e.target.value),children:[r(`option`,{value:q,children:n(`logging.levels.cluster`,`Cluster`)}),u.map(e=>r(`option`,{value:e.id,children:e.label},e.id))]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(`logging.levels.component`,`Component`),e(f,{wrapperClassName:`inline-block w-auto`,value:s,onChange:e=>c(e.target.value),children:[r(`option`,{value:J,children:n(`logging.levels.noComponent`,`None`)}),_.map(e=>r(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:d.isLoading||m===void 0?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(h,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):e(`div`,{className:`space-y-3`,children:[r(Z,{level:m.effective.level,source:m.effective.levelSource,persisted:m.persisted}),r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:m.explicit.layers.map(e=>r(Q,{layer:e,inForce:e.scope===m.effective.levelSource,busy:g,onSet:t=>y(e,t),onClear:()=>y(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),s!==J&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:_.find(e=>e.name===s)?.description??``}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`logging.levels.componentNote`,`A component is a log channel an addon declared. Its level is cluster-wide and beats both the node and the cluster layer.`)}),r(X,{days:m.opsLogRetentionDays,busy:g,onSet:e=>p.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void d.refetch()})})]})})}function X({days:t,busy:n,onSet:i}){let{t:a}=j();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[e(`label`,{className:`flex items-center justify-between gap-3`,children:[r(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),e(`span`,{className:`flex items-center gap-1.5`,children:[r(T,{type:`number`,min:0,max:3650,step:1,defaultValue:t,disabled:n,onBlur:e=>{let n=Number.parseInt(e.target.value,10);Number.isFinite(n)&&n!==t&&i(n)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`logging.levels.opsLogRetentionNote`,`How long the record of what retention deleted is kept. Cluster-wide, and deliberately longer than any camera window — it is the history of the sweep, not of the camera, and it is what makes a storage leak explainable after the fact. 0 keeps it forever.`)})]})}function Z({level:t,source:n,persisted:i}){let{t:a}=j();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),r(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:t}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:n==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:n})})]}),!i&&r(`p`,{className:`mt-1 text-[11px] text-warning`,children:a(`logging.levels.notPersisted`,`The settings store could not be read or written — what you see is live, but it would not survive a restart.`)})]})}function Q({layer:t,inForce:n,busy:i,onSet:a,onClear:o}){let{t:s}=j();return e(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.scope===`cluster`?s(`logging.levels.cluster`,`Cluster`):t.scope===`component`?t.component??``:t.nodeId??``}),n&&e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[r(m,{className:`h-3 w-3`}),s(`logging.levels.inForce`,`in force`)]})]}),r(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:t.level===null?s(`logging.levels.inherits`,`inherits — nothing set at this layer`):s(`logging.levels.setHere`,`set here: {{level}}`,{level:t.level})})]}),e(`div`,{className:`flex shrink-0 items-center gap-1`,children:[K.map(e=>r(D,{variant:`unstyled`,type:`button`,disabled:i,onClick:()=>a(e),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${t.level===e?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:e},e)),r(D,{variant:`unstyled`,type:`button`,disabled:i||t.level===null,onClick:o,className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-40`,children:s(`logging.levels.clear`,`Clear`)})]})]})}function $(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function ee(e,t){return{windowMs:Math.max(0,e.untilMs-t),capMs:Math.max(0,e.capAtMs-t)}}function te(e,t){let n=new Set(e.map(e=>e.channel));return t.filter(e=>n.has(e))}o();var ne=[_.Camera],re=8,ie=1e3,ae=15e3;function oe(){let{t:o}=j(),c=b({},{refetchInterval:15e3}),l=x(),[d,f]=a([]),[m,_]=a([]),[v,C]=a([]),[T,k]=a(()=>Date.now()),[M,N]=a([]),P=t(()=>(c.data?.channels??[]).filter(e=>e.kind===`debug`),[c.data]),F=n((e,t,n)=>{l.mutate({action:e,channels:t,deviceIds:n},{onSuccess:e=>{f(e.watches),N(e.lapsed)}})},[]);i(()=>{let e=setInterval(()=>k(Date.now()),ie);return()=>clearInterval(e)},[]),i(()=>{F(`list`,[],[]);let e=setInterval(()=>F(`list`,[],[]),ae);return()=>clearInterval(e)},[F]);let I=te(d,m).join(`|`);i(()=>{if(I===``)return;let e=setInterval(()=>F(`rearm`,I.split(`|`),[]),g);return()=>clearInterval(e)},[I,F]);let L=m.length>0&&v.length>0&&!l.isPending,z=[...new Set(d.flatMap(e=>e.deviceIds))],B=(e,t)=>_(n=>t?[...n,e]:n.filter(t=>t!==e));return e(R,{embedded:!0,icon:u,title:o(`logging.watch.title`,`Watch`),subtitle:o(`logging.watch.subtitle`,`Switch a debug channel on for chosen devices and read it live. A watch lasts 10 minutes, is renewed while this page stays open, and ends by itself after 60 minutes at most.`),children:[r(S,{headingId:`log-watch-setup`,title:o(`logging.watch.setup`,`Channels and devices`),children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(h,{className:`h-3.5 w-3.5 animate-spin`}),o(`common.loading`,`Loading…`)]}):P.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`logging.watch.noChannels`,`No addon on this cluster offers a debug channel, or none could be reached right now.`)}):e(`div`,{className:`space-y-3 p-3`,children:[r(`div`,{className:`space-y-2`,children:P.map(t=>e(`label`,{className:`flex items-start gap-2`,children:[r(s,{checked:m.includes(t.name),onChange:e=>B(t.name,e.target.checked)}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:t.description})]})]},t.name))}),e(`div`,{className:`flex flex-col gap-1`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:o(`logging.watch.devices`,`Devices`)}),r(A,{multiple:!0,pick:`device`,noun:`camera`,fixedTypes:ne,maxItems:re,recentKey:`log-watch-devices`,testId:`log-watch-devices`,value:w(v),onChange:e=>C(E(e))})]}),e(`div`,{className:`flex flex-wrap gap-2`,children:[r(D,{type:`button`,disabled:!L,onClick:()=>F(`start`,m,v),children:o(`logging.watch.start`,`Start watching`)}),e(D,{type:`button`,variant:`secondary`,disabled:d.length===0||l.isPending,onClick:()=>F(`stop`,d.map(e=>e.channel),[]),children:[r(p,{className:`mr-1 h-3.5 w-3.5`}),o(`logging.watch.stop`,`Stop`)]})]}),l.isError&&r(`p`,{className:`text-[11px] text-destructive`,children:l.error.message}),M.length>0&&r(`p`,{className:`text-[11px] text-warning`,children:o(`logging.watch.lapsed`,`Already ended, not renewed: {{names}}. Start again to continue.`,{names:M.join(`, `)})})]})}),d.length>0&&e(S,{headingId:`log-watch-live`,title:o(`logging.watch.live`,`Live`),children:[r(`div`,{className:`divide-y divide-border`,children:d.map(t=>{let n=ee(t,T);return e(`div`,{className:`flex flex-wrap items-center gap-2 p-3`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.channel}),e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),o(`logging.watch.endsIn`,`ends in {{left}}`,{left:$(n.windowMs)})]}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:o(`logging.watch.capIn`,`hard stop in {{left}}`,{left:$(n.capMs)})}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[`#`,t.deviceIds.join(`, #`)]})]},t.channel)})}),z.map(e=>r(`div`,{className:`border-t border-border`,children:r(O,{deviceId:e,limit:200,maxHeight:`max-h-80`,showScope:!0,showFilters:!1})},e))]})]})}function se(){let[e]=F(),t=e.get(`deviceId`),n=t===null?void 0:Number(t);return r(R,{embedded:!0,children:r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:r(O,{deviceId:n!==void 0&&Number.isFinite(n)?n:void 0,limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showFilters:!0,showOriginFilter:!0,columns:{available:[`integration`,`device`],defaultVisible:[`integration`,`device`]}})})})}function ce(){let{t:e}=j(),t=N(`/system/logs`,{t:e,isAdmin:!0})??{icon:c,title:e(`system.logs`,`Logs`)};return r(I,{icon:t.icon,title:t.title,defaultSection:`viewer`,sectionsLabel:`${t.title} sections`,sections:[{id:`viewer`,label:e(`admin.system.logs.viewer`,`Viewer`),content:r(se,{})},{id:M.logging.tab,label:e(`admin.system.logs.destinations`,`Destinations`),content:r(G,{}),ownedParams:P},{id:`levels`,label:e(`admin.system.logs.levels`,`Levels`),content:r(Y,{})},{id:`watch`,label:e(`admin.system.logs.watch`,`Watch`),content:r(oe,{})},{id:`diagnostics`,label:e(`admin.system.logs.diagnostics`,`Diagnostics`),content:r(V,{})}]})}export{ce as LogsPage};
|