@camstack/addon-admin-ui 1.2.728 → 1.2.730

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/assets/{AccessSection-fW6dmRnn.js → AccessSection-B1EXK7rD.js} +1 -1
  3. package/dist/assets/{Addons-CVWHgqG3.js → Addons-aZ-9NJA0.js} +1 -1
  4. package/dist/assets/{AdminPage-fevCJmVh.js → AdminPage-DHeoR4Te.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-D4DeupV0.js → AdminSectionedPage-D8MhmCco.js} +1 -1
  6. package/dist/assets/{AiProfiles-r6CPaBVS.js → AiProfiles-ByV27rXT.js} +1 -1
  7. package/dist/assets/{Archive-Cr4NQu4m.js → Archive-DaNobRfy.js} +1 -1
  8. package/dist/assets/{BootstrapSettingsForm-X-tZwGIg.js → BootstrapSettingsForm-B3k1NMVt.js} +1 -1
  9. package/dist/assets/{Build-DOIIWG1k.js → Build-PD2EGJj1.js} +4 -4
  10. package/dist/assets/{Calendars-CPOSocza.js → Calendars-Cs8b4Njz.js} +1 -1
  11. package/dist/assets/{Cluster-B60LJAof.js → Cluster-CMG3ACDU.js} +1 -1
  12. package/dist/assets/{CompositionBlockEditor-DPKbpSuE.js → CompositionBlockEditor-DtcQZA1P.js} +1 -1
  13. package/dist/assets/{CompositionEditorPage-DqUx1Svq.js → CompositionEditorPage-CPO3UIOo.js} +1 -1
  14. package/dist/assets/{Data-Ba0hIx9z.js → Data-BPf3SvZI.js} +1 -1
  15. package/dist/assets/{DeviceDetail-B7Zg3T4I.js → DeviceDetail-C-RrmSrD.js} +1 -1
  16. package/dist/assets/{Devices-CMZ7LCj5.js → Devices-wf06h1QP.js} +1 -1
  17. package/dist/assets/{EmbedDevicePage-BYQacUxi.js → EmbedDevicePage-bd0SkXxb.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-DrdAbrri.js → EmbedPlayerPage-DfV4R0cS.js} +1 -1
  19. package/dist/assets/History-DDm7cp6d.js +1 -0
  20. package/dist/assets/{Identity-iCopusSn.js → Identity-RtZzaQWR.js} +1 -1
  21. package/dist/assets/{InstancesTable-BcyxK5Cl.js → InstancesTable-BnPEdozL.js} +1 -1
  22. package/dist/assets/{IntegrationDetail-DRiFFHo4.js → IntegrationDetail-DBc1TS2S.js} +1 -1
  23. package/dist/assets/{Integrations-DZKq4p7U.js → Integrations-B8iqFjPQ.js} +1 -1
  24. package/dist/assets/{Integrations-DxstFlUA.js → Integrations-CwuKcixt.js} +1 -1
  25. package/dist/assets/{Library-Bz__2eFv.js → Library-O7AC9-kS.js} +1 -1
  26. package/dist/assets/{Locations-BTUB79la.js → Locations-D5_O9BvE.js} +1 -1
  27. package/dist/assets/{Logs-DutaKF3j.js → Logs-S2R2w5jF.js} +1 -1
  28. package/dist/assets/{MyAccess-B-j3XJth.js → MyAccess-DLxW29OY.js} +1 -1
  29. package/dist/assets/{Network-BcqiB4l2.js → Network-C-y518HB.js} +1 -1
  30. package/dist/assets/{NewExportModal-DPJu2Qsj.js → NewExportModal-Bwf_9qsO.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-DLhrPwrf.js → NodeAddonsSettingsPanel-DAwXWjiM.js} +1 -1
  32. package/dist/assets/{Notifications-B-PXWcN0.js → Notifications-Dq9Syu1M.js} +1 -1
  33. package/dist/assets/{Pipeline-PN2eMlBG.js → Pipeline-BruZh9t_.js} +1 -1
  34. package/dist/assets/{SessionsList-DQWVLdQv.js → SessionsList-CxsmPls3.js} +1 -1
  35. package/dist/assets/{Showroom-DI-zhGj-.js → Showroom-lwY9_rJE.js} +1 -1
  36. package/dist/assets/{StorageLocationsTable-DlOZCMRY.js → StorageLocationsTable-BPB9dZHm.js} +1 -1
  37. package/dist/assets/{System-187qYqYk.js → System-B8pQ8Blt.js} +1 -1
  38. package/dist/assets/{TemplateEditorDialog-BcMLkpLg.js → TemplateEditorDialog-DW9nNlCP.js} +1 -1
  39. package/dist/assets/{Terminal--MG5XN8r.js → Terminal-1WY7UYdT.js} +1 -1
  40. package/dist/assets/{TrainingProviders-DYtuyaUc.js → TrainingProviders-DL7KqBOh.js} +1 -1
  41. package/dist/assets/{Viewer-BFqv2KTn.js → Viewer-DWnz0jPx.js} +1 -1
  42. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-KMcCSeat.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-gwJGNmwB.js} +1 -1
  43. package/dist/assets/{ai-page.helpers-CwG2lNNM.js → ai-page.helpers-Blv8vMMO.js} +1 -1
  44. package/dist/assets/{assignment-candidates-CdokBQeA.js → assignment-candidates-T_qtiyRY.js} +1 -1
  45. package/dist/assets/{authed-media-DHva9b0l.js → authed-media-DWIrwQX4.js} +1 -1
  46. package/dist/assets/{board-model-BsNkJMbQ.js → board-model-BqT-K9_t.js} +1 -1
  47. package/dist/assets/{device-integration-icon-lMKyNXQ9.js → device-integration-icon-Ut-wvt9c.js} +1 -1
  48. package/dist/assets/device-picker-model-CY5TnxB2.js +1 -0
  49. package/dist/assets/{format-CLPihZvL.js → format-WGDeViun.js} +1 -1
  50. package/dist/assets/{hostInit-MQZuDlvV.js → hostInit-iNhMh4HT.js} +1 -1
  51. package/dist/assets/i18n-BJW4xO62.js +1 -0
  52. package/dist/assets/{index-BeyJSXZT.js → index-BB_RagyI.js} +5 -5
  53. package/dist/assets/{index-DLoh28hg.css → index-DKr9ed1W.css} +1 -1
  54. package/dist/assets/{linked-devices-model--I1EiM0r.js → linked-devices-model-BcRQm3Dk.js} +1 -1
  55. package/dist/assets/{mf-entry-bootstrap-0-911e33b5.js → mf-entry-bootstrap-0-ec4ea4da.js} +2 -2
  56. package/dist/assets/mount-CY5TnxB2.js +1 -0
  57. package/dist/assets/{notification-rule-status-hb9jdt7P.js → notification-rule-status-BNvwbSsv.js} +1 -1
  58. package/dist/assets/remoteEntry-m2OhoiQ_.js +1 -0
  59. package/dist/assets/src-BHZH54iC.js +279 -0
  60. package/dist/assets/{sso-popup-CC_ZFBGO.js → sso-popup-T48MTk3R.js} +1 -1
  61. package/dist/assets/{step-inspector-model-DwK8gatr.js → step-inspector-model-MK6_JfbJ.js} +1 -1
  62. package/dist/assets/{use-scenes-feed-D7xlQUFj.js → use-scenes-feed-mgAkC_s4.js} +1 -1
  63. package/dist/assets/{useAdminDeviceRemoval-JSKfbRFC.js → useAdminDeviceRemoval-xgOGcCkU.js} +1 -1
  64. package/dist/assets/{useDevice-CbDkHbCR.js → useDevice-DE-k4Bup.js} +1 -1
  65. package/dist/assets/useEventInvalidation-CY5TnxB2.js +1 -0
  66. package/dist/assets/{useFaultTypeOptions-C0o6UICy.js → useFaultTypeOptions-DpuTZyuA.js} +1 -1
  67. package/dist/assets/{useNodeUrlSelection-BCTRzpjJ.js → useNodeUrlSelection-D77cegya.js} +1 -1
  68. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DRFyxqEq.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-tnWbYyCF.js} +2 -2
  69. package/dist/index.html +8 -8
  70. package/dist/server/addon.js +1 -1
  71. package/package.json +2 -2
  72. package/dist/assets/History-C9CXoWTK.js +0 -1
  73. package/dist/assets/device-picker-model-BqDPaEks.js +0 -1
  74. package/dist/assets/i18n-CtibbGCl.js +0 -1
  75. package/dist/assets/mount-BqDPaEks.js +0 -1
  76. package/dist/assets/remoteEntry-BM46eEaY.js +0 -1
  77. package/dist/assets/src-DXJ8BQFl.js +0 -279
  78. package/dist/assets/useEventInvalidation-BqDPaEks.js +0 -1
