@camstack/addon-admin-ui 1.2.478 → 1.2.479

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/assets/Addons-2bVk9gQP.js +5 -0
  2. package/dist/assets/{AdminSectionedPage-BByl6Zss.js → AdminSectionedPage-5g5LDrXG.js} +1 -1
  3. package/dist/assets/{AiProfiles-Cvu3UHy2.js → AiProfiles-CjexfGhj.js} +1 -1
  4. package/dist/assets/{BrokerForm-D6ln7R0A.js → BrokerForm-Behibhry.js} +1 -1
  5. package/dist/assets/{Build-C0J5ce6Z.js → Build-EtMIMKRO.js} +3 -3
  6. package/dist/assets/{Calendars-G5xKjOn2.js → Calendars-DH3P_u96.js} +1 -1
  7. package/dist/assets/{Cluster-w5Kcsast.js → Cluster-CFnD0vXf.js} +1 -1
  8. package/dist/assets/{CompositionEditorPage-AIRu6m_i.js → CompositionEditorPage-DbFLOjT0.js} +1 -1
  9. package/dist/assets/{Data-r1IoElgA.js → Data-DaycWn5V.js} +2 -2
  10. package/dist/assets/{DeviceDetail-Dz6PV7rK.js → DeviceDetail-DABbOvpp.js} +2 -2
  11. package/dist/assets/{DeviceDoActionFields-gklZW8H7.js → DeviceDoActionFields-DESERgis.js} +1 -1
  12. package/dist/assets/{Devices-z5XqFK0f.js → Devices-e9WRZF8o.js} +1 -1
  13. package/dist/assets/{History-DLllXIdk.js → History-CUBYC5vJ.js} +1 -1
  14. package/dist/assets/{Identity-gwaZ5bXU.js → Identity-YiQC97gk.js} +1 -1
  15. package/dist/assets/IntegrationDetail-LZqy5tnJ.js +1 -0
  16. package/dist/assets/{IntegrationHub-Dv8jClEP.js → IntegrationHub-oKQf8Hqh.js} +1 -1
  17. package/dist/assets/Integrations-Bb8hbB7-.js +1 -0
  18. package/dist/assets/Integrations-CSF7awEo.js +1 -0
  19. package/dist/assets/{Library-BXbZKXfl.js → Library-CLum5n0h.js} +1 -1
  20. package/dist/assets/{Locations-CjHnNjAh.js → Locations-CyGnajVJ.js} +1 -1
  21. package/dist/assets/{Logs-D7ADXC_5.js → Logs-DTwpZ7zU.js} +1 -1
  22. package/dist/assets/{MyAccess-id2Dmf9N.js → MyAccess--2ZT-HhR.js} +1 -1
  23. package/dist/assets/{Network-BS9VI_eu.js → Network-DAts0LIq.js} +1 -1
  24. package/dist/assets/{NodeAddonsSettingsPanel-GEn1r68w.js → NodeAddonsSettingsPanel-96SuINk0.js} +1 -1
  25. package/dist/assets/{Notifications-CIXn3wxj.js → Notifications-BLt2f-nc.js} +1 -1
  26. package/dist/assets/{Pipeline-B6AdA9Ua.js → Pipeline-Bn9VYb0p.js} +1 -1
  27. package/dist/assets/{Recordings-2Ej5v6LZ.js → Recordings-vrFJrZh0.js} +1 -1
  28. package/dist/assets/ScanNetworkModal-u-7qAdO5.js +1 -0
  29. package/dist/assets/{SessionsList-CMV9rDkY.js → SessionsList-DJR70bvB.js} +1 -1
  30. package/dist/assets/{Showroom-eCnhoQBD.js → Showroom-CK5L2uo3.js} +1 -1
  31. package/dist/assets/{System-AxGI_wdI.js → System-Bp5NGMuQ.js} +1 -1
  32. package/dist/assets/{Terminal-Br0QNfMN.js → Terminal-BnNXFsMP.js} +1 -1
  33. package/dist/assets/{device-integration-icon-DEZs4Umq.js → device-integration-icon-CdgkjIk4.js} +1 -1
  34. package/dist/assets/{index-XXQ5yMw_.js → index-D_Tm4B7S.js} +2 -2
  35. package/dist/assets/{location-owned-usage-8xhfNE7j.js → location-owned-usage-BqMUhVoi.js} +1 -1
  36. package/dist/assets/{mf-entry-bootstrap-0-dcdd32c2.js → mf-entry-bootstrap-0-e328376a.js} +1 -1
  37. package/dist/assets/{step-inspector-model-CI19RBoT.js → step-inspector-model-G2bS8NkA.js} +1 -1
  38. package/dist/assets/{useNodeUrlSelection-DWbo46bM.js → useNodeUrlSelection-XYqqUh3q.js} +1 -1
  39. package/dist/index.html +2 -2
  40. package/dist/server/addon.js +1 -1
  41. package/package.json +1 -1
  42. package/dist/assets/Addons-DAuTfOiO.js +0 -5
  43. package/dist/assets/IntegrationDetail-P1tm0l2J.js +0 -1
  44. package/dist/assets/Integrations-B9RbWg-F.js +0 -1
  45. package/dist/assets/Integrations-BLXg84-0.js +0 -1
  46. package/dist/assets/ScanNetworkModal-CJoDRy24.js +0 -1
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cn as u,Di as d,On as f,Si as p,bn as m,dt as h,fn as g,fr as _,kn as v,or as ee,ot as te,un as y,xi as b,yi as x}from"./player-overlays-Dbv95cvz.js";import{t as ne}from"./table-2-CTZnEliG.js";import{$u as S,Dr as re,F as C,Kr as w,Mt as T,Pt as ie,Ua as E,as as ae,cs as D,ed as O,fo as oe,jt as k,li as A,ot as j,r as se,sd as M,to as N,us as ce}from"./src-DntJrWmU.js";import{t as P}from"./i18n-D0o08mg-.js";import{t as F}from"./useTranslation-BJr-n0es.js";import{fr as le,mr as ue,sr as I}from"./index-XXQ5yMw_.js";import{t as de}from"./AdminPage-3JxWocN3.js";import"./useEventInvalidation-CUPf26ML.js";import{t as L}from"./device-integration-icon-DEZs4Umq.js";import{n as R,r as z,t as B}from"./ScanNetworkModal-CJoDRy24.js";s();function V({rows:t,isExpanded:r,onToggleExpand:a,onOpen:s,renderExpanded:c,searchPlaceholder:l,emptyLabel:u}){let[d,f]=o(``),p=n(()=>{let e=d.trim().toLowerCase();return e.length===0?t:t.filter(t=>`${t.name} ${t.addonId}`.toLowerCase().includes(e))},[d,t]);return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(g,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(S,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l,"aria-label":l,className:`pl-8`})]}),p.length===0?i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:u}):i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:p.map(e=>i(H,{integration:e,expanded:r(e),onToggleExpand:a,onOpen:s,renderExpanded:c},e.id))})]})}function H({integration:t,expanded:n,onToggleExpand:r,onOpen:a,renderExpanded:o}){return e(`article`,{"data-testid":`integration-card-${t.id}`,className:M(`flex min-w-0 flex-col gap-2 overflow-x-clip rounded-lg border border-border bg-surface p-3`,n&&`sm:col-span-2 lg:col-span-3`),children:[i(U,{integration:t,expanded:n,onToggleExpand:r,onOpen:a}),n?i(`div`,{className:`min-w-0`,children:o(t)}):null]})}function U({integration:t,expanded:n,onToggleExpand:r,onOpen:a}){let{t:o}=F(),s=n?o(`integrations.integrationColumns.collapse`,`Collapse`):o(`integrations.integrationColumns.expand`,`Expand`);return e(`div`,{className:`relative flex min-w-0 items-stretch gap-3`,children:[i(w,{type:`button`,variant:`ghost`,"aria-label":o(`integrations.openNamed`,{name:t.name,defaultValue:`Open {{name}}`}),onClick:()=>a(t),className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),i(W,{integration:t}),e(`div`,{className:`pointer-events-none relative z-10 flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:[i(j,{status:t.status,className:`shrink-0`}),i(`p`,{className:`text-[11px] text-foreground-muted`,children:o(`integrations.integrationColumns.deviceCount`,{count:t.deviceCount})}),i(`div`,{className:`pointer-events-auto mt-auto self-end`,children:i(O,{type:`button`,variant:`ghost`,size:`sm`,icon:n?b:x,"aria-label":s,"aria-expanded":n,onClick:e=>K(e,t.addonId,r)})})]})]})}function W({integration:t}){return e(`div`,{className:`pointer-events-none relative z-10 flex w-28 shrink-0 flex-col items-center gap-1 lg:w-24`,children:[i(I,{type:t.addonId,size:`xl`}),i(`p`,{className:`w-full text-center text-xs font-semibold text-foreground`,children:t.name}),i(G,{addonId:t.addonId})]})}function G({addonId:t}){return i(`p`,{className:`w-full text-center text-[10px] leading-tight text-foreground-subtle`,children:t.split(`-`).map((t,n)=>e(`span`,{children:[n>0?e(l,{children:[`-`,i(`wbr`,{})]}):null,t]},`${t}-${String(n)}`))})}function K(e,t,n){e.stopPropagation(),n(t)}s();var q=`camstack.admin.integrations.view`;function fe(e){return e===`table`||e===`grid`}function J(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function pe(e=J()){if(e===null)return`table`;try{let t=e.getItem(q);return fe(t)?t:`table`}catch{return`table`}}function Y(e,t=J()){if(t!==null)try{t.setItem(q,e)}catch{}}function me(){let[e,t]=o(()=>pe());return[e,r(e=>{t(e),Y(e)},[])]}s();function he(e=!0){a(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}s();function ge(e,t){let[n,r]=o(!1);return a(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}s();function _e({providerId:t,onImport:n,onSkip:r}){let{t:s}=F(),[c,l]=o(new Set),u=N(),f=u.data,m=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,u]);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:[i(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=f??[];return e(`div`,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&i(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,r=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??r}):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:[i(`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&&i(p,{className:`h-3 w-3 text-primary-foreground`})}),i(d,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),o&&i(`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:[i(`button`,{onClick:r,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,`)`]})]})]})}var ve=`(hover: none) and (pointer: coarse)`;function X(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(ve).matches}catch{return!0}}s();function Z({onSelect:r,onClose:s,pendingAddonId:c=null}){let{t:l}=F(),u=le(),[d,f]=o(``),p=t(null),{data:m,isLoading:h}=D();a(()=>{h||!X()||p.current?.focus()},[h]);let _=n(()=>{let e=m??[],t=d.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[m,d]);if(h)return i(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let v=c!==null;return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(g,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(S,{ref:p,type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":l(`integrations.searchProviders`,`Search integrations…`)})]}),i(`div`,{className:`grid grid-cols-2 gap-2`,children:_.map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0,a=c===t.addonId,o=v;return e(`button`,{type:`button`,disabled:o,"data-testid":`provider-pick-${t.addonId}`,onClick:()=>{if(!o)if(n){let e=t.existingInstances[0].id;s(),u(`/integrations/${e}`)}else r(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?i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`img`,{src:t.iconUrl,alt:``,className:`h-5 w-5`})}):i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`span`,{className:`text-sm`,style:{color:t.color},children:`◉`})}),i(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:t.name}),t.description?i(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:t.description}):null,a?i(ee,{className:`h-4 w-4 animate-spin text-primary`}):n?e(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[i(y,{className:`h-3 w-3`}),l(`integrations.manage`)]}):null]},t.addonId)})}),_.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(m??[]).length===0?l(`integrations.noProviders`):l(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function Q(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 ye=2e4;function be({open:t,onClose:r}){let{t:s}=F(),u=le(),d=c(),[f,p]=o(`picker`),[m,g]=o(null),[_,v]=o(null),[te,y]=o(`manual`),[b,x]=o(null),[ne,S]=o(``),[re,C]=o(null),[w,T]=o(null),[ie,D]=o(!1),{data:O}=A({addonId:m??``,nodeId:`hub`},{enabled:m!=null}),oe=n(()=>O?Q(O):null,[O]),k=ae({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),j=N(),se=j.data;a(()=>{f!==`discovery`||!_||!m||j.isPending||j.data||j.mutate({addonId:m})},[f,_,m,j]);let M=E({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function ce(e,t,n,r,i,a,o,s){if(!k.isPending){if(g(e),D(s),y(n),S(r),T(null),o===`broker`){if(!a){T(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}x(a),p(`broker`);return}if(o===`account`){p(`config`);return}P(e,r)}}async function P(e,t){try{let n=await k.mutateAsync({addonId:e,name:t,settings:{}});r(),B(),u(`/integrations/${n.id}?add=1`)}catch{}}async function ue(e){if(m)try{let t=await k.mutateAsync({addonId:m,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});v(t.id),C(t.id),te===`auto`||te===`both`?p(`discovery`):L(t.id,{openAdd:!0})}catch{}}async function I(e){if(m)try{let t=await k.mutateAsync({addonId:m,name:ne,settings:{brokerId:e}});C(t.id),v(t.id),L(t.id)}catch{}}async function de(e){if(m){for(let t of e){let e=se?.find(e=>e.stableId===t);e&&await M.mutateAsync({addonId:m,candidate:e,...re===null?{}:{integrationId:re}})}L()}}function L(e,t){let n=e??_??m;r(),B(),n&&u(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function B(){p(`picker`),g(null),v(null),y(`manual`),x(null),S(``),C(null),T(null),D(!1)}function V(){r(),B()}he(t);let H=k.isPending,U=ge(H,ye);if(!t)return null;let W={picker:s(`integrations.newIntegration`),config:s(`integrations.configureIntegration`),discovery:s(`integrations.importDevices`),broker:s(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},G=H?m:null,K=k.error,q=H&&!U;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:q?void 0:V}),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:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:W[f]}),i(`button`,{onClick:V,disabled:q,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:i(h,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[K&&!H&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:K instanceof Error?K.message:String(K)}),f===`picker`&&e(l,{children:[w&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:w}),i(Z,{onSelect:ce,onClose:V,pendingAddonId:G})]}),f===`config`&&m&&i(R,{addonId:m,configSchema:oe??null,canTest:ie,onSave:ue,onBack:()=>p(`picker`)}),f===`broker`&&b&&i(z,{kind:b,onResolved:e=>{I(e)},onBack:()=>p(`picker`)}),f===`discovery`&&_&&i(_e,{providerId:_,onImport:de,onSkip:L})]}),H&&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:[i(ee,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:s(`integrations.creating`,{defaultValue:`Creating integration…`})}),!U&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),U&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:s(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(`button`,{onClick:V,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:s(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function xe({integration:t,expanded:n,onToggleExpand:r}){let{t:a}=F();return e(`div`,{className:`flex items-center gap-2.5`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(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:i(n?b:x,{className:`h-3.5 w-3.5`})}),i(I,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[i(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Se(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:P.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>i(xe,{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=>i(j,{status:e.status})}]}s();function Ce(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var $=`expand`;function we(){let{t}=F(),a=le(),s=te(),[c]=ue(),[d,p]=me(),[h,g]=o(!1),ee=r(()=>g(!0),[]),y=r(()=>g(!1),[]),[b,x]=o(!1),S=r(()=>x(!0),[]),w=r(()=>x(!1),[]);se([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),se([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:E,isLoading:ae,isError:D,refetch:O}=ce(void 0),{data:A,isLoading:j,isError:N,refetch:P}=oe({projection:`slim`}),I=n(()=>A??[],[A]),R=n(()=>E??[],[E]),z=n(()=>{let e=new Map;for(let t of I)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[I]),H=n(()=>T(E),[E]),U=n(()=>{let e=new Map;for(let t of ie(I)){let n=H(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[I,H]),W=n(()=>R.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:Ce(e),deviceCount:U.get(e.id)??0})),[R,U]),G=c.get($),K=r(e=>{let t=new URLSearchParams(window.location.search);t.get($)===e?t.delete($):t.set($,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`))},[]),q=r(e=>a(`/integrations/${e.id}`),[a]),fe=r(e=>z.get(e)??null,[z]),J=r(e=>a(`/devices/${String(e)}`),[a]),pe=r(e=>i(k,{context:`integration-detail`,devices:I,trpc:s.trpcClient,integrationOf:H,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:L,resolveParent:fe,onNavigate:J}),[I,s.trpcClient,H,fe,J]),Y=r(e=>G===e.addonId,[G]),he=n(()=>Se({isExpanded:Y,onToggleExpand:K}),[Y,K]),ge=r(e=>`${e.name} ${e.addonId}`,[]),_e=r(e=>e.addonId,[]),ve=r(()=>{O(),P()},[O,P]),X=D===!0||N===!0,Z=!X&&(ae||j||E===void 0||A===void 0),Q=R.length>0,ye=[{id:`table`,label:t(`integrations.viewTable`,`Table`),icon:ne},{id:`grid`,label:t(`integrations.viewGrid`,`Grid`),icon:_}];return e(de,{icon:f,title:t(`nav.integrations`,`Integrations`),actions:e(l,{children:[i(C,{ariaLabel:t(`integrations.viewLabel`,`Layout`),value:d,onChange:p,options:ye,testId:`integrations-view`}),i(`button`,{onClick:ve,disabled:Z,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:t(`common.refresh`,`Refresh`),children:i(m,{className:M(`h-3.5 w-3.5`,Z&&`animate-spin`)})}),e(`button`,{onClick:S,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:t(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[i(u,{className:`h-3.5 w-3.5`}),t(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:ee,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:[i(v,{className:`h-3.5 w-3.5`}),t(`integrations.newIntegration`,`New Integration`)]})]}),children:[X&&i(re,{message:t(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:ve}),Z&&i(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>i(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!X&&!Z&&!Q&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[i(`p`,{className:`text-sm`,children:t(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),i(`p`,{className:`text-xs mt-1`,children:t(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!X&&!Z&&Q&&d===`table`&&i(k,{mode:`generic`,items:W,getKey:_e,getSearchText:ge,columns:he,onRowClick:q,isExpanded:Y,renderExpanded:pe,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),!X&&!Z&&Q&&d===`grid`&&i(V,{rows:W,isExpanded:Y,onToggleExpand:K,onOpen:q,renderExpanded:pe,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),i(be,{open:h,onClose:y}),i(B,{open:b,onClose:w})]})}export{we as IntegrationsPage};
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Br as l,Cn as u,Nt as d,Q as f,Si as p,Wr as m,bi as h,bn as g,dt as _,or as v}from"./player-overlays-Dbv95cvz.js";import{Ma as y,ka as b}from"./client-DvJxGh2F.js";import{Ua as x,da as S,eo as C,fa as w,fo as T,fs as E,mi as D,no as O,sa as k,xo as A}from"./src-DntJrWmU.js";import{t as j}from"./useTranslation-BJr-n0es.js";import"./mount-CUPf26ML.js";import{P as M,lr as N}from"./index-XXQ5yMw_.js";import{t as P}from"./BrokerForm-D6ln7R0A.js";s();var F=[`amazon.com`,`amazon.it`,`amazon.de`,`amazon.co.uk`,`amazon.fr`,`amazon.es`,`amazon.ca`,`amazon.com.au`,`amazon.co.jp`,`amazon.in`,`amazon.com.br`,`amazon.com.mx`],I=f(`/addon/import-alexa`),L=2e3;function R(e){return typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function z(e){return typeof e==`object`&&!!e&&typeof e.phase==`string`&&typeof e.sessionId==`string`}function B(e){return typeof e==`object`&&!!e&&typeof e.brokerId==`string`}function V(e){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`,...e}}async function H(e,t,n){let r=await fetch(`${I}${e}`,{method:`POST`,headers:V(),body:JSON.stringify(t)}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!n(i))throw Error(`Unexpected response from server`);return i}async function U(e){let t=new URLSearchParams({sessionId:e}),n=localStorage.getItem(`camstack_admin_token`)??``,r=await fetch(`${I}/login/status?${t.toString()}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!z(i))throw Error(`Unexpected status response from server`);return i}async function W(e){try{await fetch(`${I}/login/cancel`,{method:`POST`,headers:V(),body:JSON.stringify({sessionId:e})})}catch{}}function G({brokerId:n,onResolved:s,onCancel:c}){let{t:u}=j(),[f,p]=o(`amazon.it`),[m,h]=o(`Alexa account`),[_,y]=o({kind:`idle`}),b=t(!0);a(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=t(null),S=t(null),C=r(()=>{S.current!==null&&(clearInterval(S.current),S.current=null)},[]),w=r(async e=>{C(),b.current&&y({kind:`committing`,sessionId:e});try{let t=await H(`/login/commit`,{sessionId:e,name:m.trim().length>0?m.trim():`Alexa account`,...n===void 0?{}:{brokerId:n}},B);x.current=null,s(t.brokerId)}catch(t){let n=t instanceof Error?t.message:String(t);b.current&&y({kind:`error`,message:n,sessionId:e})}},[n,m,s,C]),T=r((e,t)=>{C();let n=async()=>{try{let n=await U(e);if(n.phase===`captured`){C(),w(e);return}if(n.phase===`error`){C(),b.current&&y({kind:`error`,message:n.error??u(`integrations.alexaLoginStep.loginProxyReturnedAnError`,`Login proxy returned an error`),sessionId:e});return}if(n.phase===`cancelled`){C(),b.current&&y({kind:`idle`});return}b.current&&y({kind:`polling`,sessionId:e,loginUrl:n.loginUrl||t,phase:n.phase})}catch(e){let t=e instanceof Error?e.message:String(e);b.current&&y(e=>e.kind===`polling`?{...e}:{kind:`error`,message:t,sessionId:null})}};S.current=setInterval(()=>{n()},L)},[C,w,u]);a(()=>()=>{C(),x.current!==null&&W(x.current)},[C]);let E=async()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`starting`});try{let e=await H(`/login/start`,{amazonDomain:f},R);x.current=e.sessionId,y({kind:`polling`,sessionId:e.sessionId,loginUrl:e.loginUrl,phase:`starting`}),T(e.sessionId,e.loginUrl)}catch(e){y({kind:`error`,message:e instanceof Error?e.message:String(e),sessionId:null})}},D=()=>{C(),x.current!==null&&(W(x.current),x.current=null),y({kind:`idle`})},O=()=>{D()},k=_.kind===`idle`,A=_.kind===`starting`,M=_.kind===`polling`,P=_.kind===`committing`,I=_.kind===`error`,z=A||M||P,V=_.kind===`polling`?_.phase:null,G=_.kind===`polling`?_.loginUrl:null,K=M&&V===`awaiting-login`,q=M&&(V===`starting`||V===null);return e(`div`,{className:`space-y-4`,children:[(k||I)&&e(`div`,{className:`space-y-3`,children:[n===void 0&&e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`alexa-account-name`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.accountName`,`Account name`)}),i(`input`,{id:`alexa-account-name`,type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:u(`integrations.alexaLoginStep.alexaAccount`,`Alexa account`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`alexa-amazon-region`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:u(`integrations.alexaLoginStep.amazonRegion`,`Amazon region`)}),i(`select`,{id:`alexa-amazon-region`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:F.map(e=>i(`option`,{value:e,children:e},e))})]})]}),I&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px] flex items-start gap-2`,children:[i(d,{className:`h-3.5 w-3.5 mt-0.5 flex-shrink-0`}),i(`span`,{children:_.message})]}),A&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.startingLoginProxy`,`Starting login proxy…`)]}),q&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.waitingForProxyToBe`,`Waiting for proxy to be ready…`)]}),P&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(v,{className:`h-4 w-4 animate-spin flex-shrink-0`}),u(`integrations.alexaLoginStep.savingCredentials`,`Saving credentials…`)]}),K&&G!==null&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2`,children:[i(`p`,{className:`text-xs font-semibold text-foreground`,children:u(`integrations.alexaLoginStep.openTheLinkBelowTo`,`Open the link below to log in to your Amazon account`)}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.alexaLoginStep.afterCompletingTheLoginAnd`,`After completing the login and any 2FA steps, this wizard will continue automatically.`)}),e(`a`,{href:G,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[i(l,{className:`h-3.5 w-3.5`}),u(`integrations.alexaLoginStep.loginToAmazon`,`Login to Amazon`)]})]}),i(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[10px] text-warning`,children:i(N,{i18nKey:`integrations.alexaLoginStep.proxyNote`,components:{b:i(`strong`,{}),code:i(`code`,{className:`font-mono`})}})}),e(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle`,children:[i(v,{className:`h-3 w-3 animate-spin`}),u(`integrations.alexaLoginStep.waitingForAmazonLoginTo`,`Waiting for Amazon login to complete…`)]})]}),e(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[i(`button`,{type:`button`,onClick:z?D:c,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:z?u(`integrations.alexaLoginStep.cancelLogin`,`Cancel login`):u(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[I&&e(`button`,{type:`button`,onClick:O,className:`inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10`,children:[i(g,{className:`h-3.5 w-3.5`}),u(`common.retry`,`Retry`)]}),k&&i(`button`,{type:`button`,onClick:()=>{E()},disabled:n===void 0&&m.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:u(`integrations.alexaLoginStep.startLogin`,`Start login`)})]})]})]})}s();var K=`alexa`;function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function J(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var Y={connected:`bg-success/15 text-success`,connecting:`bg-warning/15 text-warning`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function X({kind:t,onResolved:r,onBack:a}){let{t:s}=j(),[c,l]=o(t===K?`alexa-login`:`existing`),u=S({kind:t}),d=n(()=>q(u.data).filter(e=>e.kind===t),[u.data,t]),f=w(),p=n(()=>{for(let e of J(f.data))if(e.kinds.some(e=>e.kind===t))return e.addonId},[f.data,t]),[m,g]=o(null),[_,y]=o(``),b=k({}),x=()=>{m&&r(m)},C=async e=>{_.trim().length!==0&&r((await b.mutateAsync({kind:t,name:_.trim(),settings:e,...p===void 0?{}:{addonId:p}})).id)},T=e=>{e===`new`?g(null):b.reset(),l(e)};return e(`div`,{className:`space-y-4`,children:[e(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[i(h,{className:`h-3.5 w-3.5`}),` `,s(`common.back`)]}),e(`div`,{className:`inline-flex rounded-lg border border-border p-0.5 flex-wrap gap-0.5`,children:[t===K&&i(`button`,{type:`button`,onClick:()=>T(`alexa-login`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`alexa-login`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:s(`integrations.brokerStep.loginInteractively`,`Login interactively`)}),i(`button`,{type:`button`,onClick:()=>T(`existing`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`existing`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:s(`integrations.brokerStep.useExisting`,`Use existing`)}),i(`button`,{type:`button`,onClick:()=>T(`new`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`new`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:t===K?s(`integrations.brokerStep.pasteCookie`,`Paste cookie`):s(`integrations.brokerStep.createNew`,`Create new`)})]}),c===`alexa-login`&&i(G,{onResolved:r,onCancel:a}),c===`existing`&&e(`div`,{className:`space-y-3`,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(v,{className:`h-3.5 w-3.5 animate-spin`}),` `,s(`integrations.brokerStep.loadingBrokers`)]}),u.isError&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[s(`integrations.brokerStep.failedToLoadBrokers`,`Failed to load brokers:`),` `,u.error instanceof Error?u.error.message:s(`integrations.brokerStep.unknownError`,`Unknown error`)]}),!u.isLoading&&!u.isError&&d.length===0&&i(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-6 text-center text-xs text-foreground-subtle`,children:i(N,{i18nKey:`integrations.brokerStep.noBrokers`,values:{mode:t===K?s(`integrations.brokerStep.loginInteractively`,`Login interactively`):s(`integrations.brokerStep.createNew`,`Create new`)},components:{b:i(`span`,{className:`font-medium text-foreground`})}})}),i(`div`,{className:`space-y-2`,children:d.map(t=>e(`button`,{type:`button`,onClick:()=>g(t.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${m===t.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[i(`span`,{className:`text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Y[t.status]}`,children:t.status})]},t.id))}),d.length>0&&i(`div`,{className:`flex justify-end pt-1`,children:i(`button`,{type:`button`,onClick:x,disabled:!m,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:s(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]}),c===`new`&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`integrations.brokerStep.name`,`Name`)}),i(`input`,{type:`text`,value:_,onChange:e=>y(e.target.value),placeholder:s(`integrations.brokerStep.myHomeAssistant`,`My Home Assistant`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b.isError&&i(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:b.error instanceof Error?b.error.message:String(b.error)}),i(P,{kind:t,...p===void 0?{}:{addonId:p},onSubmit:e=>{C(e).catch(()=>{})},onCancel:a,submitLabel:b.isPending?s(`integrations.brokerStep.creating`,`Creating…`):s(`integrations.brokerStep.createBroker`,`Create broker`),disabled:b.isPending||_.trim().length===0}),_.trim().length===0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`integrations.brokerStep.enterANameBeforeCreating`,`Enter a name before creating.`)})]})]})}s();function Z(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var Q={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function ee({addonId:t,configSchema:n,canTest:r=!0,initialName:a,initialConfig:s,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=j(),[p,m]=o(a??``),[h,g]=o(s??{}),[_,v]=o(null),x=E({onSuccess:e=>v(Z(e)),onError:e=>v({status:`inconclusive`,error:String(e)})}),S=D(),C=!r||_?.status===`validated`,w=!l&&p.trim().length===0,T=!w&&C;return e(`div`,{className:`space-y-4`,children:[!l&&e(`div`,{children:[i(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),i(`input`,{id:`integration-name`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),"aria-invalid":w,"aria-describedby":w?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${w?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),w&&i(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:f(`integrations.nameRequired`,`Name is required`)})]}),n&&i(M,{schema:n,values:h,onChange:e=>{g(e),v(null)},onAction:async(e,i,a)=>{let o=await S.mutateAsync({addonId:t,action:e,input:a??{}});if(r&&typeof o==`object`&&o){let e=o;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return o;let r={...h};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=y(n,r);g(i),v(null),x.mutate({addonId:t,settings:i})}return o}}),_&&i(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${Q[_.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(_)}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>x.mutate({addonId:t,settings:y(n,h)}),disabled:x.isPending||!r,title:r?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[w&&i(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:f(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),i(`button`,{onClick:()=>{w||u({name:p,config:y(n,h),secretKeys:[...b(n)]})},disabled:!T,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:c??f(`integrations.forward`)})]})]})]})]})}s();function te({open:t,onClose:a,scope:s}){let{t:c}=j(),l=x(),[d,f]=o(new Set),[h,g]=o(new Set),{data:y}=T({projection:`slim`}),b=n(()=>new Set((y??[]).map(e=>e.stableId)),[y]),S=r(async(e,t)=>{g(e=>new Set(e).add(t.stableId));try{await l.mutateAsync({addonId:e,candidate:t}),f(e=>new Set(e).add(t.stableId))}catch{}finally{g(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[l]),C=r((t,n)=>{let r=typeof n.prefilledConfig.host==`string`?n.prefilledConfig.host:null,a=b.has(n.stableId),o=d.has(n.stableId)||a,s=h.has(n.stableId);return e(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),r&&i(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:r})]}),o?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5`}),` `,a?c(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):c(`integrations.scanNetworkModal.added`,`Added`)]}):e(`button`,{type:`button`,onClick:()=>void S(t,n),disabled:s,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[s?i(v,{className:`h-3.5 w-3.5 animate-spin`}):i(m,{className:`h-3.5 w-3.5`}),c(`common.add`,`Add`)]})]},n.stableId)},[d,h,b,S,c]);if(!t)return null;let w=s?`Scan network — ${s.label}`:`Scan network for devices`;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:a}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(u,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:w})]}),i(`button`,{onClick:a,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(_,{className:`h-4 w-4`})})]}),s?i(re,{scope:s,onAdopt:C,onReset:()=>f(new Set)}):i(ne,{onAdopt:C,onReset:()=>f(new Set)})]})]})}function ne({onAdopt:t,onReset:o}){let{t:s}=j(),l=C(),u=r(()=>{o(),l.mutate({})},[l,o]);a(()=>{!l.isPending&&!l.data&&u()},[]);let d=n(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=n(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return e(c,{children:[i(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:e(`button`,{onClick:u,disabled:l.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[i(g,{className:`h-3.5 w-3.5 ${l.isPending?`animate-spin`:``}`}),s(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l.isPending&&i(ie,{label:s(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&i($,{}),!l.isPending&&l.data&&d.length===0&&i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!l.isPending&&d.length>0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.map(n=>e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-[11px] font-semibold text-foreground`,children:n.label}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,n.candidates.length,`)`]})]}),n.candidates.map(e=>t(n.addonId,e))]},n.addonId))]})]})}function re({scope:t,onAdopt:n,onReset:a}){let{t:s}=j(),l=A({addonId:t.addonId}).data??null,[d,f]=o({}),p=O(),m=r(()=>{a(),p.mutate({addonId:t.addonId,params:d})},[p,t.addonId,d,a]),h=p.data?.candidates??[];return i(c,{children:e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&i(M,{schema:l,values:d,onChange:f}),e(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?i(v,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),p.isPending?s(`integrations.scanNetworkModal.scanning`,`Scanning…`):s(`integrations.scanNetworkModal.scan`,`Scan`)]}),p.isError&&i($,{}),!p.isPending&&p.data&&h.length===0&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!p.isPending&&h.length>0&&e(`div`,{className:`space-y-1.5`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.foundShort`,{count:h.length})}),h.map(e=>n(t.addonId,e))]})]})})}function ie({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(v,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function $(){let{t}=j();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-xs text-destructive`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{ee as n,X as r,te as t};