@xopcai/xopc 0.0.192 → 0.0.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-B-tzXpDD.js → activity-store-BwmdJ5pv.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-xOu0qNwc.js → agent-avatar-dicebear-DmNq0t2n.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-BOo1rVn9.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-fMItZb-h.js → api-BM1hNzjw.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-D6Rv3OWI.js → app-management-settings-panel-B3xStqSX.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-CKoNCwco.js → appearance-settings-DglyenDq.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-DC9qPFTx.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BokNQBwH.js → archive-plugin-DvtcrBss.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Dx1HglsM.js → attachment-load-CALdq4xM.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BIGGKb0T.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-CPYAflIG.js → binary-plugins-GaVuvrDI.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-BFLgl8SS.js → block-editor-C2KrMYa_.js} +47 -47
  15. package/dist/gateway/static/root/assets/browser-settings-page-CPW_E-xj.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CqLnqA9z.js → browser-workflow-inputs-FfEEjhIS.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-Db5v3HtE.js → browser-workflows-page-DFP9_UQk.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-CsD8aGHU.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api-lov0J9A2.js → capability-presets-api-BoOzFotX.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-NCeyWH6Z.js +3 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-DSJznouK.js → channel-recipient-api-_8IiTxRB.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-CknzwxNC.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-DPaJSYX_.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-3ccRyS3L.js → connectors-api-vaSrhPF8.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-DEGE7xp_.js +2 -0
  26. package/dist/gateway/static/root/assets/{cron-expression-C9hhCiuo.js → cron-expression-BjFuXlGY.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dependency-picker-CTtZFZug.js → dependency-picker-DOdkHdPv.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-DOUeNVmC.js → desktop-pet-Dz-Yf8Uu.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-D4704vtl.js → desktop-pet-settings-C8EHFEtd.js} +1 -1
  30. package/dist/gateway/static/root/assets/{directory-picker-path-field-DJDXeA1B.js → directory-picker-path-field-DKbfmZlZ.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-C0n2NMF1.js → extension-debug-page-Dq0xsr_e.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-vG-xxRNs.js → extension-page-IgSLUyWP.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-CtuY2THd.js → extension-settings-page-VC-8Pjn2.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-CZra7GuI.js → gateway-config-api-CH2R7yqo.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-Cz33jRkR.js → gateway-settings-DLQJWaBQ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-BbVV0udv.js → gateway-startup-retry--2njcDpC.js} +1 -1
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-D2XMlA_U.js → heartbeat-settings-43loWoGb.js} +1 -1
  38. package/dist/gateway/static/root/assets/home-page-DqvpI6LC.js +3 -0
  39. package/dist/gateway/static/root/assets/{image-generation-api-BgrOvhaJ.js → image-generation-api-Cki7jfEV.js} +1 -1
  40. package/dist/gateway/static/root/assets/{index-DzmbmOGA.js → index-BpkdvHH0.js} +61 -61
  41. package/dist/gateway/static/root/assets/index-CFVjH-EK.css +1 -0
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BfyAEG1G.js → keyboard-shortcuts-settings-DJDZes_8.js} +1 -1
  43. package/dist/gateway/static/root/assets/local-app-workbench-page-CvNQM6qm.js +2 -0
  44. package/dist/gateway/static/root/assets/{local-apps-page-BYalcRSY.js → local-apps-page-C2ajOn1D.js} +1 -1
  45. package/dist/gateway/static/root/assets/{locale-store-VOY1wMO9.js → locale-store-Bjvw7jtg.js} +1 -1
  46. package/dist/gateway/static/root/assets/logs-page-BLm5yWqQ.js +2 -0
  47. package/dist/gateway/static/root/assets/{management-settings-BQf-6s32.js → management-settings--_eXnFVr.js} +1 -1
  48. package/dist/gateway/static/root/assets/{markdown-split-Cy_2SN1Q.js → markdown-split-iL2oi-x2.js} +1 -1
  49. package/dist/gateway/static/root/assets/{media-plugins-CkDupqb2.js → media-plugins-BIbkLVpQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{messages-DMJ-6-1m.js → messages-DQ5X6cXp.js} +2 -2
  51. package/dist/gateway/static/root/assets/{notes-page-kiGRR9jo.js → notes-page-xFxaZ6gT.js} +1 -1
  52. package/dist/gateway/static/root/assets/notes-workbench-PAftxL3V.js +4 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-CvzSdYVj.js → page-tabs-CROi9zm1.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-kZ0nco7e.js → preview-open-alternatives-BwYcPjOM.js} +1 -1
  55. package/dist/gateway/static/root/assets/{product-open-page-DgoieqQC.js → product-open-page-BezeuVFd.js} +1 -1
  56. package/dist/gateway/static/root/assets/project-detail-page-CCdfZcw-.js +1 -0
  57. package/dist/gateway/static/root/assets/projects-page-DOG9zm5e.js +1 -0
  58. package/dist/gateway/static/root/assets/remote-access-hub-DQBFgveI.js +1 -0
  59. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bud_NTEZ.js → runtime-tools-settings-panel-Bs6tpSyX.js} +2 -2
  60. package/dist/gateway/static/root/assets/{schema-form-GlbsCBmv.js → schema-form-CWoSjz9s.js} +1 -1
  61. package/dist/gateway/static/root/assets/sessions-page-Db6L6M2H.js +1 -0
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-CcO2bd6q.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-form-section-CKLns16d.js → settings-form-section-BJaMEHsX.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BDzpxgk0.js → settings-loading-skeleton-sn4k17x7.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-BH0pF7QB.js → settings-page-D2hfeFPX.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-layout-J793iqfm.js → settings-page-layout-CLtUsWsu.js} +1 -1
  67. package/dist/gateway/static/root/assets/setup-status-panel-UmQC_uZ1.js +1 -0
  68. package/dist/gateway/static/root/assets/{share-preview-page-UTm_7r0l.js → share-preview-page-BJ58AluH.js} +1 -1
  69. package/dist/gateway/static/root/assets/shares-settings-BZKn6Fdc.js +1 -0
  70. package/dist/gateway/static/root/assets/skill-reload-api-Cx3i24w_.js +1 -0
  71. package/dist/gateway/static/root/assets/skills-page-DjUllGtk.js +2 -0
  72. package/dist/gateway/static/root/assets/{skills-page.utils-Bwid1TGB.js → skills-page.utils-CZYIuE26.js} +1 -1
  73. package/dist/gateway/static/root/assets/system-settings-panel-DUrgdQMk.js +1 -0
  74. package/dist/gateway/static/root/assets/task-detail-page-BGG2cFe9.js +1 -0
  75. package/dist/gateway/static/root/assets/{theme-store-GVZOImyb.js → theme-store-DtxpMC5S.js} +1 -1
  76. package/dist/gateway/static/root/assets/{typed-models-lib-CT2c85Ju.js → typed-models-lib-CRNMvvFX.js} +1 -1
  77. package/dist/gateway/static/root/assets/{use-autosave-CcvY7DTh.js → use-autosave-Dle3-zdQ.js} +1 -1
  78. package/dist/gateway/static/root/assets/user-context-page-BLLmw5S1.js +1 -0
  79. package/dist/gateway/static/root/assets/{voice-api-key-field-Ricc3QGo.js → voice-api-key-field-BrWH0dCl.js} +1 -1
  80. package/dist/gateway/static/root/assets/{work-discovery-overlay-BoomfqhX.js → work-discovery-overlay-BZ1l9CFM.js} +1 -1
  81. package/dist/gateway/static/root/assets/work-discovery-page-BnPF2vx7.js +1 -0
  82. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BK6e9yzK.js +3 -0
  83. package/dist/gateway/static/root/assets/workflows-page-Bp5JxQJa.js +5 -0
  84. package/dist/gateway/static/root/index.html +7 -7
  85. package/dist/gateway/static/root/notification-sw.js +15 -0
  86. package/dist/package.js +1 -1
  87. package/dist/src/auth/oauth/xopc-cloud.js +163 -7
  88. package/dist/src/gateway/heartbeat/service.js +1 -1
  89. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  90. package/dist/src/gateway/service/run-gateway-agent.js +21 -8
  91. package/dist/src/heartbeat/index.js +1 -1
  92. package/package.json +3 -3
  93. package/dist/gateway/static/root/assets/agents-CxuwvDk0.js +0 -68
  94. package/dist/gateway/static/root/assets/apps-page-wAb5dnHZ.js +0 -1
  95. package/dist/gateway/static/root/assets/automations-page-Drgazevs.js +0 -6
  96. package/dist/gateway/static/root/assets/browser-settings-page-DmYlFJW7.js +0 -8
  97. package/dist/gateway/static/root/assets/capabilities-settings-panel-D7Z8T0o5.js +0 -7
  98. package/dist/gateway/static/root/assets/capability-presets-settings-panel-COjnwO0U.js +0 -3
  99. package/dist/gateway/static/root/assets/channels-settings-DcRYBNN7.js +0 -1
  100. package/dist/gateway/static/root/assets/channels-status-swr-C2UYdebT.js +0 -1
  101. package/dist/gateway/static/root/assets/connectors-page-FVmvBG9H.js +0 -2
  102. package/dist/gateway/static/root/assets/home-page-CPrHkPN6.js +0 -3
  103. package/dist/gateway/static/root/assets/index-Cg7Xnlu3.css +0 -1
  104. package/dist/gateway/static/root/assets/local-app-workbench-page-Clz47vSr.js +0 -2
  105. package/dist/gateway/static/root/assets/logs-page-Cxq9WMf5.js +0 -2
  106. package/dist/gateway/static/root/assets/notes-workbench-DkYkPGyB.js +0 -4
  107. package/dist/gateway/static/root/assets/project-detail-page-CeSjJd-N.js +0 -1
  108. package/dist/gateway/static/root/assets/projects-page-fZ1rm4b9.js +0 -1
  109. package/dist/gateway/static/root/assets/remote-access-hub-CbYI6KC8.js +0 -1
  110. package/dist/gateway/static/root/assets/sessions-page-sOJ_TnLm.js +0 -1
  111. package/dist/gateway/static/root/assets/settings-advanced-gate-BI0u77dt.js +0 -1
  112. package/dist/gateway/static/root/assets/setup-status-panel-CGsml89P.js +0 -1
  113. package/dist/gateway/static/root/assets/shares-settings-BM--lgUS.js +0 -1
  114. package/dist/gateway/static/root/assets/skill-reload-api-CGCOC-rV.js +0 -1
  115. package/dist/gateway/static/root/assets/skills-page-iLyaOl48.js +0 -2
  116. package/dist/gateway/static/root/assets/system-settings-panel-BcB3p1e3.js +0 -1
  117. package/dist/gateway/static/root/assets/task-detail-page-DQYEf08v.js +0 -1
  118. package/dist/gateway/static/root/assets/user-context-page-CGI41bfO.js +0 -1
  119. package/dist/gateway/static/root/assets/work-discovery-page-mbnepbQk.js +0 -1
  120. package/dist/gateway/static/root/assets/workflow-run-setup-panel-DSWG2xqL.js +0 -3
  121. package/dist/gateway/static/root/assets/workflows-page-DtV0ruyk.js +0 -5
