@xopcai/xopc 0.0.311 → 0.0.312

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 (100) hide show
  1. package/README.md +2 -1
  2. package/README.zh-CN.md +2 -1
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-zKINl7UH.js → agent-avatar-dicebear-BVIJMP8w.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-D2ePZKdY.js → agent-defaults-settings-panel-K3hTmu9d.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-BiD9STyv.js → agents-D6g_SeWI.js} +1 -1
  8. package/dist/gateway/static/root/assets/app-link-CKueEVbT.js +1 -0
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-C94LAxyt.js → app-management-settings-panel-CLg_aXYG.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-CP01zHvC.js → appearance-settings-CU52MfIT.js} +1 -1
  11. package/dist/gateway/static/root/assets/apps-page-ZpA1-6ad.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-SwWFt5MT.js → archive-plugin-CHO3heHX.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-DdTFml9l.js → attachment-load-BsmsBCI2.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-page-Kmr5WVFp.js → automations-page-CftigJlf.js} +1 -1
  15. package/dist/gateway/static/root/assets/{automations-workspace-bkijiu-Y.js → automations-workspace-IEAxKRME.js} +1 -1
  16. package/dist/gateway/static/root/assets/{binary-plugins-47UTtDNq.js → binary-plugins-CRCLWBo2.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-DvzZkMG8.js → block-editor-D0LDiOTT.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-DrUKNL9X.js → browser-automations-page-Djyv3vy-.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-settings-page-Dhf_MWCf.js → browser-settings-page-CU4VWsmX.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capabilities-settings-panel-BCubrDf8.js → capabilities-settings-panel-C9XQk3HL.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-e4T1DEfN.js → channels-settings-Bqlhjooi.js} +1 -1
  22. package/dist/gateway/static/root/assets/{chat-terminal-dock-Bg_m7HUE.js → chat-terminal-dock-CIsKqdET.js} +1 -1
  23. package/dist/gateway/static/root/assets/{computer-settings-page-CosCmVsT.js → computer-settings-page-C0YL9J7m.js} +1 -1
  24. package/dist/gateway/static/root/assets/{connector-service-page-BL-hSR7_.js → connector-service-page-BmH17JnO.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connectors-page-C0WWxnxJ.js → connectors-page-zkx8Q-e6.js} +1 -1
  26. package/dist/gateway/static/root/assets/{date-picker-DqYFVasF.js → date-picker-CDsfv8R0.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dependency-picker-DCyyFLKp.js → dependency-picker-DvhPj3CZ.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-CFnnpRA_.js → desktop-pet-Cyg8XMpL.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-U5wWRH4c.js → desktop-pet-settings-CE4GOlMM.js} +1 -1
  30. package/dist/gateway/static/root/assets/{device-pairing-wizard-BhHxvFO1.js → device-pairing-wizard-CdKJqnnw.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-DA8WJ3-E.js → extension-debug-page-D-AVJU3q.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-C2BIB88m.js → extension-page-DrFoQ9xt.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-kpYo979N.js → extension-settings-page-DxWjESC1.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-settings-CE9t1yTa.js → gateway-settings-CgXp2zq4.js} +1 -1
  35. package/dist/gateway/static/root/assets/{home-page-C7Ezx8Du.js → home-page-D6Idk732.js} +1 -1
  36. package/dist/gateway/static/root/assets/{imports-page-NPk698vI.js → imports-page-BKucJlXI.js} +1 -1
  37. package/dist/gateway/static/root/assets/{index-DxYitLp8.js → index-PFQHPGgi.js} +45 -45
  38. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BhreF0_O.js → keyboard-shortcuts-settings-BxLXD-yU.js} +1 -1
  39. package/dist/gateway/static/root/assets/{local-app-workbench-page-CPmynb3x.js → local-app-workbench-page-BmAqTRb4.js} +2 -2
  40. package/dist/gateway/static/root/assets/{local-apps-page-DOZZBdqj.js → local-apps-page-BAsQJQKJ.js} +1 -1
  41. package/dist/gateway/static/root/assets/{logs-page-M8kz26yo.js → logs-page-ZjVYXXyM.js} +1 -1
  42. package/dist/gateway/static/root/assets/{management-settings-JLqHYQvY.js → management-settings-CSTkYVOZ.js} +1 -1
  43. package/dist/gateway/static/root/assets/{markdown-view-BDpcjR_Z.js → markdown-view-DYGPxPee.js} +1 -1
  44. package/dist/gateway/static/root/assets/{media-plugins-B75SWUJd.js → media-plugins-CQtQzLyg.js} +1 -1
  45. package/dist/gateway/static/root/assets/{note-detail-panel-B_Ft0M32.js → note-detail-panel-DuXCt-MM.js} +3 -3
  46. package/dist/gateway/static/root/assets/notes-page-BjOgBVq5.js +8 -0
  47. package/dist/gateway/static/root/assets/{page-tabs-CMlQUzT6.js → page-tabs-B6DjkyMM.js} +1 -1
  48. package/dist/gateway/static/root/assets/{preview-open-alternatives-cZ2hszQT.js → preview-open-alternatives-Dn57uLhr.js} +1 -1
  49. package/dist/gateway/static/root/assets/product-delivery-CrAI8ZEa.js +1 -0
  50. package/dist/gateway/static/root/assets/{product-open-page-CPoSbglF.js → product-open-page-H2YMk8TY.js} +1 -1
  51. package/dist/gateway/static/root/assets/{project-detail-page-DYttWua0.js → project-detail-page-0zi4-i9X.js} +1 -1
  52. package/dist/gateway/static/root/assets/{projects-page-D46drWbl.js → projects-page-B18OxmJj.js} +1 -1
  53. package/dist/gateway/static/root/assets/{remote-access-hub-C9n9Nuhi.js → remote-access-hub-z-DxbuaE.js} +1 -1
  54. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-bMLWRApp.js → runtime-tools-settings-panel-DGsBTbo6.js} +1 -1
  55. package/dist/gateway/static/root/assets/scenes-page-Bgba03B_.js +1 -0
  56. package/dist/gateway/static/root/assets/{schema-form-UVJV_7AS.js → schema-form-CblI9WUA.js} +1 -1
  57. package/dist/gateway/static/root/assets/{sessions-page-C8P6ff91.js → sessions-page-B1t3bMsm.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-advanced-gate-CBX0Ezhf.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-form-section-BqzOqonM.js → settings-form-section-BAaVyxJH.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-page-DQ9RJ8-b.js → settings-page-CKNPbm5q.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-layout-D3Spald3.js → settings-page-layout-DqNCGKxQ.js} +1 -1
  62. package/dist/gateway/static/root/assets/{setup-status-panel-C8u601m8.js → setup-status-panel-Bw71C2X3.js} +1 -1
  63. package/dist/gateway/static/root/assets/{share-preview-page-BcgYzA7y.js → share-preview-page-BzMfp_HM.js} +1 -1
  64. package/dist/gateway/static/root/assets/{shares-settings-Bv-2rZ8e.js → shares-settings-BoVDQolc.js} +1 -1
  65. package/dist/gateway/static/root/assets/{skill-reload-api-LM-cgWUS.js → skill-reload-api-DtTptpAt.js} +1 -1
  66. package/dist/gateway/static/root/assets/{skills-page-ggmb7rCW.js → skills-page-DIht92q6.js} +1 -1
  67. package/dist/gateway/static/root/assets/{skills-page.utils-ADABzrtk.js → skills-page.utils-DLYRiEn3.js} +1 -1
  68. package/dist/gateway/static/root/assets/{system-settings-panel-DfkcW_Za.js → system-settings-panel-yYs4YgYk.js} +1 -1
  69. package/dist/gateway/static/root/assets/{task-detail-page-DC4yqDFd.js → task-detail-page-vgkiGo-D.js} +1 -1
  70. package/dist/gateway/static/root/assets/{tunnel-api-CTuwTdMm.js → tunnel-api-BasDYxvx.js} +1 -1
  71. package/dist/gateway/static/root/assets/{use-autosave-5ZDd9XKh.js → use-autosave-CWAUHhcb.js} +1 -1
  72. package/dist/gateway/static/root/assets/{user-model-page-BFKFhdZ0.js → user-model-page-CAGafNfP.js} +1 -1
  73. package/dist/gateway/static/root/assets/{voice-api-key-field-D3urfd-n.js → voice-api-key-field-Kc4UlxZs.js} +1 -1
  74. package/dist/gateway/static/root/assets/{work-discovery-overlay-JzM3Ylbs.js → work-discovery-overlay-BPC_c9dO.js} +1 -1
  75. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Bn2CtRdB.js → workflow-run-setup-panel-DBTciOrq.js} +1 -1
  76. package/dist/gateway/static/root/assets/{workflows-page-BiCmt98A.js → workflows-page-CSxHVs1p.js} +1 -1
  77. package/dist/gateway/static/root/index.html +4 -4
  78. package/dist/package.js +1 -1
  79. package/dist/packages/gateway-contract/src/product-delivery.js +1 -0
  80. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  81. package/dist/src/agent/tool-manuals/xopc-use.js +43 -16
  82. package/dist/src/agent/tools/xopc-use-tool.js +60 -3
  83. package/dist/src/config/index.js +2 -2
  84. package/dist/src/config/schema.d.ts +9 -0
  85. package/dist/src/config/schema.js +8 -2
  86. package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -0
  87. package/dist/src/gateway/hono/lib/config-payload.js +1 -0
  88. package/dist/src/gateway/scenes/host.js +5 -4
  89. package/dist/src/gateway/service.js +2 -2
  90. package/dist/src/scenes/metrics.d.ts +3 -1
  91. package/dist/src/scenes/metrics.js +7 -1
  92. package/dist/src/scenes/model.d.ts +3 -0
  93. package/dist/src/scenes/model.js +10 -0
  94. package/package.json +4 -4
  95. package/dist/gateway/static/root/assets/app-link-wamYbNUl.js +0 -1
  96. package/dist/gateway/static/root/assets/apps-page-B7DmSJQj.js +0 -1
  97. package/dist/gateway/static/root/assets/notes-page-C32mxSD-.js +0 -8
  98. package/dist/gateway/static/root/assets/product-delivery-CCC4FJ3Y.js +0 -1
  99. package/dist/gateway/static/root/assets/scenes-page-Dw3hmHAr.js +0 -1
  100. package/dist/gateway/static/root/assets/settings-advanced-gate-whpUsAy3.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-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{n as u}from"./locale-store-DA0Z5jM_.js";import{t as d}from"./messages-4BtQKYlM.js";import{a as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{t as y}from"./button-CS04eWY9.js";import{t as b}from"./skeleton-BwbyijEw.js";import{$i as x,Ac as S,Da as C,Ea as w,Ec as T,Ha as E,Hc as D,Jl as ee,Ju as O,La as k,Nr as A,Ra as j,Vc as M,Zu as N,da as P,do as F,fl as I,ql as te,ra as ne,za as re}from"./index-DxYitLp8.js";var L=n(),R=e(t(),1),z=r();function B(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:A(n)}function ie(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 ae(){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},V)}),e[0]=t):t=e[0],t}function V(e,t){return(0,z.jsx)(b,{className:`h-40 rounded-xl`},t)}function oe(e){let t=(0,L.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:o}=e,s=u(H),c,l,f,p,m,h,g,_;if(t[0]!==s||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=d(s).projectsPage;c=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-surface-hover text-fg-muted`,children:(0,z.jsx)(ee,{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-base font-semibold sm:text-sm text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let o=(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]})]}),u;t[20]===o?u=t[21]:(u=(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,o]}),t[20]=o,t[21]=u);let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,z.jsx)(O,{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]===u?y=t[24]:(y=(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[u,v]}),t[23]=u,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-sm leading-6 sm:text-xs sm: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-xs text-fg-muted`,m=(0,z.jsx)(`p`,{className:`hidden truncate sm:block`,children:n.workspaceRoot||e.agentDefault}),l=`mt-1`,f=B(n.lastActiveAt??n.updatedAt,e.never),t[0]=s,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]=c,t[10]=l,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_}else c=t[9],l=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16];let v;t[25]!==l||t[26]!==f?(v=(0,z.jsx)(`p`,{className:l,children:f}),t[25]=l,t[26]=f,t[27]=v):v=t[27];let b;t[28]!==p||t[29]!==m||t[30]!==v?(b=(0,z.jsxs)(`div`,{className:p,children:[m,v]}),t[28]=p,t[29]=m,t[30]=v,t[31]=b):b=t[31];let x=n.pinnedAt?c.unpin:c.pin,C=n.pinnedAt?c.unpin:c.pin,w;t[32]===n.pinnedAt?w=t[33]:(w=n.pinnedAt?(0,z.jsx)(M,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=w);let T;t[34]!==r||t[35]!==a||t[36]!==x||t[37]!==C||t[38]!==w?(T=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":x,title:C,children:w}),t[34]=r,t[35]=a,t[36]=x,t[37]=C,t[38]=w,t[39]=T):T=t[39];let E=n.status===`archived`?c.restore:c.archive,k=n.status===`archived`?c.restore:c.archive,A;t[40]===n.status?A=t[41]:(A=n.status===`archived`?(0,z.jsx)(S,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=A);let j;t[42]!==r||t[43]!==o||t[44]!==E||t[45]!==k||t[46]!==A?(j=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:o,"aria-label":E,title:k,children:A}),t[42]=r,t[43]=o,t[44]=E,t[45]=k,t[46]=A,t[47]=j):j=t[47];let P;t[48]!==T||t[49]!==j?(P=(0,z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[T,j]}),t[48]=T,t[49]=j,t[50]=P):P=t[50];let F;t[51]!==P||t[52]!==h||t[53]!==b?(F=(0,z.jsxs)(`div`,{className:h,children:[b,P]}),t[51]=P,t[52]=h,t[53]=b,t[54]=F):F=t[54];let I;return t[55]!==F||t[56]!==g||t[57]!==_?(I=(0,z.jsxs)(`article`,{className:g,children:[_,F]}),t[55]=F,t[56]=g,t[57]=_,t[58]=I):I=t[58],I}function H(e){return e.language}function U(){let e=d(u(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=F(e=>e.setPageHeader),b=F(e=>e.clearPageHeader),[S,D]=(0,R.useState)([]),[O,A]=(0,R.useState)(!0),[M,N]=(0,R.useState)(null),[L,B]=(0,R.useState)(``),[V,H]=(0,R.useState)(!1),[U,se]=(0,R.useState)(`active`),[ce,le]=(0,R.useState)(null),[ue,W]=(0,R.useState)(!1),[de,G]=(0,R.useState)(null),[K,fe]=(0,R.useState)(!1),[q,pe]=(0,R.useState)(!0),[J,me]=(0,R.useState)(``),[Y,he]=(0,R.useState)(``),[X,ge]=(0,R.useState)(``),Z=ne({initialPath:X,onPicked:ge}),Q=(0,R.useCallback)(async()=>{A(!0),N(null);try{D(ie((await k({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})).items))}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(!1)}},[]);(0,R.useEffect)(()=>{Q()},[Q]);let $=(0,R.useMemo)(()=>{let e=L.trim().toLocaleLowerCase();return S.filter(e=>U===`all`||e.status===U).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[U,S,L]),_e=(0,R.useMemo)(()=>(0,z.jsxs)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>W(!0),children:[(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,R.useLayoutEffect)(()=>(i({startExtra:null,main:(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:_e}),()=>b()),[b,_e,n.title,i]);let ve=(0,R.useCallback)(async e=>{e.preventDefault();let t=J.trim(),n=X.trim();if(!(!t||!n||K)){fe(!0),G(null);try{let e=await C({autoUnderstand:q,name:t,...Y.trim()?{description:Y.trim()}:{},workspaceRoot:n});D(t=>[e,...t.filter(t=>t.id!==e.id)]),me(``),he(``),ge(``),pe(!0),W(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){G(e instanceof Error?e.message:String(e))}finally{fe(!1)}}},[K,Y,J,X,q]),ye=(0,R.useCallback)(async(e,t)=>{le(e.id),N(null);try{let n;n=t===`pin`?e.pinnedAt?await E(e.id):await j(e.id):e.status===`archived`?await re(e.id):await w(e.id),D(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){N(e instanceof Error?e.message:String(e))}finally{le(null)}},[]),be=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}],xe=be.find(e=>e.id===U)?.label??t.all,Se=n.resultCount.replace(`{{status}}`,xe).replace(`{{count}}`,String($.length));return(0,z.jsxs)(`main`,{className:`mx-auto flex w-full max-w-6xl flex-1 flex-col gap-5 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,z.jsx)(v,{open:ue,onOpenChange:e=>{W(e),e||G(null)},children:(0,z.jsxs)(h,{children:[(0,z.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,z.jsxs)(g,{className:`xopc-dialog-content 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-overlay 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)(_,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,z.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,z.jsxs)(`form`,{onSubmit:ve,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:J,onChange:e=>me(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:Y,onChange:e=>he(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:Z.pick,disabled:K||Z.picking,children:[Z.picking?(0,z.jsx)(I,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,z.jsx)(te,{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:X?r.chooseFolder:r.selectWorkingDirectory}),(0,z.jsx)(`span`,{className:l(`mt-0.5 block truncate font-mono text-xs font-normal`,X?`text-fg-muted`:`text-fg-subtle`),title:X||void 0,children:X||t.workspaceSelectionPlaceholder})]})]}),(0,z.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),(0,z.jsx)(P,{checked:q,onChange:pe,disabled:K}),de?(0,z.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:de}):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)(m,{asChild:!0,children:(0,z.jsx)(y,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,z.jsx)(y,{type:`submit`,variant:`primary`,disabled:K||!J.trim()||!X.trim(),children:K?t.home.creating:t.create})]})]})]})]})}),Z.hasNativePicker?null:(0,z.jsx)(x,{open:Z.modalOpen,onOpenChange:Z.setModalOpen,initialAbsolutePath:X||void 0,onConfirm:Z.confirmPick,wd:r}),(0,z.jsxs)(`section`,{className:`flex min-h-10 flex-wrap items-center justify-between gap-3`,"aria-label":n.filterLabel,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,"aria-live":`polite`,children:Se}),(0,z.jsxs)(`div`,{className:l(`ml-auto flex min-w-0 items-center justify-end gap-2`,V&&`w-full sm:w-auto`),children:[V?(0,z.jsxs)(`div`,{className:`relative min-w-0 flex-1 sm:w-64 sm:flex-none`,children:[(0,z.jsx)(T,{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`,{autoFocus:!0,className:`h-11 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-12 text-base sm:h-9 sm:text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:L,onChange:e=>B(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder}),(0,z.jsx)(`button`,{type:`button`,className:`touch-target absolute right-0 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg`,onClick:()=>{B(``),H(!1)},"aria-label":n.clearSearch,title:n.clearSearch,children:(0,z.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})})]}):(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,onClick:()=>H(!0),"aria-label":t.searchPlaceholder,title:t.searchPlaceholder,children:(0,z.jsx)(T,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(a,{className:`w-28 sm:w-32`,triggerClassName:`h-9 border-edge bg-surface-panel px-2.5 text-xs font-medium`,contentClassName:`min-w-36`,align:`end`,value:U,"aria-label":n.filterLabel,onChange:e=>se(e.target.value),children:be.map(e=>(0,z.jsx)(o,{value:e.id,children:e.label},e.id))})]})]}),M?(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:M}),(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Q(),children:t.home.retry})]}):null,O?(0,z.jsx)(ae,{}):$.length?(0,z.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>(0,z.jsx)(oe,{project:e,busy:ce===e.id,onTogglePin:()=>void ye(e,`pin`),onToggleArchive:()=>void ye(e,`archive`)},e.id))}):(0,z.jsxs)(`section`,{className:`py-16 text-center`,children:[(0,z.jsx)(ee,{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{U 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-BMYIfy9x.js";import{n as a,r as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{n as u}from"./locale-store-DA0Z5jM_.js";import{t as d}from"./messages-4BtQKYlM.js";import{a as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{t as y}from"./button-CS04eWY9.js";import{t as b}from"./skeleton-BwbyijEw.js";import{$i as x,Ac as S,Da as C,Ea as w,Ec as T,Ha as E,Hc as D,Jl as ee,Ju as O,La as k,Nr as A,Ra as j,Vc as M,Zu as N,da as P,do as F,fl as I,ql as te,ra as ne,za as re}from"./index-PFQHPGgi.js";var L=n(),R=e(t(),1),z=r();function B(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:A(n)}function ie(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 ae(){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},V)}),e[0]=t):t=e[0],t}function V(e,t){return(0,z.jsx)(b,{className:`h-40 rounded-xl`},t)}function oe(e){let t=(0,L.c)(59),{project:n,busy:r,onTogglePin:a,onToggleArchive:o}=e,s=u(H),c,l,f,p,m,h,g,_;if(t[0]!==s||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=d(s).projectsPage;c=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-surface-hover text-fg-muted`,children:(0,z.jsx)(ee,{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-base font-semibold sm:text-sm text-fg`,children:n.name}),t[18]=n.name,t[19]=a);let o=(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]})]}),u;t[20]===o?u=t[21]:(u=(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[r,o]}),t[20]=o,t[21]=u);let v;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,z.jsx)(O,{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]===u?y=t[24]:(y=(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[u,v]}),t[23]=u,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-sm leading-6 sm:text-xs sm: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-xs text-fg-muted`,m=(0,z.jsx)(`p`,{className:`hidden truncate sm:block`,children:n.workspaceRoot||e.agentDefault}),l=`mt-1`,f=B(n.lastActiveAt??n.updatedAt,e.never),t[0]=s,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]=c,t[10]=l,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_}else c=t[9],l=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],_=t[16];let v;t[25]!==l||t[26]!==f?(v=(0,z.jsx)(`p`,{className:l,children:f}),t[25]=l,t[26]=f,t[27]=v):v=t[27];let b;t[28]!==p||t[29]!==m||t[30]!==v?(b=(0,z.jsxs)(`div`,{className:p,children:[m,v]}),t[28]=p,t[29]=m,t[30]=v,t[31]=b):b=t[31];let x=n.pinnedAt?c.unpin:c.pin,C=n.pinnedAt?c.unpin:c.pin,w;t[32]===n.pinnedAt?w=t[33]:(w=n.pinnedAt?(0,z.jsx)(M,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t[32]=n.pinnedAt,t[33]=w);let T;t[34]!==r||t[35]!==a||t[36]!==x||t[37]!==C||t[38]!==w?(T=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:a,"aria-label":x,title:C,children:w}),t[34]=r,t[35]=a,t[36]=x,t[37]=C,t[38]=w,t[39]=T):T=t[39];let E=n.status===`archived`?c.restore:c.archive,k=n.status===`archived`?c.restore:c.archive,A;t[40]===n.status?A=t[41]:(A=n.status===`archived`?(0,z.jsx)(S,{className:`size-4`,"aria-hidden":!0}):(0,z.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[40]=n.status,t[41]=A);let j;t[42]!==r||t[43]!==o||t[44]!==E||t[45]!==k||t[46]!==A?(j=(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-8 p-0`,disabled:r,onClick:o,"aria-label":E,title:k,children:A}),t[42]=r,t[43]=o,t[44]=E,t[45]=k,t[46]=A,t[47]=j):j=t[47];let P;t[48]!==T||t[49]!==j?(P=(0,z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[T,j]}),t[48]=T,t[49]=j,t[50]=P):P=t[50];let F;t[51]!==P||t[52]!==h||t[53]!==b?(F=(0,z.jsxs)(`div`,{className:h,children:[b,P]}),t[51]=P,t[52]=h,t[53]=b,t[54]=F):F=t[54];let I;return t[55]!==F||t[56]!==g||t[57]!==_?(I=(0,z.jsxs)(`article`,{className:g,children:[_,F]}),t[55]=F,t[56]=g,t[57]=_,t[58]=I):I=t[58],I}function H(e){return e.language}function U(){let e=d(u(e=>e.language)),t=e.projectsPage,n=t.management,r=e.chat.workingDirectory,i=F(e=>e.setPageHeader),b=F(e=>e.clearPageHeader),[S,D]=(0,R.useState)([]),[O,A]=(0,R.useState)(!0),[M,N]=(0,R.useState)(null),[L,B]=(0,R.useState)(``),[V,H]=(0,R.useState)(!1),[U,se]=(0,R.useState)(`active`),[ce,le]=(0,R.useState)(null),[ue,W]=(0,R.useState)(!1),[de,G]=(0,R.useState)(null),[K,fe]=(0,R.useState)(!1),[q,pe]=(0,R.useState)(!0),[J,me]=(0,R.useState)(``),[Y,he]=(0,R.useState)(``),[X,ge]=(0,R.useState)(``),Z=ne({initialPath:X,onPicked:ge}),Q=(0,R.useCallback)(async()=>{A(!0),N(null);try{D(ie((await k({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})).items))}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(!1)}},[]);(0,R.useEffect)(()=>{Q()},[Q]);let $=(0,R.useMemo)(()=>{let e=L.trim().toLocaleLowerCase();return S.filter(e=>U===`all`||e.status===U).filter(t=>!e||[t.name,t.description,t.brief,t.workspaceRoot].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e)))},[U,S,L]),_e=(0,R.useMemo)(()=>(0,z.jsxs)(y,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>W(!0),children:[(0,z.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t.create]}),[t.create]);(0,R.useLayoutEffect)(()=>(i({startExtra:null,main:(0,z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:_e}),()=>b()),[b,_e,n.title,i]);let ve=(0,R.useCallback)(async e=>{e.preventDefault();let t=J.trim(),n=X.trim();if(!(!t||!n||K)){fe(!0),G(null);try{let e=await C({autoUnderstand:q,name:t,...Y.trim()?{description:Y.trim()}:{},workspaceRoot:n});D(t=>[e,...t.filter(t=>t.id!==e.id)]),me(``),he(``),ge(``),pe(!0),W(!1),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){G(e instanceof Error?e.message:String(e))}finally{fe(!1)}}},[K,Y,J,X,q]),ye=(0,R.useCallback)(async(e,t)=>{le(e.id),N(null);try{let n;n=t===`pin`?e.pinnedAt?await E(e.id):await j(e.id):e.status===`archived`?await re(e.id):await w(e.id),D(e=>e.map(e=>e.id===n.id?n:e)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){N(e instanceof Error?e.message:String(e))}finally{le(null)}},[]),be=[{id:`active`,label:t.statuses.active},{id:`paused`,label:t.statuses.paused},{id:`archived`,label:t.statuses.archived},{id:`all`,label:t.all}],xe=be.find(e=>e.id===U)?.label??t.all,Se=n.resultCount.replace(`{{status}}`,xe).replace(`{{count}}`,String($.length));return(0,z.jsxs)(`main`,{className:`mx-auto flex w-full max-w-6xl flex-1 flex-col gap-5 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,z.jsx)(v,{open:ue,onOpenChange:e=>{W(e),e||G(null)},children:(0,z.jsxs)(h,{children:[(0,z.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,z.jsxs)(g,{className:`xopc-dialog-content 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-overlay 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)(_,{className:`text-base font-semibold text-fg`,children:t.createTitle}),(0,z.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:t.createDescription})]}),(0,z.jsxs)(`form`,{onSubmit:ve,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:J,onChange:e=>me(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:Y,onChange:e=>he(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:Z.pick,disabled:K||Z.picking,children:[Z.picking?(0,z.jsx)(I,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,z.jsx)(te,{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:X?r.chooseFolder:r.selectWorkingDirectory}),(0,z.jsx)(`span`,{className:l(`mt-0.5 block truncate font-mono text-xs font-normal`,X?`text-fg-muted`:`text-fg-subtle`),title:X||void 0,children:X||t.workspaceSelectionPlaceholder})]})]}),(0,z.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:t.workspaceSelectionHint})]}),(0,z.jsx)(P,{checked:q,onChange:pe,disabled:K}),de?(0,z.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:de}):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)(m,{asChild:!0,children:(0,z.jsx)(y,{type:`button`,variant:`ghost`,children:t.cancel})}),(0,z.jsx)(y,{type:`submit`,variant:`primary`,disabled:K||!J.trim()||!X.trim(),children:K?t.home.creating:t.create})]})]})]})]})}),Z.hasNativePicker?null:(0,z.jsx)(x,{open:Z.modalOpen,onOpenChange:Z.setModalOpen,initialAbsolutePath:X||void 0,onConfirm:Z.confirmPick,wd:r}),(0,z.jsxs)(`section`,{className:`flex min-h-10 flex-wrap items-center justify-between gap-3`,"aria-label":n.filterLabel,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,"aria-live":`polite`,children:Se}),(0,z.jsxs)(`div`,{className:l(`ml-auto flex min-w-0 items-center justify-end gap-2`,V&&`w-full sm:w-auto`),children:[V?(0,z.jsxs)(`div`,{className:`relative min-w-0 flex-1 sm:w-64 sm:flex-none`,children:[(0,z.jsx)(T,{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`,{autoFocus:!0,className:`h-11 w-full rounded-lg border border-edge bg-surface-panel pl-9 pr-12 text-base sm:h-9 sm:text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:L,onChange:e=>B(e.target.value),placeholder:t.searchPlaceholder,"aria-label":t.searchPlaceholder}),(0,z.jsx)(`button`,{type:`button`,className:`touch-target absolute right-0 top-1/2 flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg`,onClick:()=>{B(``),H(!1)},"aria-label":n.clearSearch,title:n.clearSearch,children:(0,z.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})})]}):(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,onClick:()=>H(!0),"aria-label":t.searchPlaceholder,title:t.searchPlaceholder,children:(0,z.jsx)(T,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsx)(a,{className:`w-28 sm:w-32`,triggerClassName:`h-9 border-edge bg-surface-panel px-2.5 text-xs font-medium`,contentClassName:`min-w-36`,align:`end`,value:U,"aria-label":n.filterLabel,onChange:e=>se(e.target.value),children:be.map(e=>(0,z.jsx)(o,{value:e.id,children:e.label},e.id))})]})]}),M?(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:M}),(0,z.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Q(),children:t.home.retry})]}):null,O?(0,z.jsx)(ae,{}):$.length?(0,z.jsx)(`section`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>(0,z.jsx)(oe,{project:e,busy:ce===e.id,onTogglePin:()=>void ye(e,`pin`),onToggleArchive:()=>void ye(e,`archive`)},e.id))}):(0,z.jsxs)(`section`,{className:`py-16 text-center`,children:[(0,z.jsx)(ee,{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{U 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{f as i,g as a,t as o}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./cn-JdwAhgNB.js";import{c as u,n as d}from"./locale-store-DA0Z5jM_.js";import{t as f}from"./messages-4BtQKYlM.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{t as y}from"./copy-to-clipboard-HOJ79TWv.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CS04eWY9.js";import{n as S,r as C}from"./gateway-config-swr-DUDX42qY.js";import{i as w,o as T}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Au as E,Ct as D,Hl as O,Ic as k,Ju as A,Li as j,Mu as M,Qc as N,Qi as P,St as F,Tt as I,_t as L,bo as R,ec as z,fl as ee,gc as B,ic as V,iu as H,kl as te,kt as ne,na as re,vc as U,vt as ie,wc as W,xu as ae,yt as oe}from"./index-DxYitLp8.js";import{n as G,r as K,t as q}from"./settings-page-layout-D3Spald3.js";import{n as J,r as se,t as ce}from"./settings-form-section-BqzOqonM.js";import{S as Y,a as le,b as ue,c as de,g as fe,i as pe,n as me,o as he,r as ge,s as _e,t as X,x as ve,y as ye}from"./tunnel-api-CTuwTdMm.js";import{t as be}from"./page-tabs-CMlQUzT6.js";import{t as xe}from"./settings-advanced-gate-whpUsAy3.js";var Z=e(t(),1),Q=n(),$=r();function Se(e){switch(e){case`active`:return`text-emerald-700 dark:text-emerald-400`;case`connecting`:return`text-amber-700 dark:text-amber-400`;default:return`text-fg-muted`}}function Ce(e){let t=(0,Q.c)(11),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=l(`inline-flex items-center gap-1.5 text-xs font-medium`,Se(r)),t[0]=r,t[1]=i);let a=r===`active`&&`bg-emerald-500`,o=r===`connecting`&&`bg-amber-500`,s;t[2]!==a||t[3]!==o?(s=l(`size-1.5 rounded-full bg-fg-subtle/50`,a,o),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`span`,{className:s,"aria-hidden":!0}),t[5]=s,t[6]=c);let u;return t[7]!==n||t[8]!==i||t[9]!==c?(u=(0,$.jsxs)(`span`,{className:i,children:[c,n]}),t[7]=n,t[8]=i,t[9]=c,t[10]=u):u=t[10],u}function we(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=d(Ee),i;t[0]===r?i=t[1]:(i=f(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!u(Te),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=b(o?`exposure-status`:null,ve,s),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:15e3},t[3]=p):p=t[3];let{data:m}=b(o?`tunnel-status`:null,me,p),h=C(o);if(!o)return null;let g=c?.tailscale.active===!0,_=m?.state,v=m?.enabled&&_===`connected`,y=m?.enabled&&(_===`connecting`||_===`reconnecting`||!!m?.startProgress||!!m?.frpcDownload),x=h.data?.payload?.config,S=!!(x&&typeof x==`object`&&!Array.isArray(x)&&x.gateway?.publicUrl),w=g?`active`:`off`,T=g?a.statusActive:a.statusOff,E;t[4]!==a.tailscaleCardTitle||t[5]!==w||t[6]!==T?(E={tab:`tailscale`,icon:O,title:a.tailscaleCardTitle,kind:w,statusLabel:T},t[4]=a.tailscaleCardTitle,t[5]=w,t[6]=T,t[7]=E):E=t[7];let D=v?`active`:y?`connecting`:`off`,k=v?a.statusActive:y?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==D||t[10]!==k?(A={tab:`public`,icon:N,title:a.publicCardTitle,kind:D,statusLabel:k},t[8]=a.publicCardTitle,t[9]=D,t[10]=k,t[11]=A):A=t[11];let j=S?`active`:`off`,M=S?a.statusActive:a.statusOff,P;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==M?(P={tab:`reverse-proxy`,icon:U,title:a.reverseProxyCardTitle,kind:j,statusLabel:M},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=M,t[15]=P):P=t[15];let F;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(F={tab:`ssh`,icon:V,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=F):F=t[18];let I;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(I={tab:`lan`,icon:W,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=I):I=t[21];let L;t[22]!==P||t[23]!==F||t[24]!==I||t[25]!==E||t[26]!==A?(L=[E,A,P,F,I],t[22]=P,t[23]=F,t[24]=I,t[25]=E,t[26]=A,t[27]=L):L=t[27];let R=L,z;return t[28]!==R||t[29]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-1 rounded-xl bg-surface-hover/20 p-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:R.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:l(`flex items-start gap-3 rounded-lg bg-surface-base/45 px-2 py-3 text-left transition-colors`,`hover:bg-surface-hover/30`,`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 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)(Ce,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=R,t[29]=n,t[30]=z):z=t[30],z}function Te(e){return e.conversationId}function Ee(e){return e.language}function De(e){let t=(0,Q.c)(21),{title:n,description:r,recommended:i,icon:a,onOpen:o,recommendedLabel:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=l(`group flex w-full items-start gap-3 px-3 py-4 text-left transition-colors`,`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=c):c=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let d;t[3]===n?d=t[4]:(d=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=d);let f;t[5]!==i||t[6]!==s?(f=i&&s?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:s}):null,t[5]=i,t[6]=s,t[7]=f):f=t[7];let p;t[8]!==d||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(E,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;return t[17]!==o||t[18]!==u||t[19]!==h?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:c,children:[u,h,g]}),t[17]=o,t[18]=u,t[19]=h,t[20]=_):_=t[20],_}function Oe(e){let t=(0,Q.c)(74),{onOpenTab:n}=e,r=d(je),i;t[0]===r?i=t[1]:(i=f(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!u(Ae),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=b(s?`exposure-status`:null,ve,c),p;t[3]===l?.conflicts?p=t[4]:(p=l?.conflicts??[],t[3]=l?.conflicts,t[4]=p);let m=p;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)(we,{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 bg-amber-500/10 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(ke)})]}):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 v;t[15]===n?v=t[16]:(v=()=>n(`tailscale`),t[15]=n,t[16]=v);let y;t[17]!==o.recommended||t[18]!==o.tailscaleCardDesc||t[19]!==o.tailscaleCardTitle||t[20]!==v?(y=(0,$.jsx)(De,{icon:O,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,onOpen:v}),t[17]=o.recommended,t[18]=o.tailscaleCardDesc,t[19]=o.tailscaleCardTitle,t[20]=v,t[21]=y):y=t[21];let x;t[22]===n?x=t[23]:(x=()=>n(`public`),t[22]=n,t[23]=x);let S;t[24]!==o.publicCardDesc||t[25]!==o.publicCardTitle||t[26]!==x?(S=(0,$.jsx)(De,{icon:N,title:o.publicCardTitle,description:o.publicCardDesc,onOpen:x}),t[24]=o.publicCardDesc,t[25]=o.publicCardTitle,t[26]=x,t[27]=S):S=t[27];let C;t[28]===n?C=t[29]:(C=()=>n(`reverse-proxy`),t[28]=n,t[29]=C);let w;t[30]!==o.reverseProxyCardDesc||t[31]!==o.reverseProxyCardTitle||t[32]!==C?(w=(0,$.jsx)(De,{icon:U,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,onOpen:C}),t[30]=o.reverseProxyCardDesc,t[31]=o.reverseProxyCardTitle,t[32]=C,t[33]=w):w=t[33];let T;t[34]===n?T=t[35]:(T=()=>n(`ssh`),t[34]=n,t[35]=T);let E;t[36]!==o.sshCardDesc||t[37]!==o.sshCardTitle||t[38]!==T?(E=(0,$.jsx)(De,{icon:V,title:o.sshCardTitle,description:o.sshCardDesc,onOpen:T}),t[36]=o.sshCardDesc,t[37]=o.sshCardTitle,t[38]=T,t[39]=E):E=t[39];let D;t[40]===n?D=t[41]:(D=()=>n(`lan`),t[40]=n,t[41]=D);let k;t[42]!==o.lanCardDesc||t[43]!==o.lanCardTitle||t[44]!==D?(k=(0,$.jsx)(De,{icon:W,title:o.lanCardTitle,description:o.lanCardDesc,onOpen:D}),t[42]=o.lanCardDesc,t[43]=o.lanCardTitle,t[44]=D,t[45]=k):k=t[45];let A;t[46]!==S||t[47]!==w||t[48]!==E||t[49]!==k||t[50]!==y?(A=(0,$.jsxs)(`div`,{className:`mt-2 flex max-w-3xl flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[y,S,w,E,k]}),t[46]=S,t[47]=w,t[48]=E,t[49]=k,t[50]=y,t[51]=A):A=t[51];let j;t[52]!==A||t[53]!==_?(j=(0,$.jsxs)(`div`,{children:[_,A]}),t[52]=A,t[53]=_,t[54]=j):j=t[54];let M;t[55]===o.oneAtATimeHint?M=t[56]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[55]=o.oneAtATimeHint,t[56]=M);let P;t[57]===a.advanced.proxyTitle?P=t[58]:(P=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[57]=a.advanced.proxyTitle,t[58]=P);let F;t[59]===a.advanced.proxyBody?F=t[60]:(F=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[59]=a.advanced.proxyBody,t[60]=F);let I;t[61]!==r||t[62]!==a.advanced.proxyDocs?(I=(0,$.jsx)(Y,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[61]=r,t[62]=a.advanced.proxyDocs,t[63]=I):I=t[63];let L;t[64]!==P||t[65]!==F||t[66]!==I?(L=(0,$.jsxs)(`div`,{className:`max-w-3xl rounded-xl bg-surface-hover/20 px-4 py-4`,children:[P,F,I]}),t[64]=P,t[65]=F,t[66]=I,t[67]=L):L=t[67];let R;return t[68]!==j||t[69]!==M||t[70]!==L||t[71]!==h||t[72]!==g?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,j,M,L]}),t[68]=j,t[69]=M,t[70]=L,t[71]=h,t[72]=g,t[73]=R):R=t[73],R}function ke(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Ae(e){return e.conversationId}function je(e){return e.language}function Me(){let e=(0,Q.c)(16),t=d(Ne),n;e[0]===t?n=e[1]:(n=f(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(J,{icon:W,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let l;e[10]!==a||e[11]!==c?(l=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=l):l=e[12];let u;return e[13]!==i||e[14]!==l?(u=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(ce,{children:[i,l]})}),e[13]=i,e[14]=l,e[15]=u):u=e[15],u}function Ne(e){return e.language}function Pe(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=d(Fe),a;t[0]===i?a=t[1]:(a=f(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,l]=(0,Z.useState)(!1),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=async()=>{await y(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(l(!0),setTimeout(()=>l(!1),2e3))},t[2]=u):u=t[2];let p=u,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-base/55 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 p(),g=(0,$.jsx)(c,{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 b;t[8]!==r||t[9]!==o.hint?(b=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]=b):b=t[10];let S;t[11]!==v||t[12]!==b?(S=(0,$.jsxs)($.Fragment,{children:[m,v,b]}),t[11]=v,t[12]=b,t[13]=S):S=t[13];let C=S;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(J,{icon:V,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===C?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:C}),t[17]=C,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ce,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let w;t[22]!==o.subtitle||t[23]!==o.title?(w=(0,$.jsx)(J,{icon:V,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:C}),t[25]=C,t[26]=T);let E;return t[27]!==w||t[28]!==T?(E=(0,$.jsxs)(ce,{children:[w,T]}),t[27]=w,t[28]=T,t[29]=E):E=t[29],E}function Fe(e){return e.language}function Ie(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Pe,{embedded:!0}),e[0]=t):t=e[0],t}var Le=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Re(e){return e&&Le.includes(e)?e:`guide`}function ze(e){let t=(0,Q.c)(32),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:u}=e,d=u===void 0?!1:u,[f,p]=(0,Z.useState)(c??!1),m;t[0]===s?m=t[1]:(m=l(`rounded-xl bg-surface-hover/20`,s),t[0]=s,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>p(Be),t[2]=h):h=t[2];let g=f&&`rotate-180`,_;t[3]===g?_=t[4]:(_=l(`size-4 shrink-0 text-fg-muted transition-transform duration-200 motion-reduce:transition-none`,g),t[3]=g,t[4]=_);let v;t[5]===_?v=t[6]:(v=(0,$.jsx)(M,{className:_,"aria-hidden":!0}),t[5]=_,t[6]=v);let y;t[7]===i?y=t[8]:(y=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[7]=i,t[8]=y);let b=f?r:n,x;t[9]===b?x=t[10]:(x=(0,$.jsx)(`span`,{children:b}),t[9]=b,t[10]=x);let S;t[11]!==f||t[12]!==v||t[13]!==y||t[14]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":f,onClick:h,className:`flex w-full items-center gap-2 rounded-2xl px-4 py-3.5 text-left text-sm font-medium text-fg transition-colors hover:text-fg`,children:[v,y,x]}),t[11]=f,t[12]=v,t[13]=y,t[14]=x,t[15]=S):S=t[15];let C=f?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,w;t[16]===C?w=t[17]:(w=l(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,C),t[16]=C,t[17]=w);let T;t[18]===a?T=t[19]:(T=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[18]=a,t[19]=T);let E;t[20]!==o||t[21]!==T?(E=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[T,o]})}),t[20]=o,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==w||t[24]!==E?(D=(0,$.jsx)(`div`,{className:w,children:E}),t[23]=w,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==S||t[27]!==D||t[28]!==m?(O=(0,$.jsxs)(`section`,{className:m,children:[S,D]}),t[26]=S,t[27]=D,t[28]=m,t[29]=O):O=t[29];let k=O;if(d){let e;return t[30]===k?e=t[31]:(e=(0,$.jsx)(xe,{children:k}),t[30]=k,t[31]=e),e}return k}function Be(e){return!e}function Ve(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:u,onCancel:d}=e,[f,y]=(0,Z.useState)(!1),b;t[0]===d?b=t[1]:(b=e=>{e||(y(!1),d())},t[0]=d,t[1]=b);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(p,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,T)}),t[2]=S):S=t[2];let C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=l(`xopc-dialog-content 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-overlay p-6 shadow-popover outline-none dark:border-edge`,w),t[3]=C):C=t[3];let E;t[4]===r?E=t[5]:(E=(0,$.jsx)(_,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=E);let D;t[6]===i?D=t[7]:(D=(0,$.jsx)(m,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=D);let O;t[8]===a?O=t[9]:(O=a.map(He),t[8]=a,t[9]=O);let k;t[10]===O?k=t[11]:(k=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:O}),t[10]=O,t[11]=k);let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>y(e.target.checked),t[12]=A):A=t[12];let j;t[13]===f?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:A}),t[13]=f,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==c||t[21]!==d?(P=(0,$.jsx)(x,{type:`button`,variant:`secondary`,onClick:d,children:c}),t[20]=c,t[21]=d,t[22]=P):P=t[22];let F=!f,I;t[23]!==s||t[24]!==u||t[25]!==F?(I=(0,$.jsx)(x,{type:`button`,disabled:F,onClick:u,children:s}),t[23]=s,t[24]=u,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==E||t[33]!==D||t[34]!==k?(R=(0,$.jsxs)(h,{children:[S,(0,$.jsxs)(g,{className:C,onOpenAutoFocus:Ue,children:[E,D,k,N,L]})]}),t[30]=N,t[31]=L,t[32]=E,t[33]=D,t[34]=k,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==b||t[38]!==R?(z=(0,$.jsx)(v,{open:n,onOpenChange:b,children:R}),t[36]=n,t[37]=b,t[38]=R,t[39]=z):z=t[39],z}function He(e){return(0,$.jsx)(`li`,{children:e},e)}function Ue(e){return e.preventDefault()}function We(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ge=[`preparing_frpc`,`registering`,`starting_frpc`];function Ke(e){return e?e===`reconnecting_frpc`?Ge.indexOf(`starting_frpc`):Ge.indexOf(e):-1}function qe(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ge.indexOf(e),i=Ke(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Je(e,t,n){let r=n.startProgress;return qe(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 Ye(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Xe(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 Ze(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(Qe),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==o?(c=[n.state,o],t[3]=n.state,t[4]=o,t[5]=c):c=t[5],(0,Z.useEffect)(a,c),!(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=Xe(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 o=Ge.map(e=>{let t=qe(e,n),i=Je(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)(ee,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(ae,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:l(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ye(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:l(`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:[We(n.frpcDownload.bytesReceived),` /`,` `,We(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]===o?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,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 Qe(e){return e+1}function $e(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 et(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function tt(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 nt(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 rt(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,b,S,C,w;t[0]!==r||t[1]!==o?(w=et(r),_=r.enabled||o,v=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=l(se(),`space-y-4`),t[9]=C):C=t[9],S=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=l(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,tt(w)),t[0]=r,t[1]=o,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=S,t[7]=C,t[8]=w):(_=t[2],v=t[3],y=t[4],b=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`,A=w===`off`&&`bg-fg-subtle`,M;t[10]!==T||t[11]!==E||t[12]!==D||t[13]!==A?(M=l(`size-1.5 rounded-full`,T,E,D,A),t[10]=T,t[11]=E,t[12]=D,t[13]=A,t[14]=M):M=t[14];let N;t[15]===M?N=t[16]:(N=(0,$.jsx)(`span`,{className:M,"aria-hidden":!0}),t[15]=M,t[16]=N);let P;t[17]!==i||t[18]!==r||t[19]!==n?(P=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`}):$e(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=P):P=t[20];let F;t[21]!==N||t[22]!==P||t[23]!==y?(F=(0,$.jsxs)(`span`,{className:y,children:[N,P]}),t[21]=N,t[22]=P,t[23]=y,t[24]=F):F=t[24];let I;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(I=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,nt(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=I):I=t[28];let L;t[29]!==F||t[30]!==I||t[31]!==b?(L=(0,$.jsxs)(`div`,{className:b,children:[F,I]}),t[29]=F,t[30]=I,t[31]=b,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(O,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=R):R=t[33];let B;t[34]!==L||t[35]!==S?(B=(0,$.jsxs)(`div`,{className:S,children:[L,R]}),t[34]=L,t[35]=S,t[36]=B):B=t[36];let V;t[37]===a?V=t[38]:(V=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]=V);let H;t[39]!==c||t[40]!==n.consentExpiredBanner?(H=c?(0,$.jsx)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=H):H=t[41];let te;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]!==o||t[51]!==p||t[52]!==s||t[53]!==n?(te=_?(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)(j,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Ze,{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:s,onClick:h,children:[s?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(x,{type:`button`,disabled:o,onClick:m,children:[o?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{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 bg-amber-500/10 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(z,{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:o||g,onClick:m,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{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]=o,t[51]=p,t[52]=s,t[53]=n,t[54]=te):te=t[54];let ne;return t[55]!==B||t[56]!==V||t[57]!==H||t[58]!==te||t[59]!==C?(ne=(0,$.jsxs)(`section`,{className:C,children:[B,V,H,te]}),t[55]=B,t[56]=V,t[57]=H,t[58]=te,t[59]=C,t[60]=ne):ne=t[60],ne}var it={reconfiguring:!1};function at(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:c,authorizingBrokerSecret:u,brokerSecretAuthorizationUrl:d,brokerSecretNotice:f,copyFailedLabel:p,onDraftChange:m,onSave:h,onAuthorize:g,onClear:_,sectionRef:v}=e,y=(0,Z.useId)(),b=r,S=!b,[C,w]=(0,Z.useReducer)(re,it),{reconfiguring:T}=C,E;t[0]!==i||t[1]!==o||t[2]!==T?(E=i&&!T&&!o.trim(),t[0]=i,t[1]=o,t[2]=T,t[3]=E):E=t[3];let D=E,O;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(O={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=O):O=t[8];let k=O,A;t[9]===o?A=t[10]:(A=o.trim().length>0&&!ne(o.trim()),t[9]=o,t[10]=A);let j=A,M;t[11]===m?M=t[12]:(M=()=>{w({type:`patch`,patch:{reconfiguring:!1}}),m(``)},t[11]=m,t[12]=M);let N=M,P=S&&`ring-1 ring-amber-500/30`,F;t[13]===P?F=t[14]:(F=l(P),t[13]=P,t[14]=F);let I=b?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:S?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,L;t[15]===I?L=t[16]:(L=l(`flex size-9 shrink-0 items-center justify-center rounded-lg`,I),t[15]=I,t[16]=L);let z;t[17]===b?z=t[18]:(z=b?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=b,t[18]=z);let B;t[19]!==L||t[20]!==z?(B=(0,$.jsx)(`span`,{className:L,children:z}),t[19]=L,t[20]=z,t[21]=B):B=t[21];let V=b?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,U;t[22]===V?U=t[23]:(U=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:V}),t[22]=V,t[23]=U);let ie=b?n.brokerSecretReadyHint:n.brokerSecretHint,W;t[24]===ie?W=t[25]:(W=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:ie}),t[24]=ie,t[25]=W);let ae;t[26]!==S||t[27]!==n.brokerSecretMissingHint?(ae=S?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=S,t[27]=n.brokerSecretMissingHint,t[28]=ae):ae=t[28];let oe;t[29]!==U||t[30]!==W||t[31]!==ae?(oe=(0,$.jsxs)(`div`,{children:[U,W,ae]}),t[29]=U,t[30]=W,t[31]=ae,t[32]=oe):oe=t[32];let G;t[33]!==u||t[34]!==S||t[35]!==g||t[36]!==T||t[37]!==c||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(G=S||T?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(x,{type:`button`,disabled:c||u,onClick:g,children:[u?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,u?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:X,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,(0,$.jsx)(H,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=u,t[34]=S,t[35]=g,t[36]=T,t[37]=c,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=G):G=t[41];let K;t[42]!==u||t[43]!==d||t[44]!==n.brokerSecretOpenAuthorization?(K=u&&d?(0,$.jsxs)(`a`,{href:d,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(H,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=u,t[43]=d,t[44]=n.brokerSecretOpenAuthorization,t[45]=K):K=t[45];let q;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==j||t[50]!==N||t[51]!==p||t[52]!==y||t[53]!==S||t[54]!==_||t[55]!==m||t[56]!==h||t[57]!==T||t[58]!==c||t[59]!==k||t[60]!==D||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(q=D?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:y,children:n.brokerSecretTitle}),(0,$.jsx)(R,{id:y,value:a,labels:k,reveal:ot,loadFailedLabel:p||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:c,onClick:()=>{w({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:c,onClick:_,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:y,children:n.brokerSecretTitle}),(0,$.jsx)(R,{id:y,value:o,onChange:m,placeholder:n.brokerSecretPlaceholder,labels:k,disabled:c}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(x,{type:`button`,disabled:c||!j,onClick:h,children:[c?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,S?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:c,onClick:_,children:n.brokerSecretClear}):null,T?(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:c,onClick:N,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=j,t[50]=N,t[51]=p,t[52]=y,t[53]=S,t[54]=_,t[55]=m,t[56]=h,t[57]=T,t[58]=c,t[59]=k,t[60]=D,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=q):q=t[71];let J;t[72]===f?J=t[73]:(J=f?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:f}):null,t[72]=f,t[73]=J);let se;t[74]!==oe||t[75]!==G||t[76]!==K||t[77]!==q||t[78]!==J?(se=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[oe,G,K,q,J]}),t[74]=oe,t[75]=G,t[76]=K,t[77]=q,t[78]=J,t[79]=se):se=t[79];let Y;t[80]!==B||t[81]!==se?(Y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[B,se]}),t[80]=B,t[81]=se,t[82]=Y):Y=t[82];let le;t[83]!==Y||t[84]!==F?(le=(0,$.jsx)(ce,{className:F,children:Y}),t[83]=Y,t[84]=F,t[85]=le):le=t[85];let ue;return t[86]!==v||t[87]!==le?(ue=(0,$.jsx)(`div`,{ref:v,id:`tunnel-broker-secret-setup`,children:le}),t[86]=v,t[87]=le,t[88]=ue):ue=t[88],ue}function ot(){return he().then(st)}function st(e){return e.registrationSecret??null}var ct={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function lt({embedded:e=!1}){let t=d(e=>e.language),n=f(t).tunnelSettings,r=!!u(e=>e.conversationId),[i,a]=(0,Z.useReducer)(re,ct),{actionError:o,starting:s,stopping:c,savingAutoStart:p,consentOpen:m,autoStartConfirmOpen:h,releaseConfirmOpen:g,releasing:_,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:w,brokerSecretAuthorizationUrl:T,brokerSecretNotice:E}=i,k=(0,Z.useRef)(null),{data:A}=C(r),{data:j,error:M,isLoading:N,mutate:R}=b(r?`tunnel-status`:null,me,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),z=(0,Z.useMemo)(()=>{let e=A?.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 j?.config?.autoStart===!0},[A,j?.config?.autoStart]),B=(0,Z.useMemo)(()=>{let e=A?.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``},[A]),V=ne(B),H=j?.registrationSecret?.configured??V;(0,Z.useEffect)(()=>{let e=()=>{R()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[R]);let te=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),U=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await _e(),await R(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[R]),W=(0,Z.useCallback)(()=>{if(!H){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),k.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(j?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}U()},[H,j?.consentRequired,U,n.brokerSecretRequiredBeforeStart]),ae=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await le(),await Promise.all([R(),U()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[R,U]),G=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await de(),await R(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[R]),K=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await ge({autoStart:e}),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Z.useCallback)(()=>{if(z){K(!1);return}if(j?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!j?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,j?.canAutoStart,j?.consentRequired,n,z]),J=(0,Z.useCallback)(async()=>{let e=v.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ge({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),S(),await R(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[v,R,n.brokerSecretSaved]),se=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ge({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),S(),await R()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[R,n.brokerSecretCleared]),ue=(0,Z.useCallback)(async()=>{let e=oe(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await I(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await D(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await ie(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await pe(),await Promise.all([R(),S()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{L(e),t&&F(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[R,n.brokerSecretSaved]),fe=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await de({release:!0}),await R(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[R]),he=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:f(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)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 X=j??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:z,brokerUrl:`https://frp.xopc.ai/api`}},ve=j?.consentRequired&&(X.enabled||z||j?.consent?.acceptedAt),ye=(0,$.jsx)(at,{t:n,brokerSecretReady:H,brokerSecretConfiguredInConfig:V,brokerSecretMaskedValue:V?B:``,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:w,brokerSecretAuthorizationUrl:T,brokerSecretNotice:E,copyFailedLabel:f(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void J(),onAuthorize:()=>void ue(),onClear:()=>void se(),sectionRef:k}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ve,{open:m,title:n.consentTitle,intro:n.consentIntro,bullets:te,checkboxLabel:n.consentCheckbox,confirmLabel:ve?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void ae(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},m?`consent-open`:`consent-closed`),(0,$.jsx)(P,{open:h,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(P,{open:g,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void fe(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(rt,{t:n,status:X,isLoading:N,statusErr:M,starting:s,stopping:c,showConsentExpired:!!ve,copyLabels:he,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:W,onStop:()=>void G()}),(0,$.jsxs)(ze,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:l(`flex items-center gap-3 text-sm text-fg`,!z&&!j?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:p||!z&&!j?.canAutoStart,onChange:q}),n.autoStart]}),!j?.canAutoStart&&!z?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ze,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-base/45 p-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Y,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(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})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(rt,{t:n,status:X,isLoading:N,statusErr:M,starting:s,stopping:c,showConsentExpired:!!ve,copyLabels:he,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,onStart:W,onStop:()=>void G()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ce,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:l(`flex items-center gap-3 text-sm text-fg`,!z&&!j?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:p||!z&&!j?.canAutoStart,onChange:q}),n.autoStart]}),!j?.canAutoStart&&!z?(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)(O,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Y,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function ut(e,t){return e.tabs[t]}function dt(e,t){return e.tabIntro[t]}function ft(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 pt(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Oe,{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)(ue,{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)(lt,{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)(ye,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ie,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Me,{}),t[6]=e):e=t[6],e}}}function mt(){let e=(0,Q.c)(3),t=i(),n=d(gt),r=f(n).remoteAccess,o=!!u(ht),[s,c]=a(),l=Re(s.get(`tab`)),p=s.get(`intent`)===`mobile-pairing`,m;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={refreshInterval:2e3},e[0]=m):m=e[0];let h=b(p?`device-pairing-readiness`:null,fe,m),g;e[1]===c?g=e[2]:(g=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=g);let _=g,v=dt(r,l),y=Le.map(e=>({id:e,label:ut(r,e)}));return(0,$.jsxs)(K,{children:[(0,$.jsx)(G,{title:r.pageTitle,meta:(0,$.jsx)(Y,{language:n,label:r.docsLink,section:ft(l),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[p?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(B,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:h.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(x,{variant:`primary`,disabled:!h.data?.ready,onClick:()=>t(`/settings/devices?startDevicePairing=mobile`),children:[h.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(be,{items:y,activeTab:l,onChange:_,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(q,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:ut(r,l),hint:l===`public`?void 0:v,showHeading:!1,framed:!1,children:(0,$.jsx)(pt,{tab:l,onOpenTab:_})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function ht(e){return e.conversationId}function gt(e){return e.language}export{mt 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{f as i,g as a,t as o}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./cn-JdwAhgNB.js";import{c as u,n as d}from"./locale-store-DA0Z5jM_.js";import{t as f}from"./messages-4BtQKYlM.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{t as y}from"./copy-to-clipboard-HOJ79TWv.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CS04eWY9.js";import{n as S,r as C}from"./gateway-config-swr-DUDX42qY.js";import{i as w,o as T}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{Au as E,Ct as D,Hl as O,Ic as k,Ju as A,Li as j,Mu as M,Qc as N,Qi as P,St as F,Tt as I,_t as L,bo as R,ec as z,fl as ee,gc as B,ic as V,iu as H,kl as te,kt as ne,na as re,vc as U,vt as ie,wc as W,xu as ae,yt as oe}from"./index-PFQHPGgi.js";import{n as G,r as K,t as q}from"./settings-page-layout-DqNCGKxQ.js";import{n as J,r as se,t as ce}from"./settings-form-section-BAaVyxJH.js";import{S as Y,a as le,b as ue,c as de,g as fe,i as pe,n as me,o as he,r as ge,s as _e,t as X,x as ve,y as ye}from"./tunnel-api-BasDYxvx.js";import{t as be}from"./page-tabs-B6DjkyMM.js";import{t as xe}from"./settings-advanced-gate-CBX0Ezhf.js";var Z=e(t(),1),Q=n(),$=r();function Se(e){switch(e){case`active`:return`text-emerald-700 dark:text-emerald-400`;case`connecting`:return`text-amber-700 dark:text-amber-400`;default:return`text-fg-muted`}}function Ce(e){let t=(0,Q.c)(11),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=l(`inline-flex items-center gap-1.5 text-xs font-medium`,Se(r)),t[0]=r,t[1]=i);let a=r===`active`&&`bg-emerald-500`,o=r===`connecting`&&`bg-amber-500`,s;t[2]!==a||t[3]!==o?(s=l(`size-1.5 rounded-full bg-fg-subtle/50`,a,o),t[2]=a,t[3]=o,t[4]=s):s=t[4];let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`span`,{className:s,"aria-hidden":!0}),t[5]=s,t[6]=c);let u;return t[7]!==n||t[8]!==i||t[9]!==c?(u=(0,$.jsxs)(`span`,{className:i,children:[c,n]}),t[7]=n,t[8]=i,t[9]=c,t[10]=u):u=t[10],u}function we(e){let t=(0,Q.c)(31),{onOpenTab:n}=e,r=d(Ee),i;t[0]===r?i=t[1]:(i=f(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!u(Te),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=b(o?`exposure-status`:null,ve,s),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:15e3},t[3]=p):p=t[3];let{data:m}=b(o?`tunnel-status`:null,me,p),h=C(o);if(!o)return null;let g=c?.tailscale.active===!0,_=m?.state,v=m?.enabled&&_===`connected`,y=m?.enabled&&(_===`connecting`||_===`reconnecting`||!!m?.startProgress||!!m?.frpcDownload),x=h.data?.payload?.config,S=!!(x&&typeof x==`object`&&!Array.isArray(x)&&x.gateway?.publicUrl),w=g?`active`:`off`,T=g?a.statusActive:a.statusOff,E;t[4]!==a.tailscaleCardTitle||t[5]!==w||t[6]!==T?(E={tab:`tailscale`,icon:O,title:a.tailscaleCardTitle,kind:w,statusLabel:T},t[4]=a.tailscaleCardTitle,t[5]=w,t[6]=T,t[7]=E):E=t[7];let D=v?`active`:y?`connecting`:`off`,k=v?a.statusActive:y?a.statusConnecting:a.statusOff,A;t[8]!==a.publicCardTitle||t[9]!==D||t[10]!==k?(A={tab:`public`,icon:N,title:a.publicCardTitle,kind:D,statusLabel:k},t[8]=a.publicCardTitle,t[9]=D,t[10]=k,t[11]=A):A=t[11];let j=S?`active`:`off`,M=S?a.statusActive:a.statusOff,P;t[12]!==a.reverseProxyCardTitle||t[13]!==j||t[14]!==M?(P={tab:`reverse-proxy`,icon:U,title:a.reverseProxyCardTitle,kind:j,statusLabel:M},t[12]=a.reverseProxyCardTitle,t[13]=j,t[14]=M,t[15]=P):P=t[15];let F;t[16]!==a.sshCardStatus||t[17]!==a.sshCardTitle?(F={tab:`ssh`,icon:V,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[16]=a.sshCardStatus,t[17]=a.sshCardTitle,t[18]=F):F=t[18];let I;t[19]!==a.lanCardStatus||t[20]!==a.lanCardTitle?(I={tab:`lan`,icon:W,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[19]=a.lanCardStatus,t[20]=a.lanCardTitle,t[21]=I):I=t[21];let L;t[22]!==P||t[23]!==F||t[24]!==I||t[25]!==E||t[26]!==A?(L=[E,A,P,F,I],t[22]=P,t[23]=F,t[24]=I,t[25]=E,t[26]=A,t[27]=L):L=t[27];let R=L,z;return t[28]!==R||t[29]!==n?(z=(0,$.jsx)(`div`,{className:`grid gap-1 rounded-xl bg-surface-hover/20 p-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:R.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:l(`flex items-start gap-3 rounded-lg bg-surface-base/45 px-2 py-3 text-left transition-colors`,`hover:bg-surface-hover/30`,`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 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)(Ce,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[28]=R,t[29]=n,t[30]=z):z=t[30],z}function Te(e){return e.conversationId}function Ee(e){return e.language}function De(e){let t=(0,Q.c)(21),{title:n,description:r,recommended:i,icon:a,onOpen:o,recommendedLabel:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=l(`group flex w-full items-start gap-3 px-3 py-4 text-left transition-colors`,`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=c):c=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let d;t[3]===n?d=t[4]:(d=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=d);let f;t[5]!==i||t[6]!==s?(f=i&&s?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:s}):null,t[5]=i,t[6]=s,t[7]=f):f=t[7];let p;t[8]!==d||t[9]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10];let m;t[11]===r?m=t[12]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=m);let h;t[13]!==p||t[14]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[p,m]}),t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(E,{className:`mt-2 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;return t[17]!==o||t[18]!==u||t[19]!==h?(_=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:c,children:[u,h,g]}),t[17]=o,t[18]=u,t[19]=h,t[20]=_):_=t[20],_}function Oe(e){let t=(0,Q.c)(74),{onOpenTab:n}=e,r=d(je),i;t[0]===r?i=t[1]:(i=f(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!u(Ae),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:l}=b(s?`exposure-status`:null,ve,c),p;t[3]===l?.conflicts?p=t[4]:(p=l?.conflicts??[],t[3]=l?.conflicts,t[4]=p);let m=p;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)(we,{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 bg-amber-500/10 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(ke)})]}):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 v;t[15]===n?v=t[16]:(v=()=>n(`tailscale`),t[15]=n,t[16]=v);let y;t[17]!==o.recommended||t[18]!==o.tailscaleCardDesc||t[19]!==o.tailscaleCardTitle||t[20]!==v?(y=(0,$.jsx)(De,{icon:O,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,onOpen:v}),t[17]=o.recommended,t[18]=o.tailscaleCardDesc,t[19]=o.tailscaleCardTitle,t[20]=v,t[21]=y):y=t[21];let x;t[22]===n?x=t[23]:(x=()=>n(`public`),t[22]=n,t[23]=x);let S;t[24]!==o.publicCardDesc||t[25]!==o.publicCardTitle||t[26]!==x?(S=(0,$.jsx)(De,{icon:N,title:o.publicCardTitle,description:o.publicCardDesc,onOpen:x}),t[24]=o.publicCardDesc,t[25]=o.publicCardTitle,t[26]=x,t[27]=S):S=t[27];let C;t[28]===n?C=t[29]:(C=()=>n(`reverse-proxy`),t[28]=n,t[29]=C);let w;t[30]!==o.reverseProxyCardDesc||t[31]!==o.reverseProxyCardTitle||t[32]!==C?(w=(0,$.jsx)(De,{icon:U,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,onOpen:C}),t[30]=o.reverseProxyCardDesc,t[31]=o.reverseProxyCardTitle,t[32]=C,t[33]=w):w=t[33];let T;t[34]===n?T=t[35]:(T=()=>n(`ssh`),t[34]=n,t[35]=T);let E;t[36]!==o.sshCardDesc||t[37]!==o.sshCardTitle||t[38]!==T?(E=(0,$.jsx)(De,{icon:V,title:o.sshCardTitle,description:o.sshCardDesc,onOpen:T}),t[36]=o.sshCardDesc,t[37]=o.sshCardTitle,t[38]=T,t[39]=E):E=t[39];let D;t[40]===n?D=t[41]:(D=()=>n(`lan`),t[40]=n,t[41]=D);let k;t[42]!==o.lanCardDesc||t[43]!==o.lanCardTitle||t[44]!==D?(k=(0,$.jsx)(De,{icon:W,title:o.lanCardTitle,description:o.lanCardDesc,onOpen:D}),t[42]=o.lanCardDesc,t[43]=o.lanCardTitle,t[44]=D,t[45]=k):k=t[45];let A;t[46]!==S||t[47]!==w||t[48]!==E||t[49]!==k||t[50]!==y?(A=(0,$.jsxs)(`div`,{className:`mt-2 flex max-w-3xl flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[y,S,w,E,k]}),t[46]=S,t[47]=w,t[48]=E,t[49]=k,t[50]=y,t[51]=A):A=t[51];let j;t[52]!==A||t[53]!==_?(j=(0,$.jsxs)(`div`,{children:[_,A]}),t[52]=A,t[53]=_,t[54]=j):j=t[54];let M;t[55]===o.oneAtATimeHint?M=t[56]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[55]=o.oneAtATimeHint,t[56]=M);let P;t[57]===a.advanced.proxyTitle?P=t[58]:(P=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[57]=a.advanced.proxyTitle,t[58]=P);let F;t[59]===a.advanced.proxyBody?F=t[60]:(F=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[59]=a.advanced.proxyBody,t[60]=F);let I;t[61]!==r||t[62]!==a.advanced.proxyDocs?(I=(0,$.jsx)(Y,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[61]=r,t[62]=a.advanced.proxyDocs,t[63]=I):I=t[63];let L;t[64]!==P||t[65]!==F||t[66]!==I?(L=(0,$.jsxs)(`div`,{className:`max-w-3xl rounded-xl bg-surface-hover/20 px-4 py-4`,children:[P,F,I]}),t[64]=P,t[65]=F,t[66]=I,t[67]=L):L=t[67];let R;return t[68]!==j||t[69]!==M||t[70]!==L||t[71]!==h||t[72]!==g?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[h,g,j,M,L]}),t[68]=j,t[69]=M,t[70]=L,t[71]=h,t[72]=g,t[73]=R):R=t[73],R}function ke(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Ae(e){return e.conversationId}function je(e){return e.language}function Me(){let e=(0,Q.c)(16),t=d(Ne),n;e[0]===t?n=e[1]:(n=f(t),e[0]=t,e[1]=n);let r=n.remoteAccess.lan,i;e[2]!==r.subtitle||e[3]!==r.title?(i=(0,$.jsx)(J,{icon:W,title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=i):i=e[4];let a;e[5]===r.body?a=e[6]:(a=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.body}),e[5]=r.body,e[6]=a);let s;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),e[7]=s):s=e[7];let c;e[8]===r.link?c=e[9]:(c=(0,$.jsxs)(o,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[r.link,s]}),e[8]=r.link,e[9]=c);let l;e[10]!==a||e[11]!==c?(l=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[a,c]}),e[10]=a,e[11]=c,e[12]=l):l=e[12];let u;return e[13]!==i||e[14]!==l?(u=(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(ce,{children:[i,l]})}),e[13]=i,e[14]=l,e[15]=u):u=e[15],u}function Ne(e){return e.language}function Pe(e){let t=(0,Q.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=d(Fe),a;t[0]===i?a=t[1]:(a=f(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[s,l]=(0,Z.useState)(!1),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=async()=>{await y(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(l(!0),setTimeout(()=>l(!1),2e3))},t[2]=u):u=t[2];let p=u,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-base/55 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 p(),g=(0,$.jsx)(c,{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 b;t[8]!==r||t[9]!==o.hint?(b=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]=b):b=t[10];let S;t[11]!==v||t[12]!==b?(S=(0,$.jsxs)($.Fragment,{children:[m,v,b]}),t[11]=v,t[12]=b,t[13]=S):S=t[13];let C=S;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(J,{icon:V,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===C?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:C}),t[17]=C,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(ce,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let w;t[22]!==o.subtitle||t[23]!==o.title?(w=(0,$.jsx)(J,{icon:V,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:C}),t[25]=C,t[26]=T);let E;return t[27]!==w||t[28]!==T?(E=(0,$.jsxs)(ce,{children:[w,T]}),t[27]=w,t[28]=T,t[29]=E):E=t[29],E}function Fe(e){return e.language}function Ie(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Pe,{embedded:!0}),e[0]=t):t=e[0],t}var Le=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Re(e){return e&&Le.includes(e)?e:`guide`}function ze(e){let t=(0,Q.c)(32),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:u}=e,d=u===void 0?!1:u,[f,p]=(0,Z.useState)(c??!1),m;t[0]===s?m=t[1]:(m=l(`rounded-xl bg-surface-hover/20`,s),t[0]=s,t[1]=m);let h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>p(Be),t[2]=h):h=t[2];let g=f&&`rotate-180`,_;t[3]===g?_=t[4]:(_=l(`size-4 shrink-0 text-fg-muted transition-transform duration-200 motion-reduce:transition-none`,g),t[3]=g,t[4]=_);let v;t[5]===_?v=t[6]:(v=(0,$.jsx)(M,{className:_,"aria-hidden":!0}),t[5]=_,t[6]=v);let y;t[7]===i?y=t[8]:(y=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[7]=i,t[8]=y);let b=f?r:n,x;t[9]===b?x=t[10]:(x=(0,$.jsx)(`span`,{children:b}),t[9]=b,t[10]=x);let S;t[11]!==f||t[12]!==v||t[13]!==y||t[14]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":f,onClick:h,className:`flex w-full items-center gap-2 rounded-2xl px-4 py-3.5 text-left text-sm font-medium text-fg transition-colors hover:text-fg`,children:[v,y,x]}),t[11]=f,t[12]=v,t[13]=y,t[14]=x,t[15]=S):S=t[15];let C=f?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,w;t[16]===C?w=t[17]:(w=l(`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,C),t[16]=C,t[17]=w);let T;t[18]===a?T=t[19]:(T=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[18]=a,t[19]=T);let E;t[20]!==o||t[21]!==T?(E=(0,$.jsx)(`div`,{className:`overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[T,o]})}),t[20]=o,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==w||t[24]!==E?(D=(0,$.jsx)(`div`,{className:w,children:E}),t[23]=w,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==S||t[27]!==D||t[28]!==m?(O=(0,$.jsxs)(`section`,{className:m,children:[S,D]}),t[26]=S,t[27]=D,t[28]=m,t[29]=O):O=t[29];let k=O;if(d){let e;return t[30]===k?e=t[31]:(e=(0,$.jsx)(xe,{children:k}),t[30]=k,t[31]=e),e}return k}function Be(e){return!e}function Ve(e){let t=(0,Q.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:u,onCancel:d}=e,[f,y]=(0,Z.useState)(!1),b;t[0]===d?b=t[1]:(b=e=>{e||(y(!1),d())},t[0]=d,t[1]=b);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(p,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,T)}),t[2]=S):S=t[2];let C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=l(`xopc-dialog-content 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-overlay p-6 shadow-popover outline-none dark:border-edge`,w),t[3]=C):C=t[3];let E;t[4]===r?E=t[5]:(E=(0,$.jsx)(_,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=E);let D;t[6]===i?D=t[7]:(D=(0,$.jsx)(m,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=D);let O;t[8]===a?O=t[9]:(O=a.map(He),t[8]=a,t[9]=O);let k;t[10]===O?k=t[11]:(k=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:O}),t[10]=O,t[11]=k);let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>y(e.target.checked),t[12]=A):A=t[12];let j;t[13]===f?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:f,onChange:A}),t[13]=f,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==c||t[21]!==d?(P=(0,$.jsx)(x,{type:`button`,variant:`secondary`,onClick:d,children:c}),t[20]=c,t[21]=d,t[22]=P):P=t[22];let F=!f,I;t[23]!==s||t[24]!==u||t[25]!==F?(I=(0,$.jsx)(x,{type:`button`,disabled:F,onClick:u,children:s}),t[23]=s,t[24]=u,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==E||t[33]!==D||t[34]!==k?(R=(0,$.jsxs)(h,{children:[S,(0,$.jsxs)(g,{className:C,onOpenAutoFocus:Ue,children:[E,D,k,N,L]})]}),t[30]=N,t[31]=L,t[32]=E,t[33]=D,t[34]=k,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==b||t[38]!==R?(z=(0,$.jsx)(v,{open:n,onOpenChange:b,children:R}),t[36]=n,t[37]=b,t[38]=R,t[39]=z):z=t[39],z}function He(e){return(0,$.jsx)(`li`,{children:e},e)}function Ue(e){return e.preventDefault()}function We(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Ge=[`preparing_frpc`,`registering`,`starting_frpc`];function Ke(e){return e?e===`reconnecting_frpc`?Ge.indexOf(`starting_frpc`):Ge.indexOf(e):-1}function qe(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Ge.indexOf(e),i=Ke(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Je(e,t,n){let r=n.startProgress;return qe(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 Ye(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function Xe(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 Ze(e){let t=(0,Q.c)(31),{status:n,t:r}=e,[,i]=(0,Z.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(Qe),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let o=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==o?(c=[n.state,o],t[3]=n.state,t[4]=o,t[5]=c):c=t[5],(0,Z.useEffect)(a,c),!(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=Xe(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 o=Ge.map(e=>{let t=qe(e,n),i=Je(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)(ee,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(ae,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:l(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ye(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:l(`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:[We(n.frpcDownload.bytesReceived),` /`,` `,We(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]===o?p=t[21]:(p=(0,$.jsx)(`ol`,{className:`space-y-2`,children:o}),t[20]=o,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 Qe(e){return e+1}function $e(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 et(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function tt(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 nt(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 rt(e){let t=(0,Q.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:u,startDisabled:d,startDisabledReason:f,stepLabel:p,onStart:m,onStop:h}=e,g=d===void 0?!1:d,_,v,y,b,S,C,w;t[0]!==r||t[1]!==o?(w=et(r),_=r.enabled||o,v=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(C=l(se(),`space-y-4`),t[9]=C):C=t[9],S=`flex flex-wrap items-start justify-between gap-3`,b=`flex items-center gap-2`,y=l(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,tt(w)),t[0]=r,t[1]=o,t[2]=_,t[3]=v,t[4]=y,t[5]=b,t[6]=S,t[7]=C,t[8]=w):(_=t[2],v=t[3],y=t[4],b=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`,A=w===`off`&&`bg-fg-subtle`,M;t[10]!==T||t[11]!==E||t[12]!==D||t[13]!==A?(M=l(`size-1.5 rounded-full`,T,E,D,A),t[10]=T,t[11]=E,t[12]=D,t[13]=A,t[14]=M):M=t[14];let N;t[15]===M?N=t[16]:(N=(0,$.jsx)(`span`,{className:M,"aria-hidden":!0}),t[15]=M,t[16]=N);let P;t[17]!==i||t[18]!==r||t[19]!==n?(P=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`}):$e(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=P):P=t[20];let F;t[21]!==N||t[22]!==P||t[23]!==y?(F=(0,$.jsxs)(`span`,{className:y,children:[N,P]}),t[21]=N,t[22]=P,t[23]=y,t[24]=F):F=t[24];let I;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(I=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,nt(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=I):I=t[28];let L;t[29]!==F||t[30]!==I||t[31]!==b?(L=(0,$.jsxs)(`div`,{className:b,children:[F,I]}),t[29]=F,t[30]=I,t[31]=b,t[32]=L):L=t[32];let R;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(O,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=R):R=t[33];let B;t[34]!==L||t[35]!==S?(B=(0,$.jsxs)(`div`,{className:S,children:[L,R]}),t[34]=L,t[35]=S,t[36]=B):B=t[36];let V;t[37]===a?V=t[38]:(V=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]=V);let H;t[39]!==c||t[40]!==n.consentExpiredBanner?(H=c?(0,$.jsx)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=H):H=t[41];let te;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]!==o||t[51]!==p||t[52]!==s||t[53]!==n?(te=_?(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)(j,{label:n.publicUrlLabel,text:r.publicUrl,labels:u})}):null,v?(0,$.jsx)(Ze,{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:s,onClick:h,children:[s?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(x,{type:`button`,disabled:o,onClick:m,children:[o?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{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 bg-amber-500/10 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(z,{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:o||g,onClick:m,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{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]=o,t[51]=p,t[52]=s,t[53]=n,t[54]=te):te=t[54];let ne;return t[55]!==B||t[56]!==V||t[57]!==H||t[58]!==te||t[59]!==C?(ne=(0,$.jsxs)(`section`,{className:C,children:[B,V,H,te]}),t[55]=B,t[56]=V,t[57]=H,t[58]=te,t[59]=C,t[60]=ne):ne=t[60],ne}var it={reconfiguring:!1};function at(e){let t=(0,Q.c)(89),{t:n,brokerSecretReady:r,brokerSecretConfiguredInConfig:i,brokerSecretMaskedValue:a,brokerSecretDraft:o,savingBrokerSecret:c,authorizingBrokerSecret:u,brokerSecretAuthorizationUrl:d,brokerSecretNotice:f,copyFailedLabel:p,onDraftChange:m,onSave:h,onAuthorize:g,onClear:_,sectionRef:v}=e,y=(0,Z.useId)(),b=r,S=!b,[C,w]=(0,Z.useReducer)(re,it),{reconfiguring:T}=C,E;t[0]!==i||t[1]!==o||t[2]!==T?(E=i&&!T&&!o.trim(),t[0]=i,t[1]=o,t[2]=T,t[3]=E):E=t[3];let D=E,O;t[4]!==n.copied||t[5]!==n.copyKey||t[6]!==n.hideKey||t[7]!==n.showKey?(O={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[4]=n.copied,t[5]=n.copyKey,t[6]=n.hideKey,t[7]=n.showKey,t[8]=O):O=t[8];let k=O,A;t[9]===o?A=t[10]:(A=o.trim().length>0&&!ne(o.trim()),t[9]=o,t[10]=A);let j=A,M;t[11]===m?M=t[12]:(M=()=>{w({type:`patch`,patch:{reconfiguring:!1}}),m(``)},t[11]=m,t[12]=M);let N=M,P=S&&`ring-1 ring-amber-500/30`,F;t[13]===P?F=t[14]:(F=l(P),t[13]=P,t[14]=F);let I=b?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:S?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,L;t[15]===I?L=t[16]:(L=l(`flex size-9 shrink-0 items-center justify-center rounded-lg`,I),t[15]=I,t[16]=L);let z;t[17]===b?z=t[18]:(z=b?(0,$.jsx)(s,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=b,t[18]=z);let B;t[19]!==L||t[20]!==z?(B=(0,$.jsx)(`span`,{className:L,children:z}),t[19]=L,t[20]=z,t[21]=B):B=t[21];let V=b?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,U;t[22]===V?U=t[23]:(U=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:V}),t[22]=V,t[23]=U);let ie=b?n.brokerSecretReadyHint:n.brokerSecretHint,W;t[24]===ie?W=t[25]:(W=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:ie}),t[24]=ie,t[25]=W);let ae;t[26]!==S||t[27]!==n.brokerSecretMissingHint?(ae=S?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[26]=S,t[27]=n.brokerSecretMissingHint,t[28]=ae):ae=t[28];let oe;t[29]!==U||t[30]!==W||t[31]!==ae?(oe=(0,$.jsxs)(`div`,{children:[U,W,ae]}),t[29]=U,t[30]=W,t[31]=ae,t[32]=oe):oe=t[32];let G;t[33]!==u||t[34]!==S||t[35]!==g||t[36]!==T||t[37]!==c||t[38]!==n.brokerSecretAuthorize||t[39]!==n.brokerSecretAuthorizing||t[40]!==n.brokerSecretConsoleLink?(G=S||T?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(x,{type:`button`,disabled:c||u,onClick:g,children:[u?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,u?n.brokerSecretAuthorizing:n.brokerSecretAuthorize]}),(0,$.jsxs)(`a`,{href:X,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,(0,$.jsx)(H,{className:`size-3`,"aria-hidden":!0})]})]}):null,t[33]=u,t[34]=S,t[35]=g,t[36]=T,t[37]=c,t[38]=n.brokerSecretAuthorize,t[39]=n.brokerSecretAuthorizing,t[40]=n.brokerSecretConsoleLink,t[41]=G):G=t[41];let K;t[42]!==u||t[43]!==d||t[44]!==n.brokerSecretOpenAuthorization?(K=u&&d?(0,$.jsxs)(`a`,{href:d,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[n.brokerSecretOpenAuthorization,(0,$.jsx)(H,{className:`size-3`,"aria-hidden":!0})]}):null,t[42]=u,t[43]=d,t[44]=n.brokerSecretOpenAuthorization,t[45]=K):K=t[45];let q;t[46]!==i||t[47]!==o||t[48]!==a||t[49]!==j||t[50]!==N||t[51]!==p||t[52]!==y||t[53]!==S||t[54]!==_||t[55]!==m||t[56]!==h||t[57]!==T||t[58]!==c||t[59]!==k||t[60]!==D||t[61]!==n.brokerSecretCancelReconfigure||t[62]!==n.brokerSecretClear||t[63]!==n.brokerSecretMaskedHelp||t[64]!==n.brokerSecretNotInConfigFile||t[65]!==n.brokerSecretPlaceholder||t[66]!==n.brokerSecretReconfigure||t[67]!==n.brokerSecretRevealFailed||t[68]!==n.brokerSecretSave||t[69]!==n.brokerSecretSaveAndContinue||t[70]!==n.brokerSecretTitle?(q=D?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:y,children:n.brokerSecretTitle}),(0,$.jsx)(R,{id:y,value:a,labels:k,reveal:ot,loadFailedLabel:p||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:c,onClick:()=>{w({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:c,onClick:_,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:y,children:n.brokerSecretTitle}),(0,$.jsx)(R,{id:y,value:o,onChange:m,placeholder:n.brokerSecretPlaceholder,labels:k,disabled:c}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(x,{type:`button`,disabled:c||!j,onClick:h,children:[c?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,S?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),i?(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:c,onClick:_,children:n.brokerSecretClear}):null,T?(0,$.jsx)(x,{type:`button`,variant:`ghost`,disabled:c,onClick:N,children:n.brokerSecretCancelReconfigure}):null]})]}),t[46]=i,t[47]=o,t[48]=a,t[49]=j,t[50]=N,t[51]=p,t[52]=y,t[53]=S,t[54]=_,t[55]=m,t[56]=h,t[57]=T,t[58]=c,t[59]=k,t[60]=D,t[61]=n.brokerSecretCancelReconfigure,t[62]=n.brokerSecretClear,t[63]=n.brokerSecretMaskedHelp,t[64]=n.brokerSecretNotInConfigFile,t[65]=n.brokerSecretPlaceholder,t[66]=n.brokerSecretReconfigure,t[67]=n.brokerSecretRevealFailed,t[68]=n.brokerSecretSave,t[69]=n.brokerSecretSaveAndContinue,t[70]=n.brokerSecretTitle,t[71]=q):q=t[71];let J;t[72]===f?J=t[73]:(J=f?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:f}):null,t[72]=f,t[73]=J);let se;t[74]!==oe||t[75]!==G||t[76]!==K||t[77]!==q||t[78]!==J?(se=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[oe,G,K,q,J]}),t[74]=oe,t[75]=G,t[76]=K,t[77]=q,t[78]=J,t[79]=se):se=t[79];let Y;t[80]!==B||t[81]!==se?(Y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[B,se]}),t[80]=B,t[81]=se,t[82]=Y):Y=t[82];let le;t[83]!==Y||t[84]!==F?(le=(0,$.jsx)(ce,{className:F,children:Y}),t[83]=Y,t[84]=F,t[85]=le):le=t[85];let ue;return t[86]!==v||t[87]!==le?(ue=(0,$.jsx)(`div`,{ref:v,id:`tunnel-broker-secret-setup`,children:le}),t[86]=v,t[87]=le,t[88]=ue):ue=t[88],ue}function ot(){return he().then(st)}function st(e){return e.registrationSecret??null}var ct={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null};function lt({embedded:e=!1}){let t=d(e=>e.language),n=f(t).tunnelSettings,r=!!u(e=>e.conversationId),[i,a]=(0,Z.useReducer)(re,ct),{actionError:o,starting:s,stopping:c,savingAutoStart:p,consentOpen:m,autoStartConfirmOpen:h,releaseConfirmOpen:g,releasing:_,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:w,brokerSecretAuthorizationUrl:T,brokerSecretNotice:E}=i,k=(0,Z.useRef)(null),{data:A}=C(r),{data:j,error:M,isLoading:N,mutate:R}=b(r?`tunnel-status`:null,me,{refreshInterval:e=>s?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),z=(0,Z.useMemo)(()=>{let e=A?.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 j?.config?.autoStart===!0},[A,j?.config?.autoStart]),B=(0,Z.useMemo)(()=>{let e=A?.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``},[A]),V=ne(B),H=j?.registrationSecret?.configured??V;(0,Z.useEffect)(()=>{let e=()=>{R()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[R]);let te=(0,Z.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),U=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{starting:!0}});try{await _e(),await R(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{starting:!1}})}},[R]),W=(0,Z.useCallback)(()=>{if(!H){a({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),k.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(j?.consentRequired){a({type:`patch`,patch:{consentOpen:!0}});return}U()},[H,j?.consentRequired,U,n.brokerSecretRequiredBeforeStart]),ae=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{consentOpen:!1}}),a({type:`patch`,patch:{actionError:null}});try{await le(),await Promise.all([R(),U()])}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[R,U]),G=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{actionError:null}}),a({type:`patch`,patch:{stopping:!0}});try{await de(),await R(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{stopping:!1}})}},[R]),K=(0,Z.useCallback)(async e=>{a({type:`patch`,patch:{savingAutoStart:!0}}),a({type:`patch`,patch:{actionError:null}});try{await ge({autoStart:e}),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingAutoStart:!1}})}},[]),q=(0,Z.useCallback)(()=>{if(z){K(!1);return}if(j?.consentRequired){a({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!j?.canAutoStart){a({type:`patch`,patch:{actionError:n.autoStartHint}});return}a({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[K,j?.canAutoStart,j?.consentRequired,n,z]),J=(0,Z.useCallback)(async()=>{let e=v.trim();if(e){a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ge({registrationSecret:e}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),S(),await R(),a({type:`patch`,patch:{actionError:null}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[v,R,n.brokerSecretSaved]),se=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await ge({registrationSecret:null}),a({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),S(),await R()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{savingBrokerSecret:!1}})}},[R,n.brokerSecretCleared]),ue=(0,Z.useCallback)(async()=>{let e=oe(),t=null,r=null;a({type:`patch`,patch:{authorizingBrokerSecret:!0,brokerSecretAuthorizationUrl:null,brokerSecretNotice:null,actionError:null}});try{for(t=(await I(`xopc-tunnel`)).sessionId;;){await new Promise(e=>window.setTimeout(e,1e3));let i=await D(t);if(i.authUrl&&i.authUrl!==r&&(r=i.authUrl,a({type:`patch`,patch:{brokerSecretAuthorizationUrl:i.authUrl}}),await ie(i.authUrl,e)),i.status===`failed`||i.status===`cancelled`)throw Error(i.error??i.message??`OAuth authorization failed`);if(i.status===`completed`){await pe(),await Promise.all([R(),S()]),a({type:`patch`,patch:{brokerSecretNotice:n.brokerSecretSaved,brokerSecretDraft:``}});return}}}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{L(e),t&&F(t).catch(()=>void 0),a({type:`patch`,patch:{authorizingBrokerSecret:!1,brokerSecretAuthorizationUrl:null}})}},[R,n.brokerSecretSaved]),fe=(0,Z.useCallback)(async()=>{a({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await de({release:!0}),await R(),S()}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{a({type:`patch`,patch:{releasing:!1}})}},[R]),he=(0,Z.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:f(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!r)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 X=j??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:z,brokerUrl:`https://frp.xopc.ai/api`}},ve=j?.consentRequired&&(X.enabled||z||j?.consent?.acceptedAt),ye=(0,$.jsx)(at,{t:n,brokerSecretReady:H,brokerSecretConfiguredInConfig:V,brokerSecretMaskedValue:V?B:``,brokerSecretDraft:v,savingBrokerSecret:y,authorizingBrokerSecret:w,brokerSecretAuthorizationUrl:T,brokerSecretNotice:E,copyFailedLabel:f(t).clipboard.copyFailed,onDraftChange:e=>a({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void J(),onAuthorize:()=>void ue(),onClear:()=>void se(),sectionRef:k}),be=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ve,{open:m,title:n.consentTitle,intro:n.consentIntro,bullets:te,checkboxLabel:n.consentCheckbox,confirmLabel:ve?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void ae(),onCancel:()=>a({type:`patch`,patch:{consentOpen:!1}})},m?`consent-open`:`consent-closed`),(0,$.jsx)(P,{open:h,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{a({type:`patch`,patch:{autoStartConfirmOpen:!1}}),K(!0)},onCancel:()=>a({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(P,{open:g,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void fe(),onCancel:()=>a({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(rt,{t:n,status:X,isLoading:N,statusErr:M,starting:s,stopping:c,showConsentExpired:!!ve,copyLabels:he,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:W,onStop:()=>void G()}),(0,$.jsxs)(ze,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:l(`flex items-center gap-3 text-sm text-fg`,!z&&!j?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:p||!z&&!j?.canAutoStart,onChange:q}),n.autoStart]}),!j?.canAutoStart&&!z?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(ze,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-base/45 p-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Y,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),be]}):(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})]}),o?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o}):null,ye,(0,$.jsx)(rt,{t:n,status:X,isLoading:N,statusErr:M,starting:s,stopping:c,showConsentExpired:!!ve,copyLabels:he,startDisabled:!H,startDisabledReason:H?void 0:n.brokerSecretRequiredBeforeStart,onStart:W,onStop:()=>void G()}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(x,{type:`button`,variant:`secondary`,disabled:_||c,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>a({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[_?(0,$.jsx)(ee,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(ce,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:l(`flex items-center gap-3 text-sm text-fg`,!z&&!j?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:z,disabled:p||!z&&!j?.canAutoStart,onChange:q}),n.autoStart]}),!j?.canAutoStart&&!z?(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)(O,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(Y,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),be]})}function ut(e,t){return e.tabs[t]}function dt(e,t){return e.tabIntro[t]}function ft(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 pt(e){let t=(0,Q.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(Oe,{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)(ue,{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)(lt,{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)(ye,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ie,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Me,{}),t[6]=e):e=t[6],e}}}function mt(){let e=(0,Q.c)(3),t=i(),n=d(gt),r=f(n).remoteAccess,o=!!u(ht),[s,c]=a(),l=Re(s.get(`tab`)),p=s.get(`intent`)===`mobile-pairing`,m;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={refreshInterval:2e3},e[0]=m):m=e[0];let h=b(p?`device-pairing-readiness`:null,fe,m),g;e[1]===c?g=e[2]:(g=e=>{c(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[1]=c,e[2]=g);let _=g,v=dt(r,l),y=Le.map(e=>({id:e,label:ut(r,e)}));return(0,$.jsxs)(K,{children:[(0,$.jsx)(G,{title:r.pageTitle,meta:(0,$.jsx)(Y,{language:n,label:r.docsLink,section:ft(l),className:`mt-1`})}),o?(0,$.jsxs)($.Fragment,{children:[p?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-accent-soft px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(B,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.mobilePairingFlow.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:h.data?.ready?r.mobilePairingFlow.ready:r.mobilePairingFlow.hint})]})]}),(0,$.jsxs)(x,{variant:`primary`,disabled:!h.data?.ready,onClick:()=>t(`/settings/devices?startDevicePairing=mobile`),children:[h.data?.ready?r.mobilePairingFlow.continue:r.mobilePairingFlow.waiting,(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0})]})]}):null,(0,$.jsx)(be,{items:y,activeTab:l,onChange:_,ariaLabel:r.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(q,{id:l,activeTab:l,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:ut(r,l),hint:l===`public`?void 0:v,showHeading:!1,framed:!1,children:(0,$.jsx)(pt,{tab:l,onOpenTab:_})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.guide.needToken})]})}function ht(e){return e.conversationId}function gt(e){return e.language}export{mt as RemoteAccessHub};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-B-GDnZO9.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./download-Dk-ZjtO6.js";import{a as s,i as c,n as l,r as u}from"./locale-store-DA0Z5jM_.js";import{t as d}from"./messages-4BtQKYlM.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./button-CS04eWY9.js";import{Ac as m,jc as h,ku as g}from"./index-DxYitLp8.js";import{n as _,r as v}from"./settings-page-layout-D3Spald3.js";import{n as y}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as b}from"./settings-advanced-gate-whpUsAy3.js";var x=e(t(),1);async function S(e){await s(u(`/api/runtime-tools/config`),{method:`PATCH`,body:JSON.stringify(e)})}async function C(){return(await s(u(`/api/runtime-tools/prune`),{method:`POST`})).payload}async function w(e){let t=await c(u(`/api/runtime-tools/${e.runtime}/${e.action}/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify({version:e.version})});if(!t.ok||!t.body)throw Error(`HTTP ${t.status}`);let n=t.body.getReader(),r=new TextDecoder,i=``,a=!1;try{for(;!a;){let{done:t,value:o}=await n.read();if(t)break;i+=r.decode(o,{stream:!0}).replace(/\r\n/g,`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-B-GDnZO9.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./download-Dk-ZjtO6.js";import{a as s,i as c,n as l,r as u}from"./locale-store-DA0Z5jM_.js";import{t as d}from"./messages-4BtQKYlM.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./button-CS04eWY9.js";import{Ac as m,jc as h,ku as g}from"./index-PFQHPGgi.js";import{n as _,r as v}from"./settings-page-layout-DqNCGKxQ.js";import{n as y}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as b}from"./settings-advanced-gate-CBX0Ezhf.js";var x=e(t(),1);async function S(e){await s(u(`/api/runtime-tools/config`),{method:`PATCH`,body:JSON.stringify(e)})}async function C(){return(await s(u(`/api/runtime-tools/prune`),{method:`POST`})).payload}async function w(e){let t=await c(u(`/api/runtime-tools/${e.runtime}/${e.action}/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify({version:e.version})});if(!t.ok||!t.body)throw Error(`HTTP ${t.status}`);let n=t.body.getReader(),r=new TextDecoder,i=``,a=!1;try{for(;!a;){let{done:t,value:o}=await n.read();if(t)break;i+=r.decode(o,{stream:!0}).replace(/\r\n/g,`
2
2
  `);let s=i.split(`
3
3
 
4
4
  `);i=s.pop()??``;for(let t of s){let n=``,r=``;for(let e of t.split(`
@@ -0,0 +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{c as i,d as a,f as o,g as s,l as c,m as l,t as u,u as d}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as f}from"./popover-select-B-GDnZO9.js";import{t as p}from"./x-B_N4OPjy.js";import{a as m,c as h,n as g,r as _}from"./locale-store-DA0Z5jM_.js";import{a as v,i as y,n as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{a as T,i as E,n as D}from"./vendor-swr-BIWyz7Rc.js";import{t as O}from"./button-CS04eWY9.js";import{t as k}from"./skeleton-BwbyijEw.js";import{Bt as A,Cc as j,Ml as M,Nu as N,Qi as P,Tu as ee,Yu as te,do as F,hc as ne,jc as I}from"./index-PFQHPGgi.js";var L=e(t(),1),R=n(),z=e=>m(_(`/api/scenes${e}`)),B=(e,t,n,r)=>m(_(`/api/scenes${e}`),{method:t,body:n===void 0?void 0:JSON.stringify(n),headers:r?{"Idempotency-Key":r}:void 0});function V(e,t){let n=e?.status;return n===401?t?`登录已失效,请重新登录后查看场景。`:`Your session expired. Sign in again to view scenes.`:n===503?t?`场景服务暂不可用,请检查服务状态后重试。`:`The scene service is unavailable. Check the Gateway and retry.`:n===409?t?`内容已被更新,请刷新后重新确认。`:`This content changed. Refresh and review it before trying again.`:(e?.body?.missing)?.some(e=>e.startsWith(`model_`))?t?`请先在模型设置中选择可用模型并配置凭据,然后重试。`:`Choose an available model and configure its credentials in model settings, then retry.`:n===422?t?`设置或授权不完整,请检查数据来源和范围。`:`Setup or permission is incomplete. Check the source and scope.`:n===404?t?`找不到这个场景或结果,请返回场景列表。`:`Scene or result not found. Return to the scenes list.`:t?`操作未完成,请检查连接后重试。你的输入仍保留在当前页面。`:`Could not finish. Check your connection and retry. Your input is still on this page.`}var H=r();function re(e){let t=(0,R.c)(49),{activationId:n,zh:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:15e3},t[0]=i):i=t[0];let a=E(`/diagnostics`,z,i),o,s,c,l,d,f,p,m,h,g,_;if(t[1]!==n||t[2]!==a.data||t[3]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a.data?.activations.find(e=>e.id===n);if(!e){c=null;break bb0}let i;t[15]===r?i=t[16]:(i=e=>e==null?r?`未设置`:`Not scheduled`:new Date(e).toLocaleString(r?`zh-CN`:`en`),t[15]=r,t[16]=i);let v=i,y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y={needs_permission:[`邮件授权已失效,请重新连接账号。`,`Mail permission expired. Reconnect the account.`],source_rate_limited:[`邮件服务暂时限流,将自动重试。`,`Mail service rate limited. A retry is scheduled.`],source_timeout:[`读取邮件超时,将自动重试。`,`Mail read timed out. A retry is scheduled.`],unchanged_result:[`资料未变化,已保留原成果和反馈。`,`Context unchanged. The existing result and feedback were preserved.`],source_not_ready:[`来源暂不可用,请检查连接器授权;稍后会重试。`,`Source unavailable. Check connector access; a retry is scheduled.`],daily_budget:[`已达每日模型调用上限,将在预算恢复后继续。`,`Daily model limit reached. Checks resume after the budget resets.`],execution_failed:[`检查失败,请检查模型凭据和服务连接,再点“现在检查”。`,`Check failed. Verify model credentials and connectivity, then check again.`],invalid_model_result:[`模型返回的格式不符合此场景要求,结果未发布;请重试或更换模型。`,`The model returned an unsupported result. Nothing was published; retry or choose another model.`],empty_input:[`请先填写安排和约束。`,`Provide arrangements and constraints first.`],source_changed:[`来源已变化,旧草稿未发布;可重新检查。`,`Source changed. The stale draft was withheld; check again.`],execution_aborted:[`检查已中断,可在服务恢复后重新检查。`,`Check interrupted. Retry after the service resumes.`]},t[17]=y):y=t[17];let b=y,x=[e.next_schedule_at,e.next_deadline_check_at,e.retry_at].filter(ie),S=e.source_reason??e.last_reason;l=`space-y-2 rounded-xl border border-edge p-4 text-sm text-fg-muted`,d=(0,H.jsxs)(`p`,{children:[r?`最近发起检查`:`Last check started`,`: `,e.last_check_at==null?r?`尚未检查`:`Not checked yet`:v(e.last_check_at)]});let C=r?`下次定时检查`:`Next scheduled check`,w=e.status!==`active`||a.data?.checksPaused?r?`当前不会自动检查`:`Automatic checks inactive`:x.length?`${Math.min(...x)<=Date.now()?r?`等待执行,原定 `:`Pending, scheduled for `:``}${v(Math.min(...x))}`:r?`暂无待执行检查`:`No check scheduled`;t[18]!==C||t[19]!==w?(f=(0,H.jsxs)(`p`,{children:[C,`: `,w]}),t[18]=C,t[19]=w,t[20]=f):f=t[20],p=e.deadline_at!=null&&(0,H.jsxs)(`p`,{children:[r?`邮件跟进截止时间`:`Mail follow-up deadline`,`: `,v(e.deadline_at)]}),m=e.source_reason&&e.source_attempt_at!=null&&(0,H.jsxs)(`p`,{children:[r?`最近尝试读取邮件`:`Last mail read attempt`,`: `,v(e.source_attempt_at),` · `,r?`连续失败`:`Consecutive failures`,`: `,e.source_failures]}),h=e.source_reason&&(0,H.jsx)(u,{to:`/connectors`,className:`inline-block text-accent underline`,children:r?`检查连接器授权`:`Check connector access`}),g=e.source_success_at!=null&&(0,H.jsxs)(`p`,{children:[r?`最近成功读取邮件`:`Last successful mail read`,`: `,v(e.source_success_at)]}),_=S&&b[S]&&(0,H.jsx)(`p`,{role:`status`,children:b[S][+!r]});let T=r?`当前场景模型`:`Current scene model`,E=a.data.currentModel??(r?`配置不可用`:`Configuration unavailable`);t[21]!==T||t[22]!==E?(o=(0,H.jsxs)(`p`,{children:[T,`: `,E]}),t[21]=T,t[22]=E,t[23]=o):o=t[23],s=e.source_reason&&e.status===`active`&&!a.data?.checksPaused&&e.source_retry_at!=null&&(0,H.jsxs)(`p`,{children:[r?`来源重试时间`:`Source retry`,`: `,v(e.source_retry_at)]})}t[1]=n,t[2]=a.data,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_}else o=t[4],s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let v=r?`所有场景待检查`:`Pending checks across scenes`,y;t[24]!==a.data.pendingChecks||t[25]!==v?(y=(0,H.jsxs)(`p`,{children:[v,`: `,a.data.pendingChecks]}),t[24]=a.data.pendingChecks,t[25]=v,t[26]=y):y=t[26];let b=r?`最近 7 天所有场景的模型用量`:`Model usage across scenes in the last 7 days`,x=a.data.lastSevenDays.modelCalls,S=r?`次调用`:`calls`,C=a.data.lastSevenDays.tokens,w=r?`估算费用`:`estimated cost`,T;t[27]===a.data.lastSevenDays.estimatedCost?T=t[28]:(T=a.data.lastSevenDays.estimatedCost.toFixed(4),t[27]=a.data.lastSevenDays.estimatedCost,t[28]=T);let D;t[29]!==a.data.lastSevenDays.modelCalls||t[30]!==a.data.lastSevenDays.tokens||t[31]!==b||t[32]!==S||t[33]!==w||t[34]!==T?(D=(0,H.jsxs)(`p`,{children:[b,`: `,x,` `,S,` · `,C,` tokens · `,w,` $`,T]}),t[29]=a.data.lastSevenDays.modelCalls,t[30]=a.data.lastSevenDays.tokens,t[31]=b,t[32]=S,t[33]=w,t[34]=T,t[35]=D):D=t[35];let O;return t[36]!==o||t[37]!==s||t[38]!==y||t[39]!==l||t[40]!==D||t[41]!==d||t[42]!==f||t[43]!==p||t[44]!==m||t[45]!==h||t[46]!==g||t[47]!==_?(O=(0,H.jsxs)(`section`,{className:l,children:[d,f,p,m,h,g,_,o,s,y,D]}),t[36]=o,t[37]=s,t[38]=y,t[39]=l,t[40]=D,t[41]=d,t[42]=f,t[43]=p,t[44]=m,t[45]=h,t[46]=g,t[47]=_,t[48]=O):O=t[48],O}function ie(e){return e!=null}function U(e){let t=(0,R.c)(13),{dirty:n,zh:r}=e,a;t[0]===n?a=t[1]:(a=e=>{n&&(e.preventDefault(),e.returnValue=``)},t[0]=n,t[1]=a),i(a);let o=c(n),s=o.state===`blocked`,l=r?`放弃未保存的更改?`:`Discard unsaved changes?`,u=r?`当前内容尚未保存,现在离开将丢失这些更改。`:`Your changes have not been saved. Leaving now will discard them.`,d=r?`放弃并离开`:`Discard and leave`,f=r?`继续编辑`:`Keep editing`,p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>{o.state===`blocked`&&o.proceed()},m=()=>{o.state===`blocked`&&o.reset()},t[2]=o,t[3]=p,t[4]=m);let h;return t[5]!==s||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==f||t[10]!==p||t[11]!==m?(h=(0,H.jsx)(P,{open:s,title:l,description:u,confirmLabel:d,cancelLabel:f,destructive:!0,overlayClassName:`z-[100]`,contentClassName:`z-[101]`,onConfirm:p,onCancel:m}),t[5]=s,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h):h=t[12],h}function ae({zh:e}){let[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(),[s,c]=(0,L.useState)(!1);async function l(){n(!0),o(void 0),c(!1);try{if(await Notification.requestPermission()!==`granted`){c(!0);return}let{publicKey:t}=await B(`/browser/prepare`,`POST`);await navigator.serviceWorker.register(`/notification-sw.js`);let n=await navigator.serviceWorker.ready,r=Uint8Array.from(atob(t.replace(/-/g,`+`).replace(/_/g,`/`)),e=>e.charCodeAt(0)),a=await n.pushManager.getSubscription(),o=a?.options.applicationServerKey;a&&(!o||!new Uint8Array(o).every((e,t)=>e===r[t])||o.byteLength!==r.byteLength)&&(await a.unsubscribe(),a=null),a??=await n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r}),await B(`/browser/subscriptions`,`POST`,{...a.toJSON(),expirationTime:a.expirationTime,language:e?`zh`:`en`}),i(!0)}catch(e){o(e)}finally{n(!1)}}let u=A()&&`PushManager`in window;return(0,H.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-3`,children:[(0,H.jsx)(O,{disabled:t||!u,onClick:()=>void l(),children:r?e?`刷新此浏览器提醒订阅`:`Refresh this browser subscription`:e?`开启页面关闭后的浏览器提醒`:`Enable reminders when this page is closed`}),r&&(0,H.jsx)(`p`,{role:`status`,children:e?`此浏览器已订阅。服务需持续运行;送达取决于浏览器和系统权限。`:`Subscribed. The Gateway must remain running; delivery depends on browser and system permissions.`}),(!u||s)&&(0,H.jsx)(`p`,{className:`text-fg-muted`,children:e?`当前环境或通知权限不支持后台提醒。成果仍会保留在场景收件箱;可在支持推送的 HTTPS 浏览器中开启。`:`Background reminders are unavailable here. Results remain in your scene inbox. Use a push-capable HTTPS browser and allow notifications.`}),a!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(a,e)})]})}function oe(e){let t=(0,R.c)(23),{zh:n,open:r,onOpenChange:i,onCloseAutoFocus:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,H.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[0]=o):o=t[0];let s;t[1]===a?s=t[2]:(s=e=>{e.preventDefault(),a()},t[1]=a,t[2]=s);let c=n?`检查与提醒设置`:`Checks and reminders`,l;t[3]===c?l=t[4]:(l=(0,H.jsx)(C,{className:`text-base font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`适用于所有场景,设置更改后自动保存。`:`Applies to all scenes. Changes are saved automatically.`,d;t[5]===u?d=t[6]:(d=(0,H.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==l||t[8]!==d?(f=(0,H.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-4 sm:px-6`,children:[l,d]}),t[7]=l,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-6`,children:(0,H.jsx)(se,{zh:n})}),t[10]=n,t[11]=p);let m=n?`关闭`:`Close`,h;t[12]===m?h=t[13]:(h=(0,H.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge p-4 sm:px-6`,children:(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(O,{type:`button`,variant:`secondary`,children:m})})}),t[12]=m,t[13]=h);let g;t[14]!==h||t[15]!==s||t[16]!==f||t[17]!==p?(g=(0,H.jsxs)(x,{children:[o,(0,H.jsxs)(S,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100dvh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,onCloseAutoFocus:s,children:[f,p,h]})]}),t[14]=h,t[15]=s,t[16]=f,t[17]=p,t[18]=g):g=t[18];let _;return t[19]!==i||t[20]!==r||t[21]!==g?(_=(0,H.jsx)(w,{open:r,onOpenChange:i,children:g}),t[19]=i,t[20]=r,t[21]=g,t[22]=_):_=t[22],_}function se({zh:e}){let t=E(`/preferences`,z),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)();async function o(e){if(!(!t.data||n)){r(!0),a(void 0);try{let n=await B(`/preferences`,`PATCH`,{...e,expectedRevision:t.data.revision});await t.mutate(n,!1)}catch(e){a(e),await t.mutate()}finally{r(!1)}}}if(!t.data)return t.error?(0,H.jsx)(`p`,{role:`alert`,children:V(t.error,e)}):(0,H.jsx)(k,{className:`h-32 w-full`});let s=t.data,c=`w-24 rounded-md border border-edge bg-surface-panel px-2 py-1 text-fg`;return(0,H.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,H.jsx)(`p`,{className:`text-fg-muted`,children:e?`设备休眠或服务关闭时不会检查;服务恢复后继续。草稿不会自动发送。`:`Checks require the device and Gateway to stay running. Drafts are never sent automatically.`}),[[`checksPaused`,e?`暂停所有检查`:`Pause all checks`],[`notificationsMuted`,e?`静音提醒(继续检查并保留成果)`:`Mute reminders (continue checks and keep results)`],[`suppressWhileViewing`,e?`查看成果时不重复提醒`:`Avoid reminders while viewing a result`],[`digestEnabled`,e?`汇总为每日摘要`:`Use a daily digest`]].map(([e,t])=>(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:s[e],disabled:n,onChange:t=>void o({[e]:t.target.checked})}),t]},e)),(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[e?`时区`:`Timezone`,(0,H.jsx)(`input`,{defaultValue:s.timezone,disabled:n,className:`${c} w-48`,onBlur:e=>{e.target.value!==s.timezone&&o({timezone:e.target.value})}},s.timezone)]}),[[`quietStartHour`,e?`免打扰开始(小时)`:`Quiet hours start`,23],[`quietEndHour`,e?`免打扰结束(小时)`:`Quiet hours end`,23],[`dailyNotificationLimit`,e?`每日提醒上限`:`Daily reminder limit`,30],...s.digestEnabled?[[`digestHour`,e?`摘要时间(小时)`:`Digest hour`,23],[`digestMinute`,e?`摘要时间(分钟)`:`Digest minute`,59]]:[]].map(([e,t,r])=>(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[t,(0,H.jsx)(`input`,{type:`number`,min:0,max:r,defaultValue:s[e],disabled:n,className:c,onBlur:t=>{let n=Number(t.target.value);t.target.value&&Number.isInteger(n)&&n>=0&&n<=r&&n!==s[e]&&o({[e]:n})}},s[e])]},e)),(0,H.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,disabled:n,checked:s.preferredChannel===`browser`,onChange:e=>void o({preferredChannel:e.target.checked?`browser`:`in_app`})}),e?`允许浏览器后台提醒`:`Allow background browser reminders`]}),(0,H.jsx)(ae,{zh:e}),i!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(i,e)}),s.checksPausedUntil&&(0,H.jsx)(O,{disabled:n,onClick:()=>void o({checksPausedUntil:null}),children:e?`取消定时暂停`:`Clear timed pause`})]})}function W({item:e,zh:t,onChange:n}){let r=(0,L.useRef)(null);(0,L.useEffect)(()=>{let t=crypto.randomUUID(),n=!1,i=()=>{B(`/presence`,`POST`,{clientId:t,surface:`web`,presentationId:e.id,visible:n&&document.visibilityState===`visible`&&document.hasFocus()}).catch(()=>void 0)},a=new IntersectionObserver(([e])=>{n=e.isIntersecting,i()},{threshold:.5});r.current&&a.observe(r.current);let o=setInterval(i,2e4);return document.addEventListener(`visibilitychange`,i),window.addEventListener(`focus`,i),window.addEventListener(`blur`,i),()=>{a.disconnect(),clearInterval(o),document.removeEventListener(`visibilitychange`,i),window.removeEventListener(`focus`,i),window.removeEventListener(`blur`,i),n=!1,i()}},[e.id]);let[i,a]=(0,L.useState)(!1),o=`/presentations/${encodeURIComponent(e.id)}`,s=E(e.readOnly?null:`${o}/feedback`,z),{mutate:c}=T(),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(),p=async e=>{if(s.data){u(!0),f(void 0);try{let t=s.data.feedback?.note??``,n=await B(`${o}/feedback`,`POST`,{expectedRevision:s.data.feedback?.revision??0,rating:e});await s.mutate({feedback:{rating:e,note:t,revision:n.revision}},{revalidate:!1}),c(`/metrics`)}catch(e){f(e),s.mutate()}finally{u(!1)}}},m=async()=>{u(!0),f(void 0);try{await B(o,`PATCH`,{read:e.status!==`read`}),n()}catch(e){f(e)}finally{u(!1)}};return(0,H.jsxs)(`article`,{ref:r,className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,children:[e.createdAt!=null&&(0,H.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[t?`生成于`:`Generated`,` `,new Date(e.createdAt).toLocaleString(t?`zh-CN`:`en`)]}),e.sourceHealth?.reason&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`邮件来源暂不可用,这份成果尚未核实最新邮件,请检查连接器授权后重试。`:`Mail is unavailable. This result has not been checked against the latest messages. Check connector access and retry.`}),(0,H.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-fg`,children:e.content.summary}),(0,H.jsx)(O,{variant:`ghost`,onClick:()=>{navigator.clipboard.writeText(e.content.summary).then(()=>a(!0)).catch(f)},children:i?t?`已复制`:`Copied`:t?`复制成果`:`Copy result`}),(0,H.jsx)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:e.sources?.length?e.sources.map(e=>(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`a`,{className:`text-accent underline`,href:e.href,target:e.kind===`mail`?`_blank`:void 0,rel:`noreferrer`,children:e.kind===`notes`?t?`查看场景资料`:`View scene notes`:e.title||(t?`查看原邮件`:`View original email`)}),e.sender&&` · ${e.sender}`]},e.href)):(0,H.jsx)(`p`,{children:t?`来源详情暂不可用`:`Source details unavailable`})}),e.readOnly?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`这份成果已结束、过期或延后,仅供查阅。`:`This result is resolved, expired or snoozed, and is available for reference.`}):(0,H.jsxs)(H.Fragment,{children:[s.error?(0,H.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[V(s.error,t),(0,H.jsx)(O,{onClick:()=>void s.mutate(),children:t?`重新加载`:`Reload`})]}):s.data?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`useful`,`not_useful`].map(e=>(0,H.jsx)(O,{disabled:l,"aria-pressed":s.data?.feedback?.rating===e,onClick:()=>void p(e),children:e===`useful`?t?`对我有帮助`:`Helpful`:t?`没有帮助`:`Not helpful`},e))}):(0,H.jsx)(k,{className:`h-11 w-48`}),(0,H.jsx)(O,{disabled:l,variant:`ghost`,onClick:()=>void m(),children:e.status===`read`?t?`标为未读`:`Mark unread`:t?`标为已读`:`Mark read`})]}),!!d&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:V(d,t)})]})}var G=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function K({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/schedules`,a=E(i,z),o=E(`/templates/${e.templateKey}/versions/${e.templateVersion}`,z),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(),d=()=>{a.mutate(),o.mutate()};if(a.error||o.error)return(0,H.jsxs)(`div`,{role:`alert`,children:[(0,H.jsx)(`p`,{children:V(a.error??o.error,t)}),(0,H.jsx)(O,{onClick:d,children:t?`重新加载`:`Reload`})]});if(!a.data||!o.data)return(0,H.jsx)(k,{className:`h-32 w-full`});let f=o.data.template.triggers.find(e=>e.type===`schedule`);if(!f)return null;let p=a.data.schedules.find(e=>e.triggerKey===f.id);return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查时间`:`Review schedule`}),p?(0,H.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.status===`active`?t?`下次检查:`:`Next check: `:t?`当前不会定时检查。已保存时间:`:`Not scheduling while inactive. Saved time: `,new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`,timeZone:p.schedule.timeZone}).format(p.nextDueAt),` · `,p.schedule.timeZone]}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未设置定时检查。只有你点“现在检查”才会执行周期复盘。`:`No recurring schedule yet. Use Check now for a manual review.`}),!!l&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:V(l,t)}),s?(0,H.jsx)(ce,{initial:s.cursor,zh:t,onCancel:()=>{c(null),n(!1)},onSave:async e=>{u(void 0);try{await B(`${i}/${encodeURIComponent(f.id)}`,`PATCH`,{expectedRevision:s.cursor?.revision??0,schedule:e}),c(null),n(!1),await a.mutate(),r?.()}catch(e){throw u(e),e}}}):(0,H.jsx)(O,{disabled:e.status!==`active`,onClick:()=>{u(void 0),c({cursor:p}),n(!0)},children:p?t?`修改时间`:`Edit schedule`:t?`设置时间`:`Set schedule`}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`没有值得关注的新变化时保持安静。暂停场景会停止定时检查。`:`Stays quiet when there is no useful change. Pause the scene to stop scheduled checks.`})]})}function ce({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,L.useState)(e?.schedule.weekdays??[0]),[o,s]=(0,L.useState)(`${String(e?.schedule.hour??18).padStart(2,`0`)}:${String(e?.schedule.minute??0).padStart(2,`0`)}`),[c,l]=(0,L.useState)(e?.schedule.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),m=async e=>{e.preventDefault();try{new Intl.DateTimeFormat(`en`,{timeZone:c})}catch{p(!0);return}if(!i.length||!/^\d{2}:\d{2}$/.test(o)){p(!0);return}p(!1),d(!0);try{let[e,t]=o.split(`:`).map(Number);await n({weekdays:i,hour:e,minute:t,timeZone:c})}catch{}finally{d(!1)}};return(0,H.jsx)(`form`,{onSubmit:e=>void m(e),children:(0,H.jsxs)(`fieldset`,{disabled:u,className:`space-y-4`,children:[(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{className:`mb-2 text-sm font-medium text-fg`,children:t?`每周检查日`:`Days of the week`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(t?[`周日`,`周一`,`周二`,`周三`,`周四`,`周五`,`周六`]:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`]).map((e,t)=>(0,H.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 rounded-md border border-edge px-3 text-sm text-fg`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.includes(t),onChange:e=>a(n=>e.target.checked?[...n,t].sort():n.filter(e=>e!==t))}),e]},t))})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`当地时间`:`Local time`,(0,H.jsx)(`input`,{type:`time`,required:!0,value:o,onChange:e=>s(e.target.value),className:G})]}),(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`时区(例如 Asia/Shanghai)`:`Time zone (for example Asia/Shanghai)`,(0,H.jsx)(`input`,{required:!0,maxLength:100,value:c,onChange:e=>l(e.target.value),className:G,spellCheck:!1})]})]}),f&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择至少一天,并填写有效时间和时区。`:`Choose at least one day and enter a valid time and time zone.`}),(0,H.jsxs)(`div`,{className:`flex gap-3`,children:[(0,H.jsx)(O,{type:`submit`,disabled:u,children:u?t?`正在保存…`:`Saving…`:t?`保存时间`:`Save schedule`}),(0,H.jsx)(O,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}function le({value:e,disabled:t,zh:n,onChange:r}){let i=E(`/sources/mail/accounts`,z),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),[l,d]=(0,L.useState)([]),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(),y=a||i.data?.accounts[0]?.id||``;async function b(){m(!0),v(void 0),d([]),g(!0),r({id:``,accountId:``,subject:``,sender:``});try{d((await B(`/sources/mail/search`,`POST`,{accountId:y,query:s})).sources)}catch(e){v(e)}finally{m(!1)}}if(i.error)return(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-2 text-sm text-danger`,children:[(0,H.jsx)(`p`,{children:V(i.error,n)}),(0,H.jsx)(O,{onClick:()=>void i.mutate(),children:n?`重新加载`:`Reload`})]});if(!i.data)return(0,H.jsx)(k,{className:`h-24 w-full`});let x=e=>`${e.subject||(n?`无主题邮件`:`Untitled mail`)} · ${e.sender||e.accountId}`;return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`搜索会读取所选 Gmail 账号的匹配邮件;开启后只持续跟进选定线程,不发送邮件,也不需要开启后台学习。`:`Search reads matching mail in your selected Gmail account. The scene follows only the selected thread, never sends mail, and requires no background learning.`}),(0,H.jsx)(f,{value:y,disabled:t||p,ariaLabel:n?`邮箱账号`:`Mail account`,placeholder:n?`选择账号`:`Choose account`,allowEmpty:!1,options:i.data.accounts.map(e=>({value:e.id,label:e.label})),onChange:e=>{o(e),d([]),r({id:``,accountId:``,subject:``,sender:``})}}),(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[n?`主题、发件人或 Gmail 搜索条件`:`Subject, sender, or Gmail query`,(0,H.jsx)(`input`,{value:s,maxLength:500,disabled:t||p,onChange:e=>c(e.target.value),className:`rounded-md border border-edge bg-surface-panel px-3 py-2`,placeholder:n?`例如 from:alice@example.com`:`e.g. from:alice@example.com`})]}),(0,H.jsx)(O,{type:`button`,disabled:t||p||!y||!s.trim(),onClick:()=>void b(),children:p?n?`正在搜索…`:`Searching…`:n?`搜索邮件`:`Search mail`}),(0,H.jsx)(f,{value:e,disabled:t||p,ariaLabel:n?`要跟进的邮件`:`Mail to follow`,placeholder:n?`选择邮件线程`:`Choose a thread`,allowEmpty:!1,options:l.map(e=>({value:e.id,label:x(e)})),onChange:e=>{let t=l.find(t=>t.id===e);t&&r(t)}}),!i.data.accounts.length&&(0,H.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[n?`请连接 Gmail,并允许读取及后台检查;要求每次确认或仅限指定 Agent 的账号暂不支持。`:`Connect Gmail and allow background reads. Accounts requiring confirmation for every read or restricted to specific agents are not supported yet.`,` `,(0,H.jsx)(u,{className:`text-accent underline`,to:`/connectors`,children:n?`管理连接`:`Manage connections`})]}),h&&!p&&!_&&!l.length&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:n?`没有找到匹配线程,请调整搜索条件。`:`No matching threads. Try a different query.`}),_!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(_,n)})]})}function ue({activation:e,zh:t,onDirty:n,onChanged:r}){let i=`/activations/${e.id}/work-items`,a=E(i,z),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(!1),f=()=>{s(null),n(!1),a.mutate(),r()};if(a.error)return(0,H.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[V(a.error,t),(0,H.jsx)(O,{onClick:()=>void a.mutate(),children:t?`重新加载`:`Reload`})]});if(!a.data)return(0,H.jsx)(k,{className:`h-32 w-full`});let p=a.data.workItems[0],m=async e=>{if(p){d(!0),l(void 0);try{await B(`/work-items/${p.id}`,`PATCH`,{expectedRevision:p.revision,status:e}),f()}catch(e){l(e)}finally{d(!1)}}};return(0,H.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4 sm:p-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这封邮件的跟进时间`:`Follow-up deadline`}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p?`${p.status===`watching`?t?`留意回复,到时检查`:`Watching replies; check at deadline`:p.status===`paused`?t?`已暂停跟进`:`Follow-up paused`:t?`已结束跟进`:`Follow-up ended`} · ${new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(p.dueAt)}`:t?`设置一个时间;此前有新回复时会重新判断是否还需要跟进。`:`Choose a deadline. New replies before then trigger a review of whether follow-up is still needed.`}),!!c&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:V(c,t)}),o?(0,H.jsx)(de,{initial:o.item?.dueAt,zh:t,onCancel:()=>{s(null),n(!1)},onSave:async t=>{l(void 0);try{o.item?await B(`/work-items/${o.item.id}`,`PATCH`,{expectedRevision:o.item.revision,dueAt:t,status:`watching`}):e.scope.kind===`objects`&&await B(i,`POST`,{subjectId:e.scope.ids[0],accountId:e.permissions.accountIds[0],dueAt:t}),f()}catch(e){throw l(e),e}}}):(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[p?.status!==`completed`&&(0,H.jsx)(O,{disabled:u||e.status!==`active`,onClick:()=>{s({item:p}),n(!0),l(void 0)},children:p?t?`重新设置跟进时间`:`Reschedule follow-up`:t?`设置跟进时间`:`Set deadline`}),p?.status===`watching`&&(0,H.jsx)(O,{disabled:u,onClick:()=>void m(`paused`),children:t?`暂停这次跟进`:`Pause follow-up`}),p&&p.status!==`completed`&&(0,H.jsx)(O,{disabled:u,onClick:()=>void m(`completed`),children:t?`结束这次跟进`:`End follow-up`})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?`结束跟进只停止检查,不表示邮件已发送或事情已经解决。`:`Ending stops checks; it does not mean a message was sent or the matter resolved.`})]})}function de({initial:e,zh:t,onSave:n,onCancel:r}){let[i,a]=(0,L.useState)(()=>{if(!e)return``;let t=new Date(e);return new Date(e-t.getTimezoneOffset()*6e4).toISOString().slice(0,16)}),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),u=async e=>{e.preventDefault();let t=new Date(i).getTime();if(!Number.isFinite(t)||t<=Date.now()){l(!0);return}l(!1),s(!0);try{await n(t)}catch{}finally{s(!1)}};return(0,H.jsx)(`form`,{onSubmit:e=>void u(e),children:(0,H.jsxs)(`fieldset`,{disabled:o,className:`space-y-3`,children:[(0,H.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[t?`跟进时间(当前设备时区)`:`Deadline (device time zone)`,(0,H.jsx)(`input`,{required:!0,type:`datetime-local`,value:i,onChange:e=>a(e.target.value),className:`min-h-11 w-full min-w-0 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),c&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t?`请选择未来的有效时间。`:`Choose a valid future time.`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(O,{type:`submit`,disabled:o,children:o?t?`正在保存…`:`Saving…`:t?`保存跟进时间`:`Save deadline`}),(0,H.jsx)(O,{type:`button`,onClick:r,children:t?`取消`:`Cancel`})]})]})})}var q=`min-h-11 w-full rounded-md border border-edge bg-surface-panel px-3 py-2 text-base text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:text-sm`,J=`min-w-0 rounded-xl border border-edge bg-surface-panel p-4 sm:p-6`,Y=`grid gap-2 text-sm font-medium text-fg`;function X(e,t){return{needs_setup:[`待完成设置`,`Finish setup`],active:[`已开启`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],archived:[`已归档`,`Archived`],running:[`正在检查`,`Checking`],succeeded:[`已准备成果`,`Result ready`],skipped:[`无需新行动`,`No new action`],retry_wait:[`等待来源或预算`,`Waiting for source or budget`],failed:[`检查失败`,`Check failed`],cancelled:[`已取消`,`Cancelled`]}[e]?.[+!t]??e}function Z(){let e=(0,R.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,H.jsx)(k,{className:`h-8 w-48`}),(0,H.jsx)(k,{className:`h-40 w-full`}),(0,H.jsx)(k,{className:`h-32 w-full`})]}),e[0]=t):t=e[0],t}function Q(e){let t=(0,R.c)(24),{error:n,retry:r}=e,i=g(fe)===`zh`;if(n?.status===503){let e=i?`场景尚未开放`:`Scenes are not available yet`,r;t[0]===e?r=t[1]:(r=(0,H.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:e}),t[0]=e,t[1]=r);let a;t[2]!==n||t[3]!==i?(a=V(n,i),t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===a?o=t[6]:(o=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}),t[5]=a,t[6]=o);let s=i?`返回对话`:`Back to chat`,c;t[7]===s?c=t[8]:(c=(0,H.jsx)(O,{asChild:!0,children:(0,H.jsx)(u,{to:`/chat`,children:s})}),t[7]=s,t[8]=c);let l;return t[9]!==r||t[10]!==o||t[11]!==c?(l=(0,H.jsxs)(`section`,{className:`${J} space-y-3`,children:[r,o,c]}),t[9]=r,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}let a;t[13]!==n||t[14]!==i?(a=V(n,i),t[13]=n,t[14]=i,t[15]=a):a=t[15];let o;t[16]===a?o=t[17]:(o=(0,H.jsx)(`p`,{className:`text-sm text-danger`,children:a}),t[16]=a,t[17]=o);let s;t[18]!==r||t[19]!==i?(s=r&&(0,H.jsxs)(O,{onClick:r,children:[(0,H.jsx)(I,{size:16,"aria-hidden":`true`}),i?`重新加载`:`Reload`]}),t[18]=r,t[19]=i,t[20]=s):s=t[20];let c;return t[21]!==o||t[22]!==s?(c=(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-edge p-4`,children:[o,s]}),t[21]=o,t[22]=s,t[23]=c):c=t[23],c}function fe(e){return e.language}function pe(){let e=(0,R.c)(5),t=h(ge);if(h(he)){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsx)(Q,{error:{status:401}}),e[0]=t):t=e[0],t}let n=t??`anonymous`,r,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={provider:me},i=(0,H.jsx)(_e,{}),e[1]=r,e[2]=i):(r=e[1],i=e[2]);let a;return e[3]===n?a=e[4]:(a=(0,H.jsx)(D,{value:r,children:i},n),e[3]=n,e[4]=a),a}function me(){return new Map}function he(e){return e.tokenExpired}function ge(e){return e.conversationId}function _e(){let e=(0,R.c)(20),{activationId:t,templateKey:n}=l(),r=a(`/scenes/inbox`),i=g(be)===`zh`,[o,c]=(0,L.useState)(!1),f=(0,L.useRef)(null),p=d(),[m]=s(),h=t&&p.state?.fromSceneInbox===!0?`/scenes/inbox${typeof p.state.inboxSearch==`string`?p.state.inboxSearch:``}`:void 0,_=F(ye),v=F(ve),y,b;e[0]!==v||e[1]!==_||e[2]!==i?(y=()=>{let e=i?`把需要持续留意的事交给 AI,把时间留给自己。`:`Let AI look after recurring needs, leaving more time for you.`,t=i?`查看全部成果`:`View all results`,n=i?`检查与提醒设置`:`Checks and reminders`;return _({startExtra:null,main:(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:i?`场景`:`Scenes`}),(0,H.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,title:e,children:e})]}),end:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(O,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,H.jsxs)(u,{"data-scene-inbox":!0,to:`/scenes/inbox`,"aria-label":t,title:t,children:[(0,H.jsx)(M,{className:`size-4`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`hidden sm:inline`,children:t})]})}),(0,H.jsx)(O,{ref:f,type:`button`,variant:`ghost`,className:`size-9 p-0`,"aria-label":n,title:n,"aria-haspopup":`dialog`,onClick:()=>c(!0),children:(0,H.jsx)(j,{className:`size-4`,"aria-hidden":`true`})})]})}),()=>v()},b=[v,_,i],e[0]=v,e[1]=_,e[2]=i,e[3]=y,e[4]=b):(y=e[3],b=e[4]),(0,L.useLayoutEffect)(y,b);let x;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,H.jsx)(`main`,{className:`h-full overflow-y-auto bg-surface-panel p-4 sm:p-8`,children:(0,H.jsx)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:(0,H.jsx)(Se,{})})}),e[5]=x):x=e[5];let S;e[6]!==t||e[7]!==r||e[8]!==h||e[9]!==m||e[10]!==n||e[11]!==i?(S=(t||n||r)&&(0,H.jsx)(xe,{titleText:r?m.has(`digest`)?i?`摘要中的成果`:`Results in this digest`:i?`场景成果`:`Scene results`:t?i?`场景详情`:`Scene details`:i?`了解并开启`:`Explore and start`,closeLabel:r?i?`关闭场景成果`:`Close scene results`:t?i?`关闭场景详情`:`Close scene details`:i?`关闭场景设置`:`Close scene setup`,backTo:h,backLabel:i?`返回成果`:`Back to results`,restoreSelector:r?`[data-scene-inbox]`:t?`[data-scene-id="${CSS.escape(t)}"]`:`[data-scene-template="${CSS.escape(n)}"]`,children:r?(0,H.jsx)($,{}):t?(0,H.jsx)(De,{id:t}):(0,H.jsx)(Ee,{templateKey:n})},t??n??`inbox`),e[6]=t,e[7]=r,e[8]=h,e[9]=m,e[10]=n,e[11]=i,e[12]=S):S=e[12];let C;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>f.current?.focus(),e[13]=C):C=e[13];let w;e[14]!==o||e[15]!==i?(w=(0,H.jsx)(oe,{zh:i,open:o,onOpenChange:c,onCloseAutoFocus:C}),e[14]=o,e[15]=i,e[16]=w):w=e[16];let T;return e[17]!==S||e[18]!==w?(T=(0,H.jsxs)(H.Fragment,{children:[x,S,w]}),e[17]=S,e[18]=w,e[19]=T):T=e[19],T}function ve(e){return e.clearPageHeader}function ye(e){return e.setPageHeader}function be(e){return e.language}function xe(e){let t=(0,R.c)(29),{titleText:n,closeLabel:r,restoreSelector:i,backTo:a,backLabel:s,children:c}=e,l=o(),d=(0,L.useRef)(null),f;t[0]===l?f=t[1]:(f=()=>l(`/scenes`,{replace:!0}),t[0]=l,t[1]=f);let m=f,h;t[2]===m?h=t[3]:(h=e=>{e||m()},t[2]=m,t[3]=h);let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,H.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[4]=g):g=t[4];let _;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{e.preventDefault(),d.current?.focus()},t[5]=_):_=t[5];let y;t[6]===i?y=t[7]:(y=e=>{e.preventDefault(),document.querySelector(i)?.focus()},t[6]=i,t[7]=y);let T;t[8]!==s||t[9]!==a?(T=a&&(0,H.jsx)(O,{asChild:!0,variant:`ghost`,className:`size-9 shrink-0 p-0`,children:(0,H.jsx)(u,{to:a,replace:!0,"aria-label":s,title:s,children:(0,H.jsx)(te,{size:18,"aria-hidden":`true`})})}),t[8]=s,t[9]=a,t[10]=T):T=t[10];let E;t[11]===n?E=t[12]:(E=(0,H.jsx)(C,{ref:d,tabIndex:-1,className:`min-w-0 flex-1 text-base font-semibold text-fg outline-none`,children:n}),t[11]=n,t[12]=E);let D;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,H.jsx)(p,{size:18,"aria-hidden":`true`}),t[13]=D):D=t[13];let k;t[14]===r?k=t[15]:(k=(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r,title:r,children:D})}),t[14]=r,t[15]=k);let A;t[16]!==T||t[17]!==E||t[18]!==k?(A=(0,H.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3 sm:px-6`,children:[T,E,k]}),t[16]=T,t[17]=E,t[18]=k,t[19]=A):A=t[19];let j;t[20]===c?j=t[21]:(j=(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-6`,children:(0,H.jsx)(`div`,{className:`space-y-6`,children:c})}),t[20]=c,t[21]=j);let M;t[22]!==A||t[23]!==j||t[24]!==y?(M=(0,H.jsxs)(x,{children:[g,(0,H.jsxs)(S,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(52rem,calc(100dvh-2rem))] w-[min(52rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,"aria-describedby":void 0,onOpenAutoFocus:_,onCloseAutoFocus:y,children:[A,j]})]}),t[22]=A,t[23]=j,t[24]=y,t[25]=M):M=t[25];let N;return t[26]!==M||t[27]!==h?(N=(0,H.jsx)(w,{open:!0,onOpenChange:h,children:M}),t[26]=M,t[27]=h,t[28]=N):N=t[28],N}function Se(){let e=(0,R.c)(48),{activationId:t}=l(),n=g(Ce)===`zh`,[r,i]=s(),a;e[0]===r?a=e[1]:(a=r.get(`after`)??``,e[0]=r,e[1]=a);let o=a,c=E(`/templates`,z),d=E(`/activations?limit=20&afterId=${encodeURIComponent(o)}`,z),f=d.mutate,p,m;if(e[2]!==t||e[3]!==f?(p=()=>{t||f()},m=[t,f],e[2]=t,e[3]=f,e[4]=p,e[5]=m):(p=e[4],m=e[5]),(0,L.useEffect)(p,m),c.error||d.error){let t=c.error??d.error,n;e[6]!==d||e[7]!==c?(n=()=>{c.mutate(),d.mutate()},e[6]=d,e[7]=c,e[8]=n):n=e[8];let r;return e[9]!==t||e[10]!==n?(r=(0,H.jsx)(Q,{error:t,retry:n}),e[9]=t,e[10]=n,e[11]=r):r=e[11],r}if(!c.data||!d.data){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsx)(Z,{}),e[12]=t):t=e[12],t}let h=n?`你想先轻松一点的事`:`Where could you use a little help?`,_;e[13]===h?_=e[14]:(_=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:h}),e[13]=h,e[14]=_);let v;if(e[15]!==c.data.templates||e[16]!==n){let t;e[18]===n?t=e[19]:(t=e=>(0,H.jsxs)(`article`,{className:`${J} space-y-3`,children:[(0,H.jsx)(ne,{className:`text-fg-muted`,size:20,"aria-hidden":`true`}),(0,H.jsx)(`h3`,{className:`text-balance font-medium text-fg`,children:e.title}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.description}),(0,H.jsx)(O,{asChild:!0,children:(0,H.jsx)(u,{"data-scene-template":e.key,to:`/scenes/new/${encodeURIComponent(e.key)}?version=${encodeURIComponent(e.version)}`,children:n?`了解并开启`:`Explore and start`})})]},`${e.key}:${e.version}`),e[18]=n,e[19]=t),v=c.data.templates.map(t),e[15]=c.data.templates,e[16]=n,e[17]=v}else v=e[17];let y;e[20]===v?y=e[21]:(y=(0,H.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:v}),e[20]=v,e[21]=y);let b;e[22]!==_||e[23]!==y?(b=(0,H.jsxs)(`section`,{className:`space-y-3`,children:[_,y]}),e[22]=_,e[23]=y,e[24]=b):b=e[24];let x=n?`我的场景`:`My scenes`,S;e[25]===x?S=e[26]:(S=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x}),e[25]=x,e[26]=S);let C;e[27]!==d.data.activations||e[28]!==n?(C=d.data.activations.length?d.data.activations.map(e=>(0,H.jsxs)(u,{to:`/scenes/${e.id}`,"data-scene-id":e.id,className:`${J} block space-y-2 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,H.jsx)(`p`,{className:`break-words font-medium text-fg`,children:e.goal}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:X(e.status===`active`&&e.setupMissing?.length?`needs_setup`:e.status,n)})]},e.id)):(0,H.jsxs)(`div`,{className:`${J} space-y-2`,children:[(0,H.jsx)(N,{"aria-hidden":`true`,className:`text-fg-muted`}),(0,H.jsx)(`p`,{className:`text-fg`,children:n?`还没有开启场景`:`No scenes yet`}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`从上面选择一件你希望 AI 帮忙照看的事。`:`Choose something above that you would like AI to look after.`})]}),e[27]=d.data.activations,e[28]=n,e[29]=C):C=e[29];let w;e[30]!==o||e[31]!==i||e[32]!==n?(w=o&&(0,H.jsx)(O,{onClick:()=>i({}),children:n?`返回第一页`:`First page`}),e[30]=o,e[31]=i,e[32]=n,e[33]=w):w=e[33];let T;e[34]!==d.data.nextCursor||e[35]!==i||e[36]!==n?(T=d.data.nextCursor&&(0,H.jsx)(O,{onClick:()=>i({after:d.data.nextCursor}),children:n?`下一页`:`Next page`}),e[34]=d.data.nextCursor,e[35]=i,e[36]=n,e[37]=T):T=e[37];let D;e[38]!==w||e[39]!==T?(D=(0,H.jsxs)(`div`,{className:`flex gap-3`,children:[w,T]}),e[38]=w,e[39]=T,e[40]=D):D=e[40];let k;e[41]!==C||e[42]!==D||e[43]!==S?(k=(0,H.jsxs)(`section`,{className:`space-y-3`,children:[S,C,D]}),e[41]=C,e[42]=D,e[43]=S,e[44]=k):k=e[44];let A;return e[45]!==k||e[46]!==b?(A=(0,H.jsxs)(H.Fragment,{children:[b,k]}),e[45]=k,e[46]=b,e[47]=A):A=e[47],A}function Ce(e){return e.language}function we(e){let t=(0,R.c)(20),{zh:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={refreshInterval:15e3,shouldRetryOnError:!1},t[0]=r):r=t[0];let i=E(`/metrics`,z,r),a;t[1]===n?a=t[2]:(a=n?[`有帮助的成果`,`没有帮助的成果`,`带来帮助的场景`]:[`Helpful results`,`Unhelpful results`,`Scenes that helped`],t[1]=n,t[2]=a);let o=a,s,c,l,u;if(t[3]!==o||t[4]!==i||t[5]!==n){let e=i.data?[i.data.usefulOutcomes,i.data.unhelpfulOutcomes,i.data.scenesWithUsefulOutcomes]:[],r=new Intl.NumberFormat(n?`zh-CN`:`en`);s=`${J} space-y-3`,c=n?`反馈概览`:`Feedback overview`;let a=n?`最近 7 天的反馈`:`Feedback in the last 7 days`;t[10]===a?l=t[11]:(l=(0,H.jsx)(`h2`,{className:`text-balance text-base font-semibold text-fg`,children:a}),t[10]=a,t[11]=l),u=i.error?(0,H.jsxs)(`div`,{role:`alert`,className:`space-y-2`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法加载统计,仍可查看和评价成果。`:`Stats are unavailable. You can still view and rate results.`}),(0,H.jsx)(O,{disabled:i.isValidating,onClick:()=>void i.mutate(),children:n?`重新加载统计`:`Reload stats`})]}):(0,H.jsx)(`dl`,{className:`grid gap-4 sm:grid-cols-3`,"aria-busy":!i.data,children:o.map((t,n)=>(0,H.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,H.jsx)(`dt`,{className:`text-sm text-fg-muted`,children:t}),(0,H.jsx)(`dd`,{className:`text-xl font-semibold tabular-nums text-fg`,children:i.data?r.format(e[n]):(0,H.jsx)(k,{className:`h-7 w-12`})})]},t))}),t[3]=o,t[4]=i,t[5]=n,t[6]=s,t[7]=c,t[8]=l,t[9]=u}else s=t[6],c=t[7],l=t[8],u=t[9];let d=n?`按你这段时间的明确反馈统计,每份成果取最新评价。已读和检查成功不计入,也不代表已采纳或节省时间。`:`Counts your explicit feedback during this period, using the latest rating per result. Reads and successful checks do not count. This does not measure adoption or time saved.`,f;t[12]===d?f=t[13]:(f=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d}),t[12]=d,t[13]=f);let p;return t[14]!==s||t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==f?(p=(0,H.jsxs)(`section`,{className:s,"aria-label":c,children:[l,u,f]}),t[14]=s,t[15]=c,t[16]=l,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function $(){let e=(0,R.c)(42),t=g(Te)===`zh`,[n,r]=s(),i;e[0]===n?i=e[1]:(i=n.get(`after`)??``,e[0]=n,e[1]=i);let a=i,o;e[2]===n?o=e[3]:(o=n.get(`digest`),e[2]=n,e[3]=o);let c=o,l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l={refreshInterval:15e3},e[4]=l):l=e[4];let d=E(`${c?`/digests/${encodeURIComponent(c)}`:`/outcomes`}?limit=20&afterId=${encodeURIComponent(a)}`,z,l);if(d.error){let t;e[5]===d?t=e[6]:(t=()=>void d.mutate(),e[5]=d,e[6]=t);let n;return e[7]!==d.error||e[8]!==t?(n=(0,H.jsx)(Q,{error:d.error,retry:t}),e[7]=d.error,e[8]=t,e[9]=n):n=e[9],n}if(!d.data){let t;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsx)(Z,{}),e[10]=t):t=e[10],t}let f=t?`集中查看各个场景准备的成果,告诉 AI 哪些对你有帮助。`:`Review results across your scenes and tell AI what helps.`,p;e[11]===f?p=e[12]:(p=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f}),e[11]=f,e[12]=p);let m;e[13]===t?m=e[14]:(m=(0,H.jsx)(we,{zh:t}),e[13]=t,e[14]=m);let h=t?`成果列表`:`Results list`,_;e[15]!==c||e[16]!==n||e[17]!==d||e[18]!==t?(_=d.data.outcomes.length?d.data.outcomes.map(e=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(W,{item:e,zh:t,onChange:()=>void d.mutate()}),(0,H.jsx)(O,{asChild:!0,variant:`ghost`,children:(0,H.jsx)(u,{state:{fromSceneInbox:!0,inboxSearch:`?${n.toString()}`},to:`/scenes/${encodeURIComponent(e.activationId)}`,children:t?`查看所属场景`:`View scene`})})]},e.id)):(0,H.jsxs)(`div`,{className:`${J} space-y-3`,children:[(0,H.jsx)(M,{size:32,"aria-hidden":`true`,className:`text-fg-muted`}),(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`这里还没有成果`:`No results here yet`}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c?t?`这份摘要中的成果目前不可查看,可能已被撤回。`:`Results in this digest are currently unavailable and may have been withdrawn.`:t?`回到场景,提供资料并检查一次;有新成果时会出现在这里。`:`Open a scene, provide context and run a check. New results will appear here.`})]}),e[15]=c,e[16]=n,e[17]=d,e[18]=t,e[19]=_):_=e[19];let v;e[20]!==h||e[21]!==_?(v=(0,H.jsx)(`section`,{className:`space-y-4`,"aria-label":h,children:_}),e[20]=h,e[21]=_,e[22]=v):v=e[22];let y=t?`成果分页`:`Results pages`,b;e[23]!==a||e[24]!==c||e[25]!==r||e[26]!==t?(b=a&&(0,H.jsx)(O,{onClick:()=>r(c?{digest:c}:{}),children:t?`返回第一页`:`First page`}),e[23]=a,e[24]=c,e[25]=r,e[26]=t,e[27]=b):b=e[27];let x;e[28]!==c||e[29]!==d.data.nextCursor||e[30]!==r||e[31]!==t?(x=d.data.nextCursor&&(0,H.jsx)(O,{onClick:()=>r({...c?{digest:c}:{},after:d.data.nextCursor}),children:t?`下一页`:`Next page`}),e[28]=c,e[29]=d.data.nextCursor,e[30]=r,e[31]=t,e[32]=x):x=e[32];let S;e[33]!==b||e[34]!==x||e[35]!==y?(S=(0,H.jsxs)(`nav`,{className:`flex flex-wrap gap-3`,"aria-label":y,children:[b,x]}),e[33]=b,e[34]=x,e[35]=y,e[36]=S):S=e[36];let C;return e[37]!==S||e[38]!==p||e[39]!==m||e[40]!==v?(C=(0,H.jsxs)(H.Fragment,{children:[p,m,v,S]}),e[37]=S,e[38]=p,e[39]=m,e[40]=v,e[41]=C):C=e[41],C}function Te(e){return e.language}function Ee({templateKey:e}){let t=g(e=>e.language)===`zh`,[n]=s(),r=o(),i=n.get(`version`)??`1.0.0`,a=E(`/templates/${encodeURIComponent(e)}/versions/${encodeURIComponent(i)}`,z),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(!1),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(),[x,S]=(0,L.useState)(!1),C=(0,L.useRef)({content:``,id:``}),w=(0,L.useRef)(``),T=!!(c||f||m)&&!x;if((0,L.useEffect)(()=>{x&&r(w.current,{replace:!0})},[x,r]),a.error)return(0,H.jsx)(Q,{error:a.error,retry:()=>void a.mutate()});if(!a.data)return(0,H.jsx)(Z,{});let D=a.data.template,k=D.contextProviders.includes(`mail`),A=async t=>{t.preventDefault(),v(!0),b(void 0);let n={templateKey:e,templateVersion:i,goal:c,scope:k?{kind:`objects`,ids:[f.trim()]}:{kind:`personal`},permissions:{accountIds:k?[u.trim()]:[],contextProviders:D.contextProviders,effectHandlers:[]}},r=JSON.stringify(n);C.current.content!==r&&(C.current={content:r,id:crypto.randomUUID()});try{w.current=`/scenes/${(await B(`/activations`,`POST`,n,C.current.id)).activation.id}`,S(!0)}catch(e){b(e)}finally{v(!1)}};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{dirty:T,zh:t}),(0,H.jsxs)(`header`,{children:[(0,H.jsx)(`h1`,{className:`text-wrap text-xl font-semibold text-fg`,children:D.title}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:D.description})]}),(0,H.jsx)(`form`,{onSubmit:e=>void A(e),className:`${J} space-y-5`,children:(0,H.jsxs)(`fieldset`,{disabled:_||x,className:`space-y-5`,children:[(0,H.jsxs)(`label`,{className:Y,children:[t?`希望它持续帮你做好什么?`:`What should it keep helping you with?`,(0,H.jsx)(`textarea`,{required:!0,maxLength:4e3,rows:3,value:c,onChange:e=>l(e.target.value),className:q,autoComplete:`off`})]}),k&&(0,H.jsx)(le,{value:f,disabled:_||x,zh:t,onChange:e=>{d(e.accountId),p(e.id),h(!1)}}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备草稿和建议,不发送消息、不执行外部写操作。下一步需补齐资料和检查时间;完成后才会自动检查。`:`Prepares drafts and suggestions only. No messages or external writes. Next, complete the context and timing settings for automatic checks.`}),(0,H.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm text-fg`,children:[(0,H.jsx)(`input`,{required:!0,type:`checkbox`,className:`ui-checkbox`,checked:m,onChange:e=>h(e.target.checked)}),t?`确认以上范围,允许读取我提供的资料。`:`I confirm this scope and allow reading the information I provide.`]}),!!y&&(0,H.jsx)(Q,{error:y}),(0,H.jsx)(O,{type:`submit`,variant:`primary`,disabled:_||x||k&&!f,children:_?t?`正在开启…`:`Starting…`:t?`继续设置`:`Continue setup`})]})})]})}function De({id:e}){let t=g(e=>e.language)===`zh`,[n]=s(),r=n.get(`result`),i=`/activations/${encodeURIComponent(e)}`,[a,o]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),u=E(i,z,{refreshInterval:15e3}),d=E(`${i}/runs?limit=20&afterId=${encodeURIComponent(a)}`,z,{refreshInterval:5e3}),f=E(`/outcomes?limit=20&activationId=${encodeURIComponent(e)}&afterId=${encodeURIComponent(c)}`,z,{refreshInterval:5e3}),[p,m]=(0,L.useState)(!1),[h,_]=(0,L.useState)(),[v,y]=(0,L.useState)(!1),b=(0,L.useRef)(null),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),[T,D]=(0,L.useState)(!1),k=x||C||T,A=async e=>{if(u.data){m(!0),_(void 0),y(!1);try{e?(b.current??=crypto.randomUUID(),await B(`${i}/checks`,`POST`,void 0,b.current),b.current=null,y(!0),o(``),l(``)):await B(i,`PATCH`,{expectedRevision:u.data.activation.revision,status:u.data.activation.status===`active`?`paused`:`active`}),await Promise.all([u.mutate(),d.mutate(),f.mutate()])}catch(e){_(e)}finally{m(!1)}}};if(u.error)return(0,H.jsx)(Q,{error:u.error,retry:()=>void u.mutate()});if(!u.data)return(0,H.jsx)(Z,{});let j=u.data.activation;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{dirty:k,zh:t}),(0,H.jsxs)(`header`,{className:`space-y-3`,children:[(0,H.jsx)(`h1`,{className:`break-words text-wrap text-xl font-semibold text-fg`,children:j.goal}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:X(j.status===`active`&&j.setupMissing?.length?`needs_setup`:j.status,t)}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只准备建议和成果,不自动发送或写入外部系统。`:`Prepares suggestions and results. Does not send or write to external systems.`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,H.jsx)(O,{variant:`primary`,disabled:p||j.status!==`active`,onClick:()=>void A(!0),children:p?t?`处理中…`:`Working…`:t?`现在检查`:`Check now`}),[`active`,`paused`,`needs_setup`].includes(j.status)&&(0,H.jsxs)(O,{disabled:p,onClick:()=>void A(!1),children:[(0,H.jsx)(ee,{size:16,"aria-hidden":`true`}),j.status===`active`?t?`暂停场景`:`Pause scene`:t?`检查设置并恢复`:`Review setup and resume`]})]}),[`active`,`paused`].includes(j.status)&&(0,H.jsx)(O,{disabled:p,variant:`ghost`,onClick:()=>{m(!0),B(i,`PATCH`,{expectedRevision:j.revision,status:`completed`}).then(()=>Promise.all([u.mutate(),f.mutate(),d.mutate()])).catch(_).finally(()=>m(!1))},children:t?`结束场景(保留成果)`:`End scene (keep results)`}),v&&(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t?`检查已排队;没有新变化时不会生成新卡片。`:`Check queued. No new card is created when nothing has changed.`})]}),h&&(0,H.jsx)(Q,{error:h,retry:()=>{u.mutate(),_(void 0)}}),j.status===`active`&&!!j.setupMissing?.length&&(0,H.jsxs)(`section`,{role:`status`,className:J,children:[(0,H.jsx)(`h2`,{className:`font-medium text-fg`,children:t?`完成以下设置后,场景才会自动检查`:`Complete setup for automatic checks`}),(0,H.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-sm text-fg-muted`,children:j.setupMissing.map(e=>(0,H.jsx)(`li`,{children:{notes:t?`填写安排和约束`:`Provide arrangements and constraints`,schedule:t?`设置周期检查时间`:`Set a recurring review time`,deadline:t?`设置邮件跟进截止时间`:`Set a mail follow-up deadline`}[e]},e))})]}),(0,H.jsx)(re,{activationId:e,zh:t}),[`active`,`paused`,`needs_setup`].includes(j.status)&&(0,H.jsx)(Oe,{activation:j,zh:t,onDirty:D,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}},j.revision),j.permissions.contextProviders.includes(`user_notes`)&&(0,H.jsx)(Ae,{path:i,zh:t,onDirty:S,onSaved:()=>{u.mutate(),f.mutate(),d.mutate()}}),j.templateKey===`mail-follow-up`?(0,H.jsx)(ue,{activation:j,zh:t,onDirty:w,onChanged:()=>{u.mutate(),f.mutate(),d.mutate()}}):(0,H.jsx)(K,{activation:j,zh:t,onDirty:w,onChanged:()=>void u.mutate()}),r&&(0,H.jsx)(ke,{activationId:e,presentationId:r,zh:t}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`最近成果`:`Recent results`}),f.error?(0,H.jsx)(Q,{error:f.error,retry:()=>void f.mutate()}):f.data?f.data.outcomes.filter(t=>t.activationId===e).length===0?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`还没有新成果。提供资料后,可以先检查一次。`:`No new results yet. Provide context and try a check.`}):f.data.outcomes.map(e=>(0,H.jsx)(W,{item:e,zh:t,onChange:()=>void f.mutate()},e.id)):(0,H.jsx)(Z,{}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[c&&(0,H.jsx)(O,{onClick:()=>l(``),children:t?`最近成果`:`Latest results`}),f.data?.nextCursor&&(0,H.jsx)(O,{onClick:()=>l(f.data.nextCursor),children:t?`更早成果`:`Earlier results`})]})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t?`检查记录`:`Check history`}),d.error?(0,H.jsx)(Q,{error:d.error,retry:()=>void d.mutate()}):d.data?d.data.runs.length===0?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`尚未执行检查。`:`No checks yet.`}):(0,H.jsx)(`ul`,{className:`divide-y divide-edge`,children:d.data.runs.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 py-3 text-sm`,children:[(0,H.jsxs)(`span`,{className:`text-fg`,children:[X(e.status,t),e.reason===`empty_input`?t?`:请先提供资料`:`: provide context first`:``]}),(0,H.jsx)(`time`,{className:`text-fg-muted`,dateTime:new Date(e.createdAt).toISOString(),children:new Intl.DateTimeFormat(t?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}).format(e.createdAt)})]},e.id))}):(0,H.jsx)(Z,{}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[a&&(0,H.jsx)(O,{onClick:()=>o(``),children:t?`最近检查`:`Latest checks`}),d.data?.nextCursor&&(0,H.jsx)(O,{onClick:()=>o(d.data.nextCursor),children:t?`更早检查`:`Earlier checks`})]})]})]})}function Oe(e){let t=(0,R.c)(39),{activation:n,zh:r,onDirty:i,onSaved:a}=e,[o,s]=(0,L.useState)(n.goal),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(),f,p;t[0]!==n.goal||t[1]!==o||t[2]!==i?(f=()=>(i(o!==n.goal),()=>i(!1)),p=[o,n.goal,i],t[0]=n.goal,t[1]=o,t[2]=i,t[3]=f,t[4]=p):(f=t[3],p=t[4]),(0,L.useEffect)(f,p);let m=r?`修改目标`:`Edit goal`,h;t[5]===m?h=t[6]:(h=(0,H.jsx)(`summary`,{className:`cursor-pointer`,children:m}),t[5]=m,t[6]=h);let g=r?`保存后暂停检查并撤回旧建议。确认设置后恢复;邮件跟进时间需另行恢复。`:`Saving pauses checks and withdraws previous suggestions. Review settings before resuming, including mail deadlines.`,_;t[7]===g?_=t[8]:(_=(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g}),t[7]=g,t[8]=_);let v=r?`新目标`:`New goal`,y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>s(e.target.value),t[9]=y):y=t[9];let b;t[10]===o?b=t[11]:(b=(0,H.jsx)(`textarea`,{value:o,maxLength:4e3,onChange:y,className:q}),t[10]=o,t[11]=b);let x;t[12]!==v||t[13]!==b?(x=(0,H.jsxs)(`label`,{className:Y,children:[v,b]}),t[12]=v,t[13]=b,t[14]=x):x=t[14];let S;t[15]!==n.goal||t[16]!==c||t[17]!==o?(S=c||!o.trim()||o===n.goal,t[15]=n.goal,t[16]=c,t[17]=o,t[18]=S):S=t[18];let C;t[19]!==n.id||t[20]!==n.permissions||t[21]!==n.revision||t[22]!==n.scope||t[23]!==o||t[24]!==a?(C=()=>{l(!0),d(void 0),B(`/activations/${n.id}`,`PATCH`,{expectedRevision:n.revision,goal:o,scope:n.scope,permissions:n.permissions}).then(a).catch(d).finally(()=>l(!1))},t[19]=n.id,t[20]=n.permissions,t[21]=n.revision,t[22]=n.scope,t[23]=o,t[24]=a,t[25]=C):C=t[25];let w=r?`保存目标`:`Save goal`,T;t[26]!==S||t[27]!==C||t[28]!==w?(T=(0,H.jsx)(O,{disabled:S,onClick:C,children:w}),t[26]=S,t[27]=C,t[28]=w,t[29]=T):T=t[29];let E;t[30]!==u||t[31]!==r?(E=u!=null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-danger`,children:V(u,r)}),t[30]=u,t[31]=r,t[32]=E):E=t[32];let D;return t[33]!==x||t[34]!==T||t[35]!==E||t[36]!==h||t[37]!==_?(D=(0,H.jsxs)(`details`,{className:`${J} space-y-3`,children:[h,_,x,T,E]}),t[33]=x,t[34]=T,t[35]=E,t[36]=h,t[37]=_,t[38]=D):D=t[38],D}function ke(e){let t=(0,R.c)(15),{activationId:n,presentationId:r,zh:i}=e,a=E(`/presentations/${encodeURIComponent(r)}`,z);if(a.error){let e;return t[0]===a.error?e=t[1]:(e=(0,H.jsx)(Q,{error:a.error}),t[0]=a.error,t[1]=e),e}if(!a.data){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(Z,{}),t[2]=e):e=t[2],e}if(a.data.outcome.activationId!==n){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(Q,{error:{status:404}}),t[3]=e):e=t[3],e}let o=i?`通知中的成果`:`Result from notification`,s;t[4]===o?s=t[5]:(s=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:o}),t[4]=o,t[5]=s);let c;t[6]===a?c=t[7]:(c=()=>void a.mutate(),t[6]=a,t[7]=c);let l;t[8]!==a.data.outcome||t[9]!==c||t[10]!==i?(l=(0,H.jsx)(W,{item:a.data.outcome,zh:i,onChange:c},a.data.outcome.id),t[8]=a.data.outcome,t[9]=c,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==s||t[13]!==l?(u=(0,H.jsxs)(`section`,{className:`space-y-3`,children:[s,l]}),t[12]=s,t[13]=l,t[14]=u):u=t[14],u}function Ae({path:e,zh:t,onSaved:n,onDirty:r}){let i=E(`${e}/notes`,z,{revalidateOnFocus:!1}),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(),d=a!==null&&a.content!==i.data?.notes.content;if((0,L.useEffect)(()=>(r(d),()=>r(!1)),[d,r]),i.error)return(0,H.jsx)(Q,{error:i.error,retry:()=>void i.mutate()});if(!i.data)return(0,H.jsx)(Z,{});let f=async t=>{t.preventDefault(),c(!0),u(void 0);try{let{content:t,revision:r,validUntil:s}=a??i.data.notes,c=await B(`${e}/notes`,`PATCH`,{expectedRevision:r,content:t,validUntil:s});await i.mutate({notes:{content:t.trim(),revision:c.revision,validUntil:s}},{revalidate:!1}),o(null),n()}catch(e){u(e)}finally{c(!1)}};return(0,H.jsxs)(`form`,{onSubmit:e=>void f(e),className:`${J} space-y-3`,children:[(0,H.jsxs)(`label`,{className:Y,children:[t?`你愿意提供的安排和约束`:`Arrangements and constraints you choose to share`,(0,H.jsx)(`textarea`,{disabled:s,rows:5,maxLength:32e3,className:q,value:a?.content??i.data.notes.content,onChange:e=>o(t=>({...t??i.data.notes,content:e.target.value})),autoComplete:`off`})]}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`只用于这个场景,不会因此访问其他家庭成员的数据。修改资料会撤回旧计划。`:`Used only in this scene. Does not grant access to other family members. Editing withdraws the previous plan.`}),!!l&&(0,H.jsx)(Q,{error:l}),(0,H.jsx)(O,{type:`submit`,disabled:s||!d,children:s?t?`正在保存…`:`Saving…`:t?`保存资料`:`Save context`}),d&&(0,H.jsx)(O,{type:`button`,disabled:s,variant:`ghost`,onClick:()=>{o(null),u(void 0),i.mutate()},children:t?`放弃修改并重新加载`:`Discard edits and reload`})]})}export{pe as ScenesPage};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-B-GDnZO9.js";import{t as a}from"./cn-JdwAhgNB.js";import{_o as o,bo as s}from"./index-DxYitLp8.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:i,value:a,onChange:u,disabled:d}=e,f=typeof i.description==`string`?i.description:void 0,p=(typeof i[`x-placeholder`]==`string`?i[`x-placeholder`]:null)||f,m=i.format;if(Array.isArray(i.enum)&&i.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 o;t[2]===u?o=t[3]:(o=e=>u(e.target.value),t[2]=u,t[3]=o);let s;t[4]===i.enum?s=t[5]:(s=i.enum.map(_),t[4]=i.enum,t[5]=s);let c;t[6]!==d||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a?(c=(0,l.jsx)(r,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:a,disabled:d,onChange:o,children:s}),t[6]=d,t[7]=n,t[8]=o,t[9]=s,t[10]=a,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]!==a?(n=(0,l.jsx)(s,{value:a,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]=a,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]!==a?(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:a,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=a,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)(i,{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:r,onChange:i,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]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,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]!==r){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=a(`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]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:r[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]=r,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]=r,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{n as r,r as i}from"./popover-select-B-GDnZO9.js";import{t as a}from"./cn-JdwAhgNB.js";import{_o as o,bo as s}from"./index-PFQHPGgi.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:i,value:a,onChange:u,disabled:d}=e,f=typeof i.description==`string`?i.description:void 0,p=(typeof i[`x-placeholder`]==`string`?i[`x-placeholder`]:null)||f,m=i.format;if(Array.isArray(i.enum)&&i.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 o;t[2]===u?o=t[3]:(o=e=>u(e.target.value),t[2]=u,t[3]=o);let s;t[4]===i.enum?s=t[5]:(s=i.enum.map(_),t[4]=i.enum,t[5]=s);let c;t[6]!==d||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a?(c=(0,l.jsx)(r,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:a,disabled:d,onChange:o,children:s}),t[6]=d,t[7]=n,t[8]=o,t[9]=s,t[10]=a,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]!==a?(n=(0,l.jsx)(s,{value:a,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]=a,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]!==a?(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:a,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=a,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)(i,{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:r,onChange:i,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]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,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]!==r){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=a(`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]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:r[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]=r,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]=r,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};