@camstack/addon-admin-ui 1.2.106 → 1.2.107
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/dist/assets/{AddLocationWizard-DPvpYCGn.js → AddLocationWizard-jaDSCfMe.js} +1 -1
- package/dist/assets/{AddonCollectionPage-DLJXV_3S.js → AddonCollectionPage-BbzrPJ6L.js} +1 -1
- package/dist/assets/{Addons-COnaHviu.js → Addons-CKENyA_0.js} +1 -1
- package/dist/assets/{AdminTabs-ugTfV6vR.js → AdminTabs-DwlG6MYX.js} +1 -1
- package/dist/assets/{AiProfiles-B3OoMGwy.js → AiProfiles-DJZuqxl2.js} +1 -1
- package/dist/assets/{BrokerForm-FW8CGvEw.js → BrokerForm-Ca2dFeu6.js} +1 -1
- package/dist/assets/{Build-CKSSyLHR.js → Build-FaaOQcq6.js} +1 -1
- package/dist/assets/{Capabilities-Bvk135Hx.js → Capabilities-hGCD-XsN.js} +1 -1
- package/dist/assets/{CapabilityBadges-2_RTtE8F.js → CapabilityBadges-B3L7BgCj.js} +1 -1
- package/dist/assets/Cluster-Ehdgj3Kp.js +11 -0
- package/dist/assets/{Data-DUfQYWdR.js → Data-BbpQ2wej.js} +1 -1
- package/dist/assets/{DetectionIntelligence-_SicEHJ7.js → DetectionIntelligence-DjHh8ghB.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-B-LbbxBn.js → DeviceAggregateSection-nls0vMuB.js} +1 -1
- package/dist/assets/{DeviceDetail-QGu4Zppg.js → DeviceDetail-B1kgvRQ1.js} +2 -2
- package/dist/assets/{Devices-DyOwMmsB.js → Devices-Ufx_psHi.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DLylekcq.js → EmbedPlayerPage-CBglbG4n.js} +1 -1
- package/dist/assets/{Events-Bd7_dT0H.js → Events-DsUrafgO.js} +1 -1
- package/dist/assets/{FormBuilder-DaTNPCtr.js → FormBuilder-CR7w8Uea.js} +1 -1
- package/dist/assets/{Identity-qjHZBREK.js → Identity-D6agnFJl.js} +1 -1
- package/dist/assets/{IntegrationDetail-DaIdJdyp.js → IntegrationDetail-tAyrEEB3.js} +1 -1
- package/dist/assets/{Integrations-BXkqNtA2.js → Integrations-BgScP7uj.js} +1 -1
- package/dist/assets/{Integrations-B3wdYU9G.js → Integrations-BgmTtkes.js} +1 -1
- package/dist/assets/{Logs-B9aMiGDX.js → Logs-SRHHss4v.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BAld-2Lw.js → MotionZonesSettings-Bqo0j30T.js} +1 -1
- package/dist/assets/{MyAccess-DYc5Ia6R.js → MyAccess-C-LZNy3P.js} +1 -1
- package/dist/assets/{Network-DtCqr7_n.js → Network-BMsGa7tx.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DCrm5WAe.js → NodeAddonsSettingsPanel-ClAYpMMi.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-DruKQsKv.js → NodeInferenceDevices-Bb4I_qvo.js} +1 -1
- package/dist/assets/{Notifications-DN4WDeO2.js → Notifications-CfqQNKJd.js} +1 -1
- package/dist/assets/{Pipeline-BQaaY2RF.js → Pipeline-OVcA977t.js} +1 -1
- package/dist/assets/{Plates-DzAZ1RGB.js → Plates-xKbZNVW4.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-t81B_gek.js → PrivacyMaskSettings-BY7zHdqw.js} +1 -1
- package/dist/assets/{ProviderIcon-1IBp_VK5.js → ProviderIcon-De4kTHTR.js} +1 -1
- package/dist/assets/{Recordings-C6gSAs30.js → Recordings-BKbyRqgK.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DId274fd.js → ScanNetworkModal-CtBvv4WV.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-B57j4d9e.js → SceneMonitorEditor-BXXt-4IO.js} +1 -1
- package/dist/assets/{Scenes-BJcEln5I.js → Scenes-teIGTKPS.js} +1 -1
- package/dist/assets/{Settings-DxbbgMBy.js → Settings-Dbzxh4Xn.js} +1 -1
- package/dist/assets/{Showroom-CGYvWhTb.js → Showroom-DxVo1-bk.js} +1 -1
- package/dist/assets/{Terminal-Db32GfJu.js → Terminal-DDef9uu4.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-x2EKNp38.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BE1fFa1_.js} +1 -1
- package/dist/assets/{bell-ring-fa6SzUi_.js → bell-ring-BwQgH1Jx.js} +1 -1
- package/dist/assets/{boxes-CfnJWdJa.js → boxes-B9qN8khW.js} +1 -1
- package/dist/assets/{build-cluster-graph-BlQoSudm.js → build-cluster-graph-BIxaMDak.js} +1 -1
- package/dist/assets/circle-check-big-CKXV1ppj.js +1 -0
- package/dist/assets/{circle-x-B470_M0K.js → circle-x-C7gUt7YG.js} +1 -1
- package/dist/assets/clock-Buox0pfk.js +1 -0
- package/dist/assets/{copy-Bz5_L_j0.js → copy-CxSGouEq.js} +1 -1
- package/dist/assets/{debounced-invalidate-BgLJ3Lz0.js → debounced-invalidate-Dsi2OJPO.js} +1 -1
- package/dist/assets/dist--DLsnle2.js +349 -0
- package/dist/assets/{dist-BiaTzHe6.js → dist-DP1UHvfy.js} +1 -1
- package/dist/assets/{download-CPPi4lEs.js → download-DZpOPJOl.js} +1 -1
- package/dist/assets/{face-bbox-Bk5OxbZ9.js → face-bbox-DZIslbfV.js} +1 -1
- package/dist/assets/{hostInit-CfHVCMU0.js → hostInit-t_jJvnIC.js} +1 -1
- package/dist/assets/index-2B_jjVhf.css +2 -0
- package/dist/assets/{index-DmGVQVip.js → index-BAEd1ERX.js} +3 -3
- package/dist/assets/{key-round-GUiZ3GBz.js → key-round-CUi3bTtL.js} +1 -1
- package/dist/assets/{layers-BHA4WXNG.js → layers-DBerP-8a.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-72686030.js → mf-entry-bootstrap-0-e5e0a6ce.js} +2 -2
- package/dist/assets/{pencil-CywoEYDw.js → pencil-Cu_AwkkH.js} +1 -1
- package/dist/assets/play-DY-uAc_T.js +1 -0
- package/dist/assets/{player-overlays-C1Oe-16j.js → player-overlays-BxZ5yvH8.js} +1 -1
- package/dist/assets/plus-CV5p_tnx.js +1 -0
- package/dist/assets/power-mTip9q3n.js +1 -0
- package/dist/assets/{radio-lEGHQd-3.js → radio-C3IEQP6m.js} +1 -1
- package/dist/assets/{refresh-cw-BEHJsw3X.js → refresh-cw-BkBjU-Za.js} +1 -1
- package/dist/assets/remoteEntry-M-lPOfwY.js +1 -0
- package/dist/assets/rotate-ccw-DhLsAlK8.js +1 -0
- package/dist/assets/rotate-cw-BwJCwVQH.js +1 -0
- package/dist/assets/{send-CdTPIK-7.js → send-Bu5E9gDd.js} +1 -1
- package/dist/assets/{server-CKXUNcfQ.js → server-CPAJbQJp.js} +1 -1
- package/dist/assets/{shield-DuQG63BO.js → shield-CKyB-C1m.js} +1 -1
- package/dist/assets/square-B3B-lXbz.js +1 -0
- package/dist/assets/{square-check-big-xoQlO2z6.js → square-check-big-CD8B3dsJ.js} +1 -1
- package/dist/assets/src-Ch7OV9gF.js +67 -0
- package/dist/assets/src-MgTxcsw3.js +349 -0
- package/dist/assets/{star-Dij84nD8.js → star-CIhdVMAM.js} +1 -1
- package/dist/assets/{undo-2-DtQ5QK61.js → undo-2-TS368FbX.js} +1 -1
- package/dist/assets/{upload-Bh__Gcoi.js → upload-bq3aTcwf.js} +1 -1
- package/dist/assets/{use-scenes-feed-BAtj9fjN.js → use-scenes-feed-D7fSSLcM.js} +1 -1
- package/dist/assets/useEventInvalidation-CZP-g5gD.js +1 -0
- package/dist/assets/{video-_cSQX0pK.js → video-B2S1p78W.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CCi4D5V9.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-FrPFHt9i.js} +2 -2
- package/dist/assets/{wifi-DFad8LAE.js → wifi-C4xxyMOA.js} +1 -1
- package/dist/assets/{zap-BEaKr1nX.js → zap-BYuFHnmk.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +256 -26
- package/package.json +1 -1
- package/dist/assets/Cluster-BIIxDRXP.js +0 -1
- package/dist/assets/circle-check-big-C_6LzyMr.js +0 -1
- package/dist/assets/clock-44ycL5OK.js +0 -1
- package/dist/assets/dist-CxVTxcO_.js +0 -349
- package/dist/assets/index-BlRpxCYM.css +0 -2
- package/dist/assets/play-Dfmddr6T.js +0 -1
- package/dist/assets/plus-BpSOCY8P.js +0 -1
- package/dist/assets/power-CNppeI6O.js +0 -1
- package/dist/assets/remoteEntry-CpjMZXjT.js +0 -1
- package/dist/assets/rotate-ccw-ZN_nOrZf.js +0 -1
- package/dist/assets/rotate-cw-CDaIhQNY.js +0 -1
- package/dist/assets/square-BpVTHFXt.js +0 -1
- package/dist/assets/src-DLoxi-uA.js +0 -349
- package/dist/assets/src-DjZVUvrt.js +0 -67
- package/dist/assets/useEventInvalidation-Deon74Uu.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,o,q as s,x as c,z as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as u}from"./player-overlays-C1Oe-16j.js";import{At as d,Dt as f,Ft as p,Lt as m,Ot as h,Pt as g,Rs as _,Rt as v,Tt as y,Vr as b,ai as x,ci as S,di as C,fi as w,ii as T,jt as E,kt as D,li as O,mi as k,ni as A,oi as j,pi as ee,ri as M,si as te,ui as N,un as P}from"./src-DjZVUvrt.js";import{Rt as F}from"./src-DLoxi-uA.js";import{a as I,i as L,n as R,o as z,r as B,t as V}from"./face-bbox-Bk5OxbZ9.js";import{a as ne,c as H,f as U,i as re,l as ie,m as W,n as G,o as ae,p as oe,r as se,s as ce,t as le,u as ue}from"./debounced-invalidate-BgLJ3Lz0.js";import{t as de}from"./pencil-CywoEYDw.js";import{t as K}from"./plus-BpSOCY8P.js";import{t as q}from"./refresh-cw-BEHJsw3X.js";import{t as fe}from"./rotate-cw-CDaIhQNY.js";import{t as pe}from"./square-check-big-xoQlO2z6.js";import{t as me}from"./square-BpVTHFXt.js";import{t as J}from"./undo-2-DtQ5QK61.js";import{B as Y,L as he,g as ge,i as X,l as _e,o as ve,q as ye,s as be,w as Z,z as xe}from"./index-DmGVQVip.js";import{t as Se}from"./AdminPage-CCD07UMs.js";import{r as Ce,t as we}from"./authed-media-BPd_L9jr.js";var Te=ye(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Ee=ye(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);n();var De=`pipeline-analytics`,Oe=`photo.analyze`,ke=`photo.enroll`,Ae=`photo.discard`,je=18*1024*1024;function Me(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 Ne(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Pe(e){if(!Me(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 Fe(e){if(!Me(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 Ie(e){if(!Me(e))return null;let t=$(e,`faceIndex`),n=$(e,`score`),r=Ne(e,`enrollable`),i=Pe(e.bbox),a=Fe(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 Le(e){if(!Me(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=Ie(e);t!==null&&i.push(t)}return{sessionId:t,ranOnNodeId:n,faces:i}}function Re(e){if(!Me(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 ze(e,t,n){let r={...e};return n===null||n===``?delete r[t]:r[t]=n,r}function Be(e,t){return e.filter(e=>e.enrollable&&t[e.faceIndex]!==void 0).length}function Ve(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 He(e){switch(e){case`no-embedding`:return`Too small or too indistinct for the recognizer to measure — try a photo where this face is larger.`;case`no-model-id`:return`The recognizer did not report which model it used, so this face cannot be enrolled safely.`;case`no-aligned-crop`:return`The recognizer produced no aligned crop for this face, so there is nothing to store.`;case`magnitude`:return`Refused by the quality gate: the features look degenerate, and a sample like this matches everybody.`;default:return`This face is not usable as a sample.`}}function Ue(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 We(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 Ge(e,t,n){return e.map(e=>e.photoIndex===t?{...e,...n}:e)}function Ke(e,t){return`${e}:${t}`}function qe(e,t,n,r){let i=ze(e[t]??{},n,r),a={...e};return Object.keys(i).length===0?delete a[t]:a[t]=i,a}function Je(e,t){let n=0;for(let r of e)r.analysis!==void 0&&(n+=Be(r.analysis.faces,t[r.photoIndex]??{}));return n}var Ye=`__new__`;function Xe(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[Ke(i.photoIndex,t.faceIndex)]??``).trim();if(a===``)return{kind:`error`,message:`${i.filename}: face ${t.faceIndex+1} is set to a new person but has no name.`};r.includes(a)||r.push(a)}}return{kind:`ok`,names:r}}function Ze(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[Ke(e,a)]??``).trim()];s!==void 0&&(o[a]=s)}r[e]=o}return r}function Qe(e,t){let n=[];for(let r of e){if(r.analysis===void 0)continue;let e=Ve(r.analysis.sessionId,r.analysis.faces,t[r.photoIndex]??{});for(let t of e)n.push({photoIndex:r.photoIndex,request:t})}return n}function $e(e){return/expired/i.test(e)}function et(e){return e instanceof Error?e.message:String(e)}async function tt(e,t,n){let r=new Map(e.map(e=>[e.photoIndex,e])),i={},a=[],o=0,s=null,c=(e,t)=>`${r.get(e)?.filename??`photo ${e+1}`}, face ${t+1}`;for(let l of Qe(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=et(t);if(!$e(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 (${et(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)}: ${et(e)}`)}}}return{enrolled:o,stampedModelId:s,failures:a,refreshedAnalyses:i}}var nt=[[`faceGallery`]],rt=``;function it(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 at(e){return e instanceof Error?e.message:String(e)}function ot({face:e,identities:t,value:n,onChange:o,disabled:s}){let l=i(()=>[{value:rt,label:`Ignore this face`},...t.map(e=>({value:e.id,label:e.name})),{value:Ye,label:`+ New person…`}],[t]);return r(`div`,{className:`rounded-md border border-border bg-surface p-2`,children:[c(`div`,{className:`mb-2 aspect-square w-full overflow-hidden rounded border border-border bg-surface-hover`,children:e.alignedCropBase64?c(`img`,{src:`data:image/jpeg;base64,${e.alignedCropBase64}`,alt:`Face ${e.faceIndex+1}`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Ee,{className:`h-8 w-8`})})}),e.enrollable?r(a,{children:[c(g,{options:l,value:n,disabled:s,onChange:e=>o(e.target.value),"aria-label":`Assign face ${e.faceIndex+1}`}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:[Math.round(e.quality.detectionShortSidePx),` px`,e.modelId?` · ${e.modelId}`:``]})]}):r(`div`,{className:`space-y-1`,children:[c(m,{variant:`warning`,className:`text-[10px]`,children:`Not usable`}),c(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:He(e.refusedReason)})]})]})}function st({photo:e,identities:t,draft:n,newNames:i,disabled:a,onAssign:o,onNameChange:s,onRetry:l}){let u=e.analysis?.faces??[],d=n[e.photoIndex]??{};return r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex items-center gap-2 border-b border-border pb-1`,children:[c(`span`,{className:`truncate text-xs font-medium text-foreground`,children:e.filename}),e.status===`analyzing`||e.status===`queued`?r(`span`,{className:`flex items-center gap-1 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-3 w-3 animate-spin`}),` analysing…`]}):null,e.status===`analyzed`&&e.analysis!==void 0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[u.length,` face`,u.length===1?``:`s`,` · analysed on`,` `,e.analysis.ranOnNodeId]}),e.status===`failed`&&r(v,{variant:`secondary`,size:`sm`,disabled:a,onClick:l,children:[c(fe,{className:`h-3 w-3`}),` Retry`]})]}),e.status===`failed`&&r(`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:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),r(`span`,{children:[`This photo could not be analysed: `,e.error??`unknown error`,`. The other photos are unaffected.`]})]}),e.status===`analyzed`&&u.length===0&&c(`p`,{className:`text-xs text-foreground-subtle`,children:`No faces were found in this photo. A face has to be reasonably large and facing the camera for the detector to measure it.`}),u.length>0&&c(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5`,children:u.map(e=>c(ot,{face:e,identities:t,value:d[e.faceIndex]??rt,disabled:a,onChange:t=>o(e.faceIndex,t)},e.faceIndex))}),u.filter(e=>d[e.faceIndex]===Ye).map(t=>r(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`w-28 shrink-0 truncate text-xs text-foreground-subtle`,children:[`Face `,t.faceIndex+1]}),c(`input`,{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:`New person name… (type the same name under another face to reuse it)`,value:i[Ke(e.photoIndex,t.faceIndex)]??``,onChange:e=>s(t.faceIndex,e.target.value)})]},t.faceIndex))]})}function ct({open:n,onOpenChange:a}){let l=u(),p=o(),m=t(null),{data:g}=te(),_=M(),[b,x]=s([]),[S,C]=s(!1),[w,T]=s(null),[O,k]=s({}),[A,j]=s({}),[ee,N]=s(null),P=i(()=>(g??[]).map(e=>({id:e.id,name:e.name})),[g]),F=b.some(e=>e.status===`queued`||e.status===`analyzing`),I=F||S,L=e(e=>{for(let t of e){let e=t.analysis?.sessionId;e!==void 0&&l.trpcClient.addons.custom.mutate({addonId:De,action:Ae,input:{sessionId:e}}).catch(()=>void 0)}},[l]),R=e(()=>{x([]),k({}),j({}),T(null),N(null),m.current&&(m.current.value=``)},[]),z=e(()=>{L(b),R(),a(!1)},[L,a,b,R]),B=e(async e=>{let t=Le(await l.trpcClient.addons.custom.mutate({addonId:De,action:Oe,input:{photoBase64:e.photoBase64,filename:e.filename}}));if(t===null)throw Error(`the server replied with something this page could not read`);return t},[l]),V=e(async e=>{x(t=>Ge(t,e.photoIndex,{status:`analyzing`,error:void 0}));try{let t=await B(e);x(n=>Ge(n,e.photoIndex,{status:`analyzed`,analysis:t}))}catch(t){x(n=>Ge(n,e.photoIndex,{status:`failed`,error:at(t)}))}},[B]),ne=e(async e=>{if(e.length===0)return;L(b),R();let t=Ue(e,{maxCount:12,maxBytes:je}),n=[];t.oversize.length>0&&n.push(`Over the ${Math.round(je/(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&&T(n.join(` `));let r;try{r=await Promise.all(t.accepted.map(async(e,t)=>({photoIndex:t,filename:e.name,photoBase64:await it(e),status:`queued`})))}catch(e){T(at(e));return}x(r),await We(r,2,e=>V(e))},[L,b,R,V]),H=Je(b,O),U=e(async()=>{C(!0),T(null),N(null);try{let e=Xe(b,O,A);if(e.kind===`error`){T(e.message);return}let t={};for(let n of e.names)t[n]=(await _.mutateAsync({name:n})).id;let n=await tt(b,Ze(O,A,t),{enroll:async e=>{let t=Re(await l.trpcClient.addons.custom.mutate({addonId:De,action:ke,input:e}));if(t===null)throw Error(`unreadable reply`);return t},reanalyze:e=>B(e)});Object.keys(n.refreshedAnalyses).length>0&&x(e=>e.map(e=>{let t=n.refreshedAnalyses[e.photoIndex];return t===void 0?e:{...e,status:`analyzed`,analysis:t}})),p.invalidateQueries({queryKey:nt}),n.failures.length>0&&T(n.failures.join(` · `)),N(n.enrolled===0?`Nothing was enrolled.`:`Enrolled ${n.enrolled} sample${n.enrolled===1?``:`s`}${n.stampedModelId===null?``:` with ${n.stampedModelId}`}.`)}catch(e){T(at(e))}finally{C(!1)}},[B,_,O,A,b,p,l]),re=b.filter(e=>e.status===`analyzed`).length;return c(y,{open:n,onOpenChange:e=>e?a(!0):z(),children:r(f,{className:`max-w-3xl`,children:[r(d,{children:[c(E,{children:`Enrol from photos`}),c(h,{children:`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.`})]}),r(`div`,{className:`rounded-md border border-border bg-surface-hover px-3 py-2 text-xs text-foreground-subtle`,children:[`For reliable recognition use `,c(`strong`,{children:`at least 3 photos per person`}),`, taken at different times, with different poses and lighting — you can select them all at once. Several frames from the same moment count as one — they do not add information.`]}),r(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{ref:m,type:`file`,accept:`image/jpeg,image/png,image/webp`,multiple:!0,className:`hidden`,onChange:e=>void ne(Array.from(e.target.files??[]))}),r(v,{variant:`secondary`,size:`sm`,disabled:I,onClick:()=>m.current?.click(),children:[F?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(Te,{className:`h-3.5 w-3.5`}),`Choose photos`]}),b.length>0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[re,`/`,b.length,` photo`,b.length===1?``:`s`,` analysed`]})]}),w!==null&&r(`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:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),c(`span`,{children:w})]}),ee!==null&&c(`div`,{className:`rounded-md border border-success/40 bg-success/10 px-3 py-2 text-xs text-success`,children:ee}),b.length>0&&c(`div`,{className:`max-h-[50vh] space-y-4 overflow-y-auto pr-1`,children:b.map(e=>c(st,{photo:e,identities:P,draft:O,newNames:A,disabled:I,onAssign:(t,n)=>k(r=>qe(r,e.photoIndex,t,n===rt?null:n)),onNameChange:(t,n)=>j(r=>({...r,[Ke(e.photoIndex,t)]:n})),onRetry:()=>void V(e)},e.photoIndex))}),r(D,{children:[c(v,{variant:`secondary`,onClick:z,disabled:S,children:`Close`}),r(v,{variant:`primary`,onClick:()=>void U(),disabled:I||H===0,children:[S?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):null,`Enrol `,H,` face`,H===1?``:`s`]})]})]})})}n();var lt=[[`faceGallery`]];function ut({identityId:e}){let t=o(),{data:n,isLoading:i}=S({identityId:e}),a=N();function s(n){a.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:lt})}})}return i?r(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):c(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>r(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?c(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Ee,{className:`h-6 w-6`})}),e.source===`photo`&&c(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 p-0.5 text-white`,title:`Enrolled from an uploaded photo`,children:c(Te,{className:`h-3 w-3`})}),c(`button`,{type:`button`,onClick:()=>s(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:c(X,{className:`h-4 w-4 text-white`})})]},e.id))})}function dt({identity:e,expanded:t,onToggle:n}){let i=o(),[l,u]=s(``),[g,_]=s(!1),[b,S]=s(!1),w=C(),T=x();function O(){u(e.name),_(!0)}function k(){_(!1),u(``)}function A(){let t=l.trim();if(!t||t===e.name){k();return}w.mutate({id:e.id,name:t},{onSettled:()=>{i.invalidateQueries({queryKey:lt}),k()}})}function j(){T.mutate({id:e.id},{onSettled:()=>{i.invalidateQueries({queryKey:lt}),S(!1)}})}return r(`div`,{className:`rounded-md border border-border bg-surface`,children:[r(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[c(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:c(R,{mediaKey:e.coverMediaKey,base64:e.coverBase64,alt:e.name,className:`h-full w-full object-cover`,placeholder:c(`div`,{className:`flex h-full w-full items-center justify-center`,children:c(Ee,{className:`h-4 w-4 text-foreground-subtle`})})})}),c(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:g?r(a,{children:[c(p,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&A(),e.key===`Escape`&&k()},className:`h-6 text-xs`,autoFocus:!0}),c(`button`,{type:`button`,onClick:A,disabled:w.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:c(Y,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:k,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:c(X,{className:`h-3.5 w-3.5`})})]}):c(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),c(m,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!g&&r(`div`,{className:`flex items-center gap-1`,children:[c(`button`,{type:`button`,onClick:O,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:c(de,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:()=>S(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:c(be,{className:`h-3.5 w-3.5`})})]}),c(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:c(t?xe:he,{className:`h-3.5 w-3.5`})})]}),t&&c(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:c(ut,{identityId:e.id})}),c(y,{open:b,onOpenChange:e=>!e&&S(!1),children:r(f,{children:[r(d,{children:[c(E,{children:`Delete person`}),r(h,{children:[`Delete `,c(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),r(D,{children:[c(v,{variant:`secondary`,onClick:()=>S(!1),children:`Cancel`}),r(v,{variant:`danger`,onClick:j,disabled:T.isPending,children:[T.isPending?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function ft(){let e=o(),[t,n]=s(``),i=M();function a(){let r=t.trim();r&&i.mutate({name:r},{onSettled:()=>{e.invalidateQueries({queryKey:lt}),n(``)}})}return r(`div`,{className:`flex items-center gap-2 pt-2`,children:[c(p,{placeholder:`New person name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a()},className:`h-7 text-xs flex-1`}),r(v,{variant:`primary`,size:`sm`,onClick:a,disabled:i.isPending||!t.trim(),children:[i.isPending?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(K,{className:`h-3.5 w-3.5`}),`Add`]})]})}function pt(){let{data:e,isLoading:t}=te(),[n,i]=s(null),[a,o]=s(!1);function l(e){i(t=>t===e?null:e)}return t?r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):r(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>c(dt,{identity:e,expanded:n===e.id,onToggle:()=>l(e.id)},e.id)),c(ft,{}),c(`div`,{className:`pt-1`,children:r(v,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:[c(Te,{className:`h-3.5 w-3.5`}),`Enrol from a photo`]})}),c(ct,{open:a,onOpenChange:o})]})}function mt(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function ht(e){return e.filter(mt).map(e=>e.faceId)}function gt(e){let t=0;for(let n of e)mt(n)&&(t+=1);return t}function _t(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}n();var vt=[[`faceGallery`]];function yt({faceIds:e,identities:t,onDone:n}){let i=o(),a=A(),l=M(),[u,m]=s(``),[g,_]=s(!1),[b,x]=s(null),S=e!==null&&e.length>0,C=e?.length??0;function w(){_(!1),m(``),x(null)}function T(){w(),n()}function O(t){!e||e.length===0||a.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{i.invalidateQueries({queryKey:vt}),T()}})}function k(){!e||!u.trim()||l.mutate({name:u.trim()},{onSuccess:e=>{e?.id&&O(e.id)},onError:()=>{i.invalidateQueries({queryKey:vt}),T()}})}let j=a.isPending||l.isPending;return c(y,{open:S,onOpenChange:e=>!e&&T(),children:r(f,{children:[r(d,{children:[c(E,{children:C>1?`Assign ${String(C)} faces to person`:`Assign face to person`}),c(h,{children:`Select an existing person or create a new one.`})]}),c(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>r(`button`,{type:`button`,onClick:()=>x(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${b===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[c(`span`,{className:`font-medium`,children:e.name}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),g?c(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:c(p,{placeholder:`New person name…`,value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()},autoFocus:!0,className:`flex-1`})}):c(`button`,{type:`button`,onClick:()=>{x(null),_(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),r(D,{children:[c(v,{variant:`secondary`,onClick:T,disabled:j,children:`Cancel`}),g?r(v,{variant:`primary`,onClick:k,disabled:j||!u.trim(),children:[j&&c(Z,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):r(v,{variant:`primary`,onClick:()=>b&&O(b),disabled:j||!b,children:[j&&c(Z,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,C>1?` ${String(C)}`:``]})]})]})})}n();function bt(e){let[t,n]=s(null),[r,i]=s(null),[a,o]=s(!1);return l(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await Ce(`${we}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),l(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function xt(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function St({label:e,value:t}){return r(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[c(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),c(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function Ct({box:e}){return c(`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:c(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function wt({face:e,cameraName:t,onClose:n,onAssign:a,onUnassign:o,onDelete:l,actionsPending:u}){let{data:d,isFetching:p}=j({faceId:e?.faceId??``},{enabled:e!==null}),[m,h]=s(`frame`),{frameSrc:g,naturalWidth:_,naturalHeight:b,failed:x}=bt(e?.keyFrameMediaKey),S=i(()=>{let t=xt(d??[]);return t?`data:image/jpeg;base64,${t.base64}`:_t(e)},[d,e]),C=i(()=>!e?.faceBbox||_===null||b===null?null:V(e.faceBbox,_,b),[e?.faceBbox,_,b]);if(e===null)return null;let w=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!x,T=w&&m===`frame`,E=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return c(y,{open:!0,onOpenChange:e=>!e&&n(),children:r(f,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[r(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),c(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),c(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(X,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[w&&r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[r(`button`,{type:`button`,onClick:()=>h(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${m===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(I,{className:`h-3.5 w-3.5`}),` Full frame`]}),r(`button`,{type:`button`,onClick:()=>h(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${m===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(z,{className:`h-3.5 w-3.5`}),` Crop`]})]}),T&&g?c(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:c(G,{src:g,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:C?c(Ct,{box:C}):void 0})}):S?r(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[c(G,{src:S,alt:`Detected face`,className:`h-full w-full`}),p&&c(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:c(Z,{className:`h-3.5 w-3.5 animate-spin`})})]}):r(`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:[c(W,{className:`h-8 w-8 text-warning/70`}),c(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),c(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[c(St,{label:`Camera`,value:t}),c(St,{label:`Captured`,value:oe(e.timestamp)}),c(St,{label:`Track`,value:e.trackId}),c(St,{label:`Identity`,value:E})]})]}),r(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?r(v,{variant:`secondary`,onClick:()=>o(e.faceId),disabled:u,children:[c(B,{className:`h-3.5 w-3.5`}),` Detach`]}):r(v,{variant:`primary`,onClick:()=>a(e.faceId),disabled:u,children:[c(L,{className:`h-3.5 w-3.5`}),` Assign`]}),r(v,{variant:`secondary`,onClick:()=>l(e.faceId),disabled:u,children:[c(be,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}function Tt(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Et(e,t){return e.faceIds.filter(e=>!t.has(e))}function Dt(e,t){return e.faceIds.filter(e=>t(e))}n();var Ot=[[`faceGallery`]],kt=20,At=.3,jt=.9,Mt=.05,Nt=.5,Pt=2,Ft=10,It=2;function Lt({cluster:e,face:t,active:n,onSelect:i}){let a=_t(t);return r(`button`,{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 ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[c(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:a===null?c(W,{className:`h-24 w-24 p-6 text-foreground-subtle`}):c(`img`,{src:a,alt:``,loading:`lazy`,decoding:`async`,className:`h-24 w-24 object-cover`})}),r(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function Rt({face:e,cameraName:t,nowMs:n,excluded:i,onToggleExclude:a,onDelete:o,deletePending:s}){let l=_t(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${i?`border-border opacity-40 grayscale`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[l===null?r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[c(W,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(G,{src:l,alt:`Face from ${t}`,className:`h-full w-full`}),c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},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?`Include face`:`Exclude face`,title:i?`Include`:`Exclude`,children:c(i?J:X,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:U(e.timestamp,n)})]}),c(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},disabled:s,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:s?c(Z,{className:`h-4 w-4 animate-spin`}):c(be,{className:`h-4 w-4`})})})]})}function zt({open:e,onClose:t,byId:n,cameraName:u,nowMs:d,identities:p,selectMany:m}){let h=o(),g=P(),_=T(),[b,x]=s(Nt),[S,C]=s(It),[E,D]=s(null),[O,k]=s({}),[A,j]=s(null),{data:ee,isFetching:M,refetch:te}=w({threshold:b,minClusterSize:S,limit:kt},{enabled:e}),N=ee??[];l(()=>{k({})},[b,S]),l(()=>{if(N.length===0){D(null);return}N.some(e=>e.representativeFaceId===E)||D(N[0]?.representativeFaceId??null)},[N]);let F=i(()=>N.find(e=>e.representativeFaceId===E)??null,[N,E]),I=F?O[F.representativeFaceId]??new Set:new Set,R=i(()=>F?Dt(F,e=>n.has(e)):[],[F,n]),z=F?F.faceIds.length-R.length:0,B=F?Et({...F,faceIds:R},I):[];function V(e){if(!F)return;let t=F.representativeFaceId;k(n=>({...n,[t]:Tt(n[t]??new Set,e)}))}function ne(){h.invalidateQueries({queryKey:Ot})}async function H(e){await g({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&_.mutate({faceId:e},{onSettled:ne})}function U(){j(null),t()}function re(){B.length!==0&&(m(B),U())}return r(y,{open:e,onOpenChange:e=>!e&&U(),children:[r(f,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[r(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`flex items-center justify-between gap-2`,children:[r(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[c(_e,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),c(`button`,{type:`button`,onClick:U,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(X,{className:`h-4 w-4`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,c(`input`,{type:`range`,min:At,max:jt,step:Mt,value:b,onChange:e=>x(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),c(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:b.toFixed(2)})]}),r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,c(`input`,{type:`number`,min:Pt,max:Ft,step:1,value:S,onChange:e=>C(Math.min(Ft,Math.max(Pt,Number(e.target.value)||Pt))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),r(v,{variant:`secondary`,onClick:()=>{k({}),te()},disabled:M,children:[M?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(q,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:M&&N.length===0?r(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):N.length===0?c(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):r(a,{children:[c(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:N.map(e=>c(Lt,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===E,onSelect:()=>D(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:N.map(e=>c(Lt,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===E,onSelect:()=>D(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:F&&r(a,{children:[z>0&&r(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[z,` not loaded — excluded from actions`]}),c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:R.map(e=>{let t=n.get(e);return t?c(Rt,{face:t,cameraName:u(t.deviceId),nowMs:d,excluded:I.has(e),onToggleExclude:()=>V(e),onDelete:()=>void H(e),deletePending:_.isPending&&_.variables?.faceId===e},e):null})})]})})]})}),r(`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:[c(v,{variant:`secondary`,onClick:re,disabled:B.length===0,children:`Select in gallery`}),r(v,{variant:`primary`,onClick:()=>j(B),disabled:B.length===0,children:[c(L,{className:`h-3.5 w-3.5`}),` Adopt (`,B.length,`)`]})]})]}),c(yt,{faceIds:A,identities:p,onDone:()=>j(null)})]})}n();var Bt=[[`faceGallery`]],Vt=500,Ht=120;function Ut({face:e,cameraName:t,nowMs:n,selected:i,onToggleSelect:a,onAssign:s,onOpenDetail:l}){let u=o(),d=ee(),f=T(),p=()=>{u.invalidateQueries({queryKey:Bt})},m=()=>l(e.faceId),h=_t(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[h===null?r(`button`,{type:`button`,onClick:m,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[c(W,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(`img`,{src:h,alt:`Face from ${t}`,onClick:m,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?`Deselect`:`Select`,children:i?c(pe,{className:`h-4 w-4 text-primary`}):c(me,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:U(e.timestamp,n)}),e.identityName&&c(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),r(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d.mutate({faceId:e.faceId},{onSettled:p})},disabled:d.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:d.isPending?c(Z,{className:`h-4 w-4 animate-spin`}):c(B,{className:`h-4 w-4`})}):c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:c(L,{className:`h-4 w-4`})}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),f.mutate({faceId:e.faceId},{onSettled:p})},disabled:f.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:f.isPending?c(Z,{className:`h-4 w-4 animate-spin`}):c(be,{className:`h-4 w-4`})})]})]})}var Wt=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function Gt(){let e=o(),[t,n]=s(`all`),[l,u]=s(ce),[d,f]=s(new Set),[p,m]=s(new Set),[h,g]=s(null),[_,y]=s(!1),[x,S]=s(null),{data:C,isLoading:w}=O({limit:Vt,filter:t,includeCrops:!1},{refetchInterval:3e4}),{data:E=[]}=te(),{data:D}=b({isCamera:!0,projection:`slim`},{staleTime:3e4}),j=A(),M=ee(),N=k(),P=T(),F=Date.now(),I=C??[],R=i(()=>{let e=new Map;for(let t of D??[])e.set(t.id,t.name);return e},[D]),z=e=>R.get(e)??`Camera #${String(e)}`,V=i(()=>H(I).map(e=>({id:e,name:z(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[I,R]),U=i(()=>ie(ue(I,l),d),[I,l,d]),G=ae(U,Ht,i(()=>JSON.stringify([t,l.fromMs,l.toMs,[...d].sort((e,t)=>e-t)]),[t,l.fromMs,l.toMs,d])),oe=i(()=>new Map(I.map(e=>[e.faceId,e])),[I]),le=i(()=>gt(U),[U]),de=x===null?null:oe.get(x)??null,K=()=>{e.invalidateQueries({queryKey:Bt})},q=()=>m(new Set);function fe(e){m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){m(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(ht(U))}let J=[...p],Y=j.isPending||N.isPending||P.isPending,he=M.isPending||P.isPending;function ge(){J.length!==0&&N.mutate({faceIds:J},{onSettled:()=>{K(),q()}})}function ve(){J.length!==0&&Promise.allSettled(J.map(e=>P.mutateAsync({faceId:e}))).then(()=>{K(),q()})}function ye(e){S(null),g([e])}function xe(e){M.mutate({faceId:e},{onSettled:K}),S(null)}function Se(e){P.mutate({faceId:e},{onSettled:K}),S(null)}let Ce=U.length!==I.length;return r(`div`,{className:`relative space-y-3`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c(`div`,{className:`flex items-center gap-1`,children:Wt.map(e=>c(`button`,{type:`button`,onClick:()=>n(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),c(se,{onChange:u}),c(re,{cameras:V,selected:d,onChange:f}),r(`button`,{type:`button`,onClick:()=>y(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${_?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(_e,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!w&&le>0&&r(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[c(W,{className:`h-3.5 w-3.5`}),` Select `,le,` crop-less`]}),!w&&c(`span`,{className:`text-[10px] text-foreground-subtle ${le>0?`ml-2`:`ml-auto`}`,children:Ce?`${String(U.length)} of ${String(I.length)} faces`:`${String(U.length)} face${U.length===1?``:`s`}`})]}),p.size>0&&r(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:[p.size,` selected`]}),r(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[r(v,{variant:`primary`,onClick:()=>g(J),disabled:Y,children:[c(L,{className:`h-3.5 w-3.5`}),` Assign`]}),r(v,{variant:`secondary`,onClick:ge,disabled:Y,children:[N.isPending?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(B,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),r(v,{variant:`secondary`,onClick:ve,disabled:Y,children:[c(be,{className:`h-3.5 w-3.5`}),` Delete`]}),c(v,{variant:`ghost`,onClick:q,disabled:Y,children:c(X,{className:`h-3.5 w-3.5`})})]})]}),w&&r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!w&&U.length===0&&c(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:I.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!w&&U.length>0&&r(a,{children:[c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:G.pageItems.map(e=>c(Ut,{face:e,cameraName:z(e.deviceId),nowMs:F,selected:p.has(e.faceId),onToggleSelect:fe,onAssign:e=>g([e]),onOpenDetail:S},e.faceId))}),c(ne,{currentPage:G.page,totalItems:G.totalItems,pageSize:G.pageSize,onPageChange:G.setPage,itemNoun:`faces`})]}),c(wt,{face:de,cameraName:de?z(de.deviceId):``,onClose:()=>S(null),onAssign:ye,onUnassign:xe,onDelete:Se,actionsPending:he}),c(yt,{faceIds:h,identities:E,onDone:()=>{g(null),q()}}),c(zt,{open:_,onClose:()=>y(!1),byId:oe,cameraName:z,nowMs:F,identities:E,selectMany:pe})]})}n();var Kt=[[`faceGallery`]],qt=2e3;function Jt(){let e=o(),n=t(e);n.current=e;let r=t(void 0);r.current||=le({delayMs:qt,invalidate:()=>{n.current.invalidateQueries({queryKey:Kt})}}),l(()=>()=>r.current?.cancel(),[]),_(F.PipelineAnalyticsFaceGalleryChanged,()=>{r.current?.trigger()})}function Yt(){return Jt(),c(Se,{icon:ge,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:r(`section`,{className:`space-y-3`,children:[r(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),c(pt,{})]}),r(`div`,{className:`pt-4 border-t border-border`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),c(Gt,{})]})]})})}export{Yt as DetectionIntelligencePage};
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,b as a,o,q as s,x as c,z as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as u}from"./player-overlays-BxZ5yvH8.js";import{At as d,Dt as f,Ft as p,Lt as m,Ot as h,Pt as g,Rs as _,Rt as v,Tt as y,Vr as b,ai as x,ci as S,di as C,fi as w,ii as T,jt as E,kt as D,li as O,mi as k,ni as A,oi as j,pi as ee,ri as M,si as te,ui as N,un as P}from"./src-Ch7OV9gF.js";import{Vt as F}from"./src-MgTxcsw3.js";import{a as I,i as L,n as R,o as z,r as B,t as V}from"./face-bbox-DZIslbfV.js";import{a as ne,c as H,f as U,i as re,l as ie,m as W,n as G,o as ae,p as oe,r as se,s as ce,t as le,u as ue}from"./debounced-invalidate-Dsi2OJPO.js";import{t as de}from"./pencil-Cu_AwkkH.js";import{t as K}from"./plus-CV5p_tnx.js";import{t as q}from"./refresh-cw-BkBjU-Za.js";import{t as fe}from"./rotate-cw-BwJCwVQH.js";import{t as pe}from"./square-check-big-CD8B3dsJ.js";import{t as me}from"./square-B3B-lXbz.js";import{t as J}from"./undo-2-TS368FbX.js";import{B as Y,L as he,g as ge,i as X,l as _e,o as ve,q as ye,s as be,w as Z,z as xe}from"./index-BAEd1ERX.js";import{t as Se}from"./AdminPage-CCD07UMs.js";import{r as Ce,t as we}from"./authed-media-BPd_L9jr.js";var Te=ye(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Ee=ye(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);n();var De=`pipeline-analytics`,Oe=`photo.analyze`,ke=`photo.enroll`,Ae=`photo.discard`,je=18*1024*1024;function Me(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 Ne(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Pe(e){if(!Me(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 Fe(e){if(!Me(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 Ie(e){if(!Me(e))return null;let t=$(e,`faceIndex`),n=$(e,`score`),r=Ne(e,`enrollable`),i=Pe(e.bbox),a=Fe(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 Le(e){if(!Me(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=Ie(e);t!==null&&i.push(t)}return{sessionId:t,ranOnNodeId:n,faces:i}}function Re(e){if(!Me(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 ze(e,t,n){let r={...e};return n===null||n===``?delete r[t]:r[t]=n,r}function Be(e,t){return e.filter(e=>e.enrollable&&t[e.faceIndex]!==void 0).length}function Ve(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 He(e){switch(e){case`no-embedding`:return`Too small or too indistinct for the recognizer to measure — try a photo where this face is larger.`;case`no-model-id`:return`The recognizer did not report which model it used, so this face cannot be enrolled safely.`;case`no-aligned-crop`:return`The recognizer produced no aligned crop for this face, so there is nothing to store.`;case`magnitude`:return`Refused by the quality gate: the features look degenerate, and a sample like this matches everybody.`;default:return`This face is not usable as a sample.`}}function Ue(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 We(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 Ge(e,t,n){return e.map(e=>e.photoIndex===t?{...e,...n}:e)}function Ke(e,t){return`${e}:${t}`}function qe(e,t,n,r){let i=ze(e[t]??{},n,r),a={...e};return Object.keys(i).length===0?delete a[t]:a[t]=i,a}function Je(e,t){let n=0;for(let r of e)r.analysis!==void 0&&(n+=Be(r.analysis.faces,t[r.photoIndex]??{}));return n}var Ye=`__new__`;function Xe(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[Ke(i.photoIndex,t.faceIndex)]??``).trim();if(a===``)return{kind:`error`,message:`${i.filename}: face ${t.faceIndex+1} is set to a new person but has no name.`};r.includes(a)||r.push(a)}}return{kind:`ok`,names:r}}function Ze(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[Ke(e,a)]??``).trim()];s!==void 0&&(o[a]=s)}r[e]=o}return r}function Qe(e,t){let n=[];for(let r of e){if(r.analysis===void 0)continue;let e=Ve(r.analysis.sessionId,r.analysis.faces,t[r.photoIndex]??{});for(let t of e)n.push({photoIndex:r.photoIndex,request:t})}return n}function $e(e){return/expired/i.test(e)}function et(e){return e instanceof Error?e.message:String(e)}async function tt(e,t,n){let r=new Map(e.map(e=>[e.photoIndex,e])),i={},a=[],o=0,s=null,c=(e,t)=>`${r.get(e)?.filename??`photo ${e+1}`}, face ${t+1}`;for(let l of Qe(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=et(t);if(!$e(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 (${et(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)}: ${et(e)}`)}}}return{enrolled:o,stampedModelId:s,failures:a,refreshedAnalyses:i}}var nt=[[`faceGallery`]],rt=``;function it(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 at(e){return e instanceof Error?e.message:String(e)}function ot({face:e,identities:t,value:n,onChange:o,disabled:s}){let l=i(()=>[{value:rt,label:`Ignore this face`},...t.map(e=>({value:e.id,label:e.name})),{value:Ye,label:`+ New person…`}],[t]);return r(`div`,{className:`rounded-md border border-border bg-surface p-2`,children:[c(`div`,{className:`mb-2 aspect-square w-full overflow-hidden rounded border border-border bg-surface-hover`,children:e.alignedCropBase64?c(`img`,{src:`data:image/jpeg;base64,${e.alignedCropBase64}`,alt:`Face ${e.faceIndex+1}`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Ee,{className:`h-8 w-8`})})}),e.enrollable?r(a,{children:[c(g,{options:l,value:n,disabled:s,onChange:e=>o(e.target.value),"aria-label":`Assign face ${e.faceIndex+1}`}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:[Math.round(e.quality.detectionShortSidePx),` px`,e.modelId?` · ${e.modelId}`:``]})]}):r(`div`,{className:`space-y-1`,children:[c(m,{variant:`warning`,className:`text-[10px]`,children:`Not usable`}),c(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:He(e.refusedReason)})]})]})}function st({photo:e,identities:t,draft:n,newNames:i,disabled:a,onAssign:o,onNameChange:s,onRetry:l}){let u=e.analysis?.faces??[],d=n[e.photoIndex]??{};return r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex items-center gap-2 border-b border-border pb-1`,children:[c(`span`,{className:`truncate text-xs font-medium text-foreground`,children:e.filename}),e.status===`analyzing`||e.status===`queued`?r(`span`,{className:`flex items-center gap-1 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-3 w-3 animate-spin`}),` analysing…`]}):null,e.status===`analyzed`&&e.analysis!==void 0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[u.length,` face`,u.length===1?``:`s`,` · analysed on`,` `,e.analysis.ranOnNodeId]}),e.status===`failed`&&r(v,{variant:`secondary`,size:`sm`,disabled:a,onClick:l,children:[c(fe,{className:`h-3 w-3`}),` Retry`]})]}),e.status===`failed`&&r(`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:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),r(`span`,{children:[`This photo could not be analysed: `,e.error??`unknown error`,`. The other photos are unaffected.`]})]}),e.status===`analyzed`&&u.length===0&&c(`p`,{className:`text-xs text-foreground-subtle`,children:`No faces were found in this photo. A face has to be reasonably large and facing the camera for the detector to measure it.`}),u.length>0&&c(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5`,children:u.map(e=>c(ot,{face:e,identities:t,value:d[e.faceIndex]??rt,disabled:a,onChange:t=>o(e.faceIndex,t)},e.faceIndex))}),u.filter(e=>d[e.faceIndex]===Ye).map(t=>r(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`w-28 shrink-0 truncate text-xs text-foreground-subtle`,children:[`Face `,t.faceIndex+1]}),c(`input`,{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:`New person name… (type the same name under another face to reuse it)`,value:i[Ke(e.photoIndex,t.faceIndex)]??``,onChange:e=>s(t.faceIndex,e.target.value)})]},t.faceIndex))]})}function ct({open:n,onOpenChange:a}){let l=u(),p=o(),m=t(null),{data:g}=te(),_=M(),[b,x]=s([]),[S,C]=s(!1),[w,T]=s(null),[O,k]=s({}),[A,j]=s({}),[ee,N]=s(null),P=i(()=>(g??[]).map(e=>({id:e.id,name:e.name})),[g]),F=b.some(e=>e.status===`queued`||e.status===`analyzing`),I=F||S,L=e(e=>{for(let t of e){let e=t.analysis?.sessionId;e!==void 0&&l.trpcClient.addons.custom.mutate({addonId:De,action:Ae,input:{sessionId:e}}).catch(()=>void 0)}},[l]),R=e(()=>{x([]),k({}),j({}),T(null),N(null),m.current&&(m.current.value=``)},[]),z=e(()=>{L(b),R(),a(!1)},[L,a,b,R]),B=e(async e=>{let t=Le(await l.trpcClient.addons.custom.mutate({addonId:De,action:Oe,input:{photoBase64:e.photoBase64,filename:e.filename}}));if(t===null)throw Error(`the server replied with something this page could not read`);return t},[l]),V=e(async e=>{x(t=>Ge(t,e.photoIndex,{status:`analyzing`,error:void 0}));try{let t=await B(e);x(n=>Ge(n,e.photoIndex,{status:`analyzed`,analysis:t}))}catch(t){x(n=>Ge(n,e.photoIndex,{status:`failed`,error:at(t)}))}},[B]),ne=e(async e=>{if(e.length===0)return;L(b),R();let t=Ue(e,{maxCount:12,maxBytes:je}),n=[];t.oversize.length>0&&n.push(`Over the ${Math.round(je/(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&&T(n.join(` `));let r;try{r=await Promise.all(t.accepted.map(async(e,t)=>({photoIndex:t,filename:e.name,photoBase64:await it(e),status:`queued`})))}catch(e){T(at(e));return}x(r),await We(r,2,e=>V(e))},[L,b,R,V]),H=Je(b,O),U=e(async()=>{C(!0),T(null),N(null);try{let e=Xe(b,O,A);if(e.kind===`error`){T(e.message);return}let t={};for(let n of e.names)t[n]=(await _.mutateAsync({name:n})).id;let n=await tt(b,Ze(O,A,t),{enroll:async e=>{let t=Re(await l.trpcClient.addons.custom.mutate({addonId:De,action:ke,input:e}));if(t===null)throw Error(`unreadable reply`);return t},reanalyze:e=>B(e)});Object.keys(n.refreshedAnalyses).length>0&&x(e=>e.map(e=>{let t=n.refreshedAnalyses[e.photoIndex];return t===void 0?e:{...e,status:`analyzed`,analysis:t}})),p.invalidateQueries({queryKey:nt}),n.failures.length>0&&T(n.failures.join(` · `)),N(n.enrolled===0?`Nothing was enrolled.`:`Enrolled ${n.enrolled} sample${n.enrolled===1?``:`s`}${n.stampedModelId===null?``:` with ${n.stampedModelId}`}.`)}catch(e){T(at(e))}finally{C(!1)}},[B,_,O,A,b,p,l]),re=b.filter(e=>e.status===`analyzed`).length;return c(y,{open:n,onOpenChange:e=>e?a(!0):z(),children:r(f,{className:`max-w-3xl`,children:[r(d,{children:[c(E,{children:`Enrol from photos`}),c(h,{children:`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.`})]}),r(`div`,{className:`rounded-md border border-border bg-surface-hover px-3 py-2 text-xs text-foreground-subtle`,children:[`For reliable recognition use `,c(`strong`,{children:`at least 3 photos per person`}),`, taken at different times, with different poses and lighting — you can select them all at once. Several frames from the same moment count as one — they do not add information.`]}),r(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{ref:m,type:`file`,accept:`image/jpeg,image/png,image/webp`,multiple:!0,className:`hidden`,onChange:e=>void ne(Array.from(e.target.files??[]))}),r(v,{variant:`secondary`,size:`sm`,disabled:I,onClick:()=>m.current?.click(),children:[F?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(Te,{className:`h-3.5 w-3.5`}),`Choose photos`]}),b.length>0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[re,`/`,b.length,` photo`,b.length===1?``:`s`,` analysed`]})]}),w!==null&&r(`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:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),c(`span`,{children:w})]}),ee!==null&&c(`div`,{className:`rounded-md border border-success/40 bg-success/10 px-3 py-2 text-xs text-success`,children:ee}),b.length>0&&c(`div`,{className:`max-h-[50vh] space-y-4 overflow-y-auto pr-1`,children:b.map(e=>c(st,{photo:e,identities:P,draft:O,newNames:A,disabled:I,onAssign:(t,n)=>k(r=>qe(r,e.photoIndex,t,n===rt?null:n)),onNameChange:(t,n)=>j(r=>({...r,[Ke(e.photoIndex,t)]:n})),onRetry:()=>void V(e)},e.photoIndex))}),r(D,{children:[c(v,{variant:`secondary`,onClick:z,disabled:S,children:`Close`}),r(v,{variant:`primary`,onClick:()=>void U(),disabled:I||H===0,children:[S?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):null,`Enrol `,H,` face`,H===1?``:`s`]})]})]})})}n();var lt=[[`faceGallery`]];function ut({identityId:e}){let t=o(),{data:n,isLoading:i}=S({identityId:e}),a=N();function s(n){a.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:lt})}})}return i?r(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):c(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>r(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?c(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Ee,{className:`h-6 w-6`})}),e.source===`photo`&&c(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 p-0.5 text-white`,title:`Enrolled from an uploaded photo`,children:c(Te,{className:`h-3 w-3`})}),c(`button`,{type:`button`,onClick:()=>s(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:c(X,{className:`h-4 w-4 text-white`})})]},e.id))})}function dt({identity:e,expanded:t,onToggle:n}){let i=o(),[l,u]=s(``),[g,_]=s(!1),[b,S]=s(!1),w=C(),T=x();function O(){u(e.name),_(!0)}function k(){_(!1),u(``)}function A(){let t=l.trim();if(!t||t===e.name){k();return}w.mutate({id:e.id,name:t},{onSettled:()=>{i.invalidateQueries({queryKey:lt}),k()}})}function j(){T.mutate({id:e.id},{onSettled:()=>{i.invalidateQueries({queryKey:lt}),S(!1)}})}return r(`div`,{className:`rounded-md border border-border bg-surface`,children:[r(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[c(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:c(R,{mediaKey:e.coverMediaKey,base64:e.coverBase64,alt:e.name,className:`h-full w-full object-cover`,placeholder:c(`div`,{className:`flex h-full w-full items-center justify-center`,children:c(Ee,{className:`h-4 w-4 text-foreground-subtle`})})})}),c(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:g?r(a,{children:[c(p,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&A(),e.key===`Escape`&&k()},className:`h-6 text-xs`,autoFocus:!0}),c(`button`,{type:`button`,onClick:A,disabled:w.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:c(Y,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:k,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:c(X,{className:`h-3.5 w-3.5`})})]}):c(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),c(m,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!g&&r(`div`,{className:`flex items-center gap-1`,children:[c(`button`,{type:`button`,onClick:O,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:c(de,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:()=>S(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:c(be,{className:`h-3.5 w-3.5`})})]}),c(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:c(t?xe:he,{className:`h-3.5 w-3.5`})})]}),t&&c(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:c(ut,{identityId:e.id})}),c(y,{open:b,onOpenChange:e=>!e&&S(!1),children:r(f,{children:[r(d,{children:[c(E,{children:`Delete person`}),r(h,{children:[`Delete `,c(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),r(D,{children:[c(v,{variant:`secondary`,onClick:()=>S(!1),children:`Cancel`}),r(v,{variant:`danger`,onClick:j,disabled:T.isPending,children:[T.isPending?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function ft(){let e=o(),[t,n]=s(``),i=M();function a(){let r=t.trim();r&&i.mutate({name:r},{onSettled:()=>{e.invalidateQueries({queryKey:lt}),n(``)}})}return r(`div`,{className:`flex items-center gap-2 pt-2`,children:[c(p,{placeholder:`New person name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a()},className:`h-7 text-xs flex-1`}),r(v,{variant:`primary`,size:`sm`,onClick:a,disabled:i.isPending||!t.trim(),children:[i.isPending?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(K,{className:`h-3.5 w-3.5`}),`Add`]})]})}function pt(){let{data:e,isLoading:t}=te(),[n,i]=s(null),[a,o]=s(!1);function l(e){i(t=>t===e?null:e)}return t?r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):r(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>c(dt,{identity:e,expanded:n===e.id,onToggle:()=>l(e.id)},e.id)),c(ft,{}),c(`div`,{className:`pt-1`,children:r(v,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:[c(Te,{className:`h-3.5 w-3.5`}),`Enrol from a photo`]})}),c(ct,{open:a,onOpenChange:o})]})}function mt(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function ht(e){return e.filter(mt).map(e=>e.faceId)}function gt(e){let t=0;for(let n of e)mt(n)&&(t+=1);return t}function _t(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}n();var vt=[[`faceGallery`]];function yt({faceIds:e,identities:t,onDone:n}){let i=o(),a=A(),l=M(),[u,m]=s(``),[g,_]=s(!1),[b,x]=s(null),S=e!==null&&e.length>0,C=e?.length??0;function w(){_(!1),m(``),x(null)}function T(){w(),n()}function O(t){!e||e.length===0||a.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{i.invalidateQueries({queryKey:vt}),T()}})}function k(){!e||!u.trim()||l.mutate({name:u.trim()},{onSuccess:e=>{e?.id&&O(e.id)},onError:()=>{i.invalidateQueries({queryKey:vt}),T()}})}let j=a.isPending||l.isPending;return c(y,{open:S,onOpenChange:e=>!e&&T(),children:r(f,{children:[r(d,{children:[c(E,{children:C>1?`Assign ${String(C)} faces to person`:`Assign face to person`}),c(h,{children:`Select an existing person or create a new one.`})]}),c(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>r(`button`,{type:`button`,onClick:()=>x(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${b===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[c(`span`,{className:`font-medium`,children:e.name}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),g?c(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:c(p,{placeholder:`New person name…`,value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()},autoFocus:!0,className:`flex-1`})}):c(`button`,{type:`button`,onClick:()=>{x(null),_(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),r(D,{children:[c(v,{variant:`secondary`,onClick:T,disabled:j,children:`Cancel`}),g?r(v,{variant:`primary`,onClick:k,disabled:j||!u.trim(),children:[j&&c(Z,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):r(v,{variant:`primary`,onClick:()=>b&&O(b),disabled:j||!b,children:[j&&c(Z,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,C>1?` ${String(C)}`:``]})]})]})})}n();function bt(e){let[t,n]=s(null),[r,i]=s(null),[a,o]=s(!1);return l(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await Ce(`${we}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),l(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function xt(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function St({label:e,value:t}){return r(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[c(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),c(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function Ct({box:e}){return c(`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:c(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function wt({face:e,cameraName:t,onClose:n,onAssign:a,onUnassign:o,onDelete:l,actionsPending:u}){let{data:d,isFetching:p}=j({faceId:e?.faceId??``},{enabled:e!==null}),[m,h]=s(`frame`),{frameSrc:g,naturalWidth:_,naturalHeight:b,failed:x}=bt(e?.keyFrameMediaKey),S=i(()=>{let t=xt(d??[]);return t?`data:image/jpeg;base64,${t.base64}`:_t(e)},[d,e]),C=i(()=>!e?.faceBbox||_===null||b===null?null:V(e.faceBbox,_,b),[e?.faceBbox,_,b]);if(e===null)return null;let w=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!x,T=w&&m===`frame`,E=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return c(y,{open:!0,onOpenChange:e=>!e&&n(),children:r(f,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[r(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),c(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),c(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(X,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[w&&r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[r(`button`,{type:`button`,onClick:()=>h(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${m===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(I,{className:`h-3.5 w-3.5`}),` Full frame`]}),r(`button`,{type:`button`,onClick:()=>h(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${m===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(z,{className:`h-3.5 w-3.5`}),` Crop`]})]}),T&&g?c(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:c(G,{src:g,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:C?c(Ct,{box:C}):void 0})}):S?r(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[c(G,{src:S,alt:`Detected face`,className:`h-full w-full`}),p&&c(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:c(Z,{className:`h-3.5 w-3.5 animate-spin`})})]}):r(`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:[c(W,{className:`h-8 w-8 text-warning/70`}),c(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),c(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[c(St,{label:`Camera`,value:t}),c(St,{label:`Captured`,value:oe(e.timestamp)}),c(St,{label:`Track`,value:e.trackId}),c(St,{label:`Identity`,value:E})]})]}),r(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?r(v,{variant:`secondary`,onClick:()=>o(e.faceId),disabled:u,children:[c(B,{className:`h-3.5 w-3.5`}),` Detach`]}):r(v,{variant:`primary`,onClick:()=>a(e.faceId),disabled:u,children:[c(L,{className:`h-3.5 w-3.5`}),` Assign`]}),r(v,{variant:`secondary`,onClick:()=>l(e.faceId),disabled:u,children:[c(be,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}function Tt(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Et(e,t){return e.faceIds.filter(e=>!t.has(e))}function Dt(e,t){return e.faceIds.filter(e=>t(e))}n();var Ot=[[`faceGallery`]],kt=20,At=.3,jt=.9,Mt=.05,Nt=.5,Pt=2,Ft=10,It=2;function Lt({cluster:e,face:t,active:n,onSelect:i}){let a=_t(t);return r(`button`,{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 ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[c(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:a===null?c(W,{className:`h-24 w-24 p-6 text-foreground-subtle`}):c(`img`,{src:a,alt:``,loading:`lazy`,decoding:`async`,className:`h-24 w-24 object-cover`})}),r(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function Rt({face:e,cameraName:t,nowMs:n,excluded:i,onToggleExclude:a,onDelete:o,deletePending:s}){let l=_t(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${i?`border-border opacity-40 grayscale`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[l===null?r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[c(W,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(G,{src:l,alt:`Face from ${t}`,className:`h-full w-full`}),c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},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?`Include face`:`Exclude face`,title:i?`Include`:`Exclude`,children:c(i?J:X,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:U(e.timestamp,n)})]}),c(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},disabled:s,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:s?c(Z,{className:`h-4 w-4 animate-spin`}):c(be,{className:`h-4 w-4`})})})]})}function zt({open:e,onClose:t,byId:n,cameraName:u,nowMs:d,identities:p,selectMany:m}){let h=o(),g=P(),_=T(),[b,x]=s(Nt),[S,C]=s(It),[E,D]=s(null),[O,k]=s({}),[A,j]=s(null),{data:ee,isFetching:M,refetch:te}=w({threshold:b,minClusterSize:S,limit:kt},{enabled:e}),N=ee??[];l(()=>{k({})},[b,S]),l(()=>{if(N.length===0){D(null);return}N.some(e=>e.representativeFaceId===E)||D(N[0]?.representativeFaceId??null)},[N]);let F=i(()=>N.find(e=>e.representativeFaceId===E)??null,[N,E]),I=F?O[F.representativeFaceId]??new Set:new Set,R=i(()=>F?Dt(F,e=>n.has(e)):[],[F,n]),z=F?F.faceIds.length-R.length:0,B=F?Et({...F,faceIds:R},I):[];function V(e){if(!F)return;let t=F.representativeFaceId;k(n=>({...n,[t]:Tt(n[t]??new Set,e)}))}function ne(){h.invalidateQueries({queryKey:Ot})}async function H(e){await g({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&_.mutate({faceId:e},{onSettled:ne})}function U(){j(null),t()}function re(){B.length!==0&&(m(B),U())}return r(y,{open:e,onOpenChange:e=>!e&&U(),children:[r(f,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[r(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`flex items-center justify-between gap-2`,children:[r(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[c(_e,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),c(`button`,{type:`button`,onClick:U,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(X,{className:`h-4 w-4`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,c(`input`,{type:`range`,min:At,max:jt,step:Mt,value:b,onChange:e=>x(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),c(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:b.toFixed(2)})]}),r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,c(`input`,{type:`number`,min:Pt,max:Ft,step:1,value:S,onChange:e=>C(Math.min(Ft,Math.max(Pt,Number(e.target.value)||Pt))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),r(v,{variant:`secondary`,onClick:()=>{k({}),te()},disabled:M,children:[M?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(q,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:M&&N.length===0?r(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):N.length===0?c(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):r(a,{children:[c(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:N.map(e=>c(Lt,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===E,onSelect:()=>D(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:N.map(e=>c(Lt,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===E,onSelect:()=>D(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:F&&r(a,{children:[z>0&&r(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[z,` not loaded — excluded from actions`]}),c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:R.map(e=>{let t=n.get(e);return t?c(Rt,{face:t,cameraName:u(t.deviceId),nowMs:d,excluded:I.has(e),onToggleExclude:()=>V(e),onDelete:()=>void H(e),deletePending:_.isPending&&_.variables?.faceId===e},e):null})})]})})]})}),r(`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:[c(v,{variant:`secondary`,onClick:re,disabled:B.length===0,children:`Select in gallery`}),r(v,{variant:`primary`,onClick:()=>j(B),disabled:B.length===0,children:[c(L,{className:`h-3.5 w-3.5`}),` Adopt (`,B.length,`)`]})]})]}),c(yt,{faceIds:A,identities:p,onDone:()=>j(null)})]})}n();var Bt=[[`faceGallery`]],Vt=500,Ht=120;function Ut({face:e,cameraName:t,nowMs:n,selected:i,onToggleSelect:a,onAssign:s,onOpenDetail:l}){let u=o(),d=ee(),f=T(),p=()=>{u.invalidateQueries({queryKey:Bt})},m=()=>l(e.faceId),h=_t(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[h===null?r(`button`,{type:`button`,onClick:m,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[c(W,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(`img`,{src:h,alt:`Face from ${t}`,onClick:m,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?`Deselect`:`Select`,children:i?c(pe,{className:`h-4 w-4 text-primary`}):c(me,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:U(e.timestamp,n)}),e.identityName&&c(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),r(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d.mutate({faceId:e.faceId},{onSettled:p})},disabled:d.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:d.isPending?c(Z,{className:`h-4 w-4 animate-spin`}):c(B,{className:`h-4 w-4`})}):c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:c(L,{className:`h-4 w-4`})}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),f.mutate({faceId:e.faceId},{onSettled:p})},disabled:f.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:f.isPending?c(Z,{className:`h-4 w-4 animate-spin`}):c(be,{className:`h-4 w-4`})})]})]})}var Wt=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function Gt(){let e=o(),[t,n]=s(`all`),[l,u]=s(ce),[d,f]=s(new Set),[p,m]=s(new Set),[h,g]=s(null),[_,y]=s(!1),[x,S]=s(null),{data:C,isLoading:w}=O({limit:Vt,filter:t,includeCrops:!1},{refetchInterval:3e4}),{data:E=[]}=te(),{data:D}=b({isCamera:!0,projection:`slim`},{staleTime:3e4}),j=A(),M=ee(),N=k(),P=T(),F=Date.now(),I=C??[],R=i(()=>{let e=new Map;for(let t of D??[])e.set(t.id,t.name);return e},[D]),z=e=>R.get(e)??`Camera #${String(e)}`,V=i(()=>H(I).map(e=>({id:e,name:z(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[I,R]),U=i(()=>ie(ue(I,l),d),[I,l,d]),G=ae(U,Ht,i(()=>JSON.stringify([t,l.fromMs,l.toMs,[...d].sort((e,t)=>e-t)]),[t,l.fromMs,l.toMs,d])),oe=i(()=>new Map(I.map(e=>[e.faceId,e])),[I]),le=i(()=>gt(U),[U]),de=x===null?null:oe.get(x)??null,K=()=>{e.invalidateQueries({queryKey:Bt})},q=()=>m(new Set);function fe(e){m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){m(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(ht(U))}let J=[...p],Y=j.isPending||N.isPending||P.isPending,he=M.isPending||P.isPending;function ge(){J.length!==0&&N.mutate({faceIds:J},{onSettled:()=>{K(),q()}})}function ve(){J.length!==0&&Promise.allSettled(J.map(e=>P.mutateAsync({faceId:e}))).then(()=>{K(),q()})}function ye(e){S(null),g([e])}function xe(e){M.mutate({faceId:e},{onSettled:K}),S(null)}function Se(e){P.mutate({faceId:e},{onSettled:K}),S(null)}let Ce=U.length!==I.length;return r(`div`,{className:`relative space-y-3`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c(`div`,{className:`flex items-center gap-1`,children:Wt.map(e=>c(`button`,{type:`button`,onClick:()=>n(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),c(se,{onChange:u}),c(re,{cameras:V,selected:d,onChange:f}),r(`button`,{type:`button`,onClick:()=>y(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${_?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(_e,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!w&&le>0&&r(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[c(W,{className:`h-3.5 w-3.5`}),` Select `,le,` crop-less`]}),!w&&c(`span`,{className:`text-[10px] text-foreground-subtle ${le>0?`ml-2`:`ml-auto`}`,children:Ce?`${String(U.length)} of ${String(I.length)} faces`:`${String(U.length)} face${U.length===1?``:`s`}`})]}),p.size>0&&r(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:[p.size,` selected`]}),r(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[r(v,{variant:`primary`,onClick:()=>g(J),disabled:Y,children:[c(L,{className:`h-3.5 w-3.5`}),` Assign`]}),r(v,{variant:`secondary`,onClick:ge,disabled:Y,children:[N.isPending?c(Z,{className:`h-3.5 w-3.5 animate-spin`}):c(B,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),r(v,{variant:`secondary`,onClick:ve,disabled:Y,children:[c(be,{className:`h-3.5 w-3.5`}),` Delete`]}),c(v,{variant:`ghost`,onClick:q,disabled:Y,children:c(X,{className:`h-3.5 w-3.5`})})]})]}),w&&r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(Z,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!w&&U.length===0&&c(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:I.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!w&&U.length>0&&r(a,{children:[c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:G.pageItems.map(e=>c(Ut,{face:e,cameraName:z(e.deviceId),nowMs:F,selected:p.has(e.faceId),onToggleSelect:fe,onAssign:e=>g([e]),onOpenDetail:S},e.faceId))}),c(ne,{currentPage:G.page,totalItems:G.totalItems,pageSize:G.pageSize,onPageChange:G.setPage,itemNoun:`faces`})]}),c(wt,{face:de,cameraName:de?z(de.deviceId):``,onClose:()=>S(null),onAssign:ye,onUnassign:xe,onDelete:Se,actionsPending:he}),c(yt,{faceIds:h,identities:E,onDone:()=>{g(null),q()}}),c(zt,{open:_,onClose:()=>y(!1),byId:oe,cameraName:z,nowMs:F,identities:E,selectMany:pe})]})}n();var Kt=[[`faceGallery`]],qt=2e3;function Jt(){let e=o(),n=t(e);n.current=e;let r=t(void 0);r.current||=le({delayMs:qt,invalidate:()=>{n.current.invalidateQueries({queryKey:Kt})}}),l(()=>()=>r.current?.cancel(),[]),_(F.PipelineAnalyticsFaceGalleryChanged,()=>{r.current?.trigger()})}function Yt(){return Jt(),c(Se,{icon:ge,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:r(`section`,{className:`space-y-3`,children:[r(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),c(pt,{})]}),r(`div`,{className:`pt-4 border-t border-border`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),c(Gt,{})]})]})})}export{Yt as DetectionIntelligencePage};
|
package/dist/assets/{DeviceAggregateSection-B-LbbxBn.js → DeviceAggregateSection-nls0vMuB.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,o as a,q 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-DhP-Lgiq.js";import{Lr as c,Rr as l,Xo as u,Zo as d,ei as f,qr as p,ti as m}from"./src-
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,o as a,q 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-DhP-Lgiq.js";import{Lr as c,Rr as l,Xo as u,Zo as d,ei as f,qr as p,ti as m}from"./src-Ch7OV9gF.js";import{Ft as h}from"./src-MgTxcsw3.js";import{t as g}from"./FormBuilder-CR7w8Uea.js";import{r as _,w as v}from"./index-BAEd1ERX.js";import{n as y,r as b,t as x}from"./SchemaTabBar-DC28nb9j.js";import{t as S}from"./StableTabPanel-Dc954AQl.js";n();function C({schema:e,values:t,pendingKeys:n,onChange:a,onAction:c,onSave:l,onDiscard:u,disabled:d,activeSubTab:f,onSubTabChange:p,flattenTabs:m=!1,deviceId:h}){let _=e.tabs??[],v=i(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),b=new Set(_.map(e=>e.id)),C=[..._,...[...v.keys()].filter(e=>!b.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],w=C[0]?.id??`general`,[T,E]=o(w),D=p!==void 0,O=new Set(C.map(e=>e.id)),k=D?f&&O.has(f)?f:w:O.has(T)?T:w,A=e=>{D?p(e):E(e)},j=v.get(k)??[],M={sections:j.length<=1?j.length===1?[{...j[0],title:``}]:j:j.every(e=>!e.title)?[{...j[0],title:``,fields:j.flatMap(e=>e.fields)}]:j},N=s(y,{pendingCount:n.length,onSave:()=>l(n),onDiscard:()=>u(n),saving:d});if(m||C.length<=1)return r(`div`,{className:`flex flex-col gap-3`,children:[s(g,{schema:e,values:t,onChange:a,onAction:c,disabled:d,deviceId:h}),N]});let P=new Map,F=new Map;for(let[e,t]of v){P.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&F.set(e,a)}return r(`div`,{className:`flex flex-col gap-3`,children:[s(x,{tabs:C.map(e=>({id:e.id,label:e.label})),activeId:k,onChange:A,countByTab:P,pendingByTab:F}),s(S,{tabKey:k,children:s(g,{schema:M,values:t,onChange:a,onAction:c,disabled:d,deviceId:h})}),N]})}var w=`device-export`,T=`export`,E=`Export`;function D(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(D):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(D)):e.writerCapName===w}function O(e){return e.tab===`export`?!0:e.fields.some(D)}n();function k(e,t){return t&&t===`admin`?e:!0}function A(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?O(e)&&O(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function j(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`}function M(e){return e.key}function N(e){if(!j(e))return e.value}function P(e){return j(e)?null:e}function F(e,t){for(let n of e)if(t(n),n.type===`group`)F(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)F(e.fields,t)}function I(e){if(!e)return{};let t={};for(let n of e.sections)F(n.fields,e=>{let n=M(e);n!==null&&(t[n]=N(e))});return t}function L(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(F(r.fields,e=>{if(n!==null||M(e)!==t)return;let r=P(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function R(e){return{...e,fields:e.fields.map(z)}}function z(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function B(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=P(e);return n?k(t,n.minRole)?e:z(e):e})}))}}function V({deviceId:n,sectionFilter:o,activeSubTab:g,onSubTabChange:y,flattenSubTabs:x,subTabGrouping:S}){let w=a(),{user:T}=_(),E=T?.isAdmin===!0,D=t(!1),{data:k,isLoading:j}=l({deviceId:n},{refetchInterval:()=>D.current?!1:2500,enabled:Number.isFinite(n)}),{data:M}=c({deviceId:n},{enabled:Number.isFinite(n)}),N=k?.settings??null,P=k?.live??null,F=i(()=>{if(!N&&!P)return null;let e=N?.sections??[],t=(P?.sections??[]).map(R),n=[...e,...t],r=o?n.filter(o):n.filter(e=>e.location!==`top-tab`&&!O(e));if(r.length===0)return null;if(S){let e=r.map(e=>({...e,tab:S.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=S.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let i=new Set;for(let e of r)i.add(e.tab??`general`);let a=[...N?.tabs??[],...(P?.tabs??[]).filter(e=>!(N?.tabs??[]).some(t=>t.id===e.id))].filter(e=>i.has(e.id));return a.length>0?{tabs:a,sections:r}:{sections:r}},[N,P,o,S]),z=i(()=>A(F),[F]),V=i(()=>B(z,E),[z,E]),H=i(()=>I(V),[V]),U=d(),W=u(),G=f(),K=p(),q=m({onSuccess:()=>{w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),J={isPending:q.isPending,mutate:e=>{q.mutate({deviceId:n,changes:[...e]})}},Y=b({schema:V,serverValues:H,onImmediateSave:e(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J]),onDeferredSave:e(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J])}),{values:X,pendingKeys:Z,handleChange:Q,handleSave:$,handleDiscard:ee}=Y;if(D.current=Y.editingPaused,j)return r(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[s(v,{className:`h-4 w-4 animate-spin mr-2`}),s(`span`,{className:`text-xs`,children:`Loading device aggregate…`})]});if(!V||V.sections.length===0)return s(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:`No aggregate contributions for this device.`});async function te(e,t,r){if(e===`regenerate-rtsp-token`){let e=[`rtspUrl:`,`regenerateToken:`].find(e=>t.startsWith(e));if(!e)throw Error(`regenerate-rtsp-token: unrecognised key "${t}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let r=t.slice(e.length);if(!r)throw Error(`regenerate-rtsp-token: key "${t}" has no streamId after prefix`);let i=h(n,r);await U.mutateAsync({brokerId:i}),w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(e===`test-probe`){if(!M)return{status:`error`,error:`Device metadata not loaded yet`};try{return await G.mutateAsync({addonId:M.addonId,type:M.type,key:t,value:r})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(e===`refresh-probe`){if(!t.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${t}" (expected "probedInfo:<streamId>")`);let e=t.slice(11);if(!e)throw Error(`refresh-probe: key "${t}" has no streamId after prefix`);let r=h(n,e),i=await W.mutateAsync({brokerId:r});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(e===`device-custom-action`){let e=await K.mutateAsync({deviceId:n,action:t,input:r});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),e}throw Error(`[device-aggregate] unknown action "${e}"`)}return s(C,{schema:V,values:X,pendingKeys:Z,onChange:Q,onAction:te,onSave:$,onDiscard:ee,disabled:J.isPending,activeSubTab:g,onSubTabChange:y,flattenTabs:x,deviceId:n})}export{O as i,T as n,E as r,V as t};
|