@camstack/addon-admin-ui 1.2.475 → 1.2.476
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/{AddonAssetIcon-BNfqkJPr.js → AddonAssetIcon-NsStjqDv.js} +1 -1
- package/dist/assets/{Addons-BQclhgQv.js → Addons-CC-7wyzX.js} +1 -1
- package/dist/assets/{AdminPage-UX2_-EVb.js → AdminPage-BBb_f0ke.js} +1 -1
- package/dist/assets/{AdminSectionedPage-CJhCo7eS.js → AdminSectionedPage-B77fFYLu.js} +1 -1
- package/dist/assets/AiProfiles-DQ7eLKoM.js +3 -0
- package/dist/assets/{BrokerForm-B1b0ZQq_.js → BrokerForm-Dql4j_7g.js} +1 -1
- package/dist/assets/Build-0VXUZTUO.js +40 -0
- package/dist/assets/{Calendars-CPP5G4iE.js → Calendars-DDdCqGq7.js} +1 -1
- package/dist/assets/{Cluster-DxeRVsUO.js → Cluster-B8y8FoQV.js} +1 -1
- package/dist/assets/CompositionBlockEditor-RHV08gl_.js +1 -0
- package/dist/assets/CompositionEditorPage-zqBIwPtu.js +1 -0
- package/dist/assets/{Data-NzOvsB8O.js → Data-C8MsiGcu.js} +1 -1
- package/dist/assets/{DeviceDetail-DKGhhLVK.js → DeviceDetail-BhhXtfQ_.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-CVBUVXjq.js → DeviceDoActionFields-CM877gWa.js} +1 -1
- package/dist/assets/{Devices-D9OmxxCE.js → Devices-D_p1jnJs.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-u5jZuoCz.js → EmbedPlayerPage-n_ZfqSgX.js} +1 -1
- package/dist/assets/{HelperWizard-Dape3GuD.js → HelperWizard-WGprHYSO.js} +1 -1
- package/dist/assets/{History-D-T-XA80.js → History-DP_G-ECr.js} +1 -1
- package/dist/assets/{Identity-DmBhBZsL.js → Identity-D_ESOlFi.js} +1 -1
- package/dist/assets/{IntegrationDetail-0C2a7iSq.js → IntegrationDetail-DAaPI_ET.js} +1 -1
- package/dist/assets/{IntegrationHub-DdxMGRIt.js → IntegrationHub-Ch94ozNN.js} +1 -1
- package/dist/assets/{Integrations-eKDwugCV.js → Integrations-BBm9vAbT.js} +1 -1
- package/dist/assets/{Integrations-aOO9hE39.js → Integrations-CcDZmbwS.js} +1 -1
- package/dist/assets/{Library-DUWYOPjU.js → Library-B6p5cMT3.js} +1 -1
- package/dist/assets/{Locations-D4YphIdu.js → Locations-C_Mo8QAj.js} +1 -1
- package/dist/assets/{Logs-CPgxOarw.js → Logs-DbUcQh4T.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-Cmq6IidK.js → MaskShapeCanvas-UFmJUhUS.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CnZg9FTF.js → MotionZonesSettings-BTxe4DbF.js} +1 -1
- package/dist/assets/{MyAccess-BKLOlMok.js → MyAccess-BjgGZZmK.js} +1 -1
- package/dist/assets/{Network-BT4UeK8H.js → Network-DJAN2ffw.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-75hJ0AJM.js → NodeAddonsSettingsPanel-P5f0HKwt.js} +1 -1
- package/dist/assets/{Notifications-B7JOfwPI.js → Notifications-BahnGVKD.js} +1 -1
- package/dist/assets/{Pipeline-DKfkLPEM.js → Pipeline-gniN2j7S.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-BFWSAVsy.js → PrivacyMaskSettings-D6kokNvH.js} +1 -1
- package/dist/assets/{Recordings-OmewxCzq.js → Recordings-BK-wAC4w.js} +1 -1
- package/dist/assets/{ScanNetworkModal-hCwvBDMd.js → ScanNetworkModal-D0nIF1xL.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BVdAyhJk.js → SceneMonitorEditor-CrDKfkgT.js} +1 -1
- package/dist/assets/{SessionsList-CTsz8qck.js → SessionsList-eAK6hNQb.js} +1 -1
- package/dist/assets/{Showroom-DlUMfmmX.js → Showroom-OGwDnxr_.js} +1 -1
- package/dist/assets/{System-xDNpG66Z.js → System-CkfHfeMd.js} +1 -1
- package/dist/assets/{Terminal-BKTT8qvq.js → Terminal-puPiVrKC.js} +1 -1
- package/dist/assets/{Viewer-Cu8oX6VE.js → Viewer-QizHE8-x.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-20B8V9NZ.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BIhn7NhC.js} +1 -1
- package/dist/assets/{addon-icons-context-BuuVE9Wr.js → addon-icons-context-DxUCqyaH.js} +1 -1
- package/dist/assets/{archive-CfJx72Ya.js → archive-Brq5E-qM.js} +1 -1
- package/dist/assets/{assignment-candidates-B51c4fCG.js → assignment-candidates-D58mtpje.js} +1 -1
- package/dist/assets/{authed-media-iyqNF0CO.js → authed-media-B_8ON2MT.js} +1 -1
- package/dist/assets/{bell-off-D1QNHdBJ.js → bell-off-CDjOfT8K.js} +1 -1
- package/dist/assets/{boxes-DomeSuUE.js → boxes-0ut2NdHU.js} +1 -1
- package/dist/assets/circle-slash-CaxGVwz5.js +1 -0
- package/dist/assets/client-DvJxGh2F.js +358 -0
- package/dist/assets/{cloud-upload-J0OXIjbZ.js → cloud-upload-M9JxZe_d.js} +1 -1
- package/dist/assets/crop-eK4NEtXI.js +1 -0
- package/dist/assets/{device-integration-icon-BQEjbsKG.js → device-integration-icon-C28x8nbP.js} +1 -1
- package/dist/assets/device-picker-model-BkHlLdb8.js +1 -0
- package/dist/assets/{dist-DcarhQ77.js → dist-B9cEBPZ1.js} +1 -1
- package/dist/assets/{eraser-DdaeWuQ6.js → eraser-Bs0PJaPY.js} +1 -1
- package/dist/assets/{hard-drive-download-YerwrGPA.js → hard-drive-download-iRJR_Xj9.js} +1 -1
- package/dist/assets/{hostInit-B6UQXYd9.js → hostInit-EKt3RqKv.js} +1 -1
- package/dist/assets/{icons-BBOyPCCy.js → icons-BivKI4y9.js} +1 -1
- package/dist/assets/{index-Ctkts88E.js → index-BFjKpxae.js} +3 -3
- package/dist/assets/index-CU-5JpMo.css +2 -0
- package/dist/assets/{key-CunS-V0Z.js → key-Crd8m-SP.js} +1 -1
- package/dist/assets/{key-round-DcVl91E5.js → key-round-DG341WFZ.js} +1 -1
- package/dist/assets/{layers-BC3a28BZ.js → layers-BnsQ5ORI.js} +1 -1
- package/dist/assets/{linked-devices-model-CWqnVKj5.js → linked-devices-model-Cgse8lhb.js} +1 -1
- package/dist/assets/{list-ordered-B_2hLh_-.js → list-ordered-BIo7AnFy.js} +1 -1
- package/dist/assets/{location-owned-usage-C3ukxAgd.js → location-owned-usage-uS8d4cQL.js} +1 -1
- package/dist/assets/{log-in-IPEzbjqk.js → log-in-D1BPSCDn.js} +1 -1
- package/dist/assets/{memory-stick-CUBeuzQu.js → memory-stick-CjPBCMfd.js} +1 -1
- package/dist/assets/{message-square-plus-DHiayOOs.js → message-square-plus-C4N5hy0x.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-976d3c1a.js → mf-entry-bootstrap-0-99fca1f4.js} +2 -2
- package/dist/assets/{mic-off-DX_Buyxi.js → mic-off-CgPfA49W.js} +1 -1
- package/dist/assets/{monitor-off-Czk3uiUL.js → monitor-off-Ib2v0VDF.js} +1 -1
- package/dist/assets/{monitor-smartphone-DhnI06Vd.js → monitor-smartphone-6w2T5Ht_.js} +1 -1
- package/dist/assets/mount-BkHlLdb8.js +1 -0
- package/dist/assets/{player-overlays-DfIXPXfC.js → player-overlays-Dbv95cvz.js} +1 -1
- package/dist/assets/{recycle-CIxCuRlw.js → recycle-DcScXiTi.js} +1 -1
- package/dist/assets/remoteEntry-awBSqPjf.js +1 -0
- package/dist/assets/{scan-eye-CNch-kOQ.js → scan-eye-CWOvobjP.js} +1 -1
- package/dist/assets/{scissors-DAqmNijF.js → scissors-NpyrGUBV.js} +1 -1
- package/dist/assets/{search-x-Bam8bduF.js → search-x-CKQw--aU.js} +1 -1
- package/dist/assets/{send-DTxEr1U2.js → send-402PlgqT.js} +1 -1
- package/dist/assets/{settings-2-Gykf_Jj2.js → settings-2-BbwQVFbm.js} +1 -1
- package/dist/assets/{speaker-vU_58Q4N.js → speaker-DCHkSyjS.js} +1 -1
- package/dist/assets/src-ByunGuTZ.js +67 -0
- package/dist/assets/{step-inspector-model-COSP18Eo.js → step-inspector-model-C-7jLQzL.js} +1 -1
- package/dist/assets/{timer-reset-BfVqeFHK.js → timer-reset-DZ3bTFWu.js} +1 -1
- package/dist/assets/{ungroup-BzhYEwYi.js → ungroup-3fOR8xo7.js} +1 -1
- package/dist/assets/{unlink-DcrSLSGi.js → unlink-vu-wpZmU.js} +1 -1
- package/dist/assets/{usb-CCxf9eVL.js → usb-CGOBq5r2.js} +1 -1
- package/dist/assets/{use-scenes-feed-CCy-Tx5-.js → use-scenes-feed-wrd7r_Sr.js} +1 -1
- package/dist/assets/{use-stationary-objects-rfvEUY5Q.js → use-stationary-objects-U-Gv-CIi.js} +1 -1
- package/dist/assets/useEventInvalidation-BkHlLdb8.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BDqOR0oD.js → useNodeUrlSelection-DZ8j6nae.js} +1 -1
- package/dist/assets/user-round-CmncOV9r.js +1 -0
- package/dist/assets/{user-x-DNQnP84p.js → user-x-CjUfhy0O.js} +1 -1
- package/dist/assets/{video-FHJCba2c.js → video-D7jv0spx.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BBtNcF2c.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BaETqb6x.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/AiProfiles-zhlwR2_B.js +0 -3
- package/dist/assets/Build-DMVYWc57.js +0 -40
- package/dist/assets/CompositionCreateForm-ZntjBNdS.js +0 -1
- package/dist/assets/CompositionEditorPage-CpvZY109.js +0 -1
- package/dist/assets/circle-slash-CPzLe6ak.js +0 -1
- package/dist/assets/client-fa7ANI4X.js +0 -358
- package/dist/assets/crop-4oyysRxn.js +0 -1
- package/dist/assets/device-picker-model-CsITnnp7.js +0 -1
- package/dist/assets/index-B4dcSKZt.css +0 -2
- package/dist/assets/mount-CsITnnp7.js +0 -1
- package/dist/assets/remoteEntry-isS_YRZd.js +0 -1
- package/dist/assets/src-Cy_bal4g.js +0 -67
- package/dist/assets/useEventInvalidation-CsITnnp7.js +0 -1
- package/dist/assets/user-round-D6lnAuWE.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,k as s,o as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as d,Li as f,Nt as p,V as m,Yt as h,bn as g,kn as _,lr as v,or as y,pn as b}from"./player-overlays-DfIXPXfC.js";import{Mr as x}from"./client-fa7ANI4X.js";import{t as S}from"./settings-2-Gykf_Jj2.js";import{Di as C,Dr as ee,Er as te,Gr as w,Ni as T,Qr as E,en as D,gn as O,tn as k,xn as ne,xr as A}from"./src-Cy_bal4g.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{c as re,d as M,lr as N,mr as P,o as F,r as I,s as L,u as R,ur as z}from"./index-Ctkts88E.js";import{t as B}from"./AdminPage-UX2_-EVb.js";import{t as V}from"./NodeAddonsSettingsPanel-75hJ0AJM.js";import{t as H}from"./AddonAssetIcon-BNfqkJPr.js";o();function U(e){let{ids:t,answered:r,legacyGroupParam:i=null,groupFirst:a}=e,[o]=P(),s=o.get(F),c=i===null?null:o.get(i),l=o.get(L),u=n(()=>R({ids:t,requested:s,answered:r,legacyGroup:c,...a===void 0?{}:{groupFirst:a}}),[t,s,r,c,a]),d=n(()=>(e,t)=>`?${M(o,e,i,t??null).toString()}`,[o,i]);return{...u,requestedSection:l,hrefFor:d}}var W=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],G=`text-[10px]`;function K({isActive:e}){let{t}=j();return r(E,{variant:e?`success`:`default`,className:G,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function q({capName:t,addonId:n,isActive:i}){let{t:a}=j(),o=c(),s=T({onSuccess:()=>{for(let e of W)o.invalidateQueries({queryKey:e})}}),l=s.isPending;return e(w,{size:`sm`,variant:i?`secondary`:`primary`,disabled:l,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!i}),children:[l?r(y,{className:`h-3 w-3 animate-spin`}):r(i?h:d,{className:`h-3 w-3`}),i?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function ie({addonId:e,displayName:t}){let{t:n}=j(),i=c(),a=C({onSuccess:()=>{for(let e of W)i.invalidateQueries({queryKey:e})}});return r(O,{label:n(`integrationHub.addonControls.restart`,`Restart`),icon:g,size:`sm`,title:n(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:n(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`),confirmLabel:n(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:a.isPending,action:()=>a.mutateAsync({addonId:e})})}o();var J=600,Y=s(null);function X({id:n,title:i,icon:a,actions:o,framed:s=!1,children:c}){let{t:d}=j(),f=u(Y),p=t(null),h=`integration-section-${n}`;ae(p,f,n);let g=e(l,{children:[f===null?null:r(z,{to:f.sectionHref(n),"aria-label":d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),title:d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:r(v,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?r(`div`,{ref:p,className:`scroll-mt-4`,children:r(ne,{headingId:h,title:i,icon:a,actions:g,children:c})}):e(`section`,{ref:p,"aria-labelledby":h,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&r(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),r(`h2`,{id:h,className:`${m} min-w-0 flex-1`,children:i}),g]}),c]})}function ae(e,t,n){let r=t?.requestedSection===n,a=t?.integrationId;i(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},J);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,a,e])}o();var Z=`max-h-72`;function oe({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s,error:c=null,lead:l,panels:u=[],settingsContent:d}){let{t:f}=j(),p=u.filter(e=>e.placement!==`end`),m=u.filter(e=>e.placement===`end`);return e(`div`,{className:`flex flex-col gap-4`,children:[r(se,{addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}),c!==null&&r(te,{message:c}),l,r(Q,{panels:p}),r(X,{id:re,title:f(`integrationHub.addonIntegrationBody.settings`,`Settings`),icon:S,children:d===void 0?r(V,{nodeId:`hub`,addonIds:[t],level:`global`,capability:i}):d}),r(le,{addonId:t}),r(Q,{panels:m})]})}function Q({panels:e}){return r(l,{children:e.map(e=>r(X,{id:e.id,title:e.title,icon:e.icon,children:e.content},e.id))})}function se({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}){return e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-surface px-2 py-1.5 sm:px-3`,"data-testid":`integration-status-strip`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[r(K,{isActive:a}),o,r(`span`,{className:`break-all font-mono text-[11px] text-foreground-subtle`,children:t})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[s,r(q,{capName:i,addonId:t,isActive:a}),r(ie,{addonId:t,displayName:n})]})]})}var ce=[{kind:`logs`,labelKey:`common.logs`,icon:b},{kind:`events`,labelKey:`common.events`,icon:f}];function le({addonId:t}){let{t:n}=j(),[i,o]=a(`logs`);return r(X,{id:I,title:n(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:r(`div`,{role:`group`,"aria-label":n(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:ce.map(({kind:t,labelKey:a,icon:s})=>e(`button`,{type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(s,{className:`h-3 w-3`,"aria-hidden":!0}),n(a)]},t))}),children:i===`logs`?r(k,{addonId:t,maxHeight:Z,showFilters:!1}):r(D,{addonId:t,category:`addon.*`,maxHeight:Z})})}var ue=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,de=`border-primary bg-primary/10 text-primary font-medium`,fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,pe={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function $({label:t,groups:n,selectedId:i,hrefFor:a}){let o=n.length>1;return r(`nav`,{"aria-label":t,className:o?`flex flex-col gap-2 sm:grid sm:grid-cols-[max-content_minmax(0,1fr)] sm:items-start sm:gap-x-3`:`flex flex-col`,children:n.map(t=>e(`div`,{role:`group`,"aria-label":t.label,className:o?`flex min-w-0 flex-col gap-1 sm:col-span-2 sm:grid sm:grid-cols-subgrid sm:items-start`:`min-w-0`,children:[o&&r(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle sm:pt-2`,children:t.label}),e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.entries.map(e=>r(me,{entry:e,current:e.id===i,href:a(e.id)},e.id)),t.install&&e(z,{to:x(t.install.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[r(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),r(`span`,{className:`truncate`,children:t.install.label})]})]})]},t.id))})}function me({entry:t,current:n,href:i}){let a=t.state===`ok`;return e(z,{to:i,"aria-current":n?`true`:void 0,className:`${ue} ${n?de:fe}`,"data-testid":`integration-pill-${t.id}`,children:[r(H,{addonId:t.id,fallback:t.fallbackIcon,tileClassName:``,size:`sm`}),r(`span`,{className:`truncate`,children:t.name}),t.showState!==!1&&r(he,{entry:t,quiet:a})]})}function he({entry:t,quiet:n}){return e(l,{children:[r(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${pe[t.state]}`,"aria-hidden":!0}),r(`span`,{className:n?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.stateLabel})]})}o();function ge({icon:t,title:i,subtitle:a,groups:o,isLoading:s,emptyTitle:c,emptyDescription:u,legacyGroupParam:d,trailing:f,embedded:p=!1}){let{t:m}=j(),h=n(()=>o.flatMap(e=>e.entries),[o]),g=n(()=>h.map(e=>e.id),[h]),_=n(()=>{let e={};for(let t of o){let n=t.entries[0];n!==void 0&&(e[t.id]=n.id)}return e},[o]),v=U({ids:g,answered:!s,legacyGroupParam:d??null,groupFirst:_}),y=h.find(e=>e.id===v.selectedId)??null,b=n(()=>y===null?null:{integrationId:y.id,requestedSection:v.requestedSection,sectionHref:e=>v.hrefFor(y.id,e)},[y,v]),x=s?null:r($,{label:m(`integrationHub.integrationHub.integrations`,`{{title}} integrations`,{title:i}),groups:o,selectedId:v.selectedId,hrefFor:e=>v.hrefFor(e)}),S=s?r(A,{children:r(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:m(`common.loading`,`Loading…`)})}):e(l,{children:[v.staleId!==null&&r(ve,{staleId:v.staleId,shownName:y?.name??null}),y!==null&&b!==null?r(Y.Provider,{value:b,children:r(`div`,{role:`region`,"aria-label":y.name,"data-testid":`integration-body`,children:y.render()},y.id)}):r(_e,{groups:o,title:c,description:u}),f]});return p?e(`div`,{className:`space-y-3`,"data-testid":`integration-hub-embedded`,children:[x,S]}):r(B,{icon:t,title:i,subtitle:a,nav:x,children:S})}function _e({groups:t,title:n,description:i}){let a=t.find(e=>e.install!==void 0)?.install;return r(A,{children:r(ee,{title:n,description:i,action:a?r(z,{to:x(a.capability),children:e(w,{variant:`primary`,size:`sm`,children:[r(_,{className:`mr-1 h-3.5 w-3.5`}),a.label]})}):void 0})})}function ve({staleId:t,shownName:n}){let{t:i}=j();return e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),e(`span`,{children:[r(N,{i18nKey:`integrationHub.staleIntegration.notice`,values:{id:t},components:{mono:r(`span`,{className:`font-mono text-foreground`})}}),n!==null&&e(l,{children:[` `,r(N,{i18nKey:`integrationHub.staleIntegration.showing`,values:{name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})]})]})]})}export{U as i,oe as n,G as r,ge as t};
|
|
1
|
+
import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o,k as s,o as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as d,Li as f,Nt as p,V as m,Yt as h,bn as g,kn as _,lr as v,or as y,pn as b}from"./player-overlays-Dbv95cvz.js";import{Mr as x}from"./client-DvJxGh2F.js";import{t as S}from"./settings-2-BbwQVFbm.js";import{Di as C,Dr as ee,Er as te,Gr as w,Ni as T,Qr as E,en as D,gn as O,tn as k,xn as ne,xr as A}from"./src-ByunGuTZ.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{c as re,d as M,lr as N,mr as P,o as F,r as I,s as L,u as R,ur as z}from"./index-BFjKpxae.js";import{t as B}from"./AdminPage-BBb_f0ke.js";import{t as V}from"./NodeAddonsSettingsPanel-P5f0HKwt.js";import{t as H}from"./AddonAssetIcon-NsStjqDv.js";o();function U(e){let{ids:t,answered:r,legacyGroupParam:i=null,groupFirst:a}=e,[o]=P(),s=o.get(F),c=i===null?null:o.get(i),l=o.get(L),u=n(()=>R({ids:t,requested:s,answered:r,legacyGroup:c,...a===void 0?{}:{groupFirst:a}}),[t,s,r,c,a]),d=n(()=>(e,t)=>`?${M(o,e,i,t??null).toString()}`,[o,i]);return{...u,requestedSection:l,hrefFor:d}}var W=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],G=`text-[10px]`;function K({isActive:e}){let{t}=j();return r(E,{variant:e?`success`:`default`,className:G,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function q({capName:t,addonId:n,isActive:i}){let{t:a}=j(),o=c(),s=T({onSuccess:()=>{for(let e of W)o.invalidateQueries({queryKey:e})}}),l=s.isPending;return e(w,{size:`sm`,variant:i?`secondary`:`primary`,disabled:l,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!i}),children:[l?r(y,{className:`h-3 w-3 animate-spin`}):r(i?h:d,{className:`h-3 w-3`}),i?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function ie({addonId:e,displayName:t}){let{t:n}=j(),i=c(),a=C({onSuccess:()=>{for(let e of W)i.invalidateQueries({queryKey:e})}});return r(O,{label:n(`integrationHub.addonControls.restart`,`Restart`),icon:g,size:`sm`,title:n(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:n(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`),confirmLabel:n(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:a.isPending,action:()=>a.mutateAsync({addonId:e})})}o();var J=600,Y=s(null);function X({id:n,title:i,icon:a,actions:o,framed:s=!1,children:c}){let{t:d}=j(),f=u(Y),p=t(null),h=`integration-section-${n}`;ae(p,f,n);let g=e(l,{children:[f===null?null:r(z,{to:f.sectionHref(n),"aria-label":d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),title:d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:r(v,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?r(`div`,{ref:p,className:`scroll-mt-4`,children:r(ne,{headingId:h,title:i,icon:a,actions:g,children:c})}):e(`section`,{ref:p,"aria-labelledby":h,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&r(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),r(`h2`,{id:h,className:`${m} min-w-0 flex-1`,children:i}),g]}),c]})}function ae(e,t,n){let r=t?.requestedSection===n,a=t?.integrationId;i(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},J);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,a,e])}o();var Z=`max-h-72`;function oe({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s,error:c=null,lead:l,panels:u=[],settingsContent:d}){let{t:f}=j(),p=u.filter(e=>e.placement!==`end`),m=u.filter(e=>e.placement===`end`);return e(`div`,{className:`flex flex-col gap-4`,children:[r(se,{addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}),c!==null&&r(te,{message:c}),l,r(Q,{panels:p}),r(X,{id:re,title:f(`integrationHub.addonIntegrationBody.settings`,`Settings`),icon:S,children:d===void 0?r(V,{nodeId:`hub`,addonIds:[t],level:`global`,capability:i}):d}),r(le,{addonId:t}),r(Q,{panels:m})]})}function Q({panels:e}){return r(l,{children:e.map(e=>r(X,{id:e.id,title:e.title,icon:e.icon,children:e.content},e.id))})}function se({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}){return e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-surface px-2 py-1.5 sm:px-3`,"data-testid":`integration-status-strip`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[r(K,{isActive:a}),o,r(`span`,{className:`break-all font-mono text-[11px] text-foreground-subtle`,children:t})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[s,r(q,{capName:i,addonId:t,isActive:a}),r(ie,{addonId:t,displayName:n})]})]})}var ce=[{kind:`logs`,labelKey:`common.logs`,icon:b},{kind:`events`,labelKey:`common.events`,icon:f}];function le({addonId:t}){let{t:n}=j(),[i,o]=a(`logs`);return r(X,{id:I,title:n(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:r(`div`,{role:`group`,"aria-label":n(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:ce.map(({kind:t,labelKey:a,icon:s})=>e(`button`,{type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(s,{className:`h-3 w-3`,"aria-hidden":!0}),n(a)]},t))}),children:i===`logs`?r(k,{addonId:t,maxHeight:Z,showFilters:!1}):r(D,{addonId:t,category:`addon.*`,maxHeight:Z})})}var ue=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,de=`border-primary bg-primary/10 text-primary font-medium`,fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,pe={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function $({label:t,groups:n,selectedId:i,hrefFor:a}){let o=n.length>1;return r(`nav`,{"aria-label":t,className:o?`flex flex-col gap-2 sm:grid sm:grid-cols-[max-content_minmax(0,1fr)] sm:items-start sm:gap-x-3`:`flex flex-col`,children:n.map(t=>e(`div`,{role:`group`,"aria-label":t.label,className:o?`flex min-w-0 flex-col gap-1 sm:col-span-2 sm:grid sm:grid-cols-subgrid sm:items-start`:`min-w-0`,children:[o&&r(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle sm:pt-2`,children:t.label}),e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.entries.map(e=>r(me,{entry:e,current:e.id===i,href:a(e.id)},e.id)),t.install&&e(z,{to:x(t.install.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[r(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),r(`span`,{className:`truncate`,children:t.install.label})]})]})]},t.id))})}function me({entry:t,current:n,href:i}){let a=t.state===`ok`;return e(z,{to:i,"aria-current":n?`true`:void 0,className:`${ue} ${n?de:fe}`,"data-testid":`integration-pill-${t.id}`,children:[r(H,{addonId:t.id,fallback:t.fallbackIcon,tileClassName:``,size:`sm`}),r(`span`,{className:`truncate`,children:t.name}),t.showState!==!1&&r(he,{entry:t,quiet:a})]})}function he({entry:t,quiet:n}){return e(l,{children:[r(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${pe[t.state]}`,"aria-hidden":!0}),r(`span`,{className:n?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.stateLabel})]})}o();function ge({icon:t,title:i,subtitle:a,groups:o,isLoading:s,emptyTitle:c,emptyDescription:u,legacyGroupParam:d,trailing:f,embedded:p=!1}){let{t:m}=j(),h=n(()=>o.flatMap(e=>e.entries),[o]),g=n(()=>h.map(e=>e.id),[h]),_=n(()=>{let e={};for(let t of o){let n=t.entries[0];n!==void 0&&(e[t.id]=n.id)}return e},[o]),v=U({ids:g,answered:!s,legacyGroupParam:d??null,groupFirst:_}),y=h.find(e=>e.id===v.selectedId)??null,b=n(()=>y===null?null:{integrationId:y.id,requestedSection:v.requestedSection,sectionHref:e=>v.hrefFor(y.id,e)},[y,v]),x=s?null:r($,{label:m(`integrationHub.integrationHub.integrations`,`{{title}} integrations`,{title:i}),groups:o,selectedId:v.selectedId,hrefFor:e=>v.hrefFor(e)}),S=s?r(A,{children:r(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:m(`common.loading`,`Loading…`)})}):e(l,{children:[v.staleId!==null&&r(ve,{staleId:v.staleId,shownName:y?.name??null}),y!==null&&b!==null?r(Y.Provider,{value:b,children:r(`div`,{role:`region`,"aria-label":y.name,"data-testid":`integration-body`,children:y.render()},y.id)}):r(_e,{groups:o,title:c,description:u}),f]});return p?e(`div`,{className:`space-y-3`,"data-testid":`integration-hub-embedded`,children:[x,S]}):r(B,{icon:t,title:i,subtitle:a,nav:x,children:S})}function _e({groups:t,title:n,description:i}){let a=t.find(e=>e.install!==void 0)?.install;return r(A,{children:r(ee,{title:n,description:i,action:a?r(z,{to:x(a.capability),children:e(w,{variant:`primary`,size:`sm`,children:[r(_,{className:`mr-1 h-3.5 w-3.5`}),a.label]})}):void 0})})}function ve({staleId:t,shownName:n}){let{t:i}=j();return e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),e(`span`,{children:[r(N,{i18nKey:`integrationHub.staleIntegration.notice`,values:{id:t},components:{mono:r(`span`,{className:`font-mono text-foreground`})}}),n!==null&&e(l,{children:[` `,r(N,{i18nKey:`integrationHub.staleIntegration.showing`,values:{name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})]})]})]})}export{U as i,oe as n,G as r,ge as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cn as l,Di as u,On as d,Si as f,bn as p,dt as m,fn as h,kn as g,or as _,ot as v,un as y,xi as b,yi as x}from"./player-overlays-DfIXPXfC.js";import{At as S,Ha as ee,Nt as C,Qu as w,at as T,ci as E,do as D,eo as O,is as te,jt as k,ls as A,od as j,r as M,ss as N}from"./src-Cy_bal4g.js";import{t as P}from"./i18n-l_m6iBJW.js";import{t as F}from"./useTranslation-BJr-n0es.js";import{fr as I,mr as ne,sr as L}from"./index-Ctkts88E.js";import{t as R}from"./AdminPage-UX2_-EVb.js";import"./useEventInvalidation-CsITnnp7.js";import{t as re}from"./device-integration-icon-BQEjbsKG.js";import{n as z,r as B,t as ie}from"./ScanNetworkModal-hCwvBDMd.js";o();function V(e=!0){i(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}o();function ae(e,t){let[n,r]=a(!1);return i(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}o();function H({providerId:t,onImport:n,onSkip:o}){let{t:s}=F(),[c,l]=a(new Set),d=O(),p=d.data,m=d.isPending||!d.data&&!d.isError;i(()=>{t&&(d.isPending||d.data||d.mutate({addonId:t}))},[t,d]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(m)return e(`div`,{className:`flex flex-col items-center py-12`,children:[r(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),r(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=p??[];return e(`div`,{className:`space-y-4`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&r(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,i=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(`button`,{onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??i}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[r(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&r(f,{className:`h-3 w-3 text-primary-foreground`})}),r(u,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),r(`span`,{className:`text-xs font-medium text-foreground truncate`,children:i}),o&&r(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},n)})}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[r(`button`,{onClick:o,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:s(`integrations.skip`)}),g.length>0&&e(`button`,{onClick:()=>n(Array.from(c)),disabled:c.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[s(`integrations.importSelected`),` (`,c.size,`)`]})]})]})}o();function U({onSelect:n,onClose:i,pendingAddonId:o=null}){let{t:s}=F(),c=I(),[l,u]=a(``),{data:d,isLoading:f}=N(),p=t(()=>{let e=d??[],t=l.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[d,l]);if(f)return r(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>r(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let m=o!==null;return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[r(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),r(w,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:s(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":s(`integrations.searchProviders`,`Search integrations…`)})]}),r(`div`,{className:`grid grid-cols-2 gap-2`,children:p.map(t=>{let a=t.instanceMode===`unique`&&t.existingInstances.length>0,l=o===t.addonId,u=m;return e(`button`,{type:`button`,disabled:u,"data-testid":`provider-pick-${t.addonId}`,onClick:()=>{if(!u)if(a){let e=t.existingInstances[0].id;i(),c(`/integrations/${e}`)}else n(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-center text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[t.iconUrl?r(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:r(`img`,{src:t.iconUrl,alt:``,className:`h-5 w-5`})}):r(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:r(`span`,{className:`text-sm`,style:{color:t.color},children:`◉`})}),r(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:t.name}),t.description?r(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:t.description}):null,l?r(_,{className:`h-4 w-4 animate-spin text-primary`}):a?e(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[r(y,{className:`h-3 w-3`}),s(`integrations.manage`)]}):null]},t.addonId)})}),p.length===0&&r(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(d??[]).length===0?s(`integrations.noProviders`):s(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}o();function oe(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var W=2e4;function se({open:n,onClose:o}){let{t:l}=F(),u=I(),d=s(),[f,p]=a(`picker`),[h,g]=a(null),[v,y]=a(null),[b,x]=a(`manual`),[S,C]=a(null),[w,T]=a(``),[D,k]=a(null),[A,j]=a(null),[M,N]=a(!1),{data:P}=E({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),ne=t(()=>P?oe(P):null,[P]),L=te({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),R=O(),re=R.data;i(()=>{f!==`discovery`||!v||!h||R.isPending||R.data||R.mutate({addonId:h})},[f,v,h,R]);let ie=ee({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function se(e,t,n,r,i,a,o,s){if(!L.isPending){if(g(e),N(s),x(n),T(r),j(null),o===`broker`){if(!a){j(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),p(`broker`);return}if(o===`account`){p(`config`);return}G(e,r)}}async function G(e,t){try{let n=await L.mutateAsync({addonId:e,name:t,settings:{}});o(),J(),u(`/integrations/${n.id}?add=1`)}catch{}}async function ce(e){if(h)try{let t=await L.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),k(t.id),b===`auto`||b===`both`?p(`discovery`):q(t.id,{openAdd:!0})}catch{}}async function le(e){if(h)try{let t=await L.mutateAsync({addonId:h,name:w,settings:{brokerId:e}});k(t.id),y(t.id),q(t.id)}catch{}}async function K(e){if(h){for(let t of e){let e=re?.find(e=>e.stableId===t);e&&await ie.mutateAsync({addonId:h,candidate:e,...D===null?{}:{integrationId:D}})}q()}}function q(e,t){let n=e??v??h;o(),J(),n&&u(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function J(){p(`picker`),g(null),y(null),x(`manual`),C(null),T(``),k(null),j(null),N(!1)}function Y(){o(),J()}V(n);let X=L.isPending,Z=ae(X,W);if(!n)return null;let ue={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=X?h:null,$=L.error,de=X&&!Z;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[r(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:Y}),e(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:ue[f]}),r(`button`,{onClick:Y,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r(m,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!X&&r(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),f===`picker`&&e(c,{children:[A&&r(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:A}),r(U,{onSelect:se,onClose:Y,pendingAddonId:Q})]}),f===`config`&&h&&r(z,{addonId:h,configSchema:ne??null,canTest:M,onSave:ce,onBack:()=>p(`picker`)}),f===`broker`&&S&&r(B,{kind:S,onResolved:e=>{le(e)},onBack:()=>p(`picker`)}),f===`discovery`&&v&&r(H,{providerId:v,onImport:K,onSkip:q})]}),X&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[r(_,{className:`h-6 w-6 animate-spin text-primary`}),r(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Z&&r(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Z&&e(c,{children:[r(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),r(`button`,{onClick:Y,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function G({integration:t,expanded:n,onToggleExpand:i}){let{t:a}=F();return e(`div`,{className:`flex items-center gap-2.5`,children:[r(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:r(n?b:x,{className:`h-3.5 w-3.5`})}),r(L,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),r(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function ce(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:P.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>r(G,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:P.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>P.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:P.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>r(T,{status:e.status})}]}o();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var K=`expand`;function q(){let{t:i}=F(),o=I(),s=v(),[u]=ne(),[f,m]=a(!1),h=n(()=>m(!0),[]),_=n(()=>m(!1),[]),[y,b]=a(!1),x=n(()=>b(!0),[]),ee=n(()=>b(!1),[]);M([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),M([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:w,isLoading:T,refetch:E}=A(void 0),{data:O,isLoading:te,refetch:N}=D({projection:`slim`}),P=t(()=>O??[],[O]),L=t(()=>w??[],[w]),z=t(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),B=t(()=>k(w),[w]),V=t(()=>{let e=new Map;for(let t of C(P)){let n=B(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[P,B]),ae=t(()=>L.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:V.get(e.id)??0})),[L,V]),H=u.get(K),U=n(e=>{let t=new URLSearchParams(window.location.search);t.get(K)===e?t.delete(K):t.set(K,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),oe=n(e=>o(`/integrations/${e.id}`),[o]),W=n(e=>z.get(e)??null,[z]),G=n(e=>o(`/devices/${String(e)}`),[o]),q=n(e=>r(S,{context:`integration-detail`,devices:P,trpc:s.trpcClient,integrationOf:B,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:re,resolveParent:W,onNavigate:G}),[P,s.trpcClient,B,W,G]),J=n(e=>H===e.addonId,[H]),Y=t(()=>ce({isExpanded:J,onToggleExpand:U}),[J,U]),X=n(e=>`${e.name} ${e.addonId}`,[]),Z=n(e=>e.addonId,[]),ue=n(()=>{E(),N()},[E,N]),Q=T||te,$=L.length>0;return e(R,{icon:d,title:i(`nav.integrations`,`Integrations`),actions:e(c,{children:[r(`button`,{onClick:ue,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:i(`common.refresh`,`Refresh`),children:r(p,{className:j(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),e(`button`,{onClick:x,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:i(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[r(l,{className:`h-3.5 w-3.5`}),i(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[r(g,{className:`h-3.5 w-3.5`}),i(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&r(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>r(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[r(`p`,{className:`text-sm`,children:i(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),r(`p`,{className:`text-xs mt-1`,children:i(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Q&&$&&r(S,{mode:`generic`,items:ae,getKey:Z,getSearchText:X,columns:Y,onRowClick:oe,isExpanded:J,renderExpanded:q,searchPlaceholder:i(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:i(`integrations.empty`,{defaultValue:`No integrations found.`})}),r(se,{open:f,onClose:_}),r(ie,{open:y,onClose:ee})]})}export{q as IntegrationsPage};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cn as l,Di as u,On as d,Si as f,bn as p,dt as m,fn as h,kn as g,or as _,ot as v,un as y,xi as b,yi as x}from"./player-overlays-Dbv95cvz.js";import{At as S,Ha as ee,Nt as C,Qu as w,at as T,ci as E,do as D,eo as O,is as te,jt as k,ls as A,od as j,r as M,ss as N}from"./src-ByunGuTZ.js";import{t as P}from"./i18n-l_m6iBJW.js";import{t as F}from"./useTranslation-BJr-n0es.js";import{fr as I,mr as ne,sr as L}from"./index-BFjKpxae.js";import{t as R}from"./AdminPage-BBb_f0ke.js";import"./useEventInvalidation-BkHlLdb8.js";import{t as re}from"./device-integration-icon-C28x8nbP.js";import{n as z,r as B,t as ie}from"./ScanNetworkModal-D0nIF1xL.js";o();function V(e=!0){i(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}o();function ae(e,t){let[n,r]=a(!1);return i(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}o();function H({providerId:t,onImport:n,onSkip:o}){let{t:s}=F(),[c,l]=a(new Set),d=O(),p=d.data,m=d.isPending||!d.data&&!d.isError;i(()=>{t&&(d.isPending||d.data||d.mutate({addonId:t}))},[t,d]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(m)return e(`div`,{className:`flex flex-col items-center py-12`,children:[r(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),r(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=p??[];return e(`div`,{className:`space-y-4`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&r(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,i=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(`button`,{onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??i}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[r(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&r(f,{className:`h-3 w-3 text-primary-foreground`})}),r(u,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),r(`span`,{className:`text-xs font-medium text-foreground truncate`,children:i}),o&&r(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},n)})}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[r(`button`,{onClick:o,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:s(`integrations.skip`)}),g.length>0&&e(`button`,{onClick:()=>n(Array.from(c)),disabled:c.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[s(`integrations.importSelected`),` (`,c.size,`)`]})]})]})}o();function U({onSelect:n,onClose:i,pendingAddonId:o=null}){let{t:s}=F(),c=I(),[l,u]=a(``),{data:d,isLoading:f}=N(),p=t(()=>{let e=d??[],t=l.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[d,l]);if(f)return r(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>r(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let m=o!==null;return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[r(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),r(w,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:s(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":s(`integrations.searchProviders`,`Search integrations…`)})]}),r(`div`,{className:`grid grid-cols-2 gap-2`,children:p.map(t=>{let a=t.instanceMode===`unique`&&t.existingInstances.length>0,l=o===t.addonId,u=m;return e(`button`,{type:`button`,disabled:u,"data-testid":`provider-pick-${t.addonId}`,onClick:()=>{if(!u)if(a){let e=t.existingInstances[0].id;i(),c(`/integrations/${e}`)}else n(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-center text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[t.iconUrl?r(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:r(`img`,{src:t.iconUrl,alt:``,className:`h-5 w-5`})}):r(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:r(`span`,{className:`text-sm`,style:{color:t.color},children:`◉`})}),r(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:t.name}),t.description?r(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:t.description}):null,l?r(_,{className:`h-4 w-4 animate-spin text-primary`}):a?e(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[r(y,{className:`h-3 w-3`}),s(`integrations.manage`)]}):null]},t.addonId)})}),p.length===0&&r(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(d??[]).length===0?s(`integrations.noProviders`):s(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}o();function oe(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var W=2e4;function se({open:n,onClose:o}){let{t:l}=F(),u=I(),d=s(),[f,p]=a(`picker`),[h,g]=a(null),[v,y]=a(null),[b,x]=a(`manual`),[S,C]=a(null),[w,T]=a(``),[D,k]=a(null),[A,j]=a(null),[M,N]=a(!1),{data:P}=E({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),ne=t(()=>P?oe(P):null,[P]),L=te({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),R=O(),re=R.data;i(()=>{f!==`discovery`||!v||!h||R.isPending||R.data||R.mutate({addonId:h})},[f,v,h,R]);let ie=ee({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function se(e,t,n,r,i,a,o,s){if(!L.isPending){if(g(e),N(s),x(n),T(r),j(null),o===`broker`){if(!a){j(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),p(`broker`);return}if(o===`account`){p(`config`);return}G(e,r)}}async function G(e,t){try{let n=await L.mutateAsync({addonId:e,name:t,settings:{}});o(),J(),u(`/integrations/${n.id}?add=1`)}catch{}}async function ce(e){if(h)try{let t=await L.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),k(t.id),b===`auto`||b===`both`?p(`discovery`):q(t.id,{openAdd:!0})}catch{}}async function le(e){if(h)try{let t=await L.mutateAsync({addonId:h,name:w,settings:{brokerId:e}});k(t.id),y(t.id),q(t.id)}catch{}}async function K(e){if(h){for(let t of e){let e=re?.find(e=>e.stableId===t);e&&await ie.mutateAsync({addonId:h,candidate:e,...D===null?{}:{integrationId:D}})}q()}}function q(e,t){let n=e??v??h;o(),J(),n&&u(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function J(){p(`picker`),g(null),y(null),x(`manual`),C(null),T(``),k(null),j(null),N(!1)}function Y(){o(),J()}V(n);let X=L.isPending,Z=ae(X,W);if(!n)return null;let ue={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=X?h:null,$=L.error,de=X&&!Z;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[r(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:Y}),e(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:ue[f]}),r(`button`,{onClick:Y,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:r(m,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!X&&r(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),f===`picker`&&e(c,{children:[A&&r(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:A}),r(U,{onSelect:se,onClose:Y,pendingAddonId:Q})]}),f===`config`&&h&&r(z,{addonId:h,configSchema:ne??null,canTest:M,onSave:ce,onBack:()=>p(`picker`)}),f===`broker`&&S&&r(B,{kind:S,onResolved:e=>{le(e)},onBack:()=>p(`picker`)}),f===`discovery`&&v&&r(H,{providerId:v,onImport:K,onSkip:q})]}),X&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[r(_,{className:`h-6 w-6 animate-spin text-primary`}),r(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Z&&r(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Z&&e(c,{children:[r(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),r(`button`,{onClick:Y,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function G({integration:t,expanded:n,onToggleExpand:i}){let{t:a}=F();return e(`div`,{className:`flex items-center gap-2.5`,children:[r(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:r(n?b:x,{className:`h-3.5 w-3.5`})}),r(L,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),r(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function ce(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:P.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>r(G,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:P.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>P.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:P.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>r(T,{status:e.status})}]}o();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var K=`expand`;function q(){let{t:i}=F(),o=I(),s=v(),[u]=ne(),[f,m]=a(!1),h=n(()=>m(!0),[]),_=n(()=>m(!1),[]),[y,b]=a(!1),x=n(()=>b(!0),[]),ee=n(()=>b(!1),[]);M([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),M([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:w,isLoading:T,refetch:E}=A(void 0),{data:O,isLoading:te,refetch:N}=D({projection:`slim`}),P=t(()=>O??[],[O]),L=t(()=>w??[],[w]),z=t(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),B=t(()=>k(w),[w]),V=t(()=>{let e=new Map;for(let t of C(P)){let n=B(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[P,B]),ae=t(()=>L.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:V.get(e.id)??0})),[L,V]),H=u.get(K),U=n(e=>{let t=new URLSearchParams(window.location.search);t.get(K)===e?t.delete(K):t.set(K,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),oe=n(e=>o(`/integrations/${e.id}`),[o]),W=n(e=>z.get(e)??null,[z]),G=n(e=>o(`/devices/${String(e)}`),[o]),q=n(e=>r(S,{context:`integration-detail`,devices:P,trpc:s.trpcClient,integrationOf:B,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:re,resolveParent:W,onNavigate:G}),[P,s.trpcClient,B,W,G]),J=n(e=>H===e.addonId,[H]),Y=t(()=>ce({isExpanded:J,onToggleExpand:U}),[J,U]),X=n(e=>`${e.name} ${e.addonId}`,[]),Z=n(e=>e.addonId,[]),ue=n(()=>{E(),N()},[E,N]),Q=T||te,$=L.length>0;return e(R,{icon:d,title:i(`nav.integrations`,`Integrations`),actions:e(c,{children:[r(`button`,{onClick:ue,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:i(`common.refresh`,`Refresh`),children:r(p,{className:j(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),e(`button`,{onClick:x,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:i(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[r(l,{className:`h-3.5 w-3.5`}),i(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[r(g,{className:`h-3.5 w-3.5`}),i(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&r(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>r(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[r(`p`,{className:`text-sm`,children:i(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),r(`p`,{className:`text-xs mt-1`,children:i(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Q&&$&&r(S,{mode:`generic`,items:ae,getKey:Z,getSearchText:X,columns:Y,onRowClick:oe,isExpanded:J,renderExpanded:q,searchPlaceholder:i(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:i(`integrations.empty`,{defaultValue:`No integrations found.`})}),r(se,{open:f,onClose:_}),r(ie,{open:y,onClose:ee})]})}export{q as IntegrationsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fn as f,It as p,On as m,ht as h,kn as g,ln as _,nr as v,or as y,ot as b,xn as x}from"./player-overlays-DfIXPXfC.js";import{Ci as S,Jr as ee,en as C}from"./client-fa7ANI4X.js";import{h as w,s as T}from"./video-FHJCba2c.js";import{t as E}from"./log-in-IPEzbjqk.js";import{t as D}from"./monitor-smartphone-DhnI06Vd.js";import{t as te}from"./recycle-CIxCuRlw.js";import{Al as O,Cn as ne,Er as k,Fa as A,Gr as j,Ot as M,Qr as N,Ur as re,_r as P,da as F,fa as ie,fr as I,hr as L,ht as ae,kr as oe,kt as R,la as z,ma as B,mr as se,oa as V,pa as H,pr as ce,pt as le,sa as U,sr as ue,ua as W,ut as G,vr as de,xi as fe}from"./src-Cy_bal4g.js";import{t as K}from"./i18n-l_m6iBJW.js";import{t as q}from"./useTranslation-BJr-n0es.js";import{P as J,fr as pe,h as Y,i as me,mr as he,x as ge}from"./index-Ctkts88E.js";import{t as _e}from"./AdminSectionedPage-CJhCo7eS.js";import{t as ve}from"./BrokerForm-B1b0ZQq_.js";import{t as ye}from"./NodeAddonsSettingsPanel-75hJ0AJM.js";import{n as be,r as X,t as xe}from"./IntegrationHub-DdxMGRIt.js";c();var Z=`kind`,Q=`name`,Se=`restore`,Ce=`restoreId`;function we(e){return{sections:[{id:`broker-identity`,title:K.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:[{type:`select`,key:Z,label:K.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label})),disabled:e.length<=1},{type:`text`,key:Q,label:K.t(`helpers.brokerIdentitySchema.name`),placeholder:K.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0},{type:`boolean`,key:Se,label:K.t(`helpers.brokerIdentitySchema.restore`),description:K.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:Ce,label:K.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Se,equals:!0}}]}]}}function Te(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(Z);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Q);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(Ce);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}var Ee={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function De(e){return Ee[e]??e}function Oe(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var ke={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function Ae({status:e}){return i(N,{variant:ke[e],className:`text-[10px]`,children:e})}function je(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Me({title:t,subtitle:n,onClose:r,children:a}){return i(I,{open:!0,onOpenChange:e=>!e&&r(),children:e(se,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(P,{children:[i(de,{children:t}),n&&i(L,{children:n})]}),i(ce,{className:`space-y-3 pr-1`,children:a})]})})}function Ne({kinds:t,onClose:r,onDone:a}){let{t:s}=q(),c=l(),u=n(()=>we(t.map(e=>({key:$(e),label:e.label}))),[t]),[d,f]=o(()=>({[Z]:$(t[0]),[Q]:``,[Se]:!1,[Ce]:``})),[p,m]=o(null),h=t.find(e=>$(e)===d.kind)??t[0],g=h?.kind??``,_=h?.addonId,v=h?.interactiveConnectPath,y=V({onSuccess:e=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]});let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null;t!==null&&v!==void 0&&v.length>0&&Y(v,t,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}),a()}}),b=e=>{let t=Te(d);if(!t.ok){m(t.problem);return}m(null);let{name:n,restoreId:r}=t.identity;y.mutate({kind:g,name:n,settings:e,...r===null?{}:{id:r},..._===void 0?{}:{addonId:_}})};return e(Me,{title:s(`brokers.brokerManager.addBroker`,`Add broker`),subtitle:s(`brokers.brokerManager.registerAMessageBrokerFor`,`Register a message broker for exporters and automations.`),onClose:y.isPending?()=>{}:r,children:[i(J,{schema:u,values:d,onChange:f}),p!==null&&i(k,{message:p}),y.isError&&i(k,{message:y.error instanceof Error?y.error.message:String(y.error)}),g&&i(ve,{kind:g,..._===void 0?{}:{addonId:_},onSubmit:b,onCancel:r,submitLabel:y.isPending?s(`brokers.brokerManager.adding`,`Adding…`):s(`brokers.brokerManager.addBroker`,`Add broker`),disabled:y.isPending},$(h))]})}function $(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Pe({broker:t,onClose:r,onDone:a}){let{t:o}=q(),s=l(),c=U({id:t.id,addonId:t.addonId}),u=H({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:t.id,addonId:t.addonId}}]}),a()}}),d=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return i(Me,{title:o(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:t.name}),subtitle:`${De(t.kind)} · ${t.id}`,onClose:u.isPending?()=>{}:r,children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.brokerManager.loadingSettings`)]}):c.isError?e(`div`,{className:`space-y-3`,children:[i(k,{message:o(`brokers.brokerManager.loadSettingsFailed`,{message:c.error instanceof Error?c.error.message:o(`common.unknownError`)})}),i(`div`,{className:`flex justify-end`,children:i(j,{variant:`outline`,size:`sm`,onClick:r,children:o(`common.close`,`Close`)})})]}):e(`div`,{className:`space-y-3`,children:[u.isError&&i(k,{message:u.error instanceof Error?u.error.message:String(u.error)}),i(ve,{kind:t.kind,addonId:t.addonId,brokerId:t.id,initialValues:d,onSubmit:e=>{u.mutate({id:t.id,settings:e,addonId:t.addonId})},onCancel:r,submitLabel:u.isPending?o(`brokers.brokerManager.saving`,`Saving…`):o(`common.save`,`Save`),disabled:u.isPending})]})})}function Fe({broker:t,interactiveConnectPath:n,interactiveDisconnectPath:r,onEdit:a}){let{t:s}=q(),c=l(),u=re(),[d,m]=o(null),g=B({onSuccess:e=>m(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>m({ok:!1,error:e instanceof Error?e.message:String(e)})}),_=ie({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),v=async()=>{await u({title:s(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:s(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:t.name}),confirmLabel:s(`common.delete`,`Delete`),variant:`danger`})&&_.mutate({id:t.id,addonId:t.addonId})},b=n!==void 0&&n.length>0&&t.status!==`connected`,x=r!==void 0&&r.length>0&&t.status===`connected`;return e(`tr`,{className:`border-b border-border last:border-0`,children:[i(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:t.name}),i(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:De(t.kind)}),e(`td`,{className:`px-3 py-2`,children:[i(Ae,{status:t.status}),d&&i(`span`,{className:`ml-2 text-[10px] ${d.ok?`text-success`:`text-danger`}`,children:d.ok?`OK`:d.error??s(`common.failedWord`)})]}),i(`td`,{className:`px-3 py-2`,children:e(`div`,{className:`flex items-center justify-end gap-1.5`,children:[b&&e(j,{variant:`primary`,size:`sm`,onClick:()=>{Y(n,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signIn`)]}),x&&e(j,{variant:`outline`,size:`sm`,onClick:()=>{Y(r,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signOut`)]}),e(j,{variant:`outline`,size:`sm`,onClick:()=>g.mutate({id:t.id,addonId:t.addonId}),disabled:g.isPending,title:s(`brokers.brokerManager.testConnection`,`Test connection`),children:[g.isPending?i(y,{className:`h-3 w-3 animate-spin`}):i(h,{className:`h-3 w-3`}),s(`brokers.brokerManager.test`,`Test`)]}),e(j,{variant:`outline`,size:`sm`,onClick:()=>a(t),title:s(`common.edit`,`Edit`),children:[i(f,{className:`h-3 w-3`}),` `,s(`common.edit`)]}),e(j,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{v()},disabled:_.isPending,title:s(`common.delete`,`Delete`),children:[_.isPending?i(y,{className:`h-3 w-3 animate-spin`}):i(p,{className:`h-3 w-3`}),s(`common.delete`,`Delete`)]})]})})]})}function Ie({addonId:t}={}){let{t:r}=q(),a=W({}),s=F(),c=n(()=>je(a.data).filter(e=>t===void 0||e.addonId===t),[a.data,t]),[l,u]=o(!1),[d,f]=o(null),p=n(()=>{let e=new Map;for(let n of Oe(s.data))if(!(t!==void 0&&n.addonId!==t))for(let t of n.kinds){let r=typeof t.interactiveConnectPath==`string`&&t.interactiveConnectPath.length>0?t.interactiveConnectPath:void 0,i=typeof t.interactiveDisconnectPath==`string`&&t.interactiveDisconnectPath.length>0?t.interactiveDisconnectPath:void 0;e.set(`${n.addonId}::${t.kind}`,{addonId:n.addonId,kind:t.kind,label:t.label,...r===void 0?{}:{interactiveConnectPath:r},...i===void 0?{}:{interactiveDisconnectPath:i}})}for(let t of c)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:De(t.kind)});return[...e.values()]},[c,s.data,t]),m=n(()=>{let e=new Map;for(let t of p)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[p]);return e(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex items-center justify-end`,children:e(j,{variant:`primary`,size:`sm`,onClick:()=>u(!0),disabled:p.length===0,title:p.length===0?r(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[i(g,{className:`h-3.5 w-3.5`}),` `,r(`brokers.brokerManager.addBroker`)]})}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:e(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[i(`thead`,{children:e(`tr`,{className:`border-b border-border bg-background/50`,children:[i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.name`,`Name`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.kind`,`Kind`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.status`,`Status`)}),i(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.actions`,`Actions`)})]})}),e(`tbody`,{children:[a.isLoading&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[i(y,{className:`inline h-4 w-4 animate-spin`}),` `,r(`brokers.brokerManager.loadingBrokers`)]})}),a.isError&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[r(`brokers.brokerManager.failedToLoadBrokers`,`Failed to load brokers:`),` `,a.error instanceof Error?a.error.message:r(`brokers.brokerManager.unknownError`,`Unknown error`)]})}),!a.isLoading&&!a.isError&&c.length===0&&i(`tr`,{children:i(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:r(`brokers.brokerManager.noBrokersRegisteredYetAdd`,`No brokers registered yet. Add one to publish device events for downstream automations.`)})}),c.map(e=>{let t=m.get(e.kind);return i(Fe,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},onEdit:f},e.id)})]})]})}),l&&i(Ne,{kinds:p,onClose:()=>u(!1),onDone:()=>u(!1)}),d&&i(Pe,{broker:d,onClose:()=>f(null),onDone:()=>f(null)})]})}c();function Le({addonId:e,fallback:t}){let{t:n}=q(),r=O({});if(r.isPending)return i(`div`,{className:`flex justify-center py-8`,children:i(y,{className:`size-6 animate-spin text-muted-foreground`})});if(r.isError)return i(k,{message:n(`brokers.brokerRecordEntriesPanel.loadKindsFailed`,`Could not load entry kinds`)});let a=r.data.kinds.find(t=>t.owner===e&&t.kind===`brokers`);return a===void 0?t:i(Re,{addonId:e,kind:a})}function Re({addonId:t,kind:r}){let{t:a}=q(),o=l(),s=W({}),c=F(),u=n(()=>{let e=new Map;for(let n of je(s.data))n.addonId===t&&e.set(n.id,n);return e},[s.data,t]),f=n(()=>{let e=new Map;for(let t of Oe(c.data))for(let n of t.kinds){let r=n.interactiveConnectPath,i=n.interactiveDisconnectPath;e.set(`${t.addonId}::${n.kind}`,{...typeof r==`string`&&r.length>0?{connect:r}:{},...typeof i==`string`&&i.length>0?{disconnect:i}:{}})}return e},[c.data]),p=()=>{o.invalidateQueries({queryKey:[[`broker`]]}),o.invalidateQueries({queryKey:[[`recordEntries`]]})};return i(G,{kind:r,extraColumns:n(()=>[{key:`status`,header:a(`brokers.brokerManager.status`,`Status`),nowrap:!0,width:`w-px`,render:e=>{let t=u.get(e.id);return t===void 0?null:i(Ae,{status:t.status})}}],[u,a]),rowActions:t=>{let n=u.get(t.id);if(n===void 0)return null;let r=f.get(`${n.addonId}::${n.kind}`);if(r===void 0)return null;let o=n.status===`connected`;return e(d,{children:[r.connect!==void 0&&!o&&e(j,{variant:`primary`,size:`sm`,"aria-label":a(`brokers.brokerManager.signIn`),onClick:()=>Y(r.connect??``,n.id,p),title:a(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signIn`)})]}),r.disconnect!==void 0&&o&&e(j,{variant:`outline`,size:`sm`,"aria-label":a(`brokers.brokerManager.signOut`),onClick:()=>Y(r.disconnect??``,n.id,p),title:a(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signOut`)})]})]})},showUpdated:!1,minWidthPx:340})}function ze(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function Be(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(ze).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function Ve(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function He(e,t){return t.find(t=>e.capNames.includes(t))??null}function Ue(e){switch(e){case`running`:return{state:`ok`,label:K.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:K.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??K.t(`common.unknownWord`)}}}c();var We=[`wasteCollections`,`listSources`],Ge=[`wasteCollections`,`listCountries`];function Ke(e){return e instanceof Error?e.message:String(e)}function qe(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function Je(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`enabled`),o=Reflect.get(n,`formValues`),s=Reflect.get(n,`serviceId`),c=Reflect.get(n,`countryId`);t.push({id:e,label:r,module:i,enabled:typeof a==`boolean`?a:!0,formValues:typeof o==`object`&&o&&!Array.isArray(o)?o:void 0,serviceId:typeof s==`string`?s:void 0,countryId:typeof c==`string`?c:void 0})}return t}function Ye(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`);return typeof t!=`string`||typeof n!=`string`?[]:[{id:t,label:n}]}):[]}function Xe(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`),r=Reflect.get(e,`module`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return[];let i=Reflect.get(e,`title`);return[{id:t,label:n,title:typeof i==`string`&&i.length>0?i:n,module:r}]}):[]}function Ze(e,t,n){return{sections:[{id:`picker`,title:K.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:K.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:K.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:K.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?K.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):K.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function Qe({addonId:c,capName:f}){let{t:m}=q(),h=b(),_=l(),v=re(),y=le({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,S]=o(!1),[ee,C]=o(null),[w,T]=o({countryId:``,serviceId:``}),[E,D]=o({label:m(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),O=t(null),k=typeof w.countryId==`string`?w.countryId:``,A=typeof w.serviceId==`string`?w.serviceId:``,M=r((e,t)=>h.trpcClient.addons.custom.mutate({addonId:c,action:e,input:t}),[c,h]),P=s({queryKey:[...We,c],queryFn:async()=>Je(await M(`listSources`,{}))}),F=s({queryKey:[...Ge,c],queryFn:async()=>Ye(await M(`listCountries`,{}))}),ie=s({queryKey:[`wasteCollections`,`listServices`,c,k],enabled:k!==``,queryFn:async()=>Xe(await M(`listServices`,{countryId:k}))}),I=s({queryKey:[`wasteCollections`,`serviceFormSchema`,c,A],enabled:A!==``,queryFn:async()=>M(`serviceFormSchema`,{serviceId:A})}),L=P.data??[],R=F.data??[],z=ie.data??[],B=qe(I.data)?I.data:void 0,se=n(()=>Ze(R,k===``?[]:z,k),[R,z,k]),V=y.state,H=V.mode===`edit`?L.find(e=>e.id===V.id)??null:null;a(()=>{if(y.state.mode===`edit`&&H!==null){let e=`edit:${H.id}`;if(O.current===e)return;O.current=e,C(null),T({countryId:H.countryId??``,serviceId:H.serviceId??``}),D(H.formValues===void 0?{label:H.label,enabled:H.enabled}:{...H.formValues});return}if(y.state.mode===`new`){if(O.current===`new`)return;O.current=`new`,C(null),T({countryId:``,serviceId:``}),D({label:m(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[H,y.state]),a(()=>{if(y.state.mode!==`new`||A===``)return;let e=z.find(e=>e.id===A);e&&D(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[y.state.mode,A,z]);let ce=r(e=>{T(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),U=r(async()=>{await _.invalidateQueries({queryKey:We})},[_]),W=u({mutationFn:async e=>M(`deleteSource`,{id:e}),onSuccess:async()=>U()}),G=r(async e=>{await v({title:m(`system.wasteSettingsSources.deleteWasteSource`,`Delete waste source?`),message:m(`system.wasteSettingsSources.removeItsCalendarUnderSystem`,`Remove “{{label}}” ({{id}}). Its calendar under System → Calendars is dropped.`,{label:e.label,id:e.id}),confirmLabel:m(`common.delete`,`Delete`),cancelLabel:m(`common.cancel`,`Cancel`),variant:`danger`})&&(await W.mutateAsync(e.id),y.state.mode===`edit`&&y.state.id===e.id&&(y.close(),O.current=null))},[v,W,y,m]),de=r(async()=>{let e=E.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){C(`Label is required.`);return}if(A===``){C(`Pick a country and a service.`);return}let n=y.state.mode===`new`,r=H?.id;if(!n&&(r===void 0||r===``)){C(`That source is no longer available.`);return}let i=E.enabled,a={...E};delete a.label,delete a.enabled,S(!0),C(null);try{n?await M(`createSource`,{label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await M(`updateSource`,{id:r,label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}),await U(),y.close(),O.current=null}catch(e){C(Ke(e))}finally{S(!1)}},[M,H,y,E,U,A]),fe=n(()=>[{key:`label`,header:m(`system.wasteSettingsSources.label`,`Label`),sortValue:e=>e.label,render:e=>i(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:m(`system.wasteSettingsSources.module`,`Module`),sortValue:e=>e.module,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:m(`system.wasteSettingsSources.enabled`,`Enabled`),sortValue:e=>+!!e.enabled,render:e=>i(N,{variant:e.enabled?`success`:`default`,children:e.enabled?m(`system.wasteSettingsSources.on`,`On`):m(`system.wasteSettingsSources.off`,`Off`)})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>i(j,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":m(`system.wasteSettingsSources.delete`,`Delete {{label}}`,{label:e.label}),"data-testid":`waste-source-delete-${e.id}`,onClick:t=>{t.stopPropagation(),G(e)},children:i(p,{className:`h-3.5 w-3.5 text-danger`})})}],[G,m]),K=y.state.mode===`new`,J=K||H!==null,pe=`${A}:${K?`new`:H?.id??`closed`}`;return e(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.pickACountryAndA`,`Pick a country and a service — configuration fields come from that HACS source.`)}),e(j,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>y.openNew(),children:[i(g,{className:`h-3.5 w-3.5`}),m(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),P.isError?i(`p`,{className:`text-sm text-danger`,children:m(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,P.isPending?i(oe,{className:`h-32 w-full`}):i(ne,{columns:fe,rows:L,rowKey:e=>e.id,pageSize:25,emptyMessage:m(`system.wasteSettingsSources.noWasteSourcesYetAdd`,`No waste sources yet. Add one to register a municipal service.`),onRowClick:e=>y.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),i(ae,{open:J,onClose:()=>{y.close(),C(null),O.current=null},title:K?m(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):m(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:H?.label??`source`}),icon:te,width:`xl`,testId:`waste-source-editor`,error:ee,footer:i(j,{type:`button`,size:`sm`,disabled:x||A===``,onClick:()=>void de(),children:x?m(`system.wasteSettingsSources.saving`,`Saving…`):m(`common.save`,`Save`)}),children:J?e(d,{children:[i(`div`,{"data-testid":`waste-country-service`,children:i(ue,{schema:se,values:w,onChange:ce},`picker:${k}:${z.length}`)}),A!==``&&B!==void 0?i(ue,{schema:B,values:E,onChange:D,bare:!0},pe):A!==``&&I.isPending?i(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.loadingFields`,`Loading fields…`)}):i(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.chooseACountryAndService`,`Choose a country and service to see the required fields.`)})]}):null}),i(ye,{nodeId:`hub`,addonIds:[c],level:`global`,capability:f,hideSectionChrome:!0})]})}c();var $e=1e4,et={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},tt=[{sectionId:`exporters`,kind:`device-export`,labelKey:`system.connectivity.exporters`,icon:_,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`},{sectionId:`email`,kind:`email`,labelKey:`system.connectivity.email`,icon:v,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:x,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:w,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function nt(t,n,r,a){let o=Ve(C,t.kind),s=n.flatMap(n=>{let a=He(n,o);if(a===null)return[];let s=Ue(n.processState);return[{id:n.addonId,name:n.displayName,fallbackIcon:t.icon,state:s.state,stateLabel:s.label,render:()=>i(be,{addonId:n.addonId,displayName:n.displayName,capName:a,isActive:n.processState===`running`,badges:e(d,{children:[i(ot,{processState:n.processState}),i(st,{kind:t.kind,addonId:n.addonId})]}),lead:t.kind===`device-export`?i(R,{addonId:n.addonId}):void 0,panels:at(t.kind,n.addonId,e=>r(`/devices/${e}`)),settingsContent:n.addonId===`waste-collections`?i(Qe,{addonId:n.addonId,capName:a}):void 0})}]});return{id:t.sectionId,label:a(t.labelKey),entries:s,install:{capability:o[0]??t.kind,label:a(t.installLabelKey)}}}function rt({descriptor:e,rows:t,isLoading:r}){let{t:a}=q(),o=pe(),s=n(()=>nt(e,t,o,a),[e,t,o,a]);return i(xe,{embedded:!0,icon:e.icon,title:a(e.labelKey),subtitle:null,groups:[s],isLoading:r,emptyTitle:a(e.emptyTitleKey),emptyDescription:a(e.emptyDescriptionKey)})}function it(){let{t:e}=q(),t=fe(void 0,{refetchInterval:$e}),[r,o]=he(),s=ge(`/system/integrations`,{t:e,isAdmin:!0})??{icon:m,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};a(()=>{let e=r.get(`tab`);if(e===null)return;let t=et[e];t===void 0||t===e||o(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[r,o]);let c=n(()=>(t.data??[]).map(Be).filter(e=>e!==null),[t.data]),l=n(()=>tt.map(n=>({id:n.sectionId,label:e(n.labelKey),ownedParams:me,content:i(rt,{descriptor:n,rows:c,isLoading:t.isLoading})})),[t.isLoading,c,e]);return i(_e,{icon:s.icon,title:s.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:l})}function at(e,t,n){return e===`device-export`?[{id:`devices`,title:K.t(`admin.system.integrations.devices`,`Devices`),icon:D,placement:`end`,content:i(M,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:K.t(`admin.system.integrations.connections`,`Connections`),icon:x,content:i(Le,{addonId:t,fallback:i(Ie,{addonId:t})})}]:[]}function ot({processState:e}){let{state:t,label:n}=Ue(e);return i(N,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${X} capitalize`,children:n})}function st({kind:e,addonId:t}){return e===`broker`?i(ct,{addonId:t}):e===`device-export`?i(lt,{addonId:t}):null}function ct({addonId:e}){let{t}=q(),{data:n}=z({addonId:e},{refetchInterval:$e,retry:!1}),r=S.safeParse(n);if(!r.success)return null;let{brokerCount:a,connectedCount:o}=r.data;return i(N,{variant:`info`,className:X,children:o>0?t(`system.connectivity.connectionsConnected`,{count:a,connected:o}):t(`system.connectivity.connections`,{count:a})})}function lt({addonId:e}){let{t}=q(),{data:n}=A({addonId:e},{refetchInterval:$e,retry:!1}),r=ee.safeParse(n);if(!r.success)return null;let{linkState:a,exposedDeviceCount:o}=r.data;return i(N,{variant:a===`linked`?`success`:a===`error`?`danger`:`default`,className:X,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:a,exposedDeviceCount:o})})}export{it as IntegrationsPage};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fn as f,It as p,On as m,ht as h,kn as g,ln as _,nr as v,or as y,ot as b,xn as x}from"./player-overlays-Dbv95cvz.js";import{Ci as S,Jr as ee,en as C}from"./client-DvJxGh2F.js";import{h as w,s as T}from"./video-D7jv0spx.js";import{t as E}from"./log-in-D1BPSCDn.js";import{t as D}from"./monitor-smartphone-6w2T5Ht_.js";import{t as te}from"./recycle-DcScXiTi.js";import{Al as O,Cn as ne,Er as k,Fa as A,Gr as j,Ot as M,Qr as N,Ur as re,_r as P,da as F,fa as ie,fr as I,hr as L,ht as ae,kr as oe,kt as R,la as z,ma as B,mr as se,oa as V,pa as H,pr as ce,pt as le,sa as U,sr as ue,ua as W,ut as G,vr as de,xi as fe}from"./src-ByunGuTZ.js";import{t as K}from"./i18n-l_m6iBJW.js";import{t as q}from"./useTranslation-BJr-n0es.js";import{P as J,fr as pe,h as Y,i as me,mr as he,x as ge}from"./index-BFjKpxae.js";import{t as _e}from"./AdminSectionedPage-B77fFYLu.js";import{t as ve}from"./BrokerForm-Dql4j_7g.js";import{t as ye}from"./NodeAddonsSettingsPanel-P5f0HKwt.js";import{n as be,r as X,t as xe}from"./IntegrationHub-Ch94ozNN.js";c();var Z=`kind`,Q=`name`,Se=`restore`,Ce=`restoreId`;function we(e){return{sections:[{id:`broker-identity`,title:K.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:[{type:`select`,key:Z,label:K.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label})),disabled:e.length<=1},{type:`text`,key:Q,label:K.t(`helpers.brokerIdentitySchema.name`),placeholder:K.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0},{type:`boolean`,key:Se,label:K.t(`helpers.brokerIdentitySchema.restore`),description:K.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:Ce,label:K.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Se,equals:!0}}]}]}}function Te(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(Z);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Q);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(Ce);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}var Ee={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function De(e){return Ee[e]??e}function Oe(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var ke={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function Ae({status:e}){return i(N,{variant:ke[e],className:`text-[10px]`,children:e})}function je(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Me({title:t,subtitle:n,onClose:r,children:a}){return i(I,{open:!0,onOpenChange:e=>!e&&r(),children:e(se,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(P,{children:[i(de,{children:t}),n&&i(L,{children:n})]}),i(ce,{className:`space-y-3 pr-1`,children:a})]})})}function Ne({kinds:t,onClose:r,onDone:a}){let{t:s}=q(),c=l(),u=n(()=>we(t.map(e=>({key:$(e),label:e.label}))),[t]),[d,f]=o(()=>({[Z]:$(t[0]),[Q]:``,[Se]:!1,[Ce]:``})),[p,m]=o(null),h=t.find(e=>$(e)===d.kind)??t[0],g=h?.kind??``,_=h?.addonId,v=h?.interactiveConnectPath,y=V({onSuccess:e=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]});let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null;t!==null&&v!==void 0&&v.length>0&&Y(v,t,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}),a()}}),b=e=>{let t=Te(d);if(!t.ok){m(t.problem);return}m(null);let{name:n,restoreId:r}=t.identity;y.mutate({kind:g,name:n,settings:e,...r===null?{}:{id:r},..._===void 0?{}:{addonId:_}})};return e(Me,{title:s(`brokers.brokerManager.addBroker`,`Add broker`),subtitle:s(`brokers.brokerManager.registerAMessageBrokerFor`,`Register a message broker for exporters and automations.`),onClose:y.isPending?()=>{}:r,children:[i(J,{schema:u,values:d,onChange:f}),p!==null&&i(k,{message:p}),y.isError&&i(k,{message:y.error instanceof Error?y.error.message:String(y.error)}),g&&i(ve,{kind:g,..._===void 0?{}:{addonId:_},onSubmit:b,onCancel:r,submitLabel:y.isPending?s(`brokers.brokerManager.adding`,`Adding…`):s(`brokers.brokerManager.addBroker`,`Add broker`),disabled:y.isPending},$(h))]})}function $(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Pe({broker:t,onClose:r,onDone:a}){let{t:o}=q(),s=l(),c=U({id:t.id,addonId:t.addonId}),u=H({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:t.id,addonId:t.addonId}}]}),a()}}),d=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return i(Me,{title:o(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:t.name}),subtitle:`${De(t.kind)} · ${t.id}`,onClose:u.isPending?()=>{}:r,children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(y,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.brokerManager.loadingSettings`)]}):c.isError?e(`div`,{className:`space-y-3`,children:[i(k,{message:o(`brokers.brokerManager.loadSettingsFailed`,{message:c.error instanceof Error?c.error.message:o(`common.unknownError`)})}),i(`div`,{className:`flex justify-end`,children:i(j,{variant:`outline`,size:`sm`,onClick:r,children:o(`common.close`,`Close`)})})]}):e(`div`,{className:`space-y-3`,children:[u.isError&&i(k,{message:u.error instanceof Error?u.error.message:String(u.error)}),i(ve,{kind:t.kind,addonId:t.addonId,brokerId:t.id,initialValues:d,onSubmit:e=>{u.mutate({id:t.id,settings:e,addonId:t.addonId})},onCancel:r,submitLabel:u.isPending?o(`brokers.brokerManager.saving`,`Saving…`):o(`common.save`,`Save`),disabled:u.isPending})]})})}function Fe({broker:t,interactiveConnectPath:n,interactiveDisconnectPath:r,onEdit:a}){let{t:s}=q(),c=l(),u=re(),[d,m]=o(null),g=B({onSuccess:e=>m(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>m({ok:!1,error:e instanceof Error?e.message:String(e)})}),_=ie({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),v=async()=>{await u({title:s(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:s(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:t.name}),confirmLabel:s(`common.delete`,`Delete`),variant:`danger`})&&_.mutate({id:t.id,addonId:t.addonId})},b=n!==void 0&&n.length>0&&t.status!==`connected`,x=r!==void 0&&r.length>0&&t.status===`connected`;return e(`tr`,{className:`border-b border-border last:border-0`,children:[i(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:t.name}),i(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:De(t.kind)}),e(`td`,{className:`px-3 py-2`,children:[i(Ae,{status:t.status}),d&&i(`span`,{className:`ml-2 text-[10px] ${d.ok?`text-success`:`text-danger`}`,children:d.ok?`OK`:d.error??s(`common.failedWord`)})]}),i(`td`,{className:`px-3 py-2`,children:e(`div`,{className:`flex items-center justify-end gap-1.5`,children:[b&&e(j,{variant:`primary`,size:`sm`,onClick:()=>{Y(n,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signIn`)]}),x&&e(j,{variant:`outline`,size:`sm`,onClick:()=>{Y(r,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signOut`)]}),e(j,{variant:`outline`,size:`sm`,onClick:()=>g.mutate({id:t.id,addonId:t.addonId}),disabled:g.isPending,title:s(`brokers.brokerManager.testConnection`,`Test connection`),children:[g.isPending?i(y,{className:`h-3 w-3 animate-spin`}):i(h,{className:`h-3 w-3`}),s(`brokers.brokerManager.test`,`Test`)]}),e(j,{variant:`outline`,size:`sm`,onClick:()=>a(t),title:s(`common.edit`,`Edit`),children:[i(f,{className:`h-3 w-3`}),` `,s(`common.edit`)]}),e(j,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{v()},disabled:_.isPending,title:s(`common.delete`,`Delete`),children:[_.isPending?i(y,{className:`h-3 w-3 animate-spin`}):i(p,{className:`h-3 w-3`}),s(`common.delete`,`Delete`)]})]})})]})}function Ie({addonId:t}={}){let{t:r}=q(),a=W({}),s=F(),c=n(()=>je(a.data).filter(e=>t===void 0||e.addonId===t),[a.data,t]),[l,u]=o(!1),[d,f]=o(null),p=n(()=>{let e=new Map;for(let n of Oe(s.data))if(!(t!==void 0&&n.addonId!==t))for(let t of n.kinds){let r=typeof t.interactiveConnectPath==`string`&&t.interactiveConnectPath.length>0?t.interactiveConnectPath:void 0,i=typeof t.interactiveDisconnectPath==`string`&&t.interactiveDisconnectPath.length>0?t.interactiveDisconnectPath:void 0;e.set(`${n.addonId}::${t.kind}`,{addonId:n.addonId,kind:t.kind,label:t.label,...r===void 0?{}:{interactiveConnectPath:r},...i===void 0?{}:{interactiveDisconnectPath:i}})}for(let t of c)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:De(t.kind)});return[...e.values()]},[c,s.data,t]),m=n(()=>{let e=new Map;for(let t of p)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[p]);return e(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex items-center justify-end`,children:e(j,{variant:`primary`,size:`sm`,onClick:()=>u(!0),disabled:p.length===0,title:p.length===0?r(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[i(g,{className:`h-3.5 w-3.5`}),` `,r(`brokers.brokerManager.addBroker`)]})}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:e(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[i(`thead`,{children:e(`tr`,{className:`border-b border-border bg-background/50`,children:[i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.name`,`Name`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.kind`,`Kind`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.status`,`Status`)}),i(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.actions`,`Actions`)})]})}),e(`tbody`,{children:[a.isLoading&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[i(y,{className:`inline h-4 w-4 animate-spin`}),` `,r(`brokers.brokerManager.loadingBrokers`)]})}),a.isError&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[r(`brokers.brokerManager.failedToLoadBrokers`,`Failed to load brokers:`),` `,a.error instanceof Error?a.error.message:r(`brokers.brokerManager.unknownError`,`Unknown error`)]})}),!a.isLoading&&!a.isError&&c.length===0&&i(`tr`,{children:i(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:r(`brokers.brokerManager.noBrokersRegisteredYetAdd`,`No brokers registered yet. Add one to publish device events for downstream automations.`)})}),c.map(e=>{let t=m.get(e.kind);return i(Fe,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},onEdit:f},e.id)})]})]})}),l&&i(Ne,{kinds:p,onClose:()=>u(!1),onDone:()=>u(!1)}),d&&i(Pe,{broker:d,onClose:()=>f(null),onDone:()=>f(null)})]})}c();function Le({addonId:e,fallback:t}){let{t:n}=q(),r=O({});if(r.isPending)return i(`div`,{className:`flex justify-center py-8`,children:i(y,{className:`size-6 animate-spin text-muted-foreground`})});if(r.isError)return i(k,{message:n(`brokers.brokerRecordEntriesPanel.loadKindsFailed`,`Could not load entry kinds`)});let a=r.data.kinds.find(t=>t.owner===e&&t.kind===`brokers`);return a===void 0?t:i(Re,{addonId:e,kind:a})}function Re({addonId:t,kind:r}){let{t:a}=q(),o=l(),s=W({}),c=F(),u=n(()=>{let e=new Map;for(let n of je(s.data))n.addonId===t&&e.set(n.id,n);return e},[s.data,t]),f=n(()=>{let e=new Map;for(let t of Oe(c.data))for(let n of t.kinds){let r=n.interactiveConnectPath,i=n.interactiveDisconnectPath;e.set(`${t.addonId}::${n.kind}`,{...typeof r==`string`&&r.length>0?{connect:r}:{},...typeof i==`string`&&i.length>0?{disconnect:i}:{}})}return e},[c.data]),p=()=>{o.invalidateQueries({queryKey:[[`broker`]]}),o.invalidateQueries({queryKey:[[`recordEntries`]]})};return i(G,{kind:r,extraColumns:n(()=>[{key:`status`,header:a(`brokers.brokerManager.status`,`Status`),nowrap:!0,width:`w-px`,render:e=>{let t=u.get(e.id);return t===void 0?null:i(Ae,{status:t.status})}}],[u,a]),rowActions:t=>{let n=u.get(t.id);if(n===void 0)return null;let r=f.get(`${n.addonId}::${n.kind}`);if(r===void 0)return null;let o=n.status===`connected`;return e(d,{children:[r.connect!==void 0&&!o&&e(j,{variant:`primary`,size:`sm`,"aria-label":a(`brokers.brokerManager.signIn`),onClick:()=>Y(r.connect??``,n.id,p),title:a(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signIn`)})]}),r.disconnect!==void 0&&o&&e(j,{variant:`outline`,size:`sm`,"aria-label":a(`brokers.brokerManager.signOut`),onClick:()=>Y(r.disconnect??``,n.id,p),title:a(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signOut`)})]})]})},showUpdated:!1,minWidthPx:340})}function ze(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function Be(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(ze).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function Ve(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function He(e,t){return t.find(t=>e.capNames.includes(t))??null}function Ue(e){switch(e){case`running`:return{state:`ok`,label:K.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:K.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??K.t(`common.unknownWord`)}}}c();var We=[`wasteCollections`,`listSources`],Ge=[`wasteCollections`,`listCountries`];function Ke(e){return e instanceof Error?e.message:String(e)}function qe(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function Je(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`enabled`),o=Reflect.get(n,`formValues`),s=Reflect.get(n,`serviceId`),c=Reflect.get(n,`countryId`);t.push({id:e,label:r,module:i,enabled:typeof a==`boolean`?a:!0,formValues:typeof o==`object`&&o&&!Array.isArray(o)?o:void 0,serviceId:typeof s==`string`?s:void 0,countryId:typeof c==`string`?c:void 0})}return t}function Ye(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`);return typeof t!=`string`||typeof n!=`string`?[]:[{id:t,label:n}]}):[]}function Xe(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`),r=Reflect.get(e,`module`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return[];let i=Reflect.get(e,`title`);return[{id:t,label:n,title:typeof i==`string`&&i.length>0?i:n,module:r}]}):[]}function Ze(e,t,n){return{sections:[{id:`picker`,title:K.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:K.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:K.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:K.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?K.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):K.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function Qe({addonId:c,capName:f}){let{t:m}=q(),h=b(),_=l(),v=re(),y=le({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,S]=o(!1),[ee,C]=o(null),[w,T]=o({countryId:``,serviceId:``}),[E,D]=o({label:m(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),O=t(null),k=typeof w.countryId==`string`?w.countryId:``,A=typeof w.serviceId==`string`?w.serviceId:``,M=r((e,t)=>h.trpcClient.addons.custom.mutate({addonId:c,action:e,input:t}),[c,h]),P=s({queryKey:[...We,c],queryFn:async()=>Je(await M(`listSources`,{}))}),F=s({queryKey:[...Ge,c],queryFn:async()=>Ye(await M(`listCountries`,{}))}),ie=s({queryKey:[`wasteCollections`,`listServices`,c,k],enabled:k!==``,queryFn:async()=>Xe(await M(`listServices`,{countryId:k}))}),I=s({queryKey:[`wasteCollections`,`serviceFormSchema`,c,A],enabled:A!==``,queryFn:async()=>M(`serviceFormSchema`,{serviceId:A})}),L=P.data??[],R=F.data??[],z=ie.data??[],B=qe(I.data)?I.data:void 0,se=n(()=>Ze(R,k===``?[]:z,k),[R,z,k]),V=y.state,H=V.mode===`edit`?L.find(e=>e.id===V.id)??null:null;a(()=>{if(y.state.mode===`edit`&&H!==null){let e=`edit:${H.id}`;if(O.current===e)return;O.current=e,C(null),T({countryId:H.countryId??``,serviceId:H.serviceId??``}),D(H.formValues===void 0?{label:H.label,enabled:H.enabled}:{...H.formValues});return}if(y.state.mode===`new`){if(O.current===`new`)return;O.current=`new`,C(null),T({countryId:``,serviceId:``}),D({label:m(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[H,y.state]),a(()=>{if(y.state.mode!==`new`||A===``)return;let e=z.find(e=>e.id===A);e&&D(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[y.state.mode,A,z]);let ce=r(e=>{T(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),U=r(async()=>{await _.invalidateQueries({queryKey:We})},[_]),W=u({mutationFn:async e=>M(`deleteSource`,{id:e}),onSuccess:async()=>U()}),G=r(async e=>{await v({title:m(`system.wasteSettingsSources.deleteWasteSource`,`Delete waste source?`),message:m(`system.wasteSettingsSources.removeItsCalendarUnderSystem`,`Remove “{{label}}” ({{id}}). Its calendar under System → Calendars is dropped.`,{label:e.label,id:e.id}),confirmLabel:m(`common.delete`,`Delete`),cancelLabel:m(`common.cancel`,`Cancel`),variant:`danger`})&&(await W.mutateAsync(e.id),y.state.mode===`edit`&&y.state.id===e.id&&(y.close(),O.current=null))},[v,W,y,m]),de=r(async()=>{let e=E.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){C(`Label is required.`);return}if(A===``){C(`Pick a country and a service.`);return}let n=y.state.mode===`new`,r=H?.id;if(!n&&(r===void 0||r===``)){C(`That source is no longer available.`);return}let i=E.enabled,a={...E};delete a.label,delete a.enabled,S(!0),C(null);try{n?await M(`createSource`,{label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await M(`updateSource`,{id:r,label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}),await U(),y.close(),O.current=null}catch(e){C(Ke(e))}finally{S(!1)}},[M,H,y,E,U,A]),fe=n(()=>[{key:`label`,header:m(`system.wasteSettingsSources.label`,`Label`),sortValue:e=>e.label,render:e=>i(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:m(`system.wasteSettingsSources.module`,`Module`),sortValue:e=>e.module,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:m(`system.wasteSettingsSources.enabled`,`Enabled`),sortValue:e=>+!!e.enabled,render:e=>i(N,{variant:e.enabled?`success`:`default`,children:e.enabled?m(`system.wasteSettingsSources.on`,`On`):m(`system.wasteSettingsSources.off`,`Off`)})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>i(j,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":m(`system.wasteSettingsSources.delete`,`Delete {{label}}`,{label:e.label}),"data-testid":`waste-source-delete-${e.id}`,onClick:t=>{t.stopPropagation(),G(e)},children:i(p,{className:`h-3.5 w-3.5 text-danger`})})}],[G,m]),K=y.state.mode===`new`,J=K||H!==null,pe=`${A}:${K?`new`:H?.id??`closed`}`;return e(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.pickACountryAndA`,`Pick a country and a service — configuration fields come from that HACS source.`)}),e(j,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>y.openNew(),children:[i(g,{className:`h-3.5 w-3.5`}),m(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),P.isError?i(`p`,{className:`text-sm text-danger`,children:m(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,P.isPending?i(oe,{className:`h-32 w-full`}):i(ne,{columns:fe,rows:L,rowKey:e=>e.id,pageSize:25,emptyMessage:m(`system.wasteSettingsSources.noWasteSourcesYetAdd`,`No waste sources yet. Add one to register a municipal service.`),onRowClick:e=>y.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),i(ae,{open:J,onClose:()=>{y.close(),C(null),O.current=null},title:K?m(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):m(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:H?.label??`source`}),icon:te,width:`xl`,testId:`waste-source-editor`,error:ee,footer:i(j,{type:`button`,size:`sm`,disabled:x||A===``,onClick:()=>void de(),children:x?m(`system.wasteSettingsSources.saving`,`Saving…`):m(`common.save`,`Save`)}),children:J?e(d,{children:[i(`div`,{"data-testid":`waste-country-service`,children:i(ue,{schema:se,values:w,onChange:ce},`picker:${k}:${z.length}`)}),A!==``&&B!==void 0?i(ue,{schema:B,values:E,onChange:D,bare:!0},pe):A!==``&&I.isPending?i(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.loadingFields`,`Loading fields…`)}):i(`p`,{className:`text-sm text-foreground-muted`,children:m(`system.wasteSettingsSources.chooseACountryAndService`,`Choose a country and service to see the required fields.`)})]}):null}),i(ye,{nodeId:`hub`,addonIds:[c],level:`global`,capability:f,hideSectionChrome:!0})]})}c();var $e=1e4,et={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},tt=[{sectionId:`exporters`,kind:`device-export`,labelKey:`system.connectivity.exporters`,icon:_,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`},{sectionId:`email`,kind:`email`,labelKey:`system.connectivity.email`,icon:v,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:x,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:w,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function nt(t,n,r,a){let o=Ve(C,t.kind),s=n.flatMap(n=>{let a=He(n,o);if(a===null)return[];let s=Ue(n.processState);return[{id:n.addonId,name:n.displayName,fallbackIcon:t.icon,state:s.state,stateLabel:s.label,render:()=>i(be,{addonId:n.addonId,displayName:n.displayName,capName:a,isActive:n.processState===`running`,badges:e(d,{children:[i(ot,{processState:n.processState}),i(st,{kind:t.kind,addonId:n.addonId})]}),lead:t.kind===`device-export`?i(R,{addonId:n.addonId}):void 0,panels:at(t.kind,n.addonId,e=>r(`/devices/${e}`)),settingsContent:n.addonId===`waste-collections`?i(Qe,{addonId:n.addonId,capName:a}):void 0})}]});return{id:t.sectionId,label:a(t.labelKey),entries:s,install:{capability:o[0]??t.kind,label:a(t.installLabelKey)}}}function rt({descriptor:e,rows:t,isLoading:r}){let{t:a}=q(),o=pe(),s=n(()=>nt(e,t,o,a),[e,t,o,a]);return i(xe,{embedded:!0,icon:e.icon,title:a(e.labelKey),subtitle:null,groups:[s],isLoading:r,emptyTitle:a(e.emptyTitleKey),emptyDescription:a(e.emptyDescriptionKey)})}function it(){let{t:e}=q(),t=fe(void 0,{refetchInterval:$e}),[r,o]=he(),s=ge(`/system/integrations`,{t:e,isAdmin:!0})??{icon:m,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};a(()=>{let e=r.get(`tab`);if(e===null)return;let t=et[e];t===void 0||t===e||o(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[r,o]);let c=n(()=>(t.data??[]).map(Be).filter(e=>e!==null),[t.data]),l=n(()=>tt.map(n=>({id:n.sectionId,label:e(n.labelKey),ownedParams:me,content:i(rt,{descriptor:n,rows:c,isLoading:t.isLoading})})),[t.isLoading,c,e]);return i(_e,{icon:s.icon,title:s.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:l})}function at(e,t,n){return e===`device-export`?[{id:`devices`,title:K.t(`admin.system.integrations.devices`,`Devices`),icon:D,placement:`end`,content:i(M,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:K.t(`admin.system.integrations.connections`,`Connections`),icon:x,content:i(Le,{addonId:t,fallback:i(Ie,{addonId:t})})}]:[]}function ot({processState:e}){let{state:t,label:n}=Ue(e);return i(N,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${X} capitalize`,children:n})}function st({kind:e,addonId:t}){return e===`broker`?i(ct,{addonId:t}):e===`device-export`?i(lt,{addonId:t}):null}function ct({addonId:e}){let{t}=q(),{data:n}=z({addonId:e},{refetchInterval:$e,retry:!1}),r=S.safeParse(n);if(!r.success)return null;let{brokerCount:a,connectedCount:o}=r.data;return i(N,{variant:`info`,className:X,children:o>0?t(`system.connectivity.connectionsConnected`,{count:a,connected:o}):t(`system.connectivity.connections`,{count:a})})}function lt({addonId:e}){let{t}=q(),{data:n}=A({addonId:e},{refetchInterval:$e,retry:!1}),r=ee.safeParse(n);if(!r.success)return null;let{linkState:a,exposedDeviceCount:o}=r.data;return i(N,{variant:a===`linked`?`success`:a===`error`?`danger`:`default`,className:X,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:a,exposedDeviceCount:o})})}export{it as IntegrationsPage};
|