@xopcai/xopc 0.0.324 → 0.0.325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B-Gczr_A.js → agent-avatar-dicebear-CxfXpPWs.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-CxcIHW_Z.js → agent-defaults-settings-panel-CDHe8gJf.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-CNuqJcHQ.js → agent-plugin-dialog-DMv-udoZ.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-CPpmkx7O.js → agents-D_xOAXgj.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BwWdVRlb.js → app-management-settings-panel-p7fZB4dT.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-EoXNDO1j.js → appearance-settings-C-clVcfp.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-6xEgLDv8.js → apps-page-Dz2g7eAN.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-B_T0uMvL.js → archive-plugin-Xm6xChUX.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-D9DDwxd2.js → attachment-load-Di8kuG4L.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-jI9vNr2r.js → automations-page-GUZgDhKj.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-rztQnZDk.js → automations-workspace-BUZhG9aJ.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-Dzsxh9OL.js → binary-plugins-OCrDjC9O.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CWUUgWWk.js → block-editor-m9tqvu7x.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-D96o3bDY.js → browser-automations-page-DuOaridE.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-DUQzQ3ic.js → browser-settings-page-D2_PgHep.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-CKWtXof8.js → capabilities-settings-panel-7Y_pJqyt.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-C8ducWB7.js → channels-settings-B-Igy1ro.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-WXZrEB3K.js → chat-terminal-dock-BfnVh8oo.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-uy9YDwxJ.js → computer-settings-page-aRG2lU4w.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BpF0SjB9.js → connector-service-page-B5EhnfJH.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-eZTfIMWI.js → connectors-page-7HfRt1LW.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Do1dl0La.js → date-picker-CtDyij_x.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BhS8s080.js → dependency-picker-z6ouWxmz.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DPVPqFlh.js → desktop-pet-BsIYCAkG.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-Dv3vG9HZ.js → desktop-pet-settings-z-0aQ5ct.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DdvO1O6W.js → device-pairing-wizard-DlmhQvY5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-cuG5Lnwf.js → extension-debug-page-Ct9pABNW.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BCTAXdyE.js → extension-page-BktsR4hj.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-kadW_icu.js → extension-settings-page-BQJc-vXH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CLZyN-u9.js → gateway-settings-BfDVlvy6.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BSqg-JE9.js → home-page-CI_eQTPL.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-_pddpuej.js → imports-page-DFpQfHVU.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CJuypaNt.js → index-19rMUT3d.js} +7 -7
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C1fKIjz4.js → keyboard-shortcuts-settings-ctJLm8TP.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DXFnYiA0.js → local-app-workbench-page-C9kaP3Dy.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CkXKS5xe.js → local-apps-page-BxC_LTqq.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-C33z-ife.js → logs-page-Ok5SpG-G.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-8eDZb0uS.js → management-settings-aOzRaQHM.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Cjj-fidX.js → media-plugins-ni5zJ4Ok.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-C95RtLuL.js → note-detail-panel-C9OEltN9.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-kFxknjMR.js → notes-page-Dj9rMgdi.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-OUL3fEYh.js → page-context-capture-button-BJA3d8vU.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-CVbY7_N5.js → page-tabs-Dyc3wKkl.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CKiIby0r.js → preview-open-alternatives-tIOIQbNX.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DlpCi5zT.js → product-open-page-DQctU8z3.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-LPAxUszX.js → project-detail-page-Dy-EwZcc.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-Cbyb4hyy.js → projects-page-JaGKa6rM.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BtDFZc6g.js → remote-access-hub-Cb8-nd60.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BT_ANpaT.js → runtime-tools-settings-panel-xhOSYfiX.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-CJlc-mg1.js → scenes-page-ClBkFdRY.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BcqsqSsV.js → schema-form-z8IeSdBp.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CUo6-iV2.js → sessions-page-BYW5l_nY.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDNwmXuH.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Dol9j_pF.js → settings-form-section-BXTJAser.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B65vii9U.js → settings-page-Br9no5e4.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-eqTUTW2L.js → settings-page-layout-D6745w0p.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BCt__prc.js → setup-status-panel-D2N9764S.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BS8o58NJ.js → share-preview-page-CE0SER59.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BsjSqEnw.js → shares-settings-Dk3_QOKQ.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-evN7gs0S.js → skill-reload-api-CPt61fEv.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BifYwEhe.js → skills-page-Db6PB2C6.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DOk-iOvN.js → skills-page.utils-DrtW5FBy.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CcSvoHfY.js → system-settings-panel-CuY1Zh5s.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-pCRG7Jb3.js → task-detail-page-o7RiDUMi.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DDGMf44u.js → tunnel-api-PGHDgvWb.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DiIkxIq7.js → use-autosave-B55oBQUt.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-CvYeM0Ml.js → user-model-page-DspelwAa.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DJV-qERt.js → voice-api-key-field-By6Lgbse.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DcHhy54L.js → work-discovery-overlay-DdhgIlyf.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DbVtLh0R.js → workflow-run-setup-panel-BOJYQaxX.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-CT8ouKcB.js → workflows-page-6ObD0IQZ.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/cli/commands/auth.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/commands/providers.js +1 -1
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/settings-advanced-gate-XeSxPjP7.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{f as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{n as u}from"./locale-store-BPZR8x9b.js";import{t as d}from"./messages-kFWhF6_t.js";import{a as f,i as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{n as v}from"./app-link-C6gA5Nck.js";import{i as y}from"./vendor-swr-BIWyz7Rc.js";import{t as b}from"./button-CS04eWY9.js";import{t as x}from"./skeleton-BwbyijEw.js";import{i as S,o as C}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Cl as w,Dt as T,Fo as E,Ft as D,Fu as O,Ju as k,Kc as A,Mt as j,Nt as M,Ot as N,aa as P,iu as F,kt as I,sd as ee}from"./index-CJuypaNt.js";import{_ as te,a as ne,d as re,f as ie,g as ae,h as oe,i as se,l as L,m as ce,n as R,p as le,r as z,s as B,t as V,u as ue,v as de}from"./tunnel-api-DDGMf44u.js";import{t as H}from"./browser-BLJWD7WI.js";var U=e(n(),1),W=r(),G=e(H(),1),K={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function fe(e){let t=await G.toString(e,{...K,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var q=i();function pe(){let e=d(u(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=y(`tunnel-status`,R,{refreshInterval:1500}),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(`idle`),[g,_]=(0,U.useState)(null),[S,C]=(0,U.useState)(``),w=(0,U.useRef)(!0);(0,U.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let E=async()=>{if(!r)return;if(r.consentRequired&&!o){l(!0);return}let e=r.registrationSecret?.configured?null:I(),t,n=!1;_(null);try{if(r.consentRequired&&await ne(),!r.registrationSecret?.configured){h(`provisioning`);let r=!1;try{await se()}catch(e){if(!ue(e))throw e;r=!0}if(r){h(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await D(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;w.current&&Date.now()<o;){let r=await M(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await N(a,e)||C(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!w.current)return;if(!s)throw Error(`Authorization expired`);await se()}await a()}if(!w.current)return;h(`starting`),await B(),f&&await z({autoStart:!0}),await a(),n=!0}catch(e){n=!0,w.current&&_(L(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{T(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&j(t).catch(()=>{})),w.current&&(h(`idle`),C(``))}};if(!r&&!i)return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(x,{className:`h-5 w-4/5`}),(0,q.jsx)(x,{className:`h-24 w-full`})]});let k=m===`provisioning`||m===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,q.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:k?t.preparingHint:m===`authorizing`?t.authorizing:t.enableHint}),S&&m===`authorizing`?(0,q.jsx)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,k?(0,q.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,q.jsx)(x,{className:`h-2 w-full`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(c||r?.consentRequired)&&m===`idle`?(0,q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,q.jsxs)(`details`,{open:c,className:`text-sm text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,q.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,q.jsx)(`li`,{children:e},e))})]}),(0,q.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,g===`key-limit`?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,q.jsxs)(b,{variant:`secondary`,className:`mt-3`,onClick:()=>void v(V),children:[t.manageTunnelKeys,(0,q.jsx)(O,{className:`size-3`})]})]}):g||i||r?.state===`error`?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:f,disabled:m!==`idle`,onChange:e=>p(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,q.jsx)(b,{className:`w-full`,variant:`primary`,disabled:!r||m!==`idle`||k||c&&!o,onClick:()=>void E(),children:m===`authorizing`?t.authorizing:k?t.preparing:g?t.retry:t.enable}),i&&!r?(0,q.jsx)(b,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var J=t({DevicePairingWizard:()=>Y});function Y(e){let t=(0,W.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,U.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,U.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,q.jsx)(he,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,q.jsx)(Z,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,q.jsx)(_,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function X(e){let t=(0,W.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,q.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,q.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,q.jsx)(ee,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,q.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function Z(e){let t=(0,W.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=u(me),o;t[0]===a?o=t[1]:(o=d(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,_;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,q.jsx)(f,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,C)}),t[2]=_):_=t[2];let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,S),t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=y):y=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,q.jsx)(c,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[y,(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let T;t[9]===s.chooseTitle?T=t[10]:(T=(0,q.jsx)(g,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=T);let E;t[11]===s.chooseHint?E=t[12]:(E=(0,q.jsx)(p,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=E);let D;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(D=(0,q.jsx)(X,{icon:F,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=D):D=t[16];let O;t[17]===n?O=t[18]:(O=()=>n(`mobile`),t[17]=n,t[18]=O);let k;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==O?(k=(0,q.jsx)(X,{icon:A,title:s.mobileTitle,hint:s.mobileHint,onClick:O}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=O,t[22]=k):k=t[22];let j;t[23]===n?j=t[24]:(j=()=>n(`browser`),t[23]=n,t[24]=j);let M;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==j?(M=(0,q.jsx)(X,{icon:w,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:j}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==k||t[30]!==M||t[31]!==D?(N=(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[D,k,M]}),t[29]=k,t[30]=M,t[31]=D,t[32]=N):N=t[32];let P;t[33]!==N||t[34]!==T||t[35]!==E?(P=(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[T,E,N]}),t[33]=N,t[34]=T,t[35]=E,t[36]=P):P=t[36];let I;return t[37]!==P||t[38]!==x?(I=(0,q.jsxs)(m,{children:[_,(0,q.jsxs)(h,{className:v,children:[x,P]})]}),t[37]=P,t[38]=x,t[39]=I):I=t[39],I}function me(e){return e.language}function he({targetKind:e,onClose:t,onPaired:n}){let r=u(e=>e.language),i=d(r),a=i.endpointToolsSettings.deviceAccess,_=a.flow,[w,T]=(0,U.useState)(!1),D=y(w?`device-pairing-readiness`:null,oe,{refreshInterval:1500}),[A,j]=(0,U.useState)(),[M,N]=(0,U.useState)(null),[F,I]=(0,U.useState)(!1),[ne,se]=(0,U.useState)(Date.now()),[L,R]=(0,U.useState)(null),z=(0,U.useRef)(!0),B=(0,U.useRef)(null),V=(0,U.useRef)(!1),ue=(0,U.useRef)(!1),H=y(A?[`device-pairing-setup`,A.id]:null,()=>ae(A.id),{refreshInterval:1500}),W=H.data?.request,G=W?.status===`completed`,K=G&&W.connectedAt!==void 0,J=y(K&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),Y=A?.targetKind===`mobile`?A.universalLink:``,X=E(()=>fe(Y),[Y],{enabled:!!Y,initial:null,errorData:null}),Z=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=E(()=>fe(Z),[Z],{enabled:!w&&e===`mobile`,initial:null,errorData:null});(0,U.useEffect)(()=>{z.current=!0;let e=setInterval(()=>se(Date.now()),1e3);return()=>{z.current=!1,clearInterval(e),B.current&&re(B.current).catch(()=>{})}},[]);let ge=(0,U.useCallback)(async()=>{if(!V.current){V.current=!0,I(!0),N(null);try{B.current&&await re(B.current),B.current=null,j(void 0);let t=await ie(e);if(t.kind===`ready`){if(!z.current){await re(t.setup.id);return}B.current=t.setup.id,j(t.setup)}else await D.mutate()}catch{z.current&&N(`create`)}finally{V.current=!1,z.current&&I(!1)}}},[D,e]);(0,U.useEffect)(()=>{D.data?.ready&&!A&&M!==`create`&&!V.current&&ge()},[D.data,A,M,ge]),(0,U.useEffect)(()=>{K&&!ue.current&&(ue.current=!0,n?.())},[K,n]);let _e=async e=>{if(W){I(!0),N(null);try{await le(W,e),await H.mutate()}catch{N(`decision`),await H.mutate()}finally{z.current&&I(!1)}}},ve=(0,U.useRef)(0);(0,U.useEffect)(()=>{H.data&&(ve.current=H.data.serverTime-Date.now())},[H.data]);let Q=ne+ve.current,ye=A&&Q>=A.expiresAt&&!W,be=W&&[`expired`,`rejected`,`cancelled`].includes(W.status),xe=A?A.expiresAt-Q<6e4:!1,Se=A?xe?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:_.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=w?K?$.success:W?.status===`pending`?$.allowTitle:G||W?.status===`approved`?_.waiting:A?$.connect:_.title:Ce,Ee=M===`create`?_.createFailed:M===`decision`?_.decisionFailed:M===`background`?_.backgroundFailed:M===`download`?a.browserDownloadFailed:null,De=async()=>{I(!0),N(null);try{await ce()}catch{N(`download`)}finally{z.current&&I(!1)}};return(0,q.jsxs)(m,{children:[(0,q.jsx)(f,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,C)}),(0,q.jsxs)(h,{className:l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,S),children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":_.cancel,onClick:t,children:(0,q.jsx)(c,{className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[K?(0,q.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,q.jsx)(g,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,q.jsx)(p,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:w?K?$.successHint:G?_.waitingForDevice:W?W.displayName:A?$.connectHint:_.intro:we}),Ee?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,w&&D.error?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:_.readinessFailed}):null,w&&H.error?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:_.statusUnavailable}):null,w?D.data?K?(0,q.jsxs)(q.Fragment,{children:[J.data?(0,q.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":J.data.runInBackground??!1,disabled:!J.data.backgroundSupported,checked:J.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>J.mutate(e.behavior)).catch(()=>N(`background`))}})]}):null,(0,q.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,q.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||W?.status===`expired`?_.expired:_.declined}),(0,q.jsx)(b,{variant:`primary`,onClick:()=>void ge(),disabled:F,children:_.refresh})]}):W?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:_.scope}),(0,q.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[W.confirmationCode.slice(0,3),` `,W.confirmationCode.slice(3)]}),(0,q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:_.compare}),(0,q.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:_.access}),(0,q.jsx)(`p`,{children:_.accessHint})]})]}):A?.targetKind===`mobile`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,q.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,q.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:X.data?(0,q.jsx)(`img`,{src:X.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):X.error?null:(0,q.jsx)(x,{className:`size-[240px] rounded-xl`})})}),X.error?null:(0,q.jsxs)(`p`,{className:l(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,q.jsx)(k,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),X.error?(0,q.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:_.qrFailed}):null,X.error?(0,q.jsx)(`div`,{className:`mt-5`,children:(0,q.jsx)(P,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,q.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(`span`,{children:_.fallback}),(0,q.jsx)(ee,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,q.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,q.jsx)(P,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):A?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(P,{text:A.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:A.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:_.valid})]}):D.data.ready?(0,q.jsx)(`div`,{className:`mt-8`,children:(0,q.jsx)(x,{className:`mx-auto size-[216px]`})}):(0,q.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[L===`tailscale`?(0,q.jsx)(de,{embedded:!0}):L===`https`?(0,q.jsx)(te,{}):L===`choices`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(b,{variant:`secondary`,className:`w-full`,onClick:()=>R(`tailscale`),children:a.useTailscale}),(0,q.jsx)(b,{variant:`secondary`,className:`w-full`,onClick:()=>R(`https`),children:a.useOwnHttps})]}):(0,q.jsx)(pe,{}),(0,q.jsx)(b,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>R(L?null:`choices`),children:L?_.back:_.existing})]}):(0,q.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,q.jsx)(x,{className:`h-5 w-3/4`}),(0,q.jsx)(x,{className:`h-40 w-full`})]}):e===`mobile`?(0,q.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,q.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,q.jsx)(x,{className:`size-36`}),(0,q.jsxs)(b,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void v(Z),children:[(0,q.jsx)(O,{className:`size-4`}),a.mobileDownload]}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,q.jsxs)(`div`,{className:`mt-7`,children:[(0,q.jsxs)(b,{variant:`secondary`,className:`w-full`,disabled:F,onClick:()=>void De(),children:[(0,q.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,q.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,q.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void v(me),children:[a.browserInstallHelp,(0,q.jsx)(O,{className:`size-3`})]})]})]}),!w||D.error||K||W?.status===`pending`||M===`create`||M===`decision`?(0,q.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:w?K?(0,q.jsx)(b,{className:`w-full`,variant:`primary`,onClick:t,children:_.done}):W?.status===`pending`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(b,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void _e(`approve`),children:_.allow}),(0,q.jsx)(b,{className:`w-full`,variant:`ghost`,disabled:F,onClick:()=>void _e(`reject`),children:_.cancel})]}):D.error?(0,q.jsx)(b,{className:`w-full`,variant:`primary`,onClick:()=>void D.mutate(),children:_.retry}):(0,q.jsx)(b,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void ge(),children:_.retry}):(0,q.jsx)(b,{className:`w-full`,variant:`primary`,onClick:()=>{N(null),T(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{J as n,Y as t};
|
|
1
|
+
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{f as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{n as u}from"./locale-store-BPZR8x9b.js";import{t as d}from"./messages-kFWhF6_t.js";import{a as f,i as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{n as v}from"./app-link-C6gA5Nck.js";import{i as y}from"./vendor-swr-BIWyz7Rc.js";import{t as b}from"./button-CS04eWY9.js";import{t as x}from"./skeleton-BwbyijEw.js";import{i as S,o as C}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Cl as w,Dt as T,Fo as E,Ft as D,Fu as O,Ju as k,Kc as A,Mt as j,Nt as M,Ot as N,aa as P,iu as F,kt as I,sd as ee}from"./index-19rMUT3d.js";import{_ as te,a as ne,d as re,f as ie,g as ae,h as oe,i as se,l as L,m as ce,n as R,p as le,r as z,s as B,t as V,u as ue,v as de}from"./tunnel-api-PGHDgvWb.js";import{t as H}from"./browser-BLJWD7WI.js";var U=e(n(),1),W=r(),G=e(H(),1),K={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function fe(e){let t=await G.toString(e,{...K,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var q=i();function pe(){let e=d(u(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=y(`tunnel-status`,R,{refreshInterval:1500}),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(`idle`),[g,_]=(0,U.useState)(null),[S,C]=(0,U.useState)(``),w=(0,U.useRef)(!0);(0,U.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let E=async()=>{if(!r)return;if(r.consentRequired&&!o){l(!0);return}let e=r.registrationSecret?.configured?null:I(),t,n=!1;_(null);try{if(r.consentRequired&&await ne(),!r.registrationSecret?.configured){h(`provisioning`);let r=!1;try{await se()}catch(e){if(!ue(e))throw e;r=!0}if(r){h(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await D(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;w.current&&Date.now()<o;){let r=await M(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await N(a,e)||C(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!w.current)return;if(!s)throw Error(`Authorization expired`);await se()}await a()}if(!w.current)return;h(`starting`),await B(),f&&await z({autoStart:!0}),await a(),n=!0}catch(e){n=!0,w.current&&_(L(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{T(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&j(t).catch(()=>{})),w.current&&(h(`idle`),C(``))}};if(!r&&!i)return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(x,{className:`h-5 w-4/5`}),(0,q.jsx)(x,{className:`h-24 w-full`})]});let k=m===`provisioning`||m===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,q.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:k?t.preparingHint:m===`authorizing`?t.authorizing:t.enableHint}),S&&m===`authorizing`?(0,q.jsx)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,k?(0,q.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,q.jsx)(x,{className:`h-2 w-full`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(c||r?.consentRequired)&&m===`idle`?(0,q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,q.jsxs)(`details`,{open:c,className:`text-sm text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,q.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,q.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,q.jsx)(`li`,{children:e},e))})]}),(0,q.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,g===`key-limit`?(0,q.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,q.jsxs)(b,{variant:`secondary`,className:`mt-3`,onClick:()=>void v(V),children:[t.manageTunnelKeys,(0,q.jsx)(O,{className:`size-3`})]})]}):g||i||r?.state===`error`?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:f,disabled:m!==`idle`,onChange:e=>p(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,q.jsx)(b,{className:`w-full`,variant:`primary`,disabled:!r||m!==`idle`||k||c&&!o,onClick:()=>void E(),children:m===`authorizing`?t.authorizing:k?t.preparing:g?t.retry:t.enable}),i&&!r?(0,q.jsx)(b,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var J=t({DevicePairingWizard:()=>Y});function Y(e){let t=(0,W.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,U.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,U.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,q.jsx)(he,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,q.jsx)(Z,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,q.jsx)(_,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function X(e){let t=(0,W.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,q.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,q.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,q.jsx)(ee,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,q.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function Z(e){let t=(0,W.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=u(me),o;t[0]===a?o=t[1]:(o=d(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,_;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,q.jsx)(f,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,C)}),t[2]=_):_=t[2];let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,S),t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=y):y=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,q.jsx)(c,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[y,(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let T;t[9]===s.chooseTitle?T=t[10]:(T=(0,q.jsx)(g,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=T);let E;t[11]===s.chooseHint?E=t[12]:(E=(0,q.jsx)(p,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=E);let D;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(D=(0,q.jsx)(X,{icon:F,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=D):D=t[16];let O;t[17]===n?O=t[18]:(O=()=>n(`mobile`),t[17]=n,t[18]=O);let k;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==O?(k=(0,q.jsx)(X,{icon:A,title:s.mobileTitle,hint:s.mobileHint,onClick:O}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=O,t[22]=k):k=t[22];let j;t[23]===n?j=t[24]:(j=()=>n(`browser`),t[23]=n,t[24]=j);let M;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==j?(M=(0,q.jsx)(X,{icon:w,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:j}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=j,t[28]=M):M=t[28];let N;t[29]!==k||t[30]!==M||t[31]!==D?(N=(0,q.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[D,k,M]}),t[29]=k,t[30]=M,t[31]=D,t[32]=N):N=t[32];let P;t[33]!==N||t[34]!==T||t[35]!==E?(P=(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[T,E,N]}),t[33]=N,t[34]=T,t[35]=E,t[36]=P):P=t[36];let I;return t[37]!==P||t[38]!==x?(I=(0,q.jsxs)(m,{children:[_,(0,q.jsxs)(h,{className:v,children:[x,P]})]}),t[37]=P,t[38]=x,t[39]=I):I=t[39],I}function me(e){return e.language}function he({targetKind:e,onClose:t,onPaired:n}){let r=u(e=>e.language),i=d(r),a=i.endpointToolsSettings.deviceAccess,_=a.flow,[w,T]=(0,U.useState)(!1),D=y(w?`device-pairing-readiness`:null,oe,{refreshInterval:1500}),[A,j]=(0,U.useState)(),[M,N]=(0,U.useState)(null),[F,I]=(0,U.useState)(!1),[ne,se]=(0,U.useState)(Date.now()),[L,R]=(0,U.useState)(null),z=(0,U.useRef)(!0),B=(0,U.useRef)(null),V=(0,U.useRef)(!1),ue=(0,U.useRef)(!1),H=y(A?[`device-pairing-setup`,A.id]:null,()=>ae(A.id),{refreshInterval:1500}),W=H.data?.request,G=W?.status===`completed`,K=G&&W.connectedAt!==void 0,J=y(K&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),Y=A?.targetKind===`mobile`?A.universalLink:``,X=E(()=>fe(Y),[Y],{enabled:!!Y,initial:null,errorData:null}),Z=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,me=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,he=E(()=>fe(Z),[Z],{enabled:!w&&e===`mobile`,initial:null,errorData:null});(0,U.useEffect)(()=>{z.current=!0;let e=setInterval(()=>se(Date.now()),1e3);return()=>{z.current=!1,clearInterval(e),B.current&&re(B.current).catch(()=>{})}},[]);let ge=(0,U.useCallback)(async()=>{if(!V.current){V.current=!0,I(!0),N(null);try{B.current&&await re(B.current),B.current=null,j(void 0);let t=await ie(e);if(t.kind===`ready`){if(!z.current){await re(t.setup.id);return}B.current=t.setup.id,j(t.setup)}else await D.mutate()}catch{z.current&&N(`create`)}finally{V.current=!1,z.current&&I(!1)}}},[D,e]);(0,U.useEffect)(()=>{D.data?.ready&&!A&&M!==`create`&&!V.current&&ge()},[D.data,A,M,ge]),(0,U.useEffect)(()=>{K&&!ue.current&&(ue.current=!0,n?.())},[K,n]);let _e=async e=>{if(W){I(!0),N(null);try{await le(W,e),await H.mutate()}catch{N(`decision`),await H.mutate()}finally{z.current&&I(!1)}}},ve=(0,U.useRef)(0);(0,U.useEffect)(()=>{H.data&&(ve.current=H.data.serverTime-Date.now())},[H.data]);let Q=ne+ve.current,ye=A&&Q>=A.expiresAt&&!W,be=W&&[`expired`,`rejected`,`cancelled`].includes(W.status),xe=A?A.expiresAt-Q<6e4:!1,Se=A?xe?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:_.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=w?K?$.success:W?.status===`pending`?$.allowTitle:G||W?.status===`approved`?_.waiting:A?$.connect:_.title:Ce,Ee=M===`create`?_.createFailed:M===`decision`?_.decisionFailed:M===`background`?_.backgroundFailed:M===`download`?a.browserDownloadFailed:null,De=async()=>{I(!0),N(null);try{await ce()}catch{N(`download`)}finally{z.current&&I(!1)}};return(0,q.jsxs)(m,{children:[(0,q.jsx)(f,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,C)}),(0,q.jsxs)(h,{className:l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,S),children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,q.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,q.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":_.cancel,onClick:t,children:(0,q.jsx)(c,{className:`size-4`})})]}),(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[K?(0,q.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,q.jsx)(g,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,q.jsx)(p,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:w?K?$.successHint:G?_.waitingForDevice:W?W.displayName:A?$.connectHint:_.intro:we}),Ee?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,w&&D.error?(0,q.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:_.readinessFailed}):null,w&&H.error?(0,q.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:_.statusUnavailable}):null,w?D.data?K?(0,q.jsxs)(q.Fragment,{children:[J.data?(0,q.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,q.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":J.data.runInBackground??!1,disabled:!J.data.backgroundSupported,checked:J.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>J.mutate(e.behavior)).catch(()=>N(`background`))}})]}):null,(0,q.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,q.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||W?.status===`expired`?_.expired:_.declined}),(0,q.jsx)(b,{variant:`primary`,onClick:()=>void ge(),disabled:F,children:_.refresh})]}):W?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:_.scope}),(0,q.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[W.confirmationCode.slice(0,3),` `,W.confirmationCode.slice(3)]}),(0,q.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:_.compare}),(0,q.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer py-2`,children:_.access}),(0,q.jsx)(`p`,{children:_.accessHint})]})]}):A?.targetKind===`mobile`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,q.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,q.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:X.data?(0,q.jsx)(`img`,{src:X.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):X.error?null:(0,q.jsx)(x,{className:`size-[240px] rounded-xl`})})}),X.error?null:(0,q.jsxs)(`p`,{className:l(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,q.jsx)(k,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),X.error?(0,q.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:_.qrFailed}):null,X.error?(0,q.jsx)(`div`,{className:`mt-5`,children:(0,q.jsx)(P,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,q.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,q.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,q.jsx)(`span`,{children:_.fallback}),(0,q.jsx)(ee,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,q.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,q.jsx)(P,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):A?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,q.jsx)(`div`,{className:`mt-6`,children:(0,q.jsx)(P,{text:A.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:A.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:_.valid})]}):D.data.ready?(0,q.jsx)(`div`,{className:`mt-8`,children:(0,q.jsx)(x,{className:`mx-auto size-[216px]`})}):(0,q.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[L===`tailscale`?(0,q.jsx)(de,{embedded:!0}):L===`https`?(0,q.jsx)(te,{}):L===`choices`?(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(b,{variant:`secondary`,className:`w-full`,onClick:()=>R(`tailscale`),children:a.useTailscale}),(0,q.jsx)(b,{variant:`secondary`,className:`w-full`,onClick:()=>R(`https`),children:a.useOwnHttps})]}):(0,q.jsx)(pe,{}),(0,q.jsx)(b,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>R(L?null:`choices`),children:L?_.back:_.existing})]}):(0,q.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,q.jsx)(x,{className:`h-5 w-3/4`}),(0,q.jsx)(x,{className:`h-40 w-full`})]}):e===`mobile`?(0,q.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[he.data?(0,q.jsx)(`img`,{src:he.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,q.jsx)(x,{className:`size-36`}),(0,q.jsxs)(b,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void v(Z),children:[(0,q.jsx)(O,{className:`size-4`}),a.mobileDownload]}),(0,q.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,q.jsxs)(`div`,{className:`mt-7`,children:[(0,q.jsxs)(b,{variant:`secondary`,className:`w-full`,disabled:F,onClick:()=>void De(),children:[(0,q.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,q.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,q.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void v(me),children:[a.browserInstallHelp,(0,q.jsx)(O,{className:`size-3`})]})]})]}),!w||D.error||K||W?.status===`pending`||M===`create`||M===`decision`?(0,q.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:w?K?(0,q.jsx)(b,{className:`w-full`,variant:`primary`,onClick:t,children:_.done}):W?.status===`pending`?(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsx)(b,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void _e(`approve`),children:_.allow}),(0,q.jsx)(b,{className:`w-full`,variant:`ghost`,disabled:F,onClick:()=>void _e(`reject`),children:_.cancel})]}):D.error?(0,q.jsx)(b,{className:`w-full`,variant:`primary`,onClick:()=>void D.mutate(),children:_.retry}):(0,q.jsx)(b,{className:`w-full`,variant:`primary`,disabled:F,onClick:()=>void ge(),children:_.retry}):(0,q.jsx)(b,{className:`w-full`,variant:`primary`,onClick:()=>{N(null),T(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{J as n,Y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-BPZR8x9b.js";import{t as i}from"./messages-kFWhF6_t.js";import{Do as a}from"./index-
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-BPZR8x9b.js";import{t as i}from"./messages-kFWhF6_t.js";import{Do as a}from"./index-19rMUT3d.js";import{n as o,r as s}from"./settings-page-layout-D6745w0p.js";var c=t();e();var l=n();function u(){let e=(0,c.c)(40),t=r(p),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let u=n.extensionDebug,m=a(),h;e[2]===m?h=e[3]:(h=m.toSorted(f),e[2]=m,e[3]=h);let g=h,_;e[4]!==u.subtitle||e[5]!==u.title?(_=(0,l.jsx)(o,{title:u.title,subtitle:u.subtitle}),e[4]=u.subtitle,e[5]=u.title,e[6]=_):_=e[6];let v;e[7]===u.listHeading?v=e[8]:(v=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.listHeading}),e[7]=u.listHeading,e[8]=v);let y;e[9]===u.colId?y=e[10]:(y=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colId}),e[9]=u.colId,e[10]=y);let b;e[11]===u.colName?b=e[12]:(b=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colName}),e[11]=u.colName,e[12]=b);let x;e[13]===u.colPermissions?x=e[14]:(x=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colPermissions}),e[13]=u.colPermissions,e[14]=x);let S;e[15]!==y||e[16]!==b||e[17]!==x?(S=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[15]=y,e[16]=b,e[17]=x,e[18]=S):S=e[18];let C;e[19]===g?C=e[20]:(C=g.map(d),e[19]=g,e[20]=C);let w;e[21]===C?w=e[22]:(w=(0,l.jsx)(`tbody`,{children:C}),e[21]=C,e[22]=w);let T;e[23]!==S||e[24]!==w?(T=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-separate border-spacing-y-1 text-left text-sm`,children:[S,w]})}),e[23]=S,e[24]=w,e[25]=T):T=e[25];let E;e[26]!==T||e[27]!==v?(E=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[v,T]}),e[26]=T,e[27]=v,e[28]=E):E=e[28];let D;e[29]===u.futureHeading?D=e[30]:(D=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.futureHeading}),e[29]=u.futureHeading,e[30]=D);let O;e[31]===u.futureBody?O=e[32]:(O=(0,l.jsx)(`p`,{className:`mt-2`,children:u.futureBody}),e[31]=u.futureBody,e[32]=O);let k;e[33]!==D||e[34]!==O?(k=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4 text-sm text-fg-muted`,children:[D,O]}),e[33]=D,e[34]=O,e[35]=k):k=e[35];let A;return e[36]!==E||e[37]!==k||e[38]!==_?(A=(0,l.jsxs)(s,{gap:`gap-5`,children:[_,E,k]}),e[36]=E,e[37]=k,e[38]=_,e[39]=A):A=e[39],A}function d(e){return(0,l.jsxs)(`tr`,{className:`bg-surface-base/55`,children:[(0,l.jsx)(`td`,{className:`rounded-l-lg px-3 py-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`rounded-r-lg px-3 py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(e){return e.language}export{u as ExtensionDebugPage};
|
package/dist/gateway/static/root/assets/{extension-page-BCTAXdyE.js → extension-page-BktsR4hj.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{Ao as a,Do as o,Io as s,gi as c}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{Ao as a,Do as o,Io as s,gi as c}from"./index-19rMUT3d.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=i(),r=o(),f=s(m),g=s(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&a(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(c,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as o,r as s}from"./popover-select-DcsFzD_i.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,i as d,n as f,r as p}from"./locale-store-BPZR8x9b.js";import{t as m}from"./messages-kFWhF6_t.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-CS04eWY9.js";import{Do as _,Xo as v,Yo as y,Zo as b,gi as x}from"./index-CJuypaNt.js";import{n as S,r as C}from"./settings-page-layout-eqTUTW2L.js";import{t as w}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as T,t as E}from"./use-autosave-DiIkxIq7.js";import{c as D,d as O,s as k}from"./voice-config-api-BaxITrwZ.js";import{t as A}from"./voice-api-key-field-DJV-qERt.js";import{t as j}from"./schema-form-BcqsqSsV.js";var M=e(t(),1),N=n(),P=r();function F(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function I(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function L(){return c(v,y)}function R(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function z(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function B({providerId:e,voiceSettings:t,mutateVoice:n}){let r=m(f(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,l={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=h(p(`/api/voice/stt-providers`),D,{revalidateOnFocus:!1}),d=(0,M.useMemo)(()=>u?.providers.find(t=>t.id===e),[e,u]),g=d?.configured??!1,_=d?.models??[],v=_[0]?.id??d?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,M.useMemo)(()=>z(t,e,v),[v,e,t]),x=(0,M.useRef)(!1),[S,C]=(0,M.useState)(null),w=S??b,k=(0,M.useRef)(w);k.current=w;let j=b,N=E({value:w,dirty:w.apiKey!==j.apiKey||w.model!==j.model,onSave:(0,M.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await O(i),await n(i,!1),x.current=JSON.stringify(k.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),I=_.length>0?_:w.model?[{id:w.model,name:w.model}]:[];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:N.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:N.status,error:N.error}),(0,P.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-xs font-medium`,g?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:g?a.configured:a.notConfigured})]})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(F,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:l,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(F,{children:i.stt.model}),I.length>0?(0,P.jsx)(o,{className:L(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),N.saveNow({...w,model:e.target.value})},children:I.map(e=>(0,P.jsx)(s,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function V(e){let t=(0,N.c)(13),{extensionId:n}=e,r=f(U),i=u(H),a;t[0]===n?a=t[1]:(a=()=>l(p(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=h(i&&n?`ext-stt-detail-${n}`:null,a),c;t[2]===o?c=t[3]:(c=I(o),t[2]=o,t[3]=c);let d=c,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:g,mutate:_,isLoading:v}=h(i?`voice-settings-ext-stt`:null,k,m);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(w,{rows:2}),t[5]=e):e=t[5],e}if(!d){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${d}`,b;return t[8]!==_||t[9]!==d||t[10]!==y||t[11]!==g?(b=(0,P.jsx)(B,{providerId:d,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=d,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function H(e){return!!e.conversationId}function U(e){return e.language}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){let t={};if(e.type!==`object`||!W(e.properties))return t;for(let[n,r]of Object.entries(e.properties))W(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function K(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function q({extensionId:e}){let t=u(e=>!!e.conversationId),{data:n,error:r}=h(t&&e?`ext-detail-${e}`:null,()=>l(p(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=h(t&&e?`ext-cfg-${e}`:null,()=>l(p(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,c=(0,M.useMemo)(()=>s&&s.type===`object`?G(s):{},[s]),f=(0,M.useMemo)(()=>({...c,...i??{}}),[c,i]),[m,_]=(0,M.useReducer)(K,{localValues:{},isDirty:!1}),v=(0,M.useRef)(!1),y=(0,M.useRef)(m.localValues);y.current=m.localValues;let b=(0,M.useRef)(f);!v.current&&b.current!==f&&(b.current=f,_({type:`sync`,value:f}));let x=(0,M.useCallback)(e=>{v.current=!0,_({type:`change`,value:e})},[]),S=(0,M.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,_({type:`reset-defaults`,value:{...G(s)}}))},[s]),C=(0,M.useCallback)(async t=>{if(!e)return;let n=await d(p(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),_({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=E({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||o){let e=r??o;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!s||s.type!==`object`?null:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:w.status,error:w.error}),(0,P.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,P.jsx)(j,{schema:s,values:m.localValues,onChange:x})]})}function J(){let e=(0,N.c)(38),t=f(Y),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=_();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(X,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let l,u,d;if(e[3]!==o||e[4]!==c||e[5]!==s){d=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),l=c.find(t),!l){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)(X,{message:t}),e[11]=t,e[12]=n),d=n;break bb0}let n=l.ui?.contributions?.settingsPanels;u=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=l,e[7]=u,e[8]=d}else l=e[6],u=e[7],d=e[8];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let p=u,h=!!(p&&l.ui),g=!!l.hasConfigSchema,v=l.kind===`media-provider`;if(!g&&!h&&!v){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)(X,{message:t}),e[13]=t,e[14]=n),n}let y=p?.title??`${l.name} Settings`,b;e[15]===y?b=e[16]:(b=(0,P.jsx)(S,{title:y}),e[15]=y,e[16]=b);let w;e[17]!==v||e[18]!==r?(w=v?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,P.jsx)(a,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[17]=v,e[18]=r,e[19]=w):w=e[19];let T;e[20]!==o||e[21]!==v?(T=v?(0,P.jsx)(V,{extensionId:o}):null,e[20]=o,e[21]=v,e[22]=T):T=e[22];let E;e[23]!==o||e[24]!==g?(E=g?(0,P.jsx)(q,{extensionId:o}):null,e[23]=o,e[24]=g,e[25]=E):E=e[25];let D;e[26]!==l.name||e[27]!==l.ui||e[28]!==o||e[29]!==h||e[30]!==p?(D=h&&p&&l.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(x,{extensionId:o,extensionName:l.name,entrypoint:p.entrypoint,permissions:l.ui?.permissions,title:p.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=l.name,e[27]=l.ui,e[28]=o,e[29]=h,e[30]=p,e[31]=D):D=e[31];let O;return e[32]!==b||e[33]!==w||e[34]!==T||e[35]!==E||e[36]!==D?(O=(0,P.jsxs)(C,{gap:`gap-5`,children:[b,w,T,E,D]}),e[32]=b,e[33]=w,e[34]=T,e[35]=E,e[36]=D,e[37]=O):O=e[37],O}function Y(e){return e.language}function X(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(C,{gap:`gap-3`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{J as ExtensionSettingsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as o,r as s}from"./popover-select-DcsFzD_i.js";import{t as c}from"./cn-JdwAhgNB.js";import{a as l,c as u,i as d,n as f,r as p}from"./locale-store-BPZR8x9b.js";import{t as m}from"./messages-kFWhF6_t.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{t as g}from"./button-CS04eWY9.js";import{Do as _,Xo as v,Yo as y,Zo as b,gi as x}from"./index-19rMUT3d.js";import{n as S,r as C}from"./settings-page-layout-D6745w0p.js";import{t as w}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as T,t as E}from"./use-autosave-B55oBQUt.js";import{c as D,d as O,s as k}from"./voice-config-api-BaxITrwZ.js";import{t as A}from"./voice-api-key-field-By6Lgbse.js";import{t as j}from"./schema-form-z8IeSdBp.js";var M=e(t(),1),N=n(),P=r();function F(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function I(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function L(){return c(v,y)}function R(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function z(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function B({providerId:e,voiceSettings:t,mutateVoice:n}){let r=m(f(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,l={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=h(p(`/api/voice/stt-providers`),D,{revalidateOnFocus:!1}),d=(0,M.useMemo)(()=>u?.providers.find(t=>t.id===e),[e,u]),g=d?.configured??!1,_=d?.models??[],v=_[0]?.id??d?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,M.useMemo)(()=>z(t,e,v),[v,e,t]),x=(0,M.useRef)(!1),[S,C]=(0,M.useState)(null),w=S??b,k=(0,M.useRef)(w);k.current=w;let j=b,N=E({value:w,dirty:w.apiKey!==j.apiKey||w.model!==j.model,onSave:(0,M.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await O(i),await n(i,!1),x.current=JSON.stringify(k.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),I=_.length>0?_:w.model?[{id:w.model,name:w.model}]:[];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:N.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:N.status,error:N.error}),(0,P.jsx)(`span`,{className:c(`rounded-full px-2 py-0.5 text-xs font-medium`,g?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:g?a.configured:a.notConfigured})]})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(F,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:l,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:c(`flex flex-col gap-1.5`,y),children:[(0,P.jsx)(F,{children:i.stt.model}),I.length>0?(0,P.jsx)(o,{className:L(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),N.saveNow({...w,model:e.target.value})},children:I.map(e=>(0,P.jsx)(s,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function V(e){let t=(0,N.c)(13),{extensionId:n}=e,r=f(U),i=u(H),a;t[0]===n?a=t[1]:(a=()=>l(p(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=h(i&&n?`ext-stt-detail-${n}`:null,a),c;t[2]===o?c=t[3]:(c=I(o),t[2]=o,t[3]=c);let d=c,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:g,mutate:_,isLoading:v}=h(i?`voice-settings-ext-stt`:null,k,m);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(w,{rows:2}),t[5]=e):e=t[5],e}if(!d){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${d}`,b;return t[8]!==_||t[9]!==d||t[10]!==y||t[11]!==g?(b=(0,P.jsx)(B,{providerId:d,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=d,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function H(e){return!!e.conversationId}function U(e){return e.language}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){let t={};if(e.type!==`object`||!W(e.properties))return t;for(let[n,r]of Object.entries(e.properties))W(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function K(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function q({extensionId:e}){let t=u(e=>!!e.conversationId),{data:n,error:r}=h(t&&e?`ext-detail-${e}`:null,()=>l(p(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=h(t&&e?`ext-cfg-${e}`:null,()=>l(p(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,c=(0,M.useMemo)(()=>s&&s.type===`object`?G(s):{},[s]),f=(0,M.useMemo)(()=>({...c,...i??{}}),[c,i]),[m,_]=(0,M.useReducer)(K,{localValues:{},isDirty:!1}),v=(0,M.useRef)(!1),y=(0,M.useRef)(m.localValues);y.current=m.localValues;let b=(0,M.useRef)(f);!v.current&&b.current!==f&&(b.current=f,_({type:`sync`,value:f}));let x=(0,M.useCallback)(e=>{v.current=!0,_({type:`change`,value:e})},[]),S=(0,M.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,_({type:`reset-defaults`,value:{...G(s)}}))},[s]),C=(0,M.useCallback)(async t=>{if(!e)return;let n=await d(p(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),_({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=E({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||o){let e=r??o;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!s||s.type!==`object`?null:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:w.status,error:w.error}),(0,P.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,P.jsx)(j,{schema:s,values:m.localValues,onChange:x})]})}function J(){let e=(0,N.c)(38),t=f(Y),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=_();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(X,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let l,u,d;if(e[3]!==o||e[4]!==c||e[5]!==s){d=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),l=c.find(t),!l){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)(X,{message:t}),e[11]=t,e[12]=n),d=n;break bb0}let n=l.ui?.contributions?.settingsPanels;u=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=l,e[7]=u,e[8]=d}else l=e[6],u=e[7],d=e[8];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let p=u,h=!!(p&&l.ui),g=!!l.hasConfigSchema,v=l.kind===`media-provider`;if(!g&&!h&&!v){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)(X,{message:t}),e[13]=t,e[14]=n),n}let y=p?.title??`${l.name} Settings`,b;e[15]===y?b=e[16]:(b=(0,P.jsx)(S,{title:y}),e[15]=y,e[16]=b);let w;e[17]!==v||e[18]!==r?(w=v?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,P.jsx)(a,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[17]=v,e[18]=r,e[19]=w):w=e[19];let T;e[20]!==o||e[21]!==v?(T=v?(0,P.jsx)(V,{extensionId:o}):null,e[20]=o,e[21]=v,e[22]=T):T=e[22];let E;e[23]!==o||e[24]!==g?(E=g?(0,P.jsx)(q,{extensionId:o}):null,e[23]=o,e[24]=g,e[25]=E):E=e[25];let D;e[26]!==l.name||e[27]!==l.ui||e[28]!==o||e[29]!==h||e[30]!==p?(D=h&&p&&l.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(x,{extensionId:o,extensionName:l.name,entrypoint:p.entrypoint,permissions:l.ui?.permissions,title:p.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=l.name,e[27]=l.ui,e[28]=o,e[29]=h,e[30]=p,e[31]=D):D=e[31];let O;return e[32]!==b||e[33]!==w||e[34]!==T||e[35]!==E||e[36]!==D?(O=(0,P.jsxs)(C,{gap:`gap-5`,children:[b,w,T,E,D]}),e[32]=b,e[33]=w,e[34]=T,e[35]=E,e[36]=D,e[37]=O):O=e[37],O}function Y(e){return e.language}function X(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(C,{gap:`gap-3`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{J as ExtensionSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-DcsFzD_i.js";import{t as s}from"./cn-JdwAhgNB.js";import{a as c,c as l,n as u,r as d}from"./locale-store-BPZR8x9b.js";import{t as f}from"./messages-kFWhF6_t.js";import{i as p,o as m}from"./vendor-swr-BIWyz7Rc.js";import{t as h}from"./button-CS04eWY9.js";import{n as g,r as _}from"./gateway-config-swr-CoQVulMd.js";import{t as v}from"./skeleton-BwbyijEw.js";import{Ac as y,Go as b,Jc as x,Ko as S,Nn as C,Ol as w,Ul as T,Xc as E,Zo as D,al as O,ba as k,cu as A,od as j,ou as M,qc as N,qo as P,qs as F,sl as I,wa as L,wn as R,zo as ee}from"./index-CJuypaNt.js";import{n as te,r as ne,t as z}from"./settings-page-layout-eqTUTW2L.js";import{n as re,t as ie}from"./settings-form-section-Dol9j_pF.js";import{t as B}from"./page-tabs-CVbY7_N5.js";import{n as ae}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as oe}from"./settings-advanced-gate-XeSxPjP7.js";var V=e(t(),1),H=n(),U=18790,W={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return P(e)}async function se(e){let t=await c(d(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function q(e){return K(e)?``:e.trim()}function ce(e){return[...e].map(e=>e.trim()).sort()}function le(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:q(e.auth.token),password:q(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:ce(e.auth.trustedProxy.requiredHeaders),allowUsers:ce(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:ce(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function ue(e,t){return le(e)!==le(t)}async function de(e){return(await c(d(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function fe(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function J(e){let t=G(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):W.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):W.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):W.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function pe(e){let t=G(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:Y(t.requiredHeaders,32),allowUsers:Y(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function me(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function Y(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function he(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function ge(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function _e(e){let t=ge(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function ve(e){let t=G(e)?e:{},n=G(t.gateway)?t.gateway:{},r=G(n.auth)?n.auth:{},i=G(n.security)?n.security:{},a=G(t.update)?t.update:{},o=G(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:he(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):U,auth:{mode:fe(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:J(r.rateLimit),trustedProxy:pe(r.trustedProxy)},corsOrigins:l,trustedProxies:Y(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:me(n.channelConnectDeferMode),channelConnectDeferIds:Y(n.channelConnectDeferIds),channelConnectDeferSkipIds:Y(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function ye(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!K(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!K(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function be(e){let t=_e(e);if(t)throw Error(t);await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:ye(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),g()}var xe={critical:3,warn:2,info:1};function Se(){return d(`/api/doctor?security=true`)}function Ce(e){return e.toSorted((e,t)=>xe[t.severity]-xe[e.severity]||e.checkId.localeCompare(t.checkId))}function we(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=Ce((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function Te(){return we(await c(Se()))}var X=r();function Ee(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=u(Oe),o;t[0]===a?o=t[1]:(o=f(a),t[0]=a,t[1]=o);let s=o.gatewaySettings,c;t[2]!==n||t[3]!==i?(c=n?[Se(),i]:null,t[2]=n,t[3]=i,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[5]=l):l=t[5];let{data:d,error:g,isLoading:_,isValidating:y,mutate:b}=p(c,De,l),x=d??null,S=g instanceof Error?g.message:g?String(g):null,C=_||y,w;t[6]===b?w=t[7]:(w=()=>{b(),m(Se())},t[6]=b,t[7]=w);let D=w,O=!n||C,k;t[8]===C?k=t[9]:(k=C?(0,X.jsx)(T,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=k);let A;t[10]===s.securityAuditRefresh?A=t[11]:(A=(0,X.jsx)(`span`,{className:`ml-1.5`,children:s.securityAuditRefresh}),t[10]=s.securityAuditRefresh,t[11]=A);let j;t[12]!==D||t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,X.jsxs)(h,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:D,children:[k,A]}),t[12]=D,t[13]=O,t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]!==s.securityAuditSubtitle||t[18]!==s.securityAuditTitle||t[19]!==j?(M=(0,X.jsx)(re,{icon:E,title:s.securityAuditTitle,subtitle:s.securityAuditSubtitle,trailing:j}),t[17]=s.securityAuditSubtitle,t[18]=s.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let N;t[21]===s.securityAuditSavedConfigHint?N=t[22]:(N=(0,X.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:s.securityAuditSavedConfigHint}),t[21]=s.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==S||t[24]!==s.securityAuditLoadError?(P=S?(0,X.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[s.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=s.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==x||t[27]!==S||t[28]!==C?(F=!S&&C&&!x?(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,X.jsx)(v,{className:`h-11 w-full rounded-lg`}),(0,X.jsx)(v,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=x,t[27]=S,t[28]=C,t[29]=F):F=t[29];let L;t[30]!==x||t[31]!==s?(L=x?(0,X.jsx)(ke,{g:s,audit:x}):null,t[30]=x,t[31]=s,t[32]=L):L=t[32];let R;return t[33]!==M||t[34]!==N||t[35]!==P||t[36]!==F||t[37]!==L?(R=(0,X.jsxs)(ie,{children:[M,N,P,F,L]}),t[33]=M,t[34]=N,t[35]=P,t[36]=F,t[37]=L,t[38]=R):R=t[38],R}function De(){return Te()}function Oe(e){return e.language}function ke(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,o,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Ne(n,r.status,r.findings),d=`space-y-4`,l=s(`rounded-lg px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,c=`flex items-start gap-2`,i=a.icon,o=s(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==o?(f=(0,X.jsx)(i,{className:o,"aria-hidden":!0}),t[10]=i,t[11]=o,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,X.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,X.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,X.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,X.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,X.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,X.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,X.jsx)(je,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,X.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,X.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Ae)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,X.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Ae(e){return(0,X.jsx)(`li`,{className:`font-mono`,children:e},e)}function je(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,o,c;if(t[0]!==r.severity){let e=Me(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,o=`flex items-start gap-2`,i=e.icon,a=s(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=o,t[4]=c}else i=t[1],a=t[2],o=t[3],c=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,X.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,X.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,X.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==o||t[26]!==l?(g=(0,X.jsxs)(`div`,{className:o,children:[l,h]}),t[24]=h,t[25]=o,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,X.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function Me(e){switch(e){case`critical`:return{icon:j,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:y,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:A,iconClass:`text-fg-muted`}}}function Ne(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:j,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`bg-red-50 text-red-950 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:y,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`bg-amber-50 text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:A,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`bg-surface-base/55 text-fg`}:{icon:E,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`bg-emerald-50 text-emerald-950 dark:bg-emerald-950/40 dark:text-emerald-100`}}var Pe=new Set([`updates`,`security`,`advanced`]);function Fe(e,t){return t===`advanced`?!0:!Pe.has(e)}function Ie(e,t){return e.filter(e=>Fe(e,t))}function Le(){return`network`}function Re(e,t){let n=(0,H.c)(5),r=R(ze),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{Fe(e,r)||t(Le())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,V.useEffect)(i,a)}function ze(e){return e.mode}function Z(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,D,`dark:border-edge`)}var Be=[`network`,`access`,`updates`,`security`,`advanced`],Ve={network:w,access:M,updates:I,security:x,advanced:N};function He(e){return e&&Be.includes(e)?e:`network`}function Ue(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function We(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Ke={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function qe(){let e=u(e=>e.language),t=f(e),n=t.gatewaySettings,[r,c]=i(),d=R(e=>e.mode),m=d===`advanced`,g=He(r.get(`tab`)),v=(0,V.useMemo)(()=>Ie(Be,d),[d]),y=(0,V.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]);Re(g,y);let x=l(e=>e.conversationId),S=l(e=>e.tokenExpired),w=l(e=>e.openTokenDialog),E=!!x,[D,A]=(0,V.useReducer)(Ge,{form:null,baseline:null,appliedBaseline:null}),M=D.form,N=D.baseline,P=D.appliedBaseline,[F,I]=(0,V.useReducer)(L,Ke),{saving:z,error:re,auditRefreshToken:ie,restarting:B,restartConfirmOpen:H}=F,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:q,isLoading:ce,mutate:le}=_(E),fe=p(E&&M?[`gateway-cors-origin-candidates`,M.port]:null,([,e])=>de(e),{revalidateOnFocus:!1}),J=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(ve(K.payload.config)),[K]);E?J!==null&&(G.current||(G.current=!0,A({type:`init-applied`,value:J})),!U.current&&W.current!==J&&(W.current=J,A({type:`sync`,value:J}),I({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,A({type:`reset`}),U.current=!1);let pe=!!(E&&ce&&K===void 0&&!q),me=q instanceof Error?q.message:q?String(q):null,Y=(0,V.useMemo)(()=>!M||!N?!1:JSON.stringify(M)!==JSON.stringify(N),[M,N]),he=(0,V.useMemo)(()=>!N||!P?!1:ue(P,N),[P,N]),ge=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),ye=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),xe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Se=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ce=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),we=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,port:e})})},[]),Te=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),De=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Oe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),ke=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Ae=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),je=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Me=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Ne=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Fe=(0,V.useCallback)(async()=>{if(!M||z)return;let e=_e(M);if(e){I({type:`patch`,patch:{error:e}});return}I({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await be(M),U.current=!1,A({type:`saved`,value:M}),I({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ie+1}})}catch(e){I({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{I({type:`patch`,patch:{saving:!1}})}},[M,z,n.saveError]),Le=(0,V.useCallback)(()=>{N&&(U.current=!1,A({type:`discard`}),I({type:`patch`,patch:{error:null,saveOk:!1}}))},[N]),ze=b(n),Ve=(0,V.useCallback)(async()=>{if(!B){I({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await C();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):I({type:`patch`,patch:{error:e.message||n.restartGatewayFailed}})}catch(e){I({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{I({type:`patch`,patch:{restarting:!1}})}}},[B,n.restartGatewayFailed]);return E?pe?(0,X.jsx)(ne,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,X.jsx)(ae,{sections:3})}):M?(0,X.jsxs)(ne,{gap:`gap-6`,children:[(0,X.jsx)(te,{title:t.settingsSections.gateway,docsLink:ee(e,`gateway`),docsLabel:n.docsLink,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(h,{type:`button`,variant:`secondary`,disabled:!Y||z,onClick:Le,children:n.discard}),(0,X.jsx)(h,{type:`button`,variant:`primary`,disabled:!Y||z,onClick:()=>void Fe(),children:z?n.saving:n.save})]})}),S?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-red-50 px-4 py-3 dark:bg-red-950/40`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,X.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,X.jsx)(`div`,{children:(0,X.jsx)(h,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>w(),children:n.updateToken})})]}):null,re?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:re}):null,he?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-amber-50 px-3 py-2 dark:bg-amber-950/40`,children:[(0,X.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,X.jsxs)(h,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:B,onClick:()=>I({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[B?(0,X.jsx)(T,{className:`size-3.5 animate-spin`}):(0,X.jsx)(O,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,X.jsx)(k,{open:H,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Ve(),onCancel:()=>I({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,X.jsx)(Je,{g:n,activeTab:g,visibleTabs:v,onChange:y}),(0,X.jsxs)(Q,{g:n,id:`network`,activeTab:g,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,X.jsxs)(a,{id:`gateway-bind-mode`,className:Z(),value:M.bind,onChange:e=>Se(e.target.value),children:[(0,X.jsx)(o,{value:`loopback`,children:n.bindLoopback}),m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{value:`lan`,children:n.bindLan}),(0,X.jsx)(o,{value:`auto`,children:n.bindAuto}),(0,X.jsx)(o,{value:`custom`,children:n.bindCustom}),(0,X.jsx)(o,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,X.jsx)(`input`,{id:`gateway-custom-bind-host`,className:s(Z(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Ce(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,X.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:s(Z(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);we(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]})]}),(0,X.jsx)(oe,{children:(0,X.jsx)(Qe,{g:n,origins:M.corsOrigins,candidates:fe.data??[],onChange:xe})})]}),(0,X.jsxs)(Q,{g:n,id:`access`,activeTab:g,children:[M.auth.mode===`none`?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,X.jsxs)(a,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>ge({mode:e.target.value}),className:Z(),children:[(0,X.jsx)(o,{value:`token`,children:n.authModeToken}),(0,X.jsx)(o,{value:`password`,children:n.authModePassword}),m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,X.jsx)(o,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,X.jsx)(oe,{children:M.auth.mode===`trusted-proxy`?(0,X.jsx)(Xe,{g:n,form:M,onTrustedProxyChange:je,onTrustedProxiesChange:Ae,onAllowRealIpFallbackChange:Ne}):null}),M.auth.mode===`token`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(nt,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:ze,reveal:()=>se(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>ge({token:e})}),(0,X.jsx)(h,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>w(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,X.jsx)(nt,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:ze,reveal:()=>se(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>ge({password:e})}):null,(0,X.jsx)(oe,{children:M.auth.mode===`none`?null:(0,X.jsx)(tt,{g:n,rateLimit:M.auth.rateLimit,onChange:Te})})]}),(0,X.jsxs)(Q,{g:n,id:`updates`,activeTab:g,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,X.jsxs)(a,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>ye(e.target.value),className:Z(),children:[(0,X.jsx)(o,{value:`stable`,children:n.channelStable}),(0,X.jsx)(o,{value:`beta`,children:n.channelBeta}),(0,X.jsx)(o,{value:`dev`,children:n.channelDev})]})]}),(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,X.jsx)(oe,{children:(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,X.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableDelayHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,X.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableJitterHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,X.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})})]})]}),(0,X.jsxs)(Q,{g:n,id:`security`,activeTab:g,children:[(0,X.jsx)(Ee,{enabled:E,refreshToken:ie}),(0,X.jsx)(Ye,{g:n,form:M,onSecurityStrictChange:Me,onDangerouslyAllowHostHeaderOriginFallbackChange:Pe})]}),(0,X.jsx)(Q,{g:n,id:`advanced`,activeTab:g,children:(0,X.jsx)(Ze,{g:n,form:M,onDeferModeChange:De,onDeferIdsChange:Oe,onSkipIdsChange:ke})})]}):(0,X.jsxs)(ne,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:re??me??n.loadError}),(0,X.jsx)(h,{type:`button`,variant:`secondary`,onClick:()=>void le(),children:n.retry})]}):(0,X.jsxs)(ne,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(te,{title:t.settingsSections.gateway}),(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Je(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Ue(n,e),icon:Ve[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,X.jsx)(B,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Q(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Ue(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=We(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,X.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,X.jsx)(z,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,showHeading:!1,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Ye(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,X.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,X.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,X.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function Xe(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:o}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=s(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,X.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,X.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,X.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,X.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,X.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,X.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,X.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===o?D=t[58]:(D=e=>o(e.target.checked),t[57]=o,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,X.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,X.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function Ze(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.channelConnectDeferMode?l=t[1]:(l=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=l);let u=r.channelConnectDeferMode,d;t[2]===i?d=t[3]:(d=e=>i(e.target.value),t[2]=i,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=Z(),t[4]=f):f=t[4];let p;t[5]===n.channelConnectDeferModeAuto?p=t[6]:(p=(0,X.jsx)(o,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=p);let m;t[7]===n.channelConnectDeferModeOff?m=t[8]:(m=(0,X.jsx)(o,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=m);let h;t[9]===n.channelConnectDeferModeExplicit?h=t[10]:(h=(0,X.jsx)(o,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=h);let g;t[11]!==r.channelConnectDeferMode||t[12]!==d||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,X.jsxs)(a,{id:`gateway-channel-defer-mode`,value:u,onChange:d,className:f,children:[p,m,h]}),t[11]=r.channelConnectDeferMode,t[12]=d,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;t[17]===n.channelConnectDeferModeHint?_=t[18]:(_=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=_);let v;t[19]!==l||t[20]!==g||t[21]!==_?(v=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[l,g,_]}),t[19]=l,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==s?(y=r.channelConnectDeferMode===`explicit`?(0,X.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=s,t[30]=y):y=t[30];let b;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==c?(b=r.channelConnectDeferMode===`off`?null:(0,X.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=c,t[38]=b):b=t[38];let x;return t[39]!==v||t[40]!==y||t[41]!==b?(x=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[v,y,b]}),t[39]=v,t[40]=y,t[41]=b,t[42]=x):x=t[42],x}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:o,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==o?(d=e=>{let t=e.trim();!t||o.includes(t)||o.length>=c||l([...o,t])},t[0]=c,t[1]=l,t[2]=o,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==o?(h=o.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:s(`text-fg-muted hover:text-fg`,F.press),"aria-label":`Remove ${e}`,onClick:()=>l(o.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=o,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let _=o.length>=c,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==a||t[16]!==_||t[17]!==v?(y=(0,X.jsx)(`input`,{className:g,placeholder:a,disabled:_,onKeyDown:v}),t[15]=a,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function Qe(e){let t=(0,H.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,l,u,d,f,p,m,g,_;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=$,l=n.corsOrigins,u=n.corsOriginsHint,d=n.corsOriginsEmpty,f=n.corsOriginsPlaceholder,p=r,m=128,g=a,_=o.length>0?(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(et)}),(0,X.jsx)(h,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map($e)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g,t[19]=_}else c=t[11],l=t[12],u=t[13],d=t[14],f=t[15],p=t[16],m=t[17],g=t[18],_=t[19];let v;t[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(v=s?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=v):v=t[24];let y;return t[25]!==c||t[26]!==v||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==g||t[34]!==_?(y=(0,X.jsxs)(c,{title:l,hint:u,emptyText:d,placeholder:f,values:p,maxItems:m,onChange:g,children:[_,v]}),t[25]=c,t[26]=v,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=g,t[34]=_,t[35]=y):y=t[35],y}function $e(e){return e.url}function et(e){return(0,X.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function tt(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,X.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,X.jsx)(`input`,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,X.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,X.jsx)(`input`,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,X.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,X.jsx)(`input`,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,X.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,X.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function nt(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,X.jsx)(S,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{qe as GatewaySettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-DcsFzD_i.js";import{t as s}from"./cn-JdwAhgNB.js";import{a as c,c as l,n as u,r as d}from"./locale-store-BPZR8x9b.js";import{t as f}from"./messages-kFWhF6_t.js";import{i as p,o as m}from"./vendor-swr-BIWyz7Rc.js";import{t as h}from"./button-CS04eWY9.js";import{n as g,r as _}from"./gateway-config-swr-CoQVulMd.js";import{t as v}from"./skeleton-BwbyijEw.js";import{Ac as y,Go as b,Jc as x,Ko as S,Nn as C,Ol as w,Ul as T,Xc as E,Zo as D,al as O,ba as k,cu as A,od as j,ou as M,qc as N,qo as P,qs as F,sl as I,wa as L,wn as R,zo as ee}from"./index-19rMUT3d.js";import{n as te,r as ne,t as z}from"./settings-page-layout-D6745w0p.js";import{n as re,t as ie}from"./settings-form-section-BXTJAser.js";import{t as B}from"./page-tabs-Dyc3wKkl.js";import{n as ae}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as oe}from"./settings-advanced-gate-CDNwmXuH.js";var V=e(t(),1),H=n(),U=18790,W={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return P(e)}async function se(e){let t=await c(d(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function q(e){return K(e)?``:e.trim()}function ce(e){return[...e].map(e=>e.trim()).sort()}function le(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:q(e.auth.token),password:q(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:ce(e.auth.trustedProxy.requiredHeaders),allowUsers:ce(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:ce(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function ue(e,t){return le(e)!==le(t)}async function de(e){return(await c(d(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function fe(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function J(e){let t=G(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):W.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):W.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):W.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function pe(e){let t=G(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:Y(t.requiredHeaders,32),allowUsers:Y(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function me(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function Y(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function he(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function ge(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function _e(e){let t=ge(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function ve(e){let t=G(e)?e:{},n=G(t.gateway)?t.gateway:{},r=G(n.auth)?n.auth:{},i=G(n.security)?n.security:{},a=G(t.update)?t.update:{},o=G(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:he(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):U,auth:{mode:fe(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:J(r.rateLimit),trustedProxy:pe(r.trustedProxy)},corsOrigins:l,trustedProxies:Y(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:me(n.channelConnectDeferMode),channelConnectDeferIds:Y(n.channelConnectDeferIds),channelConnectDeferSkipIds:Y(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function ye(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!K(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!K(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function be(e){let t=_e(e);if(t)throw Error(t);await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:ye(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),g()}var xe={critical:3,warn:2,info:1};function Se(){return d(`/api/doctor?security=true`)}function Ce(e){return e.toSorted((e,t)=>xe[t.severity]-xe[e.severity]||e.checkId.localeCompare(t.checkId))}function we(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=Ce((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function Te(){return we(await c(Se()))}var X=r();function Ee(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=u(Oe),o;t[0]===a?o=t[1]:(o=f(a),t[0]=a,t[1]=o);let s=o.gatewaySettings,c;t[2]!==n||t[3]!==i?(c=n?[Se(),i]:null,t[2]=n,t[3]=i,t[4]=c):c=t[4];let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l={revalidateOnFocus:!1},t[5]=l):l=t[5];let{data:d,error:g,isLoading:_,isValidating:y,mutate:b}=p(c,De,l),x=d??null,S=g instanceof Error?g.message:g?String(g):null,C=_||y,w;t[6]===b?w=t[7]:(w=()=>{b(),m(Se())},t[6]=b,t[7]=w);let D=w,O=!n||C,k;t[8]===C?k=t[9]:(k=C?(0,X.jsx)(T,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=k);let A;t[10]===s.securityAuditRefresh?A=t[11]:(A=(0,X.jsx)(`span`,{className:`ml-1.5`,children:s.securityAuditRefresh}),t[10]=s.securityAuditRefresh,t[11]=A);let j;t[12]!==D||t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,X.jsxs)(h,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:D,children:[k,A]}),t[12]=D,t[13]=O,t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]!==s.securityAuditSubtitle||t[18]!==s.securityAuditTitle||t[19]!==j?(M=(0,X.jsx)(re,{icon:E,title:s.securityAuditTitle,subtitle:s.securityAuditSubtitle,trailing:j}),t[17]=s.securityAuditSubtitle,t[18]=s.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let N;t[21]===s.securityAuditSavedConfigHint?N=t[22]:(N=(0,X.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:s.securityAuditSavedConfigHint}),t[21]=s.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==S||t[24]!==s.securityAuditLoadError?(P=S?(0,X.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[s.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=s.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==x||t[27]!==S||t[28]!==C?(F=!S&&C&&!x?(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,X.jsx)(v,{className:`h-11 w-full rounded-lg`}),(0,X.jsx)(v,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=x,t[27]=S,t[28]=C,t[29]=F):F=t[29];let L;t[30]!==x||t[31]!==s?(L=x?(0,X.jsx)(ke,{g:s,audit:x}):null,t[30]=x,t[31]=s,t[32]=L):L=t[32];let R;return t[33]!==M||t[34]!==N||t[35]!==P||t[36]!==F||t[37]!==L?(R=(0,X.jsxs)(ie,{children:[M,N,P,F,L]}),t[33]=M,t[34]=N,t[35]=P,t[36]=F,t[37]=L,t[38]=R):R=t[38],R}function De(){return Te()}function Oe(e){return e.language}function ke(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,a,o,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Ne(n,r.status,r.findings),d=`space-y-4`,l=s(`rounded-lg px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,c=`flex items-start gap-2`,i=a.icon,o=s(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==o?(f=(0,X.jsx)(i,{className:o,"aria-hidden":!0}),t[10]=i,t[11]=o,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,X.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,X.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,X.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,X.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,X.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,X.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,X.jsx)(je,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,X.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,X.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Ae)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,X.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Ae(e){return(0,X.jsx)(`li`,{className:`font-mono`,children:e},e)}function je(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,a,o,c;if(t[0]!==r.severity){let e=Me(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,o=`flex items-start gap-2`,i=e.icon,a=s(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=o,t[4]=c}else i=t[1],a=t[2],o=t[3],c=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,X.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,X.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,X.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==o||t[26]!==l?(g=(0,X.jsxs)(`div`,{className:o,children:[l,h]}),t[24]=h,t[25]=o,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,X.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function Me(e){switch(e){case`critical`:return{icon:j,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:y,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:A,iconClass:`text-fg-muted`}}}function Ne(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:j,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`bg-red-50 text-red-950 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:y,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`bg-amber-50 text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:A,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`bg-surface-base/55 text-fg`}:{icon:E,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`bg-emerald-50 text-emerald-950 dark:bg-emerald-950/40 dark:text-emerald-100`}}var Pe=new Set([`updates`,`security`,`advanced`]);function Fe(e,t){return t===`advanced`?!0:!Pe.has(e)}function Ie(e,t){return e.filter(e=>Fe(e,t))}function Le(){return`network`}function Re(e,t){let n=(0,H.c)(5),r=R(ze),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{Fe(e,r)||t(Le())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,V.useEffect)(i,a)}function ze(e){return e.mode}function Z(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,D,`dark:border-edge`)}var Be=[`network`,`access`,`updates`,`security`,`advanced`],Ve={network:w,access:M,updates:I,security:x,advanced:N};function He(e){return e&&Be.includes(e)?e:`network`}function Ue(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function We(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Ke={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function qe(){let e=u(e=>e.language),t=f(e),n=t.gatewaySettings,[r,c]=i(),d=R(e=>e.mode),m=d===`advanced`,g=He(r.get(`tab`)),v=(0,V.useMemo)(()=>Ie(Be,d),[d]),y=(0,V.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]);Re(g,y);let x=l(e=>e.conversationId),S=l(e=>e.tokenExpired),w=l(e=>e.openTokenDialog),E=!!x,[D,A]=(0,V.useReducer)(Ge,{form:null,baseline:null,appliedBaseline:null}),M=D.form,N=D.baseline,P=D.appliedBaseline,[F,I]=(0,V.useReducer)(L,Ke),{saving:z,error:re,auditRefreshToken:ie,restarting:B,restartConfirmOpen:H}=F,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:q,isLoading:ce,mutate:le}=_(E),fe=p(E&&M?[`gateway-cors-origin-candidates`,M.port]:null,([,e])=>de(e),{revalidateOnFocus:!1}),J=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(ve(K.payload.config)),[K]);E?J!==null&&(G.current||(G.current=!0,A({type:`init-applied`,value:J})),!U.current&&W.current!==J&&(W.current=J,A({type:`sync`,value:J}),I({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,A({type:`reset`}),U.current=!1);let pe=!!(E&&ce&&K===void 0&&!q),me=q instanceof Error?q.message:q?String(q):null,Y=(0,V.useMemo)(()=>!M||!N?!1:JSON.stringify(M)!==JSON.stringify(N),[M,N]),he=(0,V.useMemo)(()=>!N||!P?!1:ue(P,N),[P,N]),ge=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),ye=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),xe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Se=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ce=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),we=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,port:e})})},[]),Te=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),De=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Oe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),ke=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Ae=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),je=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Me=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Ne=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Fe=(0,V.useCallback)(async()=>{if(!M||z)return;let e=_e(M);if(e){I({type:`patch`,patch:{error:e}});return}I({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await be(M),U.current=!1,A({type:`saved`,value:M}),I({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ie+1}})}catch(e){I({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{I({type:`patch`,patch:{saving:!1}})}},[M,z,n.saveError]),Le=(0,V.useCallback)(()=>{N&&(U.current=!1,A({type:`discard`}),I({type:`patch`,patch:{error:null,saveOk:!1}}))},[N]),ze=b(n),Ve=(0,V.useCallback)(async()=>{if(!B){I({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await C();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):I({type:`patch`,patch:{error:e.message||n.restartGatewayFailed}})}catch(e){I({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{I({type:`patch`,patch:{restarting:!1}})}}},[B,n.restartGatewayFailed]);return E?pe?(0,X.jsx)(ne,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,X.jsx)(ae,{sections:3})}):M?(0,X.jsxs)(ne,{gap:`gap-6`,children:[(0,X.jsx)(te,{title:t.settingsSections.gateway,docsLink:ee(e,`gateway`),docsLabel:n.docsLink,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(h,{type:`button`,variant:`secondary`,disabled:!Y||z,onClick:Le,children:n.discard}),(0,X.jsx)(h,{type:`button`,variant:`primary`,disabled:!Y||z,onClick:()=>void Fe(),children:z?n.saving:n.save})]})}),S?(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-red-50 px-4 py-3 dark:bg-red-950/40`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(j,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,X.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,X.jsx)(`div`,{children:(0,X.jsx)(h,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>w(),children:n.updateToken})})]}):null,re?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:re}):null,he?(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-amber-50 px-3 py-2 dark:bg-amber-950/40`,children:[(0,X.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,X.jsxs)(h,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:B,onClick:()=>I({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[B?(0,X.jsx)(T,{className:`size-3.5 animate-spin`}):(0,X.jsx)(O,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,X.jsx)(k,{open:H,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Ve(),onCancel:()=>I({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,X.jsx)(Je,{g:n,activeTab:g,visibleTabs:v,onChange:y}),(0,X.jsxs)(Q,{g:n,id:`network`,activeTab:g,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,X.jsxs)(a,{id:`gateway-bind-mode`,className:Z(),value:M.bind,onChange:e=>Se(e.target.value),children:[(0,X.jsx)(o,{value:`loopback`,children:n.bindLoopback}),m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{value:`lan`,children:n.bindLan}),(0,X.jsx)(o,{value:`auto`,children:n.bindAuto}),(0,X.jsx)(o,{value:`custom`,children:n.bindCustom}),(0,X.jsx)(o,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,X.jsx)(`input`,{id:`gateway-custom-bind-host`,className:s(Z(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Ce(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,X.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:s(Z(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);we(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]})]}),(0,X.jsx)(oe,{children:(0,X.jsx)(Qe,{g:n,origins:M.corsOrigins,candidates:fe.data??[],onChange:xe})})]}),(0,X.jsxs)(Q,{g:n,id:`access`,activeTab:g,children:[M.auth.mode===`none`?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,X.jsxs)(a,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>ge({mode:e.target.value}),className:Z(),children:[(0,X.jsx)(o,{value:`token`,children:n.authModeToken}),(0,X.jsx)(o,{value:`password`,children:n.authModePassword}),m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(o,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,X.jsx)(o,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,X.jsx)(oe,{children:M.auth.mode===`trusted-proxy`?(0,X.jsx)(Xe,{g:n,form:M,onTrustedProxyChange:je,onTrustedProxiesChange:Ae,onAllowRealIpFallbackChange:Ne}):null}),M.auth.mode===`token`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(nt,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:ze,reveal:()=>se(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>ge({token:e})}),(0,X.jsx)(h,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>w(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,X.jsx)(nt,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:ze,reveal:()=>se(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>ge({password:e})}):null,(0,X.jsx)(oe,{children:M.auth.mode===`none`?null:(0,X.jsx)(tt,{g:n,rateLimit:M.auth.rateLimit,onChange:Te})})]}),(0,X.jsxs)(Q,{g:n,id:`updates`,activeTab:g,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,X.jsxs)(a,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>ye(e.target.value),className:Z(),children:[(0,X.jsx)(o,{value:`stable`,children:n.channelStable}),(0,X.jsx)(o,{value:`beta`,children:n.channelBeta}),(0,X.jsx)(o,{value:`dev`,children:n.channelDev})]})]}),(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,X.jsx)(oe,{children:(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,X.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableDelayHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,X.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoStableJitterHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,X.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:Z(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,A({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})})]})]}),(0,X.jsxs)(Q,{g:n,id:`security`,activeTab:g,children:[(0,X.jsx)(Ee,{enabled:E,refreshToken:ie}),(0,X.jsx)(Ye,{g:n,form:M,onSecurityStrictChange:Me,onDangerouslyAllowHostHeaderOriginFallbackChange:Pe})]}),(0,X.jsx)(Q,{g:n,id:`advanced`,activeTab:g,children:(0,X.jsx)(Ze,{g:n,form:M,onDeferModeChange:De,onDeferIdsChange:Oe,onSkipIdsChange:ke})})]}):(0,X.jsxs)(ne,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:re??me??n.loadError}),(0,X.jsx)(h,{type:`button`,variant:`secondary`,onClick:()=>void le(),children:n.retry})]}):(0,X.jsxs)(ne,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsx)(te,{title:t.settingsSections.gateway}),(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Je(e){let t=(0,H.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Ue(n,e),icon:Ve[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,X.jsx)(B,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Q(e){let t=(0,H.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Ue(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=We(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,X.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,X.jsx)(z,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,showHeading:!1,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Ye(e){let t=(0,H.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,X.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,X.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,X.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function Xe(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:o}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,X.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=s(Z(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,X.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,X.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,X.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,X.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,X.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,X.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,X.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===o?D=t[58]:(D=e=>o(e.target.checked),t[57]=o,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,X.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,X.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,X.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function Ze(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.channelConnectDeferMode?l=t[1]:(l=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=l);let u=r.channelConnectDeferMode,d;t[2]===i?d=t[3]:(d=e=>i(e.target.value),t[2]=i,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=Z(),t[4]=f):f=t[4];let p;t[5]===n.channelConnectDeferModeAuto?p=t[6]:(p=(0,X.jsx)(o,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=p);let m;t[7]===n.channelConnectDeferModeOff?m=t[8]:(m=(0,X.jsx)(o,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=m);let h;t[9]===n.channelConnectDeferModeExplicit?h=t[10]:(h=(0,X.jsx)(o,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=h);let g;t[11]!==r.channelConnectDeferMode||t[12]!==d||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,X.jsxs)(a,{id:`gateway-channel-defer-mode`,value:u,onChange:d,className:f,children:[p,m,h]}),t[11]=r.channelConnectDeferMode,t[12]=d,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;t[17]===n.channelConnectDeferModeHint?_=t[18]:(_=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=_);let v;t[19]!==l||t[20]!==g||t[21]!==_?(v=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[l,g,_]}),t[19]=l,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==s?(y=r.channelConnectDeferMode===`explicit`?(0,X.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=s,t[30]=y):y=t[30];let b;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==c?(b=r.channelConnectDeferMode===`off`?null:(0,X.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=c,t[38]=b):b=t[38];let x;return t[39]!==v||t[40]!==y||t[41]!==b?(x=(0,X.jsxs)(`div`,{className:`space-y-4`,children:[v,y,b]}),t[39]=v,t[40]=y,t[41]=b,t[42]=x):x=t[42],x}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:o,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==o?(d=e=>{let t=e.trim();!t||o.includes(t)||o.length>=c||l([...o,t])},t[0]=c,t[1]=l,t[2]=o,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==o?(h=o.length===0?(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:s(`text-fg-muted hover:text-fg`,F.press),"aria-label":`Remove ${e}`,onClick:()=>l(o.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=o,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(Z(),`font-mono text-xs`),t[12]=g):g=t[12];let _=o.length>=c,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==a||t[16]!==_||t[17]!==v?(y=(0,X.jsx)(`input`,{className:g,placeholder:a,disabled:_,onKeyDown:v}),t[15]=a,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function Qe(e){let t=(0,H.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,l,u,d,f,p,m,g,_;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=$,l=n.corsOrigins,u=n.corsOriginsHint,d=n.corsOriginsEmpty,f=n.corsOriginsPlaceholder,p=r,m=128,g=a,_=o.length>0?(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(et)}),(0,X.jsx)(h,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map($e)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=g,t[19]=_}else c=t[11],l=t[12],u=t[13],d=t[14],f=t[15],p=t[16],m=t[17],g=t[18],_=t[19];let v;t[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(v=s?(0,X.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=v):v=t[24];let y;return t[25]!==c||t[26]!==v||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==g||t[34]!==_?(y=(0,X.jsxs)(c,{title:l,hint:u,emptyText:d,placeholder:f,values:p,maxItems:m,onChange:g,children:[_,v]}),t[25]=c,t[26]=v,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=g,t[34]=_,t[35]=y):y=t[35],y}function $e(e){return e.url}function et(e){return(0,X.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function tt(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,X.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Z(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,X.jsx)(`input`,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,X.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Z(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,X.jsx)(`input`,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,X.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,X.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Z(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,X.jsx)(`input`,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,X.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,X.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function nt(e){let t=(0,H.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,X.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,X.jsx)(S,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{qe as GatewaySettingsPanel};
|