@@ -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{l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DMJ-6-1m.js";import{n as s}from"./locale-store-VOY1wMO9.js";import{Ho as c,Nc as l,No as u,Ol as d,Ta as f,Uo as p,ac as m,bc as h,ls as g,oc as _,tu as v,xs as y}from"./index-DzmbmOGA.js";import{t as b}from"./desktop-pet-sprite-DTqXSpqf.js";import{n as x,r as S}from"./settings-page-layout-J793iqfm.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=o(s(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!u()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(f,{className:`h-14 rounded-xl`}),(0,T.jsx)(f,{className:`h-14 rounded-xl`}),(0,T.jsx)(f,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(f,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),G=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,g.press),disabled:C,onClick:()=>void M(),children:[(0,T.jsx)(_,{className:a(`size-3.5`,C&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(y,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,g.press),onClick:B,children:[(0,T.jsx)(l,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.bondTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondDesc})]}),(0,T.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:e.bondSummary.replace(`{days}`,String(W)).replace(`{tasks}`,String(n.relationship.completedTaskCount))})]}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,g.press),onClick:()=>V(t),children:[(0,T.jsx)(h,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,g.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(v,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,g.press),onClick:()=>H(t),children:[(0,T.jsx)(l,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void G(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&G()},onPointerUp:()=>void G()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})}),(0,T.jsx)(E,{title:e.proactiveTips,desc:e.proactiveTipsDesc,checked:n.prefs.proactiveTipsEnabled,disabled:C,onChange:e=>void N({proactiveTipsEnabled:e})}),(0,T.jsx)(E,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:C,onChange:e=>void N({interactionEnabled:e})}),(0,T.jsx)(E,{title:e.reducedMotion,desc:e.reducedMotionDesc,checked:n.prefs.reducedMotion,disabled:C,onChange:e=>void N({reducedMotion:e})}),(0,T.jsx)(E,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:C,onChange:e=>void N({clickThroughWhenIdle:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.behaviorModeDesc})]}),(0,T.jsxs)(c,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,onChange:e=>void N({behaviorMode:e.target.value}),children:[(0,T.jsx)(p,{value:`focus`,children:e.behaviorFocus}),(0,T.jsx)(p,{value:`companion`,children:e.behaviorCompanion}),(0,T.jsx)(p,{value:`playful`,children:e.behaviorPlayful})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,g.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(m,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DQ5X6cXp.js";import{n as s}from"./locale-store-Bjvw7jtg.js";import{Al as c,Cs as l,Da as u,Fc as d,Fo as f,Go as p,Sc as m,Wo as h,cc as g,ds as _,ru as v,sc as y}from"./index-BpkdvHH0.js";import{t as b}from"./desktop-pet-sprite-DTqXSpqf.js";import{n as x,r as S}from"./settings-page-layout-CLtUsWsu.js";var C=n(),w=e(t(),1),T=r();function E(e){let t=(0,C.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,T.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,T.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function D(){let e=o(s(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,w.useState)(null),[C,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),A=typeof window<`u`?window.electronAPI?.pet:void 0,j=(0,w.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),M=(0,w.useCallback)(async()=>{if(A){D(!0);try{r(await A.getState())}finally{D(!1)}}},[A]);if((0,w.useEffect)(()=>{if(A)return M(),A.onStateChanged(r)},[A,M]),!f()||!A)return null;if(!n)return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle}),(0,T.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,T.jsxs)(`div`,{className:`space-y-3`,children:[(0,T.jsx)(u,{className:`h-14 rounded-xl`}),(0,T.jsx)(u,{className:`h-14 rounded-xl`}),(0,T.jsx)(u,{className:`h-24 rounded-xl`}),(0,T.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,T.jsx)(u,{className:`h-16 rounded-xl`},t))})]})})]});let N=async e=>{D(!0);try{r(await A.setPrefs(e))}finally{D(!1)}},P=async e=>{e?(await A.show(),r(await A.getState())):r(await A.setPrefs({enabled:!1}))},F=e=>{N({selectedPetId:e})},I=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},L=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},R=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=I(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},z=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),B=()=>{L(e.createChatDraft)},V=t=>{L(z(e.optimizeChatDraft,{id:t.id,name:I(t).name,description:I(t).description,sourcePrompt:R(t)}))},H=t=>{L(z(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},U=O??n.prefs.sizePercent,W=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),G=async(e=U)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));k(null),t!==n.prefs.sizePercent&&await N({sizePercent:t})};return(0,T.jsxs)(S,{gap:`gap-4`,children:[(0,T.jsx)(x,{title:e.title,subtitle:e.subtitle,actions:(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,_.press),disabled:C,onClick:()=>void M(),children:[(0,T.jsx)(g,{className:a(`size-3.5`,C&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,_.press),onClick:()=>void A.openCustomPetsDir(),children:[(0,T.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,T.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(E,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:C,onChange:e=>void P(e)}),(0,T.jsx)(E,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:C,onChange:e=>void N({showOnStartup:e})})]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,T.jsx)(l,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,_.press),onClick:B,children:[(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,T.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.bondTitle}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondDesc})]}),(0,T.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:e.bondSummary.replace(`{days}`,String(W)).replace(`{tasks}`,String(n.relationship.completedTaskCount))})]}),(0,T.jsxs)(`div`,{className:`mt-5`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),j?(0,T.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:I(j).name}):null]}),(0,T.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,i=I(t);return(0,T.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,T.jsx)(b,{pet:t,action:`idle`,size:`tiny`}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:i.name}),t.builtin?null:(0,T.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:i.description})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,_.press),onClick:()=>V(t),children:[(0,T.jsx)(m,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,T.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,_.press),disabled:r||C,onClick:()=>F(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,T.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,T.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void A.openCustomPetsDir(),children:[e.openFolder,(0,T.jsx)(c,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,T.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,T.jsx)(v,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,T.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,T.jsx)(`p`,{children:t.reason}),t.details?.length?(0,T.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,_.press),onClick:()=>H(t),children:[(0,T.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,T.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,T.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[U,`%`]})]}),(0,T.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:U,onChange:e=>k(Number(e.target.value)),onBlur:()=>void G(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&G()},onPointerUp:()=>void G()})]}),(0,T.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,T.jsx)(E,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:C,onChange:e=>void N({alwaysOnTop:e})}),(0,T.jsx)(E,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:C,onChange:e=>void N({bubbleEnabled:e})}),(0,T.jsx)(E,{title:e.proactiveTips,desc:e.proactiveTipsDesc,checked:n.prefs.proactiveTipsEnabled,disabled:C,onChange:e=>void N({proactiveTipsEnabled:e})}),(0,T.jsx)(E,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:C,onChange:e=>void N({interactionEnabled:e})}),(0,T.jsx)(E,{title:e.reducedMotion,desc:e.reducedMotionDesc,checked:n.prefs.reducedMotion,disabled:C,onChange:e=>void N({reducedMotion:e})}),(0,T.jsx)(E,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:C,onChange:e=>void N({clickThroughWhenIdle:e})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 p-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.behaviorModeDesc})]}),(0,T.jsxs)(h,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,onChange:e=>void N({behaviorMode:e.target.value}),children:[(0,T.jsx)(p,{value:`focus`,children:e.behaviorFocus}),(0,T.jsx)(p,{value:`companion`,children:e.behaviorCompanion}),(0,T.jsx)(p,{value:`playful`,children:e.behaviorPlayful})]})]}),(0,T.jsxs)(`button`,{type:`button`,className:a(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,_.press),disabled:C,onClick:()=>void A.resetPosition().then(r),children:[(0,T.jsx)(y,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{D as DesktopPetSettings};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Dt as r,Mt as i,jt as a}from"./index-DzmbmOGA.js";var o=e(),s=t();function c(e){let t=(0,o.c)(38),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,autoFocus:m,trailing:h}=e,g;t[0]!==l||t[1]!==c?(g={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=g):g=t[2];let _=a(g),v;t[3]===c?v=t[4]:(v=c.trim(),t[3]=c,t[4]=v);let y=v,b=y?`${y}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,x;t[5]===p?x=t[6]:(x=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=x);let S=u||_.picking,C;t[7]===l?C=t[8]:(C=e=>void l(e.target.value),t[7]=l,t[8]=C);let w=f??d.pathInputPlaceholder,T;t[9]!==m||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==c?(T=(0,s.jsx)(`input`,{type:`text`,className:x,value:c,disabled:S,onChange:C,placeholder:w,autoFocus:m,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=x,t[11]=S,t[12]=C,t[13]=w,t[14]=c,t[15]=T):T=t[15];let E=u||_.picking,D;t[16]!==b||t[17]!==_.pick||t[18]!==E||t[19]!==c||t[20]!==d.selectWorkingDirectory?(D=(0,s.jsx)(i,{compact:!0,value:c,onPick:_.pick,disabled:E,title:b,"aria-label":d.selectWorkingDirectory}),t[16]=b,t[17]=_.pick,t[18]=E,t[19]=c,t[20]=d.selectWorkingDirectory,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==h?(O=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[D,h]}),t[22]=D,t[23]=h,t[24]=O):O=t[24];let k;t[25]!==O||t[26]!==T?(k=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[T,O]}),t[25]=O,t[26]=T,t[27]=k):k=t[27];let A;t[28]!==_.confirmPick||t[29]!==_.hasNativePicker||t[30]!==_.modalOpen||t[31]!==_.setModalOpen||t[32]!==y||t[33]!==d?(A=_.hasNativePicker?null:(0,s.jsx)(r,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:d}),t[28]=_.confirmPick,t[29]=_.hasNativePicker,t[30]=_.modalOpen,t[31]=_.setModalOpen,t[32]=y,t[33]=d,t[34]=A):A=t[34];let j;return t[35]!==k||t[36]!==A?(j=(0,s.jsxs)(s.Fragment,{children:[k,A]}),t[35]=k,t[36]=A,t[37]=j):j=t[37],j}export{c as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Dt as r,Mt as i,jt as a}from"./index-BpkdvHH0.js";var o=e(),s=t();function c(e){let t=(0,o.c)(38),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,autoFocus:m,trailing:h}=e,g;t[0]!==l||t[1]!==c?(g={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=g):g=t[2];let _=a(g),v;t[3]===c?v=t[4]:(v=c.trim(),t[3]=c,t[4]=v);let y=v,b=y?`${y}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,x;t[5]===p?x=t[6]:(x=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=x);let S=u||_.picking,C;t[7]===l?C=t[8]:(C=e=>void l(e.target.value),t[7]=l,t[8]=C);let w=f??d.pathInputPlaceholder,T;t[9]!==m||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==c?(T=(0,s.jsx)(`input`,{type:`text`,className:x,value:c,disabled:S,onChange:C,placeholder:w,autoFocus:m,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=x,t[11]=S,t[12]=C,t[13]=w,t[14]=c,t[15]=T):T=t[15];let E=u||_.picking,D;t[16]!==b||t[17]!==_.pick||t[18]!==E||t[19]!==c||t[20]!==d.selectWorkingDirectory?(D=(0,s.jsx)(i,{compact:!0,value:c,onPick:_.pick,disabled:E,title:b,"aria-label":d.selectWorkingDirectory}),t[16]=b,t[17]=_.pick,t[18]=E,t[19]=c,t[20]=d.selectWorkingDirectory,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==h?(O=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[D,h]}),t[22]=D,t[23]=h,t[24]=O):O=t[24];let k;t[25]!==O||t[26]!==T?(k=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[T,O]}),t[25]=O,t[26]=T,t[27]=k):k=t[27];let A;t[28]!==_.confirmPick||t[29]!==_.hasNativePicker||t[30]!==_.modalOpen||t[31]!==_.setModalOpen||t[32]!==y||t[33]!==d?(A=_.hasNativePicker?null:(0,s.jsx)(r,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:d}),t[28]=_.confirmPick,t[29]=_.hasNativePicker,t[30]=_.modalOpen,t[31]=_.setModalOpen,t[32]=y,t[33]=d,t[34]=A):A=t[34];let j;return t[35]!==k||t[36]!==A?(j=(0,s.jsxs)(s.Fragment,{children:[k,A]}),t[35]=k,t[36]=A,t[37]=j):j=t[37],j}export{c 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{t as r}from"./messages-DMJ-6-1m.js";import{n as i}from"./locale-store-VOY1wMO9.js";import{ka as a}from"./index-DzmbmOGA.js";var o=t();e();var s=n();function c(){let e=(0,o.c)(44),t=i(d),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let c=n.extensionDebug,f=a(),p;e[2]===f?p=e[3]:(p=f.toSorted(u),e[2]=f,e[3]=p);let m=p,h;e[4]===c.title?h=e[5]:(h=(0,s.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:c.title}),e[4]=c.title,e[5]=h);let g;e[6]===c.subtitle?g=e[7]:(g=(0,s.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.subtitle}),e[6]=c.subtitle,e[7]=g);let _;e[8]!==h||e[9]!==g?(_=(0,s.jsxs)(`div`,{children:[h,g]}),e[8]=h,e[9]=g,e[10]=_):_=e[10];let v;e[11]===c.listHeading?v=e[12]:(v=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.listHeading}),e[11]=c.listHeading,e[12]=v);let y;e[13]===c.colId?y=e[14]:(y=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colId}),e[13]=c.colId,e[14]=y);let b;e[15]===c.colName?b=e[16]:(b=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colName}),e[15]=c.colName,e[16]=b);let x;e[17]===c.colPermissions?x=e[18]:(x=(0,s.jsx)(`th`,{className:`py-2`,children:c.colPermissions}),e[17]=c.colPermissions,e[18]=x);let S;e[19]!==y||e[20]!==b||e[21]!==x?(S=(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[19]=y,e[20]=b,e[21]=x,e[22]=S):S=e[22];let C;e[23]===m?C=e[24]:(C=m.map(l),e[23]=m,e[24]=C);let w;e[25]===C?w=e[26]:(w=(0,s.jsx)(`tbody`,{children:C}),e[25]=C,e[26]=w);let T;e[27]!==w||e[28]!==S?(T=(0,s.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[S,w]})}),e[27]=w,e[28]=S,e[29]=T):T=e[29];let E;e[30]!==T||e[31]!==v?(E=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[v,T]}),e[30]=T,e[31]=v,e[32]=E):E=e[32];let D;e[33]===c.futureHeading?D=e[34]:(D=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.futureHeading}),e[33]=c.futureHeading,e[34]=D);let O;e[35]===c.futureBody?O=e[36]:(O=(0,s.jsx)(`p`,{className:`mt-2`,children:c.futureBody}),e[35]=c.futureBody,e[36]=O);let k;e[37]!==D||e[38]!==O?(k=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-muted/50 p-4 text-sm text-fg-muted shadow-surface`,children:[D,O]}),e[37]=D,e[38]=O,e[39]=k):k=e[39];let A;return e[40]!==E||e[41]!==k||e[42]!==_?(A=(0,s.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[_,E,k]}),e[40]=E,e[41]=k,e[42]=_,e[43]=A):A=e[43],A}function l(e){return(0,s.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,s.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,s.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,s.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function u(e,t){return e.id.localeCompare(t.id)}function d(e){return e.language}export{c as ExtensionDebugPage};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-DQ5X6cXp.js";import{n as i}from"./locale-store-Bjvw7jtg.js";import{ja as a}from"./index-BpkdvHH0.js";var o=t();e();var s=n();function c(){let e=(0,o.c)(44),t=i(d),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let c=n.extensionDebug,f=a(),p;e[2]===f?p=e[3]:(p=f.toSorted(u),e[2]=f,e[3]=p);let m=p,h;e[4]===c.title?h=e[5]:(h=(0,s.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:c.title}),e[4]=c.title,e[5]=h);let g;e[6]===c.subtitle?g=e[7]:(g=(0,s.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.subtitle}),e[6]=c.subtitle,e[7]=g);let _;e[8]!==h||e[9]!==g?(_=(0,s.jsxs)(`div`,{children:[h,g]}),e[8]=h,e[9]=g,e[10]=_):_=e[10];let v;e[11]===c.listHeading?v=e[12]:(v=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.listHeading}),e[11]=c.listHeading,e[12]=v);let y;e[13]===c.colId?y=e[14]:(y=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colId}),e[13]=c.colId,e[14]=y);let b;e[15]===c.colName?b=e[16]:(b=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colName}),e[15]=c.colName,e[16]=b);let x;e[17]===c.colPermissions?x=e[18]:(x=(0,s.jsx)(`th`,{className:`py-2`,children:c.colPermissions}),e[17]=c.colPermissions,e[18]=x);let S;e[19]!==y||e[20]!==b||e[21]!==x?(S=(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[19]=y,e[20]=b,e[21]=x,e[22]=S):S=e[22];let C;e[23]===m?C=e[24]:(C=m.map(l),e[23]=m,e[24]=C);let w;e[25]===C?w=e[26]:(w=(0,s.jsx)(`tbody`,{children:C}),e[25]=C,e[26]=w);let T;e[27]!==w||e[28]!==S?(T=(0,s.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[S,w]})}),e[27]=w,e[28]=S,e[29]=T):T=e[29];let E;e[30]!==T||e[31]!==v?(E=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[v,T]}),e[30]=T,e[31]=v,e[32]=E):E=e[32];let D;e[33]===c.futureHeading?D=e[34]:(D=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.futureHeading}),e[33]=c.futureHeading,e[34]=D);let O;e[35]===c.futureBody?O=e[36]:(O=(0,s.jsx)(`p`,{className:`mt-2`,children:c.futureBody}),e[35]=c.futureBody,e[36]=O);let k;e[37]!==D||e[38]!==O?(k=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-muted/50 p-4 text-sm text-fg-muted shadow-surface`,children:[D,O]}),e[37]=D,e[38]=O,e[39]=k):k=e[39];let A;return e[40]!==E||e[41]!==k||e[42]!==_?(A=(0,s.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[_,E,k]}),e[40]=E,e[41]=k,e[42]=_,e[43]=A):A=e[43],A}function l(e){return(0,s.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,s.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,s.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,s.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function u(e,t){return e.id.localeCompare(t.id)}function d(e){return e.language}export{c as ExtensionDebugPage};
@@ -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{d as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{Fa as a,Ma as o,dt as s,ka as c}from"./index-DzmbmOGA.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=i(),r=c(),f=a(m),g=a(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&o(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)(s,{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
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{La as a,Pa as o,dt as s,ja as c}from"./index-BpkdvHH0.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=i(),r=c(),f=a(m),g=a(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&o(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)(s,{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{d as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DMJ-6-1m.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-VOY1wMO9.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Ho as m,Uo as h,dt as g,fs as _,hs as v,ka as y,ms as b,ps as x}from"./index-DzmbmOGA.js";import{t as S}from"./settings-loading-skeleton-BDzpxgk0.js";import{n as C,t as w}from"./use-autosave-CcvY7DTh.js";import{o as T,s as E,t as D,u as O}from"./voice-api-key-field-Ricc3QGo.js";import{t as k}from"./schema-form-GlbsCBmv.js";var A=e(t(),1),j=n(),M=r();function N(e){let t=(0,j.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function P(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 F(){return o(x,_)}function I(){return o(`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 L(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 R({providerId:e,voiceSettings:t,mutateVoice:n}){let r=s(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,c={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=p(d(`/api/voice/stt-providers`),E,{revalidateOnFocus:!1}),f=(0,A.useMemo)(()=>u?.providers.find(t=>t.id===e),[e,u]),g=f?.configured??!1,v=f?.models??[],y=v[0]?.id??f?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,A.useMemo)(()=>L(t,e,y),[y,e,t]),x=(0,A.useRef)(!1),[S,T]=(0,A.useState)(null),k=S??b,j=(0,A.useRef)(k);j.current=k;let P=b,R=w({value:k,dirty:k.apiKey!==P.apiKey||k.model!==P.model,onSave:(0,A.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(j.current)!==JSON.stringify(r),T(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),z=v.length>0?v:k.model?[{id:k.model,name:k.model}]:[];return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:R.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:R.status,error:R.error}),(0,M.jsx)(`span`,{className:o(`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,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(N,{children:i.stt.apiKey}),(0,M.jsx)(D,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:k.apiKey,onChange:e=>{x.current=!0,T(t=>({...t??b,apiKey:e}))},labels:c,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,M.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(N,{children:i.stt.model}),z.length>0?(0,M.jsx)(m,{className:F(),value:k.model,onChange:e=>{x.current=!0,T(t=>({...t??b,model:e.target.value})),R.saveNow({...k,model:e.target.value})},children:z.map(e=>(0,M.jsx)(h,{value:e.id,children:e.name},e.id))}):(0,M.jsx)(`input`,{className:I(),value:k.model,onChange:e=>{x.current=!0,T(t=>({...t??b,model:e.target.value}))}})]})]})]})}function z(e){let t=(0,j.c)(13),{extensionId:n}=e,r=l(V),i=c(B),a;t[0]===n?a=t[1]:(a=()=>f(d(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=p(i&&n?`ext-stt-detail-${n}`:null,a),u;t[2]===o?u=t[3]:(u=P(o),t[2]=o,t[3]=u);let m=u,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=p(i?`voice-settings-ext-stt`:null,T,h);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsx)(S,{rows:2}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,M.jsx)(R,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function B(e){return!!e.token}function V(e){return e.language}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U(e){let t={};if(e.type!==`object`||!H(e.properties))return t;for(let[n,r]of Object.entries(e.properties))H(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function W(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 G({extensionId:e}){let t=c(e=>!!e.token),{data:n,error:r}=p(t&&e?`ext-detail-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=p(t&&e?`ext-cfg-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,l=(0,A.useMemo)(()=>s&&s.type===`object`?U(s):{},[s]),m=(0,A.useMemo)(()=>({...l,...i??{}}),[l,i]),[h,g]=(0,A.useReducer)(W,{localValues:{},isDirty:!1}),_=(0,A.useRef)(!1),y=(0,A.useRef)(h.localValues);y.current=h.localValues;let b=(0,A.useRef)(m);!_.current&&b.current!==m&&(b.current=m,g({type:`sync`,value:m}));let x=(0,A.useCallback)(e=>{_.current=!0,g({type:`change`,value:e})},[]),S=(0,A.useCallback)(()=>{!s||s.type!==`object`||(_.current=!0,g({type:`reset-defaults`,value:{...U(s)}}))},[s]),T=(0,A.useCallback)(async t=>{if(!e)return;let n=await u(d(`/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),g({type:`saved`,value:t}),_.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),E=w({value:h.localValues,dirty:h.isDirty,onSave:T});if(!t)return null;if(r||o){let e=r??o;return(0,M.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,M.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,onBlurCapture:E.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:E.status,error:E.error}),(0,M.jsx)(v,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,M.jsx)(k,{schema:s,values:h.localValues,onChange:x})]})}function K(){let e=(0,j.c)(38),t=l(q),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:c}=i(),u=y();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(J,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,p;if(e[3]!==o||e[4]!==u||e[5]!==c){p=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),d=u.find(t),!d){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,M.jsx)(J,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=c?n?.find(e=>e.id===c||e.id===`${o}.${c}`):n?.[0]}e[3]=o,e[4]=u,e[5]=c,e[6]=d,e[7]=f,e[8]=p}else d=e[6],f=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m=f,h=!!(m&&d.ui),_=!!d.hasConfigSchema,v=d.kind===`media-provider`;if(!_&&!h&&!v){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,M.jsx)(J,{message:t}),e[13]=t,e[14]=n),n}let b=m?.title??`${d.name} Settings`,x;e[15]===b?x=e[16]:(x=(0,M.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:b}),e[15]=b,e[16]=x);let S;e[17]!==v||e[18]!==r?(S=v?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,M.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]=S):S=e[19];let C;e[20]!==o||e[21]!==v?(C=v?(0,M.jsx)(z,{extensionId:o}):null,e[20]=o,e[21]=v,e[22]=C):C=e[22];let w;e[23]!==o||e[24]!==_?(w=_?(0,M.jsx)(G,{extensionId:o}):null,e[23]=o,e[24]=_,e[25]=w):w=e[25];let T;e[26]!==d.name||e[27]!==d.ui||e[28]!==o||e[29]!==h||e[30]!==m?(T=h&&m&&d.ui?(0,M.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,M.jsx)(g,{extensionId:o,extensionName:d.name,entrypoint:m.entrypoint,permissions:d.ui?.permissions,title:m.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=d.name,e[27]=d.ui,e[28]=o,e[29]=h,e[30]=m,e[31]=T):T=e[31];let E;return e[32]!==x||e[33]!==S||e[34]!==C||e[35]!==w||e[36]!==T?(E=(0,M.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[x,S,C,w,T]}),e[32]=x,e[33]=S,e[34]=C,e[35]=w,e[36]=T,e[37]=E):E=e[37],E}function q(e){return e.language}function J(e){let t=(0,j.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{K 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{d as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DQ5X6cXp.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Bjvw7jtg.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Go as m,Wo as h,_s as g,dt as _,gs as v,hs as y,ja as b,ms as x}from"./index-BpkdvHH0.js";import{t as S}from"./settings-loading-skeleton-sn4k17x7.js";import{n as C,t as w}from"./use-autosave-Dle3-zdQ.js";import{o as T,s as E,t as D,u as O}from"./voice-api-key-field-BrWH0dCl.js";import{t as k}from"./schema-form-CWoSjz9s.js";var A=e(t(),1),j=n(),M=r();function N(e){let t=(0,j.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function P(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 F(){return o(y,x)}function I(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,v,`dark:border-edge`)}function L(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 R({providerId:e,voiceSettings:t,mutateVoice:n}){let r=s(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,c={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:u}=p(d(`/api/voice/stt-providers`),E,{revalidateOnFocus:!1}),f=(0,A.useMemo)(()=>u?.providers.find(t=>t.id===e),[e,u]),g=f?.configured??!1,_=f?.models??[],v=_[0]?.id??f?.fields.find(e=>e.key===`model`)?.defaultValue??``,y=(0,A.useMemo)(()=>L(t,e,v),[v,e,t]),b=(0,A.useRef)(!1),[S,T]=(0,A.useState)(null),k=S??y,j=(0,A.useRef)(k);j.current=k;let P=y,R=w({value:k,dirty:k.apiKey!==P.apiKey||k.model!==P.model,onSave:(0,A.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),b.current=JSON.stringify(j.current)!==JSON.stringify(r),T(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),z=_.length>0?_:k.model?[{id:k.model,name:k.model}]:[];return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:R.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:R.status,error:R.error}),(0,M.jsx)(`span`,{className:o(`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,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,x),children:[(0,M.jsx)(N,{children:i.stt.apiKey}),(0,M.jsx)(D,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:k.apiKey,onChange:e=>{b.current=!0,T(t=>({...t??y,apiKey:e}))},labels:c,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,M.jsxs)(`div`,{className:o(`flex flex-col gap-1.5`,x),children:[(0,M.jsx)(N,{children:i.stt.model}),z.length>0?(0,M.jsx)(h,{className:F(),value:k.model,onChange:e=>{b.current=!0,T(t=>({...t??y,model:e.target.value})),R.saveNow({...k,model:e.target.value})},children:z.map(e=>(0,M.jsx)(m,{value:e.id,children:e.name},e.id))}):(0,M.jsx)(`input`,{className:I(),value:k.model,onChange:e=>{b.current=!0,T(t=>({...t??y,model:e.target.value}))}})]})]})]})}function z(e){let t=(0,j.c)(13),{extensionId:n}=e,r=l(V),i=c(B),a;t[0]===n?a=t[1]:(a=()=>f(d(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=p(i&&n?`ext-stt-detail-${n}`:null,a),u;t[2]===o?u=t[3]:(u=P(o),t[2]=o,t[3]=u);let m=u,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=p(i?`voice-settings-ext-stt`:null,T,h);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsx)(S,{rows:2}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,M.jsx)(R,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function B(e){return!!e.token}function V(e){return e.language}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U(e){let t={};if(e.type!==`object`||!H(e.properties))return t;for(let[n,r]of Object.entries(e.properties))H(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function W(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 G({extensionId:e}){let t=c(e=>!!e.token),{data:n,error:r}=p(t&&e?`ext-detail-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=p(t&&e?`ext-cfg-${e}`:null,()=>f(d(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,l=(0,A.useMemo)(()=>s&&s.type===`object`?U(s):{},[s]),m=(0,A.useMemo)(()=>({...l,...i??{}}),[l,i]),[h,_]=(0,A.useReducer)(W,{localValues:{},isDirty:!1}),v=(0,A.useRef)(!1),y=(0,A.useRef)(h.localValues);y.current=h.localValues;let b=(0,A.useRef)(m);!v.current&&b.current!==m&&(b.current=m,_({type:`sync`,value:m}));let x=(0,A.useCallback)(e=>{v.current=!0,_({type:`change`,value:e})},[]),S=(0,A.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,_({type:`reset-defaults`,value:{...U(s)}}))},[s]),T=(0,A.useCallback)(async t=>{if(!e)return;let n=await u(d(`/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]),E=w({value:h.localValues,dirty:h.isDirty,onSave:T});if(!t)return null;if(r||o){let e=r??o;return(0,M.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,M.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl bg-surface-base p-4`,onBlurCapture:E.onBlurCapture,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(C,{status:E.status,error:E.error}),(0,M.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,M.jsx)(k,{schema:s,values:h.localValues,onChange:x})]})}function K(){let e=(0,j.c)(38),t=l(q),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:c}=i(),u=b();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(J,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,p;if(e[3]!==o||e[4]!==u||e[5]!==c){p=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),d=u.find(t),!d){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,M.jsx)(J,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=c?n?.find(e=>e.id===c||e.id===`${o}.${c}`):n?.[0]}e[3]=o,e[4]=u,e[5]=c,e[6]=d,e[7]=f,e[8]=p}else d=e[6],f=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m=f,h=!!(m&&d.ui),g=!!d.hasConfigSchema,v=d.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,M.jsx)(J,{message:t}),e[13]=t,e[14]=n),n}let y=m?.title??`${d.name} Settings`,x;e[15]===y?x=e[16]:(x=(0,M.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:y}),e[15]=y,e[16]=x);let S;e[17]!==v||e[18]!==r?(S=v?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,M.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]=S):S=e[19];let C;e[20]!==o||e[21]!==v?(C=v?(0,M.jsx)(z,{extensionId:o}):null,e[20]=o,e[21]=v,e[22]=C):C=e[22];let w;e[23]!==o||e[24]!==g?(w=g?(0,M.jsx)(G,{extensionId:o}):null,e[23]=o,e[24]=g,e[25]=w):w=e[25];let T;e[26]!==d.name||e[27]!==d.ui||e[28]!==o||e[29]!==h||e[30]!==m?(T=h&&m&&d.ui?(0,M.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,M.jsx)(_,{extensionId:o,extensionName:d.name,entrypoint:m.entrypoint,permissions:d.ui?.permissions,title:m.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=d.name,e[27]=d.ui,e[28]=o,e[29]=h,e[30]=m,e[31]=T):T=e[31];let E;return e[32]!==x||e[33]!==S||e[34]!==C||e[35]!==w||e[36]!==T?(E=(0,M.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[x,S,C,w,T]}),e[32]=x,e[33]=S,e[34]=C,e[35]=w,e[36]=T,e[37]=E):E=e[37],E}function q(e){return e.language}function J(e){let t=(0,j.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{K as ExtensionSettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-VOY1wMO9.js";import{do as a,ss as o,wr as s}from"./index-DzmbmOGA.js";var c=e(t(),1),l=n(),u=new Set([`updates`,`security`,`advanced`]),d=new Set([`local`,`cdp`,`cloud`]);function f(e,t){return t===`advanced`?!0:!u.has(e)}function p(e,t){return e.filter(e=>f(e,t))}function m(e,t){return t===`advanced`?!0:!d.has(e)}function h(e,t){return e.filter(e=>m(e,t))}function g(){return`network`}function _(){return`overview`}function v(e,t){let n=(0,l.c)(5),r=s(y),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{f(e,r)||t(g())},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,c.useEffect)(i,a)}function y(e){return e.mode}function b(e,t){let n=(0,l.c)(5),r=s(x),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{m(e,r)||t(_())},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,c.useEffect)(i,a)}function x(e){return e.mode}var S=18790,C={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return o(e)}async function E(e){let t=await i(r(`/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}async function D(){let e=await i(r(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok||!e.payload)throw Error(e.error?.message??`Reveal failed`);return e.payload}function O(e){return T(e)?``:e.trim()}function k(e){return[...e].map(e=>e.trim()).sort()}function A(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:O(e.auth.token),password:O(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:k(e.auth.trustedProxy.requiredHeaders),allowUsers:k(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},corsOrigins:k(e.corsOrigins),trustedProxies:k(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function j(e,t){return A(e)!==A(t)}function M(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function N(e){let t=w(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):C.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):C.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):C.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function P(e){let t=w(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:I(t.requiredHeaders,32),allowUsers:I(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function F(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function I(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 L(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function R(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 z(e){let t=R(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 B(e){let t=w(e)?e:{},n=w(t.gateway)?t.gateway:{},r=w(n.auth)?n.auth:{},i=w(n.security)?n.security:{},a=w(t.update)?t.update:{},o=w(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:L(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):S,auth:{mode:M(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:N(r.rateLimit),trustedProxy:P(r.trustedProxy)},corsOrigins:l,trustedProxies:I(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:F(n.channelConnectDeferMode),channelConnectDeferIds:I(n.channelConnectDeferIds),channelConnectDeferSkipIds:I(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 V(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&&!T(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&&!T(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 H(e){let t=z(e);if(t)throw Error(t);await i(r(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:V(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}}})}),a()}export{E as a,v as c,p as d,D as i,m as l,B as n,z as o,H as r,b as s,j as t,h as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{r,s as i}from"./locale-store-Bjvw7jtg.js";import{Or as a,ls as o,po as s}from"./index-BpkdvHH0.js";var c=e(t(),1),l=n(),u=new Set([`updates`,`security`,`advanced`]),d=new Set([`local`,`cdp`,`cloud`]);function f(e,t){return t===`advanced`?!0:!u.has(e)}function p(e,t){return e.filter(e=>f(e,t))}function m(e,t){return t===`advanced`?!0:!d.has(e)}function h(e,t){return e.filter(e=>m(e,t))}function g(){return`network`}function _(){return`overview`}function v(e,t){let n=(0,l.c)(5),r=a(y),i,o;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{f(e,r)||t(g())},o=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=o):(i=n[3],o=n[4]),(0,c.useEffect)(i,o)}function y(e){return e.mode}function b(e,t){let n=(0,l.c)(5),r=a(x),i,o;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{m(e,r)||t(_())},o=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=o):(i=n[3],o=n[4]),(0,c.useEffect)(i,o)}function x(e){return e.mode}var S=18790,C={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return o(e)}async function E(e){let t=await i(r(`/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}async function D(){let e=await i(r(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok||!e.payload)throw Error(e.error?.message??`Reveal failed`);return e.payload}function O(e){return T(e)?``:e.trim()}function k(e){return[...e].map(e=>e.trim()).sort()}function A(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:O(e.auth.token),password:O(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:k(e.auth.trustedProxy.requiredHeaders),allowUsers:k(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},corsOrigins:k(e.corsOrigins),trustedProxies:k(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function j(e,t){return A(e)!==A(t)}function M(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function N(e){let t=w(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):C.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):C.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):C.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function P(e){let t=w(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:I(t.requiredHeaders,32),allowUsers:I(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function F(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function I(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 L(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function R(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 z(e){let t=R(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 B(e){let t=w(e)?e:{},n=w(t.gateway)?t.gateway:{},r=w(n.auth)?n.auth:{},i=w(n.security)?n.security:{},a=w(t.update)?t.update:{},o=w(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:L(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):S,auth:{mode:M(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:N(r.rateLimit),trustedProxy:P(r.trustedProxy)},corsOrigins:l,trustedProxies:I(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:F(n.channelConnectDeferMode),channelConnectDeferIds:I(n.channelConnectDeferIds),channelConnectDeferSkipIds:I(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 V(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&&!T(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&&!T(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 H(e){let t=z(e);if(t)throw Error(t);await i(r(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:V(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}}})}),s()}export{E as a,v as c,p as d,D as i,m as l,B as n,z as o,H as r,b as s,j as t,h as u};
@@ -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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DMJ-6-1m.js";import{l as s,n as c,r as l,s as u}from"./locale-store-VOY1wMO9.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{At as p,Ec as m,En as h,Ho as g,Js as _,Lc as v,Lo as y,Qc as b,Ta as x,Uo as S,Xs as C,as as w,el as T,fo as E,hs as D,ic as O,js as k,kr as A,ls as j,ms as M,oc as N,os as P,qs as F,tu as I,wr as L}from"./index-DzmbmOGA.js";import{n as R,r as ee,t as z}from"./settings-page-layout-J793iqfm.js";import{n as te}from"./settings-loading-skeleton-BDzpxgk0.js";import{t as ne}from"./settings-advanced-gate-BI0u77dt.js";import{n as B,t as re}from"./settings-form-section-CKLns16d.js";import{t as ie}from"./page-tabs-CvzSdYVj.js";import{a as ae,c as oe,d as se,n as ce,o as le,r as ue,t as de}from"./gateway-config-api-CZra7GuI.js";var V=e(t(),1),H=n(),fe={critical:3,warn:2,info:1};function U(){return l(`/api/doctor?security=true`)}function W(e){return e.toSorted((e,t)=>fe[t.severity]-fe[e.severity]||e.checkId.localeCompare(t.checkId))}function G(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=W((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 K(){return G(await u(U()))}var q=r();function pe(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=c(me),s;t[0]===a?s=t[1]:(s=o(a),t[0]=a,t[1]=s);let l=s.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[U(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:h,isLoading:g,isValidating:_,mutate:y}=d(u,J,p),b=m??null,S=h instanceof Error?h.message:h?String(h):null,w=g||_,T;t[6]===y?T=t[7]:(T=()=>{y(),f(U())},t[6]=y,t[7]=T);let E=T,O=!n||w,k;t[8]===w?k=t[9]:(k=w?(0,q.jsx)(v,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,q.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}),t[8]=w,t[9]=k);let A;t[10]===l.securityAuditRefresh?A=t[11]:(A=(0,q.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=A);let j;t[12]!==E||t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,q.jsxs)(D,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:E,children:[k,A]}),t[12]=E,t[13]=O,t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==j?(M=(0,q.jsx)(B,{icon:C,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:j}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let P;t[21]===l.securityAuditSavedConfigHint?P=t[22]:(P=(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=P);let F;t[23]!==S||t[24]!==l.securityAuditLoadError?(F=S?(0,q.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=l.securityAuditLoadError,t[25]=F):F=t[25];let I;t[26]!==b||t[27]!==S||t[28]!==w?(I=!S&&w&&!b?(0,q.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,q.jsx)(x,{className:`h-11 w-full rounded-lg`}),(0,q.jsx)(x,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=b,t[27]=S,t[28]=w,t[29]=I):I=t[29];let L;t[30]!==b||t[31]!==l?(L=b?(0,q.jsx)(he,{g:l,audit:b}):null,t[30]=b,t[31]=l,t[32]=L):L=t[32];let R;return t[33]!==M||t[34]!==P||t[35]!==F||t[36]!==I||t[37]!==L?(R=(0,q.jsxs)(re,{children:[M,P,F,I,L]}),t[33]=M,t[34]=P,t[35]=F,t[36]=I,t[37]=L,t[38]=R):R=t[38],R}function J(){return K()}function me(e){return e.language}function he(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,o,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(o=ve(n,r.status,r.findings),d=`space-y-4`,l=a(`rounded-lg border px-3 py-2.5 text-sm`,o.bannerClass),u=`status`,c=`flex items-start gap-2`,i=o.icon,s=a(`mt-0.5 size-4 shrink-0`,o.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==s?(f=(0,q.jsx)(i,{className:s,"aria-hidden":!0}),t[10]=i,t[11]=s,t[12]=f):f=t[12];let p;t[13]===o.title?p=t[14]:(p=(0,q.jsx)(`p`,{className:`font-medium`,children:o.title}),t[13]=o.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,q.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,q.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,q.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,q.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,q.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,q.jsx)(ge,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,q.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,q.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,q.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Y)})]}):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,q.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 Y(e){return(0,q.jsx)(`li`,{className:`font-mono`,children:e},e)}function ge(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,o,s,c;if(t[0]!==r.severity){let e=_e(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,i=e.icon,o=a(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=o,t[3]=s,t[4]=c}else i=t[1],o=t[2],s=t[3],c=t[4];let l;t[5]!==i||t[6]!==o?(l=(0,q.jsx)(i,{className:o,"aria-hidden":!0}),t[5]=i,t[6]=o,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,q.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,q.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,q.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,q.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,q.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,q.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,q.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]!==s||t[26]!==l?(g=(0,q.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,q.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function _e(e){switch(e){case`critical`:return{icon:I,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:k,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:T,iconClass:`text-fg-muted`}}}function ve(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:I,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`border-red-200 bg-red-50 text-red-950 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:k,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:T,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:C,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900/50 dark:bg-emerald-950/40 dark:text-emerald-100`}}function X(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,M,`dark:border-edge`)}var ye=[`network`,`access`,`updates`,`security`,`advanced`],be={network:m,access:b,updates:N,security:_,advanced:F};function xe(e){return e&&ye.includes(e)?e:`network`}function Z(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Se(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function Ce(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 we={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Te(){let e=c(e=>e.language),t=o(e),n=t.gatewaySettings,[r,l]=i(),u=L(e=>e.mode),d=u===`advanced`,f=xe(r.get(`tab`)),m=(0,V.useMemo)(()=>se(ye,u),[u]),_=(0,V.useCallback)(e=>{l(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[l]);oe(f,_);let b=s(e=>e.token),x=s(e=>e.tokenExpired),C=s(e=>e.openTokenDialog),T=!!b,[k,j]=(0,V.useReducer)(Ce,{form:null,baseline:null,appliedBaseline:null}),M=k.form,N=k.baseline,P=k.appliedBaseline,[F,z]=(0,V.useReducer)(p,we),{saving:B,error:re,auditRefreshToken:ie,restarting:H,restartConfirmOpen:fe}=F,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:J,isLoading:me,mutate:he}=E(T),Y=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(ce(K.payload.config)),[K]);T?Y!==null&&(G.current||(G.current=!0,j({type:`init-applied`,value:Y})),!U.current&&W.current!==Y&&(W.current=Y,j({type:`sync`,value:Y}),z({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,j({type:`reset`}),U.current=!1);let ge=!!(T&&me&&K===void 0&&!J),_e=J instanceof Error?J.message:J?String(J):null,ve=(0,V.useMemo)(()=>!M||!N?!1:JSON.stringify(M)!==JSON.stringify(N),[M,N]),be=(0,V.useMemo)(()=>!N||!P?!1:de(P,N),[P,N]),Z=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),Se=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Te=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),$=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ne=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,port:e})})},[]),Fe=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ie=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Le=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Re=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),ze=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Be=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Ve=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),He=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ue=(0,V.useCallback)(e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),We=(0,V.useCallback)(async()=>{if(!M||B)return;let e=le(M);if(e){z({type:`patch`,patch:{error:e}});return}z({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await ue(M),U.current=!1,j({type:`saved`,value:M}),z({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ie+1}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{z({type:`patch`,patch:{saving:!1}})}},[M,B,n.saveError]),Ge=(0,V.useCallback)(()=>{N&&(U.current=!1,j({type:`discard`}),z({type:`patch`,patch:{error:null,saveOk:!1}}))},[N]),Ke=w(n),qe=(0,V.useCallback)(async()=>{if(!H){z({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await A();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):z({type:`patch`,patch:{error:e.message||n.restartGatewayFailed}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{z({type:`patch`,patch:{restarting:!1}})}}},[H,n.restartGatewayFailed]);return T?ge?(0,q.jsx)(ee,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,q.jsx)(te,{sections:3})}):M?(0,q.jsxs)(ee,{gap:`gap-6`,children:[(0,q.jsx)(R,{title:t.settingsSections.gateway,subtitle:n.subtitle,docsLink:y(e,`gateway`),docsLabel:n.docsLink,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(D,{type:`button`,variant:`secondary`,disabled:!ve||B,onClick:Ge,children:n.discard}),(0,q.jsx)(D,{type:`button`,variant:`primary`,disabled:!ve||B,onClick:()=>void We(),children:B?n.saving:n.save})]})}),x?(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(I,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,q.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,q.jsx)(`div`,{children:(0,q.jsx)(D,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>C(),children:n.updateToken})})]}):null,ve?(0,q.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,re?(0,q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:re}):null,be?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/40`,children:[(0,q.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,q.jsxs)(D,{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:H,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[H?(0,q.jsx)(v,{className:`size-3.5 animate-spin`}):(0,q.jsx)(O,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,q.jsx)(h,{open:fe,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void qe(),onCancel:()=>z({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,q.jsx)(Ee,{g:n,activeTab:f,visibleTabs:m,onChange:_}),(0,q.jsxs)(Q,{g:n,id:`network`,activeTab:f,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,q.jsxs)(g,{id:`gateway-bind-mode`,className:X(),value:M.bind,onChange:e=>$(e.target.value),children:[(0,q.jsx)(S,{value:`loopback`,children:n.bindLoopback}),d?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(S,{value:`lan`,children:n.bindLan}),(0,q.jsx)(S,{value:`auto`,children:n.bindAuto}),(0,q.jsx)(S,{value:`custom`,children:n.bindCustom}),(0,q.jsx)(S,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,q.jsx)(`input`,{id:`gateway-custom-bind-host`,className:a(X(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Ne(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,q.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:a(X(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);Pe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,q.jsx)(ne,{children:(0,q.jsx)(Ae,{g:n,origins:M.corsOrigins,onChange:Te})})]}),(0,q.jsxs)(Q,{g:n,id:`access`,activeTab:f,children:[M.auth.mode===`none`?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,q.jsxs)(g,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>Z({mode:e.target.value}),className:X(),children:[(0,q.jsx)(S,{value:`token`,children:n.authModeToken}),(0,q.jsx)(S,{value:`password`,children:n.authModePassword}),d?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(S,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,q.jsx)(S,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,q.jsx)(ne,{children:M.auth.mode===`trusted-proxy`?(0,q.jsx)(Oe,{g:n,form:M,onTrustedProxyChange:Be,onTrustedProxiesChange:ze,onAllowRealIpFallbackChange:He}):null}),M.auth.mode===`token`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Me,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:Ke,reveal:()=>ae(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({token:e})}),(0,q.jsx)(D,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>C(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,q.jsx)(Me,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:Ke,reveal:()=>ae(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({password:e})}):null,(0,q.jsx)(ne,{children:M.auth.mode===`none`?null:(0,q.jsx)(je,{g:n,rateLimit:M.auth.rateLimit,onChange:Fe})})]}),(0,q.jsxs)(Q,{g:n,id:`updates`,activeTab:f,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,q.jsxs)(g,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>Se(e.target.value),className:X(),children:[(0,q.jsx)(S,{value:`stable`,children:n.channelStable}),(0,q.jsx)(S,{value:`beta`,children:n.channelBeta}),(0,q.jsx)(S,{value:`dev`,children:n.channelDev})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableDelayHours,onChange:e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableJitterHours,onChange:e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,q.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,q.jsxs)(Q,{g:n,id:`security`,activeTab:f,children:[(0,q.jsx)(pe,{enabled:T,refreshToken:ie}),(0,q.jsx)(De,{g:n,form:M,onSecurityStrictChange:Ve,onDangerouslyAllowHostHeaderOriginFallbackChange:Ue})]}),(0,q.jsx)(Q,{g:n,id:`advanced`,activeTab:f,children:(0,q.jsx)(ke,{g:n,form:M,onDeferModeChange:Ie,onDeferIdsChange:Le,onSkipIdsChange:Re})})]}):(0,q.jsxs)(ee,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:re??_e??n.loadError}),(0,q.jsx)(D,{type:`button`,variant:`secondary`,onClick:()=>void he(),children:n.retry})]}):(0,q.jsxs)(ee,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(R,{title:t.settingsSections.gateway}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Ee(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:Z(n,e),icon:be[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,q.jsx)(ie,{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=Z(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Se(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,q.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,q.jsx)(z,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,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 De(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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 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,q.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 Oe(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:o,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,q.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,q.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=a(X(),`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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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]!==o?(E=(0,q.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:o}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=o,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,q.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,q.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,q.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,q.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,q.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,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-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 ke(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:a,onSkipIdsChange:o}=e,s;t[0]===n.channelConnectDeferMode?s=t[1]:(s=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=s);let c=r.channelConnectDeferMode,l;t[2]===i?l=t[3]:(l=e=>i(e.target.value),t[2]=i,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=X(),t[4]=u):u=t[4];let d;t[5]===n.channelConnectDeferModeAuto?d=t[6]:(d=(0,q.jsx)(S,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=d);let f;t[7]===n.channelConnectDeferModeOff?f=t[8]:(f=(0,q.jsx)(S,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=f);let p;t[9]===n.channelConnectDeferModeExplicit?p=t[10]:(p=(0,q.jsx)(S,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=p);let m;t[11]!==r.channelConnectDeferMode||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,q.jsxs)(g,{id:`gateway-channel-defer-mode`,value:c,onChange:l,className:u,children:[d,f,p]}),t[11]=r.channelConnectDeferMode,t[12]=l,t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;t[17]===n.channelConnectDeferModeHint?h=t[18]:(h=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=h);let _;t[19]!==s||t[20]!==m||t[21]!==h?(_=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[s,m,h]}),t[19]=s,t[20]=m,t[21]=h,t[22]=_):_=t[22];let v;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]!==a?(v=r.channelConnectDeferMode===`explicit`?(0,q.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:a}):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]=a,t[30]=v):v=t[30];let y;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]!==o?(y=r.channelConnectDeferMode===`off`?null:(0,q.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:o}),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]=o,t[38]=y):y=t[38];let b;return t[39]!==_||t[40]!==v||t[41]!==y?(b=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[_,v,y]}),t[39]=_,t[40]=v,t[41]=y,t[42]=b):b=t[42],b}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:o,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,q.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,q.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]!==s?(h=s.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,q.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,q.jsx)(`button`,{type:`button`,className:a(`text-fg-muted hover:text-fg`,j.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(X(),`font-mono text-xs`),t[12]=g):g=t[12];let _=s.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]!==o||t[16]!==_||t[17]!==v?(y=(0,q.jsx)(`input`,{className:g,placeholder:o,disabled:_,onKeyDown:v}),t[15]=o,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,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-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 Ae(e){let t=(0,H.c)(13),{g:n,origins:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=r.includes(`*`),t[0]=r,t[1]=a);let o=a,s;t[2]!==n.corsOriginsWildcardWarning||t[3]!==o?(s=o?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[2]=n.corsOriginsWildcardWarning,t[3]=o,t[4]=s):s=t[4];let c;return t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==i||t[10]!==r||t[11]!==s?(c=(0,q.jsx)($,{title:n.corsOrigins,hint:n.corsOriginsHint,emptyText:n.corsOriginsEmpty,placeholder:n.corsOriginsPlaceholder,values:r,maxItems:128,onChange:i,children:s}),t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=i,t[10]=r,t[11]=s,t[12]=c):c=t[12],c}function je(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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=X(),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,q.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,q.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,q.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=X(),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,q.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,q.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,q.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=X(),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,q.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,q.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,q.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,q.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-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 Me(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,q.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,q.jsx)(P,{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,q.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,q.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{Te 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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DQ5X6cXp.js";import{l as s,n as c,r as l,s as u}from"./locale-store-Bjvw7jtg.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{At as p,Da as m,En as h,Go as g,Nr as _,Ns as v,Oc as y,Or as b,Qs as x,Wo as S,Xs as C,Ys as w,_s as T,cc as E,cs as D,ds as O,el as k,gs as A,mo as j,nl as M,oc as N,ru as P,ss as F,zc as I,zo as L}from"./index-BpkdvHH0.js";import{n as R,r as ee,t as z}from"./settings-page-layout-CLtUsWsu.js";import{n as te}from"./settings-loading-skeleton-sn4k17x7.js";import{t as ne}from"./settings-advanced-gate-CcO2bd6q.js";import{n as B,t as re}from"./settings-form-section-BJaMEHsX.js";import{t as ie}from"./page-tabs-CROi9zm1.js";import{a as ae,c as oe,d as se,n as ce,o as le,r as ue,t as de}from"./gateway-config-api-CH2R7yqo.js";var V=e(t(),1),H=n(),fe={critical:3,warn:2,info:1};function U(){return l(`/api/doctor?security=true`)}function W(e){return e.toSorted((e,t)=>fe[t.severity]-fe[e.severity]||e.checkId.localeCompare(t.checkId))}function G(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=W((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 K(){return G(await u(U()))}var q=r();function pe(e){let t=(0,H.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=c(me),s;t[0]===a?s=t[1]:(s=o(a),t[0]=a,t[1]=s);let l=s.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[U(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:h,error:g,isLoading:_,isValidating:v,mutate:y}=d(u,J,p),b=h??null,S=g instanceof Error?g.message:g?String(g):null,C=_||v,w;t[6]===y?w=t[7]:(w=()=>{y(),f(U())},t[6]=y,t[7]=w);let D=w,O=!n||C,k;t[8]===C?k=t[9]:(k=C?(0,q.jsx)(I,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,q.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=k);let A;t[10]===l.securityAuditRefresh?A=t[11]:(A=(0,q.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=A);let j;t[12]!==D||t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,q.jsxs)(T,{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]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==j?(M=(0,q.jsx)(B,{icon:x,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:j}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let N;t[21]===l.securityAuditSavedConfigHint?N=t[22]:(N=(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==S||t[24]!==l.securityAuditLoadError?(P=S?(0,q.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=l.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==b||t[27]!==S||t[28]!==C?(F=!S&&C&&!b?(0,q.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,q.jsx)(m,{className:`h-11 w-full rounded-lg`}),(0,q.jsx)(m,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=b,t[27]=S,t[28]=C,t[29]=F):F=t[29];let L;t[30]!==b||t[31]!==l?(L=b?(0,q.jsx)(he,{g:l,audit:b}):null,t[30]=b,t[31]=l,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,q.jsxs)(re,{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 J(){return K()}function me(e){return e.language}function he(e){let t=(0,H.c)(40),{g:n,audit:r}=e,i,o,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(o=ve(n,r.status,r.findings),d=`space-y-4`,l=a(`rounded-lg border px-3 py-2.5 text-sm`,o.bannerClass),u=`status`,c=`flex items-start gap-2`,i=o.icon,s=a(`mt-0.5 size-4 shrink-0`,o.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==s?(f=(0,q.jsx)(i,{className:s,"aria-hidden":!0}),t[10]=i,t[11]=s,t[12]=f):f=t[12];let p;t[13]===o.title?p=t[14]:(p=(0,q.jsx)(`p`,{className:`font-medium`,children:o.title}),t[13]=o.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,q.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,q.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,q.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,q.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,q.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,q.jsx)(ge,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,q.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,q.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,q.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Y)})]}):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,q.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 Y(e){return(0,q.jsx)(`li`,{className:`font-mono`,children:e},e)}function ge(e){let t=(0,H.c)(31),{g:n,finding:r}=e,i,o,s,c;if(t[0]!==r.severity){let e=_e(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,i=e.icon,o=a(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=o,t[3]=s,t[4]=c}else i=t[1],o=t[2],s=t[3],c=t[4];let l;t[5]!==i||t[6]!==o?(l=(0,q.jsx)(i,{className:o,"aria-hidden":!0}),t[5]=i,t[6]=o,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,q.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,q.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,q.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,q.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,q.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,q.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,q.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]!==s||t[26]!==l?(g=(0,q.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,q.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function _e(e){switch(e){case`critical`:return{icon:P,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:v,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:M,iconClass:`text-fg-muted`}}}function ve(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:P,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`border-red-200 bg-red-50 text-red-950 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:v,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:M,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:x,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900/50 dark:bg-emerald-950/40 dark:text-emerald-100`}}function X(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,A,`dark:border-edge`)}var ye=[`network`,`access`,`updates`,`security`,`advanced`],be={network:y,access:k,updates:E,security:C,advanced:w};function xe(e){return e&&ye.includes(e)?e:`network`}function Z(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Se(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function Ce(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 we={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Te(){let e=c(e=>e.language),t=o(e),n=t.gatewaySettings,[r,l]=i(),u=b(e=>e.mode),d=u===`advanced`,f=xe(r.get(`tab`)),m=(0,V.useMemo)(()=>se(ye,u),[u]),v=(0,V.useCallback)(e=>{l(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[l]);oe(f,v);let y=s(e=>e.token),x=s(e=>e.tokenExpired),C=s(e=>e.openTokenDialog),w=!!y,[E,D]=(0,V.useReducer)(Ce,{form:null,baseline:null,appliedBaseline:null}),O=E.form,k=E.baseline,A=E.appliedBaseline,[M,z]=(0,V.useReducer)(p,we),{saving:B,error:re,auditRefreshToken:ie,restarting:H,restartConfirmOpen:fe}=M,U=(0,V.useRef)(!1),W=(0,V.useRef)(null),G=(0,V.useRef)(!1),{data:K,error:J,isLoading:me,mutate:he}=j(w),Y=(0,V.useMemo)(()=>K?.payload?.config===void 0?null:structuredClone(ce(K.payload.config)),[K]);w?Y!==null&&(G.current||(G.current=!0,D({type:`init-applied`,value:Y})),!U.current&&W.current!==Y&&(W.current=Y,D({type:`sync`,value:Y}),z({type:`patch`,patch:{saveOk:!1}}))):(W.current!==null||G.current)&&(W.current=null,G.current=!1,D({type:`reset`}),U.current=!1);let ge=!!(w&&me&&K===void 0&&!J),_e=J instanceof Error?J.message:J?String(J):null,ve=(0,V.useMemo)(()=>!O||!k?!1:JSON.stringify(O)!==JSON.stringify(k),[O,k]),be=(0,V.useMemo)(()=>!k||!A?!1:de(A,k),[A,k]),Z=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),Se=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Te=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),$=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Ne=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Pe=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,port:e})})},[]),Fe=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Ie=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Le=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Re=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),ze=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Be=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Ve=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),He=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ue=(0,V.useCallback)(e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),We=(0,V.useCallback)(async()=>{if(!O||B)return;let e=le(O);if(e){z({type:`patch`,patch:{error:e}});return}z({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await ue(O),U.current=!1,D({type:`saved`,value:O}),z({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ie+1}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{z({type:`patch`,patch:{saving:!1}})}},[O,B,n.saveError]),Ge=(0,V.useCallback)(()=>{k&&(U.current=!1,D({type:`discard`}),z({type:`patch`,patch:{error:null,saveOk:!1}}))},[k]),Ke=F(n),qe=(0,V.useCallback)(async()=>{if(!H){z({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await _();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):z({type:`patch`,patch:{error:e.message||n.restartGatewayFailed}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{z({type:`patch`,patch:{restarting:!1}})}}},[H,n.restartGatewayFailed]);return w?ge?(0,q.jsx)(ee,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,q.jsx)(te,{sections:3})}):O?(0,q.jsxs)(ee,{gap:`gap-6`,children:[(0,q.jsx)(R,{title:t.settingsSections.gateway,subtitle:n.subtitle,docsLink:L(e,`gateway`),docsLabel:n.docsLink,actions:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(T,{type:`button`,variant:`secondary`,disabled:!ve||B,onClick:Ge,children:n.discard}),(0,q.jsx)(T,{type:`button`,variant:`primary`,disabled:!ve||B,onClick:()=>void We(),children:B?n.saving:n.save})]})}),x?(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,q.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,q.jsx)(`div`,{children:(0,q.jsx)(T,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>C(),children:n.updateToken})})]}):null,ve?(0,q.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,re?(0,q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:re}):null,be?(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/40`,children:[(0,q.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,q.jsxs)(T,{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:H,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[H?(0,q.jsx)(I,{className:`size-3.5 animate-spin`}):(0,q.jsx)(N,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,q.jsx)(h,{open:fe,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void qe(),onCancel:()=>z({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,q.jsx)(Ee,{g:n,activeTab:f,visibleTabs:m,onChange:v}),(0,q.jsxs)(Q,{g:n,id:`network`,activeTab:f,children:[(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,q.jsxs)(S,{id:`gateway-bind-mode`,className:X(),value:O.bind,onChange:e=>$(e.target.value),children:[(0,q.jsx)(g,{value:`loopback`,children:n.bindLoopback}),d?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(g,{value:`lan`,children:n.bindLan}),(0,q.jsx)(g,{value:`auto`,children:n.bindAuto}),(0,q.jsx)(g,{value:`custom`,children:n.bindCustom}),(0,q.jsx)(g,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),O.bind===`custom`?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,q.jsx)(`input`,{id:`gateway-custom-bind-host`,className:a(X(),`font-mono text-xs`),value:O.customBindHost,onChange:e=>Ne(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,q.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:a(X(),`font-mono text-xs`),value:O.port,onChange:e=>{let t=Number(e.target.value);Pe(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):O.port)}})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,q.jsx)(ne,{children:(0,q.jsx)(Ae,{g:n,origins:O.corsOrigins,onChange:Te})})]}),(0,q.jsxs)(Q,{g:n,id:`access`,activeTab:f,children:[O.auth.mode===`none`?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.authModeNone}):null,(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,q.jsxs)(S,{id:`gateway-auth-mode`,value:O.auth.mode,onChange:e=>Z({mode:e.target.value}),className:X(),children:[(0,q.jsx)(g,{value:`token`,children:n.authModeToken}),(0,q.jsx)(g,{value:`password`,children:n.authModePassword}),d?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(g,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,q.jsx)(g,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,q.jsx)(ne,{children:O.auth.mode===`trusted-proxy`?(0,q.jsx)(Oe,{g:n,form:O,onTrustedProxyChange:Be,onTrustedProxiesChange:ze,onAllowRealIpFallbackChange:He}):null}),O.auth.mode===`token`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Me,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:O.auth.token,labels:Ke,reveal:()=>ae(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({token:e})}),(0,q.jsx)(T,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>C(),children:n.changeToken})]}):null,O.auth.mode===`password`?(0,q.jsx)(Me,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:O.auth.password,labels:Ke,reveal:()=>ae(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>Z({password:e})}):null,(0,q.jsx)(ne,{children:O.auth.mode===`none`?null:(0,q.jsx)(je,{g:n,rateLimit:O.auth.rateLimit,onChange:Fe})})]}),(0,q.jsxs)(Q,{g:n,id:`updates`,activeTab:f,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,q.jsxs)(S,{id:`gateway-update-channel`,value:O.updateChannel,onChange:e=>Se(e.target.value),className:X(),children:[(0,q.jsx)(g,{value:`stable`,children:n.channelStable}),(0,q.jsx)(g,{value:`beta`,children:n.channelBeta}),(0,q.jsx)(g,{value:`dev`,children:n.channelDev})]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:O.updateCheckOnStart,onChange:e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:O.updateAutoEnabled,onChange:e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!O.updateAutoEnabled,className:X(),value:O.updateAutoStableDelayHours,onChange:e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,q.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!O.updateAutoEnabled,className:X(),value:O.updateAutoStableJitterHours,onChange:e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,q.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!O.updateAutoEnabled,className:X(),value:O.updateAutoBetaCheckIntervalHours,onChange:e=>{U.current=!0,D({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,q.jsxs)(Q,{g:n,id:`security`,activeTab:f,children:[(0,q.jsx)(pe,{enabled:w,refreshToken:ie}),(0,q.jsx)(De,{g:n,form:O,onSecurityStrictChange:Ve,onDangerouslyAllowHostHeaderOriginFallbackChange:Ue})]}),(0,q.jsx)(Q,{g:n,id:`advanced`,activeTab:f,children:(0,q.jsx)(ke,{g:n,form:O,onDeferModeChange:Ie,onDeferIdsChange:Le,onSkipIdsChange:Re})})]}):(0,q.jsxs)(ee,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:re??_e??n.loadError}),(0,q.jsx)(T,{type:`button`,variant:`secondary`,onClick:()=>void he(),children:n.retry})]}):(0,q.jsxs)(ee,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,q.jsx)(R,{title:t.settingsSections.gateway}),(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Ee(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:Z(n,e),icon:be[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,q.jsx)(ie,{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=Z(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Se(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,q.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,q.jsx)(z,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,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 De(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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 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,q.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 Oe(e){let t=(0,H.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:o,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,q.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,q.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=a(X(),`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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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]!==o?(E=(0,q.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:o}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=o,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,q.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,q.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,q.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,q.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,q.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,q.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-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 ke(e){let t=(0,H.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:a,onSkipIdsChange:o}=e,s;t[0]===n.channelConnectDeferMode?s=t[1]:(s=(0,q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=s);let c=r.channelConnectDeferMode,l;t[2]===i?l=t[3]:(l=e=>i(e.target.value),t[2]=i,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=X(),t[4]=u):u=t[4];let d;t[5]===n.channelConnectDeferModeAuto?d=t[6]:(d=(0,q.jsx)(g,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=d);let f;t[7]===n.channelConnectDeferModeOff?f=t[8]:(f=(0,q.jsx)(g,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=f);let p;t[9]===n.channelConnectDeferModeExplicit?p=t[10]:(p=(0,q.jsx)(g,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=p);let m;t[11]!==r.channelConnectDeferMode||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,q.jsxs)(S,{id:`gateway-channel-defer-mode`,value:c,onChange:l,className:u,children:[d,f,p]}),t[11]=r.channelConnectDeferMode,t[12]=l,t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;t[17]===n.channelConnectDeferModeHint?h=t[18]:(h=(0,q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=h);let _;t[19]!==s||t[20]!==m||t[21]!==h?(_=(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[s,m,h]}),t[19]=s,t[20]=m,t[21]=h,t[22]=_):_=t[22];let v;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]!==a?(v=r.channelConnectDeferMode===`explicit`?(0,q.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:a}):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]=a,t[30]=v):v=t[30];let y;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]!==o?(y=r.channelConnectDeferMode===`off`?null:(0,q.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:o}),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]=o,t[38]=y):y=t[38];let b;return t[39]!==_||t[40]!==v||t[41]!==y?(b=(0,q.jsxs)(`div`,{className:`space-y-4`,children:[_,v,y]}),t[39]=_,t[40]=v,t[41]=y,t[42]=b):b=t[42],b}function $(e){let t=(0,H.c)(25),{title:n,hint:r,emptyText:i,placeholder:o,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,q.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,q.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]!==s?(h=s.length===0?(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,q.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,q.jsx)(`button`,{type:`button`,className:a(`text-fg-muted hover:text-fg`,O.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(X(),`font-mono text-xs`),t[12]=g):g=t[12];let _=s.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]!==o||t[16]!==_||t[17]!==v?(y=(0,q.jsx)(`input`,{className:g,placeholder:o,disabled:_,onKeyDown:v}),t[15]=o,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,q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-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 Ae(e){let t=(0,H.c)(13),{g:n,origins:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=r.includes(`*`),t[0]=r,t[1]=a);let o=a,s;t[2]!==n.corsOriginsWildcardWarning||t[3]!==o?(s=o?(0,q.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[2]=n.corsOriginsWildcardWarning,t[3]=o,t[4]=s):s=t[4];let c;return t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==i||t[10]!==r||t[11]!==s?(c=(0,q.jsx)($,{title:n.corsOrigins,hint:n.corsOriginsHint,emptyText:n.corsOriginsEmpty,placeholder:n.corsOriginsPlaceholder,values:r,maxItems:128,onChange:i,children:s}),t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=i,t[10]=r,t[11]=s,t[12]=c):c=t[12],c}function je(e){let t=(0,H.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,q.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,q.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,q.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,q.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,q.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,q.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,q.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,q.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=X(),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,q.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,q.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,q.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=X(),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,q.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,q.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,q.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=X(),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,q.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,q.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,q.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,q.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-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 Me(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,q.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,q.jsx)(D,{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,q.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,q.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{Te as GatewaySettingsPanel};
@@ -1 +1 @@
1
- import{o as e}from"./locale-store-VOY1wMO9.js";var t=6e4,n=500,r=5e3;function i(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`STARTUP_UNAVAILABLE`&&t.retryable===!0&&typeof t.retryAfterMs==`number`}function a(e){return new Promise(t=>setTimeout(t,e))}function o(e){let t=typeof e.retryAfterMs==`number`?e.retryAfterMs:n;return Math.min(Math.max(t,100),r)}async function s(n,r,s){let c=Date.now(),l=s?.timeoutMs??t;for(;;){let t=await e(n,r);if(t.status!==503)return t;let s=await t.clone().json().catch(()=>null);if(!i(s)||Date.now()-c>=l)return t;await a(o(s))}}export{s as t};
1
+ import{o as e}from"./locale-store-Bjvw7jtg.js";var t=6e4,n=500,r=5e3;function i(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`STARTUP_UNAVAILABLE`&&t.retryable===!0&&typeof t.retryAfterMs==`number`}function a(e){return new Promise(t=>setTimeout(t,e))}function o(e){let t=typeof e.retryAfterMs==`number`?e.retryAfterMs:n;return Math.min(Math.max(t,100),r)}async function s(n,r,s){let c=Date.now(),l=s?.timeoutMs??t;for(;;){let t=await e(n,r);if(t.status!==503)return t;let s=await t.clone().json().catch(()=>null);if(!i(s)||Date.now()-c>=l)return t;await a(o(s))}}export{s as t};
@@ -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{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DMJ-6-1m.js";import{l as s,n as c,r as l,s as u}from"./locale-store-VOY1wMO9.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{At as p,Cl as m,Ho as h,Lc as g,Lo as _,Mc as v,Pa as y,Uo as b,Vl as x,do as S,ds as C,fo as w,fs as T,hc as E,hs as D,ms as O,oc as k,ps as A,sl as j}from"./index-DzmbmOGA.js";import{n as ee,r as M,t as te}from"./settings-page-layout-J793iqfm.js";import{n as ne}from"./settings-loading-skeleton-BDzpxgk0.js";import{n as re,t as ie}from"./use-autosave-CcvY7DTh.js";import{t as N}from"./page-tabs-CvzSdYVj.js";import{r as ae,t as P}from"./channel-recipient-api-DSJznouK.js";import{n as oe,t as se}from"./channels-status-swr-C2UYdebT.js";import{n as F,o as I,t as ce}from"./cron-expression-C9hhCiuo.js";var L=e(t(),1),R=n();function z(){return l(`/api/workspace/heartbeat-md`)}async function le(){let e=await u(z());return typeof e.payload?.content==`string`?e.payload.content:``}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ue(e){let t=B(e)?e:{},n=B(t.gateway)?t.gateway:{},r=B(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=B(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function de(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function fe(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:de(e)}})}),S()}async function pe(e){await u(l(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),f(z())}async function me(e){await u(l(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var V=r(),H=Array.from({length:60},(e,t)=>t),U=a(A,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),W=a(`h-9 min-w-[9.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,C),G=a(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,C),he=a(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,C);function K(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function q(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function ge(e,t){switch(t.type){case`reset`:return K(t.state);case`replace`:return t.state}}function J({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let o=(0,L.useMemo)(()=>F(e),[e]),[s,c]=(0,L.useReducer)(ge,o,K),l=(0,L.useRef)(e);l.current!==e&&(l.current=e,c({type:`reset`,state:o}));let u=(0,L.useCallback)(e=>{let n={...s,...e};c({type:`replace`,state:n});let r=q(n),i=q(s);Object.keys(r).some(e=>r[e]!==i[e])&&t(ce(r))},[t,s]),{mode:d,intervalKind:f,onceDate:p,intervalMinutes:m,intervalHours:g,minute:_,hour:v,weekDays:y,dayOfMonth:x,rawCron:S,intervalMinutesDraft:C,intervalHoursDraft:w}=s,T=`${String(v).padStart(2,`0`)}:${String(_).padStart(2,`0`)}`,E=e=>{if(!e)return;let[t,n]=e.split(`:`).map(e=>parseInt(e,10));Number.isNaN(t)||Number.isNaN(n)||u({minute:n,hour:t})},D=(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,V.jsxs)(h,{className:U,disabled:r,value:d,onChange:e=>{let t=e.target.value;u({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,V.jsx)(b,{value:`no_repeat`,children:n.modeNoRepeat}),(0,V.jsx)(b,{value:`interval`,children:n.modeInterval}),(0,V.jsx)(b,{value:`hourly`,children:n.modeHourly}),(0,V.jsx)(b,{value:`daily`,children:n.modeDaily}),(0,V.jsx)(b,{value:`weekly`,children:n.modeWeekly}),(0,V.jsx)(b,{value:`monthly`,children:n.modeMonthly}),(0,V.jsx)(b,{value:`custom`,children:n.modeCustom})]}),d===`no_repeat`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`input`,{type:`date`,disabled:r,className:W,value:p,onChange:e=>{u({onceDate:e.target.value})},"aria-label":n.modeNoRepeat}),(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),d===`interval`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(h,{className:a(U,`w-auto min-w-[5rem]`),disabled:r,value:f,onChange:e=>{let t=e.target.value;u({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,V.jsx)(b,{value:`minutes`,children:n.intervalKindMinutes}),(0,V.jsx)(b,{value:`hours`,children:n.intervalKindHours})]}),f===`minutes`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:G,value:C??String(m),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),u(r)},onBlur:()=>{if(C===null)return;let e=parseInt(C,10);u({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:G,value:w??String(g),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),u(r)},onBlur:()=>{if(w===null)return;let e=parseInt(w,10);u({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,V.jsx)(h,{className:a(U,`w-auto min-w-[4rem]`),disabled:r,value:_,onChange:e=>{u({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:H.map(e=>(0,V.jsx)(b,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),d===`daily`&&(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),d===`weekly`&&(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),d===`monthly`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(h,{className:a(U,`w-auto min-w-[4.5rem]`),disabled:r,value:x,onChange:e=>{u({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,V.jsx)(b,{value:e,children:e},e))}),(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),d===`hourly`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(h,{className:a(U,`w-auto min-w-[4rem]`),disabled:r,value:_,onChange:e=>{u({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:H.map(e=>(0,V.jsx)(b,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),O=d===`weekly`?(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=y[t];return(0,V.jsx)(`button`,{type:`button`,disabled:r,className:a(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...y];e[t]=!e[t],u({weekDays:e})},children:e},e)})}):null,k=d===`custom`?(0,V.jsxs)(`div`,{className:`pt-1`,children:[(0,V.jsx)(`textarea`,{disabled:r,className:he,rows:2,spellCheck:!1,value:S,placeholder:`*/5 * * * *`,onChange:e=>{u({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,D,O,k]})}var Y=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5];new Set(Y);var _e=a(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,C),ve=a(A,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function X(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function ye({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=Y,minSeconds:a=1}){let o=(0,L.useMemo)(()=>new Set(i),[i]),s=(0,L.useMemo)(()=>o.has(e)?String(e):``,[o,e]),[c,l]=(0,L.useState)(null),u=(0,L.useRef)(e);u.current!==e&&(u.current=e,l(null));let d=Math.max(a,Math.round(e/1e3)),f=c===null?String(d):c;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`number`,min:a,step:1,disabled:r,className:_e,value:f,onChange:e=>{let n=e.target.value;l(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=a&&t(r*1e3)},onBlur:()=>{if(c===null)return;let e=parseInt(c,10);t(!Number.isFinite(e)||e<a?a*1e3:e*1e3),l(null)}}),(0,V.jsxs)(h,{className:ve,disabled:r,value:s,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),l(null))},children:[(0,V.jsx)(b,{value:``,children:n.presets.custom}),i.map(e=>(0,V.jsx)(b,{value:String(e),children:X(e,n.presets)},e))]})]})]})}var be=a(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,C),xe=()=>({start:`09:00`,end:`22:00`,timezone:``});function Se(e){let t=(0,R.c)(57),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(xe()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,V.jsx)(D,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==i.start||t[13]!==s||t[14]!==n.start?(c=(0,V.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.start,onChange:s,ariaLabel:i.start}),t[11]=a,t[12]=i.start,t[13]=s,t[14]=n.start,t[15]=c):c=t[15];let l;t[16]!==o||t[17]!==c?(l=(0,V.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[16]=o,t[17]=c,t[18]=l):l=t[18];let u;t[19]===i.end?u=t[20]:(u=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[19]=i.end,t[20]=u);let d;t[21]!==r||t[22]!==n?(d=e=>r({...n,end:e}),t[21]=r,t[22]=n,t[23]=d):d=t[23];let f;t[24]!==a||t[25]!==i.end||t[26]!==d||t[27]!==n.end?(f=(0,V.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.end,onChange:d,ariaLabel:i.end}),t[24]=a,t[25]=i.end,t[26]=d,t[27]=n.end,t[28]=f):f=t[28];let p;t[29]!==u||t[30]!==f?(p=(0,V.jsxs)(`label`,{className:`block min-w-0`,children:[u,f]}),t[29]=u,t[30]=f,t[31]=p):p=t[31];let m;t[32]===i.timezone?m=t[33]:(m=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[32]=i.timezone,t[33]=m);let h;t[34]!==r||t[35]!==n?(h=e=>r({...n,timezone:e.target.value}),t[34]=r,t[35]=n,t[36]=h):h=t[36];let g;t[37]!==a||t[38]!==h||t[39]!==n.timezone?(g=(0,V.jsx)(`input`,{type:`text`,disabled:a,className:be,value:n.timezone,onChange:h,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[37]=a,t[38]=h,t[39]=n.timezone,t[40]=g):g=t[40];let _;t[41]!==g||t[42]!==m?(_=(0,V.jsxs)(`label`,{className:`block min-w-0`,children:[m,g]}),t[41]=g,t[42]=m,t[43]=_):_=t[43];let v;t[44]!==_||t[45]!==l||t[46]!==p?(v=(0,V.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[l,p,_]}),t[44]=_,t[45]=l,t[46]=p,t[47]=v):v=t[47];let y;t[48]===r?y=t[49]:(y=()=>r(null),t[48]=r,t[49]=y);let b;t[50]!==a||t[51]!==i.clear||t[52]!==y?(b=(0,V.jsx)(D,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:y,children:i.clear}),t[50]=a,t[51]=i.clear,t[52]=y,t[53]=b):b=t[53];let x;return t[54]!==v||t[55]!==b?(x=(0,V.jsxs)(`div`,{className:`space-y-2`,children:[v,b]}),t[54]=v,t[55]=b,t[56]=x):x=t[56],x}function Z(e){let t=(0,R.c)(34),{disabled:n,label:r,hint:i,className:o}=e,s;t[0]===o?s=t[1]:(s=a(`flex flex-col gap-2`,o),t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,V.jsx)(J,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let u;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(u=e.kind===`interval`?(0,V.jsx)(ye,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??Y,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=u):u=t[18];let d;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(d=e.kind===`active-hours`?(0,V.jsx)(Se,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=d):d=t[24];let f;t[25]===i?f=t[26]:(f=i?(0,V.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=f);let p;return t[27]!==s||t[28]!==c||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==f?(p=(0,V.jsxs)(`div`,{className:s,children:[c,l,u,d,f]}),t[27]=s,t[28]=c,t[29]=l,t[30]=u,t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function Ce(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,O,`dark:border-edge`)}function we(){return a(A,T)}var Te=[`schedule`,`delivery`,`prompt`,`document`],Q={schedule:x,delivery:v,prompt:j,document:m};function Ee(e){return e&&Te.includes(e)?e:`schedule`}function De(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function Oe(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function ke(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value);return{form:e.form&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Ae(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`saved`:return{doc:e.doc===t.value?t.value:e.doc,baseline:t.value}}}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var Me={triggerLoading:!1,triggerOk:!1,triggerError:null};function Ne(){let e=c(e=>e.language),t=o(e),n=t.heartbeatSettings,r=!!s(e=>e.token),[l,u]=i(),f=Ee(l.get(`tab`)),m=(0,L.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]),[h,v]=(0,L.useReducer)(ke,{form:null,baseline:null}),b=h.form,x=h.baseline,[S,C]=(0,L.useReducer)(Ae,{doc:``,baseline:``}),T=S.doc,O=S.baseline,[k,A]=(0,L.useReducer)(p,Me),{triggerLoading:j,triggerOk:te,triggerError:N}=k,P=(0,L.useRef)(!1),F=(0,L.useRef)(!1),I=(0,L.useRef)(b),ce=(0,L.useRef)(T);I.current=b,ce.current=T;let{data:R,error:B,isLoading:de,mutate:H}=w(r),{data:U,error:W,isLoading:G,mutate:he}=d(r?z():null,le,{revalidateOnFocus:!1}),{data:K=[]}=d(r?se():null,oe,{revalidateOnFocus:!1}),q=(0,L.useMemo)(()=>je(R?.payload?.config),[R]),ge=(0,L.useMemo)(()=>ue(R?.payload?.config??{}),[R]),J=(0,L.useMemo)(()=>!b||!x?!1:JSON.stringify(b)!==JSON.stringify(x),[b,x]),Y=T!==O;(0,L.useEffect)(()=>{if(!r){v({type:`reset`}),P.current=!1;return}R!==void 0&&(P.current||v({type:`sync`,value:ge}))},[r,R,ge]),(0,L.useEffect)(()=>{if(!r){C({type:`reset`}),F.current=!1;return}U!==void 0&&(F.current||C({type:`sync`,value:U}))},[r,U]);let _e=B instanceof Error?B.message:B?String(B):W instanceof Error?W.message:W?String(W):null,ve=!!(r&&(R===void 0||U===void 0)&&!_e&&(de||G)),X=b?.target.trim()??``,{data:ye,setData:be}=y(()=>ae(X),[r,X],{enabled:r&&X.length>0,initial:[],errorData:[]}),xe=(0,L.useCallback)(()=>{X&&ae(X).then(be)},[X,be]),Se=(0,L.useCallback)(async()=>{A({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await me(),A({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>A({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){A({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{A({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),Z=(0,L.useCallback)(e=>{P.current=!0,v({type:`patch`,patch:e})},[]),Te=J||Y,Q=ie({value:(0,L.useMemo)(()=>b?{form:b,doc:T,saveConfig:J,saveDoc:Y}:null,[J,Y,T,b]),dirty:Te,onSave:(0,L.useCallback)(async e=>{try{e.saveConfig&&(await fe(e.form),v({type:`saved`,value:e.form}),P.current=!!(I.current&&JSON.stringify(I.current)!==JSON.stringify(e.form))),e.saveDoc&&(await pe(e.doc),C({type:`saved`,value:e.doc}),F.current=ce.current!==e.doc)}catch(t){throw Error(t instanceof Error?t.message:e.saveConfig?n.saveConfigError:n.saveDocError)}},[n.saveConfigError,n.saveDocError]),delayMs:Y?900:500});return r?ve?(0,V.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,V.jsx)(ne,{sections:3})}):b?(0,V.jsxs)(M,{"aria-busy":Q.status===`saving`,"data-has-baseline":x?`1`:`0`,onBlurCapture:Q.onBlurCapture,children:[(0,V.jsx)(ee,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:_(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(re,{status:Q.status,error:Q.error}),(0,V.jsxs)(D,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:j,onClick:()=>void Se(),children:[j?(0,V.jsx)(g,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,V.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),j?n.triggering:n.triggerNow]}),te?(0,V.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),q?(0,V.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,V.jsx)(`span`,{className:`font-mono text-fg-muted`,children:q})]}):null,Q.error?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Q.error}):null,N?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:N}):null,(0,V.jsx)(Pe,{h:n,activeTab:f,onChange:m}),(0,V.jsx)($,{h:n,id:`schedule`,activeTab:f,children:(0,V.jsx)(Fe,{h:n,form:b,update:Z})}),(0,V.jsx)($,{h:n,id:`delivery`,activeTab:f,children:(0,V.jsx)(Ie,{h:n,cron:t.cron,form:b,channels:K,sessionChatIds:ye,onRefreshChatIds:xe,update:Z,inputClassName:Ce,selectClassName:we})}),(0,V.jsx)($,{h:n,id:`prompt`,activeTab:f,children:(0,V.jsx)(ze,{h:n,form:b,update:Z,inputClassName:Ce})}),(0,V.jsxs)($,{h:n,id:`document`,activeTab:f,children:[(0,V.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,V.jsx)(`textarea`,{className:a(Ce(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:T,onChange:e=>{F.current=!0,C({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":T===O?`true`:`false`})]})]}):(0,V.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_e??n.loadError}),(0,V.jsx)(D,{type:`button`,variant:`secondary`,onClick:()=>{H(),he()},children:n.retry})]}):(0,V.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,V.jsx)(ee,{title:t.settingsSections.heartbeat}),(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Pe(e){let t=(0,R.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Te.map(e=>({id:e,label:De(n,e),icon:Q[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,V.jsx)(N,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function $(e){let t=(0,R.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=De(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Oe(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,V.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,V.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,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 Fe(e){let t=(0,R.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,V.jsx)(Z,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,V.jsx)(Z,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,V.jsxs)(V.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function Ie(e){let t=(0,R.c)(51),{h:n,cron:r,form:i,channels:o,sessionChatIds:s,onRefreshChatIds:c,update:l,inputClassName:u,selectClassName:d}=e,f;t[0]===o?f=t[1]:(f=new Set(o.map(Re)),t[0]=o,t[1]=f);let p=f,m;t[2]===i.target?m=t[3]:(m=i.target.trim(),t[2]=i.target,t[3]=m);let g=m,_=!!(g&&!p.has(g)),v;t[4]===n.deliveryHint?v=t[5]:(v=(0,V.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=v);let y;t[6]===r.channel?y=t[7]:(y=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=y);let x;t[8]===d?x=t[9]:(x=d(),t[8]=d,t[9]=x);let S;t[10]===l?S=t[11]:(S=e=>{l({target:e.target.value.trim(),targetChatId:``})},t[10]=l,t[11]=S);let C;t[12]===n.channelNone?C=t[13]:(C=(0,V.jsx)(b,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=C);let w;t[14]!==n.customChannelSuffix||t[15]!==_||t[16]!==g?(w=_?(0,V.jsxs)(b,{value:g,children:[g,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=_,t[16]=g,t[17]=w):w=t[17];let T;t[18]===o?T=t[19]:(T=o.map(Le),t[18]=o,t[19]=T);let E;t[20]!==x||t[21]!==S||t[22]!==C||t[23]!==w||t[24]!==T||t[25]!==g?(E=(0,V.jsxs)(h,{className:x,value:g,onChange:S,children:[C,w,T]}),t[20]=x,t[21]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=g,t[26]=E):E=t[26];let O;t[27]!==E||t[28]!==y?(O=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[y,E]}),t[27]=E,t[28]=y,t[29]=O):O=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==u||t[41]!==c||t[42]!==d||t[43]!==s||t[44]!==g||t[45]!==l?(A=g?(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,V.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:c,children:[(0,V.jsx)(k,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`text`,className:a(u(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>l({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,V.jsxs)(h,{className:a(d(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&l({targetChatId:t})},children:[(0,V.jsx)(b,{value:``,children:r.selectRecipient}),s.length>0?s.map(e=>(0,V.jsx)(b,{value:e.chatId,children:P(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,V.jsx)(b,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=u,t[41]=c,t[42]=d,t[43]=s,t[44]=g,t[45]=l,t[46]=A):A=t[46];let j;return t[47]!==O||t[48]!==A||t[49]!==v?(j=(0,V.jsxs)(V.Fragment,{children:[v,O,A]}),t[47]=O,t[48]=A,t[49]=v,t[50]=j):j=t[50],j}function Le(e){return(0,V.jsxs)(b,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Re(e){return e.name}function ze(e){let t=(0,R.c)(65),{h:n,form:r,update:i,inputClassName:o}=e,s;t[0]===i?s=t[1]:(s=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=s);let c;t[2]!==r.includeSystemPromptSection||t[3]!==s?(c=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:s}),t[2]=r.includeSystemPromptSection,t[3]=s,t[4]=c):c=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,V.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==c||t[11]!==u?(d=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[c,u]}),t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,V.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===o?p=t[16]:(p=a(o(),`min-h-36 resize-y font-mono text-xs`),t[15]=o,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,V.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,V.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,V.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===o?y=t[33]:(y=o(),t[32]=o,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,V.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,V.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,V.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,V.jsxs)(V.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{Ne as HeartbeatSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./cn-JdwAhgNB.js";import{t as o}from"./messages-DQ5X6cXp.js";import{l as s,n as c,r as l,s as u}from"./locale-store-Bjvw7jtg.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{At as p,Go as m,Ia as h,Pc as g,Tl as _,Ul as v,Wo as y,_c as b,_s as x,cc as S,gs as C,hs as w,ll as T,mo as E,ms as D,po as O,ps as k,zc as A,zo as j}from"./index-BpkdvHH0.js";import{n as ee,r as M,t as te}from"./settings-page-layout-CLtUsWsu.js";import{n as ne}from"./settings-loading-skeleton-sn4k17x7.js";import{n as re,t as ie}from"./use-autosave-Dle3-zdQ.js";import{t as N}from"./page-tabs-CROi9zm1.js";import{r as ae,t as P}from"./channel-recipient-api-_8IiTxRB.js";import{n as oe,t as se}from"./channels-status-swr-DPaJSYX_.js";import{n as F,o as I,t as ce}from"./cron-expression-BjFuXlGY.js";var L=e(t(),1),R=n();function z(){return l(`/api/workspace/heartbeat-md`)}async function le(){let e=await u(z());return typeof e.payload?.content==`string`?e.payload.content:``}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ue(e){let t=B(e)?e:{},n=B(t.gateway)?t.gateway:{},r=B(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=B(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function de(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function fe(e){await u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:de(e)}})}),O()}async function pe(e){await u(l(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),f(z())}async function me(e){await u(l(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var V=r(),H=Array.from({length:60},(e,t)=>t),U=a(w,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),W=a(`h-9 min-w-[9.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,k),G=a(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,k),he=a(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,k);function K(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function q(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function ge(e,t){switch(t.type){case`reset`:return K(t.state);case`replace`:return t.state}}function J({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let o=(0,L.useMemo)(()=>F(e),[e]),[s,c]=(0,L.useReducer)(ge,o,K),l=(0,L.useRef)(e);l.current!==e&&(l.current=e,c({type:`reset`,state:o}));let u=(0,L.useCallback)(e=>{let n={...s,...e};c({type:`replace`,state:n});let r=q(n),i=q(s);Object.keys(r).some(e=>r[e]!==i[e])&&t(ce(r))},[t,s]),{mode:d,intervalKind:f,onceDate:p,intervalMinutes:h,intervalHours:g,minute:_,hour:v,weekDays:b,dayOfMonth:x,rawCron:S,intervalMinutesDraft:C,intervalHoursDraft:w}=s,T=`${String(v).padStart(2,`0`)}:${String(_).padStart(2,`0`)}`,E=e=>{if(!e)return;let[t,n]=e.split(`:`).map(e=>parseInt(e,10));Number.isNaN(t)||Number.isNaN(n)||u({minute:n,hour:t})},D=(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,V.jsxs)(y,{className:U,disabled:r,value:d,onChange:e=>{let t=e.target.value;u({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,V.jsx)(m,{value:`no_repeat`,children:n.modeNoRepeat}),(0,V.jsx)(m,{value:`interval`,children:n.modeInterval}),(0,V.jsx)(m,{value:`hourly`,children:n.modeHourly}),(0,V.jsx)(m,{value:`daily`,children:n.modeDaily}),(0,V.jsx)(m,{value:`weekly`,children:n.modeWeekly}),(0,V.jsx)(m,{value:`monthly`,children:n.modeMonthly}),(0,V.jsx)(m,{value:`custom`,children:n.modeCustom})]}),d===`no_repeat`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`input`,{type:`date`,disabled:r,className:W,value:p,onChange:e=>{u({onceDate:e.target.value})},"aria-label":n.modeNoRepeat}),(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),d===`interval`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(y,{className:a(U,`w-auto min-w-[5rem]`),disabled:r,value:f,onChange:e=>{let t=e.target.value;u({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,V.jsx)(m,{value:`minutes`,children:n.intervalKindMinutes}),(0,V.jsx)(m,{value:`hours`,children:n.intervalKindHours})]}),f===`minutes`?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:G,value:C??String(h),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),u(r)},onBlur:()=>{if(C===null)return;let e=parseInt(C,10);u({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:G,value:w??String(g),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),u(r)},onBlur:()=>{if(w===null)return;let e=parseInt(w,10);u({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,V.jsx)(y,{className:a(U,`w-auto min-w-[4rem]`),disabled:r,value:_,onChange:e=>{u({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:H.map(e=>(0,V.jsx)(m,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),d===`daily`&&(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),d===`weekly`&&(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),d===`monthly`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(y,{className:a(U,`w-auto min-w-[4.5rem]`),disabled:r,value:x,onChange:e=>{u({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,V.jsx)(m,{value:e,children:e},e))}),(0,V.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),d===`hourly`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(y,{className:a(U,`w-auto min-w-[4rem]`),disabled:r,value:_,onChange:e=>{u({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:H.map(e=>(0,V.jsx)(m,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,V.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),O=d===`weekly`?(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=b[t];return(0,V.jsx)(`button`,{type:`button`,disabled:r,className:a(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...b];e[t]=!e[t],u({weekDays:e})},children:e},e)})}):null,k=d===`custom`?(0,V.jsxs)(`div`,{className:`pt-1`,children:[(0,V.jsx)(`textarea`,{disabled:r,className:he,rows:2,spellCheck:!1,value:S,placeholder:`*/5 * * * *`,onChange:e=>{u({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,D,O,k]})}var Y=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5];new Set(Y);var _e=a(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,k),ve=a(w,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function X(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function ye({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=Y,minSeconds:a=1}){let o=(0,L.useMemo)(()=>new Set(i),[i]),s=(0,L.useMemo)(()=>o.has(e)?String(e):``,[o,e]),[c,l]=(0,L.useState)(null),u=(0,L.useRef)(e);u.current!==e&&(u.current=e,l(null));let d=Math.max(a,Math.round(e/1e3)),f=c===null?String(d):c;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`number`,min:a,step:1,disabled:r,className:_e,value:f,onChange:e=>{let n=e.target.value;l(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=a&&t(r*1e3)},onBlur:()=>{if(c===null)return;let e=parseInt(c,10);t(!Number.isFinite(e)||e<a?a*1e3:e*1e3),l(null)}}),(0,V.jsxs)(y,{className:ve,disabled:r,value:s,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),l(null))},children:[(0,V.jsx)(m,{value:``,children:n.presets.custom}),i.map(e=>(0,V.jsx)(m,{value:String(e),children:X(e,n.presets)},e))]})]})]})}var be=a(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,k),xe=()=>({start:`09:00`,end:`22:00`,timezone:``});function Se(e){let t=(0,R.c)(57),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(xe()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,V.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==i.start||t[13]!==s||t[14]!==n.start?(c=(0,V.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.start,onChange:s,ariaLabel:i.start}),t[11]=a,t[12]=i.start,t[13]=s,t[14]=n.start,t[15]=c):c=t[15];let l;t[16]!==o||t[17]!==c?(l=(0,V.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[16]=o,t[17]=c,t[18]=l):l=t[18];let u;t[19]===i.end?u=t[20]:(u=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[19]=i.end,t[20]=u);let d;t[21]!==r||t[22]!==n?(d=e=>r({...n,end:e}),t[21]=r,t[22]=n,t[23]=d):d=t[23];let f;t[24]!==a||t[25]!==i.end||t[26]!==d||t[27]!==n.end?(f=(0,V.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.end,onChange:d,ariaLabel:i.end}),t[24]=a,t[25]=i.end,t[26]=d,t[27]=n.end,t[28]=f):f=t[28];let p;t[29]!==u||t[30]!==f?(p=(0,V.jsxs)(`label`,{className:`block min-w-0`,children:[u,f]}),t[29]=u,t[30]=f,t[31]=p):p=t[31];let m;t[32]===i.timezone?m=t[33]:(m=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[32]=i.timezone,t[33]=m);let h;t[34]!==r||t[35]!==n?(h=e=>r({...n,timezone:e.target.value}),t[34]=r,t[35]=n,t[36]=h):h=t[36];let g;t[37]!==a||t[38]!==h||t[39]!==n.timezone?(g=(0,V.jsx)(`input`,{type:`text`,disabled:a,className:be,value:n.timezone,onChange:h,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[37]=a,t[38]=h,t[39]=n.timezone,t[40]=g):g=t[40];let _;t[41]!==g||t[42]!==m?(_=(0,V.jsxs)(`label`,{className:`block min-w-0`,children:[m,g]}),t[41]=g,t[42]=m,t[43]=_):_=t[43];let v;t[44]!==_||t[45]!==l||t[46]!==p?(v=(0,V.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[l,p,_]}),t[44]=_,t[45]=l,t[46]=p,t[47]=v):v=t[47];let y;t[48]===r?y=t[49]:(y=()=>r(null),t[48]=r,t[49]=y);let b;t[50]!==a||t[51]!==i.clear||t[52]!==y?(b=(0,V.jsx)(x,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:y,children:i.clear}),t[50]=a,t[51]=i.clear,t[52]=y,t[53]=b):b=t[53];let S;return t[54]!==v||t[55]!==b?(S=(0,V.jsxs)(`div`,{className:`space-y-2`,children:[v,b]}),t[54]=v,t[55]=b,t[56]=S):S=t[56],S}function Z(e){let t=(0,R.c)(34),{disabled:n,label:r,hint:i,className:o}=e,s;t[0]===o?s=t[1]:(s=a(`flex flex-col gap-2`,o),t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,V.jsx)(J,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let u;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(u=e.kind===`interval`?(0,V.jsx)(ye,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??Y,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=u):u=t[18];let d;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(d=e.kind===`active-hours`?(0,V.jsx)(Se,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=d):d=t[24];let f;t[25]===i?f=t[26]:(f=i?(0,V.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=f);let p;return t[27]!==s||t[28]!==c||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==f?(p=(0,V.jsxs)(`div`,{className:s,children:[c,l,u,d,f]}),t[27]=s,t[28]=c,t[29]=l,t[30]=u,t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function Ce(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function we(){return a(w,D)}var Te=[`schedule`,`delivery`,`prompt`,`document`],Q={schedule:v,delivery:g,prompt:T,document:_};function Ee(e){return e&&Te.includes(e)?e:`schedule`}function De(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function Oe(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function ke(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value);return{form:e.form&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Ae(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`saved`:return{doc:e.doc===t.value?t.value:e.doc,baseline:t.value}}}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var Me={triggerLoading:!1,triggerOk:!1,triggerError:null};function Ne(){let e=c(e=>e.language),t=o(e),n=t.heartbeatSettings,r=!!s(e=>e.token),[l,u]=i(),f=Ee(l.get(`tab`)),m=(0,L.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]),[g,_]=(0,L.useReducer)(ke,{form:null,baseline:null}),v=g.form,y=g.baseline,[S,C]=(0,L.useReducer)(Ae,{doc:``,baseline:``}),w=S.doc,T=S.baseline,[D,O]=(0,L.useReducer)(p,Me),{triggerLoading:k,triggerOk:te,triggerError:N}=D,P=(0,L.useRef)(!1),F=(0,L.useRef)(!1),I=(0,L.useRef)(v),ce=(0,L.useRef)(w);I.current=v,ce.current=w;let{data:R,error:B,isLoading:de,mutate:H}=E(r),{data:U,error:W,isLoading:G,mutate:he}=d(r?z():null,le,{revalidateOnFocus:!1}),{data:K=[]}=d(r?se():null,oe,{revalidateOnFocus:!1}),q=(0,L.useMemo)(()=>je(R?.payload?.config),[R]),ge=(0,L.useMemo)(()=>ue(R?.payload?.config??{}),[R]),J=(0,L.useMemo)(()=>!v||!y?!1:JSON.stringify(v)!==JSON.stringify(y),[v,y]),Y=w!==T;(0,L.useEffect)(()=>{if(!r){_({type:`reset`}),P.current=!1;return}R!==void 0&&(P.current||_({type:`sync`,value:ge}))},[r,R,ge]),(0,L.useEffect)(()=>{if(!r){C({type:`reset`}),F.current=!1;return}U!==void 0&&(F.current||C({type:`sync`,value:U}))},[r,U]);let _e=B instanceof Error?B.message:B?String(B):W instanceof Error?W.message:W?String(W):null,ve=!!(r&&(R===void 0||U===void 0)&&!_e&&(de||G)),X=v?.target.trim()??``,{data:ye,setData:be}=h(()=>ae(X),[r,X],{enabled:r&&X.length>0,initial:[],errorData:[]}),xe=(0,L.useCallback)(()=>{X&&ae(X).then(be)},[X,be]),Se=(0,L.useCallback)(async()=>{O({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await me(),O({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>O({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){O({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{O({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),Z=(0,L.useCallback)(e=>{P.current=!0,_({type:`patch`,patch:e})},[]),Te=J||Y,Q=ie({value:(0,L.useMemo)(()=>v?{form:v,doc:w,saveConfig:J,saveDoc:Y}:null,[J,Y,w,v]),dirty:Te,onSave:(0,L.useCallback)(async e=>{try{e.saveConfig&&(await fe(e.form),_({type:`saved`,value:e.form}),P.current=!!(I.current&&JSON.stringify(I.current)!==JSON.stringify(e.form))),e.saveDoc&&(await pe(e.doc),C({type:`saved`,value:e.doc}),F.current=ce.current!==e.doc)}catch(t){throw Error(t instanceof Error?t.message:e.saveConfig?n.saveConfigError:n.saveDocError)}},[n.saveConfigError,n.saveDocError]),delayMs:Y?900:500});return r?ve?(0,V.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,V.jsx)(ne,{sections:3})}):v?(0,V.jsxs)(M,{"aria-busy":Q.status===`saving`,"data-has-baseline":y?`1`:`0`,onBlurCapture:Q.onBlurCapture,children:[(0,V.jsx)(ee,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:j(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(re,{status:Q.status,error:Q.error}),(0,V.jsxs)(x,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:k,onClick:()=>void Se(),children:[k?(0,V.jsx)(A,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,V.jsx)(b,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),k?n.triggering:n.triggerNow]}),te?(0,V.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),q?(0,V.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,V.jsx)(`span`,{className:`font-mono text-fg-muted`,children:q})]}):null,Q.error?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Q.error}):null,N?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:N}):null,(0,V.jsx)(Pe,{h:n,activeTab:f,onChange:m}),(0,V.jsx)($,{h:n,id:`schedule`,activeTab:f,children:(0,V.jsx)(Fe,{h:n,form:v,update:Z})}),(0,V.jsx)($,{h:n,id:`delivery`,activeTab:f,children:(0,V.jsx)(Ie,{h:n,cron:t.cron,form:v,channels:K,sessionChatIds:ye,onRefreshChatIds:xe,update:Z,inputClassName:Ce,selectClassName:we})}),(0,V.jsx)($,{h:n,id:`prompt`,activeTab:f,children:(0,V.jsx)(ze,{h:n,form:v,update:Z,inputClassName:Ce})}),(0,V.jsxs)($,{h:n,id:`document`,activeTab:f,children:[(0,V.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,V.jsx)(`textarea`,{className:a(Ce(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:w,onChange:e=>{F.current=!0,C({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":w===T?`true`:`false`})]})]}):(0,V.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_e??n.loadError}),(0,V.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>{H(),he()},children:n.retry})]}):(0,V.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,V.jsx)(ee,{title:t.settingsSections.heartbeat}),(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Pe(e){let t=(0,R.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Te.map(e=>({id:e,label:De(n,e),icon:Q[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,V.jsx)(N,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function $(e){let t=(0,R.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=De(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Oe(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,V.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,V.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,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 Fe(e){let t=(0,R.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,V.jsx)(Z,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,V.jsx)(Z,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,V.jsxs)(V.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function Ie(e){let t=(0,R.c)(51),{h:n,cron:r,form:i,channels:o,sessionChatIds:s,onRefreshChatIds:c,update:l,inputClassName:u,selectClassName:d}=e,f;t[0]===o?f=t[1]:(f=new Set(o.map(Re)),t[0]=o,t[1]=f);let p=f,h;t[2]===i.target?h=t[3]:(h=i.target.trim(),t[2]=i.target,t[3]=h);let g=h,_=!!(g&&!p.has(g)),v;t[4]===n.deliveryHint?v=t[5]:(v=(0,V.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=v);let b;t[6]===r.channel?b=t[7]:(b=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=b);let C;t[8]===d?C=t[9]:(C=d(),t[8]=d,t[9]=C);let w;t[10]===l?w=t[11]:(w=e=>{l({target:e.target.value.trim(),targetChatId:``})},t[10]=l,t[11]=w);let T;t[12]===n.channelNone?T=t[13]:(T=(0,V.jsx)(m,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=T);let E;t[14]!==n.customChannelSuffix||t[15]!==_||t[16]!==g?(E=_?(0,V.jsxs)(m,{value:g,children:[g,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=_,t[16]=g,t[17]=E):E=t[17];let D;t[18]===o?D=t[19]:(D=o.map(Le),t[18]=o,t[19]=D);let O;t[20]!==C||t[21]!==w||t[22]!==T||t[23]!==E||t[24]!==D||t[25]!==g?(O=(0,V.jsxs)(y,{className:C,value:g,onChange:w,children:[T,E,D]}),t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=g,t[26]=O):O=t[26];let k;t[27]!==O||t[28]!==b?(k=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[b,O]}),t[27]=O,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==u||t[41]!==c||t[42]!==d||t[43]!==s||t[44]!==g||t[45]!==l?(A=g?(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,V.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:c,children:[(0,V.jsx)(S,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`text`,className:a(u(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>l({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,V.jsxs)(y,{className:a(d(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&l({targetChatId:t})},children:[(0,V.jsx)(m,{value:``,children:r.selectRecipient}),s.length>0?s.map(e=>(0,V.jsx)(m,{value:e.chatId,children:P(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,V.jsx)(m,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=u,t[41]=c,t[42]=d,t[43]=s,t[44]=g,t[45]=l,t[46]=A):A=t[46];let j;return t[47]!==k||t[48]!==A||t[49]!==v?(j=(0,V.jsxs)(V.Fragment,{children:[v,k,A]}),t[47]=k,t[48]=A,t[49]=v,t[50]=j):j=t[50],j}function Le(e){return(0,V.jsxs)(m,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Re(e){return e.name}function ze(e){let t=(0,R.c)(65),{h:n,form:r,update:i,inputClassName:o}=e,s;t[0]===i?s=t[1]:(s=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=s);let c;t[2]!==r.includeSystemPromptSection||t[3]!==s?(c=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:s}),t[2]=r.includeSystemPromptSection,t[3]=s,t[4]=c):c=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,V.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==c||t[11]!==u?(d=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[c,u]}),t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,V.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===o?p=t[16]:(p=a(o(),`min-h-36 resize-y font-mono text-xs`),t[15]=o,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,V.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,V.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,V.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===o?y=t[33]:(y=o(),t[32]=o,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,V.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,V.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,V.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,V.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,V.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,V.jsxs)(V.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{Ne as HeartbeatSettingsPanel};