@xopcai/xopc 0.0.158 → 0.0.159

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 (105) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/dashscope/src/image-generation-provider.js +1 -1
  3. package/dist/extensions/fal/src/image-generation-provider.js +1 -1
  4. package/dist/extensions/google/src/image-generation-provider.js +1 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/{action-boundary-settings-panel-2p1f4-KA.js → action-boundary-settings-panel-CaRK2vIy.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BIl6X2b_.js → agent-avatar-dicebear-BeVf03hx.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agents-bnkKH9EI.js → agents-P05C4A-3.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-CZxw161D.js → app-management-settings-panel-BG2ulMYw.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-CRXNlDhH.js → appearance-settings-0Kjenr2T.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-l4ripRNG.js → apps-page-DANGrBpN.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-CpVshjXu.js → archive-plugin-ChiNnH1e.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-M9WqqJnQ.js → attachment-load-pbBlQR-g.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automation-suggestion-card-CYMsAsYf.js → automation-suggestion-card-CTZDOyDy.js} +1 -1
  15. package/dist/gateway/static/root/assets/{automations-page-Kny7tLiF.js → automations-page-BXfGL_cm.js} +1 -1
  16. package/dist/gateway/static/root/assets/{binary-plugins-Cjn3zb4u.js → binary-plugins-BeZGzpGF.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-BPKdquaV.js → block-editor-BnDmhN5Z.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-settings-page-vr1tXAab.js → browser-settings-page-534luV0B.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-presets-api-Bzkcsyzn.js → capability-presets-api-Ii36j_7v.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-D4rH4Dax.js → capability-presets-settings-panel-Cl3dw4yh.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-Tlhbi5eh.js → channels-settings-M91zFJVi.js} +1 -1
  22. package/dist/gateway/static/root/assets/{connector-logo-ljPKdYKh.js → connector-logo-CiLxuZ8S.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-_XfvjXoY.js → connectors-page-CV5UulW6.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-DKUlAgm7.js → desktop-pet-Cil2eSpW.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-aWWzjdza.js → desktop-pet-settings-DwsC6l5F.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-Dmy1035j.js → directory-picker-path-field-CC2VL5Mc.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-tT4WkBkd.js → dreaming-settings-KY7ZfVsy.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-CL79q8AH.js → extension-debug-page-C8KBeucs.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-hq80wkFI.js → extension-page-CV-5Kcyk.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-BV-9GDfT.js → extension-settings-page-DvUtDrAu.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-CFqoN2NW.js → gateway-config-api-DXfVeJLc.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-DzR-kM91.js → gateway-settings-BpJ0v56l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{goal-create-dialog-BLjHRtqe.js → goal-create-dialog-lMHD-2CX.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-detail-page-BRxeujXh.js → goal-detail-page-yPmF-G7b.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goals-config-api--qJ4qlRq.js → goals-config-api-P8VhLqYF.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-page-BaZ3aw4u.js → goals-page-BHTCKobG.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goals-settings-h7x9h5lb.js → goals-settings-DHXyaH_O.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-settings-71IhhM3s.js → heartbeat-settings-CNckP_Dv.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-BgZhEOkN.css +1 -0
  40. package/dist/gateway/static/root/assets/{index-EXa_i6BT.js → index-BuqGh2SW.js} +65 -65
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BZGmHvLu.js → keyboard-shortcuts-settings-jXmv1RVX.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-app-workbench-page-lUpd6lSo.js → local-app-workbench-page-zpp_wciE.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-apps-page-CiLqrMIh.js → local-apps-page-Cs5LKjtc.js} +1 -1
  44. package/dist/gateway/static/root/assets/{logs-page-FPDTmcWe.js → logs-page-B4CRYqYR.js} +1 -1
  45. package/dist/gateway/static/root/assets/{markdown-split-r1HPWfCU.js → markdown-split-BFqeSNte.js} +1 -1
  46. package/dist/gateway/static/root/assets/{media-plugins-D74kd3hn.js → media-plugins-Cc8379gq.js} +1 -1
  47. package/dist/gateway/static/root/assets/{models-hub-panel-BXrdePhv.js → models-hub-panel-1hdoAoB_.js} +1 -1
  48. package/dist/gateway/static/root/assets/{notes-page-Dgu02514.js → notes-page-DlGU4ipo.js} +1 -1
  49. package/dist/gateway/static/root/assets/{notes-workbench-D-EAhXv1.js → notes-workbench-DQEAZTA5.js} +2 -2
  50. package/dist/gateway/static/root/assets/{page-tabs-hinRdDy3.js → page-tabs-kFOswGlG.js} +1 -1
  51. package/dist/gateway/static/root/assets/{preview-open-alternatives-C7fw3oGy.js → preview-open-alternatives-CvjuvABg.js} +1 -1
  52. package/dist/gateway/static/root/assets/{project-detail-page-BjpB1wrp.js → project-detail-page-Bp9bC7A6.js} +1 -1
  53. package/dist/gateway/static/root/assets/{projects-page-BxyjqOfC.js → projects-page-RNorFXTw.js} +1 -1
  54. package/dist/gateway/static/root/assets/{remote-access-hub-BFv6Upke.js → remote-access-hub-BqRTcM_6.js} +1 -1
  55. package/dist/gateway/static/root/assets/{save-bar-controls-C3aU8-vO.js → save-bar-controls-DwrD7ODx.js} +1 -1
  56. package/dist/gateway/static/root/assets/{schedule-field-DjegExFD.js → schedule-field-Ba4WzTmE.js} +1 -1
  57. package/dist/gateway/static/root/assets/{schema-form-DLubnsql.js → schema-form-DvydL8eF.js} +1 -1
  58. package/dist/gateway/static/root/assets/{sessions-page-BX4DH8J7.js → sessions-page-B2EfW1cm.js} +1 -1
  59. package/dist/gateway/static/root/assets/settings-advanced-gate-CklL85T4.js +1 -0
  60. package/dist/gateway/static/root/assets/{settings-collapsible-section-3syQHsNR.js → settings-collapsible-section-LaQqGGej.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-form-section-D4DCZzKg.js → settings-form-section-DruI__qO.js} +1 -1
  62. package/dist/gateway/static/root/assets/{settings-loading-skeleton-c5K85ylS.js → settings-loading-skeleton-UvA-eDhF.js} +1 -1
  63. package/dist/gateway/static/root/assets/{settings-page-DNiDlaRq.js → settings-page-5oCGSebm.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-page-layout-iTRY1Hy-.js → settings-page-layout-DG-XMIPu.js} +1 -1
  65. package/dist/gateway/static/root/assets/{setup-status-panel-BH4xQKM9.js → setup-status-panel-D3my1HgB.js} +1 -1
  66. package/dist/gateway/static/root/assets/{share-preview-page-B88Afrhe.js → share-preview-page-FLVeTrRt.js} +1 -1
  67. package/dist/gateway/static/root/assets/{shares-settings-B6kKkvOb.js → shares-settings-DVxgjrsP.js} +1 -1
  68. package/dist/gateway/static/root/assets/{skill-reload-api-DtjS-nUK.js → skill-reload-api-Bcu58ZaF.js} +1 -1
  69. package/dist/gateway/static/root/assets/{skills-page-CQEoPv0u.js → skills-page-CDd-84FE.js} +1 -1
  70. package/dist/gateway/static/root/assets/{system-settings-panel-DtpTq837.js → system-settings-panel-CeK93xVi.js} +1 -1
  71. package/dist/gateway/static/root/assets/{typed-models-lib-ndEnUP3b.js → typed-models-lib-D1Lr2gG0.js} +1 -1
  72. package/dist/gateway/static/root/assets/{user-context-page-Dn2T3itn.js → user-context-page-1OyJnTyR.js} +1 -1
  73. package/dist/gateway/static/root/assets/{voice-api-key-field-wtWc3SfN.js → voice-api-key-field-B2ncRwHS.js} +1 -1
  74. package/dist/gateway/static/root/assets/{work-discovery-page-Ckxhj66e.js → work-discovery-page-BZlY4PZL.js} +1 -1
  75. package/dist/gateway/static/root/assets/{work-item-detail-page-_1QgGPNw.js → work-item-detail-page-DPXMrneY.js} +1 -1
  76. package/dist/gateway/static/root/assets/{work-page-BPdf2iuv.js → work-page-CTERoqyv.js} +1 -1
  77. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ukmpkj66.js → workflow-run-setup-panel-Bynqe4kV.js} +1 -1
  78. package/dist/gateway/static/root/assets/{workflows-page-DdKTx0Hs.js → workflows-page-CLgsnqFQ.js} +1 -1
  79. package/dist/gateway/static/root/index.html +2 -2
  80. package/dist/package.js +1 -1
  81. package/dist/src/agent/embedded/session-tool-result-guard.js +14 -0
  82. package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -1
  83. package/dist/src/agent/service/process-direct-streaming.js +1 -1
  84. package/dist/src/agent/tools/image-generate-tool.js +10 -3
  85. package/dist/src/agent/tools/send-media.js +20 -70
  86. package/dist/src/agent/tools/tool-media.d.ts +9 -0
  87. package/dist/src/agent/tools/tool-media.js +58 -0
  88. package/dist/src/config/agent-profile.js +1 -1
  89. package/dist/src/gateway/agent-run-relay.d.ts +2 -0
  90. package/dist/src/gateway/agent-run-relay.js +114 -14
  91. package/dist/src/gateway/agents-admin.js +1 -1
  92. package/dist/src/gateway/chat-stream/mapper.d.ts +1 -1
  93. package/dist/src/gateway/chat-stream/mapper.js +27 -42
  94. package/dist/src/gateway/chat-stream/thinking-delta-coalescer.d.ts +7 -0
  95. package/dist/src/gateway/chat-stream/thinking-delta-coalescer.js +103 -0
  96. package/dist/src/gateway/hono/sse.d.ts +1 -1
  97. package/dist/src/gateway/hono/sse.js +1 -1
  98. package/dist/src/gateway/service/run-gateway-agent.js +5 -1
  99. package/dist/src/media/session-references.js +9 -6
  100. package/dist/src/session/client-history.d.ts +1 -0
  101. package/dist/src/session/client-history.js +56 -12
  102. package/dist/src/session/types.d.ts +1 -0
  103. package/package.json +1 -1
  104. package/dist/gateway/static/root/assets/index-gpwk8Nro.css +0 -1
  105. package/dist/gateway/static/root/assets/settings-advanced-gate-CJ9MbRP8.js +0 -1
