@camstack/addon-admin-ui 1.2.476 → 1.2.477
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-NsStjqDv.js → AddonAssetIcon-B_-30Ezl.js} +1 -1
- package/dist/assets/Addons-CbHidHOJ.js +5 -0
- package/dist/assets/{AdminPage-BBb_f0ke.js → AdminPage-3JxWocN3.js} +1 -1
- package/dist/assets/{AdminSectionedPage-B77fFYLu.js → AdminSectionedPage-DtiHBXGC.js} +1 -1
- package/dist/assets/AiProfiles-7FToWDqj.js +3 -0
- package/dist/assets/{BrokerForm-Dql4j_7g.js → BrokerForm-D5-q8F_8.js} +1 -1
- package/dist/assets/{Build-0VXUZTUO.js → Build-DwW5kYsa.js} +4 -4
- package/dist/assets/{Calendars-DDdCqGq7.js → Calendars-BhMRY6EV.js} +1 -1
- package/dist/assets/{Cluster-B8y8FoQV.js → Cluster-z11q6anB.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-RHV08gl_.js → CompositionBlockEditor-CElNVsCR.js} +1 -1
- package/dist/assets/{CompositionEditorPage-zqBIwPtu.js → CompositionEditorPage-NzgZB76B.js} +1 -1
- package/dist/assets/Data-D_U-HkwO.js +2 -0
- package/dist/assets/{DeviceDetail-BhhXtfQ_.js → DeviceDetail-D89wXQHP.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-CM877gWa.js → DeviceDoActionFields-Bj4gX0r-.js} +1 -1
- package/dist/assets/{Devices-D_p1jnJs.js → Devices-BnhDZU3y.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-n_ZfqSgX.js → EmbedPlayerPage-Ccf5hGui.js} +1 -1
- package/dist/assets/{HelperWizard-WGprHYSO.js → HelperWizard-CrXHYd19.js} +2 -2
- package/dist/assets/History-BsJBR2zt.js +1 -0
- package/dist/assets/Identity-B_6I_sCY.js +1 -0
- package/dist/assets/IntegrationDetail-B9L7AfYy.js +1 -0
- package/dist/assets/IntegrationHub-CSaA690G.js +1 -0
- package/dist/assets/Integrations-B-KtSB_m.js +1 -0
- package/dist/assets/Integrations-CMW4LOX-.js +1 -0
- package/dist/assets/{Library-B6p5cMT3.js → Library-3dGkOQB5.js} +1 -1
- package/dist/assets/Locations-Bh5GRDCv.js +3 -0
- package/dist/assets/{Logs-DbUcQh4T.js → Logs-diqSxXEc.js} +1 -1
- package/dist/assets/{MyAccess-BjgGZZmK.js → MyAccess-BqulMSGv.js} +1 -1
- package/dist/assets/{Network-DJAN2ffw.js → Network-C8Gpb2Vn.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-P5f0HKwt.js → NodeAddonsSettingsPanel-Dq6sGWkR.js} +1 -1
- package/dist/assets/Notifications-C5w5t75z.js +1 -0
- package/dist/assets/Pipeline-CjumfHMc.js +1 -0
- package/dist/assets/Recordings-DE76fgEt.js +1 -0
- package/dist/assets/{ScanNetworkModal-D0nIF1xL.js → ScanNetworkModal-DXzDOpxk.js} +1 -1
- package/dist/assets/SessionsList-Ca-zN1Fi.js +2 -0
- package/dist/assets/{Showroom-OGwDnxr_.js → Showroom-B9HZ38O5.js} +1 -1
- package/dist/assets/{System-CkfHfeMd.js → System-CHEbMPI_.js} +1 -1
- package/dist/assets/{Terminal-puPiVrKC.js → Terminal-CWFZuQLg.js} +3 -3
- package/dist/assets/{Viewer-QizHE8-x.js → Viewer-DwNVIy-u.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BIhn7NhC.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-QiJARN9B.js} +1 -1
- package/dist/assets/{addon-icons-context-DxUCqyaH.js → addon-icons-context-lrP_33gc.js} +1 -1
- package/dist/assets/{assignment-candidates-D58mtpje.js → assignment-candidates-BcnFMc1B.js} +1 -1
- package/dist/assets/{authed-media-B_8ON2MT.js → authed-media-CnaIhiH3.js} +1 -1
- package/dist/assets/{board-model-4EY3kgfH.js → board-model-gmvqxkjB.js} +1 -1
- package/dist/assets/{device-integration-icon-C28x8nbP.js → device-integration-icon-0oWIIjcP.js} +1 -1
- package/dist/assets/device-picker-model-CUPf26ML.js +1 -0
- package/dist/assets/{format-Bq6kzos8.js → format-CIO4xeN9.js} +1 -1
- package/dist/assets/{hostInit-EKt3RqKv.js → hostInit-DB6u6qxU.js} +1 -1
- package/dist/assets/i18n-xhwARoF0.js +1 -0
- package/dist/assets/icons-apbWMCU4.js +1 -0
- package/dist/assets/index-C3uCLHv0.js +4 -0
- package/dist/assets/{index-CU-5JpMo.css → index-D4ZlWCxy.css} +1 -1
- package/dist/assets/{linked-devices-model-Cgse8lhb.js → linked-devices-model-BoOq02QT.js} +1 -1
- package/dist/assets/{location-owned-usage-uS8d4cQL.js → location-owned-usage-IF2k-L3A.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-99fca1f4.js → mf-entry-bootstrap-0-f45a46c2.js} +2 -2
- package/dist/assets/mount-CUPf26ML.js +1 -0
- package/dist/assets/remoteEntry-CVuKB7K_.js +1 -0
- package/dist/assets/src-DntJrWmU.js +67 -0
- package/dist/assets/{step-inspector-model-C-7jLQzL.js → step-inspector-model-CyqFN-LU.js} +1 -1
- package/dist/assets/table-2-CTZnEliG.js +1 -0
- package/dist/assets/{use-scenes-feed-wrd7r_Sr.js → use-scenes-feed-D80maECB.js} +1 -1
- package/dist/assets/{use-stationary-objects-U-Gv-CIi.js → use-stationary-objects-DBEa50KS.js} +1 -1
- package/dist/assets/useEventInvalidation-CUPf26ML.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DZ8j6nae.js → useNodeUrlSelection-DGV2ltbG.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BaETqb6x.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CglCXJMd.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Addons-CC-7wyzX.js +0 -5
- package/dist/assets/AiProfiles-DQ7eLKoM.js +0 -3
- package/dist/assets/Data-C8MsiGcu.js +0 -2
- package/dist/assets/History-DP_G-ECr.js +0 -1
- package/dist/assets/Identity-D_ESOlFi.js +0 -1
- package/dist/assets/IntegrationDetail-DAaPI_ET.js +0 -1
- package/dist/assets/IntegrationHub-Ch94ozNN.js +0 -1
- package/dist/assets/Integrations-BBm9vAbT.js +0 -1
- package/dist/assets/Integrations-CcDZmbwS.js +0 -1
- package/dist/assets/Locations-C_Mo8QAj.js +0 -3
- package/dist/assets/Notifications-BahnGVKD.js +0 -1
- package/dist/assets/Pipeline-gniN2j7S.js +0 -1
- package/dist/assets/Recordings-BK-wAC4w.js +0 -1
- package/dist/assets/SessionsList-eAK6hNQb.js +0 -2
- package/dist/assets/device-picker-model-BkHlLdb8.js +0 -1
- package/dist/assets/i18n-l_m6iBJW.js +0 -1
- package/dist/assets/icons-BivKI4y9.js +0 -1
- package/dist/assets/index-BFjKpxae.js +0 -4
- package/dist/assets/mount-BkHlLdb8.js +0 -1
- package/dist/assets/remoteEntry-awBSqPjf.js +0 -1
- package/dist/assets/src-ByunGuTZ.js +0 -67
- package/dist/assets/useEventInvalidation-BkHlLdb8.js +0 -1
|
@@ -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,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{$a as x,Ha as S,bo as C,da as w,do as T,ds as E,oa as D,pi as O,to as k,ua as A}from"./src-ByunGuTZ.js";import{t as j}from"./useTranslation-BJr-n0es.js";import"./mount-BkHlLdb8.js";import{P as M,lr as N}from"./index-BFjKpxae.js";import{t as P}from"./BrokerForm-Dql4j_7g.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=A({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=D({}),x=()=>{m&&r(m)},S=async e=>{_.trim().length!==0&&r((await b.mutateAsync({kind:t,name:_.trim(),settings:e,...p===void 0?{}:{addonId:p}})).id)},C=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:()=>C(`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:()=>C(`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:()=>C(`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=>{S(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=O(),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=S(),[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]),x=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 x(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,x,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=x(),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=C({addonId:t.addonId}).data??null,[d,f]=o({}),p=k(),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};
|
|
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-C3uCLHv0.js";import{t as P}from"./BrokerForm-D5-q8F_8.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,It as l,Rr as u,cn as d,dt as f,or as p,ot as m,pi as h,sa as g,sn as _}from"./player-overlays-Dbv95cvz.js";import{a as v,i as y,s as b}from"./video-D7jv0spx.js";import{t as x}from"./key-round-DG341WFZ.js";import{$r as S,$u as C,Bn as ee,Dr as w,Gr as T,Hn as te,Ju as E,Kn as D,Kr as O,Ot as k,Ru as A,Sn as j,Tn as M,Un as N,Wr as P,_r as F,ct as ne,ed as I,ei as L,fo as re,gn as R,gr as z,gt as ie,hn as B,hr as V,lt as ae,mn as H,mr as U,mt as oe,pr as W,sd as G,vr as K,wn as se,yd as q,yr as J}from"./src-DntJrWmU.js";import{t as Y}from"./i18n-xhwARoF0.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{$n as ce,lr as le,n as Z,t as ue}from"./index-C3uCLHv0.js";s();function de({id:t,title:n,icon:r,description:a,actions:o,tone:s=`default`,notice:l=null,onDismissNotice:u,children:d}){return i(j,{headingId:`access-${t}`,title:n,icon:r,actions:o,testId:`access-${t}`,children:e(`div`,{className:`${c} space-y-3`,children:[i(`div`,{className:G(`text-[11px] leading-relaxed`,s===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),l!==null&&i(pe,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:h,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:y,line:`border-danger/40 text-danger`,mark:`text-danger`}};function pe({notice:t,onDismiss:n}){let{t:r}=X(),a=fe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:G(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[i(o,{className:G(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),i(`span`,{className:`min-w-0 flex-1`,children:t.message}),n!==void 0&&i(I,{type:`button`,variant:`ghost`,size:`sm`,icon:f,"aria-label":r(`access.accessSection.dismiss`,`Dismiss`),onClick:n,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=A();return n(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function he(e,t=null){return e===null?t:{tone:`danger`,message:e}}var ge={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function _e(e){return Y.t(ge[e])}var ve={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ye={current:0,active:1,expired:2,revoked:3};function be(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function xe({status:e}){return i(S,{variant:ve[e],className:`text-[10px]`,children:_e(e)})}function Se({row:t,action:n}){if(!n.isAvailable(t))return null;let r=n.icon,a=n.busyId===t.id;return e(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n.onRun(t),disabled:n.disabled,"aria-label":Y.t(`access.credentialColumns.actionOn`,{action:n.label,name:t.name}),className:n.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?i(p,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(r,{className:`h-3 w-3`,"aria-hidden":!0}),n.label]})}function Ce(t){return[{key:`name`,header:Y.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[i(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&i(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:Y.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:Y.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[i(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&i(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:Y.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ye[e.status],render:e=>i(xe,{status:e.status})},{key:`created`,header:Y.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.createdAt,`—`)})},{key:`lastUsed`,header:Y.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.lastUsedAt,Y.t(`access.credentialColumns.never`))})},{key:`expires`,header:Y.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:Y.t(`access.credentialColumns.actionsHeader`),render:e=>i(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:i(Se,{row:e,action:t},t.label))})}].filter(e=>e!==null)}s();var we=6,Te={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Ee(e){let t=Te[e];return t===void 0?e:Y.t(t)}function De(e,t){return Y.t(t.key,{count:e})}function Q(e,t){return Y.t(`access.bulk.countOf`,{count:e,noun:De(e,t)})}function Oe(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>Y.t(`access.bulk.statusCount`,{count:t,status:_e(e).toLowerCase()})).join(`, `)}function ke(e,t){let n=e.slice(0,we).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>we?[Y.t(`access.bulk.previewMore`,{count:e.length-we})]:[];return[Y.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:Oe(e)}),``,...n,...r].join(`
|
|
2
|
+
`)}async function Ae(e,t,n){let r=String(t.length),i=await e({title:Y.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:ke(t,n),label:Y.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:Y.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:Y.t(`access.bulk.confirmMismatch`,{expected:r,noun:De(2,n)})});return i!==null&&i.trim()===r}function je(e,t){let n=T(),r=q.auth.revokeCredentials.useMutation(),[i,a]=o(null);return{run:async i=>{if(i.length===0||!await Ae(n,i,e))return!1;a(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Ee(e.reason));return a({tone:`success`,message:n.length>0?Y.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):Y.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return a({tone:`danger`,message:Y.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:Y.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:i,dismiss:()=>a(null)}}function Me(e,t,n){let r=T(),[i,a]=o(!1),[s,c]=o(null);return{run:async i=>{if(i.length===0||!await Ae(r,i,e))return!1;c(null),a(!0);let o=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){o.push(`${e.name}: ${t instanceof Error?t.message:Y.t(`access.bulk.requestFailed`)}`)}return a(!1),n(),o.length===0?(c({tone:`success`,message:Y.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:Y.t(o.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:o.length,details:o.slice(0,3).join(`; `)})}),s>0)},busy:i,outcome:s,dismiss:()=>c(null)}}s();var Ne={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Pe={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Fe=e=>e.status!==`current`,Ie=[`active`,`current`];function Le({rows:t,label:r,isLoading:a,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:m,defaultStatus:h=Ie}){let{t:g}=X(),[_]=o(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),v=H(t,Ne,_),[y,b]=o(()=>new Set),x=u??g(`access.credentialColumns.never`),S=n(()=>Ce({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,g]),C=n(()=>m===void 0?()=>!1:e=>Fe(e)&&m.isSelectable(e),[m]),ee=n(()=>v.rows.filter(e=>y.has(e.id)&&C(e)),[v.rows,y,C]);return a?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:r})]}):s===null?e(`div`,{className:`space-y-3`,children:[i(B,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Pe[e.id]===void 0?e.id:g(Pe[e.id]),...e.id===`status`?{facetLabel:e=>_e(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:r}),searchLabel:g(`access.credentialTable.searchLabel`,{label:r}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:r}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),m!==void 0&&i(Re,{bulk:m,shown:v.rows.filter(C),targets:ee,onSelect:b}),i(se,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:M,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:r}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:r}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:De(1,m.noun)})}}})]}):i(w,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:r}),message:s})}function Re({bulk:t,shown:n,targets:r,onSelect:a}){let{t:o}=X(),{revoke:s,noun:c}=t,u=(t.quickSelect??[]).map(e=>({...e,rows:n.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(r)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[n.length>0&&i(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(n.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:n.length})}),u.map(t=>e(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),r.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(r.length,c)})}),e(O,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[i(f,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(O,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?i(p,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(l,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(r.length,c)})]})]})]})}var ze=(e,t)=>t===null?`—`:e.get(t)??t;function Be(e,t){return e!=null&&e<=t?`expired`:`active`}function Ve(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:ze(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function He(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Ue=`All permissions`,We=`View link`,Ge=`Scoped`,Ke={"grid-view":`Grid`,"events-view":`Events`};function qe(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Je(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Ye(e,t,n){return e===`*`?Ue:Je(e)?`${`${Ke[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${qe(e.grant.deviceIds,t)}`:n(e)}function Xe(e){return e.includes(`*`)?Ue:e.some(Je)?We:Ge}function Ze(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:ze(t,e.subjectId),kind:Xe(e.scopes),scope:n,status:e.revokedAt===null?Be(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Qe(e){return`${e.provider}\u0000${e.subject}`}function $e(e,t){return{id:Qe(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:ze(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var et=40,tt=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],nt=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],rt=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function it(e,t){return e.find(e=>e.test.test(t))?.name??null}function at(e){return e.length<=et?e:`${e.slice(0,et)}…`}function ot(e){if(e===null||e.trim().length===0)return{label:Y.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=it(rt,t);if(n!==null)return{label:n,raw:t};let r=it(tt,t),i=it(nt,t);return r!==null&&i!==null?{label:Y.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:at(t),raw:t}:{label:r,raw:t}}var st={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,exchange:`helpers.sessionClient.method.exchange`};function ct(e){let t=st[e];return t===void 0?e:Y.t(t)}function lt(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}s();function ut(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function dt(n){let{t:a}=X(),s=m(),[c,l]=o(!1),[u,d]=o(``),[f,h]=o(null),[g,_]=o(null),v=t(null),y=r(e=>{v.current?.(e),v.current=null,l(!1),d(``),h(null),_(null)},[]),b=r(()=>new Promise(e=>{v.current?.(null),v.current=e,_(null),l(!0)}),[]),S=async()=>{h(`password`),_(null);try{let{reauthToken:e}=await s.reauthenticate({password:u});y(e)}catch(e){_(ut(e,`Password is incorrect`)),h(null)}},ee=async()=>{h(`passkey`),_(null);try{let{optionsJSON:e}=await s.reauthBeginPasskey();if(!ue(e))throw Error(`passkey authentication options missing challenge`);let t=await Z({optionsJSON:e}),{reauthToken:n}=await s.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});y(n)}catch(e){_(ut(e,`Passkey verification failed`)),h(null)}};return{requestProof:b,dialog:i(W,{open:c,onOpenChange:e=>!e&&y(null),children:e(V,{children:[e(K,{children:[i(J,{children:a(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),i(z,{children:a(`auth.reauthDialog.needsPassword`,{action:n})})]}),e(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&f===null&&S()},children:[i(C,{type:`password`,autoComplete:`current-password`,placeholder:a(`auth.reauthDialog.currentPassword`,`Current password`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`auth.reauthDialog.currentPassword`,`Current password`)}),g!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:g}),e(F,{className:`flex flex-wrap gap-2`,children:[e(O,{type:`button`,variant:`outline`,disabled:f!==null,onClick:()=>void ee(),children:[f===`passkey`?i(p,{className:`h-4 w-4 animate-spin`}):i(x,{className:`h-4 w-4`}),a(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),e(O,{type:`submit`,disabled:u.length===0||f!==null,children:[f===`password`&&i(p,{className:`h-4 w-4 animate-spin`}),a(`common.confirm`,`Confirm`)]})]})]})]})})}}function ft({token:t,label:n,onClose:r}){let{t:a}=X();return i(W,{open:!0,onOpenChange:e=>!e&&r(),children:e(V,{width:`md`,scroll:`body`,children:[i(K,{children:i(J,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:n})})}),e(U,{className:`space-y-3`,children:[i(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),i(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(F,{children:[i(R,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),i(O,{type:`button`,variant:`primary`,size:`sm`,onClick:r,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var pt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};s();var mt=80,$=86400,ht=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],gt={type:`device-multiselect`,key:`cameras`,deviceFilter:{types:[`camera`]},maxItems:64},_t={type:`capability`,target:``,access:[`view`,`create`]};function vt({open:t,users:r,onClose:s,onSubmit:c,submitting:l,formError:f,awaitingProof:m}){let{t:h}=X(),v=g(),{user:y}=ce(),b=y?.isAdmin===!0,S=b?null:y?.scopes??[],[w,T]=o(`scopes`),[k,A]=o(y?.id??``),[j,M]=o(``),[P,F]=o([_t]),[I,re]=o([]),[R,z]=o(`grid-view`),[B,V]=o(!1),[H,U]=o(`30`);a(()=>{t||(T(`scopes`),A(y?.id??``),M(``),F([_t]),re([]),z(`grid-view`),V(!1),U(`30`))},[t,y?.id]),a(()=>{w!==`view-link`&&H===`never`&&U(`30`)},[w,H]);let oe=n(()=>ht.filter(e=>e.seconds!==`never`||w===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?h(`access.createTokenModal.never`,`Never (until revoked)`):h(`access.createTokenModal.days`,{count:Number(e.value)})})),[w,h]),W=j.trim(),G=w===`scopes`?ae(P,v):null,K=I.map(Number).filter(e=>Number.isInteger(e)&&e>=0),se=ht.find(e=>e.value===H)?.seconds??30*$,q=()=>w===`all`?[`*`]:w===`view-link`?[{type:`share-view`,grant:{kind:R,deviceIds:K,...B?{talk:!0}:{}}}]:P,J=W.length>0&&W.length<=mt&&!l&&!m&&(w===`all`?b:w===`view-link`?K.length>0:P.length>0&&G===null),Y=()=>{if(!J)return;let e=b&&w!==`all`&&k!==``&&k!==y?.id;c({scopes:q(),expiresIn:se,label:W,...e?{subjectId:k}:{}})},Z=w===`all`,ue=Z?d:_;return i(ie,{open:t,onClose:s,title:h(`access.createTokenModal.createToken`,`Create token`),icon:Z?d:x,error:f,width:`md`,testId:`create-token-dialog`,footer:e(O,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:Y,disabled:!J,"data-testid":`create-token-submit`,children:[l||m?i(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):i(ue,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),h(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(D,{children:h(`access.createTokenModal.whatItMayDo`,`What it may do`)}),i(ee,{appearance:`pills`,value:w,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&T(e)},children:e(te,{"aria-label":h(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(N,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[i(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(N,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[i(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachViewLink`,`View link`)]}),b?e(N,{value:`all`,"data-testid":`token-reach-all`,children:[i(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?i(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:i(`p`,{children:i(le,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:i(`strong`,{})}})})}):null,b&&w!==`all`&&r.length>1?e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-user`,children:h(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),i(E,{id:`token-user`,value:k,onChange:e=>A(e.target.value),options:r.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-name`,children:h(`access.createTokenModal.label`,`Label`)}),i(C,{id:`token-name`,value:j,maxLength:mt,required:!0,onChange:e=>M(e.target.value),placeholder:w===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),w===`scopes`?e(`div`,{className:`space-y-1`,children:[i(D,{children:h(`access.createTokenModal.scopes`,`Scopes`)}),i(ne,{value:P,onChange:F,clampToParent:S}),G&&i(`p`,{className:`text-[10px] text-danger`,children:G}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:h(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,w===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[i(D,{children:h(`access.createTokenModal.cameras`,`Cameras`)}),i(L,{field:{...gt,label:h(`access.createTokenModal.cameras`,`Cameras`)},value:I,onChange:e=>re(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])})]}),e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-view-kind`,children:h(`access.createTokenModal.viewKind`,`Shows`)}),i(E,{id:`token-view-kind`,value:R,onChange:e=>z(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:h(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:h(`access.createTokenModal.viewEvents`,`Events`)}]})]}),R===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[i(`input`,{type:`checkbox`,className:`mt-0.5`,checked:B,onChange:e=>V(e.target.checked),"data-testid":`token-view-talk`}),i(`span`,{children:h(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[i(D,{htmlFor:`token-lifetime`,children:h(`access.createTokenModal.expires`,`Expires after`)}),i(E,{id:`token-lifetime`,value:H,onChange:e=>U(e.target.value),options:oe})]})]})})}s();var yt={key:`access.nouns.token`};function bt(e){return typeof e==`object`&&!!e&&`kind`in e}function xt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${bt(e.selector)?k(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function St({headerOwnsCreate:t=!1,createRequested:r=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:u}=X(),d=g(),{user:f}=ce(),p=P(),m=q.useUtils(),h=me(),{data:_}=A(),v=n(()=>_??[],[_]),{data:y}=re({}),b=n(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),S=q.auth.listTokens.useQuery(void 0),{requestProof:C,dialog:ee}=dt(`Creating a token with all permissions`),{state:w,openNew:T,close:te}=oe({newKey:pt.token}),[E,D]=o(null),[k,j]=o(null),[M,N]=o(!1),[F,ne]=o(null),[I,L]=o(null);a(()=>{r&&(T(),s?.())},[r,T,s]);let R=()=>{m.auth.listTokens.invalidate(),m.auth.listAuthAudit.invalidate()},z=q.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{R(),te(),j(null),N(!1),ne({token:e,label:t.label})},onError:e=>{j(`Create failed: ${e.message}`),N(!1)}}),ie=q.auth.revokeToken.useMutation({onSuccess:()=>{L(null),R()},onError:e=>{L(null),D(`Revoke failed: ${e.message}`)}}),B=je(yt,R),V=Date.now(),ae=(S.data??[]).filter(e=>!c||e.subjectId===f?.id).map(e=>Ze(e,h,e.scopes.includes(`*`)?null:e.scopes.map(e=>Ye(e,b,e=>xt(e,d))).join(`, `),V)),H=async e=>{await p({title:u(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?u(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):u(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:u(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(D(null),L(e.id),ie.mutate({id:e.id}))},U=e=>{(async()=>{D(null),j(null);let t;if(e.scopes.includes(`*`)){N(!0);let e=await C();if(N(!1),e===null)return;t=e}z.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[ee,i(de,{notice:he(E,B.outcome),onDismissNotice:()=>{D(null),B.dismiss()},id:c?`my-tokens`:`tokens`,title:c?u(`access.tokensSection.myTokens`,`My tokens`):u(`access.tokensSection.tokens`,`Tokens`),icon:x,actions:t?void 0:e(O,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:T,children:[i(x,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),u(`system.access.newToken`,`New token`)]}),description:u(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:i(Le,{rows:ae,label:u(`common.tokensLabel`),isLoading:S.isLoading,loadError:S.isError?S.error?.message??`Request failed`:null,emptyText:u(`access.tokensSection.noTokens`,`No tokens.`),action:{label:u(`access.tokensSection.revoke2`,`Revoke`),icon:l,isAvailable:e=>e.status===`active`,onRun:e=>void H(e),busyId:I,disabled:B.busy||I!==null},...f?.isAdmin===!0?{bulk:{revoke:B,noun:yt,isSelectable:e=>e.status===`active`}}:{}})}),i(vt,{open:w.mode===`new`,users:v.map(e=>({id:e.id,username:e.username})),onClose:()=>{te(),j(null),N(!1)},submitting:z.isPending,formError:k,awaitingProof:M,onSubmit:U}),F&&i(ft,{token:F.token,label:F.label,onClose:()=>ne(null)})]})}var Ct=864e5,wt={qr:`QR (by an admin)`,self:`Self-enrolled`},Tt={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function Et(e){return e.status===`revoked`}function Dt(e){return e.status!==`revoked`}function Ot(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function kt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/Ct)}function At(e,t){let n=kt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function jt(e,t){let n=kt(e,t);return n===null?Y.t(`helpers.certificateModel.unknown`):n===0?Y.t(`helpers.certificateModel.today`):n>0?Y.t(`helpers.certificateModel.inDays`,{count:n}):Y.t(`helpers.certificateModel.daysAgo`,{count:-n})}function Mt(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Nt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Pt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Ft(e){if(!e.online)return{allowed:!1,reason:Y.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var It={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Lt(e){if(e.ok)return{tone:`success`,message:Y.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Pt(e.newSerial)})};let t=e.keptPreviousLeaf?Y.t(`helpers.certificateModel.keptPrevious`):Y.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:Y.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:Y.t(It[e.stage]),reason:e.reason,kept:t})}}function Rt(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var zt=11;function Bt(e,t){let n=e.slice(0,zt);return t===null?n:`${n} · ${t}`}function Vt(e){return{id:e.id,name:e.deviceName,detail:Bt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:Tt[e.platform],scope:wt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ht(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:Tt[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ut({sessions:t,isLoading:n,loadError:r,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=X();return n?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):r===null?t.length===0?i(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>i(Wt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,r]})}function Wt({session:t,revoking:n,onRevoke:r}){let{t:a}=X(),o=ot(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[i(v,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&i(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:ct(t.method)}),i(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),i(`span`,{children:a(`auth.sessionsList.lastActive`,{when:lt(t.lastUsedAt)})}),i(`span`,{children:a(`auth.sessionsList.expires`,{when:lt(t.expiresAt)})})]})]}),!t.current&&e(`button`,{onClick:r,disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[n?i(p,{className:`h-3 w-3 animate-spin`}):i(b,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{me as A,He as C,Me as D,je as E,de as O,$e as S,Le as T,dt as _,Dt as a,lt as b,jt as c,Ot as d,Ft as f,pt as g,St as h,Et as i,he as k,Lt as l,Pt as m,Vt as n,Rt as o,Nt as p,Ht as r,Mt as s,Ut as t,At as u,ot as v,Ve as w,Qe as x,ct as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{at as i}from"./src-ByunGuTZ.js";import{P as a,cr as o,sr as s}from"./index-BFjKpxae.js";r();function c({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function l({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}var u={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function d(){let[r,d]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(c,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(c,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(l,{name:`primary`,cssVar:`--color-primary`}),t(l,{name:`background`,cssVar:`--color-background`}),t(l,{name:`surface`,cssVar:`--color-surface`}),t(l,{name:`foreground`,cssVar:`--color-foreground`}),t(l,{name:`success`,cssVar:`--color-success`}),t(l,{name:`warning`,cssVar:`--color-warning`}),t(l,{name:`danger`,cssVar:`--color-danger`}),t(l,{name:`info`,cssVar:`--color-info`}),t(l,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(l,{name:`onvif`,hex:`#3b82f6`}),t(l,{name:`hikvision`,hex:`#a855f7`}),t(l,{name:`reolink`,hex:`#06b6d4`}),t(l,{name:`ha`,hex:`#22d3ee`}),t(l,{name:`rtsp`,hex:`#78716c`})]})}),t(c,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),t(`button`,{disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),t(c,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(`input`,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(`input`,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,children:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(`textarea`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(f,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),t(c,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(i,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(o,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(c,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(c,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(s,{type:e,size:`lg`,showLabel:!0},e))})}),e(c,{title:`Form Builder Demo`,children:[t(a,{schema:u,values:r,onChange:d}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(r,null,2)})]})]}),t(c,{title:`Info Boxes`,children:t(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:n,label:r,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function f(){let[e,r]=n(!0);return t(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:t(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{d as ShowroomPage};
|
|
1
|
+
import{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{ot as i}from"./src-DntJrWmU.js";import{P as a,cr as o,sr as s}from"./index-C3uCLHv0.js";r();function c({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function l({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}var u={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function d(){let[r,d]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(c,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(c,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(l,{name:`primary`,cssVar:`--color-primary`}),t(l,{name:`background`,cssVar:`--color-background`}),t(l,{name:`surface`,cssVar:`--color-surface`}),t(l,{name:`foreground`,cssVar:`--color-foreground`}),t(l,{name:`success`,cssVar:`--color-success`}),t(l,{name:`warning`,cssVar:`--color-warning`}),t(l,{name:`danger`,cssVar:`--color-danger`}),t(l,{name:`info`,cssVar:`--color-info`}),t(l,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(l,{name:`onvif`,hex:`#3b82f6`}),t(l,{name:`hikvision`,hex:`#a855f7`}),t(l,{name:`reolink`,hex:`#06b6d4`}),t(l,{name:`ha`,hex:`#22d3ee`}),t(l,{name:`rtsp`,hex:`#78716c`})]})}),t(c,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),t(`button`,{disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),t(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),t(c,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(`input`,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(`input`,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,children:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(`textarea`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(f,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),t(c,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(i,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(o,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(c,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(c,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(s,{type:e,size:`lg`,showLabel:!0},e))})}),e(c,{title:`Form Builder Demo`,children:[t(a,{schema:u,values:r,onChange:d}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(r,null,2)})]})]}),t(c,{title:`Info Boxes`,children:t(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:n,label:r,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function f(){let[e,r]=n(!0);return t(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:t(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{d as ShowroomPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,a as o,et as s,o as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as d,It as f,Nt as p,Rr as m,Tn as h,bi as g,bn as _,dn as v,en as y,hi as b,mi as x,mr as S,or as C,ot as w,rr as ee,sn as te,tr as ne,un as T,xi as re,yi as ie}from"./player-overlays-Dbv95cvz.js";import{Zr as ae}from"./client-DvJxGh2F.js";import{i as oe}from"./video-D7jv0spx.js";import{t as E}from"./key-round-DG341WFZ.js";import{Bn as D,Cn as O,Cs as se,Er as ce,Es as le,Gr as k,Gu as A,Hn as j,Hr as M,Qr as N,Qu as P,Ss as ue,Ts as de,Ur as fe,Vn as pe,Wr as me,_r as he,_s as ge,bs as F,cu as I,du as L,fr as _e,gr as ve,gs as ye,hn as R,hr as be,mr as xe,mu as Se,od as z,pd as Ce,pr as we,vr as Te,vs as Ee,wn as De,ws as Oe,xn as ke,xr as Ae,xs as je,ys as Me,zn as Ne}from"./src-ByunGuTZ.js";import{t as B}from"./i18n-l_m6iBJW.js";import{t as V}from"./useTranslation-BJr-n0es.js";import{T as Pe,lr as Fe,mr as Ie,x as Le}from"./index-BFjKpxae.js";import{t as Re}from"./AdminSectionedPage-B77fFYLu.js";import{t as H}from"./AdminPage-BBb_f0ke.js";import{t as ze}from"./NodeAddonsSettingsPanel-P5f0HKwt.js";import{t as Be}from"./AddonAssetIcon-NsStjqDv.js";s();var Ve={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},He={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function Ue({entry:t,actions:n}){let i=t.name.toLowerCase(),a=Ve[i]??`border-primary`,o=He[i]??`bg-primary/5`,s=t.providers.find(e=>e.active),c=n?.pendingCapability===t.name;return e(`div`,{className:`rounded-lg border-t-2 border border-border ${a} ${o} p-3 space-y-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[e(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[t.name,c&&r(C,{className:`h-3 w-3 animate-spin text-primary`})]}),r(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${t.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:t.mode})]}),t.mode===`singleton`?r(We,{entry:t,actions:n,activeProvider:s,isPending:c}):r(Ge,{entry:t,actions:n,isPending:c})]})}function We({entry:t,actions:n,activeProvider:i,isPending:a}){let{t:o}=V();if(!n)return r(`div`,{children:i?e(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[r(x,{className:`h-3 w-3 text-green-400 shrink-0`}),r(`span`,{className:`font-medium`,children:i.addonName}),r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noActiveProvider`,`No active provider`)})});if(t.providers.length===0)return r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noProviders`,`No providers`)});let s=`__inherit__`;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`space-y-1`,children:t.providers.map(i=>{let o=i.active;return e(`button`,{type:`button`,disabled:a||o,onClick:()=>n.onSelectSingleton(t.name,i.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${o?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[r(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${o?`border-green-400 bg-green-400`:`border-border`}`}),r(`span`,{className:`font-medium truncate`,children:i.addonName}),o&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},i.addonId)})}),t.perNode&&t.perNode.length>0&&r(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:t.perNode.map(i=>{let c=i.hasOverride&&i.resolvedActive?i.resolvedActive:s,l=[{value:s,label:i.resolvedActive?o(`addons.capabilityMap.inheritGlobalWith`,{provider:i.resolvedActive}):o(`addons.capabilityMap.inheritGlobal`)},...i.providers.map(e=>({value:e,label:e}))],u=e=>{e===s?n.onClearNodeSingleton(t.name,i.nodeId):n.onSelectNodeSingleton(t.name,i.nodeId,e)},d=a;return e(`div`,{className:`space-y-0.5`,children:[e(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[i.nodeId,i.hasOverride&&r(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:o(`common.override`)})]}),l.map(t=>{let n=c===t.value;return e(`button`,{type:`button`,disabled:d||n,onClick:()=>u(t.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[r(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),r(`span`,{className:`font-medium truncate`,children:t.label}),n&&t.value!==s&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},t.value)})]},i.nodeId)})})]})}function Ge({entry:t,actions:n,isPending:i}){let{t:a}=V();if(t.providers.length===0)return r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:a(`addons.capabilityMap.noProviders`,`No providers`)});if(!n)return r(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.addonName}),t.active&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},t.addonId))});let o=t.providers.filter(e=>e.active).map(e=>e.addonId),s=(e,r)=>{let i=r?[...new Set([...o,e])]:o.filter(t=>t!==e);n.onToggleCollection(t.name,i)};return r(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${i?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[e(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[r(`input`,{type:`checkbox`,checked:t.active,disabled:i,onChange:e=>s(t.addonId,e.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),r(`span`,{className:`text-foreground truncate`,children:t.addonName})]}),t.active&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},t.addonId))})}function U({capabilities:e,actions:t}){let{t:n}=V();return e.length===0?r(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:n(`addons.capabilityMap.noCapabilitiesRegistered`,`No capabilities registered`)}):r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>r(Ue,{entry:e,actions:t},e.name))})}var W=[`capabilities`,`listCapabilities`];function Ke(e){return e===`singleton`||e===`collection`}function qe(e){let t=e.indexOf(`@`);return t===-1?B.t(`system.capabilities.providerHub`,{addonId:e}):`${e.slice(0,t)} (${e.slice(t+1)})`}function Je(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:qe(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function Ye(){let{t:n}=V(),i=w(),[s,c]=a(null),[u,d]=a(null),f=o({queryKey:W,queryFn:()=>i.trpcClient.capabilities.listCapabilities.query()}),p=t(()=>{let e=(f.data??[]).flatMap(e=>Ke(e.mode)?[Je(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[f.data]),m=t(()=>p.filter(e=>e.mode===`singleton`),[p]),h=t(()=>p.filter(e=>e.mode===`collection`),[p]),g=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:t.capName,addonId:t.addonId})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToSet`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),_=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToSetOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),v=l({mutationFn:e=>i.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:t.capName,nodeId:t.nodeId})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToClearOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),S=l({mutationFn:e=>i.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:t.capName,length:t.enabledAddonIds.length})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToUpdate`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),C={onSelectSingleton:(e,t)=>g.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>_.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>v.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>S.mutate({capName:e,enabledAddonIds:t}),pendingCapability:s};return e(H,{embedded:!0,icon:y,title:n(`system.capabilities.capabilities`,`Capabilities`),subtitle:n(`system.capabilities.chooseWhichProviderIsActive`,`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`),children:[u&&e(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${u.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[u.kind===`success`?r(x,{className:`h-3.5 w-3.5 shrink-0`}):r(b,{className:`h-3.5 w-3.5 shrink-0`}),r(`span`,{children:u.message})]}),f.isLoading&&r(`div`,{className:`flex items-center justify-center py-16`,children:r(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),f.isError&&!f.isLoading&&r(ce,{title:n(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:f.error instanceof Error?f.error.message:n(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void f.refetch()}),!f.isLoading&&!f.isError&&p.length===0&&r(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:n(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!f.isLoading&&!f.isError&&p.length>0&&e(`div`,{className:`space-y-6`,children:[m.length>0&&e(`section`,{className:`space-y-2`,children:[r(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:n(`system.capabilities.singletonPickOneProvider`,`Singleton — pick one provider`)}),r(U,{capabilities:m,actions:C})]}),h.length>0&&e(`section`,{className:`space-y-2`,children:[r(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:n(`system.capabilities.collectionEnableASet`,`Collection — enable a set`)}),r(U,{capabilities:h,actions:C})]})]})]})}var G=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Xe={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function Ze(e){let t=Xe[e];return t===void 0?e:B.t(t)}function Qe({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:B.t(`helpers.keychainNotices.locked`,{reason:Ze(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?B.t(`helpers.keychainNotices.resetPending`,{count:n}):B.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:B.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:B.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:B.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:B.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>G.indexOf(e.id)-G.indexOf(t.id))}var $e={dateStyle:`short`,timeStyle:`short`};function K(e){return e===null?`—`:new Date(e).toLocaleString(void 0,$e)}function q({value:t,copyValue:n,srLabel:i,maxWidthClass:a,className:o}){let s=n??t;return e(`span`,{className:z(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:z(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(R,{value:s,srLabel:i,className:`h-6 shrink-0 px-1.5`})]})}s();var et=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function tt(e){return[{key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>K(e.at)},{key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>r(N,{variant:et.has(e.action)?`warning`:`default`,children:e.action})},{key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>r(`span`,{className:`font-mono`,children:e.actor})},{key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(q,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>r(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function nt({entries:n}){let{t:i}=V(),[o,s]=a(0),c=t(()=>tt(i),[i]);if(n===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:i(`common.loading`,`Loading…`)});let l=Math.max(1,Math.ceil(n.length/25)),u=Math.min(o,l-1),d=u*25,f=n.slice(d,d+25);return e(`div`,{className:`space-y-2`,children:[r(O,{columns:c,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:i(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),n.length>25&&e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:i(n.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:n.length})}),e(`span`,{className:`inline-flex items-center gap-1`,children:[r(k,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(k,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function rt(e,t){switch(e){case`locked`:return r(k,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:B.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(k,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:B.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(k,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:B.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(k,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:B.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(k,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:B.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function it(e,t){switch(e){case`locked`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:r(at,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return r(`p`,{children:r(Fe,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:r(`code`,{className:`font-mono`})}})});case`recovery-key`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function at({reset:t,pending:n}){let{t:i}=V(),a=t.actor===`trigger-file`?i(`secrets.keychainNoticeContent.resetByTrigger`):i(`secrets.keychainNoticeContent.resetByAdmin`,{actor:t.actor});return e(`div`,{className:`space-y-1.5`,children:[r(`p`,{children:i(`secrets.keychainNoticeContent.resetDetail`,{when:K(t.at),by:a,archived:t.archived})}),n.length>0&&r(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:n.map(t=>e(`li`,{className:`break-all`,children:[t.owner,` · `,t.scope,` · `,t.fieldPath]},t.ref))})]})}s();var ot=2,J={danger:{icon:oe,text:`text-danger`,border:`border-danger/40`},warning:{icon:p,text:`text-warning`,border:`border-warning/40`},info:{icon:S,text:`text-info`,border:`border-border`}};function st({notices:t,renderAction:n,renderDetail:i}){let{t:o}=V(),[s,c]=a(!1),l=t[0];if(l===void 0)return null;let u=t.length>ot,d=u&&!s?t.slice(0,1):t,f=t.length-d.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:z(`rounded-lg border bg-surface`,J[l.tone].border),children:[r(`ul`,{className:`divide-y divide-border`,children:d.map(e=>r(ct,{notice:e,action:n(e.id),detail:i(e.id)},e.id))}),u&&r(`div`,{className:`border-t border-border px-3 py-1`,children:e(k,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(re,{className:z(`h-3.5 w-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0}),s?o(`secrets.keychainNotices.showLess`,`Show less`):o(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:f})]})})]})}function ct({notice:t,action:n,detail:i}){let{t:o}=V(),[s,c]=a(!1),l=J[t.tone],u=l.icon,d=i!=null,f=`keychain-notice-${t.id}`;return e(`li`,{className:`px-3 py-2`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[e(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[r(u,{className:z(`mt-0.5 h-3.5 w-3.5 shrink-0`,l.text),"aria-hidden":!0}),r(`span`,{className:`min-w-0 break-words`,children:t.title})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[d&&r(k,{size:`sm`,variant:`ghost`,"aria-expanded":s,"aria-controls":f,onClick:()=>c(e=>!e),children:o(`secrets.keychainNotices.details`,`Details`)}),n]})]}),d&&s&&r(`div`,{id:f,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:i})]})}var lt={"config-file":`Key file (config.yaml)`,"previous-config-file":`Previous key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},ut=8;function dt({status:t,busy:n,onDownload:i,onRotate:a,onPurge:o}){let{t:s}=V(),c=t.keychain.state===`locked`,l=t.keySource??t.configuredSource;return r(ke,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:E,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(k,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(k,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(k,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${d} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[e(Y,{label:s(`secrets.keychainStatusCard.state`,`State`),children:[c?e(N,{variant:`danger`,className:`gap-1`,children:[r(ee,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.locked`,`Locked`)]}):e(N,{variant:`success`,className:`gap-1`,children:[r(te,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:s(`common.stored`,{count:t.secretCount})})]}),e(Y,{label:s(`secrets.keychainStatusCard.keySource`,`Key source`),children:[r(`span`,{className:`block`,children:lt[l.kind]}),l.path!==void 0&&r(q,{value:l.path,srLabel:`key path`})]}),r(Y,{label:s(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:t.fingerprint===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:`inline-flex items-center gap-0.5`,children:[r(`span`,{className:`font-mono`,title:t.fingerprint,children:t.fingerprint.slice(0,ut)}),r(R,{value:t.fingerprint,srLabel:`fingerprint`})]})}),r(Y,{label:s(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:t.recoveryKeyDownloadedAt===null?r(N,{variant:`warning`,children:s(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):r(`span`,{children:s(`secrets.keychainStatusCard.taken`,{when:K(t.recoveryKeyDownloadedAt)})})})]})})}function Y({label:t,children:n}){return e(`div`,{className:`min-w-0 text-xs`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:n})]})}s();var ft=1e3;function pt({revealed:t,onClose:n}){let{t:o}=V(),[s,c]=a(A);i(()=>{if(t===null)return;let e=Date.now();c(A);let r=setTimeout(n,A),i=setInterval(()=>c(Math.max(0,A-(Date.now()-e))),ft);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let l=Math.ceil(s/1e3);return r(_e,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(xe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(u,{children:[e(he,{children:[r(Te,{className:`break-all`,children:t.entry.fieldPath}),e(be,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(we,{children:r(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:t.value})}),e(ve,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`secrets.revealDialog.recorded`,{seconds:l})}),e(`div`,{className:`flex justify-end gap-2`,children:[r(R,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(k,{size:`sm`,variant:`outline`,onClick:n,children:o(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var X={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},mt=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],Z=`system`;function ht(t){let{t:n}=V(),{secrets:i,filter:a,onFilterChange:o,onDeleteOrphans:s,deleting:c,locked:l}=t;if(i===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`common.loading`,`Loading…`)});let u=e=>e===`all`?i.length:i.filter(t=>t.usage===e).length,d=i.filter(e=>e.usage===`orphan`).map(e=>e.ref),p=a===`all`?i:i.filter(e=>e.usage===a);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":n(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:mt.map(t=>e(k,{size:`sm`,variant:a===t.id?`secondary`:`ghost`,"aria-pressed":a===t.id,className:a===t.id?`ring-1 ring-border`:void 0,onClick:()=>o(t.id),children:[n(t.labelKey),r(`span`,{className:`text-foreground-subtle tabular-nums`,children:u(t.id)})]},t.id))}),d.length>0&&e(k,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(O,{columns:_t(t),rows:p,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:De,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:i.length===0?n(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):n(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function gt({owner:t}){let{t:n}=V();return e(`span`,{className:`flex items-center gap-2`,children:[r(Be,{addonId:t,fallback:t===Z?v:h,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),r(`span`,{className:`font-medium`,children:t===Z?n(`secrets.secretsTable.hubSystem`,`Hub (system)`):t})]})}function _t({locked:t,onReveal:n,revealing:i}){return[{key:`owner`,header:B.t(`secrets.secretsTable.owner`,`Owner`),render:e=>r(gt,{owner:e.owner}),sortValue:e=>e.owner},{key:`scope`,header:B.t(`secrets.secretsTable.scope`,`Scope`),render:e=>r(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{key:`field`,header:B.t(`secrets.secretsTable.field`,`Field`),render:e=>r(q,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{key:`updated`,header:B.t(`secrets.secretsTable.updated`,`Updated`),render:e=>K(e.updatedAt),sortValue:e=>e.updatedAt},{key:`last-read`,header:B.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>K(e.lastReadAt),sortValue:e=>e.lastReadAt},{key:`status`,header:B.t(`secrets.secretsTable.status`,`Status`),render:e=>r(N,{variant:X[e.usage].variant,title:B.t(X[e.usage].hintKey),children:B.t(X[e.usage].labelKey)}),sortValue:e=>X[e.usage].rank},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:a=>e(k,{size:`sm`,variant:`ghost`,disabled:t||i,"aria-label":B.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:a.fieldPath}),title:t?B.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):B.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>n(a),children:[r(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function vt(e){return e instanceof Error?e.message:String(e)}function yt(e){let{t}=V(),n=fe(),r=M(),i=me(),a=Ee(),o=de(),s=je(),c=ue(),l=ye(),u=ge(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:vt(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:ae})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}s();var Q=`view`;function bt(){let[e,t]=Ie();return[e.get(Q)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(Q):r.set(Q,n),t(r,{replace:!0})}]}function xt(){let{t:i}=V(),o=le({}),s=F({}),c=Me({limit:500}),l=se({}),u=Oe(),d=M(),[f,p]=bt(),[m,h]=a(`all`),[g,_]=a(null),v=yt(()=>{o.refetch(),s.refetch(),c.refetch(),l.refetch()}),y=o.data?.keychain.state===`locked`,b=t(()=>(s.data??[]).filter(e=>e.usage===`orphan`).length,[s.data]),x=t(()=>o.data===void 0?[]:Qe({status:o.data,reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry.length??0,orphans:b}),[o.data,l.data,b]),S={reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async e=>{try{_({entry:e,value:(await u.mutateAsync({ref:e.ref})).value}),s.refetch()}catch(e){await d({title:i(`admin.system.secrets.revealRefused`,`Reveal refused`),message:Pe(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(H,{embedded:!0,icon:E,title:i(`admin.system.secrets.secrets`,`Secrets`),subtitle:i(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[r(st,{notices:x,renderAction:e=>rt(e,S),renderDetail:e=>it(e,S)}),o.data!==void 0&&r(dt,{status:o.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),e(Ne,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(pe,{children:[r(j,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(j,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(D,{value:`values`,children:r(ht,{secrets:s.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:u.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),r(D,{value:`audit`,children:r(nt,{entries:c.data})})]}),r(pt,{revealed:g,onClose:w})]})}s();var St=[[`system`]];function $(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function Ct(){let{t}=V(),n=c(),o=L(),s=Se(),l=I(),[u,d]=a(``),[f,p]=a(``),[m,h]=a(null),g=o.data?.location??null;i(()=>{d(g===null?``:$(g.latitude)),p(g===null?``:$(g.longitude))},[g]);let v=async()=>{await n.invalidateQueries({queryKey:St})},y=async e=>{e.preventDefault();let t=Number(u),n=Number(f);if(u.trim()===``||f.trim()===``){h(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){h(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){h(`Longitude must be between -180 and 180 decimal degrees.`);return}h(null),await s.mutateAsync({latitude:t,longitude:n}),await v()},b=async()=>{h(null),await s.mutateAsync(null),await v()},x=async()=>{h(null),await l.mutateAsync(),await v()},S=s.isPending||l.isPending||o.isLoading;return e(Ae,{className:`space-y-3`,children:[e(`div`,{className:`flex items-start justify-between gap-3`,children:[e(`div`,{className:`flex items-start gap-2`,children:[r(ne,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),r(`div`,{children:r(`h3`,{className:`text-sm font-medium`,children:t(`settings.siteLocationCard.siteLocation`,`Site location`)})})]}),g===null?r(N,{variant:`warning`,children:t(`settings.siteLocationCard.notConfigured`,`Not configured`)}):r(N,{variant:g.source===`operator-set`?`success`:`info`,children:g.source===`operator-set`?t(`settings.siteLocationCard.setByYou`,`Set by you`):t(`settings.siteLocationCard.derivedFromIp`,`Derived from IP`)})]}),g?.label!==void 0&&g.label!==``?r(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.detectedNear`,{place:g.label})}):null,g===null&&o.data?.derivationAttemptedAt!==null?e(`p`,{className:`text-xs text-warning`,children:[t(`settings.siteLocationCard.automaticDetectionFromThePublic`,`Automatic detection from the public IP did not succeed`),o.data?.derivationError!==null&&o.data?.derivationError!==void 0?`: ${o.data.derivationError}`:`.`,` `,t(`settings.siteLocationCard.itIsNotRetriedOn`,`It is not retried on its own — enter the coordinates, or press Detect.`)]}):null,e(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:y,children:[e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[r(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.latitude`,`Latitude`)}),r(P,{className:`w-40`,value:u,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>d(e.target.value),"aria-label":t(`settings.siteLocationCard.latitude`,`Latitude`)})]}),e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[r(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.longitude`,`Longitude`)}),r(P,{className:`w-40`,value:f,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>p(e.target.value),"aria-label":t(`settings.siteLocationCard.longitude`,`Longitude`)})]}),r(k,{type:`submit`,disabled:S,children:t(`common.save`,`Save`)}),e(k,{type:`button`,variant:`ghost`,disabled:S,onClick:x,children:[r(_,{className:`h-3.5 w-3.5 mr-1`}),t(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),g===null?null:r(k,{type:`button`,variant:`ghost`,disabled:S,onClick:b,children:t(`settings.siteLocationCard.clear`,`Clear`)})]}),m===null?null:r(`p`,{className:`text-xs text-danger`,children:m}),r(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.wgs84DecimalDegreesDetectAsks`,`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`)})]})}function wt(){let{t}=V(),{nodes:n,isLoading:i}=Ce(),a=n.find(e=>e.isHub&&e.isOnline),o=a?.addons.map(e=>e.addonId)??[];return e(H,{embedded:!0,children:[r(Ct,{}),i?r(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:t(`admin.system.settings.loadingHubTopology`,`Loading hub topology…`)}):a?o.length===0?r(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:t(`admin.system.settings.noAddonsInstalledOnThe`,`No addons installed on the hub yet.`)}):r(ze,{nodeId:a.id,addonIds:o,level:`global`}):e(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12`,children:[r(T,{className:`h-8 w-8 opacity-30`}),r(`p`,{children:t(`admin.system.settings.noOnlineHubNodeFound`,`No online hub node found.`)}),r(`p`,{className:`text-xs`,children:t(`admin.system.settings.settingsWillAppearOnceThe`,`Settings will appear once the hub is reachable.`)})]})]})}function Tt(){let{t:e}=V(),t=Le(`/system/settings`,{t:e,isAdmin:!0})??{icon:T,title:e(`system.systemNav`,`System`)};return r(Re,{icon:t.icon,title:t.title,defaultSection:`settings`,sectionsLabel:`${t.title} sections`,sections:[{id:`settings`,label:e(`system.system.settings`,`Settings`),content:r(wt,{})},{id:`secrets`,label:e(`system.system.secrets`,`Secrets`),content:r(xt,{}),ownedParams:[`view`]},{id:`capabilities`,label:e(`system.system.capabilities`,`Capabilities`),content:r(Ye,{})}]})}export{Tt as SystemPage};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,a as o,et as s,o as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as d,It as f,Nt as p,Rr as m,Tn as h,bi as g,bn as _,dn as v,en as y,hi as b,mi as x,mr as S,or as C,ot as w,rr as ee,sn as te,tr as ne,un as T,xi as re,yi as ie}from"./player-overlays-Dbv95cvz.js";import{Zr as ae}from"./client-DvJxGh2F.js";import{i as oe}from"./video-D7jv0spx.js";import{t as E}from"./key-round-DG341WFZ.js";import{$r as D,$u as O,Bn as se,Cs as ce,Dr as le,Ds as ue,Es as de,Gr as fe,Hn as k,Kr as A,Ku as j,Sn as pe,Sr as me,Ss as he,Tn as ge,Ts as _e,Un as M,Ur as N,Vn as P,Wr as F,_r as I,_s as ve,bs as ye,fu as be,gn as L,gr as xe,hr as Se,hu as Ce,lu as we,md as Te,mr as Ee,pr as De,sd as R,vr as Oe,vs as ke,wn as z,ws as Ae,xs as je,yr as Me,ys as Ne}from"./src-DntJrWmU.js";import{t as B}from"./i18n-xhwARoF0.js";import{t as V}from"./useTranslation-BJr-n0es.js";import{T as Pe,lr as Fe,mr as Ie,x as Le}from"./index-C3uCLHv0.js";import{t as Re}from"./AdminSectionedPage-DtiHBXGC.js";import{t as H}from"./AdminPage-3JxWocN3.js";import{t as ze}from"./NodeAddonsSettingsPanel-Dq6sGWkR.js";import{t as Be}from"./AddonAssetIcon-B_-30Ezl.js";s();var Ve={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},He={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function Ue({entry:t,actions:n}){let i=t.name.toLowerCase(),a=Ve[i]??`border-primary`,o=He[i]??`bg-primary/5`,s=t.providers.find(e=>e.active),c=n?.pendingCapability===t.name;return e(`div`,{className:`rounded-lg border-t-2 border border-border ${a} ${o} p-3 space-y-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[e(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[t.name,c&&r(C,{className:`h-3 w-3 animate-spin text-primary`})]}),r(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${t.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:t.mode})]}),t.mode===`singleton`?r(We,{entry:t,actions:n,activeProvider:s,isPending:c}):r(Ge,{entry:t,actions:n,isPending:c})]})}function We({entry:t,actions:n,activeProvider:i,isPending:a}){let{t:o}=V();if(!n)return r(`div`,{children:i?e(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[r(x,{className:`h-3 w-3 text-green-400 shrink-0`}),r(`span`,{className:`font-medium`,children:i.addonName}),r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noActiveProvider`,`No active provider`)})});if(t.providers.length===0)return r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noProviders`,`No providers`)});let s=`__inherit__`;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`space-y-1`,children:t.providers.map(i=>{let o=i.active;return e(`button`,{type:`button`,disabled:a||o,onClick:()=>n.onSelectSingleton(t.name,i.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${o?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[r(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${o?`border-green-400 bg-green-400`:`border-border`}`}),r(`span`,{className:`font-medium truncate`,children:i.addonName}),o&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},i.addonId)})}),t.perNode&&t.perNode.length>0&&r(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:t.perNode.map(i=>{let c=i.hasOverride&&i.resolvedActive?i.resolvedActive:s,l=[{value:s,label:i.resolvedActive?o(`addons.capabilityMap.inheritGlobalWith`,{provider:i.resolvedActive}):o(`addons.capabilityMap.inheritGlobal`)},...i.providers.map(e=>({value:e,label:e}))],u=e=>{e===s?n.onClearNodeSingleton(t.name,i.nodeId):n.onSelectNodeSingleton(t.name,i.nodeId,e)},d=a;return e(`div`,{className:`space-y-0.5`,children:[e(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[i.nodeId,i.hasOverride&&r(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:o(`common.override`)})]}),l.map(t=>{let n=c===t.value;return e(`button`,{type:`button`,disabled:d||n,onClick:()=>u(t.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[r(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),r(`span`,{className:`font-medium truncate`,children:t.label}),n&&t.value!==s&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},t.value)})]},i.nodeId)})})]})}function Ge({entry:t,actions:n,isPending:i}){let{t:a}=V();if(t.providers.length===0)return r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:a(`addons.capabilityMap.noProviders`,`No providers`)});if(!n)return r(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.addonName}),t.active&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},t.addonId))});let o=t.providers.filter(e=>e.active).map(e=>e.addonId),s=(e,r)=>{let i=r?[...new Set([...o,e])]:o.filter(t=>t!==e);n.onToggleCollection(t.name,i)};return r(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${i?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[e(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[r(`input`,{type:`checkbox`,checked:t.active,disabled:i,onChange:e=>s(t.addonId,e.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),r(`span`,{className:`text-foreground truncate`,children:t.addonName})]}),t.active&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},t.addonId))})}function U({capabilities:e,actions:t}){let{t:n}=V();return e.length===0?r(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:n(`addons.capabilityMap.noCapabilitiesRegistered`,`No capabilities registered`)}):r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>r(Ue,{entry:e,actions:t},e.name))})}var W=[`capabilities`,`listCapabilities`];function Ke(e){return e===`singleton`||e===`collection`}function qe(e){let t=e.indexOf(`@`);return t===-1?B.t(`system.capabilities.providerHub`,{addonId:e}):`${e.slice(0,t)} (${e.slice(t+1)})`}function Je(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:qe(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function Ye(){let{t:n}=V(),i=w(),[s,c]=a(null),[u,d]=a(null),f=o({queryKey:W,queryFn:()=>i.trpcClient.capabilities.listCapabilities.query()}),p=t(()=>{let e=(f.data??[]).flatMap(e=>Ke(e.mode)?[Je(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[f.data]),m=t(()=>p.filter(e=>e.mode===`singleton`),[p]),h=t(()=>p.filter(e=>e.mode===`collection`),[p]),g=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:t.capName,addonId:t.addonId})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToSet`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),_=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToSetOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),v=l({mutationFn:e=>i.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:t.capName,nodeId:t.nodeId})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToClearOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),S=l({mutationFn:e=>i.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:t.capName,length:t.enabledAddonIds.length})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToUpdate`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),C={onSelectSingleton:(e,t)=>g.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>_.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>v.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>S.mutate({capName:e,enabledAddonIds:t}),pendingCapability:s};return e(H,{embedded:!0,icon:y,title:n(`system.capabilities.capabilities`,`Capabilities`),subtitle:n(`system.capabilities.chooseWhichProviderIsActive`,`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`),children:[u&&e(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${u.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[u.kind===`success`?r(x,{className:`h-3.5 w-3.5 shrink-0`}):r(b,{className:`h-3.5 w-3.5 shrink-0`}),r(`span`,{children:u.message})]}),f.isLoading&&r(`div`,{className:`flex items-center justify-center py-16`,children:r(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),f.isError&&!f.isLoading&&r(le,{title:n(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:f.error instanceof Error?f.error.message:n(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void f.refetch()}),!f.isLoading&&!f.isError&&p.length===0&&r(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:n(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!f.isLoading&&!f.isError&&p.length>0&&e(`div`,{className:`space-y-6`,children:[m.length>0&&e(`section`,{className:`space-y-2`,children:[r(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:n(`system.capabilities.singletonPickOneProvider`,`Singleton — pick one provider`)}),r(U,{capabilities:m,actions:C})]}),h.length>0&&e(`section`,{className:`space-y-2`,children:[r(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:n(`system.capabilities.collectionEnableASet`,`Collection — enable a set`)}),r(U,{capabilities:h,actions:C})]})]})]})}var G=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Xe={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function Ze(e){let t=Xe[e];return t===void 0?e:B.t(t)}function Qe({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:B.t(`helpers.keychainNotices.locked`,{reason:Ze(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?B.t(`helpers.keychainNotices.resetPending`,{count:n}):B.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:B.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:B.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:B.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:B.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>G.indexOf(e.id)-G.indexOf(t.id))}var $e={dateStyle:`short`,timeStyle:`short`};function K(e){return e===null?`—`:new Date(e).toLocaleString(void 0,$e)}function q({value:t,copyValue:n,srLabel:i,maxWidthClass:a,className:o}){let s=n??t;return e(`span`,{className:R(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:R(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(L,{value:s,srLabel:i,className:`h-6 shrink-0 px-1.5`})]})}s();var et=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function tt(e){return[{key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>K(e.at)},{key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>r(D,{variant:et.has(e.action)?`warning`:`default`,children:e.action})},{key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>r(`span`,{className:`font-mono`,children:e.actor})},{key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(q,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>r(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function nt({entries:n}){let{t:i}=V(),[o,s]=a(0),c=t(()=>tt(i),[i]);if(n===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:i(`common.loading`,`Loading…`)});let l=Math.max(1,Math.ceil(n.length/25)),u=Math.min(o,l-1),d=u*25,f=n.slice(d,d+25);return e(`div`,{className:`space-y-2`,children:[r(z,{columns:c,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:i(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),n.length>25&&e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:i(n.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:n.length})}),e(`span`,{className:`inline-flex items-center gap-1`,children:[r(A,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(A,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function rt(e,t){switch(e){case`locked`:return r(A,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:B.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(A,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:B.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(A,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:B.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(A,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:B.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(A,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:B.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function it(e,t){switch(e){case`locked`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:r(at,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return r(`p`,{children:r(Fe,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:r(`code`,{className:`font-mono`})}})});case`recovery-key`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function at({reset:t,pending:n}){let{t:i}=V(),a=t.actor===`trigger-file`?i(`secrets.keychainNoticeContent.resetByTrigger`):i(`secrets.keychainNoticeContent.resetByAdmin`,{actor:t.actor});return e(`div`,{className:`space-y-1.5`,children:[r(`p`,{children:i(`secrets.keychainNoticeContent.resetDetail`,{when:K(t.at),by:a,archived:t.archived})}),n.length>0&&r(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:n.map(t=>e(`li`,{className:`break-all`,children:[t.owner,` · `,t.scope,` · `,t.fieldPath]},t.ref))})]})}s();var ot=2,J={danger:{icon:oe,text:`text-danger`,border:`border-danger/40`},warning:{icon:p,text:`text-warning`,border:`border-warning/40`},info:{icon:S,text:`text-info`,border:`border-border`}};function st({notices:t,renderAction:n,renderDetail:i}){let{t:o}=V(),[s,c]=a(!1),l=t[0];if(l===void 0)return null;let u=t.length>ot,d=u&&!s?t.slice(0,1):t,f=t.length-d.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:R(`rounded-lg border bg-surface`,J[l.tone].border),children:[r(`ul`,{className:`divide-y divide-border`,children:d.map(e=>r(ct,{notice:e,action:n(e.id),detail:i(e.id)},e.id))}),u&&r(`div`,{className:`border-t border-border px-3 py-1`,children:e(A,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(re,{className:R(`h-3.5 w-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0}),s?o(`secrets.keychainNotices.showLess`,`Show less`):o(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:f})]})})]})}function ct({notice:t,action:n,detail:i}){let{t:o}=V(),[s,c]=a(!1),l=J[t.tone],u=l.icon,d=i!=null,f=`keychain-notice-${t.id}`;return e(`li`,{className:`px-3 py-2`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[e(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[r(u,{className:R(`mt-0.5 h-3.5 w-3.5 shrink-0`,l.text),"aria-hidden":!0}),r(`span`,{className:`min-w-0 break-words`,children:t.title})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[d&&r(A,{size:`sm`,variant:`ghost`,"aria-expanded":s,"aria-controls":f,onClick:()=>c(e=>!e),children:o(`secrets.keychainNotices.details`,`Details`)}),n]})]}),d&&s&&r(`div`,{id:f,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:i})]})}var lt={"config-file":`Key file (config.yaml)`,"previous-config-file":`Previous key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},ut=8;function dt({status:t,busy:n,onDownload:i,onRotate:a,onPurge:o}){let{t:s}=V(),c=t.keychain.state===`locked`,l=t.keySource??t.configuredSource;return r(pe,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:E,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(A,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(A,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(A,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${d} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[e(Y,{label:s(`secrets.keychainStatusCard.state`,`State`),children:[c?e(D,{variant:`danger`,className:`gap-1`,children:[r(ee,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.locked`,`Locked`)]}):e(D,{variant:`success`,className:`gap-1`,children:[r(te,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:s(`common.stored`,{count:t.secretCount})})]}),e(Y,{label:s(`secrets.keychainStatusCard.keySource`,`Key source`),children:[r(`span`,{className:`block`,children:lt[l.kind]}),l.path!==void 0&&r(q,{value:l.path,srLabel:`key path`})]}),r(Y,{label:s(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:t.fingerprint===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:`inline-flex items-center gap-0.5`,children:[r(`span`,{className:`font-mono`,title:t.fingerprint,children:t.fingerprint.slice(0,ut)}),r(L,{value:t.fingerprint,srLabel:`fingerprint`})]})}),r(Y,{label:s(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:t.recoveryKeyDownloadedAt===null?r(D,{variant:`warning`,children:s(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):r(`span`,{children:s(`secrets.keychainStatusCard.taken`,{when:K(t.recoveryKeyDownloadedAt)})})})]})})}function Y({label:t,children:n}){return e(`div`,{className:`min-w-0 text-xs`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:n})]})}s();var ft=1e3;function pt({revealed:t,onClose:n}){let{t:o}=V(),[s,c]=a(j);i(()=>{if(t===null)return;let e=Date.now();c(j);let r=setTimeout(n,j),i=setInterval(()=>c(Math.max(0,j-(Date.now()-e))),ft);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let l=Math.ceil(s/1e3);return r(De,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(Se,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(u,{children:[e(Oe,{children:[r(Me,{className:`break-all`,children:t.entry.fieldPath}),e(xe,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(Ee,{children:r(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:t.value})}),e(I,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`secrets.revealDialog.recorded`,{seconds:l})}),e(`div`,{className:`flex justify-end gap-2`,children:[r(L,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(A,{size:`sm`,variant:`outline`,onClick:n,children:o(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var X={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},mt=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],Z=`system`;function ht(t){let{t:n}=V(),{secrets:i,filter:a,onFilterChange:o,onDeleteOrphans:s,deleting:c,locked:l}=t;if(i===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`common.loading`,`Loading…`)});let u=e=>e===`all`?i.length:i.filter(t=>t.usage===e).length,d=i.filter(e=>e.usage===`orphan`).map(e=>e.ref),p=a===`all`?i:i.filter(e=>e.usage===a);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":n(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:mt.map(t=>e(A,{size:`sm`,variant:a===t.id?`secondary`:`ghost`,"aria-pressed":a===t.id,className:a===t.id?`ring-1 ring-border`:void 0,onClick:()=>o(t.id),children:[n(t.labelKey),r(`span`,{className:`text-foreground-subtle tabular-nums`,children:u(t.id)})]},t.id))}),d.length>0&&e(A,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(z,{columns:_t(t),rows:p,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:ge,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:i.length===0?n(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):n(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function gt({owner:t}){let{t:n}=V();return e(`span`,{className:`flex items-center gap-2`,children:[r(Be,{addonId:t,fallback:t===Z?v:h,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),r(`span`,{className:`font-medium`,children:t===Z?n(`secrets.secretsTable.hubSystem`,`Hub (system)`):t})]})}function _t({locked:t,onReveal:n,revealing:i}){return[{key:`owner`,header:B.t(`secrets.secretsTable.owner`,`Owner`),render:e=>r(gt,{owner:e.owner}),sortValue:e=>e.owner},{key:`scope`,header:B.t(`secrets.secretsTable.scope`,`Scope`),render:e=>r(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{key:`field`,header:B.t(`secrets.secretsTable.field`,`Field`),render:e=>r(q,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{key:`updated`,header:B.t(`secrets.secretsTable.updated`,`Updated`),render:e=>K(e.updatedAt),sortValue:e=>e.updatedAt},{key:`last-read`,header:B.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>K(e.lastReadAt),sortValue:e=>e.lastReadAt},{key:`status`,header:B.t(`secrets.secretsTable.status`,`Status`),render:e=>r(D,{variant:X[e.usage].variant,title:B.t(X[e.usage].hintKey),children:B.t(X[e.usage].labelKey)}),sortValue:e=>X[e.usage].rank},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:a=>e(A,{size:`sm`,variant:`ghost`,disabled:t||i,"aria-label":B.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:a.fieldPath}),title:t?B.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):B.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>n(a),children:[r(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function vt(e){return e instanceof Error?e.message:String(e)}function yt(e){let{t}=V(),n=F(),r=N(),i=fe(),a=Ne(),o=de(),s=he(),c=ce(),l=ve(),u=ke(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:vt(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:ae})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}s();var Q=`view`;function bt(){let[e,t]=Ie();return[e.get(Q)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(Q):r.set(Q,n),t(r,{replace:!0})}]}function xt(){let{t:i}=V(),o=ue({}),s=je({}),c=ye({limit:500}),l=Ae({}),u=_e(),d=N(),[f,p]=bt(),[m,h]=a(`all`),[g,_]=a(null),v=yt(()=>{o.refetch(),s.refetch(),c.refetch(),l.refetch()}),y=o.data?.keychain.state===`locked`,b=t(()=>(s.data??[]).filter(e=>e.usage===`orphan`).length,[s.data]),x=t(()=>o.data===void 0?[]:Qe({status:o.data,reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry.length??0,orphans:b}),[o.data,l.data,b]),S={reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async e=>{try{_({entry:e,value:(await u.mutateAsync({ref:e.ref})).value}),s.refetch()}catch(e){await d({title:i(`admin.system.secrets.revealRefused`,`Reveal refused`),message:Pe(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(H,{embedded:!0,icon:E,title:i(`admin.system.secrets.secrets`,`Secrets`),subtitle:i(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[r(st,{notices:x,renderAction:e=>rt(e,S),renderDetail:e=>it(e,S)}),o.data!==void 0&&r(dt,{status:o.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),e(se,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(k,{children:[r(M,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(M,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(P,{value:`values`,children:r(ht,{secrets:s.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:u.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),r(P,{value:`audit`,children:r(nt,{entries:c.data})})]}),r(pt,{revealed:g,onClose:w})]})}s();var St=[[`system`]];function $(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function Ct(){let{t}=V(),n=c(),o=be(),s=Ce(),l=we(),[u,d]=a(``),[f,p]=a(``),[m,h]=a(null),g=o.data?.location??null;i(()=>{d(g===null?``:$(g.latitude)),p(g===null?``:$(g.longitude))},[g]);let v=async()=>{await n.invalidateQueries({queryKey:St})},y=async e=>{e.preventDefault();let t=Number(u),n=Number(f);if(u.trim()===``||f.trim()===``){h(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){h(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){h(`Longitude must be between -180 and 180 decimal degrees.`);return}h(null),await s.mutateAsync({latitude:t,longitude:n}),await v()},b=async()=>{h(null),await s.mutateAsync(null),await v()},x=async()=>{h(null),await l.mutateAsync(),await v()},S=s.isPending||l.isPending||o.isLoading;return e(me,{className:`space-y-3`,children:[e(`div`,{className:`flex items-start justify-between gap-3`,children:[e(`div`,{className:`flex items-start gap-2`,children:[r(ne,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),r(`div`,{children:r(`h3`,{className:`text-sm font-medium`,children:t(`settings.siteLocationCard.siteLocation`,`Site location`)})})]}),g===null?r(D,{variant:`warning`,children:t(`settings.siteLocationCard.notConfigured`,`Not configured`)}):r(D,{variant:g.source===`operator-set`?`success`:`info`,children:g.source===`operator-set`?t(`settings.siteLocationCard.setByYou`,`Set by you`):t(`settings.siteLocationCard.derivedFromIp`,`Derived from IP`)})]}),g?.label!==void 0&&g.label!==``?r(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.detectedNear`,{place:g.label})}):null,g===null&&o.data?.derivationAttemptedAt!==null?e(`p`,{className:`text-xs text-warning`,children:[t(`settings.siteLocationCard.automaticDetectionFromThePublic`,`Automatic detection from the public IP did not succeed`),o.data?.derivationError!==null&&o.data?.derivationError!==void 0?`: ${o.data.derivationError}`:`.`,` `,t(`settings.siteLocationCard.itIsNotRetriedOn`,`It is not retried on its own — enter the coordinates, or press Detect.`)]}):null,e(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:y,children:[e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[r(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.latitude`,`Latitude`)}),r(O,{className:`w-40`,value:u,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>d(e.target.value),"aria-label":t(`settings.siteLocationCard.latitude`,`Latitude`)})]}),e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[r(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.longitude`,`Longitude`)}),r(O,{className:`w-40`,value:f,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>p(e.target.value),"aria-label":t(`settings.siteLocationCard.longitude`,`Longitude`)})]}),r(A,{type:`submit`,disabled:S,children:t(`common.save`,`Save`)}),e(A,{type:`button`,variant:`ghost`,disabled:S,onClick:x,children:[r(_,{className:`h-3.5 w-3.5 mr-1`}),t(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),g===null?null:r(A,{type:`button`,variant:`ghost`,disabled:S,onClick:b,children:t(`settings.siteLocationCard.clear`,`Clear`)})]}),m===null?null:r(`p`,{className:`text-xs text-danger`,children:m}),r(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.wgs84DecimalDegreesDetectAsks`,`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`)})]})}function wt(){let{t}=V(),{nodes:n,isLoading:i}=Te(),a=n.find(e=>e.isHub&&e.isOnline),o=a?.addons.map(e=>e.addonId)??[];return e(H,{embedded:!0,children:[r(Ct,{}),i?r(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:t(`admin.system.settings.loadingHubTopology`,`Loading hub topology…`)}):a?o.length===0?r(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:t(`admin.system.settings.noAddonsInstalledOnThe`,`No addons installed on the hub yet.`)}):r(ze,{nodeId:a.id,addonIds:o,level:`global`}):e(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12`,children:[r(T,{className:`h-8 w-8 opacity-30`}),r(`p`,{children:t(`admin.system.settings.noOnlineHubNodeFound`,`No online hub node found.`)}),r(`p`,{className:`text-xs`,children:t(`admin.system.settings.settingsWillAppearOnceThe`,`Settings will appear once the hub is reachable.`)})]})]})}function Tt(){let{t:e}=V(),t=Le(`/system/settings`,{t:e,isAdmin:!0})??{icon:T,title:e(`system.systemNav`,`System`)};return r(Re,{icon:t.icon,title:t.title,defaultSection:`settings`,sectionsLabel:`${t.title} sections`,sections:[{id:`settings`,label:e(`system.system.settings`,`Settings`),content:r(wt,{})},{id:`secrets`,label:e(`system.system.secrets`,`Secrets`),content:r(xt,{}),ownedParams:[`view`]},{id:`capabilities`,label:e(`system.system.capabilities`,`Capabilities`),content:r(Ye,{})}]})}export{Tt as SystemPage};
|