@camstack/addon-admin-ui 1.2.635 → 1.2.637
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/CHANGELOG.md +14 -0
- package/dist/assets/Addons-BlKy1u2u.js +5 -0
- package/dist/assets/{AdminPage-C28MWSEJ.js → AdminPage-_ITsYONa.js} +1 -1
- package/dist/assets/{AdminSectionedPage-N7ZzoaCA.js → AdminSectionedPage-Xr_hesYw.js} +1 -1
- package/dist/assets/AiProfiles-YERCq98T.js +3 -0
- package/dist/assets/{Authentication-CdkAuFpQ.js → Authentication-CWHj8Czl.js} +1 -1
- package/dist/assets/Build-BmlbmwZw.js +39 -0
- package/dist/assets/{Calendars-Bl2YxKcY.js → Calendars-Bg6sl6iG.js} +1 -1
- package/dist/assets/{CameraGrids-BmuQfQwD.js → CameraGrids-BWF-BVdJ.js} +1 -1
- package/dist/assets/Cluster-BsLfi42d.js +1 -0
- package/dist/assets/CompositionBlockEditor-C0mH1XDD.js +2 -0
- package/dist/assets/CompositionEditorPage-5iKEcr6R.js +1 -0
- package/dist/assets/Data-DSMQmnZv.js +2 -0
- package/dist/assets/DeviceDetail-kBF3z5wo.js +2 -0
- package/dist/assets/{Devices-DfUS0XHQ.js → Devices-DQ8VksMo.js} +1 -1
- package/dist/assets/EmbedDevicePage-DOj0N5Mn.js +1 -0
- package/dist/assets/{EmbedPlayerPage-CXqkku3M.js → EmbedPlayerPage-J9i3kCrj.js} +1 -1
- package/dist/assets/History-BFkKRlW8.js +1 -0
- package/dist/assets/Identity-5sx8SWa4.js +1 -0
- package/dist/assets/InstancesTable-BagVOERb.js +1 -0
- package/dist/assets/IntegrationDetail-ByG-grc8.js +1 -0
- package/dist/assets/Integrations-BReJ0gq9.js +1 -0
- package/dist/assets/{Integrations-DM8ICLWP.js → Integrations-DK9ZlSbS.js} +2 -2
- package/dist/assets/Library-CVdwKZBw.js +1 -0
- package/dist/assets/Locations-CDUPDAGA.js +3 -0
- package/dist/assets/{Logs-BUWUMnM2.js → Logs-qlrqjJUI.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-GSzxL0sb.js → MaskShapeCanvas-C_kXMOhj.js} +1 -1
- package/dist/assets/{MotionZonesSettings-zuXI8WDy.js → MotionZonesSettings-CarcYpLx.js} +1 -1
- package/dist/assets/MyAccess-sO6455Tp.js +2 -0
- package/dist/assets/Network-B-NGzfdC.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-DY9KrknX.js → NodeAddonsSettingsPanel-BtSyXQ4v.js} +1 -1
- package/dist/assets/Notifications-BhHrfZKJ.js +1 -0
- package/dist/assets/Pipeline-C9_jNGPl.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-B4NUHvPx.js → PrivacyMaskSettings-BCxCYZMd.js} +1 -1
- package/dist/assets/Recordings-DTwvvqkz.js +1 -0
- package/dist/assets/RemoteGrid-CDLuEg4n.js +1 -0
- package/dist/assets/{ScanSubnetEditor-C7Np_Myd.js → ScanSubnetEditor-L1fLOCgh.js} +1 -1
- package/dist/assets/SceneMonitorEditor-C6ytHNuF.js +1 -0
- package/dist/assets/SessionsList-WhsG7RxJ.js +2 -0
- package/dist/assets/{Showroom-CpQU2YYQ.js → Showroom-DGD_uw5N.js} +1 -1
- package/dist/assets/StorageLocationsTable-CV0MMZ6R.js +1 -0
- package/dist/assets/{System-c-od2eUi.js → System-CUM8c-ad.js} +1 -1
- package/dist/assets/{Templates-DbOHcEoP.js → Templates-B1e69LSo.js} +1 -1
- package/dist/assets/{Terminal-vgjKTZ6i.js → Terminal-BzbVWqvg.js} +3 -3
- package/dist/assets/{TrainingProviders-DwApoYD1.js → TrainingProviders-CF4NFH__.js} +1 -1
- package/dist/assets/{Viewer-wmQSDFx4.js → Viewer-XTh3fjp9.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BJYMJYN7.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BezlQnHO.js} +1 -1
- package/dist/assets/{action-draft-SrqFGFVW.js → action-draft-DztPBE6P.js} +1 -1
- package/dist/assets/addon-icons-context-Bb2eBZv3.js +1 -0
- package/dist/assets/{ai-page.helpers-C_Yr1xBa.js → ai-page.helpers-B1a9LT5I.js} +1 -1
- package/dist/assets/archive-ChKlYFY2.js +1 -0
- package/dist/assets/{assignment-candidates-JnnkKMNk.js → assignment-candidates-DtwDORE1.js} +1 -1
- package/dist/assets/{authed-media-b_KsU6o6.js → authed-media-C0rONCq5.js} +1 -1
- package/dist/assets/bell-off-ChsIJ9tx.js +1 -0
- package/dist/assets/{board-model-Dhq6ifuR.js → board-model-DB92Pi_O.js} +1 -1
- package/dist/assets/boxes-k5PsZ3NR.js +1 -0
- package/dist/assets/calendar-clock-Iy6okb6K.js +1 -0
- package/dist/assets/chevron-down-CBb-F8DT.js +1 -0
- package/dist/assets/circle-arrow-up-5n0C9Hkd.js +1 -0
- package/dist/assets/circle-slash-Duh934sZ.js +1 -0
- package/dist/assets/client-mnldOm50.js +921 -0
- package/dist/assets/create-composition-xpQJ_im0.js +2 -0
- package/dist/assets/crop-B-t0rzRY.js +1 -0
- package/dist/assets/database-zap-DHuELz_w.js +1 -0
- package/dist/assets/device-detail-rao8xQIi.js +1 -0
- package/dist/assets/{device-integration-icon-JcbJW-sx.js → device-integration-icon-DSKbNj0K.js} +1 -1
- package/dist/assets/device-picker-model-CLxwtH6P.js +1 -0
- package/dist/assets/{dist-DtXy-_hV.js → dist-AhzFc2N5.js} +1 -1
- package/dist/assets/dist-jfEaRcCl.js +921 -0
- package/dist/assets/eraser-B3lnG9yK.js +1 -0
- package/dist/assets/file-up-2YD_M6f_.js +1 -0
- package/dist/assets/{format-ClefNnBA.js → format-B0YD4Zes.js} +1 -1
- package/dist/assets/grip-vertical-C89CQZwo.js +1 -0
- package/dist/assets/hard-drive-download-C6N6tovA.js +1 -0
- package/dist/assets/{hostInit-Zt1c3yOY.js → hostInit-Cc2xXBkZ.js} +1 -1
- package/dist/assets/i18n-ByFr51sS.js +1 -0
- package/dist/assets/icons-B5aMnrp4.js +1 -0
- package/dist/assets/{index-BZIzoUuI.css → index-CcY1r6e1.css} +1 -1
- package/dist/assets/index-D5GcZJtC.js +4 -0
- package/dist/assets/key-CH4aXNMz.js +1 -0
- package/dist/assets/languages-Du_pOBpX.js +1 -0
- package/dist/assets/layers-BH9u1mrE.js +1 -0
- package/dist/assets/link-2-off-DmsjRAt7.js +1 -0
- package/dist/assets/{linked-devices-model-CNibZiAj.js → linked-devices-model-DMdglvhv.js} +1 -1
- package/dist/assets/memory-stick-BQrJMbEW.js +1 -0
- package/dist/assets/message-square-plus-_aGccjyj.js +1 -0
- package/dist/assets/{mf-entry-bootstrap-0-b11ec2f0.js → mf-entry-bootstrap-0-aa99f5e1.js} +2 -2
- package/dist/assets/mic-off-BIQ5bbUV.js +1 -0
- package/dist/assets/monitor-off-DnOkDa2s.js +1 -0
- package/dist/assets/monitor-smartphone-DPI9EQus.js +1 -0
- package/dist/assets/mount-CLxwtH6P.js +1 -0
- package/dist/assets/{notification-rule-status-CSdUF_tS.js → notification-rule-status-DfiT5MFH.js} +1 -1
- package/dist/assets/player-overlays-BZByYYB8.js +1 -0
- package/dist/assets/remoteEntry-BFXSwA_z.js +1 -0
- package/dist/assets/ruler-Buxogset.js +1 -0
- package/dist/assets/scan-eye-B0eLch9E.js +1 -0
- package/dist/assets/scissors-BgY-d4kD.js +1 -0
- package/dist/assets/search-x-C5ra3Aft.js +1 -0
- package/dist/assets/send-D_NAoo3n.js +1 -0
- package/dist/assets/settings-2-BIrKVPOG.js +1 -0
- package/dist/assets/shapes-BPdkDjXe.js +1 -0
- package/dist/assets/sigma-Bc8X6bFu.js +1 -0
- package/dist/assets/src-DKRp5NPI.js +169 -0
- package/dist/assets/{sso-popup-C1hR2YBu.js → sso-popup-CcJP5NlL.js} +1 -1
- package/dist/assets/{step-inspector-model-BuQhYJra.js → step-inspector-model-DrTK6qqE.js} +1 -1
- package/dist/assets/table-2-DMxm3oyu.js +1 -0
- package/dist/assets/timer-reset-5221y6Jb.js +1 -0
- package/dist/assets/ungroup-BlQtUKBm.js +1 -0
- package/dist/assets/unlink-D3-IGpS8.js +1 -0
- package/dist/assets/usb-P4R9CjYI.js +1 -0
- package/dist/assets/{use-scenes-feed-DzJr-F4l.js → use-scenes-feed-3gS-l6TV.js} +1 -1
- package/dist/assets/{use-stationary-objects-DWdYOvvX.js → use-stationary-objects-6FuPeLm0.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-BRmWRglP.js → useAdminDeviceRemoval-Ds-ZvGNc.js} +1 -1
- package/dist/assets/useEventInvalidation-CLxwtH6P.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BHycntFj.js → useNodeUrlSelection-DAoFJ0Oq.js} +1 -1
- package/dist/assets/useTemplateSave-DZcYOuHu.js +1 -0
- package/dist/assets/user-round-CXEgJIXU.js +1 -0
- package/dist/assets/user-x-Dm3VRn93.js +1 -0
- package/dist/assets/variable-IcIR23WN.js +1 -0
- package/dist/assets/video-BV-3O_ZC.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-aKVCr1TV.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-ZzcWUaNn.js} +2 -2
- package/dist/index.html +12 -10
- package/dist/server/addon.js +136 -13
- package/package.json +2 -2
- package/dist/assets/Addons-it-7xyWO.js +0 -5
- package/dist/assets/AiProfiles-DvvGmPqc.js +0 -3
- package/dist/assets/Build-Dj-J_LDL.js +0 -39
- package/dist/assets/Cluster-BHVazygn.js +0 -1
- package/dist/assets/CompositionBlockEditor-BJo6-Hg-.js +0 -2
- package/dist/assets/CompositionEditorPage-CSgC3j3b.js +0 -1
- package/dist/assets/Data-DMpGwsud.js +0 -2
- package/dist/assets/DeviceDetail-C5qPLFqX.js +0 -2
- package/dist/assets/History-Bu9dClRP.js +0 -1
- package/dist/assets/Identity-P-9FfQY9.js +0 -1
- package/dist/assets/InstancesTable-D2wYEpEv.js +0 -1
- package/dist/assets/IntegrationDetail-Ckv-pM-X.js +0 -1
- package/dist/assets/Integrations-BAN_fC9m.js +0 -1
- package/dist/assets/Library-Boz_glAa.js +0 -1
- package/dist/assets/Locations-G2ggYLH1.js +0 -3
- package/dist/assets/MyAccess-BEvsl84G.js +0 -2
- package/dist/assets/Network-Q3AVjSDy.js +0 -1
- package/dist/assets/Notifications-B09FRQLf.js +0 -1
- package/dist/assets/Pipeline-DzMkRdB8.js +0 -1
- package/dist/assets/Recordings-d918Fao6.js +0 -1
- package/dist/assets/SceneMonitorEditor-D5EfTLG4.js +0 -1
- package/dist/assets/SessionsList--ByXUdry.js +0 -2
- package/dist/assets/StorageLocationsTable-Cb-zvsAa.js +0 -1
- package/dist/assets/archive-CnD3EIbI.js +0 -1
- package/dist/assets/bell-off-DXoIeft3.js +0 -1
- package/dist/assets/boxes-2HiFvbRi.js +0 -1
- package/dist/assets/calendar-clock-BdVpCjGZ.js +0 -1
- package/dist/assets/circle-arrow-up-DtE1a3jK.js +0 -1
- package/dist/assets/circle-slash-DD5DGeBE.js +0 -1
- package/dist/assets/client-DtixJSIH.js +0 -839
- package/dist/assets/create-composition-CdHcgM5T.js +0 -2
- package/dist/assets/crop-DtJsKDRR.js +0 -1
- package/dist/assets/database-zap-hwvWqFAr.js +0 -1
- package/dist/assets/device-picker-model-BhZ3nUKX.js +0 -1
- package/dist/assets/dist-DN98Ncd8.js +0 -839
- package/dist/assets/eraser-0igUeEn4.js +0 -1
- package/dist/assets/file-up-Bim5lEKk.js +0 -1
- package/dist/assets/hard-drive-download-BqaDoqeT.js +0 -1
- package/dist/assets/i18n-xBJb_nV7.js +0 -1
- package/dist/assets/icons-DWvhrrHw.js +0 -1
- package/dist/assets/index-IUYaCNr3.js +0 -4
- package/dist/assets/key-OpPYfUdn.js +0 -1
- package/dist/assets/languages-NKFv36FH.js +0 -1
- package/dist/assets/layers-BYYEeSk8.js +0 -1
- package/dist/assets/link-2-off-BQUSK1Q1.js +0 -1
- package/dist/assets/memory-stick-FrjSgbSx.js +0 -1
- package/dist/assets/message-square-plus-R1KzFT_3.js +0 -1
- package/dist/assets/mic-off-D-uv270W.js +0 -1
- package/dist/assets/monitor-off-23GJfNCk.js +0 -1
- package/dist/assets/monitor-smartphone-Bv9btLO7.js +0 -1
- package/dist/assets/mount-BhZ3nUKX.js +0 -1
- package/dist/assets/player-overlays-DS6dT7SD.js +0 -1
- package/dist/assets/remoteEntry-C8Nu6Wkp.js +0 -1
- package/dist/assets/ruler-B5-PAq3K.js +0 -1
- package/dist/assets/scan-eye-B6Jzl98g.js +0 -1
- package/dist/assets/scissors-DSuf9Nu7.js +0 -1
- package/dist/assets/search-x-DikQGG4z.js +0 -1
- package/dist/assets/send-DjOMX7BE.js +0 -1
- package/dist/assets/settings-2-RGt6KSqH.js +0 -1
- package/dist/assets/shapes-C2fW7MJb.js +0 -1
- package/dist/assets/sigma-BhKqPZ7F.js +0 -1
- package/dist/assets/src-D1sUPCi1.js +0 -169
- package/dist/assets/table-2-CMyjawoR.js +0 -1
- package/dist/assets/timer-reset-B7vcTXYk.js +0 -1
- package/dist/assets/ungroup-cZrrI4SI.js +0 -1
- package/dist/assets/unlink-CU8i3fPe.js +0 -1
- package/dist/assets/usb-CZTccxRm.js +0 -1
- package/dist/assets/useEventInvalidation-BhZ3nUKX.js +0 -1
- package/dist/assets/useTemplateSave-BIt_84s3.js +0 -1
- package/dist/assets/user-round-Cdt6x46z.js +0 -1
- package/dist/assets/user-x-C8J-JEQi.js +0 -1
- package/dist/assets/variable-B1tjLNN5.js +0 -1
- package/dist/assets/video-lKXIQOeO.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,P 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{Oa as c}from"./player-overlays-DS6dT7SD.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js";s();var _={rect:`#ef4444`,polygon:`#3b82f6`,grid:`#6366f1`,line:`#f59e0b`},v=`33`,y=`66`,b=`#6366f1`,x=3,S=2,C=12,w=16,T=9;function E(e,t,n){return{x:e.x*t,y:e.y*n}}function D(e,t,n){return{x:e.x/t,y:e.y/n}}function O(e,t,n){return e.flatMap(e=>[e.x*t,e.y*n])}function k(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function A(e){return e.color??_[e.shape.kind]}function j(e,t){let n=e[t],r=e[(t+1)%e.length];if(!n||!r)return[...e];let i={x:(n.x+r.x)/2,y:(n.y+r.y)/2};return[...e.slice(0,t+1),i,...e.slice(t+1)]}function M(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return Math.abs(e.x-r.x)<1e-6&&Math.abs(e.y-r.y)<1e-6}):!1}function N(e){return e.kind===`polygon`||e.kind===`line`}function P({items:n,selectedId:s,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=t(null),[H,ee]=o({w:800,h:450}),[U,W]=o([]),[G,K]=o(null),[te,ne]=o(null),[q,J]=o(null),Y=v!==null&&y.includes(v);a(()=>{if(!q)return;let e=n.find(e=>e.id===q.itemId);if(!e||!N(e.shape)){J(null);return}M(e.shape.points,q.points)&&J(null)},[n,q]),a(()=>{let e=V.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;ee(j?{w:n,h:r}:{w:n,h:n*9/16})});return t.observe(e),()=>t.disconnect()},[j]),a(()=>{!Y&&G!==null&&K(null)},[Y,G]);let X=r(e=>{m(e),W([])},[m]),re=r(e=>{if(!Y||v===null){f(null);return}let t=e.target.getStage();if(!t)return;let n=t.getPointerPosition();if(!n)return;let r=D(n,H.w,H.h);if(v===`rect`){let e=k(r.x),t=k(r.y);X({kind:`rect`,x:e,y:t,width:Math.min(.2,1-e),height:Math.min(.2,1-t)});return}if(v===`grid`){let e=I?.width??w,t=I?.height??T;X({kind:`grid`,gridWidth:e,gridHeight:t,cells:Array.from({length:e*t},()=>!1)});return}if(v===`line`){if(U.length===0){W([r]);return}X({kind:`line`,points:[...U,r]});return}if(v===`polygon`){if(U.length===0){W([r]);return}if(U.length>=x){let e=E(U[0],H.w,H.h);if(Math.hypot(n.x-e.x,n.y-e.y)<C){X({kind:`polygon`,points:U});return}}W(e=>[...e,r])}},[Y,v,U,H,I,X,f]),ie=r(e=>{!Y||v!==`polygon`||U.length<x||(e.cancelBubble=!0,X({kind:`polygon`,points:U}))},[Y,v,U,X]),Z=t(null),Q=t(null);a(()=>()=>{Z.current!==null&&cancelAnimationFrame(Z.current)},[]);let ae=r(e=>{if(!Y)return;let t=e.target.getStage();t&&(Q.current=t.getPointerPosition()??null,Z.current===null&&(Z.current=requestAnimationFrame(()=>{Z.current=null,K(Q.current)})))},[Y]),oe=t(!1),se=t(!0),ce=t(new Set),le=r((e,t,n,r)=>{let i=t.gridWidth*t.gridHeight;if(n<0||n>=i||t.cells[n]===r)return;let a=[...t.cells];for(;a.length<i;)a.push(!1);a.length=i,a[n]=r,p(e,{...t,cells:a})},[p]),$=[];if(!j){for(let e=1;e<w;e++){let t=H.w/w*e;$.push(i(u,{points:[t,0,t,H.h],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gv-${e}`))}for(let e=1;e<T;e++){let t=H.h/T*e;$.push(i(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return e(`div`,{ref:V,className:j?`absolute inset-0`:`relative w-full bg-zinc-900 rounded-lg overflow-hidden`,style:{cursor:Y?`crosshair`:`default`},children:[P&&!j?i(`div`,{className:`absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover`,style:{width:H.w,height:H.h},children:P}):null,e(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[e(g,{listening:!1,children:[i(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),i(g,{children:n.map(e=>{let t=e.id===s,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return i(L,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isDrawing:Y,size:H,onSelect:f,onShapeChange:p},e.id);if(e.shape.kind===`grid`)return i(R,{item:e,shape:e.shape,color:r,dimmed:n,editable:a,size:H,onSelect:f,paintingRef:oe,paintValueRef:se,paintedRef:ce,paintCell:le},e.id);let o=e.shape.kind===`line`,c=o?S:Math.max(x,F?.min??x),l=o?S:F?.max,u=q&&q.itemId===e.id?q.points:e.shape.points;return i(z,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isLine:o,isDrawing:Y,size:H,effectivePoints:u,minVertices:c,maxVertices:l,isDragging:te===e.id,onSelect:f,onShapeChange:p,setDragOverride:J,setDraggingItemId:ne},e.id)})}),i(g,{listening:!1,children:Y&&U.length>0&&e(d,{children:[v===`polygon`&&U.length>=2&&i(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&i(u,{points:[U[0].x*H.w,U[0].y*H.h,G.x,G.y],stroke:_.line,strokeWidth:1.5,dash:[6,3],opacity:.7}),v===`polygon`&&G&&U.length>=1&&i(u,{points:[U[U.length-1].x*H.w,U[U.length-1].y*H.h,G.x,G.y],stroke:b,strokeWidth:1,dash:[4,4],opacity:.5}),U.map((e,t)=>{let n=E(e,H.w,H.h),r=t===0&&v===`polygon`&&U.length>=x;return i(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?i(`div`,{className:`px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700`,children:v===`line`?B(`uiLibrary.maskShapeCanvas.hintLine`,`Click to set the start point, click again to complete the line`):v===`rect`?B(`uiLibrary.maskShapeCanvas.hintRect`,`Click to drop a rectangle, then drag the corner to resize`):v===`grid`?B(`uiLibrary.maskShapeCanvas.hintGrid`,`Click to add the grid, then paint cells`):U.length<x?B(`uiLibrary.maskShapeCanvas.hintPoints`,`Click to add points (min 3). Double-click or click the first point to close.`):B(`uiLibrary.maskShapeCanvas.hintMore`,`Continue adding points. Double-click or click the first point to close.`)}):null]})}var F=.02;function I(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.width-t.width)<1e-6&&Math.abs(e.height-t.height)<1e-6}function L({item:t,shape:n,color:r,selected:s,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=o(null),S={x:n.x,y:n.y,width:n.width,height:n.height};a(()=>{b&&I(S,b)&&x(null)},[n.x,n.y,n.width,n.height,b]);let C=b??S,w=C.x*m.w,T=C.y*m.h,E=C.width*m.w,D=C.height*m.h,O=c?.35:s?1:.85,A=e=>{x(e),_(t.id,{kind:`rect`,x:e.x,y:e.y,width:e.width,height:e.height})};return i(d,{onClick:e=>{e.cancelBubble=!0,u||g(t.id)},children:e(d,{draggable:l,dragBoundFunc:l?e=>({x:Math.max(-w,Math.min(m.w-(w+E),e.x)),y:Math.max(-T,Math.min(m.h-(T+D),e.y))}):void 0,onDragEnd:l?e=>{let t=e.target,n=t.x()/m.w,r=t.y()/m.h;if(t.position({x:0,y:0}),n===0&&r===0)return;let i=Math.min(Math.max(0,C.x+n),Math.max(0,1-C.width)),a=Math.min(Math.max(0,C.y+r),Math.max(0,1-C.height));A({...C,x:i,y:a})}:void 0,onMouseEnter:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=u?`crosshair`:`default`)},children:[i(p,{x:w,y:T,width:E,height:D,fill:r+(s?y:v),stroke:r,strokeWidth:s?2.5:1.5,opacity:O}),t.label?i(f,{x:w,y:T-16,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?i(h,{x:w+E,y:T+D,radius:6,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,dragBoundFunc:e=>({x:Math.min(m.w,Math.max(w,e.x)),y:Math.min(m.h,Math.max(T,e.y))}),onDragStart:e=>{e.cancelBubble=!0},onDragMove:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);x({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onDragEnd:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);A({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onMouseEnter:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`nwse-resize`)},onMouseLeave:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`default`)}}):null]})})}function R({item:e,shape:t,color:n,dimmed:r,editable:a,size:o,onSelect:s,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=o.w/m,v=o.h/h,b=m*h,x=r?.3:1,S=n=>{if(!a){s(e.id);return}let r=g[n]!==!0;c.current=!0,l.current=r,u.current=new Set([n]),f(e.id,t,n,r)},C=n=>{!c.current||!a||u.current.has(n)||(u.current.add(n),f(e.id,t,n,l.current))},w=()=>{c.current&&(c.current=!1,u.current=new Set)};return i(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,a=Math.floor(t/m),o=g[t]===!0;return i(p,{x:r*_,y:a*v,width:_,height:v,fill:o?n+y:`#ffffff10`,stroke:o?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:t,shape:n,color:r,selected:a,dimmed:o,editable:s,isLine:c,isDrawing:l,size:p,effectivePoints:g,minVertices:_,maxVertices:b,isDragging:x,onSelect:S,onShapeChange:C,setDragOverride:w,setDraggingItemId:T}){let k=O(g,p.w,p.h),A=o?.35:a?1:c?.8:.85,M=e=>c?{kind:`line`,points:[...e]}:{kind:`polygon`,points:[...e]},N=g.map(e=>e.x*p.w),P=g.map(e=>e.y*p.h),F=N.length>0?Math.min(...N):0,I=N.length>0?Math.max(...N):0,L=P.length>0?Math.min(...P):0,R=P.length>0?Math.max(...P):0,z=e=>({x:Math.max(-F,Math.min(p.w-I,e.x)),y:Math.max(-L,Math.min(p.h-R,e.y))}),B=e=>{let r=e.target,i=r.x()/p.w,a=r.y()/p.h;if(r.position({x:0,y:0}),T(null),i===0&&a===0)return;let o=n.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:t.id,points:o}),C(t.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return e(d,{onClick:e=>{e.cancelBubble=!0,l||S(t.id)},children:[e(d,{draggable:s,dragBoundFunc:s?z:void 0,onDragStart:s?()=>T(t.id):void 0,onDragEnd:s?B:void 0,onMouseEnter:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?i(m,{points:k,stroke:r,strokeWidth:a?3:2,fill:r,pointerLength:10,pointerWidth:8,opacity:A}):i(u,{points:k,closed:!0,fill:r+(a?y:v),stroke:r,strokeWidth:a?2.5:1.5,opacity:A}),t.label&&g.length>0?(()=>{let e=E({x:g.reduce((e,t)=>e+t.x,0)/g.length,y:g.reduce((e,t)=>e+t.y,0)/g.length},p.w,p.h),n=Math.max(40,t.label.length*11*.62);return i(f,{x:e.x-n/2,y:e.y-7,width:n,align:`center`,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),s&&!x&&g.map((e,a)=>{let o=E(e,p.w,p.h);return i(h,{x:o.x,y:o.y,radius:5,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h);w(e=>{let i=e&&e.itemId===t.id?e.points:n.points;return{itemId:t.id,points:i.map((e,t)=>t===a?r:e)}})},onDragEnd:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h),i=n.points.map((e,t)=>t===a?r:e);w({itemId:t.id,points:i}),C(t.id,M(i))},onContextMenu:e=>{e.evt.preventDefault(),e.cancelBubble=!0,V&&C(t.id,M(n.points.filter((e,t)=>t!==a)))}},`pt-${a}`)}),s&&!x&&H&&g.length>=2&&g.map((e,a)=>{let o=g[(a+1)%g.length],s=E({x:(e.x+o.x)/2,y:(e.y+o.y)/2},p.w,p.h);return i(h,{x:s.x,y:s.y,radius:4,fill:`#ffffff`,stroke:r,strokeWidth:1.5,opacity:.6,onMouseEnter:e=>{let t=e.target;t.to({radius:6,opacity:1,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=`copy`)},onMouseLeave:e=>{let t=e.target;t.to({radius:4,opacity:.6,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=l?`crosshair`:`default`)},onClick:e=>{e.cancelBubble=!0,C(t.id,M(j(n.points,a)))}},`mid-${a}`)})]})}var B=n(P);export{B as MaskShapeCanvas};
|
|
1
|
+
import{C as e,J as t,P 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{Aa as c}from"./player-overlays-BZByYYB8.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js";s();var _={rect:`#ef4444`,polygon:`#3b82f6`,grid:`#6366f1`,line:`#f59e0b`},v=`33`,y=`66`,b=`#6366f1`,x=3,S=2,C=12,w=16,T=9;function E(e,t,n){return{x:e.x*t,y:e.y*n}}function D(e,t,n){return{x:e.x/t,y:e.y/n}}function O(e,t,n){return e.flatMap(e=>[e.x*t,e.y*n])}function k(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function A(e){return e.color??_[e.shape.kind]}function j(e,t){let n=e[t],r=e[(t+1)%e.length];if(!n||!r)return[...e];let i={x:(n.x+r.x)/2,y:(n.y+r.y)/2};return[...e.slice(0,t+1),i,...e.slice(t+1)]}function M(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return Math.abs(e.x-r.x)<1e-6&&Math.abs(e.y-r.y)<1e-6}):!1}function N(e){return e.kind===`polygon`||e.kind===`line`}function P({items:n,selectedId:s,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=t(null),[H,ee]=o({w:800,h:450}),[U,W]=o([]),[G,K]=o(null),[te,ne]=o(null),[q,J]=o(null),Y=v!==null&&y.includes(v);a(()=>{if(!q)return;let e=n.find(e=>e.id===q.itemId);if(!e||!N(e.shape)){J(null);return}M(e.shape.points,q.points)&&J(null)},[n,q]),a(()=>{let e=V.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;ee(j?{w:n,h:r}:{w:n,h:n*9/16})});return t.observe(e),()=>t.disconnect()},[j]),a(()=>{!Y&&G!==null&&K(null)},[Y,G]);let X=r(e=>{m(e),W([])},[m]),re=r(e=>{if(!Y||v===null){f(null);return}let t=e.target.getStage();if(!t)return;let n=t.getPointerPosition();if(!n)return;let r=D(n,H.w,H.h);if(v===`rect`){let e=k(r.x),t=k(r.y);X({kind:`rect`,x:e,y:t,width:Math.min(.2,1-e),height:Math.min(.2,1-t)});return}if(v===`grid`){let e=I?.width??w,t=I?.height??T;X({kind:`grid`,gridWidth:e,gridHeight:t,cells:Array.from({length:e*t},()=>!1)});return}if(v===`line`){if(U.length===0){W([r]);return}X({kind:`line`,points:[...U,r]});return}if(v===`polygon`){if(U.length===0){W([r]);return}if(U.length>=x){let e=E(U[0],H.w,H.h);if(Math.hypot(n.x-e.x,n.y-e.y)<C){X({kind:`polygon`,points:U});return}}W(e=>[...e,r])}},[Y,v,U,H,I,X,f]),ie=r(e=>{!Y||v!==`polygon`||U.length<x||(e.cancelBubble=!0,X({kind:`polygon`,points:U}))},[Y,v,U,X]),Z=t(null),Q=t(null);a(()=>()=>{Z.current!==null&&cancelAnimationFrame(Z.current)},[]);let ae=r(e=>{if(!Y)return;let t=e.target.getStage();t&&(Q.current=t.getPointerPosition()??null,Z.current===null&&(Z.current=requestAnimationFrame(()=>{Z.current=null,K(Q.current)})))},[Y]),oe=t(!1),se=t(!0),ce=t(new Set),le=r((e,t,n,r)=>{let i=t.gridWidth*t.gridHeight;if(n<0||n>=i||t.cells[n]===r)return;let a=[...t.cells];for(;a.length<i;)a.push(!1);a.length=i,a[n]=r,p(e,{...t,cells:a})},[p]),$=[];if(!j){for(let e=1;e<w;e++){let t=H.w/w*e;$.push(i(u,{points:[t,0,t,H.h],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gv-${e}`))}for(let e=1;e<T;e++){let t=H.h/T*e;$.push(i(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return e(`div`,{ref:V,className:j?`absolute inset-0`:`relative w-full bg-zinc-900 rounded-lg overflow-hidden`,style:{cursor:Y?`crosshair`:`default`},children:[P&&!j?i(`div`,{className:`absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover`,style:{width:H.w,height:H.h},children:P}):null,e(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[e(g,{listening:!1,children:[i(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),i(g,{children:n.map(e=>{let t=e.id===s,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return i(L,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isDrawing:Y,size:H,onSelect:f,onShapeChange:p},e.id);if(e.shape.kind===`grid`)return i(R,{item:e,shape:e.shape,color:r,dimmed:n,editable:a,size:H,onSelect:f,paintingRef:oe,paintValueRef:se,paintedRef:ce,paintCell:le},e.id);let o=e.shape.kind===`line`,c=o?S:Math.max(x,F?.min??x),l=o?S:F?.max,u=q&&q.itemId===e.id?q.points:e.shape.points;return i(z,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isLine:o,isDrawing:Y,size:H,effectivePoints:u,minVertices:c,maxVertices:l,isDragging:te===e.id,onSelect:f,onShapeChange:p,setDragOverride:J,setDraggingItemId:ne},e.id)})}),i(g,{listening:!1,children:Y&&U.length>0&&e(d,{children:[v===`polygon`&&U.length>=2&&i(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&i(u,{points:[U[0].x*H.w,U[0].y*H.h,G.x,G.y],stroke:_.line,strokeWidth:1.5,dash:[6,3],opacity:.7}),v===`polygon`&&G&&U.length>=1&&i(u,{points:[U[U.length-1].x*H.w,U[U.length-1].y*H.h,G.x,G.y],stroke:b,strokeWidth:1,dash:[4,4],opacity:.5}),U.map((e,t)=>{let n=E(e,H.w,H.h),r=t===0&&v===`polygon`&&U.length>=x;return i(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?i(`div`,{className:`px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700`,children:v===`line`?B(`uiLibrary.maskShapeCanvas.hintLine`,`Click to set the start point, click again to complete the line`):v===`rect`?B(`uiLibrary.maskShapeCanvas.hintRect`,`Click to drop a rectangle, then drag the corner to resize`):v===`grid`?B(`uiLibrary.maskShapeCanvas.hintGrid`,`Click to add the grid, then paint cells`):U.length<x?B(`uiLibrary.maskShapeCanvas.hintPoints`,`Click to add points (min 3). Double-click or click the first point to close.`):B(`uiLibrary.maskShapeCanvas.hintMore`,`Continue adding points. Double-click or click the first point to close.`)}):null]})}var F=.02;function I(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.width-t.width)<1e-6&&Math.abs(e.height-t.height)<1e-6}function L({item:t,shape:n,color:r,selected:s,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=o(null),S={x:n.x,y:n.y,width:n.width,height:n.height};a(()=>{b&&I(S,b)&&x(null)},[n.x,n.y,n.width,n.height,b]);let C=b??S,w=C.x*m.w,T=C.y*m.h,E=C.width*m.w,D=C.height*m.h,O=c?.35:s?1:.85,A=e=>{x(e),_(t.id,{kind:`rect`,x:e.x,y:e.y,width:e.width,height:e.height})};return i(d,{onClick:e=>{e.cancelBubble=!0,u||g(t.id)},children:e(d,{draggable:l,dragBoundFunc:l?e=>({x:Math.max(-w,Math.min(m.w-(w+E),e.x)),y:Math.max(-T,Math.min(m.h-(T+D),e.y))}):void 0,onDragEnd:l?e=>{let t=e.target,n=t.x()/m.w,r=t.y()/m.h;if(t.position({x:0,y:0}),n===0&&r===0)return;let i=Math.min(Math.max(0,C.x+n),Math.max(0,1-C.width)),a=Math.min(Math.max(0,C.y+r),Math.max(0,1-C.height));A({...C,x:i,y:a})}:void 0,onMouseEnter:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=u?`crosshair`:`default`)},children:[i(p,{x:w,y:T,width:E,height:D,fill:r+(s?y:v),stroke:r,strokeWidth:s?2.5:1.5,opacity:O}),t.label?i(f,{x:w,y:T-16,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?i(h,{x:w+E,y:T+D,radius:6,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,dragBoundFunc:e=>({x:Math.min(m.w,Math.max(w,e.x)),y:Math.min(m.h,Math.max(T,e.y))}),onDragStart:e=>{e.cancelBubble=!0},onDragMove:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);x({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onDragEnd:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);A({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onMouseEnter:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`nwse-resize`)},onMouseLeave:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`default`)}}):null]})})}function R({item:e,shape:t,color:n,dimmed:r,editable:a,size:o,onSelect:s,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=o.w/m,v=o.h/h,b=m*h,x=r?.3:1,S=n=>{if(!a){s(e.id);return}let r=g[n]!==!0;c.current=!0,l.current=r,u.current=new Set([n]),f(e.id,t,n,r)},C=n=>{!c.current||!a||u.current.has(n)||(u.current.add(n),f(e.id,t,n,l.current))},w=()=>{c.current&&(c.current=!1,u.current=new Set)};return i(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,a=Math.floor(t/m),o=g[t]===!0;return i(p,{x:r*_,y:a*v,width:_,height:v,fill:o?n+y:`#ffffff10`,stroke:o?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:t,shape:n,color:r,selected:a,dimmed:o,editable:s,isLine:c,isDrawing:l,size:p,effectivePoints:g,minVertices:_,maxVertices:b,isDragging:x,onSelect:S,onShapeChange:C,setDragOverride:w,setDraggingItemId:T}){let k=O(g,p.w,p.h),A=o?.35:a?1:c?.8:.85,M=e=>c?{kind:`line`,points:[...e]}:{kind:`polygon`,points:[...e]},N=g.map(e=>e.x*p.w),P=g.map(e=>e.y*p.h),F=N.length>0?Math.min(...N):0,I=N.length>0?Math.max(...N):0,L=P.length>0?Math.min(...P):0,R=P.length>0?Math.max(...P):0,z=e=>({x:Math.max(-F,Math.min(p.w-I,e.x)),y:Math.max(-L,Math.min(p.h-R,e.y))}),B=e=>{let r=e.target,i=r.x()/p.w,a=r.y()/p.h;if(r.position({x:0,y:0}),T(null),i===0&&a===0)return;let o=n.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:t.id,points:o}),C(t.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return e(d,{onClick:e=>{e.cancelBubble=!0,l||S(t.id)},children:[e(d,{draggable:s,dragBoundFunc:s?z:void 0,onDragStart:s?()=>T(t.id):void 0,onDragEnd:s?B:void 0,onMouseEnter:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?i(m,{points:k,stroke:r,strokeWidth:a?3:2,fill:r,pointerLength:10,pointerWidth:8,opacity:A}):i(u,{points:k,closed:!0,fill:r+(a?y:v),stroke:r,strokeWidth:a?2.5:1.5,opacity:A}),t.label&&g.length>0?(()=>{let e=E({x:g.reduce((e,t)=>e+t.x,0)/g.length,y:g.reduce((e,t)=>e+t.y,0)/g.length},p.w,p.h),n=Math.max(40,t.label.length*11*.62);return i(f,{x:e.x-n/2,y:e.y-7,width:n,align:`center`,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),s&&!x&&g.map((e,a)=>{let o=E(e,p.w,p.h);return i(h,{x:o.x,y:o.y,radius:5,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h);w(e=>{let i=e&&e.itemId===t.id?e.points:n.points;return{itemId:t.id,points:i.map((e,t)=>t===a?r:e)}})},onDragEnd:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h),i=n.points.map((e,t)=>t===a?r:e);w({itemId:t.id,points:i}),C(t.id,M(i))},onContextMenu:e=>{e.evt.preventDefault(),e.cancelBubble=!0,V&&C(t.id,M(n.points.filter((e,t)=>t!==a)))}},`pt-${a}`)}),s&&!x&&H&&g.length>=2&&g.map((e,a)=>{let o=g[(a+1)%g.length],s=E({x:(e.x+o.x)/2,y:(e.y+o.y)/2},p.w,p.h);return i(h,{x:s.x,y:s.y,radius:4,fill:`#ffffff`,stroke:r,strokeWidth:1.5,opacity:.6,onMouseEnter:e=>{let t=e.target;t.to({radius:6,opacity:1,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=`copy`)},onMouseLeave:e=>{let t=e.target;t.to({radius:4,opacity:.6,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=l?`crosshair`:`default`)},onClick:e=>{e.cancelBubble=!0,C(t.id,M(j(n.points,a)))}},`mid-${a}`)})]})}var B=n(P);export{B as MaskShapeCanvas};
|
|
@@ -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 ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{
|
|
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 ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Aa as te,Da as c,Gr as l,K as u,U as ne,X as re,gt as d,n as f,z as p}from"./player-overlays-BZByYYB8.js";import{MaskShapeCanvas as m}from"./MaskShapeCanvas-C_kXMOhj.js";s();var ie=110,h=`motion-zones`,g=0,_=[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:s}){let w=te(),D=u(d().trpcClient,s),[O,k]=o(null),[A,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[I,L]=o(v),[R,z]=o(!1),[B,V]=o(!1),H=t(!1);a(()=>{if(!D)return;let e=!1;return H.current=!1,k(null),j(!1),N(null),F(null),L(v),V(!1),(async()=>{try{let t=await D.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(k(t),H.current)return;let n=await D.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);H.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);F(i),N(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;ne(t)?j(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[D]);let U=O?O.grid.width:0,W=O?O.grid.height:0,G=C(U,I),K=C(W,I),q=n(()=>M&&O?E(M,U,W,I):null,[M,O,U,W,I]),J=n(()=>q!==null&&P!==null&&!S(q,P),[q,P]),ae=n(()=>q?q.reduce((e,t)=>t?e+1:e,0):0,[q]),oe=U*W,Y=G*K,X=r(e=>{Y>0&&N(Array.from({length:Y},()=>e))},[Y]),se=r(()=>{N(e=>e&&e.map(e=>!e))},[]),Z=r(()=>{P&&O&&N(T(P,U,W,I))},[P,O,U,W,I]),ce=r(e=>{e===I||!O||N(t=>{if(!t)return L(e),t;let n=T(E(t,U,W,I),U,W,e);return L(e),n})},[I,O,U,W]),Q=n(()=>O&&M?[{id:g,shape:{kind:`grid`,gridWidth:G,gridHeight:K,cells:[...M]}}]:[],[O,M,G,K]),$=r((e,t)=>{t.kind===`grid`&&N(t.cells)},[]),le=r(async()=>{if(!(!D||!M||!O)){z(!0);try{let e=E(M,O.grid.width,O.grid.height,I),t={kind:`grid`,gridWidth:O.grid.width,gridHeight:O.grid.height,cells:e};await D.motionZones?.setZone({patch:{regions:[{id:g,enabled:!0,shape:t}]}});let n=await D.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],O.grid.width,O.grid.height);F(t),N(T(t,O.grid.width,O.grid.height,I))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{z(!1)}}},[D,M,O,I]);f(n(()=>B&&!A&&O&&M?{id:h,order:ie,node:i(m,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:G,height:K},selectedId:g,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[B,A,O,M,Q,$,G,K]));let ue=!A&&O!==null&&M!==null;return D?i(re,{title:w(`uiLibrary.motionZones.title`,`Motion Zones`),icon:i(l,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:i(`div`,{className:`flex flex-col gap-3`,children:A?i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ue?e(ee,{children:[i(`p`,{className:`${p} leading-relaxed`,children:i(c,{uiKey:`uiLibrary.motionZones.intro`,fallback:`Toggle <0>Edit grid</0> to paint the region directly on the live frame, then <1>Save</1> to push the mask to the camera. Pick a bigger <2>Cell size</2> for quicker, broad-stroke painting — it's resampled to the camera's native {{width}}×{{height}} grid on save (×1 is the finest).`,components:[i(`strong`,{className:`text-foreground`},`e`),i(`strong`,{className:`text-foreground`},`s`),i(`strong`,{className:`text-foreground`},`c`)],values:{width:O.grid.width,height:O.grid.height}})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:()=>V(e=>!e),disabled:R,"aria-pressed":B,className:B?b:y,children:B?w(`uiLibrary.motionZones.doneEditing`,`Done editing`):w(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),i(`button`,{type:`button`,onClick:()=>X(!0),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOn`,`All on`)}),i(`button`,{type:`button`,onClick:()=>X(!1),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOff`,`All off`)}),i(`button`,{type:`button`,onClick:se,disabled:R,className:y,children:w(`uiLibrary.motionZones.invert`,`Invert`)}),e(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":w(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[i(`span`,{className:`${p} mr-0.5`,children:w(`uiLibrary.motionZones.cellSize`,`Cell size`)}),_.map(t=>e(`button`,{type:`button`,onClick:()=>ce(t),disabled:R,"aria-pressed":I===t,title:t===1?w(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:U,height:W}):w(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:C(U,t),height:C(W,t),factor:t}),className:I===t?b:y,children:[`×`,t]},t))]}),e(`span`,{className:`${p} ml-1 tabular-nums`,children:[w(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:ae,total:oe,width:O.grid.width,height:O.grid.height}),I===1?``:w(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:G,height:K})]}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Z,disabled:R||!J,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:w(`uiLibrary.motionZones.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void le(),disabled:R||!J,className:b,children:R?w(`uiLibrary.motionZones.saving`,`Saving…`):w(`uiLibrary.motionZones.save`,`Save`)})]})]}):i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{D as MotionZonesSettings};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./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-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Aa as f,Cn as p,Fi as m,Kt as h,Nr as g,Or as _,Pi as v,Q as y,Sr as b,Tr as x,Yt as S,_i as C,ct as w,da as T,er as E,gt as D,pn as O,ri as k,ut as A}from"./player-overlays-BZByYYB8.js";import{_i as j,gi as M}from"./client-mnldOm50.js";import{c as N,f as ee}from"./video-BV-3O_ZC.js";import{t as te}from"./monitor-smartphone-DPI9EQus.js";import{t as ne}from"./unlink-D3-IGpS8.js";import{Fn as re,Fr as ie,Ht as ae,Nf as P,Pr as oe,_c as F,af as I,ji as L,pi as R,yc as se}from"./src-DKRp5NPI.js";import{t as ce}from"./i18n-ByFr51sS.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-CLxwtH6P.js";import{c as le,i as ue,l as B,s as V}from"./sso-popup-CcJP5NlL.js";import{Br as H,Hr as U,I as W,Kr as de,n as G}from"./index-D5GcZJtC.js";import{t as fe}from"./AdminSectionedPage-Xr_hesYw.js";import{t as pe}from"./AdminPage-_ITsYONa.js";import{D as me,O as he,_ as ge,a as _e,h as ve,r as ye,t as K,w as be}from"./SessionsList-WhsG7RxJ.js";l();var xe=`${M}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function Se(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function J(e){return j(e)}function Ce(e){return e.startsWith(`https://`)}function we(e){let t=e.flatMap(e=>{let t=Se(e),n=J(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>q[e.tier]-q[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:Ce(r),plausible:e.plausible}]))}function Te(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=J(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function Ee(e){let t=new URL(xe);return t.searchParams.set(`hub`,e),t.toString()}var De=176,Y={scheme:`https`};function Oe(){let{t:e}=z(),t=se(Y),r=F(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(O,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(h,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(L,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(ke,{candidates:we(t.data.endpoints),preferredOrigin:r})]})]})}function ke({candidates:e,preferredOrigin:t}){let{t:r}=z(),[o,c]=s(null),l=Te(e,o,t),u=i(()=>l?Ee(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(oe,{value:u,size:De,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(A,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(re,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(h,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function Ae(e){return new Date(e).toLocaleDateString()}function je(){let{t:e}=z(),t=w(),i=P.useUtils(),c=P.auth.listLinkableProviders.useQuery(),l=P.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,p]=s(()=>B(window.location.search)),h=r(null),g=G(`Linking a sign-in account`),b=r(null);o(()=>()=>b.current?.(),[]);let[S,C]=s(null);o(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let T=P.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=h.current;if(h.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{C(null),p(B(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};b.current?.(),b.current=V(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{b.current?.(),b.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=y(le(e))},onError:e=>{h.current?.close(),h.current=null,C(null),d(e.message)}}),E=P.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),D=c.data??[],O=l.data??[],k=S!==null&&O.some(e=>e.provider===S);if(o(()=>{!k||S===null||(C(null),p({kind:`linked`,provider:S}))},[k,S]),D.length===0&&O.length===0)return null;let A=new Set(O.map(e=>e.provider)),j=e=>D.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),E.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[g.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(v,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(m,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),O.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:O.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ae(t.linkedAt)})})]}),n(L,{variant:`unstyled`,onClick:()=>void M(t,r),disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(ne,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:D.filter(e=>!A.has(e.provider)).map(t=>n(L,{variant:`unstyled`,onClick:()=>{d(null),p(null),g.requestProof().then(e=>{e!==null&&(h.current=ue(null),C(h.current===null?null:t.provider),T.mutate({provider:t.provider,reauthToken:e}))})},disabled:T.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[T.isPending&&T.variables?.provider===t.provider?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function Me({value:r,size:i=192}){let{t:c}=z(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Ne(){let{t:e}=z(),t=D(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,p]=s(null),h=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=o.length>0&&l.length>0&&o!==l,_=o.length>0&&o.length<8,y=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(g||_)&&a(`div`,{className:`text-[11px] text-danger`,children:g?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(v,{className:`h-3 w-3`}):a(m,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{p(null),h.mutate({currentPassword:r,newPassword:o})},disabled:!y||h.isPending,children:[h.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(b,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(I,{type:`password`,value:t,onChange:e=>r(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`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Pe({username:e}){let{t}=z(),r=D(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),f=l.data,[p,h]=s(null),[g,_]=s(``),[y,b]=s(null),[S,w]=s(!1),T=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{h({secret:e.secret,otpauthUrl:e.otpauthUrl}),_(``),b(null)},onError:e=>b(e instanceof Error?e.message:`Setup failed`)}),E=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{h(null),_(``),b(null),l.refetch()},onError:e=>b(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{b(null),l.refetch()},onError:e=>b(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!S)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[S]);let j=i(()=>l.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,p]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(O,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{b(null),T.mutate()},disabled:T.isPending,children:[T.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(O,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&p&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(H,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(Me,{value:p.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),n(L,{variant:`ghost`,onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},children:[S?a(v,{className:`h-3 w-3 text-success`}):a(C,{className:`h-3 w-3`}),S?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(I,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:g,onChange:e=>_(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&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(m,{className:`h-3 w-3`}),y]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(L,{variant:`outline`,onClick:()=>{h(null),b(null),_(``)},children:t(`common.cancel`,`Cancel`)}),n(L,{onClick:()=>{b(null),E.mutate({code:g})},disabled:E.isPending||g.length!==6,children:[E.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(v,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(v,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(m,{className:`h-3 w-3`}),y]}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`danger`,onClick:()=>{b(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(O,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Fe(){return R(`auth-webauthn/passkey-enrollment`)?a(ie,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Ie(){let{t:e}=z(),{logout:t}=W(),r=w(),i=P.useUtils(),o=P.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=P.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=P.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ge(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`unstyled`,onClick:()=>void p(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(N,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Le=`You`;function Re(){let{t:e}=z(),t=w(),n=P.useUtils(),r=P.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=P.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ye(e,Le)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:T,isAvailable:_e,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(me,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:O,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:he(o),onDismissNotice:()=>c(null),children:a(be,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},ze=[`linked`,`linkError`],Be={view:{icon:k,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:E,cls:`bg-primary/15 text-primary`},delete:{icon:S,cls:`bg-danger/15 text-danger`}};function Ve(){let{t:e}=z(),{user:t,logout:r}=W(),[i]=de(),o=e(`system.myAccess`,`My access`);if(!t)return a(pe,{icon:p,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(i.get(`tab`)===`preferences`)return a(U,{to:`/system/settings`,replace:!0});if(ze.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(U,{to:`?${e.toString()}`,replace:!0})}return a(fe,{icon:p,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(L,{variant:`outline`,onClick:r,children:[a(N,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(He,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Ne,{}),a(Pe,{username:t.username}),a(Fe,{}),a(je,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Ie,{}),a(Re,{}),a(Oe,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ve,{ownOnly:!0})}]})}function He({user:e}){let{t}=z(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`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()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(H,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`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:[a(g,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(Ue,{scopes:i})]})}function Ue({scopes:e}){let{t}=z(),r=f();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`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:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ae(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=Be[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Ve as MyAccessPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as l,Dn as u,Et as d,In as f,Jn as p,Kt as m,L as h,Sa as g,Sn as _,Sr as v,St as y,Tr as b,Vi as x,Yn as S,Yt as C,Z as w,_i as T,ai as E,cn as D,gt as O,ir as k,jn as ee,un as te,ut as ne,zn as re}from"./player-overlays-BZByYYB8.js";import{hi as ie,mi as ae,ni as oe,pi as A}from"./client-mnldOm50.js";import{t as se}from"./boxes-k5PsZ3NR.js";import{c as ce,l as le,p as j}from"./video-BV-3O_ZC.js";import{Bn as ue,Ci as de,Dc as fe,Dr as pe,Fc as me,Gr as he,Hc as ge,Ic as _e,Ko as ve,Lc as ye,Oc as be,Pc as xe,Rc as Se,Rn as Ce,Sc as we,Tc as Te,Ti as M,Uc as Ee,Un as N,Vc as De,Vn as Oe,_c as ke,af as P,gc as Ae,ji as F,of as I,vc as je,wc as Me}from"./src-DKRp5NPI.js";import{t as L}from"./i18n-ByFr51sS.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-CLxwtH6P.js";import{Hr as Ne,Kr as Pe,Vr as Fe,a as z,i as B,x as Ie}from"./index-D5GcZJtC.js";import{t as Le}from"./AdminSectionedPage-Xr_hesYw.js";import{t as V}from"./AdminPage-_ITsYONa.js";import{r as H,t as U}from"./InstancesTable-BagVOERb.js";import{t as Re}from"./useInvalidateAddonSettings-CyofQfBo.js";o();var ze=5e3,Be=`network-access`,Ve={connected:!1,endpoint:null};function He(){let{t:e}=R(),t=s(),[n,i]=a(null),[o,c]=a({}),l=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),i(null),c(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},u=(e,t)=>{i(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);c(e=>({...e,[n]:r}))},d=ge({onSuccess:l,onError:u}),f=Ee({onSuccess:l,onError:u}),p={key:`tunnel`,header:e(`system.remoteAccess.colTunnel`,`Tunnel`),notSortableReason:e(`system.remoteAccess.tunnelNotSortable`,`A live connection state is not a value to order by.`),render:e=>r(Ue,{addonId:e.addonId,error:o[e.addonId]})},m=e=>r(We,{addonId:e,busyId:n,onStart:e=>{i(e),d.mutate({addonId:e})},onStop:e=>{i(e),f.mutate({addonId:e})}});return r(U,{functionCap:Be,icon:j,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`),addLabel:e(`system.remoteAccess.addTunnel`,`Add tunnel`),extraColumns:[p],rowActions:e=>m(e.addonId),fixedRowActions:e=>m(e.addonId)})}function W(e){let{data:t}=De({addonId:e},{refetchInterval:ze,retry:!1}),n=t?oe.safeParse(t):null;return n?.success?n.data:Ve}function Ue({addonId:t,error:n}){let{t:i}=R(),a=W(t);return e(`span`,{className:`flex flex-col items-start gap-1`,children:[r(M,{variant:a.connected?`success`:`default`,className:H,children:a.connected?i(`system.remoteAccess.connected`,`Connected`):i(`system.remoteAccess.disconnected`,`Disconnected`)}),a.endpoint&&e(`a`,{href:a.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[r(E,{className:`h-3 w-3`}),a.endpoint.url]}),n!==void 0&&r(`span`,{role:`alert`,className:`text-xs text-danger`,children:n})]})}function We({addonId:e,busyId:t,onStart:n,onStop:i}){let{t:a}=R(),o=W(e),s=t===e;return o.connected?r(I,{icon:s?b:D,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.stop`,`Stop`),disabled:s,onClick:()=>i(e)}):r(I,{icon:s?b:S,variant:`ghost`,size:`sm`,"aria-label":a(`system.remoteAccess.start`,`Start`),disabled:s,onClick:()=>n(e)})}function Ge(){let{t:e}=R();return r(U,{functionCap:`turn-provider`,icon:k,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),addLabel:e(`system.turnServers.addProvider`,`Add provider`)})}o();var Ke={lan:k,wifi:d,docker:se,vpn:v,loopback:u,other:u},qe={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Je=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Ye(n){let{t:i}=R(),{interfaces:a,disabled:o,hideLoopback:s,ipv4Only:c,emptyMessage:l}=n,d=t(()=>a.filter(e=>!(s&&e.kind===`loopback`||c&&e.family!==`IPv4`)),[a,s,c]),f=t(()=>{let e=new Map;for(let t of d){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Je.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[d]),p=e=>n.mode===`single`?n.value===e:n.value.includes(e),h=e=>{if(o||e.kind===`loopback`)return;if(n.mode===`single`){n.onChange(n.value===e.address?null:e.address);return}let t=new Set(n.value);t.has(e.address)?t.delete(e.address):t.add(e.address),n.onChange([...t])};return d.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??i(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):r(`div`,{className:`flex flex-col gap-3`,children:f.map(({kind:t,items:a})=>e(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[r(Ke[t]??u,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:qe[t]??t}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,a.length]})]}),r(`ul`,{className:`divide-y divide-border`,children:a.map(t=>{let a=p(t.address),s=t.kind===`loopback`,c=!t.plausible&&!s;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 ${s?`opacity-60 cursor-not-allowed`:o?`opacity-60`:c?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>h(t),children:[r(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${n.mode===`single`?`rounded-full`:`rounded`} border ${a?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:a&&r(x,{className:`h-3 w-3`})}),e(`div`,{className:`flex-1 min-w-0 ${c?`text-foreground-subtle`:``}`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[r(`span`,{className:`font-mono text-xs font-semibold ${c?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),r(`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&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:i(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),s&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:i(`shared.addressSelector.alwaysIncluded`,`Always included`)}),c&&e(`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:[r(m,{className:`h-2.5 w-2.5`}),i(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),e(`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))})}var G=[{role:`appConnections`,get title(){return L.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return L.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return L.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return L.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return L.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.internalHelp`)}}],Xe=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function K(e,t){return e.inUse.includes(t)}function Ze(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return K(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&K(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:ae}:{kind:`set`,input:n}}function Qe(e){return G.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}o();var q={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function $e({book:t,loading:n,saving:i,error:o,onSetRole:s,onAdd:c,onRemove:l}){let{t:u}=R(),[d,f]=a(``),[h,_]=a(``),[v,y]=a(null),[b,x]=a(null),S=()=>{let e=ie(d);if(!e.ok){y(e.reason);return}y(null),f(``),_(``),c(e.baseUrl,h.trim())},w=(e,t)=>{let n=Ze(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){x({input:n.input,reason:n.reason});return}x(null),s(n.input)}},T=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:n=>e(`div`,{className:`min-w-0 py-0.5`,children:[r(`div`,{className:`font-mono text-[12px] break-all ${n.plausible?`text-foreground`:`text-foreground-subtle`}`,children:n.baseUrl}),e(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:n.label}),n.kind===`app-link`&&e(`span`,{className:`font-mono`,children:[`hub=`,` `,t?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),n.custom&&n.detected&&r(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),n.kind!==`custom`&&n.interfaceKind!==`lan`&&n.interfaceKind!==`public`&&n.interfaceKind!==`other`&&r(`span`,{className:`uppercase tracking-wide`,children:n.interfaceKind}),!n.plausible&&n.interfaceKind!==`loopback`&&e(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[r(m,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=q[e.kind]??q.loopback;return r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...G.map(t=>({key:t.role,headerRender:()=>r(`span`,{title:t.help,children:t.title}),align:`center`,nowrap:!0,width:`w-24`,render:n=>{let a=n.eligible.includes(t.role),o=n.flags.includes(t.role),s=K(n,t.role);return e(`label`,{className:`inline-flex items-center justify-center gap-1 ${a?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:a?s&&!o?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:t.title,help:t.help}):t.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[r(g,{checked:a&&s,disabled:!a||i,onChange:()=>w(n,t),"aria-label":`${t.title}: ${n.baseUrl}`}),s&&!o&&a&&r(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?r(F,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:r(C,{className:`h-3 w-3`})}):null}],E=t===void 0?[]:Qe(t);return e(he,{children:[e(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[e(`div`,{children:[r(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),r(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),e(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[r(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),r(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:G.map(t=>e(`div`,{className:`contents`,children:[r(`dt`,{className:`font-medium`,children:t.title}),r(`dd`,{className:`text-foreground-subtle`,children:t.help})]},t.role))}),r(`p`,{className:`mt-1.5 text-foreground-subtle`,children:Xe})]})]}),E.length>0&&r(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:E.map(t=>e(`div`,{className:`contents`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.title}),e(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${t.role}`,children:[t.inUse,r(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:t.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),t.automatic?r(`span`,{}):r(F,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>s({role:t.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},t.role))}),b!==null&&e(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[r(m,{className:`h-3.5 w-3.5 text-amber-600`}),r(`span`,{className:`flex-1 min-w-[220px]`,children:b.reason}),r(F,{size:`sm`,variant:`secondary`,onClick:()=>{s({...b.input,acceptInsecureHttp:!0}),x(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),r(F,{size:`sm`,variant:`ghost`,onClick:()=>x(null),children:u(`common.cancel`,`Cancel`)})]}),o!==null&&r(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:o})]}),r(N,{columns:T,rows:t?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:n?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),e(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[e(`div`,{className:`flex-1 min-w-[220px]`,children:[r(P,{value:d,onChange:e=>{f(e.target.value),y(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:i}),v!==null&&r(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:v})]}),r(`div`,{className:`w-48`,children:r(P,{value:h,onChange:e=>_(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:i})}),e(F,{size:`sm`,variant:`secondary`,disabled:i||d.trim()===``,onClick:S,children:[r(p,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}o();function et(){let{t:n}=R(),o=s(),c=()=>{o.invalidateQueries({queryKey:[[`localNetwork`]]})},u=we(void 0,{refetchInterval:3e4}),d=je(void 0),p=be({onSuccess:c}),m=Te({onSuccess:e=>{C(e.addresses),c()}}),h=t(()=>u.data?.interfaces??[],[u.data]),g=ke({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),_=fe({onSuccess:c}),v=Ae({onSuccess:c}),y=Me({onSuccess:c}),b=_.error?.message??v.error?.message??y.error?.message??null,x=_.isPending||v.isPending||y.isPending,[S,C]=a([]),[w,T]=a(!1);i(()=>{!w&&d.data&&(C(d.data.addresses),T(!0))},[d.data,w]);let E=d.data?.addresses??[],D=t(()=>{if(S.length!==E.length)return!0;let e=[...S].toSorted(),t=[...E].toSorted();return e.some((e,n)=>e!==t[n])},[S,E]);return e(V,{embedded:!0,children:[e(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[r(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:n(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),r(`div`,{className:`flex items-center gap-2 shrink-0`,children:e(F,{size:`sm`,variant:`secondary`,onClick:()=>{u.refetch(),d.refetch(),g.refetch()},disabled:u.isLoading,children:[r(re,{className:`h-3 w-3 ${u.isLoading?`animate-spin`:``}`}),n(`common.refresh`,`Refresh`)]})})]}),r(Oe,{headingId:`network-allowed-addresses`,title:n(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e(F,{size:`sm`,variant:`secondary`,onClick:()=>m.mutate(void 0),disabled:m.isPending||p.isPending,title:n(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[r(te,{className:`h-3 w-3`}),m.isPending?n(`system.networkAddresses.detecting`,`Detecting…`):n(`system.networkAddresses.bestMatch`,`Best match`)]}),e(F,{size:`sm`,variant:`secondary`,onClick:()=>{C([])},disabled:S.length===0||p.isPending,children:[r(f,{className:`h-3 w-3`}),n(`system.networkAddresses.clear`,`Clear`)]}),D&&r(F,{size:`sm`,variant:`secondary`,onClick:()=>{C(E)},disabled:p.isPending,children:n(`system.networkAddresses.discard`,`Discard`)}),e(F,{size:`sm`,variant:`primary`,onClick:()=>{p.mutate({addresses:[...S]})},disabled:!D||p.isPending,children:[r(ee,{className:`h-3 w-3`}),p.isPending?n(`system.networkAddresses.saving`,`Saving…`):n(`common.save`,`Save`)]})]}),children:e(`div`,{className:l,children:[r(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:S.length===0?n(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):n(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(S.length)})}),r(Ye,{mode:`multiple`,interfaces:h,value:S,onChange:C,disabled:p.isPending,emptyMessage:u.isLoading?n(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):n(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),r($e,{book:g.data,loading:g.isLoading,saving:x,error:b,onSetRole:e=>_.mutate({...e}),onAdd:(e,t)=>v.mutate({baseUrl:e,label:t}),onRemove:e=>y.mutate({baseUrl:e})})]})}var tt=5e3,nt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function J(e){let{data:t,isLoading:n}=xe({addonId:e},{refetchInterval:tt,retry:!1}),r=t?A.safeParse(t):null;return{status:r?.success?r.data:nt,isLoading:n}}function Y({addonId:t}){let{t:n}=R(),{status:i}=J(t);return e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[r(M,{variant:i.joined?`success`:`default`,className:H,children:i.joined?n(`system.meshNetworks.joined`,`Joined`):n(`system.meshNetworks.notJoined`,`Not joined`)}),i.joined&&r(M,{className:`text-[10px]`,children:n(`common.peers`,{count:i.peerCount})}),i.error!==void 0&&r(M,{variant:`danger`,className:`text-[10px]`,title:i.error,children:n(`system.meshNetworks.error`,`Error`)})]})}o();function rt({addonId:t}){return e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(Y,{addonId:t}),r(it,{addonId:t})]})}function it({addonId:t}){let{t:i}=R(),o=s(),[l,u]=a(!1),[d,f]=a(null),p=O(),{status:m}=J(t),h=n(()=>{o.invalidateQueries({queryKey:[[`meshNetwork`]]})},[o]),g=Se(),v=me({onSuccess:h}),x=ye({onSuccess:h}),S=n(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await g.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await at(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?A.safeParse(e):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,h,g,p]),C=n(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return r(c,{children:m.joined?e(c,{children:[e(F,{size:`sm`,variant:`secondary`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(b,{className:`h-3 w-3 animate-spin`}):r(ce,{className:`h-3 w-3`}),i(`system.meshNetworks.disconnect`,`Disconnect`)]}),e(F,{size:`sm`,variant:`ghost`,disabled:x.isPending,onClick:()=>x.mutate({addonId:t}),children:[x.isPending?r(b,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]}):l?e(F,{size:`sm`,variant:`ghost`,onClick:C,children:[r(y,{className:`h-3 w-3 mr-1`}),` `,i(`common.cancel`)]}):e(c,{children:[e(F,{size:`sm`,variant:`primary`,onClick:()=>void S(),children:[r(le,{className:`h-3 w-3`}),i(`system.meshNetworks.connect`,`Connect`)]}),e(F,{size:`sm`,variant:`ghost`,disabled:x.isPending,onClick:()=>x.mutate({addonId:t}),children:[x.isPending?r(b,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]})})}function at(e){return new Promise(t=>setTimeout(t,e))}o();var ot={mesh:`bg-info/15 text-info`,public:`bg-primary/15 text-primary`},st=3e4;function ct({addonId:t}){let{t:n}=R(),{status:i}=J(t),a=_e({addonId:t},{refetchInterval:st,retry:!1});return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[i.error&&r(de,{message:i.error}),r(lt,{status:i}),i.endpoints.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:n(`system.meshNetworks.endpoints`,`Endpoints`)}),i.endpoints.map(t=>e(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[e(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${ot[t.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[t.scope===`public`?r(j,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,t.label]}),e(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-success hover:underline break-all flex items-center gap-1`,children:[r(E,{className:`h-3 w-3 shrink-0`}),t.url]})]},t.id))]})]}),r(`div`,{className:`border-t border-border`,children:r(dt,{peers:a.data?.peers??[],loading:a.isLoading})})]})}function lt({status:t}){let{t:n}=R();return r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:n(`system.meshNetworks.tenant`,`Tenant`),value:t.tenantName||`—`},{label:n(`system.meshNetworks.user`,`User`),value:t.userLogin??`—`},{label:n(`system.meshNetworks.controlPlane`,`Control plane`),value:t.controlPlaneUrl||`—`},{label:n(`system.meshNetworks.meshIp`,`Mesh IP`),value:t.meshIp||`—`,mono:!0},{label:n(`system.meshNetworks.magicdns`,`MagicDNS`),value:t.magicDnsHostname||`—`,mono:!0},{label:n(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:t.magicDnsSuffix||`—`,mono:!0},{label:n(`system.meshNetworks.peers`,`Peers`),value:String(t.peerCount)},{label:n(`system.meshNetworks.keyExpiry`,`Key expiry`),value:t.keyExpiry?ut(t.keyExpiry):`—`}].map(t=>e(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[r(`span`,{className:`text-foreground-subtle shrink-0`,children:t.label}),r(`span`,{className:`text-foreground truncate ${t.mono?`font-mono`:``}`,children:t.value})]},t.label))})}function ut(e){let t=e-Date.now();if(t<0)return L.t(`system.meshNetworks.expiredAgo`,{when:Z(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return L.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?L.t(`system.meshNetworks.expiryHours`,{count:r}):L.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function dt({peers:i,loading:a}){let{t:o}=R(),s=t(()=>i.map(e=>({...e,_id:e.id})),[i]),c=n(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=t(()=>[{key:`hostname`,header:o(`system.meshNetworks.hostname`,`Hostname`),render:t=>e(`div`,{className:`flex flex-col`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.hostname||o(`system.meshNetworks.unknown`,`(unknown)`)}),t.isSelf&&r(M,{variant:`info`,children:o(`common.self`)}),t.exitNodeOption&&r(M,{variant:`warning`,children:`exit-node`})]}),t.userLogin&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:t.userLogin})]})},{key:`magicDns`,header:o(`system.meshNetworks.magicdns`,`MagicDNS`),render:t=>t.magicDns?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs truncate`,children:t.magicDns}),r(F,{variant:`unstyled`,onClick:()=>c(t.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:r(T,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:t=>{let n=t.addresses[0]??``;return n?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs`,children:n}),r(F,{variant:`unstyled`,onClick:()=>c(n),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyIp`,`Copy IP`),children:r(T,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:o(`system.meshNetworks.connection`,`Connection`),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(M,{variant:ft(t.connection),children:t.connection}),t.relay&&r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:t.relay})]})},{key:`routes`,header:o(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?r(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:o(`system.meshNetworks.txRx`,`TX / RX`),render:t=>e(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,X(t.txBytes),` · ↓ `,X(t.rxBytes)]})},{key:`lastSeen`,header:o(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Z(e.lastSeenMs):`—`})}],[c,o]);return a&&i.length===0?e(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[r(b,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,o(`systemPage.meshNetworks.loadingPeers`)]}):i.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:o(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):r(`div`,{className:`p-4`,children:r(N,{columns:l,rows:s,rowKey:e=>e._id,minWidthPx:820})})}function ft(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function X(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 Z(e){let t=Date.now()-e;return t<6e4?L.t(`system.meshNetworks.justNow`):t<36e5?L.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?L.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):L.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}var Q=`mesh-network`;function pt(){let{t}=R();return r(U,{functionCap:Q,icon:k,title:t(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:t(`system.meshNetworks.privateVpnMeshesThatConnect`,`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).`),emptyTitle:t(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:t(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`),addLabel:t(`system.meshNetworks.addMesh`,`Add mesh`),install:{capability:Q,label:t(`system.meshNetworks.addMesh`,`Add mesh`)},extraColumns:[{key:`mesh-state`,header:t(`system.meshNetworks.connectionState`,`Mesh`),notSortableReason:t(`system.meshNetworks.connectionStateNotSortable`,`Live state of the tailnet, not a stored value.`),render:e=>r(Y,{addonId:e.addonId})}],lead:t=>e(`div`,{className:`flex flex-col gap-3`,children:[r(rt,{addonId:t.addonId}),r(ct,{addonId:t.addonId})]})})}var $=`/system/identity?tab=certificates`;function mt(){let{t}=R(),n=O(),i=Re();return r(V,{embedded:!0,children:e(`div`,{className:h,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),r(pe,{trpc:n.trpcClient,addonId:`local-network`,cap:`local-network`,scope:`node`,nodeId:`hub`,onAfterChange:i,title:t(`system.localAccess.lanHttp`,`LAN HTTP`)}),e(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[t(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,r(Fe,{className:`underline`,to:$,children:t(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}o();function ht({value:n,onChange:i}){let{t:a}=R(),{data:o}=ve({isCamera:!0,projection:`slim`}),s=t(()=>o===void 0?[{value:``,label:a(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:o.length===0?[{value:``,label:a(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:a(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...o.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[o,a]);return e(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.networkDiagnostics.camera`,`Camera`)}),r(ne,{value:n===null?``:String(n),disabled:o===void 0||o.length===0,onChange:e=>i(e.target.value===``?null:Number(e.target.value)),options:s})]})}function gt(){let t=O(),[i,o]=a(null);return r(V,{embedded:!0,children:e(`div`,{className:h,"data-testid":`network-diagnostics`,children:[r(ue,{loadServers:n(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),r(Ce,{trpc:t.trpcClient,serverUrl:w(),deviceId:i,cameraField:r(ht,{value:i,onChange:o})})]})})}var _t=[`certificate`,`certificates`,`https`];function vt(){let{t:e}=R(),[t]=Pe();if(_t.includes(t.get(`tab`)??``))return r(Ne,{to:$,replace:!0});let n=Ie(`/system/network`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.network`,`Network`)};return r(Le,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:r(mt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:r(et,{})},{id:z.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:r(He,{}),ownedParams:B},{id:z.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:r(pt,{}),ownedParams:B},{id:z.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:r(Ge,{}),ownedParams:B},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:r(gt,{})}]})}export{vt as NetworkPage};
|
package/dist/assets/{NodeAddonsSettingsPanel-DY9KrknX.js → NodeAddonsSettingsPanel-BtSyXQ4v.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{gt as m}from"./player-overlays-DS6dT7SD.js";import{Fs as h,Ps as g}from"./client-DtixJSIH.js";import{Ia as _,aa as v,bo as y,ha as ee,ia as te,jt as ne,zi as b}from"./src-D1sUPCi1.js";import{t as re}from"./useTranslation-BJr-n0es.js";import{F as x,N as ie,P as ae,ut as S}from"./index-IUYaCNr3.js";c();var C=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(S,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function oe(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function D(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function se(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!D(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function ce(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of h({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function le(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}function ue(e,t){let n=e??`general`;return t?.[n]??n}function O(e){return typeof e!=`object`||!e||!(`key`in e)?null:typeof e.key==`string`?e.key:null}function k(e,t){let n=t.fieldKeys===void 0?null:new Set(t.fieldKeys),r=[];for(let i of e){let e=n===null?i.fields:i.fields.filter(e=>{let t=O(e);return t!==null&&n.has(t)});e.length!==0&&r.push({...i,fields:e,...t.tabAliases===void 0?{}:{tab:ue(i.tab,t.tabAliases)},...t.hideSectionChrome===!0?{title:``,description:void 0}:{}})}return r}c();function A(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>A(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function j(e,t){return{...e,fields:e.fields.map(e=>A(e,t))}}function de(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>j(e,t))},values:t}}function M({nodeId:a,addonIds:o,level:c,deviceId:u,capability:h,sectionIds:b,omitSectionIds:x,fieldKeys:S,hideSectionChrome:C,tabAliases:w,tabLabelOverrides:T,sectionTab:E,fieldScope:D,emptyMessage:O,extraTabs:A,schemaTabExtras:j,title:M,description:N,selfTabbed:pe,activeTab:me,onActiveTabChange:he}){let{t:P}=re(),F=d(),I=m().trpcClient,ge=v(),_e=te(),ve=y(),ye=_(),L=pe===!0||!!(A&&A.length>0),[be,xe]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let R=a??`hub`,z=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:R,deviceId:u??null,cap:h??null,scope:D??null,sections:[b??null,x??null]}],queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:R});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=se({declarations:t,...D===void 0?{}:{fieldScope:D},...h===void 0?{}:{capability:h},...b===void 0?{}:{allowSectionIds:b},...x===void 0?{}:{omitSectionIds:x}}),r=await Promise.all(n.map(async t=>{let n=await I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{}});return n===null?null:{declaration:t,form:n}})),i=r.filter(e=>e!==null);if(i.length!==r.length)return{addonId:e,result:null,keyTargets:{}};let a=ce(i);return{addonId:e,result:a.form,keyTargets:a.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:R});return{addonId:e,result:t!==null&&D!==void 0?oe(t,D):t,keyTargets:{}}},placeholderData:f}))}),Se=z.some(e=>e.isLoading),B=z.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),V=n(()=>{let e=new Set;for(let t of z){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(ue(t.tab,w))}return[...e]},[w,B+`::`+z.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),H=n(()=>new Map((A??[]).map(e=>[e.id,e])),[A]),U=n(()=>{if(!L)return[];let e=[...new Set([...V,...(A??[]).map(e=>e.id),...(j??[]).map(e=>e.tabId)])],t=e=>{let t=H.get(e);if(t?.order!==void 0)return t.order;let n=g[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[L,V,A,H,j]),Ce=n(()=>{let e=new Map,t=e=>g[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of V)e.set(n,t(n));for(let n of j??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of A??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(T??{}))e.set(t,n);return e},[V,A,j,T]),W=me===void 0?be:me,G=L?W&&U.includes(W)?W:U[0]??null:null,we=e=>{xe(e),he?.(e)},Te=G!==null&&H.has(G),K=L?G&&!Te?G:void 0:E,{data:Ee}=ee(void 0),De=n(()=>{let e=new Map;for(let t of Ee??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Ee]),q=t(new Map),J=n(()=>{let e=b?new Set(b):null,t=x?new Set(x):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of z){if(!e.data)continue;e.data.result!==null&&q.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=q.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=de(i),c={...S===void 0?{}:{fieldKeys:S},...C===void 0?{}:{hideSectionChrome:C},...w===void 0?{}:{tabAliases:w}},l=k(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:k(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[B,b,x,S,C,w]),Oe=n(()=>z.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!q.current.has(e.data.addonId)?[e.data.addonId]:[]),[B,c]),[Y,ke]=s(new Map),Ae=r(e=>{ke(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=t(new Map),je=r(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=r(async(e,t)=>{if(c!==`global`){await _e.mutateAsync({addonId:e,deviceId:u,nodeId:R,patch:t});return}let{groups:n,unowned:r}=le(t,J.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>ge.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,J,ge,_e,F,R,u]),Me=r(async(e,t)=>{await Z(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Z,F]),Ne=r(async(e,t,n,r)=>{let i=R;try{switch(t){case`reprobe-hwaccel`:await ve.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await ye.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[ve,ye,R,F,I]),Pe=r((e,t)=>{Me(e,t)},[Me]),Q=p({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(await Z(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Fe=r(()=>{for(let e of X.current.values())e.discard()},[]),Ie=n(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),Le=n(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(Se)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let $=G&&Te?H.get(G):void 0,Re=Oe.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:Oe.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:De.get(e)??e})},e))}):null;if(!L&&J.length===0)return Re===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:O??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):Re;let ze=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(M||N)&&e(`div`,{className:`border-b border-border pb-2`,children:[M&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:M}),N&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:N})]}),J.length>0||L?Re:null,L&&i(ie,{tabs:U.map(e=>({id:e,label:Ce.get(e)??e})),activeId:G,onChange:we,pendingByTab:Le}),Q.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(ne,{tabKey:$?`extra:${G??``}`:`tab:${G??``}`,children:$?$.content:(()=>{let t=K?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===K).length,0):0,n=!!K&&t<=1,r=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>K?(e.tab??`general`)===K:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(j??[]).filter(e=>e.tabId===K),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:O??P(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(fe,{entries:r,paneStates:Y,displayNames:De,disabled:ze,setPaneRef:je,onPaneStateChange:Ae,onImmediateSave:Pe,onAction:Ne,inline:L||!!E}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!Se&&i(ae,{pendingCount:Ie,onSave:()=>Q.mutate(),onDiscard:Fe,saving:ze})]})}function fe({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(b,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{k as n,M as t};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{gt as m}from"./player-overlays-BZByYYB8.js";import{Ls as h,Rs as g}from"./client-mnldOm50.js";import{Oa as _,Xi as v,Zi as y,fo as ee,ji as b,jt as te,sa as ne}from"./src-DKRp5NPI.js";import{t as re}from"./useTranslation-BJr-n0es.js";import{F as x,N as ie,P as ae,lt as S}from"./index-D5GcZJtC.js";c();var C=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(S,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function oe(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function D(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function se(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!D(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function ce(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of g({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function le(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}function ue(e,t){let n=e??`general`;return t?.[n]??n}function O(e){return typeof e!=`object`||!e||!(`key`in e)?null:typeof e.key==`string`?e.key:null}function k(e,t){let n=t.fieldKeys===void 0?null:new Set(t.fieldKeys),r=[];for(let i of e){let e=n===null?i.fields:i.fields.filter(e=>{let t=O(e);return t!==null&&n.has(t)});e.length!==0&&r.push({...i,fields:e,...t.tabAliases===void 0?{}:{tab:ue(i.tab,t.tabAliases)},...t.hideSectionChrome===!0?{title:``,description:void 0}:{}})}return r}c();function A(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>A(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function j(e,t){return{...e,fields:e.fields.map(e=>A(e,t))}}function de(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>j(e,t))},values:t}}function M({nodeId:a,addonIds:o,level:c,deviceId:u,capability:g,sectionIds:b,omitSectionIds:x,fieldKeys:S,hideSectionChrome:C,tabAliases:w,tabLabelOverrides:T,sectionTab:E,fieldScope:D,emptyMessage:O,extraTabs:A,schemaTabExtras:j,title:M,description:N,selfTabbed:pe,activeTab:me,onActiveTabChange:he}){let{t:P}=re(),F=d(),I=m().trpcClient,ge=y(),_e=v(),ve=ee(),ye=_(),L=pe===!0||!!(A&&A.length>0),[be,xe]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let R=a??`hub`,z=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:R,deviceId:u??null,cap:g??null,scope:D??null,sections:[b??null,x??null]}],queryFn:async()=>{if(c===`global`){let t=await I.addonSettings.listScopedSettings.query({addonId:e,nodeId:R});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=se({declarations:t,...D===void 0?{}:{fieldScope:D},...g===void 0?{}:{capability:g},...b===void 0?{}:{allowSectionIds:b},...x===void 0?{}:{omitSectionIds:x}}),r=await Promise.all(n.map(async t=>{let n=await I.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{}});return n===null?null:{declaration:t,form:n}})),i=r.filter(e=>e!==null);if(i.length!==r.length)return{addonId:e,result:null,keyTargets:{}};let a=ce(i);return{addonId:e,result:a.form,keyTargets:a.keyTargets}}let t=await I.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:R});return{addonId:e,result:t!==null&&D!==void 0?oe(t,D):t,keyTargets:{}}},placeholderData:f}))}),Se=z.some(e=>e.isLoading),B=z.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),V=n(()=>{let e=new Set;for(let t of z){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(ue(t.tab,w))}return[...e]},[w,B+`::`+z.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),H=n(()=>new Map((A??[]).map(e=>[e.id,e])),[A]),U=n(()=>{if(!L)return[];let e=[...new Set([...V,...(A??[]).map(e=>e.id),...(j??[]).map(e=>e.tabId)])],t=e=>{let t=H.get(e);if(t?.order!==void 0)return t.order;let n=h[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[L,V,A,H,j]),Ce=n(()=>{let e=new Map,t=e=>h[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of V)e.set(n,t(n));for(let n of j??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of A??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(T??{}))e.set(t,n);return e},[V,A,j,T]),W=me===void 0?be:me,G=L?W&&U.includes(W)?W:U[0]??null:null,we=e=>{xe(e),he?.(e)},Te=G!==null&&H.has(G),K=L?G&&!Te?G:void 0:E,{data:Ee}=ne(void 0),De=n(()=>{let e=new Map;for(let t of Ee??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Ee]),q=t(new Map),J=n(()=>{let e=b?new Set(b):null,t=x?new Set(x):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of z){if(!e.data)continue;e.data.result!==null&&q.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=q.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=de(i),c={...S===void 0?{}:{fieldKeys:S},...C===void 0?{}:{hideSectionChrome:C},...w===void 0?{}:{tabAliases:w}},l=k(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:k(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[B,b,x,S,C,w]),Oe=n(()=>z.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!q.current.has(e.data.addonId)?[e.data.addonId]:[]),[B,c]),[Y,ke]=s(new Map),Ae=r(e=>{ke(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=t(new Map),je=r(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=r(async(e,t)=>{if(c!==`global`){await _e.mutateAsync({addonId:e,deviceId:u,nodeId:R,patch:t});return}let{groups:n,unowned:r}=le(t,J.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>ge.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:R}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw F.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,J,ge,_e,F,R,u]),Me=r(async(e,t)=>{await Z(e,t),F.invalidateQueries({queryKey:[[`addonSettings`]]})},[Z,F]),Ne=r(async(e,t,n,r)=>{let i=R;try{switch(t){case`reprobe-hwaccel`:await ve.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await ye.mutateAsync({nodeId:i}),F.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await I.addons.custom.mutate({addonId:e,action:t,input:r});return F.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[ve,ye,R,F,I]),Pe=r((e,t)=>{Me(e,t)},[Me]),Q=p({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(await Z(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();F.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Fe=r(()=>{for(let e of X.current.values())e.discard()},[]),Ie=n(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),Le=n(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(Se)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let $=G&&Te?H.get(G):void 0,Re=Oe.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:Oe.map(e=>i(`div`,{children:P(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:De.get(e)??e})},e))}):null;if(!L&&J.length===0)return Re===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:O??P(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:P(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):Re;let ze=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(M||N)&&e(`div`,{className:`border-b border-border pb-2`,children:[M&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:M}),N&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:N})]}),J.length>0||L?Re:null,L&&i(ie,{tabs:U.map(e=>({id:e,label:Ce.get(e)??e})),activeId:G,onChange:we,pendingByTab:Le}),Q.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[P(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(te,{tabKey:$?`extra:${G??``}`:`tab:${G??``}`,children:$?$.content:(()=>{let t=K?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===K).length,0):0,n=!!K&&t<=1,r=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>K?(e.tab??`general`)===K:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(j??[]).filter(e=>e.tabId===K),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:O??P(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(fe,{entries:r,paneStates:Y,displayNames:De,disabled:ze,setPaneRef:je,onPaneStateChange:Ae,onImmediateSave:Pe,onAction:Ne,inline:L||!!E}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!Se&&i(ae,{pendingCount:Ie,onSave:()=>Q.mutate(),onDiscard:Fe,saving:ze})]})}function fe({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(b,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{k as n,M as t};
|