@camstack/addon-admin-ui 1.2.153 → 1.2.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AddLocationWizard-BfxhNm72.js +1 -0
- package/dist/assets/AddonCollectionPage-CW6du21q.js +1 -0
- package/dist/assets/Addons-BCE446N3.js +1 -0
- package/dist/assets/{AdminTabs-CpTKjy3v.js → AdminTabs-1yjfu33C.js} +1 -1
- package/dist/assets/AiProfiles-DbZ88iAM.js +3 -0
- package/dist/assets/{BrokerForm-ClNFIGW2.js → BrokerForm-DseGi1Ub.js} +1 -1
- package/dist/assets/{Build-Dla0OrwG.js → Build-DNAKikEi.js} +1 -1
- package/dist/assets/Capabilities-BOxOXZqi.js +1 -0
- package/dist/assets/{CapabilityBadges-CBc1Ca4t.js → CapabilityBadges-BG9r_kWm.js} +1 -1
- package/dist/assets/{Cluster-C_dTsHIY.js → Cluster-JIhlt3tf.js} +1 -1
- package/dist/assets/Data-BlydjDLl.js +1 -0
- package/dist/assets/DetectionIntelligence-BTC_Eh-Y.js +1 -0
- package/dist/assets/{DeviceAggregateSection-r-vVpuVq.js → DeviceAggregateSection-BeCY5AWo.js} +1 -1
- package/dist/assets/DeviceDetail-C_9n4Eke.js +2 -0
- package/dist/assets/Devices-DAkxHV_f.js +1 -0
- package/dist/assets/EmbedPlayerPage-vHHjh6s1.js +1 -0
- package/dist/assets/Events-DEvn98Qt.js +1 -0
- package/dist/assets/{FormBuilder-KnE-MHOY.js → FormBuilder-BIvQTEvk.js} +1 -1
- package/dist/assets/Identity-CnNL9mtn.js +1 -0
- package/dist/assets/IntegrationDetail-Sp_S_ZZ6.js +1 -0
- package/dist/assets/Integrations-Dn6FCyD1.js +1 -0
- package/dist/assets/{Integrations-YJYVfqN6.js → Integrations-edIshugj.js} +1 -1
- package/dist/assets/{Locations-nmHSshK6.js → Locations-B4Ki08Fr.js} +1 -1
- package/dist/assets/{Logs-DsBOOcf1.js → Logs-C1mu_oqz.js} +1 -1
- package/dist/assets/MotionZonesSettings-C5bKo6VP.js +1 -0
- package/dist/assets/MyAccess-rsk_o68D.js +2 -0
- package/dist/assets/Network-BfXTfXpg.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-yJ1M4XXy.js +1 -0
- package/dist/assets/{NodeInferenceDevices-kXy3hl6a.js → NodeInferenceDevices-Cbms_ewQ.js} +1 -1
- package/dist/assets/Notifications-CYUWmHtc.js +1 -0
- package/dist/assets/Pipeline-D5RoCUYQ.js +1 -0
- package/dist/assets/{Plates-XWUvNHoY.js → Plates-C31WrsPP.js} +1 -1
- package/dist/assets/PrivacyMaskSettings-BgFR-8_v.js +1 -0
- package/dist/assets/ProviderIcon-BdOOt6NS.js +1 -0
- package/dist/assets/Recordings-BLxcb-u8.js +1 -0
- package/dist/assets/ScanNetworkModal-CVf4XBhJ.js +1 -0
- package/dist/assets/SceneMonitorEditor-DlDLUHNS.js +1 -0
- package/dist/assets/{Scenes-D_2WuJmD.js → Scenes-Dn1PHCKZ.js} +1 -1
- package/dist/assets/{Settings-CRM_OepW.js → Settings-DtX2H7WE.js} +1 -1
- package/dist/assets/{Showroom-D4PTTERP.js → Showroom-BTCAPgIc.js} +1 -1
- package/dist/assets/{StorageLocationsPanel-DnZ-Tb-M.js → StorageLocationsPanel-DjN1rF67.js} +1 -1
- package/dist/assets/{Terminal-BCcYOV7X.js → Terminal-Wrtj19tl.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-H4A6egtU.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DGyZ1yvA.js} +1 -1
- package/dist/assets/authed-media-B2oVDhFm.js +1 -0
- package/dist/assets/{bell-off-_uCfwsq_.js → bell-off-ThMBRHmm.js} +1 -1
- package/dist/assets/{bell-ring-M-bbfQBU.js → bell-ring-u3bfQpNj.js} +1 -1
- package/dist/assets/{boxes-DD7B6vWr.js → boxes-hhzzspMj.js} +1 -1
- package/dist/assets/circle-check-big-PD2necrU.js +1 -0
- package/dist/assets/circle-dot-CfQwdzX_.js +1 -0
- package/dist/assets/circle-slash-DCYqlMaI.js +1 -0
- package/dist/assets/{circle-x-CsGhZWZ1.js → circle-x-BSCCj6XY.js} +1 -1
- package/dist/assets/clock-FKrzO9GG.js +1 -0
- package/dist/assets/{copy-BIhozMgo.js → copy-D6KkwfwO.js} +1 -1
- package/dist/assets/{debounced-invalidate-DGDmoLua.js → debounced-invalidate-dP8VFj-6.js} +1 -1
- package/dist/assets/dist--wTVCxDD.js +349 -0
- package/dist/assets/{dist-BBNkFRmf.js → dist-CMs2hAK8.js} +1 -1
- package/dist/assets/{download-BDzIO8OY.js → download-CLiKKUeT.js} +1 -1
- package/dist/assets/{face-bbox-CGA0mg9Y.js → face-bbox-DhlMbqaG.js} +1 -1
- package/dist/assets/{flame-BYOYZC1n.js → flame-BsG4Dybp.js} +1 -1
- package/dist/assets/{hard-drive-90CWkv-h.js → hard-drive-C4AIQBj2.js} +1 -1
- package/dist/assets/{hard-drive-download-Om-EHrji.js → hard-drive-download-CF0kY-Oh.js} +1 -1
- package/dist/assets/hostInit-DBL0LSae.js +1 -0
- package/dist/assets/index-BhOTpumf.js +4 -0
- package/dist/assets/{key-round-DCbMTVqq.js → key-round-e_hEDPKI.js} +1 -1
- package/dist/assets/{layers-CyQMm87X.js → layers-Bt9-2SKv.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-b5a58a12.js → mf-entry-bootstrap-0-8e6b60bd.js} +2 -2
- package/dist/assets/{pencil-QF3La2Sl.js → pencil-B6y0Oh2c.js} +1 -1
- package/dist/assets/play-BzhcoUnI.js +1 -0
- package/dist/assets/player-overlays-O631SNei.js +1 -0
- package/dist/assets/plus-CXFJeQjl.js +1 -0
- package/dist/assets/power-Hyd0gaaN.js +1 -0
- package/dist/assets/{radio-Dx7yXPbe.js → radio-BSady5VM.js} +1 -1
- package/dist/assets/{refresh-cw-C39zORZV.js → refresh-cw-CeOt1Ggs.js} +1 -1
- package/dist/assets/remoteEntry-DbJlNVkx.js +1 -0
- package/dist/assets/rotate-ccw-DUz61akn.js +1 -0
- package/dist/assets/rotate-cw-CRmmE-UE.js +1 -0
- package/dist/assets/{send-CVOYFzeZ.js → send-BJ2kJEsy.js} +1 -1
- package/dist/assets/{server-DQLgZ7bE.js → server-CTk4i3JI.js} +1 -1
- package/dist/assets/{shield-AayD-Dai.js → shield-ByGdqNqR.js} +1 -1
- package/dist/assets/{shield-alert-B9Y8lmS2.js → shield-alert-BhpAYEmO.js} +1 -1
- package/dist/assets/square-B82yoL5W.js +1 -0
- package/dist/assets/{square-check-big-CL2u5bS3.js → square-check-big-C46Bqq3N.js} +1 -1
- package/dist/assets/src-BUg1AeOd.js +349 -0
- package/dist/assets/src-CScffhwR.js +67 -0
- package/dist/assets/{undo-2-B_3P5GNw.js → undo-2-FvLHiGAn.js} +1 -1
- package/dist/assets/use-scenes-feed-D2o2bYVo.js +1 -0
- package/dist/assets/useEventInvalidation-1GDWOejJ.js +1 -0
- package/dist/assets/{useNodeUrlSelection-S-4TmE9o.js → useNodeUrlSelection-CXYW7Br7.js} +1 -1
- package/dist/assets/user-round-XIXxEj4E.js +1 -0
- package/dist/assets/{video-BeD7NTRZ.js → video-DSsRyUk3.js} +1 -1
- package/dist/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BuvoQQIr.js +5 -0
- package/dist/assets/vite-preload-helper-kNaey6uv.js +1 -0
- package/dist/assets/{wifi-BgJhCz5w.js → wifi-ekk-6n_W.js} +1 -1
- package/dist/assets/{zap-D7GDVAk6.js → zap-x6R--oqr.js} +1 -1
- package/dist/index.html +10 -10
- package/dist/manifest.webmanifest +4 -4
- package/dist/server/addon.js +88 -2
- package/package.json +1 -1
- package/dist/assets/AddLocationWizard-POU-h4lC.js +0 -1
- package/dist/assets/AddonCollectionPage-_c7aqfTY.js +0 -1
- package/dist/assets/Addons-B1JQF4gb.js +0 -1
- package/dist/assets/AiProfiles-DZ9Ow0HR.js +0 -3
- package/dist/assets/Capabilities-M7k-RZWl.js +0 -1
- package/dist/assets/Data-DrADfMZC.js +0 -1
- package/dist/assets/DetectionIntelligence-QnPJgItV.js +0 -1
- package/dist/assets/DeviceDetail-CodUJS1P.js +0 -2
- package/dist/assets/Devices-BXh61CPy.js +0 -1
- package/dist/assets/EmbedPlayerPage-BcO3cVi5.js +0 -1
- package/dist/assets/Events-jBSvPW0i.js +0 -1
- package/dist/assets/Identity-BfukWwzn.js +0 -1
- package/dist/assets/IntegrationDetail-DKYyTNAX.js +0 -1
- package/dist/assets/Integrations-BDtG7b0i.js +0 -1
- package/dist/assets/MotionZonesSettings-D2UavUBf.js +0 -1
- package/dist/assets/MyAccess-lt7fhuDE.js +0 -2
- package/dist/assets/Network-DL8OmVoI.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-BGiMbeFK.js +0 -1
- package/dist/assets/Notifications-DIk8CGG-.js +0 -1
- package/dist/assets/Pipeline-CVyZTH5E.js +0 -1
- package/dist/assets/PrivacyMaskSettings-GBuB9bMT.js +0 -1
- package/dist/assets/ProviderIcon-CNI4drnz.js +0 -1
- package/dist/assets/Recordings-D50YdeX2.js +0 -1
- package/dist/assets/ScanNetworkModal-DSQYVB5-.js +0 -1
- package/dist/assets/SceneMonitorEditor-CliKadd2.js +0 -1
- package/dist/assets/authed-media-BPd_L9jr.js +0 -1
- package/dist/assets/circle-check-big-JbEuda-K.js +0 -1
- package/dist/assets/circle-dot-BiSKsHqx.js +0 -1
- package/dist/assets/circle-slash-BFJ5arnl.js +0 -1
- package/dist/assets/clock-CP-wdltQ.js +0 -1
- package/dist/assets/dist-S_GbEBCn.js +0 -349
- package/dist/assets/hostInit-ArnQd5Ro.js +0 -1
- package/dist/assets/index-DpyYghK5.js +0 -4
- package/dist/assets/play-D8PRXtJj.js +0 -1
- package/dist/assets/player-overlays-C7P-BYK6.js +0 -1
- package/dist/assets/plus-DCgFS8Qr.js +0 -1
- package/dist/assets/power-CLys8a7n.js +0 -1
- package/dist/assets/remoteEntry-CUCr4zXw.js +0 -1
- package/dist/assets/rotate-ccw-D64HdccI.js +0 -1
- package/dist/assets/rotate-cw-CLXt3-FP.js +0 -1
- package/dist/assets/square-CTn6q5rG.js +0 -1
- package/dist/assets/src-D4J0MlT1.js +0 -67
- package/dist/assets/src-DVkz1MkU.js +0 -349
- package/dist/assets/use-scenes-feed-CtEQ_eXD.js +0 -1
- package/dist/assets/useEventInvalidation-DmM7qYZh.js +0 -1
- package/dist/assets/user-round-CqtpH11x.js +0 -1
- package/dist/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BzqZKccv.js +0 -5
- package/dist/assets/vite-preload-helper-zJ_50EbN.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Q as l}from"./player-overlays-C7P-BYK6.js";import{Er as u,Jr as d,Lr as f,Oi as p,T as m,Ti as h,gn as g,ji as _,r as v,w as y,yn as ee}from"./src-D4J0MlT1.js";import{t as b}from"./ProviderIcon-CNI4drnz.js";import{t as x}from"./plus-DCgFS8Qr.js";import{i as te,n as ne,r as re,t as S}from"./ScanNetworkModal-DSQYVB5-.js";import{t as C}from"./refresh-cw-C39zORZV.js";import{B as w,H as T,L as E,Q as D,X as O,f as k,r as ie,t as A,v as j,w as M,z as ae}from"./index-DpyYghK5.js";import{t as oe}from"./AdminPage-CCD07UMs.js";import"./useEventInvalidation-DmM7qYZh.js";import{t as N}from"./StatusBadge-CeptlsPG.js";import{t as P}from"./useBodyScrollLock-BDocajQE.js";t();function F(e,t){let[n,r]=o(!1);return c(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}t();function I({providerId:e,onImport:t,onSkip:r}){let{t:i}=A(),[a,l]=o(new Set),u=f(),d=u.data,p=u.isPending||!u.data&&!u.isError;c(()=>{e&&(u.isPending||u.data||u.mutate({addonId:e}))},[e,u]);function m(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(p)return n(`div`,{className:`flex flex-col items-center py-12`,children:[s(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:i(`integrations.searchingDevices`)})]});let h=d??[];return n(`div`,{className:`space-y-4`,children:[s(`p`,{className:`text-xs text-foreground-subtle`,children:h.length>0?i(`integrations.foundDevices`,{count:h.length}):i(`integrations.noDevicesFound`)}),h.length>0&&s(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:h.map(e=>{let t=e.stableId,r=e.suggestedName??t,o=a.has(t),c=e.alreadyOnboarded===!0;return n(`button`,{onClick:()=>{c||m(t)},disabled:c,title:c?i(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${c?`border-border bg-surface opacity-60 cursor-not-allowed`:o?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[s(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${o&&!c?`border-primary bg-primary`:`border-border`}`,children:o&&!c&&s(w,{className:`h-3 w-3 text-primary-foreground`})}),s(T,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),s(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),c&&s(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:i(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),n(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.skip`)}),h.length>0&&n(`button`,{onClick:()=>t(Array.from(a)),disabled:a.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[i(`integrations.importSelected`),` (`,a.size,`)`]})]})]})}function L({onSelect:e,onClose:t,pendingAddonId:r=null}){let{t:i}=A(),a=O(),{data:o,isLoading:c}=p();if(c)return s(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-14 rounded-lg bg-surface animate-pulse`},e))});let l=r!==null;return n(`div`,{className:`space-y-2`,children:[(o??[]).map(o=>{let c=o.instanceMode===`unique`&&o.existingInstances.length>0,u=r===o.addonId,d=l;return n(`button`,{disabled:d,onClick:()=>{if(!d)if(c){let e=o.existingInstances[0].id;t(),a(`/integrations/${e}`)}else e(o.addonId,o.instanceMode,o.discoveryMode,o.name,o.kind,o.brokerKind,o.mode,o.canTest)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[o.iconUrl?s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`img`,{src:o.iconUrl,alt:``,className:`h-5 w-5`})}):s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`span`,{className:`text-sm`,style:{color:o.color},children:`◉`})}),n(`div`,{className:`flex-1 min-w-0`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:o.name}),o.description&&s(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,children:o.description})]}),u?s(M,{className:`h-4 w-4 animate-spin text-primary flex-shrink-0`}):c?n(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[s(k,{className:`h-3 w-3`}),i(`integrations.manage`)]}):s(E,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},o.addonId)}),(o??[]).length===0&&s(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:i(`integrations.noProviders`)})]})}t();function se(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var R=2e4;function ce({open:e,onClose:t}){let{t:l}=A(),d=O(),p=a(),[m,g]=o(`picker`),[_,v]=o(null),[y,b]=o(null),[x,te]=o(`manual`),[S,C]=o(null),[w,T]=o(``),[E,D]=o(null),[k,j]=o(null),[ae,oe]=o(!1),{data:N}=ee({addonId:_??``,nodeId:`hub`},{enabled:_!=null}),ce=r(()=>N?se(N):null,[N]),z=h({onSuccess:()=>p.invalidateQueries({queryKey:[[`integrations`]]})}),B=f(),le=B.data;c(()=>{m!==`discovery`||!y||!_||B.isPending||B.data||B.mutate({addonId:_})},[m,y,_,B]);let V=u({onSuccess:()=>p.invalidateQueries({queryKey:[[`deviceManager`]]})});function H(e,t,n,r,i,a,o,s){if(!z.isPending){if(v(e),oe(s),te(n),T(r),j(null),o===`broker`){if(!a){j(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),g(`broker`);return}if(o===`account`){g(`config`);return}U(e,r)}}async function U(e,n){try{let r=await z.mutateAsync({addonId:e,name:n,settings:{}});t(),q(),d(`/integrations/${r.id}?add=1`)}catch{}}async function W(e){if(_)try{let t=await z.mutateAsync({addonId:_,name:e.name,settings:e.config});b(t.id),x===`auto`||x===`both`?g(`discovery`):K(t.id)}catch{}}async function G(e){if(_)try{let t=await z.mutateAsync({addonId:_,name:w,settings:{brokerId:e}});D(t.id),b(t.id),K(t.id)}catch{}}async function ue(e){if(_){for(let t of e){let e=le?.find(e=>e.stableId===t);e&&await V.mutateAsync({addonId:_,candidate:e,...E===null?{}:{integrationId:E}})}K()}}function K(e){let n=e??y??_;t(),q(),n&&d(`/integrations/${n}`)}function q(){g(`picker`),v(null),b(null),te(`manual`),C(null),T(``),D(null),j(null),oe(!1)}function J(){t(),q()}P(e);let Y=z.isPending,X=F(Y,R);if(!e)return null;let Z={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=Y?_:null,$=z.error,de=Y&&!X;return n(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:J}),n(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:Z[m]}),s(`button`,{onClick:J,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:s(ie,{className:`h-4 w-4`})})]}),n(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!Y&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),m===`picker`&&n(i,{children:[k&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:k}),s(L,{onSelect:H,onClose:J,pendingAddonId:Q})]}),m===`config`&&_&&s(ne,{addonId:_,configSchema:ce??null,canTest:ae,onSave:W,onBack:()=>g(`picker`)}),m===`broker`&&S&&s(re,{kind:S,onResolved:e=>{G(e)},onBack:()=>g(`picker`)}),m===`discovery`&&y&&s(I,{providerId:y,onImport:ue,onSkip:K})]}),Y&&n(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[s(M,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!X&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),X&&n(i,{children:[s(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),s(`button`,{onClick:J,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function z({integration:e,expanded:t,onToggleExpand:r}){return n(`div`,{className:`flex items-center gap-2.5`,children:[s(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:s(t?ae:E,{className:`h-3.5 w-3.5`})}),s(b,{type:e.addonId,size:`sm`}),n(`div`,{className:`flex min-w-0 flex-col`,children:[s(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function B(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>s(z,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>s(N,{status:e.status})}]}t();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var V=`expand`;function H(){let{t}=A(),a=O(),c=l(),[u]=D(),[f,p]=o(!1),h=e(()=>p(!0),[]),ee=e(()=>p(!1),[]),[ne,re]=o(!1),w=e(()=>re(!0),[]),T=e(()=>re(!1),[]);v([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),v([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:E,isLoading:k,refetch:ie}=_(void 0),{data:M,isLoading:ae,refetch:N}=d({projection:`slim`}),P=r(()=>M??[],[M]),F=r(()=>E??[],[E]),I=r(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),L=r(()=>{let e=new Map;for(let t of m(P)){let n=t.addonId??``;n&&e.set(n,(e.get(n)??0)+1)}return e},[P]),se=r(()=>F.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:L.get(e.addonId)??0})),[F,L]),R=u.get(V),z=e(e=>{let t=new URLSearchParams(window.location.search);t.get(V)===e?t.delete(V):t.set(V,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),H=e(e=>a(`/integrations/${e.id}`),[a]),U=e(e=>I.get(e)??null,[I]),W=e(e=>s(b,{type:e,size:`sm`}),[]),G=e(e=>a(`/devices/${String(e)}`),[a]),ue=e(e=>s(y,{context:`integration-detail`,devices:P,trpc:c.trpcClient,forceAddon:e.addonId,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:W,resolveParent:U,onNavigate:G}),[P,c.trpcClient,W,U,G]),K=e(e=>R===e.addonId,[R]),q=r(()=>B({isExpanded:K,onToggleExpand:z}),[K,z]),J=e(e=>`${e.name} ${e.addonId}`,[]),Y=e(e=>e.addonId,[]),X=e(()=>{ie(),N()},[ie,N]),Z=k||ae,Q=F.length>0;return n(oe,{icon:j,title:t(`nav.integrations`,`Integrations`),actions:n(i,{children:[s(`button`,{onClick:X,disabled:Z,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:`Refresh`,children:s(C,{className:g(`h-3.5 w-3.5`,Z&&`animate-spin`)})}),n(`button`,{onClick:w,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:`Scan the local network for devices`,children:[s(te,{className:`h-3.5 w-3.5`}),`Scan network`]}),n(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[s(x,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Z&&s(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&n(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[s(`p`,{className:`text-sm`,children:`No integrations configured.`}),s(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Z&&Q&&s(y,{mode:`generic`,items:se,getKey:Y,getSearchText:J,columns:q,onRowClick:H,isExpanded:K,renderExpanded:ue,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),s(ce,{open:f,onClose:ee}),s(S,{open:ne,onClose:T})]})}export{H as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{G as l,M as u,Q as ee,W as d,Y as f,lt as p,n as m}from"./player-overlays-C7P-BYK6.js";import{MaskShapeCanvas as h}from"./MaskShapeCanvas-Dcpby34M.js";var te=p(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]);n();var ne=110,g=`motion-zones`,_=0,re=[1,2,3],v=1,y=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,b=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function x(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:n}){let p=l(ee().trpcClient,n),[w,D]=o(null),[O,k]=o(!1),[A,j]=o(null),[M,N]=o(null),[P,F]=o(v),[I,L]=o(!1),[R,z]=o(!1),B=t(!1);c(()=>{if(!p)return;let e=!1;return B.current=!1,D(null),k(!1),j(null),N(null),F(v),z(!1),(async()=>{try{let t=await p.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(D(t),B.current)return;let n=await p.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);B.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);N(i),j(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;d(t)?k(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[p]);let V=w?w.grid.width:0,H=w?w.grid.height:0,U=C(V,P),W=C(H,P),G=i(()=>A&&w?E(A,V,H,P):null,[A,w,V,H,P]),K=i(()=>G!==null&&M!==null&&!S(G,M),[G,M]),q=i(()=>G?G.reduce((e,t)=>t?e+1:e,0):0,[G]),J=V*H,Y=U*W,X=e(e=>{Y>0&&j(Array.from({length:Y},()=>e))},[Y]),Z=e(()=>{j(e=>e&&e.map(e=>!e))},[]),ie=e(()=>{M&&w&&j(T(M,V,H,P))},[M,w,V,H,P]),ae=e(e=>{e===P||!w||j(t=>{if(!t)return F(e),t;let n=T(E(t,V,H,P),V,H,e);return F(e),n})},[P,w,V,H]),Q=i(()=>w&&A?[{id:_,shape:{kind:`grid`,gridWidth:U,gridHeight:W,cells:[...A]}}]:[],[w,A,U,W]),$=e((e,t)=>{t.kind===`grid`&&j(t.cells)},[]),oe=e(async()=>{if(!(!p||!A||!w)){L(!0);try{let e=E(A,w.grid.width,w.grid.height,P),t={kind:`grid`,gridWidth:w.grid.width,gridHeight:w.grid.height,cells:e};await p.motionZones?.setZone({patch:{regions:[{id:_,enabled:!0,shape:t}]}});let n=await p.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],w.grid.width,w.grid.height);N(t),j(T(t,w.grid.width,w.grid.height,P))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{L(!1)}}},[p,A,w,P]);return m(i(()=>R&&!O&&w&&A?{id:g,order:ne,node:s(h,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:U,height:W},selectedId:_,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[R,O,w,A,Q,$,U,W])),p?s(f,{title:`Motion Zones`,icon:s(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:s(`div`,{className:`flex flex-col gap-3`,children:O?s(`p`,{className:`${u} leading-relaxed`,children:`This camera doesn't expose an on-board motion zones grid.`}):!O&&w!==null&&A!==null?r(a,{children:[r(`p`,{className:`${u} leading-relaxed`,children:[`Toggle `,s(`strong`,{className:`text-foreground`,children:`Edit grid`}),` to paint the region directly on the live frame, then `,s(`strong`,{className:`text-foreground`,children:`Save`}),` to push the mask to the camera. Pick a bigger`,` `,s(`strong`,{className:`text-foreground`,children:`Cell size`}),` for quicker, broad-stroke painting — it's resampled to the camera's native `,w.grid.width,`×`,w.grid.height,` grid on save (×1 is the finest).`]}),r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`button`,{type:`button`,onClick:()=>z(e=>!e),disabled:I,"aria-pressed":R,className:R?b:y,children:R?`Done editing`:`Edit grid`}),s(`button`,{type:`button`,onClick:()=>X(!0),disabled:I,className:y,children:`All on`}),s(`button`,{type:`button`,onClick:()=>X(!1),disabled:I,className:y,children:`All off`}),s(`button`,{type:`button`,onClick:Z,disabled:I,className:y,children:`Invert`}),r(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":`Cell size`,children:[s(`span`,{className:`${u} mr-0.5`,children:`Cell size`}),re.map(e=>r(`button`,{type:`button`,onClick:()=>ae(e),disabled:I,"aria-pressed":P===e,title:e===1?`Camera grid ${V}×${H} (finest)`:`${C(V,e)}×${C(H,e)} painting grid · cells ×${e} bigger`,className:P===e?b:y,children:[`×`,e]},e))]}),r(`span`,{className:`${u} ml-1 tabular-nums`,children:[q,` / `,J,` cells · `,w.grid.width,`×`,w.grid.height,P===1?``:` · paint ${U}×${W}`]}),s(`span`,{className:`flex-1`}),s(`button`,{type:`button`,onClick:ie,disabled:I||!K,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),s(`button`,{type:`button`,onClick:()=>void oe(),disabled:I||!K,className:b,children:I?`Saving…`:`Save`})]})]}):s(`p`,{className:`${u} leading-relaxed`,children:`Loading the camera's grid…`})})}):null}export{D as MotionZonesSettings};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-BHo8W_uH.js","assets/rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-zJ_50EbN.js";import{Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Q as d}from"./player-overlays-C7P-BYK6.js";import{S as f,qt as p,tn as m}from"./src-D4J0MlT1.js";import{t as h}from"./circle-check-big-JbEuda-K.js";import{t as g}from"./copy-BIhozMgo.js";import{t as _}from"./key-round-DCbMTVqq.js";import{t as v}from"./pencil-QF3La2Sl.js";import{A as y,C as b,I as x,S,T as C,l as w,n as T,o as E,w as D}from"./index-DpyYghK5.js";import{t as O}from"./AdminPage-CCD07UMs.js";n();function k({value:n,size:i=192}){let[a,o]=s(null),[c,d]=s(null);if(u(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){d(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||o(e)}catch(e){r||d(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1])).catch(()=>{r||d(`qrcode library not installed`)}),()=>{r=!0}},[n]),c)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:`QR rendering unavailable — use the secret below.`});if(!a)return l(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:`Generating…`});let f=a.modules.size,p=i/f,m=[];for(let e=0;e<f;e++)for(let t=0;t<f;t++)a.modules.data[e*f+t]&&m.push(l(`rect`,{x:t*p,y:e*p,width:p,height:p,fill:`currentColor`},`${t}-${e}`));return r(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[l(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),m]})}n();var A={view:{icon:y,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:v,cls:`bg-primary/15 text-primary`},delete:{icon:E,cls:`bg-danger/15 text-danger`}};function j(){let{user:e,logout:t}=T();if(!e)return l(O,{children:l(`div`,{className:`text-xs text-foreground-subtle`,children:`Not signed in.`})});let n=e.isAdmin,i=e.scopes??[];return r(O,{children:[r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[l(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),r(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?`Administrator`:`User`,` · session id`,` `,r(`span`,{className:`font-mono`,children:[e.id.slice(0,8),`…`]})]})]})]}),n&&r(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[l(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),r(`div`,{children:[l(`div`,{className:`font-semibold text-foreground`,children:`Unrestricted access`}),l(`p`,{className:`text-foreground-subtle mt-0.5`,children:`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`})]})]}),l(M,{}),l(P,{username:e.username}),l(F,{}),i.length>0&&r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2 border-b border-border`,children:[l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Granted scopes`}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Baked into your session token at login; sign out + back in to refresh after changes.`})]}),r(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[l(`div`,{children:`Type`}),l(`div`,{children:`Target`}),l(`div`,{children:`Access`})]}),l(`ul`,{className:`divide-y divide-border`,children:i.map((e,t)=>r(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[l(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),l(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?f(e.selector):e.target}),l(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let n=e.access.includes(t),{icon:i,cls:a}=A[t];return r(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:n?`Can ${t}`:`Cannot ${t}`,children:[l(i,{className:`h-3 w-3`}),t]},t)})})]},t))})]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:t,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[l(S,{className:`h-3 w-3`}),`Sign out`]})})]})}function M(){let e=d(),[t,n]=s(``),[i,a]=s(``),[o,u]=s(``),[f,p]=s(null),m=c({mutationFn:t=>e.changeOwnPassword(t),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),n(``),a(``),u(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=i.length>0&&o.length>0&&i!==o,v=i.length>0&&i.length<8,y=t.length>=1&&i.length>=8&&i===o;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Change password`})]}),r(`div`,{className:`p-4 space-y-3`,children:[l(N,{label:`Current password`,value:t,onChange:n,autoComplete:`current-password`}),l(N,{label:`New password`,value:i,onChange:a,autoComplete:`new-password`,hint:`At least 8 characters.`}),l(N,{label:`Confirm new password`,value:o,onChange:u,autoComplete:`new-password`}),(g||v)&&l(`div`,{className:`text-[11px] text-danger`,children:g?`Passwords do not match.`:`New password must be at least 8 characters.`}),f&&r(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[f.kind===`success`?l(h,{className:`h-3 w-3`}):l(x,{className:`h-3 w-3`}),f.msg]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{p(null),m.mutate({currentPassword:t,newPassword:i})},disabled:!y||m.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[m.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(b,{className:`h-3 w-3`}),`Update password`]})})]})]})}function N({label:e,value:t,onChange:n,autoComplete:i,hint:a}){return r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),l(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:i,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`}),a&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:a})]})}function P({username:e}){let t=d(),n=a({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>t.getOwnTotpStatus()}),f=n.data,[p,m]=s(null),[_,v]=s(``),[y,b]=s(null),[S,C]=s(!1),T=c({mutationFn:()=>t.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),v(``),b(null)},onError:e=>b(e instanceof Error?e.message:`Setup failed`)}),E=c({mutationFn:e=>t.confirmOwnTotp(e),onSuccess:()=>{m(null),v(``),b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=c({mutationFn:()=>t.disableOwnTotp(),onSuccess:()=>{b(null),n.refetch()},onError:e=>b(e instanceof Error?e.message:`Disable failed`)});u(()=>{if(!S)return;let e=setTimeout(()=>C(!1),1500);return()=>clearTimeout(e)},[S]);let A=i(()=>n.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[n.isLoading,f?.enabled,p]);return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[l(w,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`div`,{className:`text-xs font-semibold text-foreground`,children:`Two-factor authentication`})]}),r(`div`,{className:`p-4 space-y-3`,children:[A===`loading`&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[l(D,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),A===`not_enrolled`&&r(o,{children:[l(`div`,{className:`text-xs text-foreground-subtle`,children:`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{b(null),T.mutate()},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[T.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(w,{className:`h-3 w-3`}),`Enable 2FA`]})})]}),A===`setup_in_progress`&&p&&r(o,{children:[r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`Scan the QR code (or enter the secret manually) into your authenticator app for`,` `,l(`span`,{className:`font-mono`,children:e}),`, then enter the 6-digit code below to confirm.`]}),r(`div`,{className:`flex flex-col items-center gap-3`,children:[l(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:l(k,{value:p.otpauthUrl,size:180})}),r(`div`,{className:`w-full`,children:[l(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:`Secret (manual entry)`}),r(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[l(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),r(`button`,{onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>C(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[S?l(h,{className:`h-3 w-3 text-emerald-500`}):l(g,{className:`h-3 w-3`}),S?`Copied`:`Copy`]})]})]})]}),r(`div`,{className:`space-y-1`,children:[l(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),l(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:_,onChange:e=>v(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),y&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(x,{className:`h-3 w-3`}),y]}),r(`div`,{className:`flex justify-end gap-2`,children:[l(`button`,{onClick:()=>{m(null),b(null),v(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),r(`button`,{onClick:()=>{b(null),E.mutate({code:_})},disabled:E.isPending||_.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[E.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(h,{className:`h-3 w-3`}),`Confirm`]})]})]}),A===`enrolled`&&f&&r(o,{children:[r(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[l(h,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),r(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[l(`div`,{className:`font-medium`,children:`2FA is active`}),r(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`]})]})]}),y&&r(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[l(x,{className:`h-3 w-3`}),y]}),l(`div`,{className:`flex justify-end`,children:r(`button`,{onClick:()=>{b(null),O.mutate()},disabled:O.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[O.isPending?l(D,{className:`h-3 w-3 animate-spin`}):l(w,{className:`h-3 w-3`}),`Disable 2FA`]})})]})]})]})}function F(){return m(`auth-webauthn/passkey-enrollment`)?l(p,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{j as MyAccessPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Q as l}from"./player-overlays-C7P-BYK6.js";import{$i as u,Bi as d,Ft as f,Gi as p,Hi as m,It as h,Ji as g,Jt as _,Ki as v,Mn as y,Ps as b,Pt as x,Qi as S,Ri as ee,Ui as te,Vi as C,Wi as ne,Xi as w,Yi as re,Zi as T,aa as E,ea as ie,ia as ae,it as D,jn as O,jt as oe,nt as se,oa as k,qi as ce,ta as A,zi as le}from"./src-D4J0MlT1.js";import{ct as j,rt as M}from"./src-DVkz1MkU.js";import{t as N}from"./boxes-DD7B6vWr.js";import{t as P}from"./copy-BIhozMgo.js";import{t as F}from"./play-D8PRXtJj.js";import{t as ue}from"./refresh-cw-C39zORZV.js";import{t as de}from"./rotate-ccw-D64HdccI.js";import{t as I}from"./server-DQLgZ7bE.js";import{t as L}from"./shield-AayD-Dai.js";import{t as R}from"./square-CTn6q5rG.js";import{t as z}from"./wifi-BgJhCz5w.js";import{B,C as V,D as H,J as U,M as W,S as fe,a as pe,c as me,r as he,w as G,y as K}from"./index-DpyYghK5.js";import{t as ge}from"./AdminPage-CCD07UMs.js";import{t as _e}from"./AdminTabs-CpTKjy3v.js";import{t as ve}from"./NodeAddonsSettingsPanel-BGiMbeFK.js";import{t as q}from"./AddonCollectionPage-_c7aqfTY.js";import{t as J}from"./addon-display-names-DvSEQty-.js";var ye=U(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),be=U(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),xe=U(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]);t();var Y=5e3,Se={connected:!1,endpoint:null};function Ce(){let e=a(),t=y({capName:`network-access`},{refetchInterval:Y}),n=O(void 0,{refetchInterval:Y}),i=r(()=>J(n.data??[]),[n.data]),c=r(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),[l,u]=o(null),[d,f]=o({}),p=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),u(null),f(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},m=(e,t)=>{u(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);f(e=>({...e,[n]:r}))},h=E({onSuccess:p,onError:m}),g=k({onSuccess:p,onError:m});return s(q,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:H,itemIcon:H,capability:`network-access`,installButtonLabel:`Add tunnel`,items:c,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>s(Te,{addonId:e.addonId}),itemError:e=>d[e.addonId]??null,renderPrimaryAction:e=>s(Ee,{addonId:e.addonId,busyId:l,onStart:e=>{u(e),h.mutate({addonId:e})},onStop:e=>{u(e),g.mutate({addonId:e})}})})}function we(e){let{data:t}=ae({addonId:e},{refetchInterval:Y,retry:!1}),n=t?j.safeParse(t):null;return n?.success?n.data:Se}function Te({addonId:e}){let t=we(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&n(`a`,{href:t.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1`,children:[s(W,{className:`h-3 w-3`}),t.endpoint.url]})]})}function Ee({addonId:e,busyId:t,onStart:r,onStop:i}){let a=we(e),o=t===e;return a.connected?n(h,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?s(G,{className:`h-3 w-3 animate-spin`}):s(R,{className:`h-3 w-3`}),`Stop`]}):n(h,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>r(e),children:[o?s(G,{className:`h-3 w-3 animate-spin`}):s(F,{className:`h-3 w-3`}),`Start`]})}t();var De=3e4;function Oe(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function ke(){let e=y({capName:`turn-provider`},{refetchInterval:De}),t=O(void 0,{refetchInterval:De}),i=b(),a=i.data??[],o=r(()=>J(t.data??[]),[t.data]);return s(q,{title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,pageIcon:K,itemIcon:K,capability:`turn-provider`,installButtonLabel:`Add provider`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,o]),isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,renderExpandedPanel:e=>s(Ae,{addonId:e.addonId,enabled:e.isActive}),trailing:n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),s(h,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:`Refresh`})]}),s(`div`,{className:`p-4`,children:a.length===0?s(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):s(`div`,{className:`flex flex-col gap-3`,children:a.map((e,t)=>{let r=Array.isArray(e.urls)?e.urls:[e.urls];return n(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&n(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,s(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,s(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(e=>s(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function Ae({addonId:e,enabled:t}){let i=b({addonId:e},{enabled:t,retry:!1}),a=r(()=>Oe(i.data??[]),[i.data]);return!t||a.length===0?null:n(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[n(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,a.length,`)`]}),s(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>s(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}t();var je={lan:K,wifi:z,docker:N,vpn:V,loopback:I,other:I},Me={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Ne=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Pe(e){let{interfaces:t,disabled:i,hideLoopback:a,ipv4Only:o,emptyMessage:c}=e,l=r(()=>t.filter(e=>!(a&&e.kind===`loopback`||o&&e.family!==`IPv4`)),[t,a,o]),u=r(()=>{let e=new Map;for(let t of l){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Ne.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[l]),d=t=>e.mode===`single`?e.value===t:e.value.includes(t),f=t=>{if(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return l.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic`,children:c??`No addresses available.`}):s(`div`,{className:`flex flex-col gap-3`,children:u.map(({kind:t,items:r})=>n(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[s(je[t]??I,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Me[t]??t}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=d(t.address),a=t.kind===`loopback`,o=!t.plausible&&!a;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 ${a?`opacity-60 cursor-not-allowed`:i?`opacity-60`:o?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>f(t),children:[s(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&s(B,{className:`h-3 w-3`})}),n(`div`,{className:`flex-1 min-w-0 ${o?`text-foreground-subtle`:``}`,children:[n(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`span`,{className:`font-mono text-xs font-semibold ${o?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),s(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),a&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),o&&n(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[s(pe,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),n(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}t();var Fe={"lan-ipv4":{label:`IPv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{label:`IPv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{label:`Public`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},loopback:{label:`Loopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function X(e){return e.kind!==`loopback`}function Ie(e){return e.kind!==`loopback`}function Le(){let e=a(),t=l(),i=te(void 0,{refetchInterval:3e4}),u=ee(void 0),f=ce({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),_=p({onSuccess:t=>{S(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),v=r(()=>i.data?.interfaces??[],[i.data]),y=le({port:typeof window<`u`?Number(window.location.port)||(window.location.protocol===`https:`?443:80):4e3,scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),[b,S]=o([]),[C,ne]=o(!1);c(()=>{!C&&u.data&&(S(u.data.addresses),ne(!0))},[u.data,C]);let w=u.data?.addresses??[],T=r(()=>{if(b.length!==w.length)return!0;let e=[...b].toSorted(),t=[...w].toSorted();return e.some((e,n)=>e!==t[n])},[b,w]),E=()=>{f.mutate({addresses:[...b]})},ie=()=>{S(w)},ae=()=>{S([])},D=()=>{i.refetch(),y.refetch(),u.refetch(),k.refetch(),j.refetch()},O=async()=>{try{let e=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info(`[network-addresses] race result`,e)}catch(e){console.warn(`[network-addresses] race failed`,e)}},k=d(),A=g({onSuccess:()=>void k.refetch()}),j=m(),M=re({onSuccess:()=>void j.refetch()}),N=y.data?.endpoints??[],P=k.data?.baseUrl??null,F=k.data?.resolved??null,I=j.data?.baseUrls??[],L=I.length===0,R=P===null,z=e=>L?e.kind===`lan-ipv4`||e.kind===`public`&&e.interfaceKind===`public`:I.includes(e.baseUrl),B=e=>P===null?F===e.baseUrl:P===e.baseUrl,V=e=>{if(!X(e))return;let t=L?N.filter(e=>X(e)&&z(e)).map(e=>e.baseUrl):[...I],n=t.includes(e.baseUrl)?t.filter(t=>t!==e.baseUrl):[...t,e.baseUrl];M.mutate({baseUrls:n})},H=e=>{if(Ie(e)){if(B(e)){R||A.mutate({baseUrl:null});return}A.mutate({baseUrl:e.baseUrl})}},U=r(()=>[{key:`url`,header:`Endpoint`,render:e=>n(`div`,{className:`min-w-0 py-0.5`,children:[s(`div`,{className:`font-mono text-[12px] break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),n(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[s(`span`,{children:e.label}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&s(`span`,{className:`uppercase tracking-wide`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&n(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:e.plausibleReason||void 0,children:[s(pe,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]})]})},{key:`kind`,header:`Kind`,nowrap:!0,render:e=>{let t=Fe[e.kind]??Fe.loopback;return s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:t.label})}},{key:`viewer`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Viewer`,L?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-24`,render:e=>{let t=X(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:e.kind===`loopback`?`Loopback is not a client route.`:`Use this URL in the API / viewer race.`,children:s(oe,{checked:t&&z(e),disabled:!t||M.isPending,onChange:()=>V(e),"aria-label":`Viewer: ${e.baseUrl}`})})}},{key:`notifications`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Notifications`,R?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-28`,render:e=>{let t=Ie(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:t?`Notification links and deep links use this address.`:`Loopback is not a client route.`,children:s(oe,{checked:t&&B(e),disabled:!t||A.isPending,onChange:()=>H(e),"aria-label":`Notifications: ${e.baseUrl}`})})}}],[L,R,I,P,F,M.isPending,A.isPending,N]);return n(ge,{children:[n(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[s(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Pin which host addresses exist, then tick the destinations each URL should serve. Viewer auto is IPv4 + public; every other row (including IPv6) can be ticked on.`}),n(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n(h,{size:`sm`,variant:`secondary`,onClick:D,disabled:i.isLoading,children:[s(ue,{className:`h-3 w-3 ${i.isLoading?`animate-spin`:``}`}),`Refresh`]}),s(h,{size:`sm`,variant:`secondary`,onClick:O,children:`Probe race`})]})]}),n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:b.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${b.length} pinned`})]}),n(`div`,{className:`flex items-center gap-1`,children:[n(h,{size:`sm`,variant:`secondary`,onClick:()=>_.mutate(void 0),disabled:_.isPending||f.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[s(me,{className:`h-3 w-3`}),_.isPending?`Detecting…`:`Best match`]}),n(h,{size:`sm`,variant:`secondary`,onClick:ae,disabled:b.length===0||f.isPending,children:[s(de,{className:`h-3 w-3`}),`Clear`]}),T&&s(h,{size:`sm`,variant:`secondary`,onClick:ie,disabled:f.isPending,children:`Discard`}),n(h,{size:`sm`,variant:`primary`,onClick:E,disabled:!T||f.isPending,children:[s(be,{className:`h-3 w-3`}),f.isPending?`Saving…`:`Save`]})]})]}),s(`div`,{className:`p-4`,children:s(Pe,{mode:`multiple`,interfaces:v,value:b,onChange:S,disabled:f.isPending,emptyMessage:i.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),n(x,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`Ranked URLs this hub advertises. Tick Viewer (many) and Notifications (one).`})]}),n(`div`,{className:`flex items-center gap-1`,children:[!L&&s(h,{size:`sm`,variant:`secondary`,disabled:M.isPending,onClick:()=>M.mutate({baseUrls:[]}),children:`Viewer → auto`}),!R&&s(h,{size:`sm`,variant:`secondary`,disabled:A.isPending,onClick:()=>A.mutate({baseUrl:null}),children:`Notifications → auto`})]})]}),R&&F===null&&s(`p`,{className:`px-4 pt-3 text-[11px] text-amber-600 dark:text-amber-400`,children:`No public address is reachable, so notification media ships as bytes only — a backend that can only take links (WhatsApp, gotify) receives none.`}),s(se,{columns:U,rows:N,rowKey:e=>`${e.priority}-${e.baseUrl}`,minWidthPx:640,bordered:!1,mobileMode:`scroll`,emptyMessage:y.isLoading?`Loading…`:`No endpoints available.`,rowClassName:e=>e.plausible?void 0:`opacity-80`})]})]})}t();var Re={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Z=5e3,ze=3e4,Be={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Ve(){let e=y({capName:`mesh-network`},{refetchInterval:Z}),t=O(void 0,{refetchInterval:Z}),n=r(()=>J(t.data??[]),[t.data]);return s(q,{title:`Mesh Networks`,subtitle:`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`,pageIcon:N,itemIcon:K,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]),isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`,renderStatusBadges:e=>s(He,{addonId:e.addonId}),renderPrimaryAction:e=>s(Ue,{addonId:e.addonId}),renderExpandedPanel:e=>s(We,{addonId:e.addonId})})}function Q(e){let{data:t,isLoading:n}=T({addonId:e},{refetchInterval:Z,retry:!1}),r=t?M.safeParse(t):null;return{status:r?.success?r.data:Be,isLoading:n}}function He({addonId:e}){let{status:t}=Q(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.joined?`Joined`:`Not joined`}),t.joined&&n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function Ue({addonId:t}){let r=a(),[c,u]=o(!1),[d,f]=o(null),p=l(),{status:m}=Q(t),g=e(()=>{r.invalidateQueries({queryKey:[[`meshNetwork`]]})},[r]),_=A(),v=S({onSuccess:g}),y=ie({onSuccess:g}),b=e(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await _.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await Ze(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?M.safeParse(e):null;if(n?.success&&n.data.joined){g();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,g,_,p]),x=e(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return s(i,{children:m.joined?n(i,{children:[n(h,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(fe,{className:`h-3 w-3`}),`Disconnect`]}),n(h,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(xe,{className:`h-3 w-3`}),`Log out`]})]}):c?n(h,{size:`sm`,variant:`ghost`,onClick:x,children:[s(he,{className:`h-3 w-3 mr-1`}),` Cancel`]}):n(i,{children:[n(h,{size:`sm`,variant:`primary`,onClick:()=>void b(),children:[s(ye,{className:`h-3 w-3`}),`Connect`]}),n(h,{size:`sm`,variant:`ghost`,disabled:y.isPending,onClick:()=>y.mutate({addonId:t}),children:[y.isPending?s(G,{className:`h-3 w-3 animate-spin`}):s(xe,{className:`h-3 w-3`}),`Log out`]})]})})}function We({addonId:e}){let{status:t}=Q(e),r=u({addonId:e},{refetchInterval:ze,retry:!1});return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`p-4 space-y-4`,children:[t.error&&s(_,{message:t.error}),s(Ge,{status:t}),t.endpoints.length>0&&n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),t.endpoints.map(e=>n(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Re[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?s(H,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),n(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[s(W,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),s(`div`,{className:`border-t border-border`,children:s(qe,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function Ge({status:e}){return s(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:`Tenant`,value:e.tenantName||`—`},{label:`User`,value:e.userLogin??`—`},{label:`Control plane`,value:e.controlPlaneUrl||`—`},{label:`Mesh IP`,value:e.meshIp||`—`,mono:!0},{label:`MagicDNS`,value:e.magicDnsHostname||`—`,mono:!0},{label:`DNS suffix`,value:e.magicDnsSuffix||`—`,mono:!0},{label:`Peers`,value:String(e.peerCount)},{label:`Key expiry`,value:e.keyExpiry?Ke(e.keyExpiry):`—`}].map(e=>n(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[s(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),s(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Ke(e){let t=e-Date.now();if(t<0)return`Expired ${Xe(e)}`;let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;let r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function qe({peers:t,loading:i}){let a=r(()=>t.map(e=>({...e,_id:e.id})),[t]),o=e(e=>{e&&navigator.clipboard?.writeText(e)},[]),c=r(()=>[{key:`hostname`,header:`Hostname`,render:e=>n(`div`,{className:`flex flex-col`,children:[n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&s(f,{variant:`info`,children:`self`}),e.exitNodeOption&&s(f,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&s(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),s(`button`,{onClick:()=>o(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:s(P,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs`,children:t}),s(`button`,{onClick:()=>o(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:s(P,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>n(`div`,{className:`flex items-center gap-1.5`,children:[s(f,{variant:Je(e.connection),children:e.connection}),e.relay&&s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?s(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>n(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Ye(e.txBytes),` · ↓ `,Ye(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>s(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Xe(e.lastSeenMs):`—`})}],[o]);return i&&t.length===0?n(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[s(G,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):t.length===0?s(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):s(`div`,{className:`p-4`,children:s(se,{columns:c,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function Je(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Ye(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function Xe(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function Ze(e){return new Promise(t=>setTimeout(t,e))}t();function $(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Qe(){let e=a(),t=C(void 0,{refetchInterval:15e3}),r=ne({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),i=v({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),c=w({onSuccess:()=>{d(!1),p(``),g(``),y(``),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),l=t.data,[u,d]=o(!1),[f,p]=o(``),[m,g]=o(``),[_,y]=o(``),b=()=>{if(!l?.caCertPem)return;let e=new Blob([l.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},S=l?.mode===`uploaded`?`Uploaded`:l?.mode===`generated`?`Generated local CA`:`TLS disabled`;return n(`div`,{className:`flex flex-col gap-4`,children:[s(ve,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:`LAN HTTP`,description:`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`}),n(x,{className:`p-4 space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(L,{className:`h-4 w-4 text-foreground-subtle`}),s(`h3`,{className:`text-sm font-semibold`,children:`Certificate`})]}),t.isError&&s(`p`,{className:`text-xs text-danger`,children:`Could not read TLS status.`}),l?.reissueError&&s(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:l.reissueError}),l?.restartRequired&&s(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Restart the hub to apply the new certificate.`}),n(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Mode`}),s(`dd`,{className:`font-medium`,children:S})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Valid to`}),s(`dd`,{className:`font-mono`,children:l?.validTo?new Date(l.validTo).toLocaleString():`—`})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Leaf SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.leafFingerprintSha256??void 0,children:$(l?.leafFingerprintSha256??null)})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`CA SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.caFingerprintSha256??void 0,children:$(l?.caFingerprintSha256??null)})]})]}),l&&l.sans.length>0&&s(`div`,{className:`flex flex-wrap gap-1`,children:l.sans.map(e=>s(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),n(`div`,{className:`flex flex-wrap gap-2`,children:[s(D,{label:`Regenerate`,title:`Issue a new leaf?`,description:`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`,confirmLabel:`Regenerate`,disabled:l?.mode===`uploaded`||r.isPending,action:()=>r.mutateAsync({})}),s(h,{size:`sm`,variant:`outline`,onClick:()=>d(e=>!e),children:`Upload`}),l?.caCertPem&&s(h,{size:`sm`,variant:`outline`,onClick:b,children:`Download CA`}),l?.mode===`uploaded`&&s(D,{label:`Revert to generated`,title:`Drop the uploaded certificate?`,description:`Deletes the uploaded pair and returns to the generated local CA.`,confirmLabel:`Revert`,confirmVariant:`danger`,disabled:i.isPending,action:()=>i.mutateAsync({})})]}),u&&n(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Certificate PEM`,s(`textarea`,{value:f,onChange:e=>p(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Private key PEM`,s(`textarea`,{value:m,onChange:e=>g(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`CA PEM (optional)`,s(`textarea`,{value:_,onChange:e=>y(e.target.value),rows:4,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),s(h,{size:`sm`,disabled:!f.trim()||!m.trim()||c.isPending,onClick:()=>c.mutate({certPem:f,keyPem:m,..._.trim()?{caPem:_}:{}}),children:`Save certificate`}),c.isError&&s(`p`,{className:`text-xs text-danger`,children:c.error instanceof Error?c.error.message:`Upload failed`})]})]})]})}function $e(){return s(`div`,{className:`flex flex-col p-4`,children:s(_e,{defaultTab:`addresses`,tabs:[{id:`local-access`,label:`Local access`,icon:z,content:s(Qe,{})},{id:`addresses`,label:`Network Addresses`,icon:I,content:s(Le,{})},{id:`remote-access`,label:`Remote Access`,icon:H,content:s(Ce,{})},{id:`mesh`,label:`Mesh Networks`,icon:N,content:s(Ve,{})},{id:`turn`,label:`TURN Servers`,icon:K,content:s(ke,{})}]})})}export{$e as NetworkPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as e,I as t,K as n,Q as r,S as i,W as a,b as o,i as s,k as c,o as l,p as u,q as d,t as f,x as p,z as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Q as h}from"./player-overlays-C7P-BYK6.js";import{Sn as g,Zn as _,jn as v,xn as y,xr as ee}from"./src-D4J0MlT1.js";import{Ut as b}from"./src-DVkz1MkU.js";import{n as te,r as x,t as ne}from"./SchemaTabBar-DC28nb9j.js";import{t as S}from"./FormBuilder-KnE-MHOY.js";import{t as re}from"./StableTabPanel-Dc954AQl.js";r();var C=c(function({addonId:r,schema:i,serverValues:o,onImmediateSave:s,onStateChange:c,onAction:l,disabled:u},d){let f=x({schema:i,serverValues:o,onImmediateSave:t(e=>s(r,e),[r,s]),onDeferredSave:t(()=>{},[])});e(d,()=>({flush:()=>{let e={};for(let t of f.pendingKeys)e[t]=f.values[t];return f.handleDiscard(f.pendingKeys),e},discard:()=>f.resetAll()}),[f]);let h=f.pendingKeys,g=h.join(`|`),_=a(()=>h.map(e=>`${e}=${JSON.stringify(f.values[e])}`).join(`,`),[h,f.values]),v=n(c);m(()=>{v.current=c},[c]),m(()=>{let e={};for(let t of h)e[t]=f.values[t];v.current({addonId:r,pendingKeys:h,pendingValues:e})},[r,g,_]);let y=a(()=>{if(l)return(e,t,n)=>l(r,e,t,n)},[r,l]);return p(S,{schema:i,values:f.values,onChange:f.handleChange,disabled:u,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function ie(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}r();function D(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>D(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function O(e,t){return{...e,fields:e.fields.map(e=>D(e,t))}}function ae(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>O(e,t))},values:t}}function k({nodeId:e,addonIds:r,level:c,deviceId:m,capability:x,sectionIds:S,omitSectionIds:C,sectionTab:w,fieldScope:T,surface:E,emptyMessage:D,extraTabs:O,schemaTabExtras:k,title:A,description:j,selfTabbed:se}){let M=l(),N=h().trpcClient,P=g(),F=y(),I=ee(),L=_(),R=se===!0||!!(O&&O.length>0),[z,ce]=d(null);if(c===`device`&&!m)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);if(E!==void 0){if(c!==`global`||m!==void 0)throw Error(`NodeAddonsSettingsPanel: integration-level settings are addon-wide — they cannot be mounted at device level or with a deviceId. A second page, never a second scope.`);if(e!==null)throw Error(`NodeAddonsSettingsPanel: an integration has no node behind it — pass nodeId={null}. Received ${JSON.stringify(e)}.`);if(T!==void 0)throw Error("NodeAddonsSettingsPanel: integration-level settings arrive already cluster-scoped from core — remove `fieldScope` rather than restating it.")}let B=e??`hub`,V=s({queries:r.map(e=>({queryKey:[[`addonSettings`,E===void 0?c===`global`?`getGlobalSettings`:`getDeviceSettings`:`getIntegrationSettings`],{addonId:e,nodeId:B,deviceId:m??null,cap:x??null,scope:T??null}],queryFn:async()=>{let t=e=>e!==null&&T!==void 0?ie(e,T):e;return E===void 0?c===`global`?{addonId:e,result:t(await N.addonSettings.getGlobalSettings.query({addonId:e,nodeId:B,...x?{cap:x}:{}}))}:{addonId:e,result:t(await N.addonSettings.getDeviceSettings.query({addonId:e,deviceId:m,nodeId:B}))}:{addonId:e,result:await N.addonSettings.getIntegrationSettings.query({addonId:e,nodeId:B})}},placeholderData:u}))}),H=V.some(e=>e.isLoading),le=V.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),U=a(()=>{let e=new Set;for(let t of V){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(t.tab??`general`)}return[...e]},[le+`::`+V.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),W=a(()=>new Map((O??[]).map(e=>[e.id,e])),[O]),G=a(()=>{if(!R)return[];let e=[...new Set([...U,...(O??[]).map(e=>e.id),...(k??[]).map(e=>e.tabId)])],t=e=>{let t=W.get(e);if(t?.order!==void 0)return t.order;let n=b[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[R,U,O,W,k]),ue=a(()=>{let e=new Map,t=e=>b[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of U)e.set(n,t(n));for(let n of k??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of O??[])e.set(t.id,t.label);return e},[U,O,k]),K=R?z&&G.includes(z)?z:G[0]??null:null,de=K!==null&&W.has(K),q=R?K&&!de?K:void 0:w,{data:fe}=v(void 0),pe=a(()=>{let e=new Map;for(let t of fe??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[fe]),me=n(new Map),J=a(()=>{let e=S?new Set(S):null,t=C?new Set(C):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of V){if(!e.data)continue;let t=e.data.result??me.current.get(e.data.addonId)??null;if(e.data.result!==null&&me.current.set(e.data.addonId,e.data.result),t===null)continue;let{schema:i,values:a}=ae(t),o=i.sections.filter(e=>n(e.id));if(o.length===0)continue;let s={...t,sections:t.sections.filter(e=>n(e.id))},c={...i,sections:o};r.push({addonId:e.data.addonId,schemaWithValues:s,schema:c,serverValues:a})}return r},[le,S,C]),[Y,he]=d(new Map),ge=t(e=>{he(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=n(new Map),_e=t(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),ve=t(async(e,t)=>{c===`global`?await P.mutateAsync({addonId:e,nodeId:B,patch:t}):await F.mutateAsync({addonId:e,deviceId:m,nodeId:B,patch:t}),M.invalidateQueries({queryKey:[[`addonSettings`]]})},[P,F,B,c,m,M]),ye=t(async(e,t,n,r)=>{let i=B;try{switch(t){case`reprobe-hwaccel`:await I.mutateAsync({nodeId:i}),M.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await L.mutateAsync({nodeId:i}),M.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await N.addons.custom.mutate({addonId:e,action:t,input:r});return M.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[I,L,B,M,N]),be=t((e,t)=>{ve(e,t)},[ve]),Z=f({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(c===`global`?await P.mutateAsync({addonId:e,nodeId:B,patch:t}):await F.mutateAsync({addonId:e,deviceId:m,nodeId:B,patch:t}),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();M.invalidateQueries({queryKey:[[`addonSettings`]]})}}),xe=t(()=>{for(let e of X.current.values())e.discard()},[]),Se=a(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),Ce=a(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(H)return p(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let Q=K&&de?W.get(K):void 0;if(!R&&J.length===0)return p(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:D??i(o,{children:[`No addons in`,` `,r.length>0?`[${r.join(`, `)}]`:`the current selection`,` expose`,` `,c,`-level settings on this node.`]})});let $=Z.isPending;return i(`div`,{className:`space-y-4`,children:[(A||j)&&i(`div`,{className:`border-b border-border pb-2`,children:[A&&p(`h2`,{className:`text-sm font-semibold text-foreground`,children:A}),j&&p(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:j})]}),R&&p(ne,{tabs:G.map(e=>({id:e,label:ue.get(e)??e})),activeId:K,onChange:ce,pendingByTab:Ce}),Z.isError&&i(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed: `,String(Z.error?.message??Z.error)]}),p(re,{tabKey:Q?`extra:${K??``}`:`tab:${K??``}`,children:Q?Q.content:(()=>{let e=q?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===q).length,0):0,t=q!==null&&e<=1,n=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>q?(e.tab??`general`)===q:!0).map(e=>t?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),r=(k??[]).filter(e=>e.tabId===q),a=r.filter(e=>(e.placement??`before`)===`before`),o=r.filter(e=>e.placement===`after`);return n.length===0&&r.length===0?p(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:D??`Nothing to configure here for this node.`}):i(`div`,{className:`space-y-6`,children:[a.map((e,t)=>p(`div`,{children:e.content},`extra-before-${t}`)),n.length>0&&p(oe,{entries:n,paneStates:Y,displayNames:pe,disabled:$,setPaneRef:_e,onPaneStateChange:ge,onImmediateSave:be,onAction:ye,inline:R||!!w}),o.map((e,t)=>p(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!H&&p(te,{pendingCount:Se,onSave:()=>Z.mutate(),onDiscard:xe,saving:$})]})}function oe({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:o,onPaneStateChange:s,onImmediateSave:c,onAction:l,inline:u}){let f=a(()=>[...e].toSorted((e,t)=>{if(e.addonId===`system-config`)return-1;if(t.addonId===`system-config`)return 1;let r=n.get(e.addonId)??e.addonId,i=n.get(t.addonId)??t.addonId;return r.localeCompare(i)}),[e,n]),[h,g]=d(f[0]?.addonId??``);m(()=>{f.length!==0&&(f.find(e=>e.addonId===h)||g(f[0].addonId))},[f,h]);let _=f.find(e=>e.addonId===h)??f[0];if(!_)return null;let v=a(()=>l?(e,t,n,r)=>l(e,t,n,r):void 0,[l]),y=e=>p(C,{ref:o(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:c,onStateChange:s,onAction:v,disabled:r},e.addonId);return f.length===1||u?p(`div`,{className:`flex flex-col gap-4`,children:f.map(y)}):i(`div`,{className:`flex flex-col gap-3`,children:[p(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:f.map(e=>{let r=n.get(e.addonId)??e.addonId,a=e.addonId===_.addonId,o=(t.get(e.addonId)?.pendingKeys.length??0)>0;return i(`button`,{type:`button`,onClick:()=>g(e.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[r,o&&p(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},e.addonId)})}),p(`div`,{className:`space-y-2`,children:f.map(e=>p(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{k as t};
|