@@ -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{t as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-BuT0SR1R.js";import{n as s}from"./locale-store-C_M71MK9.js";import{$ as c,Aa as l,Ao as u,At as d,Fo as f,Ga as p,Io as m,Ja as h,Mo as g,No as _,Po as v,Pt as y,Ua as b,Wa as x,ao as S,bc as C,hc as w,ja as T,jo as E,ko as D,ms as O,mu as k,oc as A,tc as j,vl as M,vu as N,yc as P,yl as F,zc as I}from"./index-EXa_i6BT.js";var L=n(),R=e(t(),1),z=r();function ee(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:c(n)}function te(e){return[...e].sort((e,t)=>{let n=Number(!!t.pinnedAt)-Number(!!e.pinnedAt);return n===0?new Date(t.lastActiveAt??t.updatedAt).getTime()-new Date(e.lastActiveAt??e.updatedAt).getTime():n})}function ne(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:6},B)}),e[0]=t):t=e[0],t}function B(e,t){return(0,z.jsx)(S,{className:`h-40 rounded-xl`},t)}function re(e){let t=(0,L.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:c}=e,l=s(V),u,d,f,p,m,h,g,_;if(t[0]!==l||t[1]!==n.brief||t[2]!==n.description||t[3]!==n.id||t[4]!==n.lastActiveAt||t[5]!==n.name||t[6]!==n.status||t[7]!==n.updatedAt||t[8]!==n.workspaceRoot){let e=o(l).projectsPage;u=e.management,g=`flex h-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4`;let r;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:(0,z.jsx)(F,{className:`size-4`,"aria-hidden":!0})}),t[17]=r):r=t[17];let a;t[18]===n.name?a=t[19]:(a=(0,z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let s=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[a,(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.statuses[n.status]})]}),c;t[20]===s?c=t[21]:(c=(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,s]}),t[20]=s,t[21]=c);let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,z.jsx)(k,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[22]=v):v=t[22];let y;t[23]===c?y=t[24]:(y=(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,v]}),t[23]=c,t[24]=y),_=(0,z.jsxs)(i,{to:`/projects/${encodeURIComponent(n.id)}`,className:`group flex min-w-0 flex-1 flex-col rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[y,(0,z.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-xs leading-5 text-fg-muted`,children:n.description||n.brief||e.noDescription})]}),h=`mt-3 flex shrink-0 items-end justify-between gap-3 border-t border-edge-subtle pt-3`,p=`min-w-0 text-[11px] text-fg-subtle`,m=(0,z.jsx)(`p`,{className:`truncate`,children:n.workspaceRoot||e.agentDefault}),d=`mt-1`,f=ee(n.lastActiveAt??n.updatedAt,e.never),t[0]=l,t[1]=n.brief,t[2]=n.description,t[3]=n.id,t[4]=n.lastActiveAt,t[5]=n.name,t[6]=n.status,t[7]=n.updatedAt,t[8]=n.workspaceRoot,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_}else u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16];let v;t[25]!==d||t[26]!==f?(v=(0,z.jsx)(`p`,{className:d,children:f}),t[25]=d,t[26]=f,t[27]=v):v=t[27];let y;t[28]!==p||t[29]!==m||t[30]!==v?(y=(0,z.jsxs)(`div`,{className:p,children:[m,v]}),t[28]=p,t[29]=m,t[30]=v,t[31]=y):y=t[31];let b=n.pinnedAt?u.unpin:u.pin,x=n.pinnedAt?u.unpin:u.pin,S;t[32]===n.pinnedAt?S=t[33]:(S=n.pinnedAt?(0,z.jsx)(P,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=S);let w;t[34]!==r||t[35]!==a||t[36]!==b||t[37]!==x||t[38]!==S?(w=(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":b,title:x,children:S}),t[34]=r,t[35]=a,t[36]=b,t[37]=x,t[38]=S,t[39]=w):w=t[39];let T=n.status===`archived`?u.restore:u.archive,E=n.status===`archived`?u.restore:u.archive,D;t[40]===n.status?D=t[41]:(D=n.status===`archived`?(0,z.jsx)(A,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=D);let j;t[42]!==r||t[43]!==c||t[44]!==T||t[45]!==E||t[46]!==D?(j=(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:c,"aria-label":T,title:E,children:D}),t[42]=r,t[43]=c,t[44]=T,t[45]=E,t[46]=D,t[47]=j):j=t[47];let M;t[48]!==w||t[49]!==j?(M=(0,z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[w,j]}),t[48]=w,t[49]=j,t[50]=M):M=t[50];let I;t[51]!==M||t[52]!==h||t[53]!==y?(I=(0,z.jsxs)(`div`,{className:h,children:[y,M]}),t[51]=M,t[52]=h,t[53]=y,t[54]=I):I=t[54];let R;return t[55]!==I||t[56]!==g||t[57]!==_?(R=(0,z.jsxs)(`article`,{className:g,children:[_,I]}),t[55]=I,t[56]=g,t[57]=_,t[58]=R):R=t[58],R}function V(e){return e.language}function H(){let e=o(s(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=m(e=>e.setPageHeader),c=m(e=>e.clearPageHeader),[S,C]=(0,R.useState)([]),[k,A]=(0,R.useState)(!0),[N,P]=(0,R.useState)(null),[L,ee]=(0,R.useState)(``),[B,V]=(0,R.useState)(`active`),[H,U]=(0,R.useState)(null),[ie,W]=(0,R.useState)(!1),[G,K]=(0,R.useState)(null),[q,J]=(0,R.useState)(!1),[Y,ae]=(0,R.useState)(``),[X,oe]=(0,R.useState)(``),[Z,se]=(0,R.useState)(``),Q=y({initialPath:Z,onPicked:se}),$=(0,R.useCallback)(async()=>{A(!0),P(null);try{C(te((await b({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})).items))}catch(e){P(e instanceof Error?e.message:String(e))}finally{A(!1)}},[]);(0,R.useEffect)(()=>{$()},[$]);let ce=(0,R.useMemo)(()=>{let e=L.trim().toLocaleLowerCase();return S.filter(e=>B===`all`||e.status===B).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[B,S,L]),le=(0,R.useMemo)(()=>(0,z.jsxs)(O,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>W(!0),children:[(0,z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,R.useLayoutEffect)(()=>(i({startExtra:null,main:(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:le}),()=>c()),[c,le,n.subtitle,n.title,i]);let ue=(0,R.useCallback)(async e=>{e.preventDefault();let t=Y.trim(),n=Z.trim();if(!(!t||!n||q)){J(!0),K(null);try{let e=await T({name:t,...X.trim()?{description:X.trim()}:{},workspaceRoot:n});C(t=>[e,...t.filter(t=>t.id!==e.id)]),ae(``),oe(``),se(``),W(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){K(e instanceof Error?e.message:String(e))}finally{J(!1)}}},[q,X,Y,Z]),de=(0,R.useCallback)(async(e,t)=>{U(e.id),P(null);try{let n;n=t===`pin`?e.pinnedAt?await h(e.id):await x(e.id):e.status===`archived`?await p(e.id):await l(e.id),C(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{U(null)}},[]),fe=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}];return(0,z.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,z.jsx)(D,{open:ie,onOpenChange:e=>{W(e),e||K(null)},children:(0,z.jsxs)(v,{children:[(0,z.jsx)(_,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,z.jsxs)(E,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,z.jsx)(f,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,z.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,z.jsxs)(`form`,{onSubmit:ue,className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.projectName,(0,z.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:Y,onChange:e=>ae(e.target.value),maxLength:160})]}),(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[n.descriptionLabel,(0,z.jsx)(`textarea`,{className:`min-h-28 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-normal leading-6 outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:X,onChange:e=>oe(e.target.value),maxLength:2e3,placeholder:n.descriptionPlaceholder})]}),(0,z.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspaceRoot}),(0,z.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Q.pick,disabled:q||Q.picking,children:[Q.picking?(0,z.jsx)(I,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,z.jsx)(M,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Z?r.chooseFolder:r.selectWorkingDirectory}),(0,z.jsx)(`span`,{className:a(`mt-0.5 block truncate font-mono text-xs font-normal`,Z?`text-fg-muted`:`text-fg-subtle`),title:Z||void 0,children:Z||t.workspaceSelectionPlaceholder})]})]}),(0,z.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),G?(0,z.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:G}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,z.jsx)(u,{asChild:!0,children:(0,z.jsx)(O,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,z.jsx)(O,{type:`submit`,variant:`primary`,disabled:q||!Y.trim()||!Z.trim(),children:q?t.workHome.creating:t.create})]})]})]})]})}),Q.hasNativePicker?null:(0,z.jsx)(d,{open:Q.modalOpen,onOpenChange:Q.setModalOpen,initialAbsolutePath:Z||void 0,onConfirm:Q.confirmPick,wd:r}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,"aria-label":n.filterLabel,children:fe.map(e=>(0,z.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,B===e.id?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>V(e.id),children:e.label},e.id))}),(0,z.jsxs)(`label`,{className:`relative block min-w-0 sm:w-64`,children:[(0,z.jsx)(j,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`input`,{className:`h-9 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:L,onChange:e=>ee(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder})]})]}),N?(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,role:`alert`,children:[(0,z.jsx)(`span`,{children:N}),(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void $(),children:t.workHome.retry})]}):null,k?(0,z.jsx)(ne,{}):ce.length?(0,z.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ce.map(e=>(0,z.jsx)(re,{project:e,busy:H===e.id,onTogglePin:()=>void de(e,`pin`),onToggleArchive:()=>void de(e,`archive`)},e.id))}):(0,z.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge p-10 text-center`,children:[(0,z.jsx)(F,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.emptyTitle}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint})]})]})}export{H as ProjectsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-BuT0SR1R.js";import{n as s}from"./locale-store-C_M71MK9.js";import{$ as c,Aa as l,Ao as u,At as d,Fo as f,Ga as p,Io as m,Ja as h,Mo as g,No as _,Po as v,Pt as y,Ua as b,Wa as x,ao as S,bc as C,hc as w,ja as T,jo as E,ko as D,ms as O,mu as k,oc as A,tc as j,vl as M,vu as N,yc as P,yl as F,zc as I}from"./index-BuqGh2SW.js";var L=n(),R=e(t(),1),z=r();function ee(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:c(n)}function te(e){return[...e].sort((e,t)=>{let n=Number(!!t.pinnedAt)-Number(!!e.pinnedAt);return n===0?new Date(t.lastActiveAt??t.updatedAt).getTime()-new Date(e.lastActiveAt??e.updatedAt).getTime():n})}function ne(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:6},B)}),e[0]=t):t=e[0],t}function B(e,t){return(0,z.jsx)(S,{className:`h-40 rounded-xl`},t)}function re(e){let t=(0,L.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:c}=e,l=s(V),u,d,f,p,m,h,g,_;if(t[0]!==l||t[1]!==n.brief||t[2]!==n.description||t[3]!==n.id||t[4]!==n.lastActiveAt||t[5]!==n.name||t[6]!==n.status||t[7]!==n.updatedAt||t[8]!==n.workspaceRoot){let e=o(l).projectsPage;u=e.management,g=`flex h-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4`;let r;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,z.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:(0,z.jsx)(F,{className:`size-4`,"aria-hidden":!0})}),t[17]=r):r=t[17];let a;t[18]===n.name?a=t[19]:(a=(0,z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let s=(0,z.jsxs)(`div`,{className:`min-w-0`,children:[a,(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.statuses[n.status]})]}),c;t[20]===s?c=t[21]:(c=(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,s]}),t[20]=s,t[21]=c);let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,z.jsx)(k,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[22]=v):v=t[22];let y;t[23]===c?y=t[24]:(y=(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,v]}),t[23]=c,t[24]=y),_=(0,z.jsxs)(i,{to:`/projects/${encodeURIComponent(n.id)}`,className:`group flex min-w-0 flex-1 flex-col rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[y,(0,z.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-xs leading-5 text-fg-muted`,children:n.description||n.brief||e.noDescription})]}),h=`mt-3 flex shrink-0 items-end justify-between gap-3 border-t border-edge-subtle pt-3`,p=`min-w-0 text-[11px] text-fg-subtle`,m=(0,z.jsx)(`p`,{className:`truncate`,children:n.workspaceRoot||e.agentDefault}),d=`mt-1`,f=ee(n.lastActiveAt??n.updatedAt,e.never),t[0]=l,t[1]=n.brief,t[2]=n.description,t[3]=n.id,t[4]=n.lastActiveAt,t[5]=n.name,t[6]=n.status,t[7]=n.updatedAt,t[8]=n.workspaceRoot,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_}else u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16];let v;t[25]!==d||t[26]!==f?(v=(0,z.jsx)(`p`,{className:d,children:f}),t[25]=d,t[26]=f,t[27]=v):v=t[27];let y;t[28]!==p||t[29]!==m||t[30]!==v?(y=(0,z.jsxs)(`div`,{className:p,children:[m,v]}),t[28]=p,t[29]=m,t[30]=v,t[31]=y):y=t[31];let b=n.pinnedAt?u.unpin:u.pin,x=n.pinnedAt?u.unpin:u.pin,S;t[32]===n.pinnedAt?S=t[33]:(S=n.pinnedAt?(0,z.jsx)(P,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=S);let w;t[34]!==r||t[35]!==a||t[36]!==b||t[37]!==x||t[38]!==S?(w=(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":b,title:x,children:S}),t[34]=r,t[35]=a,t[36]=b,t[37]=x,t[38]=S,t[39]=w):w=t[39];let T=n.status===`archived`?u.restore:u.archive,E=n.status===`archived`?u.restore:u.archive,D;t[40]===n.status?D=t[41]:(D=n.status===`archived`?(0,z.jsx)(A,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=D);let j;t[42]!==r||t[43]!==c||t[44]!==T||t[45]!==E||t[46]!==D?(j=(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:c,"aria-label":T,title:E,children:D}),t[42]=r,t[43]=c,t[44]=T,t[45]=E,t[46]=D,t[47]=j):j=t[47];let M;t[48]!==w||t[49]!==j?(M=(0,z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[w,j]}),t[48]=w,t[49]=j,t[50]=M):M=t[50];let I;t[51]!==M||t[52]!==h||t[53]!==y?(I=(0,z.jsxs)(`div`,{className:h,children:[y,M]}),t[51]=M,t[52]=h,t[53]=y,t[54]=I):I=t[54];let R;return t[55]!==I||t[56]!==g||t[57]!==_?(R=(0,z.jsxs)(`article`,{className:g,children:[_,I]}),t[55]=I,t[56]=g,t[57]=_,t[58]=R):R=t[58],R}function V(e){return e.language}function H(){let e=o(s(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=m(e=>e.setPageHeader),c=m(e=>e.clearPageHeader),[S,C]=(0,R.useState)([]),[k,A]=(0,R.useState)(!0),[N,P]=(0,R.useState)(null),[L,ee]=(0,R.useState)(``),[B,V]=(0,R.useState)(`active`),[H,U]=(0,R.useState)(null),[ie,W]=(0,R.useState)(!1),[G,K]=(0,R.useState)(null),[q,J]=(0,R.useState)(!1),[Y,ae]=(0,R.useState)(``),[X,oe]=(0,R.useState)(``),[Z,se]=(0,R.useState)(``),Q=y({initialPath:Z,onPicked:se}),$=(0,R.useCallback)(async()=>{A(!0),P(null);try{C(te((await b({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})).items))}catch(e){P(e instanceof Error?e.message:String(e))}finally{A(!1)}},[]);(0,R.useEffect)(()=>{$()},[$]);let ce=(0,R.useMemo)(()=>{let e=L.trim().toLocaleLowerCase();return S.filter(e=>B===`all`||e.status===B).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[B,S,L]),le=(0,R.useMemo)(()=>(0,z.jsxs)(O,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>W(!0),children:[(0,z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,R.useLayoutEffect)(()=>(i({startExtra:null,main:(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:le}),()=>c()),[c,le,n.subtitle,n.title,i]);let ue=(0,R.useCallback)(async e=>{e.preventDefault();let t=Y.trim(),n=Z.trim();if(!(!t||!n||q)){J(!0),K(null);try{let e=await T({name:t,...X.trim()?{description:X.trim()}:{},workspaceRoot:n});C(t=>[e,...t.filter(t=>t.id!==e.id)]),ae(``),oe(``),se(``),W(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){K(e instanceof Error?e.message:String(e))}finally{J(!1)}}},[q,X,Y,Z]),de=(0,R.useCallback)(async(e,t)=>{U(e.id),P(null);try{let n;n=t===`pin`?e.pinnedAt?await h(e.id):await x(e.id):e.status===`archived`?await p(e.id):await l(e.id),C(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{U(null)}},[]),fe=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}];return(0,z.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,z.jsx)(D,{open:ie,onOpenChange:e=>{W(e),e||K(null)},children:(0,z.jsxs)(v,{children:[(0,z.jsx)(_,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,z.jsxs)(E,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,z.jsx)(f,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,z.jsx)(g,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,z.jsxs)(`form`,{onSubmit:ue,className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.projectName,(0,z.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:Y,onChange:e=>ae(e.target.value),maxLength:160})]}),(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[n.descriptionLabel,(0,z.jsx)(`textarea`,{className:`min-h-28 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-normal leading-6 outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:X,onChange:e=>oe(e.target.value),maxLength:2e3,placeholder:n.descriptionPlaceholder})]}),(0,z.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,z.jsx)(`span`,{className:`font-medium text-fg`,children:t.workspaceRoot}),(0,z.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:Q.pick,disabled:q||Q.picking,children:[Q.picking?(0,z.jsx)(I,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,z.jsx)(M,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Z?r.chooseFolder:r.selectWorkingDirectory}),(0,z.jsx)(`span`,{className:a(`mt-0.5 block truncate font-mono text-xs font-normal`,Z?`text-fg-muted`:`text-fg-subtle`),title:Z||void 0,children:Z||t.workspaceSelectionPlaceholder})]})]}),(0,z.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),G?(0,z.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:G}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,z.jsx)(u,{asChild:!0,children:(0,z.jsx)(O,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,z.jsx)(O,{type:`submit`,variant:`primary`,disabled:q||!Y.trim()||!Z.trim(),children:q?t.workHome.creating:t.create})]})]})]})]})}),Q.hasNativePicker?null:(0,z.jsx)(d,{open:Q.modalOpen,onOpenChange:Q.setModalOpen,initialAbsolutePath:Z||void 0,onConfirm:Q.confirmPick,wd:r}),(0,z.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,"aria-label":n.filterLabel,children:fe.map(e=>(0,z.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,B===e.id?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>V(e.id),children:e.label},e.id))}),(0,z.jsxs)(`label`,{className:`relative block min-w-0 sm:w-64`,children:[(0,z.jsx)(j,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`input`,{className:`h-9 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:L,onChange:e=>ee(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder})]})]}),N?(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,role:`alert`,children:[(0,z.jsx)(`span`,{children:N}),(0,z.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void $(),children:t.workHome.retry})]}):null,k?(0,z.jsx)(ne,{}):ce.length?(0,z.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:ce.map(e=>(0,z.jsx)(re,{project:e,busy:H===e.id,onTogglePin:()=>void de(e,`pin`),onToggleArchive:()=>void de(e,`archive`)},e.id))}):(0,z.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge p-10 text-center`,children:[(0,z.jsx)(F,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,z.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.emptyTitle}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint})]})]})}export{H as ProjectsPage};
@@ -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-uQ0fehio.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-BuT0SR1R.js";import{a as u,i as d,l as f,n as p,o as m,r as h,s as g}from"./locale-store-C_M71MK9.js";import{a as _,i as v}from"./vendor-swr-BIWyz7Rc.js";import{$s as y,As as b,Fo as x,Gn as S,Ho as C,Js as w,Ks as T,Mo as E,No as D,Nt as O,Oc as k,Ol as A,Oo as j,Pl as M,Po as N,Ps as P,Ql as F,Ul as I,Xo as L,Yo as R,_i as z,ao as B,as as V,cc as ee,ci as te,di as H,el as ne,fi as U,gi as re,hi as W,io as G,jo as K,ko as q,li as J,mi as Y,ms as X,pc as ie,pi as ae,pl as oe,ps as se,ro as ce,rr as le,si as ue,ui as de,vi as fe,yi as pe,zc as me,zi as he}from"./index-EXa_i6BT.js";import{n as ge,r as _e,t as ve}from"./settings-page-layout-iTRY1Hy-.js";import{t as ye}from"./settings-collapsible-section-3syQHsNR.js";import{n as be,r as xe,t as Se}from"./settings-form-section-D4DCZzKg.js";import{t as Ce}from"./browser-BLJWD7WI.js";import{t as we}from"./page-tabs-hinRdDy3.js";var Z=n(),Q=e(t(),1);function Te(e,t){let{mutate:n}=_(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),ce()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await H();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await ue();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await te(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await J():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function Ee(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,se,`dark:border-edge`)}function De(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:s,onRefreshQr:c}=e,u=i===void 0?!1:i,d=s===void 0?!1:s,f=p(Ae),m;t[0]===f?m=t[1]:(m=l(f),t[0]=f,t[1]=m);let h=m,g=h.tunnelSettings,_=d?h.remoteAccess.lan:null,v;t[2]!==h.clipboard.copyFailed||t[3]!==g.pairCopied||t[4]!==g.pairCopyLink?(v={copy:g.pairCopyLink,copied:g.pairCopied,copyFailed:h.clipboard.copyFailed},t[2]=h.clipboard.copyFailed,t[3]=g.pairCopied,t[4]=g.pairCopyLink,t[5]=v):v=t[5];let y=v,{tunnelActive:b,tunnelStatus:x,tunnelQr:S,pairContext:C,pairBaseUrl:w,setPairBaseUrl:E,applySuggestedPairUrl:D,applyCandidateUrl:O,resetPairBaseFromContext:k,baseOk:A,localhostWarn:j,pairingBlocked:M,deepLink:N,qrPayload:P,qrDataUrl:F,qrGenFailed:I,encoding:L}=n,R;t[6]===k?R=t[7]:(R=e=>{k(e.recommended.url)},t[6]=k,t[7]=R);let z=Te(r,R),B,V,te,H,ne;if(t[8]!==O||t[9]!==D||t[10]!==A||t[11]!==z||t[12]!==r||t[13]!==_||t[14]!==d||t[15]!==j||t[16]!==c||t[17]!==w||t[18]!==C?.candidates||t[19]!==C?.recommended||t[20]!==M||t[21]!==E||t[22]!==u||t[23]!==g.pairBaseUrlHint||t[24]!==g.pairBaseUrlLabel||t[25]!==g.pairBaseUrlPlaceholder||t[26]!==g.pairBlockedLoopbackBody||t[27]!==g.pairBlockedNextSteps||t[28]!==g.pairBlockedTitle||t[29]!==g.pairCandidatesTitle||t[30]!==g.pairEnableLanButton||t[31]!==g.pairEnableLanEnabling||t[32]!==g.pairEnableLanSecurityAuditLink||t[33]!==g.pairInvalidBaseUrl||t[34]!==g.pairLocalhostWarning||t[35]!==g.pairSelectCandidateHint||t[36]!==g.pairSelectCandidateTitle||t[37]!==g.pairSubtitle||t[38]!==g.pairSuggestedLanLabel||t[39]!==g.pairTitle||t[40]!==g.pairTunnelActive||t[41]!==g.pairTunnelLanUrl||t[42]!==g.pairTunnelPublicUrl||t[43]!==g.pairUseSuggestedUrl||t[44]!==g.pairWaitingForTunnel||t[45]!==g.refreshQr||t[46]!==b||t[47]!==S||t[48]!==x?.publicUrl){ne=Symbol.for(`react.early_return_sentinel`);bb0:{let e=C?.candidates.filter(ke)??[],n=d?(e.find(Oe)?.url??e[0]?.url??``).trim():C?.recommended.url?.trim()??``,i=(d||!b)&&e.length>1,s=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:o(`text-xs font-medium`,r),children:i?g.pairSelectCandidateTitle:g.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:o(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,w.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>O(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:o(`mt-1 text-[11px] leading-relaxed`,r),children:g.pairSelectCandidateHint}):null]})};if(B=u&&!d,B&&!b){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(T,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===g.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,g.pairTitle]}),t[55]=g.pairTitle,t[56]=n);let r;t[57]===g.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:g.pairWaitingForTunnel}),t[57]=g.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Se,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],ne=i;break bb0}let l=_?.pairTitle??g.pairTitle,f=d?_?.pairSubtitle??g.pairSubtitle:b?g.pairTunnelActive:g.pairSubtitle,p=!!(c&&(d||u&&b)),m=B?`mb-2`:`mb-3`,h;t[62]===m?h=t[63]:(h=o(`flex flex-wrap items-start justify-between gap-2`,m),t[62]=m,t[63]=h);let v;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(T,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=v):v=t[64];let y;t[65]===l?y=t[66]:(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[v,l]}),t[65]=l,t[66]=y);let k;t[67]!==B||t[68]!==f||t[69]!==g.pairSubtitle?(k=B?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:g.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:f}),t[67]=B,t[68]=f,t[69]=g.pairSubtitle,t[70]=k):k=t[70];let N;t[71]!==y||t[72]!==k?(N=(0,$.jsxs)(`div`,{children:[y,k]}),t[71]=y,t[72]=k,t[73]=N):N=t[73];let P;t[74]!==c||t[75]!==p||t[76]!==g.refreshQr?(P=p?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void c(),children:[(0,$.jsx)(ee,{className:`size-4`}),g.refreshQr]}):null,t[74]=c,t[75]=p,t[76]=g.refreshQr,t[77]=P):P=t[77],t[78]!==h||t[79]!==N||t[80]!==P?(V=(0,$.jsxs)(`div`,{className:h,children:[N,P]}),t[78]=h,t[79]=N,t[80]=P,t[81]=V):V=t[81],te=M?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:g.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:g.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:g.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:D,children:g.pairUseSuggestedUrl})]}):null,e.length>0?s(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(X,{type:`button`,className:`w-full sm:w-auto`,disabled:z.busy||!r,onClick:()=>z.setConfirmOpen(!0),children:[z.busy?(0,$.jsx)(me,{className:`size-3.5 animate-spin`}):null,z.busy?g.pairEnableLanEnabling:g.pairEnableLanButton]})}),z.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:z.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?_?.pairBlockedNextSteps??g.pairBlockedNextSteps:g.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(a,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairEnableLanSecurityAuditLink}),d&&_?.pairPublicTabLink?(0,$.jsx)(a,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:_.pairPublicTabLink}):null]})]}):null,H=b&&!d?B?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:x?.publicUrl})]}),S?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:S.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:g.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:o(Ee(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||g.pairBaseUrlPlaceholder,value:w,onChange:e=>E(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:g.pairBaseUrlHint}),!A&&w.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:g.pairInvalidBaseUrl}):null,j?(0,$.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:g.pairLocalhostWarning}):null,i?s(`neutral`):null]})}t[8]=O,t[9]=D,t[10]=A,t[11]=z,t[12]=r,t[13]=_,t[14]=d,t[15]=j,t[16]=c,t[17]=w,t[18]=C?.candidates,t[19]=C?.recommended,t[20]=M,t[21]=E,t[22]=u,t[23]=g.pairBaseUrlHint,t[24]=g.pairBaseUrlLabel,t[25]=g.pairBaseUrlPlaceholder,t[26]=g.pairBlockedLoopbackBody,t[27]=g.pairBlockedNextSteps,t[28]=g.pairBlockedTitle,t[29]=g.pairCandidatesTitle,t[30]=g.pairEnableLanButton,t[31]=g.pairEnableLanEnabling,t[32]=g.pairEnableLanSecurityAuditLink,t[33]=g.pairInvalidBaseUrl,t[34]=g.pairLocalhostWarning,t[35]=g.pairSelectCandidateHint,t[36]=g.pairSelectCandidateTitle,t[37]=g.pairSubtitle,t[38]=g.pairSuggestedLanLabel,t[39]=g.pairTitle,t[40]=g.pairTunnelActive,t[41]=g.pairTunnelLanUrl,t[42]=g.pairTunnelPublicUrl,t[43]=g.pairUseSuggestedUrl,t[44]=g.pairWaitingForTunnel,t[45]=g.refreshQr,t[46]=b,t[47]=S,t[48]=x?.publicUrl,t[49]=B,t[50]=V,t[51]=te,t[52]=H,t[53]=ne}else B=t[49],V=t[50],te=t[51],H=t[52],ne=t[53];if(ne!==Symbol.for(`react.early_return_sentinel`))return ne;let U;t[82]===g.pairSecurityNote?U=t[83]:(U=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:g.pairSecurityNote}),t[82]=g.pairSecurityNote,t[83]=U);let re;t[84]!==y||t[85]!==N||t[86]!==L||t[87]!==M||t[88]!==F||t[89]!==I||t[90]!==g.pairEncoding||t[91]!==g.pairImageError||t[92]!==g.pairQrDisabled?(re=N?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[F&&!I?(0,$.jsx)(`img`,{src:F,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,L?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.pairEncoding}):null,I?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:g.pairImageError}):null,(0,$.jsx)(he,{text:N,labels:y})]}):M?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.pairQrDisabled}):null,t[84]=y,t[85]=N,t[86]=L,t[87]=M,t[88]=F,t[89]=I,t[90]=g.pairEncoding,t[91]=g.pairImageError,t[92]=g.pairQrDisabled,t[93]=re):re=t[93];let W;t[94]!==B||t[95]!==P||t[96]!==g.deeplinkTitle?(W=P&&!B?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:g.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:P})]}):null,t[94]=B,t[95]=P,t[96]=g.deeplinkTitle,t[97]=W):W=t[97];let G;t[98]!==B||t[99]!==g.pairMobileProbeHint||t[100]!==g.pairSchemeHint?(G=B?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:g.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:g.pairMobileProbeHint})]}),t[98]=B,t[99]=g.pairMobileProbeHint,t[100]=g.pairSchemeHint,t[101]=G):G=t[101];let K,q;t[102]===z?(K=t[103],q=t[104]):(K=()=>void z.runEnableLanPairing(),q=()=>{z.busy||z.setConfirmOpen(!1)},t[102]=z,t[103]=K,t[104]=q);let J;t[105]!==z.confirmOpen||t[106]!==g.consentCancel||t[107]!==g.pairEnableLanButton||t[108]!==g.pairEnableLanConfirmBody||t[109]!==g.pairEnableLanConfirmTitle||t[110]!==K||t[111]!==q?(J=(0,$.jsx)(le,{open:z.confirmOpen,title:g.pairEnableLanConfirmTitle,description:g.pairEnableLanConfirmBody,confirmLabel:g.pairEnableLanButton,cancelLabel:g.consentCancel,onConfirm:K,onCancel:q}),t[105]=z.confirmOpen,t[106]=g.consentCancel,t[107]=g.pairEnableLanButton,t[108]=g.pairEnableLanConfirmBody,t[109]=g.pairEnableLanConfirmTitle,t[110]=K,t[111]=q,t[112]=J):J=t[112];let Y;return t[113]!==U||t[114]!==re||t[115]!==W||t[116]!==G||t[117]!==J||t[118]!==V||t[119]!==te||t[120]!==H?(Y=(0,$.jsx)(Se,{children:(0,$.jsxs)($.Fragment,{children:[V,te,H,U,re,W,G,J]})}),t[113]=U,t[114]=re,t[115]=W,t[116]=G,t[117]=J,t[118]=V,t[119]=te,t[120]=H,t[121]=Y):Y=t[121],Y}function Oe(e){return e.reachable}function ke(e){return e.kind===`lan`}function Ae(e){return e.language}function je(e){let t=(0,Z.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(D,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,L)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=o(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,R),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let v;t[6]===i?v=t[7]:(v=(0,$.jsx)(E,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=v);let y;t[8]===a?y=t[9]:(y=a.map(Me),t[8]=a,t[9]=y);let b;t[10]===y?b=t[11]:(b=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===s?w=t[16]:(w=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=w);let T;t[17]!==w||t[18]!==C?(T=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=T):T=t[19];let O;t[20]!==l||t[21]!==d?(O=(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=O):O=t[22];let k=!f,A;t[23]!==c||t[24]!==u||t[25]!==k?(A=(0,$.jsx)(X,{type:`button`,disabled:k,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=k,t[26]=A):A=t[26];let j;t[27]!==O||t[28]!==A?(j=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[O,A]}),t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==T||t[31]!==j||t[32]!==_||t[33]!==v||t[34]!==b?(M=(0,$.jsxs)(N,{children:[h,(0,$.jsxs)(K,{className:g,onOpenAutoFocus:Ne,children:[_,v,b,T,j]})]}),t[30]=T,t[31]=j,t[32]=_,t[33]=v,t[34]=b,t[35]=M):M=t[35];let P;return t[36]!==n||t[37]!==m||t[38]!==M?(P=(0,$.jsx)(q,{open:n,onOpenChange:m,children:M}),t[36]=n,t[37]=m,t[38]=M,t[39]=P):P=t[39],P}function Me(e){return(0,$.jsx)(`li`,{children:e},e)}function Ne(e){return e.preventDefault()}function Pe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Fe=[`preparing_frpc`,`registering`,`starting_frpc`];function Ie(e){return e?e===`reconnecting_frpc`?Fe.indexOf(`starting_frpc`):Fe.indexOf(e):-1}function Le(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Fe.indexOf(e),i=Ie(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Re(e,t,n){let r=n.startProgress;return Le(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function ze(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Be(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ve(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,i]=(0,Q.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(He),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let c=n.startProgress?.startedAt,l;if(t[3]!==n.state||t[4]!==c?(l=[n.state,c],t[3]=n.state,t[4]=c,t[5]=l):l=t[5],(0,Q.useEffect)(a,l),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let u,d,f,p,m;if(t[6]!==n||t[7]!==r){let e=Be(n.startProgress?.startedAt);u=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,d=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(f=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=f):f=t[19];let c=Fe.map(e=>{let t=Le(e,n),i=Re(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(s,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(me,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(I,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:o(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:ze(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:o(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Pe(n.frpcDownload.bytesReceived),` /`,` `,Pe(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===c?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:c}),t[20]=c,t[21]=p),m=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[22]!==u||t[23]!==r.publicUrlPendingNotice?(h=u?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=u,t[23]=r.publicUrlPendingNotice,t[24]=h):h=t[24];let g;return t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:d,children:[f,p,m,h]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g):g=t[30],g}function He(e){return e+1}function Ue(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function We(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function Ge(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Ke(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function qe(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,x,S,C,w;t[0]!==r||t[1]!==s?(w=We(r),_=r.enabled||s,v=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=o(xe(),`space-y-4`),t[9]=C):C=t[9],S=`flex flex-wrap items-start justify-between gap-3`,x=`flex items-center gap-2`,y=o(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ge(w)),t[0]=r,t[1]=s,t[2]=_,t[3]=v,t[4]=y,t[5]=x,t[6]=S,t[7]=C,t[8]=w):(_=t[2],v=t[3],y=t[4],x=t[5],S=t[6],C=t[7],w=t[8]);let T=w===`connected`&&`bg-emerald-500`,E=w===`progress`&&`bg-amber-500 animate-pulse`,D=w===`error`&&`bg-red-500`,O=w===`off`&&`bg-fg-subtle`,k;t[10]!==T||t[11]!==E||t[12]!==D||t[13]!==O?(k=o(`size-1.5 rounded-full`,T,E,D,O),t[10]=T,t[11]=E,t[12]=D,t[13]=O,t[14]=k):k=t[14];let A;t[15]===k?A=t[16]:(A=(0,$.jsx)(`span`,{className:k,"aria-hidden":!0}),t[15]=k,t[16]=A);let j;t[17]!==i||t[18]!==r||t[19]!==n?(j=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):Ue(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=j):j=t[20];let M;t[21]!==A||t[22]!==j||t[23]!==y?(M=(0,$.jsxs)(`span`,{className:y,children:[A,j]}),t[21]=A,t[22]=j,t[23]=y,t[24]=M):M=t[24];let N;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(N=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ke(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=N):N=t[28];let P;t[29]!==M||t[30]!==N||t[31]!==x?(P=(0,$.jsxs)(`div`,{className:x,children:[M,N]}),t[29]=M,t[30]=N,t[31]=x,t[32]=P):P=t[32];let F;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(oe,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=F):F=t[33];let I;t[34]!==P||t[35]!==S?(I=(0,$.jsxs)(`div`,{className:S,children:[P,F]}),t[34]=P,t[35]=S,t[36]=I):I=t[36];let L;t[37]===a?L=t[38]:(L=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=L);let R;t[39]!==l||t[40]!==n.consentExpiredBanner?(R=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=R):R=t[41];let z;t[42]!==_||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(z=_?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(he,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Ve,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(X,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(me,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(X,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(me,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=u,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=z):z=t[54];let B;return t[55]!==I||t[56]!==L||t[57]!==R||t[58]!==z||t[59]!==C?(B=(0,$.jsxs)(`section`,{className:C,children:[I,L,R,z]}),t[55]=I,t[56]=L,t[57]=R,t[58]=z,t[59]=C,t[60]=B):B=t[60],B}var Je=`https://console.xopc.ai/keys/tunnel`,Ye={reconfiguring:!1};function Xe(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:i,brokerSecretConfiguredInConfig:a,brokerSecretMaskedValue:c,brokerSecretDraft:l,savingBrokerSecret:u,brokerSecretNotice:d,copyFailedLabel:f,onDraftChange:p,onSave:m,onClear:h,sectionRef:g}=e,_=(0,Q.useId)(),v=i&&!r,y=!v,[b,x]=(0,Q.useReducer)(O,Ye),{reconfiguring:C}=b,w;t[0]!==a||t[1]!==l||t[2]!==r||t[3]!==C?(w=a&&!r&&!C&&!l.trim(),t[0]=a,t[1]=l,t[2]=r,t[3]=C,t[4]=w):w=t[4];let T=w,E;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(E={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=E):E=t[9];let D=E,k;t[10]===l?k=t[11]:(k=l.trim().length>0&&!S(l.trim()),t[10]=l,t[11]=k);let j=k,M;t[12]===p?M=t[13]:(M=()=>{x({type:`patch`,patch:{reconfiguring:!1}}),p(``)},t[12]=p,t[13]=M);let N=M,P=v&&`ring-1 ring-amber-500/30`,F;t[14]===P?F=t[15]:(F=o(P),t[14]=P,t[15]=F);let I=y?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:v?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,L;t[16]===I?L=t[17]:(L=o(`flex size-9 shrink-0 items-center justify-center rounded-lg`,I),t[16]=I,t[17]=L);let R;t[18]===y?R=t[19]:(R=y?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=y,t[19]=R);let z;t[20]!==L||t[21]!==R?(z=(0,$.jsx)(`span`,{className:L,children:R}),t[20]=L,t[21]=R,t[22]=z):z=t[22];let B=y?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,ee;t[23]===B?ee=t[24]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:B}),t[23]=B,t[24]=ee);let te=y?n.brokerSecretReadyHint:n.brokerSecretHint,H;t[25]===te?H=t[26]:(H=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:te}),t[25]=te,t[26]=H);let U;t[27]!==v||t[28]!==n.brokerSecretMissingHint?(U=v?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=v,t[28]=n.brokerSecretMissingHint,t[29]=U):U=t[29];let re;t[30]!==ee||t[31]!==H||t[32]!==U?(re=(0,$.jsxs)(`div`,{children:[ee,H,U]}),t[30]=ee,t[31]=H,t[32]=U,t[33]=re):re=t[33];let W;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(A,{className:`size-3`,"aria-hidden":!0}),t[34]=W):W=t[34];let G;t[35]===n.brokerSecretConsoleLink?G=t[36]:(G=(0,$.jsxs)(`a`,{href:Je,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,W]}),t[35]=n.brokerSecretConsoleLink,t[36]=G);let K;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(K=r?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=K):K=t[39];let q;t[40]!==a||t[41]!==l||t[42]!==r||t[43]!==c||t[44]!==j||t[45]!==N||t[46]!==f||t[47]!==_||t[48]!==v||t[49]!==h||t[50]!==p||t[51]!==m||t[52]!==C||t[53]!==u||t[54]!==D||t[55]!==T||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(q=T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(V,{id:_,value:c,labels:D,reveal:Ze,loadFailedLabel:f||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>{x({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(V,{id:_,value:l,onChange:p,placeholder:n.brokerSecretPlaceholder,labels:D,disabled:u}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(X,{type:`button`,disabled:u||!j,onClick:m,children:[u?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,v?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),a||r?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear}):null,C?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:N,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=a,t[41]=l,t[42]=r,t[43]=c,t[44]=j,t[45]=N,t[46]=f,t[47]=_,t[48]=v,t[49]=h,t[50]=p,t[51]=m,t[52]=C,t[53]=u,t[54]=D,t[55]=T,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=q):q=t[66];let J;t[67]===d?J=t[68]:(J=d?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:d}):null,t[67]=d,t[68]=J);let Y;t[69]!==re||t[70]!==G||t[71]!==K||t[72]!==q||t[73]!==J?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[re,G,K,q,J]}),t[69]=re,t[70]=G,t[71]=K,t[72]=q,t[73]=J,t[74]=Y):Y=t[74];let ie;t[75]!==z||t[76]!==Y?(ie=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,Y]}),t[75]=z,t[76]=Y,t[77]=ie):ie=t[77];let ae;t[78]!==ie||t[79]!==F?(ae=(0,$.jsx)(Se,{className:F,children:ie}),t[78]=ie,t[79]=F,t[80]=ae):ae=t[80];let oe;return t[81]!==g||t[82]!==ae?(oe=(0,$.jsx)(`div`,{ref:g,id:`tunnel-broker-secret-setup`,children:ae}),t[81]=g,t[82]=ae,t[83]=oe):oe=t[83],oe}function Ze(){return z().then(Qe)}function Qe(e){return e.registrationSecret??null}function $e(e){let t=(0,Z.c)(10),{language:n,label:r,section:i,className:a}=e,s;t[0]!==n||t[1]!==i?(s=C(n,i),t[0]=n,t[1]=i,t[2]=s):s=t[2];let c;t[3]===a?c=t[4]:(c=o(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(A,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var et=e(Ce(),1),tt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function nt(e){return et.toDataURL(e,tt)}function rt(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function it(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function at(e,t){return e?t?rt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function ot(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=_(),a=(0,Q.useRef)(!1),{data:o}=v(r?`tunnel-status`:null,Y,{refreshInterval:6e4}),{data:s,mutate:c}=v(r?`tunnel-pair-context`:null,U,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let l=o?.state===`connected`&&!!o.publicUrl?.trim(),f=l&&!n,{data:p,mutate:m}=v(f&&r?`tunnel-qr`:null,ae,{refreshInterval:4*6e4}),{data:h,mutate:g}=v(!f&&r&&s?.pairingReady?`tunnel-pair`:null,de,{refreshInterval:4*6e4}),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==C.pairContext||n!==C.preferLan)){w({pairContext:s,preferLan:n});let e=at(s,n);y!==e&&b(e)}let T=(0,Q.useCallback)(e=>{a.current=!0,b(e)},[]),E=(0,Q.useCallback)(()=>{let e=at(s,n);e&&(a.current=!0,b(e))},[s,n]),D=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),O=(0,Q.useCallback)(e=>{a.current=!1,b(e?.trim()||at(s,n))},[s,n]),k=y.trim(),A=(0,Q.useMemo)(()=>{try{let e=new URL(k);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[k]),M=A&&u(k),N=!f&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),P=!f&&A&&!M&&!!h?.pairingSecret&&(s?.pairingReady===!0||!N),F=(0,Q.useMemo)(()=>{let e=rt(s);return n?e||(k&&!it(s,k)?k:``):k},[s,n,k]),I=(0,Q.useMemo)(()=>{if(!e)return``;if(x.trim())return x.trim();if(f&&p?.qrPayload?.trim())return p.qrPayload.trim();if(!P||!h?.pairingSecret)return``;let t=s?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=s?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?F:t?.url??k;return i?d({baseUrl:i,pairingSecret:h.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,F,h?.pairingSecret,P,x,n,k,f,p?.qrPayload,s?.candidates]),L=j(()=>nt(I),[I],{enabled:!!I,initial:null,errorData:null}),R=I?L.data:null,z=!!(I&&L.error!==null&&!L.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:p,pairContext:s,pairBaseUrl:y,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,baseOk:A,localhostWarn:M,pairingBlocked:N,deepLink:I,qrPayload:I,qrDataUrl:R,qrGenFailed:z,encoding:!!(I&&!R&&!z),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){S(e.trim()),m({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:p?.lanUrl??null},!1);return}S(``),await c(),f?await m():s?.pairingReady&&await g()},[g,c,m,s?.pairingReady,p?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:O}}var st={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function ct({embedded:e=!1}){let t=p(e=>e.language),n=l(t).tunnelSettings,r=f(e=>e.token),i=!!r,[a,s]=(0,Q.useReducer)(O,st),{actionError:c,starting:u,stopping:d,savingAutoStart:m,consentOpen:h,autoStartConfirmOpen:g,releaseConfirmOpen:_,releasing:y,brokerSecretDraft:b,savingBrokerSecret:x,brokerSecretNotice:C}=a,w=(0,Q.useRef)(null),T=ot(r??``),{data:E}=G(i),{data:D,error:k,isLoading:A,mutate:j}=v(i?`tunnel-status`:null,Y,{refreshInterval:e=>u?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),M=(0,Q.useMemo)(()=>{let e=E?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return D?.config?.autoStart===!0},[E,D?.config?.autoStart]),N=(0,Q.useMemo)(()=>{let e=E?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[E]),P=S(N),F=D?.registrationSecret?.source===`env`,I=D?.registrationSecret?.source===`missing`,L=D?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{j()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[j]);let R=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),z=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{actionError:null}}),s({type:`patch`,patch:{starting:!0}});try{let e=await fe();await j(),ce(),await T.refreshQr(e.qrPayload)}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{starting:!1}})}},[j,T.refreshQr]),B=(0,Q.useCallback)(()=>{if(!L){s({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),w.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(D?.consentRequired){s({type:`patch`,patch:{consentOpen:!0}});return}z()},[L,D?.consentRequired,z,n.brokerSecretRequiredBeforeStart]),V=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{consentOpen:!1}}),s({type:`patch`,patch:{actionError:null}});try{await re(),await Promise.all([j(),z()])}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[j,z]),ee=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{actionError:null}}),s({type:`patch`,patch:{stopping:!0}});try{await pe(),await Promise.all([T.refreshQr(),j()]),ce()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{stopping:!1}})}},[j,T.refreshQr]),te=(0,Q.useCallback)(async e=>{s({type:`patch`,patch:{savingAutoStart:!0}}),s({type:`patch`,patch:{actionError:null}});try{await W({autoStart:e}),ce()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingAutoStart:!1}})}},[]),H=(0,Q.useCallback)(()=>{if(M){te(!1);return}if(D?.consentRequired){s({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!D?.canAutoStart){s({type:`patch`,patch:{actionError:n.autoStartHint}});return}s({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[te,D?.canAutoStart,D?.consentRequired,n,M]),ne=(0,Q.useCallback)(async()=>{let e=b.trim();if(e){s({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await W({registrationSecret:e}),s({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),ce(),await j(),s({type:`patch`,patch:{actionError:null}})}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[b,j,n.brokerSecretSaved]),U=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await W({registrationSecret:null}),s({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),ce(),await j()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingBrokerSecret:!1}})}},[j,n.brokerSecretCleared]),K=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await pe({release:!0}),await Promise.all([T.refreshQr(),j()]),ce()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{releasing:!1}})}},[j,T.refreshQr]),q=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!i)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let J=D??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:M,brokerUrl:`https://frp.xopc.ai/api`}},ie=D?.consentRequired&&(J.enabled||M||D?.consent?.acceptedAt),ae=(0,$.jsx)(Xe,{t:n,brokerSecretFromEnv:F,brokerSecretMissing:I,brokerSecretConfiguredInConfig:P,brokerSecretMaskedValue:P?N:``,brokerSecretDraft:b,savingBrokerSecret:x,brokerSecretNotice:C,copyFailedLabel:l(t).clipboard.copyFailed,onDraftChange:e=>s({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void ne(),onClear:()=>void U(),sectionRef:w}),se=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(je,{open:h,title:n.consentTitle,intro:n.consentIntro,bullets:R,checkboxLabel:n.consentCheckbox,confirmLabel:ie?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void V(),onCancel:()=>s({type:`patch`,patch:{consentOpen:!1}})},h?`consent-open`:`consent-closed`),(0,$.jsx)(le,{open:g,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{s({type:`patch`,patch:{autoStartConfirmOpen:!1}}),te(!0)},onCancel:()=>s({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(le,{open:_,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void K(),onCancel:()=>s({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,ae,(0,$.jsx)(qe,{t:n,status:J,isLoading:A,statusErr:k,starting:u,stopping:d,showConsentExpired:!!ie,copyLabels:q,startDisabled:!L,startDisabledReason:L?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:B,onStop:()=>void ee()}),(0,$.jsx)(De,{pairQr:T,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void T.refreshQr()}),(0,$.jsxs)(ye,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:o(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:m||!M&&!D?.canAutoStart,onChange:H}),n.autoStart]}),!D?.canAutoStart&&!M?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,J.subdomain||J.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:y||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>s({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ye,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),se]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,ae,(0,$.jsx)(qe,{t:n,status:J,isLoading:A,statusErr:k,starting:u,stopping:d,showConsentExpired:!!ie,copyLabels:q,startDisabled:!L,startDisabledReason:L?void 0:n.brokerSecretRequiredBeforeStart,onStart:B,onStop:()=>void ee()}),(0,$.jsx)(De,{pairQr:T,gatewayToken:r??``}),J.subdomain||J.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:y||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>s({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,n.release]})}):null,J.subdomain||J.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Se,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:o(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:m||!M&&!D?.canAutoStart,onChange:H}),n.autoStart]}),!D?.canAutoStart&&!M?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),se]})}async function lt(){let e=await m(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ut(e=`serve`){let t=await m(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function dt(){let e=await m(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var ft=`https://tailscale.com/download`;function pt(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:ft,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function mt({embedded:e=!1}){let t=p(e=>e.language),n=l(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!f(e=>e.token),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),{data:u,mutate:d,isLoading:m}=v(i?`exposure-status`:null,lt,{refreshInterval:3e4}),h=u?.tailscale.hostname,g=u?.tailscale.active===!0,_=u?.tailscale.cliAvailable!==!1,y=h?`https://${h}/`:null,b=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await ut(`serve`),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]),x=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await dt(),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]);if(!i)return null;let S=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(pt,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&u?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(pt,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,m&&!u?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(B,{className:`h-20 rounded-lg`}),(0,$.jsx)(B,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:g?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(he,{text:y,labels:r})}):null,s?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:s}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:g?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void x(),children:[a?(0,$.jsx)(me,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(X,{type:`button`,disabled:a||!_,onClick:()=>void b(),children:[a?(0,$.jsx)(me,{className:`mr-1 size-4 animate-spin`}):(0,$.jsx)(ie,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)($e,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?S:(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:oe,title:n.title,subtitle:n.subtitle}),S]})}function ht(){let e=(0,Z.c)(26),t=p(_t),n=f(gt),r;e[0]===t?r=e[1]:(r=l(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={preferLan:!0},e[2]=o):o=e[2];let s=ot(n??``,o),c;e[3]!==i.subtitle||e[4]!==i.title?(c=(0,$.jsx)(be,{icon:y,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=c):c=e[5];let u;e[6]===i.body?u=e[7]:(u=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=u);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let m;e[9]===i.link?m=e[10]:(m=(0,$.jsxs)(a,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,d]}),e[9]=i.link,e[10]=m);let h;e[11]!==u||e[12]!==m?(h=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,m]}),e[11]=u,e[12]=m,e[13]=h):h=e[13];let g;e[14]!==c||e[15]!==h?(g=(0,$.jsxs)(Se,{children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16];let _=n??``,v;e[17]===s?v=e[18]:(v=()=>void s.refreshQr(),e[17]=s,e[18]=v);let b;e[19]!==s||e[20]!==_||e[21]!==v?(b=(0,$.jsx)(De,{pairQr:s,gatewayToken:_,lanOnly:!0,onRefreshQr:v}),e[19]=s,e[20]=_,e[21]=v,e[22]=b):b=e[22];let x;return e[23]!==b||e[24]!==g?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g,b]}),e[23]=b,e[24]=g,e[25]=x):x=e[25],x}function gt(e){return e.token}function _t(e){return e.language}function vt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=p(yt),a;t[0]===i?a=t[1]:(a=l(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await c(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=m):m=t[3];let h,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>void f(),g=(0,$.jsx)(M,{className:`mr-1 size-4`}),t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=s?o.copied:o.copy,v;t[6]===_?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:h,children:[g,_]})}),t[6]=_,t[7]=v);let y;t[8]!==r||t[9]!==o.hint?(y=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=y):y=t[10];let b;t[11]!==v||t[12]!==y?(b=(0,$.jsxs)($.Fragment,{children:[m,v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13];let x=b;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(be,{icon:P,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===x?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:x}),t[17]=x,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Se,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let S;t[22]!==o.subtitle||t[23]!==o.title?(S=(0,$.jsx)(be,{icon:P,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=S):S=t[24];let C;t[25]===x?C=t[26]:(C=(0,$.jsx)(`div`,{className:`mt-4`,children:x}),t[25]=x,t[26]=C);let w;return t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(Se,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function yt(e){return e.language}function bt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(vt,{embedded:!0}),e[0]=t):t=e[0],t}function xt(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function St(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,xt(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ct(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=p(Et),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,s=!!f(Tt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(s?`exposure-status`:null,lt,c),d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:15e3},t[3]=d):d=t[3];let{data:m}=v(s?`tunnel-status`:null,Y,d),h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={refreshInterval:6e4},t[4]=h):h=t[4];let{data:g}=v(s?`tunnel-pair-context`:null,U,h);if(!s)return null;let _=u?.tailscale.active===!0,b=m?.state,x=m?.enabled&&b===`connected`,S=m?.enabled&&(b===`connecting`||b===`reconnecting`||!!m?.startProgress||!!m?.frpcDownload),C=(g?.candidates??[]).some(wt),T=_?`active`:`off`,E=_?a.statusActive:a.statusOff,D;t[5]!==a.tailscaleCardTitle||t[6]!==T||t[7]!==E?(D={tab:`tailscale`,icon:oe,title:a.tailscaleCardTitle,kind:T,statusLabel:E},t[5]=a.tailscaleCardTitle,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O=x?`active`:S?`connecting`:`off`,A=x?a.statusActive:S?a.statusConnecting:a.statusOff,j;t[9]!==a.publicCardTitle||t[10]!==O||t[11]!==A?(j={tab:`public`,icon:k,title:a.publicCardTitle,kind:O,statusLabel:A},t[9]=a.publicCardTitle,t[10]=O,t[11]=A,t[12]=j):j=t[12];let M=C?`active`:`off`,N=C?a.statusActive:a.statusOff,F;t[13]!==a.reverseProxyCardTitle||t[14]!==M||t[15]!==N?(F={tab:`reverse-proxy`,icon:w,title:a.reverseProxyCardTitle,kind:M,statusLabel:N},t[13]=a.reverseProxyCardTitle,t[14]=M,t[15]=N,t[16]=F):F=t[16];let I;t[17]!==a.sshCardStatus||t[18]!==a.sshCardTitle?(I={tab:`ssh`,icon:P,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[17]=a.sshCardStatus,t[18]=a.sshCardTitle,t[19]=I):I=t[19];let L;t[20]!==a.lanCardStatus||t[21]!==a.lanCardTitle?(L={tab:`lan`,icon:y,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[20]=a.lanCardStatus,t[21]=a.lanCardTitle,t[22]=L):L=t[22];let R;t[23]!==j||t[24]!==F||t[25]!==I||t[26]!==L||t[27]!==D?(R=[D,j,F,I,L],t[23]=j,t[24]=F,t[25]=I,t[26]=L,t[27]=D,t[28]=R):R=t[28];let z=R,B;return t[29]!==z||t[30]!==n?(B=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:z.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:o(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(St,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=z,t[30]=n,t[31]=B):B=t[31],B}function wt(e){return e.kind===`reverse-proxy`}function Tt(e){return e.token}function Et(e){return e.language}function Dt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===a?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==l?(p=i&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=i,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(F,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Ot(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=p(jt),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!f(At),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(s?`exposure-status`:null,lt,c),d;t[3]===u?.conflicts?d=t[4]:(d=u?.conflicts??[],t[3]=u?.conflicts,t[4]=d);let m=d;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let h;t[7]===n?h=t[8]:(h=(0,$.jsx)(Ct,{onOpenTab:n}),t[7]=n,t[8]=h);let g;t[9]!==m||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(g=m.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:m.map(kt)})]}):null,t[9]=m,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=g):g=t[12];let _;t[13]===o.pickMethod?_=t[14]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=_);let b;t[15]===n?b=t[16]:(b=()=>n(`tailscale`),t[15]=n,t[16]=b);let x;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==b?(x=(0,$.jsx)(Dt,{icon:oe,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:b}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=b,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=()=>n(`public`),t[23]=n,t[24]=S);let C;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==S?(C=(0,$.jsx)(Dt,{icon:k,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:S}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=S,t[29]=C):C=t[29];let T;t[30]===n?T=t[31]:(T=()=>n(`reverse-proxy`),t[30]=n,t[31]=T);let E;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==T?(E=(0,$.jsx)(Dt,{icon:w,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:T}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=T,t[36]=E):E=t[36];let D;t[37]===n?D=t[38]:(D=()=>n(`ssh`),t[37]=n,t[38]=D);let O;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==D?(O=(0,$.jsx)(Dt,{icon:P,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:D}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=D,t[43]=O):O=t[43];let A;t[44]===n?A=t[45]:(A=()=>n(`lan`),t[44]=n,t[45]=A);let j;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==A?(j=(0,$.jsx)(Dt,{icon:y,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:A}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=A,t[50]=j):j=t[50];let M;t[51]!==C||t[52]!==E||t[53]!==O||t[54]!==j||t[55]!==x?(M=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[x,C,E,O,j]}),t[51]=C,t[52]=E,t[53]=O,t[54]=j,t[55]=x,t[56]=M):M=t[56];let N;t[57]!==M||t[58]!==_?(N=(0,$.jsxs)(`div`,{children:[_,M]}),t[57]=M,t[58]=_,t[59]=N):N=t[59];let F;t[60]===o.oneAtATimeHint?F=t[61]:(F=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=F);let I;t[62]===a.advanced.proxyTitle?I=t[63]:(I=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=I);let L;t[64]===a.advanced.proxyBody?L=t[65]:(L=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=L);let R;t[66]!==r||t[67]!==a.advanced.proxyDocs?(R=(0,$.jsx)($e,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=R):R=t[68];let z;t[69]!==I||t[70]!==L||t[71]!==R?(z=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[I,L,R]}),t[69]=I,t[70]=L,t[71]=R,t[72]=z):z=t[72];let B;t[73]!==o.docsLink||t[74]!==r?(B=(0,$.jsx)($e,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=B):B=t[75];let V;return t[76]!==N||t[77]!==F||t[78]!==z||t[79]!==B||t[80]!==h||t[81]!==g?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,N,F,z,B]}),t[76]=N,t[77]=F,t[78]=z,t[79]=B,t[80]=h,t[81]=g,t[82]=V):V=t[82],V}function kt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function At(e){return e.token}function jt(e){return e.language}async function Mt(e){let t=await m(h(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Nt(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Pt(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Ft(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||Pt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function It(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,se,`dark:border-edge`)}function Lt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Rt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function zt(){let e=p(e=>e.language),t=l(e).remoteAccess.reverseProxy,n=!!f(e=>e.token),r=Ft(),{mutate:i}=_(),{data:a,mutate:s}=v(n?`tunnel-pair-context`:null,U,{refreshInterval:6e4}),c=Lt(a),[u,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({busy:!1,result:null}),[y,b]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{u||(c?m(c):r&&m(r))},[c,r,u]);let x=(0,Q.useMemo)(()=>u.trim()||(c??r??``),[c,r,u]),S=!c&&!!r&&x===r,C=Rt(a),{data:w,mutate:T}=v(n&&x?[`reverse-proxy-pair`,x]:null,()=>de(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),E=(0,Q.useMemo)(()=>!x||!w?.pairingSecret?``:d({baseUrl:x,pairingSecret:w.pairingSecret,lanUrl:C}),[x,C,w?.pairingSecret]),D=j(()=>nt(E),[E],{enabled:!!E,initial:null,errorData:null}),O=(0,Q.useCallback)(async()=>{let e=u.trim()||x;if(e){g({busy:!0,result:null});try{g({busy:!1,result:await Mt(e)})}catch(e){g({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[u,x]),k=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){b({busy:!0,error:null});try{await Nt(e),await s(),await i(`tunnel-pair-context`),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[x,i,s]),A=(0,Q.useCallback)(async()=>{b({busy:!0,error:null});try{await Nt(null),await s(),await i(`tunnel-pair-context`),m(``),g({busy:!1,result:null}),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,s]),M=(0,Q.useCallback)(async()=>{await T()},[T]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:oe,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:o(It(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:u,onChange:e=>{m(e.target.value),g({busy:!1,result:null})}}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void O(),disabled:h.busy||!u.trim(),children:[h.busy?(0,$.jsx)(me,{className:`size-3.5 animate-spin`}):null,h.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),S&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,h.result?(0,$.jsx)(Bt,{result:h.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[x&&c!==x?(0,$.jsxs)(X,{type:`button`,onClick:()=>void k(),disabled:y.busy,children:[y.busy?(0,$.jsx)(me,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,c?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>void A(),disabled:y.busy,children:t.clear}):null]}),y.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:y.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(Se,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),E?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void M(),children:[(0,$.jsx)(ee,{className:`size-4`}),t.refreshQr]}):null]}),x?w?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,x,C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,C]}):null]}),D.data?(0,$.jsx)(`img`,{src:D.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):D.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(he,{text:E,labels:{copy:t.copyLink,copied:t.copied,copyFailed:l(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Bt(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Vt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Ht(e){return e&&Vt.includes(e)?e:`guide`}function Ut(e,t){return e.tabs[t]}function Wt(e,t){return e.tabIntro[t]}function Gt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Kt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Ot,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(mt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ct,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bt,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ht,{}),t[6]=e):e=t[6],e}}}function qt(){let e=(0,Z.c)(2),t=p(Yt),n=l(t).remoteAccess,r=!!f(Jt),[a,o]=i(),s=Ht(a.get(`tab`)),c;e[0]===o?c=e[1]:(c=e=>{o(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=o,e[1]=c);let u=c,d=Wt(n,s),m=Vt.map(e=>({id:e,label:Ut(n,e)}));return(0,$.jsxs)(_e,{children:[(0,$.jsx)(ge,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)($e,{language:t,label:n.docsLink,section:Gt(s),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(we,{items:m,activeTab:s,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(ve,{id:s,activeTab:s,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Ut(n,s),hint:s===`public`?void 0:d,children:(0,$.jsx)(Kt,{tab:s,onOpenTab:u})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Jt(e){return e.token}function Yt(e){return e.language}export{qt as RemoteAccessHub};
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-uQ0fehio.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-BuT0SR1R.js";import{a as u,i as d,l as f,n as p,o as m,r as h,s as g}from"./locale-store-C_M71MK9.js";import{a as _,i as v}from"./vendor-swr-BIWyz7Rc.js";import{$s as y,As as b,Fo as x,Gn as S,Ho as C,Js as w,Ks as T,Mo as E,No as D,Nt as O,Oc as k,Ol as A,Oo as j,Pl as M,Po as N,Ps as P,Ql as F,Ul as I,Xo as L,Yo as R,_i as z,ao as B,as as V,cc as ee,ci as te,di as H,el as ne,fi as U,gi as re,hi as W,io as G,jo as K,ko as q,li as J,mi as Y,ms as X,pc as ie,pi as ae,pl as oe,ps as se,ro as ce,rr as le,si as ue,ui as de,vi as fe,yi as pe,zc as me,zi as he}from"./index-BuqGh2SW.js";import{n as ge,r as _e,t as ve}from"./settings-page-layout-DG-XMIPu.js";import{t as ye}from"./settings-collapsible-section-LaQqGGej.js";import{n as be,r as xe,t as Se}from"./settings-form-section-DruI__qO.js";import{t as Ce}from"./browser-BLJWD7WI.js";import{t as we}from"./page-tabs-kFOswGlG.js";var Z=n(),Q=e(t(),1);function Te(e,t){let{mutate:n}=_(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),ce()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await H();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await ue();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await te(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await J():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}var $=r();function Ee(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,se,`dark:border-edge`)}function De(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:s,onRefreshQr:c}=e,u=i===void 0?!1:i,d=s===void 0?!1:s,f=p(Ae),m;t[0]===f?m=t[1]:(m=l(f),t[0]=f,t[1]=m);let h=m,g=h.tunnelSettings,_=d?h.remoteAccess.lan:null,v;t[2]!==h.clipboard.copyFailed||t[3]!==g.pairCopied||t[4]!==g.pairCopyLink?(v={copy:g.pairCopyLink,copied:g.pairCopied,copyFailed:h.clipboard.copyFailed},t[2]=h.clipboard.copyFailed,t[3]=g.pairCopied,t[4]=g.pairCopyLink,t[5]=v):v=t[5];let y=v,{tunnelActive:b,tunnelStatus:x,tunnelQr:S,pairContext:C,pairBaseUrl:w,setPairBaseUrl:E,applySuggestedPairUrl:D,applyCandidateUrl:O,resetPairBaseFromContext:k,baseOk:A,localhostWarn:j,pairingBlocked:M,deepLink:N,qrPayload:P,qrDataUrl:F,qrGenFailed:I,encoding:L}=n,R;t[6]===k?R=t[7]:(R=e=>{k(e.recommended.url)},t[6]=k,t[7]=R);let z=Te(r,R),B,V,te,H,ne;if(t[8]!==O||t[9]!==D||t[10]!==A||t[11]!==z||t[12]!==r||t[13]!==_||t[14]!==d||t[15]!==j||t[16]!==c||t[17]!==w||t[18]!==C?.candidates||t[19]!==C?.recommended||t[20]!==M||t[21]!==E||t[22]!==u||t[23]!==g.pairBaseUrlHint||t[24]!==g.pairBaseUrlLabel||t[25]!==g.pairBaseUrlPlaceholder||t[26]!==g.pairBlockedLoopbackBody||t[27]!==g.pairBlockedNextSteps||t[28]!==g.pairBlockedTitle||t[29]!==g.pairCandidatesTitle||t[30]!==g.pairEnableLanButton||t[31]!==g.pairEnableLanEnabling||t[32]!==g.pairEnableLanSecurityAuditLink||t[33]!==g.pairInvalidBaseUrl||t[34]!==g.pairLocalhostWarning||t[35]!==g.pairSelectCandidateHint||t[36]!==g.pairSelectCandidateTitle||t[37]!==g.pairSubtitle||t[38]!==g.pairSuggestedLanLabel||t[39]!==g.pairTitle||t[40]!==g.pairTunnelActive||t[41]!==g.pairTunnelLanUrl||t[42]!==g.pairTunnelPublicUrl||t[43]!==g.pairUseSuggestedUrl||t[44]!==g.pairWaitingForTunnel||t[45]!==g.refreshQr||t[46]!==b||t[47]!==S||t[48]!==x?.publicUrl){ne=Symbol.for(`react.early_return_sentinel`);bb0:{let e=C?.candidates.filter(ke)??[],n=d?(e.find(Oe)?.url??e[0]?.url??``).trim():C?.recommended.url?.trim()??``,i=(d||!b)&&e.length>1,s=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:o(`text-xs font-medium`,r),children:i?g.pairSelectCandidateTitle:g.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:o(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,w.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>O(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:o(`mt-1 text-[11px] leading-relaxed`,r),children:g.pairSelectCandidateHint}):null]})};if(B=u&&!d,B&&!b){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(T,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===g.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,g.pairTitle]}),t[55]=g.pairTitle,t[56]=n);let r;t[57]===g.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:g.pairWaitingForTunnel}),t[57]=g.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Se,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],ne=i;break bb0}let l=_?.pairTitle??g.pairTitle,f=d?_?.pairSubtitle??g.pairSubtitle:b?g.pairTunnelActive:g.pairSubtitle,p=!!(c&&(d||u&&b)),m=B?`mb-2`:`mb-3`,h;t[62]===m?h=t[63]:(h=o(`flex flex-wrap items-start justify-between gap-2`,m),t[62]=m,t[63]=h);let v;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(T,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=v):v=t[64];let y;t[65]===l?y=t[66]:(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[v,l]}),t[65]=l,t[66]=y);let k;t[67]!==B||t[68]!==f||t[69]!==g.pairSubtitle?(k=B?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:g.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:f}),t[67]=B,t[68]=f,t[69]=g.pairSubtitle,t[70]=k):k=t[70];let N;t[71]!==y||t[72]!==k?(N=(0,$.jsxs)(`div`,{children:[y,k]}),t[71]=y,t[72]=k,t[73]=N):N=t[73];let P;t[74]!==c||t[75]!==p||t[76]!==g.refreshQr?(P=p?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void c(),children:[(0,$.jsx)(ee,{className:`size-4`}),g.refreshQr]}):null,t[74]=c,t[75]=p,t[76]=g.refreshQr,t[77]=P):P=t[77],t[78]!==h||t[79]!==N||t[80]!==P?(V=(0,$.jsxs)(`div`,{className:h,children:[N,P]}),t[78]=h,t[79]=N,t[80]=P,t[81]=V):V=t[81],te=M?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:g.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:g.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:g.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:D,children:g.pairUseSuggestedUrl})]}):null,e.length>0?s(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(X,{type:`button`,className:`w-full sm:w-auto`,disabled:z.busy||!r,onClick:()=>z.setConfirmOpen(!0),children:[z.busy?(0,$.jsx)(me,{className:`size-3.5 animate-spin`}):null,z.busy?g.pairEnableLanEnabling:g.pairEnableLanButton]})}),z.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:z.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:d?_?.pairBlockedNextSteps??g.pairBlockedNextSteps:g.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(a,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:g.pairEnableLanSecurityAuditLink}),d&&_?.pairPublicTabLink?(0,$.jsx)(a,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:_.pairPublicTabLink}):null]})]}):null,H=b&&!d?B?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:x?.publicUrl})]}),S?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:g.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:S.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:g.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:o(Ee(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||g.pairBaseUrlPlaceholder,value:w,onChange:e=>E(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:g.pairBaseUrlHint}),!A&&w.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:g.pairInvalidBaseUrl}):null,j?(0,$.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:g.pairLocalhostWarning}):null,i?s(`neutral`):null]})}t[8]=O,t[9]=D,t[10]=A,t[11]=z,t[12]=r,t[13]=_,t[14]=d,t[15]=j,t[16]=c,t[17]=w,t[18]=C?.candidates,t[19]=C?.recommended,t[20]=M,t[21]=E,t[22]=u,t[23]=g.pairBaseUrlHint,t[24]=g.pairBaseUrlLabel,t[25]=g.pairBaseUrlPlaceholder,t[26]=g.pairBlockedLoopbackBody,t[27]=g.pairBlockedNextSteps,t[28]=g.pairBlockedTitle,t[29]=g.pairCandidatesTitle,t[30]=g.pairEnableLanButton,t[31]=g.pairEnableLanEnabling,t[32]=g.pairEnableLanSecurityAuditLink,t[33]=g.pairInvalidBaseUrl,t[34]=g.pairLocalhostWarning,t[35]=g.pairSelectCandidateHint,t[36]=g.pairSelectCandidateTitle,t[37]=g.pairSubtitle,t[38]=g.pairSuggestedLanLabel,t[39]=g.pairTitle,t[40]=g.pairTunnelActive,t[41]=g.pairTunnelLanUrl,t[42]=g.pairTunnelPublicUrl,t[43]=g.pairUseSuggestedUrl,t[44]=g.pairWaitingForTunnel,t[45]=g.refreshQr,t[46]=b,t[47]=S,t[48]=x?.publicUrl,t[49]=B,t[50]=V,t[51]=te,t[52]=H,t[53]=ne}else B=t[49],V=t[50],te=t[51],H=t[52],ne=t[53];if(ne!==Symbol.for(`react.early_return_sentinel`))return ne;let U;t[82]===g.pairSecurityNote?U=t[83]:(U=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:g.pairSecurityNote}),t[82]=g.pairSecurityNote,t[83]=U);let re;t[84]!==y||t[85]!==N||t[86]!==L||t[87]!==M||t[88]!==F||t[89]!==I||t[90]!==g.pairEncoding||t[91]!==g.pairImageError||t[92]!==g.pairQrDisabled?(re=N?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[F&&!I?(0,$.jsx)(`img`,{src:F,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,L?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.pairEncoding}):null,I?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:g.pairImageError}):null,(0,$.jsx)(he,{text:N,labels:y})]}):M?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.pairQrDisabled}):null,t[84]=y,t[85]=N,t[86]=L,t[87]=M,t[88]=F,t[89]=I,t[90]=g.pairEncoding,t[91]=g.pairImageError,t[92]=g.pairQrDisabled,t[93]=re):re=t[93];let W;t[94]!==B||t[95]!==P||t[96]!==g.deeplinkTitle?(W=P&&!B?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:g.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:P})]}):null,t[94]=B,t[95]=P,t[96]=g.deeplinkTitle,t[97]=W):W=t[97];let G;t[98]!==B||t[99]!==g.pairMobileProbeHint||t[100]!==g.pairSchemeHint?(G=B?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:g.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:g.pairMobileProbeHint})]}),t[98]=B,t[99]=g.pairMobileProbeHint,t[100]=g.pairSchemeHint,t[101]=G):G=t[101];let K,q;t[102]===z?(K=t[103],q=t[104]):(K=()=>void z.runEnableLanPairing(),q=()=>{z.busy||z.setConfirmOpen(!1)},t[102]=z,t[103]=K,t[104]=q);let J;t[105]!==z.confirmOpen||t[106]!==g.consentCancel||t[107]!==g.pairEnableLanButton||t[108]!==g.pairEnableLanConfirmBody||t[109]!==g.pairEnableLanConfirmTitle||t[110]!==K||t[111]!==q?(J=(0,$.jsx)(le,{open:z.confirmOpen,title:g.pairEnableLanConfirmTitle,description:g.pairEnableLanConfirmBody,confirmLabel:g.pairEnableLanButton,cancelLabel:g.consentCancel,onConfirm:K,onCancel:q}),t[105]=z.confirmOpen,t[106]=g.consentCancel,t[107]=g.pairEnableLanButton,t[108]=g.pairEnableLanConfirmBody,t[109]=g.pairEnableLanConfirmTitle,t[110]=K,t[111]=q,t[112]=J):J=t[112];let Y;return t[113]!==U||t[114]!==re||t[115]!==W||t[116]!==G||t[117]!==J||t[118]!==V||t[119]!==te||t[120]!==H?(Y=(0,$.jsx)(Se,{children:(0,$.jsxs)($.Fragment,{children:[V,te,H,U,re,W,G,J]})}),t[113]=U,t[114]=re,t[115]=W,t[116]=G,t[117]=J,t[118]=V,t[119]=te,t[120]=H,t[121]=Y):Y=t[121],Y}function Oe(e){return e.reachable}function ke(e){return e.kind===`lan`}function Ae(e){return e.language}function je(e){let t=(0,Z.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:s,confirmLabel:c,cancelLabel:l,onConfirm:u,onCancel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===d?m=t[1]:(m=e=>{e||(p(!1),d())},t[0]=d,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(D,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,L)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=o(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,R),t[3]=g):g=t[3];let _;t[4]===r?_=t[5]:(_=(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=_);let v;t[6]===i?v=t[7]:(v=(0,$.jsx)(E,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=v);let y;t[8]===a?y=t[9]:(y=a.map(Me),t[8]=a,t[9]=y);let b;t[10]===y?b=t[11]:(b=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>p(e.target.checked),t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:S}),t[13]=f,t[14]=C);let w;t[15]===s?w=t[16]:(w=(0,$.jsx)(`span`,{children:s}),t[15]=s,t[16]=w);let T;t[17]!==w||t[18]!==C?(T=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[C,w]}),t[17]=w,t[18]=C,t[19]=T):T=t[19];let O;t[20]!==l||t[21]!==d?(O=(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:d,children:l}),t[20]=l,t[21]=d,t[22]=O):O=t[22];let k=!f,A;t[23]!==c||t[24]!==u||t[25]!==k?(A=(0,$.jsx)(X,{type:`button`,disabled:k,onClick:u,children:c}),t[23]=c,t[24]=u,t[25]=k,t[26]=A):A=t[26];let j;t[27]!==O||t[28]!==A?(j=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[O,A]}),t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]!==T||t[31]!==j||t[32]!==_||t[33]!==v||t[34]!==b?(M=(0,$.jsxs)(N,{children:[h,(0,$.jsxs)(K,{className:g,onOpenAutoFocus:Ne,children:[_,v,b,T,j]})]}),t[30]=T,t[31]=j,t[32]=_,t[33]=v,t[34]=b,t[35]=M):M=t[35];let P;return t[36]!==n||t[37]!==m||t[38]!==M?(P=(0,$.jsx)(q,{open:n,onOpenChange:m,children:M}),t[36]=n,t[37]=m,t[38]=M,t[39]=P):P=t[39],P}function Me(e){return(0,$.jsx)(`li`,{children:e},e)}function Ne(e){return e.preventDefault()}function Pe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Fe=[`preparing_frpc`,`registering`,`starting_frpc`];function Ie(e){return e?e===`reconnecting_frpc`?Fe.indexOf(`starting_frpc`):Fe.indexOf(e):-1}function Le(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Fe.indexOf(e),i=Ie(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Re(e,t,n){let r=n.startProgress;return Le(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function ze(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Be(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ve(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,i]=(0,Q.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(He),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let c=n.startProgress?.startedAt,l;if(t[3]!==n.state||t[4]!==c?(l=[n.state,c],t[3]=n.state,t[4]=c,t[5]=l):l=t[5],(0,Q.useEffect)(a,l),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let u,d,f,p,m;if(t[6]!==n||t[7]!==r){let e=Be(n.startProgress?.startedAt);u=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,d=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(f=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=f):f=t[19];let c=Fe.map(e=>{let t=Le(e,n),i=Re(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(s,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(me,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(I,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:o(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:ze(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:o(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Pe(n.frpcDownload.bytesReceived),` /`,` `,Pe(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===c?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:c}),t[20]=c,t[21]=p),m=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[22]!==u||t[23]!==r.publicUrlPendingNotice?(h=u?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=u,t[23]=r.publicUrlPendingNotice,t[24]=h):h=t[24];let g;return t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:d,children:[f,p,m,h]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=h,t[30]=g):g=t[30],g}function He(e){return e+1}function Ue(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function We(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function Ge(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Ke(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function qe(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:s,stopping:c,showConsentExpired:l,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,x,S,C,w;t[0]!==r||t[1]!==s?(w=We(r),_=r.enabled||s,v=s||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=o(xe(),`space-y-4`),t[9]=C):C=t[9],S=`flex flex-wrap items-start justify-between gap-3`,x=`flex items-center gap-2`,y=o(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ge(w)),t[0]=r,t[1]=s,t[2]=_,t[3]=v,t[4]=y,t[5]=x,t[6]=S,t[7]=C,t[8]=w):(_=t[2],v=t[3],y=t[4],x=t[5],S=t[6],C=t[7],w=t[8]);let T=w===`connected`&&`bg-emerald-500`,E=w===`progress`&&`bg-amber-500 animate-pulse`,D=w===`error`&&`bg-red-500`,O=w===`off`&&`bg-fg-subtle`,k;t[10]!==T||t[11]!==E||t[12]!==D||t[13]!==O?(k=o(`size-1.5 rounded-full`,T,E,D,O),t[10]=T,t[11]=E,t[12]=D,t[13]=O,t[14]=k):k=t[14];let A;t[15]===k?A=t[16]:(A=(0,$.jsx)(`span`,{className:k,"aria-hidden":!0}),t[15]=k,t[16]=A);let j;t[17]!==i||t[18]!==r||t[19]!==n?(j=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):Ue(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=j):j=t[20];let M;t[21]!==A||t[22]!==j||t[23]!==y?(M=(0,$.jsxs)(`span`,{className:y,children:[A,j]}),t[21]=A,t[22]=j,t[23]=y,t[24]=M):M=t[24];let N;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(N=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Ke(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=N):N=t[28];let P;t[29]!==M||t[30]!==N||t[31]!==x?(P=(0,$.jsxs)(`div`,{className:x,children:[M,N]}),t[29]=M,t[30]=N,t[31]=x,t[32]=P):P=t[32];let F;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(oe,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=F):F=t[33];let I;t[34]!==P||t[35]!==S?(I=(0,$.jsxs)(`div`,{className:S,children:[P,F]}),t[34]=P,t[35]=S,t[36]=I):I=t[36];let L;t[37]===a?L=t[38]:(L=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=L);let R;t[39]!==l||t[40]!==n.consentExpiredBanner?(R=l?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=l,t[40]=n.consentExpiredBanner,t[41]=R):R=t[41];let z;t[42]!==_||t[43]!==u||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==r||t[48]!==g||t[49]!==f||t[50]!==s||t[51]!==p||t[52]!==c||t[53]!==n?(z=_?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(he,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Ve,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:c,onClick:h,children:[c?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(X,{type:`button`,disabled:s,onClick:m,children:[s?(0,$.jsx)(me,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:p}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),g&&f?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:f}):null,(0,$.jsxs)(X,{type:`button`,disabled:s||g,onClick:m,className:`w-full sm:w-auto`,children:[s?(0,$.jsx)(me,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{className:`size-4`}),n.start]})]}),t[42]=_,t[43]=u,t[44]=m,t[45]=h,t[46]=v,t[47]=r,t[48]=g,t[49]=f,t[50]=s,t[51]=p,t[52]=c,t[53]=n,t[54]=z):z=t[54];let B;return t[55]!==I||t[56]!==L||t[57]!==R||t[58]!==z||t[59]!==C?(B=(0,$.jsxs)(`section`,{className:C,children:[I,L,R,z]}),t[55]=I,t[56]=L,t[57]=R,t[58]=z,t[59]=C,t[60]=B):B=t[60],B}var Je=`https://console.xopc.ai/keys/tunnel`,Ye={reconfiguring:!1};function Xe(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:i,brokerSecretConfiguredInConfig:a,brokerSecretMaskedValue:c,brokerSecretDraft:l,savingBrokerSecret:u,brokerSecretNotice:d,copyFailedLabel:f,onDraftChange:p,onSave:m,onClear:h,sectionRef:g}=e,_=(0,Q.useId)(),v=i&&!r,y=!v,[b,x]=(0,Q.useReducer)(O,Ye),{reconfiguring:C}=b,w;t[0]!==a||t[1]!==l||t[2]!==r||t[3]!==C?(w=a&&!r&&!C&&!l.trim(),t[0]=a,t[1]=l,t[2]=r,t[3]=C,t[4]=w):w=t[4];let T=w,E;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(E={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=E):E=t[9];let D=E,k;t[10]===l?k=t[11]:(k=l.trim().length>0&&!S(l.trim()),t[10]=l,t[11]=k);let j=k,M;t[12]===p?M=t[13]:(M=()=>{x({type:`patch`,patch:{reconfiguring:!1}}),p(``)},t[12]=p,t[13]=M);let N=M,P=v&&`ring-1 ring-amber-500/30`,F;t[14]===P?F=t[15]:(F=o(P),t[14]=P,t[15]=F);let I=y?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:v?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,L;t[16]===I?L=t[17]:(L=o(`flex size-9 shrink-0 items-center justify-center rounded-lg`,I),t[16]=I,t[17]=L);let R;t[18]===y?R=t[19]:(R=y?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=y,t[19]=R);let z;t[20]!==L||t[21]!==R?(z=(0,$.jsx)(`span`,{className:L,children:R}),t[20]=L,t[21]=R,t[22]=z):z=t[22];let B=y?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,ee;t[23]===B?ee=t[24]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:B}),t[23]=B,t[24]=ee);let te=y?n.brokerSecretReadyHint:n.brokerSecretHint,H;t[25]===te?H=t[26]:(H=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:te}),t[25]=te,t[26]=H);let U;t[27]!==v||t[28]!==n.brokerSecretMissingHint?(U=v?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=v,t[28]=n.brokerSecretMissingHint,t[29]=U):U=t[29];let re;t[30]!==ee||t[31]!==H||t[32]!==U?(re=(0,$.jsxs)(`div`,{children:[ee,H,U]}),t[30]=ee,t[31]=H,t[32]=U,t[33]=re):re=t[33];let W;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(A,{className:`size-3`,"aria-hidden":!0}),t[34]=W):W=t[34];let G;t[35]===n.brokerSecretConsoleLink?G=t[36]:(G=(0,$.jsxs)(`a`,{href:Je,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,W]}),t[35]=n.brokerSecretConsoleLink,t[36]=G);let K;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(K=r?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=K):K=t[39];let q;t[40]!==a||t[41]!==l||t[42]!==r||t[43]!==c||t[44]!==j||t[45]!==N||t[46]!==f||t[47]!==_||t[48]!==v||t[49]!==h||t[50]!==p||t[51]!==m||t[52]!==C||t[53]!==u||t[54]!==D||t[55]!==T||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(q=T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(V,{id:_,value:c,labels:D,reveal:Ze,loadFailedLabel:f||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>{x({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:_,children:n.brokerSecretTitle}),(0,$.jsx)(V,{id:_,value:l,onChange:p,placeholder:n.brokerSecretPlaceholder,labels:D,disabled:u}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(X,{type:`button`,disabled:u||!j,onClick:m,children:[u?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,v?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),a||r?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:h,children:n.brokerSecretClear}):null,C?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:u,onClick:N,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=a,t[41]=l,t[42]=r,t[43]=c,t[44]=j,t[45]=N,t[46]=f,t[47]=_,t[48]=v,t[49]=h,t[50]=p,t[51]=m,t[52]=C,t[53]=u,t[54]=D,t[55]=T,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=q):q=t[66];let J;t[67]===d?J=t[68]:(J=d?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:d}):null,t[67]=d,t[68]=J);let Y;t[69]!==re||t[70]!==G||t[71]!==K||t[72]!==q||t[73]!==J?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[re,G,K,q,J]}),t[69]=re,t[70]=G,t[71]=K,t[72]=q,t[73]=J,t[74]=Y):Y=t[74];let ie;t[75]!==z||t[76]!==Y?(ie=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,Y]}),t[75]=z,t[76]=Y,t[77]=ie):ie=t[77];let ae;t[78]!==ie||t[79]!==F?(ae=(0,$.jsx)(Se,{className:F,children:ie}),t[78]=ie,t[79]=F,t[80]=ae):ae=t[80];let oe;return t[81]!==g||t[82]!==ae?(oe=(0,$.jsx)(`div`,{ref:g,id:`tunnel-broker-secret-setup`,children:ae}),t[81]=g,t[82]=ae,t[83]=oe):oe=t[83],oe}function Ze(){return z().then(Qe)}function Qe(e){return e.registrationSecret??null}function $e(e){let t=(0,Z.c)(10),{language:n,label:r,section:i,className:a}=e,s;t[0]!==n||t[1]!==i?(s=C(n,i),t[0]=n,t[1]=i,t[2]=s):s=t[2];let c;t[3]===a?c=t[4]:(c=o(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=c);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(A,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==s||t[8]!==c?(u=(0,$.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:c,children:[r,l]}),t[6]=r,t[7]=s,t[8]=c,t[9]=u):u=t[9],u}var et=e(Ce(),1),tt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function nt(e){return et.toDataURL(e,tt)}function rt(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function it(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function at(e,t){return e?t?rt(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function ot(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=_(),a=(0,Q.useRef)(!1),{data:o}=v(r?`tunnel-status`:null,Y,{refreshInterval:6e4}),{data:s,mutate:c}=v(r?`tunnel-pair-context`:null,U,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let l=o?.state===`connected`&&!!o.publicUrl?.trim(),f=l&&!n,{data:p,mutate:m}=v(f&&r?`tunnel-qr`:null,ae,{refreshInterval:4*6e4}),{data:h,mutate:g}=v(!f&&r&&s?.pairingReady?`tunnel-pair`:null,de,{refreshInterval:4*6e4}),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==C.pairContext||n!==C.preferLan)){w({pairContext:s,preferLan:n});let e=at(s,n);y!==e&&b(e)}let T=(0,Q.useCallback)(e=>{a.current=!0,b(e)},[]),E=(0,Q.useCallback)(()=>{let e=at(s,n);e&&(a.current=!0,b(e))},[s,n]),D=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,b(t))},[]),O=(0,Q.useCallback)(e=>{a.current=!1,b(e?.trim()||at(s,n))},[s,n]),k=y.trim(),A=(0,Q.useMemo)(()=>{try{let e=new URL(k);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[k]),M=A&&u(k),N=!f&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),P=!f&&A&&!M&&!!h?.pairingSecret&&(s?.pairingReady===!0||!N),F=(0,Q.useMemo)(()=>{let e=rt(s);return n?e||(k&&!it(s,k)?k:``):k},[s,n,k]),I=(0,Q.useMemo)(()=>{if(!e)return``;if(x.trim())return x.trim();if(f&&p?.qrPayload?.trim())return p.qrPayload.trim();if(!P||!h?.pairingSecret)return``;let t=s?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=s?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?F:t?.url??k;return i?d({baseUrl:i,pairingSecret:h.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,F,h?.pairingSecret,P,x,n,k,f,p?.qrPayload,s?.candidates]),L=j(()=>nt(I),[I],{enabled:!!I,initial:null,errorData:null}),R=I?L.data:null,z=!!(I&&L.error!==null&&!L.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:p,pairContext:s,pairBaseUrl:y,setPairBaseUrl:T,applySuggestedPairUrl:E,applyCandidateUrl:D,baseOk:A,localhostWarn:M,pairingBlocked:N,deepLink:I,qrPayload:I,qrDataUrl:R,qrGenFailed:z,encoding:!!(I&&!R&&!z),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){S(e.trim()),m({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:p?.lanUrl??null},!1);return}S(``),await c(),f?await m():s?.pairingReady&&await g()},[g,c,m,s?.pairingReady,p?.lanUrl,o?.publicUrl,f]),resetPairBaseFromContext:O}}var st={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function ct({embedded:e=!1}){let t=p(e=>e.language),n=l(t).tunnelSettings,r=f(e=>e.token),i=!!r,[a,s]=(0,Q.useReducer)(O,st),{actionError:c,starting:u,stopping:d,savingAutoStart:m,consentOpen:h,autoStartConfirmOpen:g,releaseConfirmOpen:_,releasing:y,brokerSecretDraft:b,savingBrokerSecret:x,brokerSecretNotice:C}=a,w=(0,Q.useRef)(null),T=ot(r??``),{data:E}=G(i),{data:D,error:k,isLoading:A,mutate:j}=v(i?`tunnel-status`:null,Y,{refreshInterval:e=>u?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),M=(0,Q.useMemo)(()=>{let e=E?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return D?.config?.autoStart===!0},[E,D?.config?.autoStart]),N=(0,Q.useMemo)(()=>{let e=E?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[E]),P=S(N),F=D?.registrationSecret?.source===`env`,I=D?.registrationSecret?.source===`missing`,L=D?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{j()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[j]);let R=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),z=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{actionError:null}}),s({type:`patch`,patch:{starting:!0}});try{let e=await fe();await j(),ce(),await T.refreshQr(e.qrPayload)}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{starting:!1}})}},[j,T.refreshQr]),B=(0,Q.useCallback)(()=>{if(!L){s({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),w.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(D?.consentRequired){s({type:`patch`,patch:{consentOpen:!0}});return}z()},[L,D?.consentRequired,z,n.brokerSecretRequiredBeforeStart]),V=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{consentOpen:!1}}),s({type:`patch`,patch:{actionError:null}});try{await re(),await Promise.all([j(),z()])}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[j,z]),ee=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{actionError:null}}),s({type:`patch`,patch:{stopping:!0}});try{await pe(),await Promise.all([T.refreshQr(),j()]),ce()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{stopping:!1}})}},[j,T.refreshQr]),te=(0,Q.useCallback)(async e=>{s({type:`patch`,patch:{savingAutoStart:!0}}),s({type:`patch`,patch:{actionError:null}});try{await W({autoStart:e}),ce()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingAutoStart:!1}})}},[]),H=(0,Q.useCallback)(()=>{if(M){te(!1);return}if(D?.consentRequired){s({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!D?.canAutoStart){s({type:`patch`,patch:{actionError:n.autoStartHint}});return}s({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[te,D?.canAutoStart,D?.consentRequired,n,M]),ne=(0,Q.useCallback)(async()=>{let e=b.trim();if(e){s({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await W({registrationSecret:e}),s({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),ce(),await j(),s({type:`patch`,patch:{actionError:null}})}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[b,j,n.brokerSecretSaved]),U=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await W({registrationSecret:null}),s({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),ce(),await j()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{savingBrokerSecret:!1}})}},[j,n.brokerSecretCleared]),K=(0,Q.useCallback)(async()=>{s({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await pe({release:!0}),await Promise.all([T.refreshQr(),j()]),ce()}catch(e){s({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{releasing:!1}})}},[j,T.refreshQr]),q=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!i)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let J=D??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:M,brokerUrl:`https://frp.xopc.ai/api`}},ie=D?.consentRequired&&(J.enabled||M||D?.consent?.acceptedAt),ae=(0,$.jsx)(Xe,{t:n,brokerSecretFromEnv:F,brokerSecretMissing:I,brokerSecretConfiguredInConfig:P,brokerSecretMaskedValue:P?N:``,brokerSecretDraft:b,savingBrokerSecret:x,brokerSecretNotice:C,copyFailedLabel:l(t).clipboard.copyFailed,onDraftChange:e=>s({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void ne(),onClear:()=>void U(),sectionRef:w}),se=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(je,{open:h,title:n.consentTitle,intro:n.consentIntro,bullets:R,checkboxLabel:n.consentCheckbox,confirmLabel:ie?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void V(),onCancel:()=>s({type:`patch`,patch:{consentOpen:!1}})},h?`consent-open`:`consent-closed`),(0,$.jsx)(le,{open:g,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{s({type:`patch`,patch:{autoStartConfirmOpen:!1}}),te(!0)},onCancel:()=>s({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(le,{open:_,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void K(),onCancel:()=>s({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,ae,(0,$.jsx)(qe,{t:n,status:J,isLoading:A,statusErr:k,starting:u,stopping:d,showConsentExpired:!!ie,copyLabels:q,startDisabled:!L,startDisabledReason:L?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:B,onStop:()=>void ee()}),(0,$.jsx)(De,{pairQr:T,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void T.refreshQr()}),(0,$.jsxs)(ye,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:o(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:m||!M&&!D?.canAutoStart,onChange:H}),n.autoStart]}),!D?.canAutoStart&&!M?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,J.subdomain||J.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:y||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>s({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ye,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),se]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),c?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:c}):null,ae,(0,$.jsx)(qe,{t:n,status:J,isLoading:A,statusErr:k,starting:u,stopping:d,showConsentExpired:!!ie,copyLabels:q,startDisabled:!L,startDisabledReason:L?void 0:n.brokerSecretRequiredBeforeStart,onStart:B,onStop:()=>void ee()}),(0,$.jsx)(De,{pairQr:T,gatewayToken:r??``}),J.subdomain||J.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:y||d,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>s({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[y?(0,$.jsx)(me,{className:`size-4 animate-spin`}):null,n.release]})}):null,J.subdomain||J.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Se,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:o(`flex items-center gap-3 text-sm text-fg`,!M&&!D?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:M,disabled:m||!M&&!D?.canAutoStart,onChange:H}),n.autoStart]}),!D?.canAutoStart&&!M?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)($e,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),se]})}async function lt(){let e=await m(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ut(e=`serve`){let t=await m(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function dt(){let e=await m(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var ft=`https://tailscale.com/download`;function pt(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:ft,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function mt({embedded:e=!1}){let t=p(e=>e.language),n=l(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!f(e=>e.token),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),{data:u,mutate:d,isLoading:m}=v(i?`exposure-status`:null,lt,{refreshInterval:3e4}),h=u?.tailscale.hostname,g=u?.tailscale.active===!0,_=u?.tailscale.cliAvailable!==!1,y=h?`https://${h}/`:null,b=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await ut(`serve`),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]),x=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await dt(),await d()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]);if(!i)return null;let S=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(pt,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&u?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(pt,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,m&&!u?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(B,{className:`h-20 rounded-lg`}),(0,$.jsx)(B,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:g?n.statusActive:n.statusOff}),y?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(he,{text:y,labels:r})}):null,s?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:s}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:g?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void x(),children:[a?(0,$.jsx)(me,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(X,{type:`button`,disabled:a||!_,onClick:()=>void b(),children:[a?(0,$.jsx)(me,{className:`mr-1 size-4 animate-spin`}):(0,$.jsx)(ie,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)($e,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?S:(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:oe,title:n.title,subtitle:n.subtitle}),S]})}function ht(){let e=(0,Z.c)(26),t=p(_t),n=f(gt),r;e[0]===t?r=e[1]:(r=l(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={preferLan:!0},e[2]=o):o=e[2];let s=ot(n??``,o),c;e[3]!==i.subtitle||e[4]!==i.title?(c=(0,$.jsx)(be,{icon:y,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=c):c=e[5];let u;e[6]===i.body?u=e[7]:(u=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=u);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let m;e[9]===i.link?m=e[10]:(m=(0,$.jsxs)(a,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,d]}),e[9]=i.link,e[10]=m);let h;e[11]!==u||e[12]!==m?(h=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,m]}),e[11]=u,e[12]=m,e[13]=h):h=e[13];let g;e[14]!==c||e[15]!==h?(g=(0,$.jsxs)(Se,{children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16];let _=n??``,v;e[17]===s?v=e[18]:(v=()=>void s.refreshQr(),e[17]=s,e[18]=v);let b;e[19]!==s||e[20]!==_||e[21]!==v?(b=(0,$.jsx)(De,{pairQr:s,gatewayToken:_,lanOnly:!0,onRefreshQr:v}),e[19]=s,e[20]=_,e[21]=v,e[22]=b):b=e[22];let x;return e[23]!==b||e[24]!==g?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g,b]}),e[23]=b,e[24]=g,e[25]=x):x=e[25],x}function gt(e){return e.token}function _t(e){return e.language}function vt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=p(yt),a;t[0]===i?a=t[1]:(a=l(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,u]=(0,Q.useState)(!1),d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=async()=>{await c(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(u(!0),setTimeout(()=>u(!1),2e3))},t[2]=d):d=t[2];let f=d,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=m):m=t[3];let h,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>void f(),g=(0,$.jsx)(M,{className:`mr-1 size-4`}),t[4]=h,t[5]=g):(h=t[4],g=t[5]);let _=s?o.copied:o.copy,v;t[6]===_?v=t[7]:(v=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:h,children:[g,_]})}),t[6]=_,t[7]=v);let y;t[8]!==r||t[9]!==o.hint?(y=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=y):y=t[10];let b;t[11]!==v||t[12]!==y?(b=(0,$.jsxs)($.Fragment,{children:[m,v,y]}),t[11]=v,t[12]=y,t[13]=b):b=t[13];let x=b;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(be,{icon:P,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===x?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:x}),t[17]=x,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Se,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let S;t[22]!==o.subtitle||t[23]!==o.title?(S=(0,$.jsx)(be,{icon:P,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=S):S=t[24];let C;t[25]===x?C=t[26]:(C=(0,$.jsx)(`div`,{className:`mt-4`,children:x}),t[25]=x,t[26]=C);let w;return t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(Se,{children:[S,C]}),t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function yt(e){return e.language}function bt(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(vt,{embedded:!0}),e[0]=t):t=e[0],t}function xt(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function St(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,xt(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Ct(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=p(Et),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,s=!!f(Tt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(s?`exposure-status`:null,lt,c),d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d={refreshInterval:15e3},t[3]=d):d=t[3];let{data:m}=v(s?`tunnel-status`:null,Y,d),h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={refreshInterval:6e4},t[4]=h):h=t[4];let{data:g}=v(s?`tunnel-pair-context`:null,U,h);if(!s)return null;let _=u?.tailscale.active===!0,b=m?.state,x=m?.enabled&&b===`connected`,S=m?.enabled&&(b===`connecting`||b===`reconnecting`||!!m?.startProgress||!!m?.frpcDownload),C=(g?.candidates??[]).some(wt),T=_?`active`:`off`,E=_?a.statusActive:a.statusOff,D;t[5]!==a.tailscaleCardTitle||t[6]!==T||t[7]!==E?(D={tab:`tailscale`,icon:oe,title:a.tailscaleCardTitle,kind:T,statusLabel:E},t[5]=a.tailscaleCardTitle,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O=x?`active`:S?`connecting`:`off`,A=x?a.statusActive:S?a.statusConnecting:a.statusOff,j;t[9]!==a.publicCardTitle||t[10]!==O||t[11]!==A?(j={tab:`public`,icon:k,title:a.publicCardTitle,kind:O,statusLabel:A},t[9]=a.publicCardTitle,t[10]=O,t[11]=A,t[12]=j):j=t[12];let M=C?`active`:`off`,N=C?a.statusActive:a.statusOff,F;t[13]!==a.reverseProxyCardTitle||t[14]!==M||t[15]!==N?(F={tab:`reverse-proxy`,icon:w,title:a.reverseProxyCardTitle,kind:M,statusLabel:N},t[13]=a.reverseProxyCardTitle,t[14]=M,t[15]=N,t[16]=F):F=t[16];let I;t[17]!==a.sshCardStatus||t[18]!==a.sshCardTitle?(I={tab:`ssh`,icon:P,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[17]=a.sshCardStatus,t[18]=a.sshCardTitle,t[19]=I):I=t[19];let L;t[20]!==a.lanCardStatus||t[21]!==a.lanCardTitle?(L={tab:`lan`,icon:y,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[20]=a.lanCardStatus,t[21]=a.lanCardTitle,t[22]=L):L=t[22];let R;t[23]!==j||t[24]!==F||t[25]!==I||t[26]!==L||t[27]!==D?(R=[D,j,F,I,L],t[23]=j,t[24]=F,t[25]=I,t[26]=L,t[27]=D,t[28]=R):R=t[28];let z=R,B;return t[29]!==z||t[30]!==n?(B=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:z.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:o(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(St,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=z,t[30]=n,t[31]=B):B=t[31],B}function wt(e){return e.kind===`reverse-proxy`}function Tt(e){return e.token}function Et(e){return e.language}function Dt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:s,openLabel:c,recommendedLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===a?d=t[2]:(d=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==l?(p=i&&l?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:l}):null,t[5]=i,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(F,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let b;return t[22]!==s||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:u,children:[v,y]}),t[22]=s,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function Ot(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=p(jt),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!f(At),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=v(s?`exposure-status`:null,lt,c),d;t[3]===u?.conflicts?d=t[4]:(d=u?.conflicts??[],t[3]=u?.conflicts,t[4]=d);let m=d;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let h;t[7]===n?h=t[8]:(h=(0,$.jsx)(Ct,{onOpenTab:n}),t[7]=n,t[8]=h);let g;t[9]!==m||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(g=m.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:m.map(kt)})]}):null,t[9]=m,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=g):g=t[12];let _;t[13]===o.pickMethod?_=t[14]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=_);let b;t[15]===n?b=t[16]:(b=()=>n(`tailscale`),t[15]=n,t[16]=b);let x;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==b?(x=(0,$.jsx)(Dt,{icon:oe,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:b}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=b,t[22]=x):x=t[22];let S;t[23]===n?S=t[24]:(S=()=>n(`public`),t[23]=n,t[24]=S);let C;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==S?(C=(0,$.jsx)(Dt,{icon:k,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:S}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=S,t[29]=C):C=t[29];let T;t[30]===n?T=t[31]:(T=()=>n(`reverse-proxy`),t[30]=n,t[31]=T);let E;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==T?(E=(0,$.jsx)(Dt,{icon:w,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:T}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=T,t[36]=E):E=t[36];let D;t[37]===n?D=t[38]:(D=()=>n(`ssh`),t[37]=n,t[38]=D);let O;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==D?(O=(0,$.jsx)(Dt,{icon:P,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:D}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=D,t[43]=O):O=t[43];let A;t[44]===n?A=t[45]:(A=()=>n(`lan`),t[44]=n,t[45]=A);let j;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==A?(j=(0,$.jsx)(Dt,{icon:y,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:A}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=A,t[50]=j):j=t[50];let M;t[51]!==C||t[52]!==E||t[53]!==O||t[54]!==j||t[55]!==x?(M=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[x,C,E,O,j]}),t[51]=C,t[52]=E,t[53]=O,t[54]=j,t[55]=x,t[56]=M):M=t[56];let N;t[57]!==M||t[58]!==_?(N=(0,$.jsxs)(`div`,{children:[_,M]}),t[57]=M,t[58]=_,t[59]=N):N=t[59];let F;t[60]===o.oneAtATimeHint?F=t[61]:(F=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=F);let I;t[62]===a.advanced.proxyTitle?I=t[63]:(I=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=I);let L;t[64]===a.advanced.proxyBody?L=t[65]:(L=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=L);let R;t[66]!==r||t[67]!==a.advanced.proxyDocs?(R=(0,$.jsx)($e,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=R):R=t[68];let z;t[69]!==I||t[70]!==L||t[71]!==R?(z=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[I,L,R]}),t[69]=I,t[70]=L,t[71]=R,t[72]=z):z=t[72];let B;t[73]!==o.docsLink||t[74]!==r?(B=(0,$.jsx)($e,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=B):B=t[75];let V;return t[76]!==N||t[77]!==F||t[78]!==z||t[79]!==B||t[80]!==h||t[81]!==g?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,N,F,z,B]}),t[76]=N,t[77]=F,t[78]=z,t[79]=B,t[80]=h,t[81]=g,t[82]=V):V=t[82],V}function kt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function At(e){return e.token}function jt(e){return e.language}async function Mt(e){let t=await m(h(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Nt(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function Pt(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Ft(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||Pt(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function It(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,se,`dark:border-edge`)}function Lt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Rt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function zt(){let e=p(e=>e.language),t=l(e).remoteAccess.reverseProxy,n=!!f(e=>e.token),r=Ft(),{mutate:i}=_(),{data:a,mutate:s}=v(n?`tunnel-pair-context`:null,U,{refreshInterval:6e4}),c=Lt(a),[u,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({busy:!1,result:null}),[y,b]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{u||(c?m(c):r&&m(r))},[c,r,u]);let x=(0,Q.useMemo)(()=>u.trim()||(c??r??``),[c,r,u]),S=!c&&!!r&&x===r,C=Rt(a),{data:w,mutate:T}=v(n&&x?[`reverse-proxy-pair`,x]:null,()=>de(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),E=(0,Q.useMemo)(()=>!x||!w?.pairingSecret?``:d({baseUrl:x,pairingSecret:w.pairingSecret,lanUrl:C}),[x,C,w?.pairingSecret]),D=j(()=>nt(E),[E],{enabled:!!E,initial:null,errorData:null}),O=(0,Q.useCallback)(async()=>{let e=u.trim()||x;if(e){g({busy:!0,result:null});try{g({busy:!1,result:await Mt(e)})}catch(e){g({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[u,x]),k=(0,Q.useCallback)(async()=>{let e=x.trim();if(e){b({busy:!0,error:null});try{await Nt(e),await s(),await i(`tunnel-pair-context`),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[x,i,s]),A=(0,Q.useCallback)(async()=>{b({busy:!0,error:null});try{await Nt(null),await s(),await i(`tunnel-pair-context`),m(``),g({busy:!1,result:null}),b({busy:!1,error:null})}catch(e){b({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,s]),M=(0,Q.useCallback)(async()=>{await T()},[T]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{icon:oe,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:o(It(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:u,onChange:e=>{m(e.target.value),g({busy:!1,result:null})}}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void O(),disabled:h.busy||!u.trim(),children:[h.busy?(0,$.jsx)(me,{className:`size-3.5 animate-spin`}):null,h.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),S&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,h.result?(0,$.jsx)(Bt,{result:h.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[x&&c!==x?(0,$.jsxs)(X,{type:`button`,onClick:()=>void k(),disabled:y.busy,children:[y.busy?(0,$.jsx)(me,{className:`size-3.5 animate-spin`}):null,y.busy?t.saving:t.saveAsDefault]}):null,c?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>void A(),disabled:y.busy,children:t.clear}):null]}),y.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:y.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(Se,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),E?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void M(),children:[(0,$.jsx)(ee,{className:`size-4`}),t.refreshQr]}):null]}),x?w?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,x,C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,C]}):null]}),D.data?(0,$.jsx)(`img`,{src:D.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):D.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(he,{text:E,labels:{copy:t.copyLink,copied:t.copied,copyFailed:l(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Bt(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Vt=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Ht(e){return e&&Vt.includes(e)?e:`guide`}function Ut(e,t){return e.tabs[t]}function Wt(e,t){return e.tabIntro[t]}function Gt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Kt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Ot,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(mt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ct,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(bt,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ht,{}),t[6]=e):e=t[6],e}}}function qt(){let e=(0,Z.c)(2),t=p(Yt),n=l(t).remoteAccess,r=!!f(Jt),[a,o]=i(),s=Ht(a.get(`tab`)),c;e[0]===o?c=e[1]:(c=e=>{o(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=o,e[1]=c);let u=c,d=Wt(n,s),m=Vt.map(e=>({id:e,label:Ut(n,e)}));return(0,$.jsxs)(_e,{children:[(0,$.jsx)(ge,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)($e,{language:t,label:n.docsLink,section:Gt(s),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(we,{items:m,activeTab:s,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(ve,{id:s,activeTab:s,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Ut(n,s),hint:s===`public`?void 0:d,children:(0,$.jsx)(Kt,{tab:s,onOpenTab:u})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Jt(e){return e.token}function Yt(e){return e.language}export{qt as RemoteAccessHub};
@@ -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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BuT0SR1R.js";import{n as o,p as s}from"./locale-store-C_M71MK9.js";import{ms as c,zc as l}from"./index-EXa_i6BT.js";var u=e(t(),1);function d(e,t){let n=!1,r=0,i=t;for(let t of e.values())t.dirty&&(n=!0,r+=1),t.saving&&(i=!0);return{anyDirty:n,dirtyCount:r,anySaving:i}}var f=s((e,t)=>({sections:new Map,saveAllInFlight:!1,anyDirty:!1,dirtyCount:0,anySaving:!1,registerSection:t=>{e(e=>{let n=new Map(e.sections);return n.set(t.id,t),{sections:n,...d(n,e.saveAllInFlight)}})},unregisterSection:t=>{e(e=>{if(!e.sections.has(t))return e;let n=new Map(e.sections);return n.delete(t),{sections:n,...d(n,e.saveAllInFlight)}})},saveAll:async()=>{let n=Array.from(t().sections.values()).filter(e=>e.dirty);if(n.length===0)return{ok:!0,saved:0,failures:[]};e(e=>({saveAllInFlight:!0,...d(e.sections,!0)}));let r=[],i=0;try{let e=await Promise.all(n.map(async e=>{try{let t=await e.save();return{id:e.id,result:t}}catch(t){return{id:e.id,result:{ok:!1,error:t instanceof Error?t.message:String(t)}}}}));for(let{id:t,result:n}of e)n.ok?i+=1:r.push({id:t,error:n.error??`Save failed`})}finally{e(e=>({saveAllInFlight:!1,...d(e.sections,!1)}))}return{ok:r.length===0,saved:i,failures:r}},discardAll:()=>{for(let e of t().sections.values())e.dirty&&e.discard()}}));function p({id:e,dirty:t,saving:n,save:r,discard:i}){let a=(0,u.useRef)(r),o=(0,u.useRef)(i);a.current=r,o.current=i;let s=f(e=>e.registerSection),c=f(e=>e.unregisterSection);(0,u.useEffect)(()=>(s({id:e,dirty:t,saving:n,save:async()=>{try{return await a.current(),{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},discard:()=>o.current()}),()=>c(e)),[e,t,n,s,c])}var m=n(),h=r();function g(){let e=(0,m.c)(26),t=a(o(S)).modelsHub.saveBar,n=f(x),r=f(b),s=f(y),d=f(v),p=f(_),g;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],e[0]=g):g=e[0];let[C,w]=(0,u.useState)(g),[T,E]=(0,u.useState)(!1);if(!n&&C.length===0&&!T)return null;let D;e[1]===d?D=e[2]:(D=async()=>{w([]),E(!1);let e=await d();e.ok&&e.saved>0?(E(!0),window.setTimeout(()=>E(!1),2500)):e.ok||w(e.failures)},e[1]=d,e[2]=D);let O=D,k;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=i(`sticky top-0 z-10 -mx-4 flex flex-col gap-2 border-b border-edge-subtle bg-surface-base/85 px-4 py-2 backdrop-blur`,`sm:flex-row sm:items-center sm:justify-between`),e[3]=k):k=e[3];let A=C.length>0?(0,h.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,role:`alert`,children:t.failuresSummary.replace(`{{count}}`,String(C.length))}):null,j=!n||r,M;e[4]===p?M=e[5]:(M=()=>p(),e[4]=p,e[5]=M);let N;e[6]!==t.discardAll||e[7]!==j||e[8]!==M?(N=(0,h.jsx)(c,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:j,onClick:M,children:t.discardAll}),e[6]=t.discardAll,e[7]=j,e[8]=M,e[9]=N):N=e[9];let P=!n||r,F;e[10]===O?F=e[11]:(F=()=>void O(),e[10]=O,e[11]=F);let I;e[12]===r?I=e[13]:(I=r?(0,h.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,e[12]=r,e[13]=I);let L=r?`ml-1.5`:void 0,R;e[14]!==t.saveAll||e[15]!==L?(R=(0,h.jsx)(`span`,{className:L,children:t.saveAll}),e[14]=t.saveAll,e[15]=L,e[16]=R):R=e[16];let z;e[17]!==I||e[18]!==R||e[19]!==P||e[20]!==F?(z=(0,h.jsxs)(c,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:P,onClick:F,children:[I,R]}),e[17]=I,e[18]=R,e[19]=P,e[20]=F,e[21]=z):z=e[21];let B;return e[22]!==z||e[23]!==A||e[24]!==N?(B=(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[A,N,z]}),e[22]=z,e[23]=A,e[24]=N,e[25]=B):B=e[25],(0,h.jsxs)(`div`,{className:k,role:`region`,"aria-label":t.title,children:[(0,h.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?t.dirtySummary.replace(`{{count}}`,String(s)):T?t.savedSummary:t.cleanSummary}),B]})}function _(e){return e.discardAll}function v(e){return e.saveAll}function y(e){return e.dirtyCount}function b(e){return e.anySaving}function x(e){return e.anyDirty}function S(e){return e.language}export{p as n,g as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-BuT0SR1R.js";import{n as o,p as s}from"./locale-store-C_M71MK9.js";import{ms as c,zc as l}from"./index-BuqGh2SW.js";var u=e(t(),1);function d(e,t){let n=!1,r=0,i=t;for(let t of e.values())t.dirty&&(n=!0,r+=1),t.saving&&(i=!0);return{anyDirty:n,dirtyCount:r,anySaving:i}}var f=s((e,t)=>({sections:new Map,saveAllInFlight:!1,anyDirty:!1,dirtyCount:0,anySaving:!1,registerSection:t=>{e(e=>{let n=new Map(e.sections);return n.set(t.id,t),{sections:n,...d(n,e.saveAllInFlight)}})},unregisterSection:t=>{e(e=>{if(!e.sections.has(t))return e;let n=new Map(e.sections);return n.delete(t),{sections:n,...d(n,e.saveAllInFlight)}})},saveAll:async()=>{let n=Array.from(t().sections.values()).filter(e=>e.dirty);if(n.length===0)return{ok:!0,saved:0,failures:[]};e(e=>({saveAllInFlight:!0,...d(e.sections,!0)}));let r=[],i=0;try{let e=await Promise.all(n.map(async e=>{try{let t=await e.save();return{id:e.id,result:t}}catch(t){return{id:e.id,result:{ok:!1,error:t instanceof Error?t.message:String(t)}}}}));for(let{id:t,result:n}of e)n.ok?i+=1:r.push({id:t,error:n.error??`Save failed`})}finally{e(e=>({saveAllInFlight:!1,...d(e.sections,!1)}))}return{ok:r.length===0,saved:i,failures:r}},discardAll:()=>{for(let e of t().sections.values())e.dirty&&e.discard()}}));function p({id:e,dirty:t,saving:n,save:r,discard:i}){let a=(0,u.useRef)(r),o=(0,u.useRef)(i);a.current=r,o.current=i;let s=f(e=>e.registerSection),c=f(e=>e.unregisterSection);(0,u.useEffect)(()=>(s({id:e,dirty:t,saving:n,save:async()=>{try{return await a.current(),{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},discard:()=>o.current()}),()=>c(e)),[e,t,n,s,c])}var m=n(),h=r();function g(){let e=(0,m.c)(26),t=a(o(S)).modelsHub.saveBar,n=f(x),r=f(b),s=f(y),d=f(v),p=f(_),g;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],e[0]=g):g=e[0];let[C,w]=(0,u.useState)(g),[T,E]=(0,u.useState)(!1);if(!n&&C.length===0&&!T)return null;let D;e[1]===d?D=e[2]:(D=async()=>{w([]),E(!1);let e=await d();e.ok&&e.saved>0?(E(!0),window.setTimeout(()=>E(!1),2500)):e.ok||w(e.failures)},e[1]=d,e[2]=D);let O=D,k;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=i(`sticky top-0 z-10 -mx-4 flex flex-col gap-2 border-b border-edge-subtle bg-surface-base/85 px-4 py-2 backdrop-blur`,`sm:flex-row sm:items-center sm:justify-between`),e[3]=k):k=e[3];let A=C.length>0?(0,h.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,role:`alert`,children:t.failuresSummary.replace(`{{count}}`,String(C.length))}):null,j=!n||r,M;e[4]===p?M=e[5]:(M=()=>p(),e[4]=p,e[5]=M);let N;e[6]!==t.discardAll||e[7]!==j||e[8]!==M?(N=(0,h.jsx)(c,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:j,onClick:M,children:t.discardAll}),e[6]=t.discardAll,e[7]=j,e[8]=M,e[9]=N):N=e[9];let P=!n||r,F;e[10]===O?F=e[11]:(F=()=>void O(),e[10]=O,e[11]=F);let I;e[12]===r?I=e[13]:(I=r?(0,h.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,e[12]=r,e[13]=I);let L=r?`ml-1.5`:void 0,R;e[14]!==t.saveAll||e[15]!==L?(R=(0,h.jsx)(`span`,{className:L,children:t.saveAll}),e[14]=t.saveAll,e[15]=L,e[16]=R):R=e[16];let z;e[17]!==I||e[18]!==R||e[19]!==P||e[20]!==F?(z=(0,h.jsxs)(c,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:P,onClick:F,children:[I,R]}),e[17]=I,e[18]=R,e[19]=P,e[20]=F,e[21]=z):z=e[21];let B;return e[22]!==z||e[23]!==A||e[24]!==N?(B=(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[A,N,z]}),e[22]=z,e[23]=A,e[24]=N,e[25]=B):B=e[25],(0,h.jsxs)(`div`,{className:k,role:`region`,"aria-label":t.title,children:[(0,h.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?t.dirtySummary.replace(`{{count}}`,String(s)):T?t.savedSummary:t.cleanSummary}),B]})}function _(e){return e.discardAll}function v(e){return e.saveAll}function y(e){return e.dirtyCount}function b(e){return e.anySaving}function x(e){return e.anyDirty}function S(e){return e.language}export{p as n,g 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{t as i}from"./cn-BQ_8x0bT.js";import{Go as a,fs as o,ms as s,qo as c,us as l}from"./index-EXa_i6BT.js";import{n as u,t as d}from"./cron-expression-B3B1eqnr.js";var f=n(),p=e(t(),1),m=r(),h=Array.from({length:60},(e,t)=>t),g=i(o,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),_=i(`h-9 min-w-[6.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,l,`dark:bg-surface-panel`),v=i(`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`,l),y=i(`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`,l),b=i(`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`,l);function x(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function S(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function C(e,t){switch(t.type){case`reset`:return x(t.state);case`replace`:return t.state}}function w({value:e,onChange:t,labels:n,disabled:r,showHeading:o=!0}){let s=(0,p.useMemo)(()=>u(e),[e]),[l,f]=(0,p.useReducer)(C,s,x),w=(0,p.useRef)(e);w.current!==e&&(w.current=e,f({type:`reset`,state:s}));let T=(0,p.useCallback)(e=>{let n={...l,...e};f({type:`replace`,state:n});let r=S(n),i=S(l);Object.keys(r).some(e=>r[e]!==i[e])&&t(d(r))},[t,l]),{mode:E,intervalKind:D,onceDate:O,intervalMinutes:k,intervalHours:A,minute:j,hour:M,weekDays:N,dayOfMonth:P,rawCron:F,intervalMinutesDraft:I,intervalHoursDraft:L}=l,R=`${String(M).padStart(2,`0`)}:${String(j).padStart(2,`0`)}`,z=e=>{let t=e.target.value;if(!t)return;let[n,r]=t.split(`:`).map(e=>parseInt(e,10));Number.isNaN(n)||Number.isNaN(r)||T({minute:r,hour:n})},B=(0,m.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,m.jsxs)(a,{className:g,disabled:r,value:E,onChange:e=>{let t=e.target.value;T({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,m.jsx)(c,{value:`no_repeat`,children:n.modeNoRepeat}),(0,m.jsx)(c,{value:`interval`,children:n.modeInterval}),(0,m.jsx)(c,{value:`hourly`,children:n.modeHourly}),(0,m.jsx)(c,{value:`daily`,children:n.modeDaily}),(0,m.jsx)(c,{value:`weekly`,children:n.modeWeekly}),(0,m.jsx)(c,{value:`monthly`,children:n.modeMonthly}),(0,m.jsx)(c,{value:`custom`,children:n.modeCustom})]}),E===`no_repeat`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`input`,{type:`date`,disabled:r,className:v,value:O,onChange:e=>{T({onceDate:e.target.value})},"aria-label":n.modeNoRepeat}),(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel})]}),E===`interval`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(a,{className:i(g,`w-auto min-w-[5rem]`),disabled:r,value:D,onChange:e=>{let t=e.target.value;T({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,m.jsx)(c,{value:`minutes`,children:n.intervalKindMinutes}),(0,m.jsx)(c,{value:`hours`,children:n.intervalKindHours})]}),D===`minutes`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:y,value:I??String(k),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),T(r)},onBlur:()=>{if(I===null)return;let e=parseInt(I,10);T({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:y,value:L??String(A),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),T(r)},onBlur:()=>{if(L===null)return;let e=parseInt(L,10);T({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,m.jsx)(a,{className:i(g,`w-auto min-w-[4rem]`),disabled:r,value:j,onChange:e=>{T({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:h.map(e=>(0,m.jsx)(c,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),E===`daily`&&(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel}),E===`weekly`&&(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel}),E===`monthly`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a,{className:i(g,`w-auto min-w-[4.5rem]`),disabled:r,value:P,onChange:e=>{T({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,m.jsx)(c,{value:e,children:e},e))}),(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel})]}),E===`hourly`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a,{className:i(g,`w-auto min-w-[4rem]`),disabled:r,value:j,onChange:e=>{T({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:h.map(e=>(0,m.jsx)(c,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),V=E===`weekly`?(0,m.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=N[t];return(0,m.jsx)(`button`,{type:`button`,disabled:r,className:i(`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=[...N];e[t]=!e[t],T({weekDays:e})},children:e},e)})}):null,H=E===`custom`?(0,m.jsxs)(`div`,{className:`pt-1`,children:[(0,m.jsx)(`textarea`,{disabled:r,className:b,rows:2,spellCheck:!1,value:F,placeholder:`*/5 * * * *`,onChange:e=>{T({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,m.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,m.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o?(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,B,V,H]})}var T=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5],E=new Set(T),D=i(`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`,l),O=i(o,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function k(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 A({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=T,minSeconds:o=1}){let s=(0,p.useMemo)(()=>new Set(i),[i]),l=(0,p.useMemo)(()=>s.has(e)?String(e):``,[s,e]),[u,d]=(0,p.useState)(null),f=(0,p.useRef)(e);f.current!==e&&(f.current=e,d(null));let h=Math.max(o,Math.round(e/1e3)),g=u===null?String(h):u;return(0,m.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`input`,{type:`number`,min:o,step:1,disabled:r,className:D,value:g,onChange:e=>{let n=e.target.value;d(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=o&&t(r*1e3)},onBlur:()=>{if(u===null)return;let e=parseInt(u,10);t(!Number.isFinite(e)||e<o?o*1e3:e*1e3),d(null)}}),(0,m.jsxs)(a,{className:O,disabled:r,value:l,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),d(null))},children:[(0,m.jsx)(c,{value:``,children:n.presets.custom}),i.map(e=>(0,m.jsx)(c,{value:String(e),children:k(e,n.presets)},e))]})]})]})}var j=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,l),M=()=>({start:`09:00`,end:`22:00`,timezone:``});function N(e){let t=(0,f.c)(55),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(M()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,m.jsx)(s,{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,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let c;t[8]!==r||t[9]!==n?(c=e=>r({...n,start:e.target.value}),t[8]=r,t[9]=n,t[10]=c):c=t[10];let l;t[11]!==a||t[12]!==c||t[13]!==n.start?(l=(0,m.jsx)(`input`,{type:`time`,step:60,disabled:a,className:j,value:n.start,onChange:c}),t[11]=a,t[12]=c,t[13]=n.start,t[14]=l):l=t[14];let u;t[15]!==o||t[16]!==l?(u=(0,m.jsxs)(`label`,{className:`block min-w-0`,children:[o,l]}),t[15]=o,t[16]=l,t[17]=u):u=t[17];let d;t[18]===i.end?d=t[19]:(d=(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[18]=i.end,t[19]=d);let p;t[20]!==r||t[21]!==n?(p=e=>r({...n,end:e.target.value}),t[20]=r,t[21]=n,t[22]=p):p=t[22];let h;t[23]!==a||t[24]!==p||t[25]!==n.end?(h=(0,m.jsx)(`input`,{type:`time`,step:60,disabled:a,className:j,value:n.end,onChange:p}),t[23]=a,t[24]=p,t[25]=n.end,t[26]=h):h=t[26];let g;t[27]!==d||t[28]!==h?(g=(0,m.jsxs)(`label`,{className:`block min-w-0`,children:[d,h]}),t[27]=d,t[28]=h,t[29]=g):g=t[29];let _;t[30]===i.timezone?_=t[31]:(_=(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[30]=i.timezone,t[31]=_);let v;t[32]!==r||t[33]!==n?(v=e=>r({...n,timezone:e.target.value}),t[32]=r,t[33]=n,t[34]=v):v=t[34];let y;t[35]!==a||t[36]!==v||t[37]!==n.timezone?(y=(0,m.jsx)(`input`,{type:`text`,disabled:a,className:j,value:n.timezone,onChange:v,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[35]=a,t[36]=v,t[37]=n.timezone,t[38]=y):y=t[38];let b;t[39]!==y||t[40]!==_?(b=(0,m.jsxs)(`label`,{className:`block min-w-0`,children:[_,y]}),t[39]=y,t[40]=_,t[41]=b):b=t[41];let x;t[42]!==b||t[43]!==u||t[44]!==g?(x=(0,m.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,g,b]}),t[42]=b,t[43]=u,t[44]=g,t[45]=x):x=t[45];let S;t[46]===r?S=t[47]:(S=()=>r(null),t[46]=r,t[47]=S);let C;t[48]!==a||t[49]!==i.clear||t[50]!==S?(C=(0,m.jsx)(s,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:S,children:i.clear}),t[48]=a,t[49]=i.clear,t[50]=S,t[51]=C):C=t[51];let w;return t[52]!==x||t[53]!==C?(w=(0,m.jsxs)(`div`,{className:`space-y-2`,children:[x,C]}),t[52]=x,t[53]=C,t[54]=w):w=t[54],w}function P(e){let t=(0,f.c)(34),{disabled:n,label:r,hint:a,className:o}=e,s;t[0]===o?s=t[1]:(s=i(`flex flex-col gap-2`,o),t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,m.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,m.jsx)(w,{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,m.jsx)(A,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??T,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,m.jsx)(N,{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 p;t[25]===a?p=t[26]:(p=a?(0,m.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[25]=a,t[26]=p);let h;return t[27]!==s||t[28]!==c||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==p?(h=(0,m.jsxs)(`div`,{className:s,children:[c,l,u,d,p]}),t[27]=s,t[28]=c,t[29]=l,t[30]=u,t[31]=d,t[32]=p,t[33]=h):h=t[33],h}export{E as n,P as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{Go as a,fs as o,ms as s,qo as c,us as l}from"./index-BuqGh2SW.js";import{n as u,t as d}from"./cron-expression-B3B1eqnr.js";var f=n(),p=e(t(),1),m=r(),h=Array.from({length:60},(e,t)=>t),g=i(o,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),_=i(`h-9 min-w-[6.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,l,`dark:bg-surface-panel`),v=i(`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`,l),y=i(`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`,l),b=i(`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`,l);function x(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function S(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function C(e,t){switch(t.type){case`reset`:return x(t.state);case`replace`:return t.state}}function w({value:e,onChange:t,labels:n,disabled:r,showHeading:o=!0}){let s=(0,p.useMemo)(()=>u(e),[e]),[l,f]=(0,p.useReducer)(C,s,x),w=(0,p.useRef)(e);w.current!==e&&(w.current=e,f({type:`reset`,state:s}));let T=(0,p.useCallback)(e=>{let n={...l,...e};f({type:`replace`,state:n});let r=S(n),i=S(l);Object.keys(r).some(e=>r[e]!==i[e])&&t(d(r))},[t,l]),{mode:E,intervalKind:D,onceDate:O,intervalMinutes:k,intervalHours:A,minute:j,hour:M,weekDays:N,dayOfMonth:P,rawCron:F,intervalMinutesDraft:I,intervalHoursDraft:L}=l,R=`${String(M).padStart(2,`0`)}:${String(j).padStart(2,`0`)}`,z=e=>{let t=e.target.value;if(!t)return;let[n,r]=t.split(`:`).map(e=>parseInt(e,10));Number.isNaN(n)||Number.isNaN(r)||T({minute:r,hour:n})},B=(0,m.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,m.jsxs)(a,{className:g,disabled:r,value:E,onChange:e=>{let t=e.target.value;T({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,m.jsx)(c,{value:`no_repeat`,children:n.modeNoRepeat}),(0,m.jsx)(c,{value:`interval`,children:n.modeInterval}),(0,m.jsx)(c,{value:`hourly`,children:n.modeHourly}),(0,m.jsx)(c,{value:`daily`,children:n.modeDaily}),(0,m.jsx)(c,{value:`weekly`,children:n.modeWeekly}),(0,m.jsx)(c,{value:`monthly`,children:n.modeMonthly}),(0,m.jsx)(c,{value:`custom`,children:n.modeCustom})]}),E===`no_repeat`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`input`,{type:`date`,disabled:r,className:v,value:O,onChange:e=>{T({onceDate:e.target.value})},"aria-label":n.modeNoRepeat}),(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel})]}),E===`interval`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(a,{className:i(g,`w-auto min-w-[5rem]`),disabled:r,value:D,onChange:e=>{let t=e.target.value;T({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,m.jsx)(c,{value:`minutes`,children:n.intervalKindMinutes}),(0,m.jsx)(c,{value:`hours`,children:n.intervalKindHours})]}),D===`minutes`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:y,value:I??String(k),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),T(r)},onBlur:()=>{if(I===null)return;let e=parseInt(I,10);T({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:y,value:L??String(A),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),T(r)},onBlur:()=>{if(L===null)return;let e=parseInt(L,10);T({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,m.jsx)(a,{className:i(g,`w-auto min-w-[4rem]`),disabled:r,value:j,onChange:e=>{T({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:h.map(e=>(0,m.jsx)(c,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),E===`daily`&&(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel}),E===`weekly`&&(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel}),E===`monthly`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a,{className:i(g,`w-auto min-w-[4.5rem]`),disabled:r,value:P,onChange:e=>{T({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,m.jsx)(c,{value:e,children:e},e))}),(0,m.jsx)(`input`,{type:`time`,step:60,disabled:r,className:_,value:R,onChange:z,"aria-label":n.scheduleTimeLabel})]}),E===`hourly`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a,{className:i(g,`w-auto min-w-[4rem]`),disabled:r,value:j,onChange:e=>{T({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:h.map(e=>(0,m.jsx)(c,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,m.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),V=E===`weekly`?(0,m.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=N[t];return(0,m.jsx)(`button`,{type:`button`,disabled:r,className:i(`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=[...N];e[t]=!e[t],T({weekDays:e})},children:e},e)})}):null,H=E===`custom`?(0,m.jsxs)(`div`,{className:`pt-1`,children:[(0,m.jsx)(`textarea`,{disabled:r,className:b,rows:2,spellCheck:!1,value:F,placeholder:`*/5 * * * *`,onChange:e=>{T({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,m.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,m.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o?(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,B,V,H]})}var T=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5],E=new Set(T),D=i(`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`,l),O=i(o,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function k(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 A({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=T,minSeconds:o=1}){let s=(0,p.useMemo)(()=>new Set(i),[i]),l=(0,p.useMemo)(()=>s.has(e)?String(e):``,[s,e]),[u,d]=(0,p.useState)(null),f=(0,p.useRef)(e);f.current!==e&&(f.current=e,d(null));let h=Math.max(o,Math.round(e/1e3)),g=u===null?String(h):u;return(0,m.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`input`,{type:`number`,min:o,step:1,disabled:r,className:D,value:g,onChange:e=>{let n=e.target.value;d(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=o&&t(r*1e3)},onBlur:()=>{if(u===null)return;let e=parseInt(u,10);t(!Number.isFinite(e)||e<o?o*1e3:e*1e3),d(null)}}),(0,m.jsxs)(a,{className:O,disabled:r,value:l,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),d(null))},children:[(0,m.jsx)(c,{value:``,children:n.presets.custom}),i.map(e=>(0,m.jsx)(c,{value:String(e),children:k(e,n.presets)},e))]})]})]})}var j=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,l),M=()=>({start:`09:00`,end:`22:00`,timezone:``});function N(e){let t=(0,f.c)(55),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(M()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,m.jsx)(s,{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,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let c;t[8]!==r||t[9]!==n?(c=e=>r({...n,start:e.target.value}),t[8]=r,t[9]=n,t[10]=c):c=t[10];let l;t[11]!==a||t[12]!==c||t[13]!==n.start?(l=(0,m.jsx)(`input`,{type:`time`,step:60,disabled:a,className:j,value:n.start,onChange:c}),t[11]=a,t[12]=c,t[13]=n.start,t[14]=l):l=t[14];let u;t[15]!==o||t[16]!==l?(u=(0,m.jsxs)(`label`,{className:`block min-w-0`,children:[o,l]}),t[15]=o,t[16]=l,t[17]=u):u=t[17];let d;t[18]===i.end?d=t[19]:(d=(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[18]=i.end,t[19]=d);let p;t[20]!==r||t[21]!==n?(p=e=>r({...n,end:e.target.value}),t[20]=r,t[21]=n,t[22]=p):p=t[22];let h;t[23]!==a||t[24]!==p||t[25]!==n.end?(h=(0,m.jsx)(`input`,{type:`time`,step:60,disabled:a,className:j,value:n.end,onChange:p}),t[23]=a,t[24]=p,t[25]=n.end,t[26]=h):h=t[26];let g;t[27]!==d||t[28]!==h?(g=(0,m.jsxs)(`label`,{className:`block min-w-0`,children:[d,h]}),t[27]=d,t[28]=h,t[29]=g):g=t[29];let _;t[30]===i.timezone?_=t[31]:(_=(0,m.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[30]=i.timezone,t[31]=_);let v;t[32]!==r||t[33]!==n?(v=e=>r({...n,timezone:e.target.value}),t[32]=r,t[33]=n,t[34]=v):v=t[34];let y;t[35]!==a||t[36]!==v||t[37]!==n.timezone?(y=(0,m.jsx)(`input`,{type:`text`,disabled:a,className:j,value:n.timezone,onChange:v,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[35]=a,t[36]=v,t[37]=n.timezone,t[38]=y):y=t[38];let b;t[39]!==y||t[40]!==_?(b=(0,m.jsxs)(`label`,{className:`block min-w-0`,children:[_,y]}),t[39]=y,t[40]=_,t[41]=b):b=t[41];let x;t[42]!==b||t[43]!==u||t[44]!==g?(x=(0,m.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,g,b]}),t[42]=b,t[43]=u,t[44]=g,t[45]=x):x=t[45];let S;t[46]===r?S=t[47]:(S=()=>r(null),t[46]=r,t[47]=S);let C;t[48]!==a||t[49]!==i.clear||t[50]!==S?(C=(0,m.jsx)(s,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:S,children:i.clear}),t[48]=a,t[49]=i.clear,t[50]=S,t[51]=C):C=t[51];let w;return t[52]!==x||t[53]!==C?(w=(0,m.jsxs)(`div`,{className:`space-y-2`,children:[x,C]}),t[52]=x,t[53]=C,t[54]=w):w=t[54],w}function P(e){let t=(0,f.c)(34),{disabled:n,label:r,hint:a,className:o}=e,s;t[0]===o?s=t[1]:(s=i(`flex flex-col gap-2`,o),t[0]=o,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,m.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,m.jsx)(w,{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,m.jsx)(A,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??T,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,m.jsx)(N,{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 p;t[25]===a?p=t[26]:(p=a?(0,m.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[25]=a,t[26]=p);let h;return t[27]!==s||t[28]!==c||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==p?(h=(0,m.jsxs)(`div`,{className:s,children:[c,l,u,d,p]}),t[27]=s,t[28]=c,t[29]=l,t[30]=u,t[31]=d,t[32]=p,t[33]=h):h=t[33],h}export{E as n,P 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"./cn-BQ_8x0bT.js";import{Go as i,as as a,ns as o,qo as s}from"./index-EXa_i6BT.js";var c=t();e();var l=n();function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function f(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function p(e){return e[`x-hidden`]===!0}function m(e){let t=e.properties;if(!u(t))return[];let n=[];for(let[e,r]of Object.entries(t))u(r)&&(p(r)||n.push({key:e,sub:r,order:d(r),group:f(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function h(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function g(e){let t=(0,c.c)(38),{name:n,s:r,value:s,onChange:u,disabled:d}=e,f=typeof r.description==`string`?r.description:void 0,p=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||f,m=r.format;if(Array.isArray(r.enum)&&r.enum.every(v)){let e;t[0]===f?e=t[1]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let a;t[2]===u?a=t[3]:(a=e=>u(e.target.value),t[2]=u,t[3]=a);let o;t[4]===r.enum?o=t[5]:(o=r.enum.map(_),t[4]=r.enum,t[5]=o);let c;t[6]!==d||t[7]!==n||t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,l.jsx)(i,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:s,disabled:d,onChange:a,children:o}),t[6]=d,t[7]=n,t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11];let p;return t[12]!==e||t[13]!==c?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,c]}),t[12]=e,t[13]=c,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==s?(n=(0,l.jsx)(a,{value:s,onChange:u,placeholder:p,labels:o,disabled:d,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=d,t[18]=u,t[19]=p,t[20]=s,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let h;t[25]===f?h=t[26]:(h=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===u?g=t[28]:(g=e=>u(e.target.value),t[27]=u,t[28]=g);let y;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==s?(y=(0,l.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:s,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=s,t[34]=y):y=t[34];let b;return t[35]!==h||t[36]!==y?(b=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y]}),t[35]=h,t[36]=y,t[37]=b):b=t[37],b}function _(e){return(0,l.jsx)(s,{value:e,children:e},e)}function v(e){return typeof e==`string`}function y(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,o=typeof n.description==`string`?n.description:void 0,s;t[0]===o?s=t[1]:(s=o?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,l.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==s||t[9]!==f?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,f]}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p}function b(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:o?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,l.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,l.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,l.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function x(e){let t=(0,c.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,d=n.items,f=u(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=o?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==s||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===s?_=t[12]:(_=s?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:s}):null,t[11]=s,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,l.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=s,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,l.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=o?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,l.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,l.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function S(e){let t=(0,c.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,c;t[2]===a?c=t[3]:(c=e=>a(e),t[2]=a,t[3]=c);let u;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(u=(0,l.jsx)(b,{s:r,value:n,disabled:o,onChange:c,labels:s}),t[4]=o,t[5]=s,t[6]=r,t[7]=n,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==e||t[11]!==u?(d=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,s;t[15]!==o||t[16]!==a||t[17]!==r||t[18]!==n?(s=(0,l.jsx)(y,{s:r,value:n,disabled:o,onChange:a}),t[15]=o,t[16]=a,t[17]=r,t[18]=n,t[19]=s):s=t[19];let c;return t[20]!==e||t[21]!==s?(c=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let s=typeof i==`string`?i:``,c;t[25]!==o||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==s?(c=(0,l.jsx)(g,{name:n,s:r,value:s,disabled:o,onChange:a}),t[25]=o,t[26]=n,t[27]=a,t[28]=r,t[29]=s,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=u(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(C)?i.map(String):[],t[36]=i,t[37]=n);let c;t[38]!==o||t[39]!==s||t[40]!==a||t[41]!==r||t[42]!==n?(c=(0,l.jsx)(x,{s:r,value:n,disabled:o,onChange:a,labels:s}),t[38]=o,t[39]=s,t[40]=a,t[41]=r,t[42]=n,t[43]=c):c=t[43];let u;return t[44]!==e||t[45]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=u):u=t[46],u}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=u(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=c);let d;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,l.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,l.jsx)(w,{schema:r,values:n,onChange:a,disabled:o,labels:s})}),t[51]=o,t[52]=s,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==c||t[58]!==d?(p=(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,d]}),t[57]=c,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==d||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=s,t[61]=d,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){let t=(0,c.c)(28),{schema:n,values:i,onChange:a,disabled:o,className:s,labels:d}=e,f=o===void 0?!1:o,p;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],p=e;break bb0}let e;t[1]===n?e=t[2]:(e=m(n),t[1]=n,t[2]=e),p=e}let g=p,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=h(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!u(n.properties)||g.length===0)return null;let x,C;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==d||t[13]!==b||t[14]!==i){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=r(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==d||t[22]!==b||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>b(e.key,t),disabled:f,labels:d},e.key));return e===``?(0,l.jsx)(`div`,{children:t},`default`):(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,l.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=d,t[22]=b,t[23]=i,t[24]=n):n=t[24],C=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=d,t[13]=b,t[14]=i,t[15]=x,t[16]=C}else x=t[15],C=t[16];let w;return t[25]!==x||t[26]!==C?(w=(0,l.jsx)(`div`,{className:x,children:C}),t[25]=x,t[26]=C,t[27]=w):w=t[27],w}function T(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{w as t};
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"./cn-BQ_8x0bT.js";import{Go as i,as as a,ns as o,qo as s}from"./index-BuqGh2SW.js";var c=t();e();var l=n();function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function f(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function p(e){return e[`x-hidden`]===!0}function m(e){let t=e.properties;if(!u(t))return[];let n=[];for(let[e,r]of Object.entries(t))u(r)&&(p(r)||n.push({key:e,sub:r,order:d(r),group:f(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function h(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function g(e){let t=(0,c.c)(38),{name:n,s:r,value:s,onChange:u,disabled:d}=e,f=typeof r.description==`string`?r.description:void 0,p=(typeof r[`x-placeholder`]==`string`?r[`x-placeholder`]:null)||f,m=r.format;if(Array.isArray(r.enum)&&r.enum.every(v)){let e;t[0]===f?e=t[1]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let a;t[2]===u?a=t[3]:(a=e=>u(e.target.value),t[2]=u,t[3]=a);let o;t[4]===r.enum?o=t[5]:(o=r.enum.map(_),t[4]=r.enum,t[5]=o);let c;t[6]!==d||t[7]!==n||t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,l.jsx)(i,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:s,disabled:d,onChange:a,children:o}),t[6]=d,t[7]=n,t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11];let p;return t[12]!==e||t[13]!==c?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,c]}),t[12]=e,t[13]=c,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==s?(n=(0,l.jsx)(a,{value:s,onChange:u,placeholder:p,labels:o,disabled:d,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=d,t[18]=u,t[19]=p,t[20]=s,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let h;t[25]===f?h=t[26]:(h=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===u?g=t[28]:(g=e=>u(e.target.value),t[27]=u,t[28]=g);let y;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==s?(y=(0,l.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:s,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=s,t[34]=y):y=t[34];let b;return t[35]!==h||t[36]!==y?(b=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y]}),t[35]=h,t[36]=y,t[37]=b):b=t[37],b}function _(e){return(0,l.jsx)(s,{value:e,children:e},e)}function v(e){return typeof e==`string`}function y(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,o=typeof n.description==`string`?n.description:void 0,s;t[0]===o?s=t[1]:(s=o?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,l.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==s||t[9]!==f?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,f]}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p}function b(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:o?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,l.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,l.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,l.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function x(e){let t=(0,c.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,d=n.items,f=u(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=o?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==s||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===s?_=t[12]:(_=s?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:s}):null,t[11]=s,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,l.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=s,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,l.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=o?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,l.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,l.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function S(e){let t=(0,c.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,c;t[2]===a?c=t[3]:(c=e=>a(e),t[2]=a,t[3]=c);let u;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(u=(0,l.jsx)(b,{s:r,value:n,disabled:o,onChange:c,labels:s}),t[4]=o,t[5]=s,t[6]=r,t[7]=n,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==e||t[11]!==u?(d=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,s;t[15]!==o||t[16]!==a||t[17]!==r||t[18]!==n?(s=(0,l.jsx)(y,{s:r,value:n,disabled:o,onChange:a}),t[15]=o,t[16]=a,t[17]=r,t[18]=n,t[19]=s):s=t[19];let c;return t[20]!==e||t[21]!==s?(c=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let s=typeof i==`string`?i:``,c;t[25]!==o||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==s?(c=(0,l.jsx)(g,{name:n,s:r,value:s,disabled:o,onChange:a}),t[25]=o,t[26]=n,t[27]=a,t[28]=r,t[29]=s,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=u(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(C)?i.map(String):[],t[36]=i,t[37]=n);let c;t[38]!==o||t[39]!==s||t[40]!==a||t[41]!==r||t[42]!==n?(c=(0,l.jsx)(x,{s:r,value:n,disabled:o,onChange:a,labels:s}),t[38]=o,t[39]=s,t[40]=a,t[41]=r,t[42]=n,t[43]=c):c=t[43];let u;return t[44]!==e||t[45]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=u):u=t[46],u}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=u(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=c);let d;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,l.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,l.jsx)(w,{schema:r,values:n,onChange:a,disabled:o,labels:s})}),t[51]=o,t[52]=s,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==c||t[58]!==d?(p=(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,d]}),t[57]=c,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==d||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=s,t[61]=d,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){let t=(0,c.c)(28),{schema:n,values:i,onChange:a,disabled:o,className:s,labels:d}=e,f=o===void 0?!1:o,p;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],p=e;break bb0}let e;t[1]===n?e=t[2]:(e=m(n),t[1]=n,t[2]=e),p=e}let g=p,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=h(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==a||t[7]!==i?(y=(e,t)=>{a({...i,[e]:t})},t[6]=a,t[7]=i,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!u(n.properties)||g.length===0)return null;let x,C;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==d||t[13]!==b||t[14]!==i){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=r(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==d||t[22]!==b||t[23]!==i?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:i[e.key],onValue:t=>b(e.key,t),disabled:f,labels:d},e.key));return e===``?(0,l.jsx)(`div`,{children:t},`default`):(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,l.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=d,t[22]=b,t[23]=i,t[24]=n):n=t[24],C=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=d,t[13]=b,t[14]=i,t[15]=x,t[16]=C}else x=t[15],C=t[16];let w;return t[25]!==x||t[26]!==C?(w=(0,l.jsx)(`div`,{className:x,children:C}),t[25]=x,t[26]=C,t[27]=w):w=t[27],w}function T(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{w as t};