@@ -1 +1 @@
1
- import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{_i as s,ca as c,ft as l,la as u,ma as d,sa as f,to as p}from"./player-overlays-Cp7Gj5VT.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{$i as h,Ap as g,Rp as _,Xi as v,Yi as y,Zi as b,cc as x,ea as S,nf as C,ta as w}from"./src-DXJ8BQFl.js";import{t as T}from"./i18n-CtibbGCl.js";import{t as E}from"./useTranslation-BJr-n0es.js";function D(e){let{delayMs:t,invalidate:n,setTimeoutFn:r=setTimeout,clearTimeoutFn:i=clearTimeout}=e,a;function o(){a===void 0&&(a=r(()=>{a=void 0,n()},t))}function s(){a!==void 0&&(i(a),a=void 0)}return{trigger:o,cancel:s}}o();function O({cameras:n,selected:o,onChange:s}){let{t:c}=E(),[l,f]=a(!1),p=t(null);i(()=>{if(!l)return;function e(e){p.current&&e.target instanceof Node&&!p.current.contains(e.target)&&f(!1)}function t(e){e.key===`Escape`&&f(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]);function h(e){let t=new Set(o);t.has(e)?t.delete(e):t.add(e),s(t)}let _=o.size,v=_===0?`All cameras`:_===1?n.find(e=>o.has(e.id))?.name??`1 camera`:`${String(_)} cameras`;return e(`div`,{ref:p,className:`relative`,children:[e(g,{variant:`unstyled`,type:`button`,onClick:()=>f(e=>!e),disabled:n.length===0,className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:opacity-40 ${_>0?`border-primary/40 bg-primary/8 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(d,{className:`h-3.5 w-3.5`}),r(`span`,{className:`max-w-[10rem] truncate`,children:v}),r(m,{className:`h-3 w-3 opacity-70`})]}),l&&e(`div`,{className:`absolute left-0 z-30 mt-1 max-h-64 w-[min(15rem,calc(100vw-1.5rem))] overflow-y-auto rounded-md border border-border bg-surface p-1 shadow-lg shadow-black/30`,children:[_>0&&r(g,{variant:`unstyled`,type:`button`,onClick:()=>s(new Set),className:`mb-1 w-full rounded px-2 py-1 text-left text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:c(`detectionIntelligence.cameraMultiSelect.clearSelection`,`Clear selection`)}),n.map(t=>{let n=o.has(t.id);return e(g,{variant:`unstyled`,type:`button`,onClick:()=>h(t.id),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors ${n?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[r(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${n?`border-primary bg-primary text-white`:`border-border`}`,children:n&&r(u,{className:`h-2.5 w-2.5`})}),r(`span`,{className:`truncate`,children:t.name})]},t.id)})]})]})}var k={fromMs:null,toMs:null},A=36e5,j=24*A;function M(e,t){switch(e){case`24h`:return{fromMs:t-j,toMs:null};case`7d`:return{fromMs:t-7*j,toMs:null};case`30d`:return{fromMs:t-30*j,toMs:null};case`all`:return k}}function N(e){return e.fromMs!==null||e.toMs!==null}function P(e,t){return N(t)?e.filter(e=>!(t.fromMs!==null&&e.timestamp<t.fromMs||t.toMs!==null&&e.timestamp>t.toMs)):[...e]}function F(e,t){return t.size===0?[...e]:e.filter(e=>t.has(e.deviceId))}function I(e){let t=new Set,n=[];for(let r of e)t.has(r.deviceId)||(t.add(r.deviceId),n.push(r.deviceId));return n}function L(e){if(!e)return null;let t=Date.parse(`${e}T00:00:00`);return Number.isNaN(t)?null:t}function R(e){if(!e)return null;let t=Date.parse(`${e}T23:59:59.999`);return Number.isNaN(t)?null:t}function z(e,t){if(!Number.isFinite(e)||e<=0)return`—`;let n=t-e;return n<6e4?T.t(`helpers.relativeTime.justNow`):n<A?T.t(`helpers.relativeTime.minutesAgo`,{count:Math.floor(n/6e4)}):n<j?T.t(`helpers.relativeTime.hoursAgo`,{count:Math.floor(n/A)}):n<7*j?T.t(`helpers.relativeTime.daysAgo`,{count:Math.floor(n/j)}):new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function B(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function V(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}o();var H=[{label:`24h`,value:`24h`},{label:`7d`,value:`7d`},{label:`30d`,value:`30d`},{labelKey:`common.all`,value:`all`}];function U({onChange:t}){let{t:n}=E(),[i,o]=a(`all`),[s,c]=a(``),[l,u]=a(``);function d(e){o(e),c(``),u(``),t(M(e,Date.now()))}function f(e,n){o(`custom`),c(e),u(n),t({fromMs:L(e),toMs:R(n)})}let p=`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground outline-none focus:border-primary [color-scheme:light] dark:[color-scheme:dark]`;return e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:H.map(e=>r(g,{variant:`unstyled`,type:`button`,onClick:()=>d(e.value),className:`rounded px-2.5 py-1 text-[11px] transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.labelKey===void 0?e.label:n(e.labelKey)},e.value))}),e(`div`,{className:`flex items-center gap-1`,children:[r(_,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.fromDate`,`From date`),value:s,max:l||void 0,onChange:e=>f(e.target.value,l),className:`${p} ${i===`custom`&&s?`border-primary/50`:``}`}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:`→`}),r(_,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.toDate`,`To date`),value:l,min:s||void 0,onChange:e=>f(s,e.target.value),className:`${p} ${i===`custom`&&l?`border-primary/50`:``}`})]})]})}o();var W=2.6;function G({src:t,alt:n,className:o,overlay:s,fit:c=`contain`}){let[l,u]=a(!1),[d,f]=a(`50% 50%`);i(()=>{u(!1),f(`50% 50%`)},[t]);function p(e){if(!l){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*100,r=(e.clientY-t.top)/t.height*100;f(`${String(n)}% ${String(r)}%`)}u(e=>!e)}let m=c===`natural`;return r(`div`,{className:`relative overflow-hidden bg-background ${o??``}`,onClick:p,children:e(`div`,{className:`relative select-none transition-transform duration-200 ease-out ${m?`w-full`:`h-full w-full`} ${l?`cursor-zoom-out`:`cursor-zoom-in`}`,style:{transformOrigin:d,transform:l?`scale(${String(W)})`:`scale(1)`},children:[r(`img`,{src:t,alt:n,draggable:!1,className:m?`block h-auto w-full object-contain`:`h-full w-full object-contain`}),s]})})}var K=2;function q(e,t){if(t<=1)return[{kind:`page`,n:1}];if(t<=7){let e=[];for(let n=1;n<=t;n++)e.push({kind:`page`,n});return e}let n=[],r=Math.max(2,e-K),i=Math.min(t-1,e+K);n.push({kind:`page`,n:1}),r>2&&n.push({kind:`ellipsis`,side:`left`});for(let e=r;e<=i;e++)n.push({kind:`page`,n:e});return i<t-1&&n.push({kind:`ellipsis`,side:`right`}),n.push({kind:`page`,n:t}),n}function J({currentPage:t,totalItems:n,pageSize:i,onPageChange:a,itemNoun:o=`items`}){let{t:s}=E();if(n<=i)return null;let l=Math.ceil(n/i),u=(t-1)*i+1,d=Math.min(t*i,n),p=q(t,l),m=`inline-flex h-7 min-w-7 items-center justify-center rounded-md px-2 text-[11px] transition-colors disabled:opacity-40`;return e(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:s(`galleryPager.showing`,{from:u,to:d,total:n,noun:o})}),e(`div`,{className:`flex items-center gap-1`,children:[r(g,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t-1),disabled:t<=1,"aria-label":s(`galleryPager.previousPage`,`Previous page`),children:r(c,{className:`h-3.5 w-3.5`})}),p.map(e=>e.kind===`ellipsis`?r(`span`,{className:`px-1 opacity-60`,children:`…`},`ellipsis-${e.side}`):r(g,{variant:`unstyled`,type:`button`,className:`${m} ${e.n===t?`bg-primary/12 text-primary font-medium`:`hover:bg-surface-hover hover:text-foreground`}`,onClick:()=>a(e.n),"aria-current":e.n===t?`page`:void 0,children:e.n},e.n)),r(g,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t+1),disabled:t>=l,"aria-label":s(`galleryPager.nextPage`,`Next page`),children:r(f,{className:`h-3.5 w-3.5`})})]})]})}o();function Y(e,t,r){let[o,s]=a(1);i(()=>{s(1)},[r]);let c=e.length,l=Math.max(1,Math.ceil(c/t)),u=Math.min(o,l);return i(()=>{u!==o&&s(u)},[u,o]),{page:u,setPage:s,pageItems:n(()=>{let n=(u-1)*t;return e.slice(n,n+t)},[e,u,t]),totalPages:l,totalItems:c,pageSize:t}}o();var X=[`high`,`mid`,`low`],Z=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ee=10080*60*1e3;function Q(e){return $(Date.now()-e*6e4)}function $(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function te({onClose:t,onCreated:i,initialDeviceId:o,initialRange:c}){let{t:u}=E(),d=x({isCamera:!0,projection:`slim`}),f=n(()=>(d.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[d.data]),[m,T]=a(o??``),[D,O]=a(`high`),[k,A]=a(c===void 0?Q(60):$(c.fromMs)),[j,M]=a(c===void 0?Q(0):$(c.toMs)),[N,P]=a(1),[F,I]=a(!0),[L,R]=a(``),[z,B]=a(null),V=m===``?f[0]?.id??null:m,H=new Date(k).getTime(),U=new Date(j).getTime(),W=Number.isFinite(H)&&Number.isFinite(U)&&H<U,G=C({onSuccess:()=>{i(),t()},onError:e=>B(e instanceof Error?e.message:String(e))});return r(y,{open:!0,onOpenChange:e=>!e&&t(),children:e(b,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(S,{children:e(w,{className:`flex items-center gap-1.5`,children:[r(s,{className:`h-3.5 w-3.5`}),u(`recordings.newExportModal.newExport`,`New export`)]})}),e(v,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.camera`,`Camera`)}),r(l,{value:V??``,onChange:e=>T(Number(e.target.value)),className:`w-full`,children:f.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.profile`,`Profile`)}),r(l,{value:D,onChange:e=>O(e.target.value),className:`w-full`,children:X.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.from`,`From`)}),r(_,{type:`datetime-local`,value:k,onChange:e=>A(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.to`,`To`)}),r(_,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.speed`,`Speed`)}),r(l,{value:N,onChange:e=>P(Number(e.target.value)),className:`w-full`,children:Z.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:u(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(_,{type:`text`,value:L,onChange:e=>R(e.target.value),placeholder:u(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(p,{checked:F,disabled:N!==1,onChange:e=>I(e.target.checked),className:`accent-primary`}),u(N===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!W&&r(`p`,{className:`text-[11px] text-danger`,children:u(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),z&&r(`p`,{className:`text-[11px] text-danger`,children:z})]}),e(h,{children:[r(g,{variant:`outline`,size:`sm`,onClick:t,children:u(`common.cancel`,`Cancel`)}),r(g,{size:`sm`,onClick:()=>{if(V===null||!W)return;B(null);let e=L.trim();G.mutate({deviceId:V,profile:D,fromMs:H,toMs:U,options:{includeAudio:F,maxLifeMs:ee,deleteAfterDownload:!1,...N===1?{}:{speed:N},...e.length>0?{title:e}:{}}})},disabled:V===null||!W||G.isPending,children:G.isPending?u(`recordings.newExportModal.queuing`,`Queuing…`):u(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}export{U as a,F as c,z as d,V as f,G as i,P as l,D as m,Y as n,k as o,O as p,J as r,I as s,te as t,B as u};
1
+ import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{_i as s,ca as c,ft as l,la as u,ma as d,sa as f,to as p}from"./player-overlays-Cp7Gj5VT.js";import{t as m}from"./chevron-down-CBb-F8DT.js";import{$i as h,Ap as g,Rp as _,Xi as v,Yi as y,Zi as b,cc as x,ea as S,nf as C,ta as w}from"./src-BHZH54iC.js";import{t as T}from"./i18n-BJW4xO62.js";import{t as E}from"./useTranslation-BJr-n0es.js";function D(e){let{delayMs:t,invalidate:n,setTimeoutFn:r=setTimeout,clearTimeoutFn:i=clearTimeout}=e,a;function o(){a===void 0&&(a=r(()=>{a=void 0,n()},t))}function s(){a!==void 0&&(i(a),a=void 0)}return{trigger:o,cancel:s}}o();function O({cameras:n,selected:o,onChange:s}){let{t:c}=E(),[l,f]=a(!1),p=t(null);i(()=>{if(!l)return;function e(e){p.current&&e.target instanceof Node&&!p.current.contains(e.target)&&f(!1)}function t(e){e.key===`Escape`&&f(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]);function h(e){let t=new Set(o);t.has(e)?t.delete(e):t.add(e),s(t)}let _=o.size,v=_===0?`All cameras`:_===1?n.find(e=>o.has(e.id))?.name??`1 camera`:`${String(_)} cameras`;return e(`div`,{ref:p,className:`relative`,children:[e(g,{variant:`unstyled`,type:`button`,onClick:()=>f(e=>!e),disabled:n.length===0,className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:opacity-40 ${_>0?`border-primary/40 bg-primary/8 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(d,{className:`h-3.5 w-3.5`}),r(`span`,{className:`max-w-[10rem] truncate`,children:v}),r(m,{className:`h-3 w-3 opacity-70`})]}),l&&e(`div`,{className:`absolute left-0 z-30 mt-1 max-h-64 w-[min(15rem,calc(100vw-1.5rem))] overflow-y-auto rounded-md border border-border bg-surface p-1 shadow-lg shadow-black/30`,children:[_>0&&r(g,{variant:`unstyled`,type:`button`,onClick:()=>s(new Set),className:`mb-1 w-full rounded px-2 py-1 text-left text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:c(`detectionIntelligence.cameraMultiSelect.clearSelection`,`Clear selection`)}),n.map(t=>{let n=o.has(t.id);return e(g,{variant:`unstyled`,type:`button`,onClick:()=>h(t.id),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors ${n?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[r(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${n?`border-primary bg-primary text-white`:`border-border`}`,children:n&&r(u,{className:`h-2.5 w-2.5`})}),r(`span`,{className:`truncate`,children:t.name})]},t.id)})]})]})}var k={fromMs:null,toMs:null},A=36e5,j=24*A;function M(e,t){switch(e){case`24h`:return{fromMs:t-j,toMs:null};case`7d`:return{fromMs:t-7*j,toMs:null};case`30d`:return{fromMs:t-30*j,toMs:null};case`all`:return k}}function N(e){return e.fromMs!==null||e.toMs!==null}function P(e,t){return N(t)?e.filter(e=>!(t.fromMs!==null&&e.timestamp<t.fromMs||t.toMs!==null&&e.timestamp>t.toMs)):[...e]}function F(e,t){return t.size===0?[...e]:e.filter(e=>t.has(e.deviceId))}function I(e){let t=new Set,n=[];for(let r of e)t.has(r.deviceId)||(t.add(r.deviceId),n.push(r.deviceId));return n}function L(e){if(!e)return null;let t=Date.parse(`${e}T00:00:00`);return Number.isNaN(t)?null:t}function R(e){if(!e)return null;let t=Date.parse(`${e}T23:59:59.999`);return Number.isNaN(t)?null:t}function z(e,t){if(!Number.isFinite(e)||e<=0)return`—`;let n=t-e;return n<6e4?T.t(`helpers.relativeTime.justNow`):n<A?T.t(`helpers.relativeTime.minutesAgo`,{count:Math.floor(n/6e4)}):n<j?T.t(`helpers.relativeTime.hoursAgo`,{count:Math.floor(n/A)}):n<7*j?T.t(`helpers.relativeTime.daysAgo`,{count:Math.floor(n/j)}):new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function B(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function V(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}o();var H=[{label:`24h`,value:`24h`},{label:`7d`,value:`7d`},{label:`30d`,value:`30d`},{labelKey:`common.all`,value:`all`}];function U({onChange:t}){let{t:n}=E(),[i,o]=a(`all`),[s,c]=a(``),[l,u]=a(``);function d(e){o(e),c(``),u(``),t(M(e,Date.now()))}function f(e,n){o(`custom`),c(e),u(n),t({fromMs:L(e),toMs:R(n)})}let p=`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground outline-none focus:border-primary [color-scheme:light] dark:[color-scheme:dark]`;return e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:H.map(e=>r(g,{variant:`unstyled`,type:`button`,onClick:()=>d(e.value),className:`rounded px-2.5 py-1 text-[11px] transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.labelKey===void 0?e.label:n(e.labelKey)},e.value))}),e(`div`,{className:`flex items-center gap-1`,children:[r(_,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.fromDate`,`From date`),value:s,max:l||void 0,onChange:e=>f(e.target.value,l),className:`${p} ${i===`custom`&&s?`border-primary/50`:``}`}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:`→`}),r(_,{type:`date`,"aria-label":n(`detectionIntelligence.dateRangeFilter.toDate`,`To date`),value:l,min:s||void 0,onChange:e=>f(s,e.target.value),className:`${p} ${i===`custom`&&l?`border-primary/50`:``}`})]})]})}o();var W=2.6;function G({src:t,alt:n,className:o,overlay:s,fit:c=`contain`}){let[l,u]=a(!1),[d,f]=a(`50% 50%`);i(()=>{u(!1),f(`50% 50%`)},[t]);function p(e){if(!l){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*100,r=(e.clientY-t.top)/t.height*100;f(`${String(n)}% ${String(r)}%`)}u(e=>!e)}let m=c===`natural`;return r(`div`,{className:`relative overflow-hidden bg-background ${o??``}`,onClick:p,children:e(`div`,{className:`relative select-none transition-transform duration-200 ease-out ${m?`w-full`:`h-full w-full`} ${l?`cursor-zoom-out`:`cursor-zoom-in`}`,style:{transformOrigin:d,transform:l?`scale(${String(W)})`:`scale(1)`},children:[r(`img`,{src:t,alt:n,draggable:!1,className:m?`block h-auto w-full object-contain`:`h-full w-full object-contain`}),s]})})}var K=2;function q(e,t){if(t<=1)return[{kind:`page`,n:1}];if(t<=7){let e=[];for(let n=1;n<=t;n++)e.push({kind:`page`,n});return e}let n=[],r=Math.max(2,e-K),i=Math.min(t-1,e+K);n.push({kind:`page`,n:1}),r>2&&n.push({kind:`ellipsis`,side:`left`});for(let e=r;e<=i;e++)n.push({kind:`page`,n:e});return i<t-1&&n.push({kind:`ellipsis`,side:`right`}),n.push({kind:`page`,n:t}),n}function J({currentPage:t,totalItems:n,pageSize:i,onPageChange:a,itemNoun:o=`items`}){let{t:s}=E();if(n<=i)return null;let l=Math.ceil(n/i),u=(t-1)*i+1,d=Math.min(t*i,n),p=q(t,l),m=`inline-flex h-7 min-w-7 items-center justify-center rounded-md px-2 text-[11px] transition-colors disabled:opacity-40`;return e(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:s(`galleryPager.showing`,{from:u,to:d,total:n,noun:o})}),e(`div`,{className:`flex items-center gap-1`,children:[r(g,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t-1),disabled:t<=1,"aria-label":s(`galleryPager.previousPage`,`Previous page`),children:r(c,{className:`h-3.5 w-3.5`})}),p.map(e=>e.kind===`ellipsis`?r(`span`,{className:`px-1 opacity-60`,children:`…`},`ellipsis-${e.side}`):r(g,{variant:`unstyled`,type:`button`,className:`${m} ${e.n===t?`bg-primary/12 text-primary font-medium`:`hover:bg-surface-hover hover:text-foreground`}`,onClick:()=>a(e.n),"aria-current":e.n===t?`page`:void 0,children:e.n},e.n)),r(g,{variant:`unstyled`,type:`button`,className:`${m} hover:bg-surface-hover`,onClick:()=>a(t+1),disabled:t>=l,"aria-label":s(`galleryPager.nextPage`,`Next page`),children:r(f,{className:`h-3.5 w-3.5`})})]})]})}o();function Y(e,t,r){let[o,s]=a(1);i(()=>{s(1)},[r]);let c=e.length,l=Math.max(1,Math.ceil(c/t)),u=Math.min(o,l);return i(()=>{u!==o&&s(u)},[u,o]),{page:u,setPage:s,pageItems:n(()=>{let n=(u-1)*t;return e.slice(n,n+t)},[e,u,t]),totalPages:l,totalItems:c,pageSize:t}}o();var X=[`high`,`mid`,`low`],Z=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ee=10080*60*1e3;function Q(e){return $(Date.now()-e*6e4)}function $(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function te({onClose:t,onCreated:i,initialDeviceId:o,initialRange:c}){let{t:u}=E(),d=x({isCamera:!0,projection:`slim`}),f=n(()=>(d.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[d.data]),[m,T]=a(o??``),[D,O]=a(`high`),[k,A]=a(c===void 0?Q(60):$(c.fromMs)),[j,M]=a(c===void 0?Q(0):$(c.toMs)),[N,P]=a(1),[F,I]=a(!0),[L,R]=a(``),[z,B]=a(null),V=m===``?f[0]?.id??null:m,H=new Date(k).getTime(),U=new Date(j).getTime(),W=Number.isFinite(H)&&Number.isFinite(U)&&H<U,G=C({onSuccess:()=>{i(),t()},onError:e=>B(e instanceof Error?e.message:String(e))});return r(y,{open:!0,onOpenChange:e=>!e&&t(),children:e(b,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(S,{children:e(w,{className:`flex items-center gap-1.5`,children:[r(s,{className:`h-3.5 w-3.5`}),u(`recordings.newExportModal.newExport`,`New export`)]})}),e(v,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.camera`,`Camera`)}),r(l,{value:V??``,onChange:e=>T(Number(e.target.value)),className:`w-full`,children:f.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.profile`,`Profile`)}),r(l,{value:D,onChange:e=>O(e.target.value),className:`w-full`,children:X.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.from`,`From`)}),r(_,{type:`datetime-local`,value:k,onChange:e=>A(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.to`,`To`)}),r(_,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.speed`,`Speed`)}),r(l,{value:N,onChange:e=>P(Number(e.target.value)),className:`w-full`,children:Z.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:u(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(_,{type:`text`,value:L,onChange:e=>R(e.target.value),placeholder:u(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(p,{checked:F,disabled:N!==1,onChange:e=>I(e.target.checked),className:`accent-primary`}),u(N===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!W&&r(`p`,{className:`text-[11px] text-danger`,children:u(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),z&&r(`p`,{className:`text-[11px] text-danger`,children:z})]}),e(h,{children:[r(g,{variant:`outline`,size:`sm`,onClick:t,children:u(`common.cancel`,`Cancel`)}),r(g,{size:`sm`,onClick:()=>{if(V===null||!W)return;B(null);let e=L.trim();G.mutate({deviceId:V,profile:D,fromMs:H,toMs:U,options:{includeAudio:F,maxLifeMs:ee,deleteAfterDownload:!1,...N===1?{}:{speed:N},...e.length>0?{title:e}:{}}})},disabled:V===null||!W||G.isPending,children:G.isPending?u(`recordings.newExportModal.queuing`,`Queuing…`):u(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}export{U as a,F as c,z as d,V as f,G as i,P as l,D as m,Y as n,k as o,O as p,J as r,I as s,te as t,B as u};
@@ -1 +1 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{bt as m}from"./player-overlays-Cp7Gj5VT.js";import{bl as h,yl as g}from"./src-uL_wvvFJ.js";import{Ap as _,at as v,co as y,so as b,ut as ee,vo as te,ws as ne,zo as re}from"./src-DXJ8BQFl.js";import{t as ie}from"./useTranslation-BJr-n0es.js";import{A as ae,Wt as x,j as S}from"./index-BeyJSXZT.js";import{n as oe,t as se}from"./settings-section-shape-DbQZZpNL.js";c();var C=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=S({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(x,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function ce(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function le(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function ue(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!le(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function de(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of h({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function fe(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}c();function D(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>D(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function O(e,t){return{...e,fields:e.fields.map(e=>D(e,t))}}function pe(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>O(e,t))},values:t}}function k({nodeId:a,addonIds:o,level:c,deviceId:u,capability:h,omitCapabilities:_,sectionIds:x,omitSectionIds:S,fieldKeys:C,omitFieldKeys:w,hideSectionChrome:T,tabAliases:E,tabLabelOverrides:le,sectionTab:D,fieldScope:O,emptyMessage:k,extraTabs:A,schemaTabExtras:j,title:M,description:N,selfTabbed:he,activeTab:ge,onActiveTabChange:_e}){let{t:P}=ie(),F=d(),I=m().trpcClient,ve=y(),ye=b(),be=ne(),xe=re(),L=he===!0||!!(A&&A.length>0),[Se,Ce]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let R=a??`hub`,z=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:R,deviceId:u??null,cap:h??null,omitCaps:_??null,scope:O??null,sections:[x??null,S??null]}],queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:R});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=new Set(_??[]),r=ue({declarations:t.filter(e=>!n.has(e.cap)),...O===void 0?{}:{fieldScope:O},...h===void 0?{}:{capability:h},...x===void 0?{}:{allowSectionIds:x},...S===void 0?{}:{omitSectionIds:S}}),i=await Promise.all(r.map(async t=>{let n=await I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{}});return n===null?null:{declaration:t,form:n}})),a=i.filter(e=>e!==null);if(a.length!==i.length)return{addonId:e,result:null,keyTargets:{}};let o=de(a);return{addonId:e,result:o.form,keyTargets:o.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:R});return{addonId:e,result:t!==null&&O!==void 0?ce(t,O):t,keyTargets:{}}},placeholderData:f}))}),we=z.some(e=>e.isLoading),B=z.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),V=n(()=>{let e=new Set;for(let t of z){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,E))}return[...e]},[E,B+`::`+z.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),H=n(()=>new Map((A??[]).map(e=>[e.id,e])),[A]),U=n(()=>{if(!L)return[];let e=[...new Set([...V,...(A??[]).map(e=>e.id),...(j??[]).map(e=>e.tabId)])],t=e=>{let t=H.get(e);if(t?.order!==void 0)return t.order;let n=g[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[L,V,A,H,j]),Te=n(()=>{let e=new Map,t=e=>g[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of V)e.set(n,t(n));for(let n of j??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of A??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(le??{}))e.set(t,n);return e},[V,A,j,le]),W=ge===void 0?Se:ge,G=L?W&&U.includes(W)?W:U[0]??null:null,Ee=e=>{Ce(e),_e?.(e)},De=G!==null&&H.has(G),K=L?G&&!De?G:void 0:D,{data:Oe}=te(void 0),ke=n(()=>{let e=new Map;for(let t of Oe??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Oe]),q=t(new Map),J=n(()=>{let e=x?new Set(x):null,t=S?new Set(S):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of z){if(!e.data)continue;e.data.result!==null&&q.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=q.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=pe(i),c={...C===void 0?{}:{fieldKeys:C},...w===void 0?{}:{omitFieldKeys:w},...T===void 0?{}:{hideSectionChrome:T},...E===void 0?{}:{tabAliases:E}},l=se(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:se(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[B,x,S,C,w,T,E]),Ae=n(()=>z.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!q.current.has(e.data.addonId)?[e.data.addonId]:[]),[B,c]),[Y,je]=s(new Map),Me=r(e=>{je(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=t(new Map),Ne=r(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=r(async(e,t)=>{if(c!==`global`){await ye.mutateAsync({addonId:e,deviceId:u,nodeId:R,patch:t});return}let{groups:n,unowned:r}=fe(t,J.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>ve.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,J,ve,ye,F,R,u]),Pe=r(async(e,t)=>{await Z(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Z,F]),Fe=r(async(e,t,n,r)=>{let i=R;try{switch(t){case`reprobe-hwaccel`:await be.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await xe.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[be,xe,R,F,I]),Ie=r((e,t)=>{Pe(e,t)},[Pe]),Q=p({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(await Z(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Le=r(()=>{for(let e of X.current.values())e.discard()},[]),Re=n(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),ze=n(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(we)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let Be=G&&De?H.get(G):void 0,$=Ae.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:Ae.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:ke.get(e)??e})},e))}):null;if(!L&&J.length===0)return $===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:k??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):$;let Ve=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(M||N)&&e(`div`,{className:`border-b border-border pb-2`,children:[M&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:M}),N&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:N})]}),J.length>0||L?$:null,L&&i(ae,{tabs:U.map(e=>({id:e,label:Te.get(e)??e})),activeId:G,onChange:Ee,pendingByTab:ze}),Q.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(v,{tabKey:Be?`extra:${G??``}`:`tab:${G??``}`,children:Be?Be.content:(()=>{let t=K?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===K).length,0):0,n=!!K&&t<=1,r=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>K?(e.tab??`general`)===K:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(j??[]).filter(e=>e.tabId===K),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:k??P(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(me,{entries:r,paneStates:Y,displayNames:ke,disabled:Ve,setPaneRef:Ne,onPaneStateChange:Me,onImmediateSave:Ie,onAction:Fe,inline:L||!!D}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!we&&i(ee,{pendingCount:Re,onSave:()=>Q.mutate(),onDiscard:Le,saving:Ve})]})}function me({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let v=m.find(e=>e.addonId===h)??m[0];if(!v)return null;let y=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),b=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:y,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(b)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===v.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(_,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===v.addonId?void 0:{display:`none`},children:b(e)},e.addonId))})]})}export{k as t};
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{bt as m}from"./player-overlays-Cp7Gj5VT.js";import{bl as h,yl as g}from"./src-uL_wvvFJ.js";import{Ap as _,at as v,co as y,so as b,ut as ee,vo as te,ws as ne,zo as re}from"./src-BHZH54iC.js";import{t as ie}from"./useTranslation-BJr-n0es.js";import{A as ae,Wt as x,j as S}from"./index-BB_RagyI.js";import{n as oe,t as se}from"./settings-section-shape-DbQZZpNL.js";c();var C=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=S({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(x,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function ce(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function le(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function ue(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!le(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function de(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of h({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function fe(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}c();function D(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>D(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function O(e,t){return{...e,fields:e.fields.map(e=>D(e,t))}}function pe(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>O(e,t))},values:t}}function k({nodeId:a,addonIds:o,level:c,deviceId:u,capability:h,omitCapabilities:_,sectionIds:x,omitSectionIds:S,fieldKeys:C,omitFieldKeys:w,hideSectionChrome:T,tabAliases:E,tabLabelOverrides:le,sectionTab:D,fieldScope:O,emptyMessage:k,extraTabs:A,schemaTabExtras:j,title:M,description:N,selfTabbed:he,activeTab:ge,onActiveTabChange:_e}){let{t:P}=ie(),F=d(),I=m().trpcClient,ve=y(),ye=b(),be=ne(),xe=re(),L=he===!0||!!(A&&A.length>0),[Se,Ce]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let R=a??`hub`,z=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:R,deviceId:u??null,cap:h??null,omitCaps:_??null,scope:O??null,sections:[x??null,S??null]}],queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:R});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=new Set(_??[]),r=ue({declarations:t.filter(e=>!n.has(e.cap)),...O===void 0?{}:{fieldScope:O},...h===void 0?{}:{capability:h},...x===void 0?{}:{allowSectionIds:x},...S===void 0?{}:{omitSectionIds:S}}),i=await Promise.all(r.map(async t=>{let n=await I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{}});return n===null?null:{declaration:t,form:n}})),a=i.filter(e=>e!==null);if(a.length!==i.length)return{addonId:e,result:null,keyTargets:{}};let o=de(a);return{addonId:e,result:o.form,keyTargets:o.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:R});return{addonId:e,result:t!==null&&O!==void 0?ce(t,O):t,keyTargets:{}}},placeholderData:f}))}),we=z.some(e=>e.isLoading),B=z.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),V=n(()=>{let e=new Set;for(let t of z){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,E))}return[...e]},[E,B+`::`+z.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),H=n(()=>new Map((A??[]).map(e=>[e.id,e])),[A]),U=n(()=>{if(!L)return[];let e=[...new Set([...V,...(A??[]).map(e=>e.id),...(j??[]).map(e=>e.tabId)])],t=e=>{let t=H.get(e);if(t?.order!==void 0)return t.order;let n=g[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[L,V,A,H,j]),Te=n(()=>{let e=new Map,t=e=>g[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of V)e.set(n,t(n));for(let n of j??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of A??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(le??{}))e.set(t,n);return e},[V,A,j,le]),W=ge===void 0?Se:ge,G=L?W&&U.includes(W)?W:U[0]??null:null,Ee=e=>{Ce(e),_e?.(e)},De=G!==null&&H.has(G),K=L?G&&!De?G:void 0:D,{data:Oe}=te(void 0),ke=n(()=>{let e=new Map;for(let t of Oe??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Oe]),q=t(new Map),J=n(()=>{let e=x?new Set(x):null,t=S?new Set(S):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of z){if(!e.data)continue;e.data.result!==null&&q.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=q.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=pe(i),c={...C===void 0?{}:{fieldKeys:C},...w===void 0?{}:{omitFieldKeys:w},...T===void 0?{}:{hideSectionChrome:T},...E===void 0?{}:{tabAliases:E}},l=se(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:se(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[B,x,S,C,w,T,E]),Ae=n(()=>z.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!q.current.has(e.data.addonId)?[e.data.addonId]:[]),[B,c]),[Y,je]=s(new Map),Me=r(e=>{je(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=t(new Map),Ne=r(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=r(async(e,t)=>{if(c!==`global`){await ye.mutateAsync({addonId:e,deviceId:u,nodeId:R,patch:t});return}let{groups:n,unowned:r}=fe(t,J.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>ve.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,J,ve,ye,F,R,u]),Pe=r(async(e,t)=>{await Z(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Z,F]),Fe=r(async(e,t,n,r)=>{let i=R;try{switch(t){case`reprobe-hwaccel`:await be.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await xe.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[be,xe,R,F,I]),Ie=r((e,t)=>{Pe(e,t)},[Pe]),Q=p({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(await Z(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Le=r(()=>{for(let e of X.current.values())e.discard()},[]),Re=n(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),ze=n(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(we)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let Be=G&&De?H.get(G):void 0,$=Ae.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:Ae.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:ke.get(e)??e})},e))}):null;if(!L&&J.length===0)return $===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:k??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):$;let Ve=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(M||N)&&e(`div`,{className:`border-b border-border pb-2`,children:[M&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:M}),N&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:N})]}),J.length>0||L?$:null,L&&i(ae,{tabs:U.map(e=>({id:e,label:Te.get(e)??e})),activeId:G,onChange:Ee,pendingByTab:ze}),Q.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(v,{tabKey:Be?`extra:${G??``}`:`tab:${G??``}`,children:Be?Be.content:(()=>{let t=K?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===K).length,0):0,n=!!K&&t<=1,r=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>K?(e.tab??`general`)===K:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(j??[]).filter(e=>e.tabId===K),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:k??P(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(me,{entries:r,paneStates:Y,displayNames:ke,disabled:Ve,setPaneRef:Ne,onPaneStateChange:Me,onImmediateSave:Ie,onAction:Fe,inline:L||!!D}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!we&&i(ee,{pendingCount:Re,onSave:()=>Q.mutate(),onDiscard:Le,saving:Ve})]})}function me({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let v=m.find(e=>e.addonId===h)??m[0];if(!v)return null;let y=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),b=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:y,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(b)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===v.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(_,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===v.addonId?void 0:{display:`none`},children:b(e)},e.addonId))})]})}export{k as t};