@xopcai/xopc 0.0.160 → 0.0.161

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 (117) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{action-boundary-settings-panel-CY3sizqC.js → action-boundary-settings-panel-BIVBUiNT.js} +1 -1
  4. package/dist/gateway/static/root/assets/activity-store-o7GRljfD.js +1 -0
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B_27aaZQ.js → agent-avatar-dicebear-9R3szLMc.js} +1 -1
  6. package/dist/gateway/static/root/assets/{agents-B1l3iii6.js → agents-_qbUaYbs.js} +1 -1
  7. package/dist/gateway/static/root/assets/{api-BbzB57CJ.js → api-jSTqFMq9.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-DfmyWcyh.js → app-management-settings-panel-D81cyE76.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-B2v0c-K-.js → appearance-settings-Ct6bZQCV.js} +1 -1
  10. package/dist/gateway/static/root/assets/{apps-page-DaNFLsp0.js → apps-page-0sPqD0FK.js} +1 -1
  11. package/dist/gateway/static/root/assets/{archive-plugin-DL5Lnx0C.js → archive-plugin-CfD7AZKn.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-InuP-ZjQ.js → attachment-load-CP_Gaxt3.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automation-suggestion-card-CahGuh7B.js → automation-suggestion-card-BGKM_NDZ.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automations-page-Cd0gMx6p.js → automations-page-BxWBuBsE.js} +3 -3
  15. package/dist/gateway/static/root/assets/{binary-plugins-CdOTGYVu.js → binary-plugins-IPr2EVnS.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-D6ShK1S-.js → block-editor-B6aHEGA6.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-settings-page-BmUYDL2Z.js → browser-settings-page-C499b9AH.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capability-presets-api-BzoLm52Z.js → capability-presets-api-CCX9-LjU.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CE7mrWtS.js → capability-presets-settings-panel-Dva9SiPK.js} +1 -1
  20. package/dist/gateway/static/root/assets/{channel-recipient-api-DbgydMjl.js → channel-recipient-api-MmLMLDWf.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-D1_gcAHK.js → channels-settings-DNAU7u9o.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-status-swr-CIOH7tgn.js +1 -0
  23. package/dist/gateway/static/root/assets/check-DUBLcKHA.js +1 -0
  24. package/dist/gateway/static/root/assets/circle-alert-BEjgurr2.js +1 -0
  25. package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +1 -0
  26. package/dist/gateway/static/root/assets/{connector-logo-C3bJC9nt.js → connector-logo-BbjzIs87.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-TwiBp8vY.js +2 -0
  28. package/dist/gateway/static/root/assets/createLucideIcon-DPHK1VkS.js +1 -0
  29. package/dist/gateway/static/root/assets/{desktop-pet-wacrnJJ1.js → desktop-pet-CYH5ZSXy.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-BrHVvbBw.js → desktop-pet-settings-DQLqGLc0.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-sprite-CFd1jGLJ.js → desktop-pet-sprite-DTqXSpqf.js} +1 -1
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-BPI969w-.js → directory-picker-path-field-ClsiXhmz.js} +1 -1
  33. package/dist/gateway/static/root/assets/{dreaming-settings-iw6QXD45.js → dreaming-settings-CjMPPdzg.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-debug-page-rCHyhEr6.js → extension-debug-page-57eizjhB.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-C4gQsAPt.js → extension-page-CsbSb3u1.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-DB_3eik7.js → extension-settings-page-DKA9-lyP.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-api-Cdt38iF2.js → gateway-config-api-DIPJuzBZ.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-DM4BgyGw.js → gateway-settings-CDLqAQY7.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-ChRFNjj_.js → gateway-startup-retry-DrfSJtvT.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goal-create-dialog-BQamcEmF.js → goal-create-dialog-Q3B0E-0s.js} +1 -1
  41. package/dist/gateway/static/root/assets/{goal-detail-page-DZUQ0Lf1.js → goal-detail-page-C5VAK04G.js} +1 -1
  42. package/dist/gateway/static/root/assets/{goals-config-api-RvljeEm6.js → goals-config-api-lGC10UkU.js} +1 -1
  43. package/dist/gateway/static/root/assets/{goals-page-BtxVD27C.js → goals-page-BJb-5IYw.js} +2 -2
  44. package/dist/gateway/static/root/assets/{goals-settings-DMGV4S4L.js → goals-settings-BWq0pdrA.js} +1 -1
  45. package/dist/gateway/static/root/assets/{heartbeat-settings-B8r5EXc5.js → heartbeat-settings-D4o8BJVv.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-CkUHH170.css +1 -0
  47. package/dist/gateway/static/root/assets/index-vq_cJZJC.js +199 -0
  48. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-1-LYibQ4.js → keyboard-shortcuts-settings-6T2QYehS.js} +1 -1
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-euH17Kvb.js +2 -0
  50. package/dist/gateway/static/root/assets/{local-apps-page-CC4vtUUI.js → local-apps-page-DCjg2K9f.js} +1 -1
  51. package/dist/gateway/static/root/assets/{locale-store-CPbGB_6l.js → locale-store-Dar-xqQr.js} +1 -1
  52. package/dist/gateway/static/root/assets/{logs-page-Bn_taxBV.js → logs-page-CyYCBqym.js} +1 -1
  53. package/dist/gateway/static/root/assets/{markdown-split-CprEIf8A.js → markdown-split-rt1XO43g.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-BXt_Sj2O.js → media-plugins-Bwo8CJuh.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-CxySDn9d.js +5 -0
  56. package/dist/gateway/static/root/assets/{models-hub-panel-DJReXRP9.js → models-hub-panel-DObxxjc9.js} +1 -1
  57. package/dist/gateway/static/root/assets/{notes-page-Wf5-eyyM.js → notes-page-Dp-pkX7d.js} +1 -1
  58. package/dist/gateway/static/root/assets/{notes-workbench-BbdjzYzs.js → notes-workbench-CCb4RXcZ.js} +2 -2
  59. package/dist/gateway/static/root/assets/{page-tabs-dtpK_4Fs.js → page-tabs-CzZ4iKOb.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-DijtEVxG.js → preview-open-alternatives-3E_Qa-58.js} +1 -1
  61. package/dist/gateway/static/root/assets/product-delivery-BTRT9kCS.js +1 -0
  62. package/dist/gateway/static/root/assets/product-open-page-B2T48Sbt.js +1 -0
  63. package/dist/gateway/static/root/assets/{project-detail-page-BwG8SOzI.js → project-detail-page-BvEcriRC.js} +1 -1
  64. package/dist/gateway/static/root/assets/{projects-page-nUlyUtxh.js → projects-page-B_e79MRJ.js} +1 -1
  65. package/dist/gateway/static/root/assets/{remote-access-hub-rf7bjije.js → remote-access-hub-DGcqnYfR.js} +1 -1
  66. package/dist/gateway/static/root/assets/{save-bar-controls-qhDisdqY.js → save-bar-controls-CkeKasGm.js} +1 -1
  67. package/dist/gateway/static/root/assets/{schedule-field-AhJ50NoT.js → schedule-field-TkqUL3wm.js} +1 -1
  68. package/dist/gateway/static/root/assets/{schema-form-AuJg2CXU.js → schema-form-DC-iU5IG.js} +1 -1
  69. package/dist/gateway/static/root/assets/{sessions-page-CSoHUe38.js → sessions-page-DQZhrDJ8.js} +1 -1
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-BkdeN99Y.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-collapsible-section-D5ganr_X.js → settings-collapsible-section-Dpqth3oA.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-form-section-Db3cKRsg.js → settings-form-section-CNqF6IwY.js} +1 -1
  73. package/dist/gateway/static/root/assets/{settings-loading-skeleton-D05YKT2x.js → settings-loading-skeleton-DkvwitK_.js} +1 -1
  74. package/dist/gateway/static/root/assets/{settings-page-layout-Cv_Cu4I5.js → settings-page-layout-DWvNgISx.js} +1 -1
  75. package/dist/gateway/static/root/assets/{settings-page-DYfXmfTx.js → settings-page-qPG7I2zd.js} +1 -1
  76. package/dist/gateway/static/root/assets/{setup-status-panel-wBWOFpvw.js → setup-status-panel-lwRAh9aw.js} +1 -1
  77. package/dist/gateway/static/root/assets/{share-preview-page-CYkZVuse.js → share-preview-page-DGpSPW-n.js} +1 -1
  78. package/dist/gateway/static/root/assets/{shares-settings-BAMma1-P.js → shares-settings-BGj9IVUr.js} +1 -1
  79. package/dist/gateway/static/root/assets/skill-reload-api-B2UBAs5U.js +1 -0
  80. package/dist/gateway/static/root/assets/{skills-page-Ca2RA29R.js → skills-page-DdjzFZ8I.js} +1 -1
  81. package/dist/gateway/static/root/assets/{system-settings-panel-C1Ng5bXh.js → system-settings-panel-8TxxSbUw.js} +1 -1
  82. package/dist/gateway/static/root/assets/{theme-store-LMHIDR9n.js → theme-store-B5FzMWOx.js} +1 -1
  83. package/dist/gateway/static/root/assets/{typed-models-lib-Ch2Bdm_5.js → typed-models-lib-DEGtSA5h.js} +1 -1
  84. package/dist/gateway/static/root/assets/{use-channel-catalog-CZnaMOeL.js → use-channel-catalog-BDU6FneG.js} +1 -1
  85. package/dist/gateway/static/root/assets/{user-context-page-CTumZa0y.js → user-context-page-BTTZpAGV.js} +1 -1
  86. package/dist/gateway/static/root/assets/{voice-api-key-field-DdlMxeqO.js → voice-api-key-field-DuDQd-WU.js} +1 -1
  87. package/dist/gateway/static/root/assets/work-discovery-page-BUVkVCsW.js +1 -0
  88. package/dist/gateway/static/root/assets/{work-item-detail-page--wxLw1p_.js → work-item-detail-page-DeEPPu4n.js} +1 -1
  89. package/dist/gateway/static/root/assets/work-page-DQNUyTUq.js +1 -0
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BFk8TvTw.js → workflow-run-setup-panel-Cwi8Pz7n.js} +1 -1
  91. package/dist/gateway/static/root/assets/{workflows-page-CVVJd4gy.js → workflows-page-BIy4wrzO.js} +3 -3
  92. package/dist/gateway/static/root/index.html +12 -10
  93. package/dist/package.js +1 -1
  94. package/dist/src/config/agent-profile.js +1 -1
  95. package/dist/src/gateway/agents-admin.js +1 -1
  96. package/dist/src/gateway/hono/sse.d.ts +2 -0
  97. package/dist/src/gateway/hono/sse.js +10 -3
  98. package/dist/src/gateway/run-loop.js +17 -7
  99. package/dist/src/gateway/server.d.ts +1 -0
  100. package/dist/src/gateway/server.js +9 -0
  101. package/dist/src/local-apps/preview-runtime-bridge.d.ts +1 -1
  102. package/dist/src/local-apps/preview-runtime-bridge.js +14 -11
  103. package/package.json +1 -1
  104. package/dist/gateway/static/root/assets/activity-store-3Cso_2qm.js +0 -1
  105. package/dist/gateway/static/root/assets/channels-status-swr-Cqfqv59m.js +0 -1
  106. package/dist/gateway/static/root/assets/check-BODqo66o.js +0 -1
  107. package/dist/gateway/static/root/assets/circle-alert-RzVebuX2.js +0 -1
  108. package/dist/gateway/static/root/assets/cn-BQ_8x0bT.js +0 -1
  109. package/dist/gateway/static/root/assets/connectors-page-CaLBi6Na.js +0 -2
  110. package/dist/gateway/static/root/assets/index-CHKe7nwC.js +0 -197
  111. package/dist/gateway/static/root/assets/index-CXhfUIjh.css +0 -1
  112. package/dist/gateway/static/root/assets/local-app-workbench-page-CTTfyFe3.js +0 -2
  113. package/dist/gateway/static/root/assets/messages-DDsiqdJS.js +0 -5
  114. package/dist/gateway/static/root/assets/settings-advanced-gate-Db976IEa.js +0 -1
  115. package/dist/gateway/static/root/assets/skill-reload-api-TWxFFWxM.js +0 -1
  116. package/dist/gateway/static/root/assets/work-discovery-page-CcfZhdBi.js +0 -1
  117. package/dist/gateway/static/root/assets/work-page-DyS0XBpV.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{d as i,l as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-DDsiqdJS.js";import{n as l}from"./locale-store-CPbGB_6l.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$o as d,$t as f,Bo as p,Fs as m,Gt as h,Ho as g,Hs as _,Jn as v,Jt as y,Ko as b,Kt as x,Oc as S,Ps as C,Ql as w,Qs as T,Qt as E,Rl as D,Ro as O,Rs as k,Sc as A,Ss as j,Ts as M,Uo as N,Vo as P,Wo as F,Wt as I,Xa as L,Xt as R,Yt as z,Zt as B,an as V,au as H,bo as U,cn as W,du as ee,en as te,et as G,fn as ne,gl as re,gs as ie,gu as ae,hn as oe,in as se,ln as ce,ml as K,mn as q,nc as J,nn as le,on as ue,qt as de,rn as fe,sn as pe,tl as me,tn as he,ts as ge,zl as _e,zo as ve}from"./index-CHKe7nwC.js";import{t as ye}from"./page-tabs-dtpK_4Fs.js";import{t as be}from"./connector-logo-C3bJC9nt.js";var Y=n(),X=e(t(),1),Z=r();function xe(e){let t=(0,Y.c)(104),{value:n,onChange:r,labels:i,language:a,inputClassName:s}=e,c;t[0]===n.timezone?c=t[1]:(c=()=>q.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=c);let[l,u]=(0,X.useState)(c),f;t[2]===n.timezone?f=t[3]:(f=()=>!!n.timezone&&!q.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=f);let[p,m]=(0,X.useState)(f),h;t[4]===n.pronouns?h=t[5]:(h=()=>!!n.pronouns&&!ne.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=h);let[g,_]=(0,X.useState)(h),v;bb0:{if(p){v=`__custom__`;break bb0}v=q.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let y=v,b;t[6]!==r||t[7]!==n?(b=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=b):b=t[8];let x=b,S;t[9]===a?S=t[10]:(S=(e,t)=>a===`zh`?t:e,t[9]=a,t[10]=S);let C=S,w;t[11]===i.callName?w=t[12]:(w=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.callName}),t[11]=i.callName,t[12]=w);let T;t[13]===x?T=t[14]:(T=e=>x({callName:e.target.value}),t[13]=x,t[14]=T);let E;t[15]!==s||t[16]!==i.callNamePlaceholder||t[17]!==T||t[18]!==n.callName?(E=(0,Z.jsx)(`input`,{className:s,value:n.callName,onChange:T,placeholder:i.callNamePlaceholder,autoComplete:`off`}),t[15]=s,t[16]=i.callNamePlaceholder,t[17]=T,t[18]=n.callName,t[19]=E):E=t[19];let D;t[20]!==w||t[21]!==E?(D=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[w,E]}),t[20]=w,t[21]=E,t[22]=D):D=t[22];let O;t[23]===i.pronouns?O=t[24]:(O=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.pronouns}),t[23]=i.pronouns,t[24]=O);let k=g?`__custom__`:n.pronouns,A;t[25]!==x||t[26]!==n.pronouns?(A=e=>{if(e.target.value===`__custom__`){_(!0),ne.some(e=>e.value===n.pronouns)&&x({pronouns:``});return}_(!1),x({pronouns:e.target.value})},t[25]=x,t[26]=n.pronouns,t[27]=A):A=t[27];let j;t[28]===i.pronounsPlaceholder?j=t[29]:(j=(0,Z.jsx)(ge,{value:``,children:i.pronounsPlaceholder}),t[28]=i.pronounsPlaceholder,t[29]=j);let M;t[30]===C?M=t[31]:(M=ne.map(e=>(0,Z.jsx)(ge,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),t[30]=C,t[31]=M);let N;t[32]===i.custom?N=t[33]:(N=(0,Z.jsx)(ge,{value:`__custom__`,children:i.custom}),t[32]=i.custom,t[33]=N);let P;t[34]!==s||t[35]!==k||t[36]!==A||t[37]!==j||t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(d,{className:s,value:k,onChange:A,children:[j,M,N]}),t[34]=s,t[35]=k,t[36]=A,t[37]=j,t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==s||t[42]!==i.pronounsPlaceholder||t[43]!==g||t[44]!==x||t[45]!==n.pronouns?(F=g?(0,Z.jsx)(`input`,{className:o(s,`mt-1 text-xs`),value:n.pronouns,onChange:e=>x({pronouns:e.target.value}),placeholder:i.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=s,t[42]=i.pronounsPlaceholder,t[43]=g,t[44]=x,t[45]=n.pronouns,t[46]=F):F=t[46];let I;t[47]!==O||t[48]!==P||t[49]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[O,P,F]}),t[47]=O,t[48]=P,t[49]=F,t[50]=I):I=t[50];let L;t[51]===i.timezone?L=t[52]:(L=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.timezone}),t[51]=i.timezone,t[52]=L);let R;t[53]===s?R=t[54]:(R=o(s,`min-w-0 flex-1`),t[53]=s,t[54]=R);let z;t[55]===x?z=t[56]:(z=e=>{if(e.target.value===`__custom__`){m(!0);return}m(!1),u(``),x({timezone:e.target.value})},t[55]=x,t[56]=z);let B;t[57]===C?B=t[58]:(B=q.map(e=>(0,Z.jsx)(ge,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),t[57]=C,t[58]=B);let V;t[59]===i.timezoneCustom?V=t[60]:(V=(0,Z.jsx)(ge,{value:`__custom__`,children:i.timezoneCustom}),t[59]=i.timezoneCustom,t[60]=V);let H;t[61]!==R||t[62]!==z||t[63]!==B||t[64]!==V||t[65]!==y?(H=(0,Z.jsxs)(d,{className:R,value:y,onChange:z,children:[B,V]}),t[61]=R,t[62]=z,t[63]=B,t[64]=V,t[65]=y,t[66]=H):H=t[66];let U;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(U=o(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,ie.press),t[67]=U):U=t[67];let W;t[68]===x?W=t[69]:(W=()=>{let e=oe();if(!e)return;let t=q.some(t=>t.value===e);m(!t),u(t?``:e),x({timezone:e})},t[68]=x,t[69]=W);let ee;t[70]!==i.timezoneDetect||t[71]!==W?(ee=(0,Z.jsx)(`button`,{type:`button`,className:U,onClick:W,children:i.timezoneDetect}),t[70]=i.timezoneDetect,t[71]=W,t[72]=ee):ee=t[72];let te;t[73]!==H||t[74]!==ee?(te=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[H,ee]}),t[73]=H,t[74]=ee,t[75]=te):te=t[75];let G;t[76]!==l||t[77]!==s||t[78]!==p||t[79]!==x?(G=p?(0,Z.jsx)(`input`,{className:o(s,`mt-1 font-mono text-xs`),value:l,onChange:e=>{u(e.target.value),x({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=l,t[77]=s,t[78]=p,t[79]=x,t[80]=G):G=t[80];let re;t[81]!==L||t[82]!==te||t[83]!==G?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[L,te,G]}),t[81]=L,t[82]=te,t[83]=G,t[84]=re):re=t[84];let ae;t[85]===i.notes?ae=t[86]:(ae=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.notes}),t[85]=i.notes,t[86]=ae);let se;t[87]===s?se=t[88]:(se=o(s,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=s,t[88]=se);let ce;t[89]===x?ce=t[90]:(ce=e=>x({notes:e.target.value}),t[89]=x,t[90]=ce);let K;t[91]!==i.notesPlaceholder||t[92]!==se||t[93]!==ce||t[94]!==n.notes?(K=(0,Z.jsx)(`textarea`,{className:se,value:n.notes,onChange:ce,placeholder:i.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=i.notesPlaceholder,t[92]=se,t[93]=ce,t[94]=n.notes,t[95]=K):K=t[95];let J;t[96]!==ae||t[97]!==K?(J=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[ae,K]}),t[96]=ae,t[97]=K,t[98]=J):J=t[98];let le;return t[99]!==D||t[100]!==I||t[101]!==re||t[102]!==J?(le=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[D,I,re,J]}),t[99]=D,t[100]=I,t[101]=re,t[102]=J,t[103]=le):le=t[103],le}var Se={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function Ce(e){if(e.branding?.logoUrl)return e.branding;let t=Se[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}function we(e){let t=(0,Y.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:s}=e,l=c(r).you,[u,d]=(0,X.useState)(!1),f=n?.accountLabel??(n?.accountCount&&n.accountCount>1&&n.accountOrdinal?l.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),h,_;t[0]===n?(h=t[1],_=t[2]):(h=()=>{n&&d(!1)},_=[n],t[0]=n,t[1]=h,t[2]=_),(0,X.useEffect)(h,_);let v;t[3]!==i||t[4]!==a?(v=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=v):v=t[5];let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>d(!1),t[8]=x):x=t[8];let S=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,C;t[9]===S?C=t[10]:(C=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,S),t[9]=S,t[10]=C);let w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(_e,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>d(!0),t[12]=T):T=t[12];let E=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,D;t[13]===E?D=t[14]:(D=o(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,E),t[13]=E,t[14]=D);let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=A):A=t[15];let I=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),L;t[16]===I?L=t[17]:(L=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:I}),t[16]=I,t[17]=L);let R;t[18]!==i||t[19]!==l.cancel?(R=(0,Z.jsx)(ve,{asChild:!0,children:(0,Z.jsx)(j,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=R):R=t[20];let z=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,B;t[21]!==u||t[22]!==s?(B=()=>s(u),t[21]=u,t[22]=s,t[23]=B):B=t[23];let V;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t[24]=V):V=t[24];let H=i?l.disconnecting:l.disconnectAction,U;t[25]!==i||t[26]!==z||t[27]!==B||t[28]!==H?(U=(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,className:z,disabled:i,onClick:B,children:[V,H]}),t[25]=i,t[26]=z,t[27]=B,t[28]=H,t[29]=U):U=t[29];let W;return t[30]!==R||t[31]!==U?(W=(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[R,U]}),t[30]=R,t[31]=U,t[32]=W):W=t[32],(0,Z.jsx)(O,{open:n!==null,onOpenChange:v,children:(0,Z.jsxs)(N,{children:[y,(0,Z.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,Z.jsx)(ve,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:b})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[f?(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,f)}):null,(0,Z.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:x,className:C,children:[w,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:T,disabled:!n?.derivedUnderstandingCount,className:D,children:[A,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),L]})]})]}),W]})]})})}var Te=new Set([`overview`,`profile`,`understanding`,`sources`,`controls`]),Ee=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],De=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function Oe(e,t){return e.replace(`{{count}}`,String(t))}function ke(e,t){let n=Date.parse(e);return Number.isFinite(n)?G(n,t):e}function Ae(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Te.has(e)?e:`overview`}function je(){let e=(0,Y.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(L,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Z.jsx)(L,{className:`h-64 rounded-2xl`}),(0,Z.jsx)(L,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Me(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Ne(e){let t=(0,Y.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(n.statement),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),b=n.status!==`active`,x=b?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===x?C=t[1]:(C=o(`rounded-xl border p-3.5`,x),t[0]=x,t[1]=C);let w;t[2]!==a||t[3]!==m||t[4]!==f||t[5]!==g||t[6]!==v||t[7]!==n||t[8]!==r||t[9]!==b||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(w=f?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{className:o(De,`min-h-20 resize-y`),value:m,onChange:e=>h(e.target.value),placeholder:i.updatePlaceholder}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{h(n.statement),p(!1)},children:i.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!m.trim(),onClick:()=>{u(m.trim()),p(!1)},children:i.save})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(T,{className:`size-3 text-accent`,"aria-hidden":!0}),Me(n,i)]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,Z.jsx)(`span`,{children:Oe(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,Z.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,ke(n.latestEvidenceAt,r))}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[b?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,Z.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,Z.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,Z.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:v,onClick:()=>{if(g){_(null);return}y(!0),B(n.id).then(e=>_(e.history)).finally(()=>y(!1))},children:[(0,Z.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,Z.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,Z.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,Z.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:ke(n.updatedAt,r)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Oe(i.evidenceCount,n.evidenceCount)})]})]})]}),g?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),g.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:ke(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=m,t[4]=f,t[5]=g,t[6]=v,t[7]=n,t[8]=r,t[9]=b,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let E;return t[16]!==C||t[17]!==w?(E=(0,Z.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=E):E=t[18],E}function Pe(e){let t=(0,Y.c)(84),{source:n,language:r,t:i,onConfigure:a,onDisconnect:s}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.accountCount||t[1]!==n.accountLabel||t[2]!==n.accountOrdinal||t[3]!==i.sourceAccountFallback?(l=n.accountLabel??(n.accountCount&&n.accountCount>1&&n.accountOrdinal?i.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),t[0]=n.accountCount,t[1]=n.accountLabel,t[2]=n.accountOrdinal,t[3]=i.sourceAccountFallback,t[4]=l):l=t[4];let u=l,d;t[5]!==n.lastHealthStatus||t[6]!==i.healthIssue||t[7]!==i.healthOk||t[8]!==i.sourceHealth?(d=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[5]=n.lastHealthStatus,t[6]=i.healthIssue,t[7]=i.healthOk,t[8]=i.sourceHealth,t[9]=d):d=t[9];let f=d,p=`${i.manageSources}: ${n.displayName}`,m;t[10]===a?m=t[11]:(m=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[10]=a,t[11]=m);let h=n.displayName,g;t[12]===n?g=t[13]:(g=Ce(n),t[12]=n,t[13]=g);let _;t[14]!==n.displayName||t[15]!==g?(_=(0,Z.jsx)(be,{connector:{displayName:h,branding:g},size:`sm`}),t[14]=n.displayName,t[15]=g,t[16]=_):_=t[16];let v;t[17]===n.displayName?v=t[18]:(v=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[17]=n.displayName,t[18]=v);let y;t[19]===u?y=t[20]:(y=u?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:u}):null,t[19]=u,t[20]=y);let b;t[21]===n.description?b=t[22]:(b=(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[21]=n.description,t[22]=b);let x;t[23]!==b||t[24]!==v||t[25]!==y?(x=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[v,y,b]}),t[23]=b,t[24]=v,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==_?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[_,x]}),t[27]=x,t[28]=_,t[29]=S):S=t[29];let C=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,w;t[30]===C?w=t[31]:(w=o(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,C),t[30]=C,t[31]=w);let T;t[32]!==c||t[33]!==w?(T=(0,Z.jsx)(`span`,{className:w,children:c}),t[32]=c,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==S||t[36]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,T]}),t[35]=S,t[36]=T,t[37]=E):E=t[37];let D;t[38]!==n.access.context||t[39]!==i.sourceContext?(D=n.access.context?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[38]=n.access.context,t[39]=i.sourceContext,t[40]=D):D=t[40];let O;t[41]!==n.access.memory||t[42]!==i.sourceMemory?(O=n.access.memory?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[41]=n.access.memory,t[42]=i.sourceMemory,t[43]=O):O=t[43];let k;t[44]!==n.access.read||t[45]!==i.sourceRead?(k=n.access.read?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[44]=n.access.read,t[45]=i.sourceRead,t[46]=k):k=t[46];let A;t[47]!==n.access.write||t[48]!==i.sourceWrite?(A=n.access.write?(0,Z.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[47]=n.access.write,t[48]=i.sourceWrite,t[49]=A):A=t[49];let M;t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A?(M=(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[D,O,k,A]}),t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=M):M=t[54];let N;t[55]!==f||t[56]!==r||t[57]!==n.derivedUnderstandingCount||t[58]!==n.installed||t[59]!==n.knowledgeItemCount||t[60]!==n.lastActivityAt||t[61]!==n.lastSyncAt||t[62]!==n.lastSyncError||t[63]!==n.lastSyncStatus||t[64]!==i.sourceDerivedCount||t[65]!==i.sourceKnowledgeCount||t[66]!==i.sourceLastSync||t[67]!==i.sourceLastUsed||t[68]!==i.sourceNeverUsed||t[69]!==i.sourceSyncFailed?(N=n.installed?(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[f?(0,Z.jsx)(`p`,{children:f}):null,(0,Z.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,ke(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,Z.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,ke(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,Z.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,Z.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,Z.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[55]=f,t[56]=r,t[57]=n.derivedUnderstandingCount,t[58]=n.installed,t[59]=n.knowledgeItemCount,t[60]=n.lastActivityAt,t[61]=n.lastSyncAt,t[62]=n.lastSyncError,t[63]=n.lastSyncStatus,t[64]=i.sourceDerivedCount,t[65]=i.sourceKnowledgeCount,t[66]=i.sourceLastSync,t[67]=i.sourceLastUsed,t[68]=i.sourceNeverUsed,t[69]=i.sourceSyncFailed,t[70]=N):N=t[70];let P;t[71]!==s||t[72]!==n.installed||t[73]!==n.instanceId||t[74]!==i.disconnect?(P=n.installed&&n.instanceId?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),s()},children:i.disconnect})}):null,t[71]=s,t[72]=n.installed,t[73]=n.instanceId,t[74]=i.disconnect,t[75]=P):P=t[75];let F;return t[76]!==a||t[77]!==E||t[78]!==M||t[79]!==N||t[80]!==P||t[81]!==p||t[82]!==m?(F=(0,Z.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":p,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:m,children:[E,M,N,P]}),t[76]=a,t[77]=E,t[78]=M,t[79]=N,t[80]=P,t[81]=p,t[82]=m,t[83]=F):F=t[83],F}function Fe(e){let t=(0,Y.c)(63),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:s,onUpdate:c,onDelete:l}=e,[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(``),g=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,_;t[0]===g?_=t[1]:(_=o(`rounded-xl border p-4`,g),t[0]=g,t[1]=_);let v=i.playbookNames[n.id],y;t[2]===v?y=t[3]:(y=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:v}),t[2]=v,t[3]=y);let b;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(b=Oe(i.playbookRuleCount,n.rules.filter(Ie).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=b):b=t[6];let x;t[7]===b?x=t[8]:(x=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:b}),t[7]=b,t[8]=x);let C;t[9]!==y||t[10]!==x?(C=(0,Z.jsxs)(`div`,{children:[y,x]}),t[9]=y,t[10]=x,t[11]=C):C=t[11];let w=n.enabled?i.pausePlaybook:i.resumePlaybook,T;t[12]!==r||t[13]!==a||t[14]!==w?(T=(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:w}),t[12]=r,t[13]=a,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==C||t[17]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,T]}),t[16]=C,t[17]=T,t[18]=E):E=t[18];let D;t[19]!==r||t[20]!==f||t[21]!==m||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(D=n.rules.map((e,t)=>(0,Z.jsx)(`li`,{className:o(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{className:o(De,`min-h-16 resize-y`),value:m,onChange:e=>h(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!m.trim(),onClick:()=>{c(e.id,{statement:m.trim()}),p(null)},children:i.save})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),h(e.statement)},children:[(0,Z.jsx)(S,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,Z.jsx)(k,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=m,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=D):D=t[33];let O;t[34]===D?O=t[35]:(O=(0,Z.jsx)(`ul`,{className:`mt-3 space-y-2`,children:D}),t[34]=D,t[35]=O);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>d(e.target.value),t[36]=A):A=t[36];let M;t[37]!==u||t[38]!==i.newRulePlaceholder?(M=(0,Z.jsx)(`input`,{className:De,value:u,onChange:A,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=M):M=t[39];let N;t[40]!==r||t[41]!==u?(N=r||!u.trim(),t[40]=r,t[41]=u,t[42]=N):N=t[42];let P;t[43]!==u||t[44]!==s?(P=()=>{s(u.trim()),d(``)},t[43]=u,t[44]=s,t[45]=P):P=t[45];let F;t[46]!==i.addRule||t[47]!==N||t[48]!==P?(F=(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:N,onClick:P,children:i.addRule}),t[46]=i.addRule,t[47]=N,t[48]=P,t[49]=F):F=t[49];let I;t[50]!==M||t[51]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[M,F]}),t[50]=M,t[51]=F,t[52]=I):I=t[52];let L=i.playbookRuleExamples[n.id],R;t[53]===L?R=t[54]:(R=(0,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-fg-subtle`,children:L}),t[53]=L,t[54]=R);let z;t[55]!==I||t[56]!==R?(z=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[I,R]}),t[55]=I,t[56]=R,t[57]=z):z=t[57];let B;return t[58]!==E||t[59]!==O||t[60]!==_||t[61]!==z?(B=(0,Z.jsxs)(`article`,{className:_,children:[E,O,z]}),t[58]=E,t[59]=O,t[60]=_,t[61]=z,t[62]=B):B=t[62],B}function Ie(e){return e.enabled}function Le(e){let t=(0,Y.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:s,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,Z.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=d);let f=n?l.meetSuggestedBody:l.meetBody,p;t[6]===f?p=t[7]:(p=(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:f}),t[6]=f,t[7]=p);let m;t[8]===l.callName?m=t[9]:(m=(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=m);let h;t[10]===a?h=t[11]:(h=e=>a(e.target.value),t[10]=a,t[11]=h);let g;t[12]!==i||t[13]!==r||t[14]!==s?(g=e=>{e.key===`Enter`&&r.trim()&&!i&&s()},t[12]=i,t[13]=r,t[14]=s,t[15]=g):g=t[15];let _=l.meetPlaceholder,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=o(De,`h-10 flex-1 bg-surface-base/90`),t[16]=v):v=t[16];let y;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==h||t[20]!==g?(y=(0,Z.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,onChange:h,onKeyDown:g,placeholder:_,className:v}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=h,t[20]=g,t[21]=y):y=t[21];let b;t[22]!==i||t[23]!==r?(b=i||!r.trim(),t[22]=i,t[23]=r,t[24]=b):b=t[24];let x=i?l.meetSaving:l.meetSave,S;t[25]!==s||t[26]!==b||t[27]!==x?(S=(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:b,onClick:s,children:x}),t[25]=s,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==y||t[30]!==S||t[31]!==m?(C=(0,Z.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[m,y,S]}),t[29]=y,t[30]=S,t[31]=m,t[32]=C):C=t[32];let w;t[33]!==n||t[34]!==l.meetSource?(w=n?(0,Z.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,Z.jsx)(J,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=w):w=t[35];let T;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(T=(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=T):T=t[39];let E;return t[40]!==C||t[41]!==w||t[42]!==T||t[43]!==d||t[44]!==p?(E=(0,Z.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,Z.jsxs)(`div`,{className:`relative max-w-2xl`,children:[d,p,C,w,T]})}),t[40]=C,t[41]=w,t[42]=T,t[43]=d,t[44]=p,t[45]=E):E=t[45],E}function Re(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,p]=i(),m=Ae(r.get(`tab`)),g=U(e=>e.setPageHeader),T=U(e=>e.clearPageHeader),{data:O,error:k,isLoading:M,mutate:N}=u(`/api/you`,E),[P,F]=(0,X.useState)(null),[L,B]=(0,X.useState)(!1),[G,ne]=(0,X.useState)(``),[ie,K]=(0,X.useState)(`preference`),[q,ve]=(0,X.useState)(null),[be,Y]=(0,X.useState)(!1),[Se,Ce]=(0,X.useState)(null),[Te,Ie]=(0,X.useState)(!1),[Re,ze]=(0,X.useState)(``),[Be,Ve]=(0,X.useState)(!1),[He,Ue]=(0,X.useState)(null),[We,Ge]=(0,X.useState)(!1),[Ke,qe]=(0,X.useState)(null),[Je,Ye]=(0,X.useState)(!1),[Xe,Ze]=(0,X.useState)(null),Qe=(0,X.useRef)(null),$e=(0,X.useRef)(null),Q=O?.profile??{callName:``,pronouns:``,timezone:``,notes:``},et=(0,X.useMemo)(()=>O?.understanding.filter(e=>e.status===`active`)??[],[O]),tt=(0,X.useMemo)(()=>O?.understanding.filter(e=>e.status!==`active`)??[],[O]),nt=(0,X.useMemo)(()=>new Map(Ee.map(e=>[e,et.filter(t=>t.facet===e)])),[et]),rt=He??O?.controls??null,it=O?.sources.filter(e=>e.installed&&e.enabled)??[],at=it.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),p(n,{replace:!0})},ot=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,X.useLayoutEffect)(()=>(g({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>T()),[T,g,t.subtitle,t.title]),(0,X.useEffect)(()=>{!O||O.profile.callName||ze(O.profileSetup.callNameSuggestion?.value??``)},[O,O?.profile.callName,O?.profileSetup.callNameSuggestion?.id]);async function st(e,n,r){F(e.id);try{let t=await ue(e.id,{action:n,content:r});await N(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),N()}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function ct(e,n){F(`consent:${e}`);try{await de(e,n),await N(),b({type:`success`,title:t.title,message:t.saved})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function lt(){let e=G.trim();if(e){F(`understanding:new`);try{await x({content:e,kind:ie}),ne(``),B(!1),await N(),b({type:`success`,title:t.understandingTitle,message:t.saved})}catch{b({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{F(null)}}}async function ut(){if(tt.length){F(`understanding:batch`);try{await I(tt.map(e=>e.id),`confirm`),await N()}catch{b({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{F(null)}}}async function dt(e,n){F(`conflict:${e}`);try{await he(e,n),await N()}catch{b({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{F(null)}}async function ft(e){F(`grant:${e}`);try{await le(e),await N()}catch{b({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{F(null)}}async function pt(r,i){F(`insight:${r.id}`);try{let t=await se(r.id,{action:i,uiLocale:e});await N(),i===`apply`&&t.href&&n(t.href)}catch{b({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{F(null)}}async function mt(e){F(`playbook:${e.id}`);try{await fe(e.id,!e.enabled),await N()}catch{b({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function ht(e,n){F(`playbook:${e}`);try{await n(),await N()}catch{b({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function gt(){if(q){F(q.id);try{await f(q.id);let e=q.id;ve(null),await N(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),N()}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}}async function _t(){if(Se){Ie(!0);try{let e=await W(Se);Y(!1),Ce(null),await N(t=>t&&{...t,...e},{revalidate:!1})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ie(!1)}}}async function vt(){let e=Re.trim();if(!(!e||Be)){Ve(!0);try{let t=await W({callName:e,timezone:Q.timezone||oe()});await N(e=>e&&{...e,...t},{revalidate:!1})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ve(!1)}}}async function yt(){if(!Be){Ve(!0);try{let e=await ce(`snooze`);await N(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ve(!1)}}}function bt(){Ce(Q),Y(!0),$(`profile`),requestAnimationFrame(()=>Qe.current?.scrollIntoView({behavior:`smooth`,block:`start`}))}function xt(e){K(e),B(!0),$(`understanding`)}async function St(){if(rt){Ge(!0);try{Ue(await pe(rt)),await N(),b({type:`success`,title:t.title,message:t.saved})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ge(!1)}}}async function Ct(e){if(!(!Ke?.instanceId||Je)){Ye(!0);try{let n=await z(Ke.instanceId,e);qe(null),await N(),b({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{b({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{Ye(!1)}}}async function wt(){if(!Xe){Ze(`export`);try{let e=await R(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{b({type:`error`,title:t.transferTitle,message:t.saveError})}finally{Ze(null)}}}async function Tt(e){if(!(!e||Xe)){Ze(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await te(JSON.parse(await e.text()));await N(),$(`understanding`,`review`),b({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{b({type:`error`,title:t.transferTitle,message:t.importError})}finally{$e.current&&($e.current.value=``),Ze(null)}}}return(0,Z.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(ye,{items:[{id:`overview`,label:t.tabs.overview,icon:re},{id:`profile`,label:t.tabs.profile,icon:w},{id:`understanding`,label:t.tabs.understanding,icon:ee,count:tt.length||void 0},{id:`sources`,label:t.tabs.sources,icon:_e},{id:`controls`,label:t.tabs.controls,icon:J}],activeTab:m,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`,className:`pr-8 sm:pr-1`,buttonClassName:`px-2.5 sm:px-3`}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 w-8 bg-gradient-to-l from-surface-panel to-transparent sm:hidden`,"aria-hidden":!0})]}),M?(0,Z.jsx)(je,{}):k||!O?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,O&&m===`overview`?(0,Z.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Q.callName&&O.profileSetup.shouldPrompt?(0,Z.jsx)(Le,{suggestion:O.profileSetup.callNameSuggestion,draft:Re,busy:Be,onDraftChange:ze,onSave:()=>void vt(),onLater:()=>void yt(),t}):null,tt.length>0||at.length>0||!Q.callName?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[tt.length>0?(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[Oe(t.reviewCount,tt.length),(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]}):null,at.length>0?(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[Oe(t.sourceIssues,at.length),(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]}):null,Q.callName?null:(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:bt,children:[t.completeProfile,(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:et.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:it.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`,`review`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:tt.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.waitingReview})]})]})]}),O.insights.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(me,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:O.insights.map(e=>(0,Z.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?Oe(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void pt(e,`dismiss`),children:t.notNow}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void pt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(w,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`profile`),children:(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.callName||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.timezone||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.pronouns||`—`})]}),Q.notes?(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,Z.jsx)(`dd`,{className:`mt-1 line-clamp-2 text-sm leading-6 text-fg`,children:Q.notes})]}):null]})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ee,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[et.slice(0,4).map(e=>(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),et.length===0?(0,Z.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]})]}):null,O&&m===`profile`?(0,Z.jsxs)(`div`,{id:`you-panel-profile`,role:`tabpanel`,"aria-labelledby":`you-tab-profile`,className:`space-y-5`,children:[(0,Z.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:t.profileOwnershipHint}),(0,Z.jsxs)(`section`,{ref:Qe,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(w,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.profileHint})]}),be?null:(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:bt,children:[(0,Z.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),be&&Se?(0,Z.jsxs)(`div`,{className:`mt-5`,children:[(0,Z.jsx)(xe,{value:Se,onChange:Ce,language:e,inputClassName:De,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>{Y(!1),Ce(null)},children:t.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:Te,onClick:()=>void _t(),children:Te?t.saving:t.save})]})]}):(0,Z.jsxs)(`dl`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.callName||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.timezone||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.pronouns||`—`})]}),(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,Z.jsx)(`dd`,{className:`mt-1 whitespace-pre-wrap text-sm leading-6 text-fg`,children:Q.notes||`—`})]})]})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.structuredContextTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.structuredContextHint}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`preference`),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addPreference}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addPreferenceHint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`boundary`),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addBoundary}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addBoundaryHint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`current_state`),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addCurrentFocus}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addCurrentFocusHint})]})]})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.playbooksHint}),O.playbooks.length>0?(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:O.playbooks.map(e=>(0,Z.jsx)(Fe,{playbook:e,busy:P===`playbook:${e.id}`,t,onToggleGroup:()=>void mt(e),onCreate:t=>void ht(e.id,()=>h(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void ht(e.id,()=>V(e.id,t,n)),onDelete:t=>void ht(e.id,()=>y(e.id,t))},e.id))}):(0,Z.jsx)(`p`,{className:`mt-4 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.emptyPlaybooks})]})]}):null,O&&m===`understanding`?(0,Z.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,Z.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,Z.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),L?null:(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>B(!0),children:[(0,Z.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),L?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Z.jsx)(`textarea`,{className:o(De,`min-h-24 resize-y`),value:G,onChange:e=>ne(e.target.value),placeholder:t.understandingPlaceholder}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,Z.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,Z.jsx)(d,{value:ie,onChange:e=>K(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,Z.jsx)(ge,{value:e,children:t},e))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>{B(!1),ne(``)},children:t.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:!G.trim()||P===`understanding:new`,onClick:()=>void lt(),children:t.add})]})]})]}):null]}),O.conflictGroups.some(e=>e.unresolved)?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-3`,children:O.conflictGroups.filter(e=>e.unresolved).map(n=>(0,Z.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Me(r,t),` · `,ke(r.updatedAt,e)]})]}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:P===`conflict:${n.id}`,onClick:()=>void dt(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,O.consentRequests.length>0?(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),O.consentRequests.map(e=>(0,Z.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`deny`),children:t.consentDeny}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`once`),children:t.consentOnce}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`session`),children:t.consentSession}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,tt.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:P===`understanding:batch`,onClick:()=>void ut(),children:t.reviewAll})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:tt.map(n=>(0,Z.jsx)(Ne,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ve(n)},n.id))})]}):et.length>0?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,Z.jsx)(s,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,Ee.map(n=>{let r=nt.get(n)??[];return r.length===0?null:(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,Z.jsx)(Ne,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ve(n)},n.id))})]},n)}),O.understanding.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,O&&m===`sources`?(0,Z.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,Z.jsxs)(j,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]})]}),O.sourceRecommendations.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:O.sourceRecommendations.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ot({id:e.sourceId}),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:O.sources.map(n=>(0,Z.jsx)(Pe,{source:n,language:e,t,onConfigure:()=>ot(n),onDisconnect:()=>qe(n)},`${n.id}:${n.instanceId??`catalog`}`))}),O.sources.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,O&&m===`controls`&&rt?(0,Z.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.controlHint}),(0,Z.jsxs)(`div`,{className:`mt-4 max-w-2xl space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,Z.jsx)(d,{value:rt.mode,onChange:e=>Ue({...rt,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,Z.jsx)(ge,{value:e,children:t},e))})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,Z.jsx)(d,{value:rt.sensitiveWritePolicy,onChange:e=>Ue({...rt,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,Z.jsx)(ge,{value:e,children:t},e))})]}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,Z.jsx)(J,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:t.transientPromise})]}),(0,Z.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:We,onClick:()=>void St(),children:We?t.saving:t.save})})]})]}),(0,Z.jsxs)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.actionBoundaryMovedTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.actionBoundaryMovedHint})]}),(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>n(`/settings/action-boundary`),children:[t.manageActionBoundary,(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),O.referenceGrants.length>0?(0,Z.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:O.referenceGrants.map(n=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${ke(n.expiresAt,e)}`:``]})]}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:P===`grant:${n.id}`,onClick:()=>void ft(n.id),children:t.revoke})]},n.id))}):(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,disabled:Xe!==null,onClick:()=>void wt(),children:[(0,Z.jsx)(D,{className:`size-4`,"aria-hidden":!0}),Xe===`export`?t.exporting:t.exportAction]}),(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,disabled:Xe!==null,onClick:()=>$e.current?.click(),children:[(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),Xe===`import`?t.importing:t.importAction]}),(0,Z.jsx)(`input`,{ref:$e,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void Tt(e.target.files?.[0])})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,Z.jsx)(v,{open:q!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void gt(),onCancel:()=>ve(null)}),(0,Z.jsx)(we,{source:Ke,language:e,busy:Je,onOpenChange:e=>{e||qe(null)},onConfirm:e=>void Ct(e)})]})}export{Re as UserContextPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-CxySDn9d.js";import{n as l}from"./locale-store-Dar-xqQr.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$o as d,$t as f,Bo as p,Fs as m,Gt as h,Ho as g,Hs as _,Jn as v,Jt as y,Ko as b,Kt as x,Oc as S,Ps as C,Ql as w,Qs as T,Qt as E,Rl as D,Ro as O,Rs as k,Sc as A,Ss as j,Ts as M,Uo as N,Vo as P,Wo as F,Wt as I,Xa as L,Xt as R,Yt as z,Zt as B,an as V,au as H,bo as U,cn as W,du as ee,en as te,et as G,fn as ne,gl as re,gs as ie,gu as ae,hn as oe,in as se,ln as ce,ml as K,mn as q,nc as J,nn as le,on as ue,qt as de,rn as fe,sn as pe,tl as me,tn as he,ts as ge,zl as _e,zo as ve}from"./index-vq_cJZJC.js";import{t as ye}from"./page-tabs-CzZ4iKOb.js";import{t as be}from"./connector-logo-BbjzIs87.js";var Y=n(),X=e(t(),1),Z=r();function xe(e){let t=(0,Y.c)(104),{value:n,onChange:r,labels:i,language:a,inputClassName:o}=e,c;t[0]===n.timezone?c=t[1]:(c=()=>q.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=c);let[l,u]=(0,X.useState)(c),f;t[2]===n.timezone?f=t[3]:(f=()=>!!n.timezone&&!q.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=f);let[p,m]=(0,X.useState)(f),h;t[4]===n.pronouns?h=t[5]:(h=()=>!!n.pronouns&&!ne.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=h);let[g,_]=(0,X.useState)(h),v;bb0:{if(p){v=`__custom__`;break bb0}v=q.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let y=v,b;t[6]!==r||t[7]!==n?(b=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=b):b=t[8];let x=b,S;t[9]===a?S=t[10]:(S=(e,t)=>a===`zh`?t:e,t[9]=a,t[10]=S);let C=S,w;t[11]===i.callName?w=t[12]:(w=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.callName}),t[11]=i.callName,t[12]=w);let T;t[13]===x?T=t[14]:(T=e=>x({callName:e.target.value}),t[13]=x,t[14]=T);let E;t[15]!==o||t[16]!==i.callNamePlaceholder||t[17]!==T||t[18]!==n.callName?(E=(0,Z.jsx)(`input`,{className:o,value:n.callName,onChange:T,placeholder:i.callNamePlaceholder,autoComplete:`off`}),t[15]=o,t[16]=i.callNamePlaceholder,t[17]=T,t[18]=n.callName,t[19]=E):E=t[19];let D;t[20]!==w||t[21]!==E?(D=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[w,E]}),t[20]=w,t[21]=E,t[22]=D):D=t[22];let O;t[23]===i.pronouns?O=t[24]:(O=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.pronouns}),t[23]=i.pronouns,t[24]=O);let k=g?`__custom__`:n.pronouns,A;t[25]!==x||t[26]!==n.pronouns?(A=e=>{if(e.target.value===`__custom__`){_(!0),ne.some(e=>e.value===n.pronouns)&&x({pronouns:``});return}_(!1),x({pronouns:e.target.value})},t[25]=x,t[26]=n.pronouns,t[27]=A):A=t[27];let j;t[28]===i.pronounsPlaceholder?j=t[29]:(j=(0,Z.jsx)(ge,{value:``,children:i.pronounsPlaceholder}),t[28]=i.pronounsPlaceholder,t[29]=j);let M;t[30]===C?M=t[31]:(M=ne.map(e=>(0,Z.jsx)(ge,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),t[30]=C,t[31]=M);let N;t[32]===i.custom?N=t[33]:(N=(0,Z.jsx)(ge,{value:`__custom__`,children:i.custom}),t[32]=i.custom,t[33]=N);let P;t[34]!==o||t[35]!==k||t[36]!==A||t[37]!==j||t[38]!==M||t[39]!==N?(P=(0,Z.jsxs)(d,{className:o,value:k,onChange:A,children:[j,M,N]}),t[34]=o,t[35]=k,t[36]=A,t[37]=j,t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==o||t[42]!==i.pronounsPlaceholder||t[43]!==g||t[44]!==x||t[45]!==n.pronouns?(F=g?(0,Z.jsx)(`input`,{className:s(o,`mt-1 text-xs`),value:n.pronouns,onChange:e=>x({pronouns:e.target.value}),placeholder:i.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=o,t[42]=i.pronounsPlaceholder,t[43]=g,t[44]=x,t[45]=n.pronouns,t[46]=F):F=t[46];let I;t[47]!==O||t[48]!==P||t[49]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[O,P,F]}),t[47]=O,t[48]=P,t[49]=F,t[50]=I):I=t[50];let L;t[51]===i.timezone?L=t[52]:(L=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.timezone}),t[51]=i.timezone,t[52]=L);let R;t[53]===o?R=t[54]:(R=s(o,`min-w-0 flex-1`),t[53]=o,t[54]=R);let z;t[55]===x?z=t[56]:(z=e=>{if(e.target.value===`__custom__`){m(!0);return}m(!1),u(``),x({timezone:e.target.value})},t[55]=x,t[56]=z);let B;t[57]===C?B=t[58]:(B=q.map(e=>(0,Z.jsx)(ge,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),t[57]=C,t[58]=B);let V;t[59]===i.timezoneCustom?V=t[60]:(V=(0,Z.jsx)(ge,{value:`__custom__`,children:i.timezoneCustom}),t[59]=i.timezoneCustom,t[60]=V);let H;t[61]!==R||t[62]!==z||t[63]!==B||t[64]!==V||t[65]!==y?(H=(0,Z.jsxs)(d,{className:R,value:y,onChange:z,children:[B,V]}),t[61]=R,t[62]=z,t[63]=B,t[64]=V,t[65]=y,t[66]=H):H=t[66];let U;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(U=s(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,ie.press),t[67]=U):U=t[67];let W;t[68]===x?W=t[69]:(W=()=>{let e=oe();if(!e)return;let t=q.some(t=>t.value===e);m(!t),u(t?``:e),x({timezone:e})},t[68]=x,t[69]=W);let ee;t[70]!==i.timezoneDetect||t[71]!==W?(ee=(0,Z.jsx)(`button`,{type:`button`,className:U,onClick:W,children:i.timezoneDetect}),t[70]=i.timezoneDetect,t[71]=W,t[72]=ee):ee=t[72];let te;t[73]!==H||t[74]!==ee?(te=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[H,ee]}),t[73]=H,t[74]=ee,t[75]=te):te=t[75];let G;t[76]!==l||t[77]!==o||t[78]!==p||t[79]!==x?(G=p?(0,Z.jsx)(`input`,{className:s(o,`mt-1 font-mono text-xs`),value:l,onChange:e=>{u(e.target.value),x({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=l,t[77]=o,t[78]=p,t[79]=x,t[80]=G):G=t[80];let re;t[81]!==L||t[82]!==te||t[83]!==G?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[L,te,G]}),t[81]=L,t[82]=te,t[83]=G,t[84]=re):re=t[84];let ae;t[85]===i.notes?ae=t[86]:(ae=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.notes}),t[85]=i.notes,t[86]=ae);let se;t[87]===o?se=t[88]:(se=s(o,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=o,t[88]=se);let ce;t[89]===x?ce=t[90]:(ce=e=>x({notes:e.target.value}),t[89]=x,t[90]=ce);let K;t[91]!==i.notesPlaceholder||t[92]!==se||t[93]!==ce||t[94]!==n.notes?(K=(0,Z.jsx)(`textarea`,{className:se,value:n.notes,onChange:ce,placeholder:i.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=i.notesPlaceholder,t[92]=se,t[93]=ce,t[94]=n.notes,t[95]=K):K=t[95];let J;t[96]!==ae||t[97]!==K?(J=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[ae,K]}),t[96]=ae,t[97]=K,t[98]=J):J=t[98];let le;return t[99]!==D||t[100]!==I||t[101]!==re||t[102]!==J?(le=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[D,I,re,J]}),t[99]=D,t[100]=I,t[101]=re,t[102]=J,t[103]=le):le=t[103],le}var Se={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function Ce(e){if(e.branding?.logoUrl)return e.branding;let t=Se[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}function we(e){let t=(0,Y.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:o}=e,l=c(r).you,[u,d]=(0,X.useState)(!1),f=n?.accountLabel??(n?.accountCount&&n.accountCount>1&&n.accountOrdinal?l.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),h,_;t[0]===n?(h=t[1],_=t[2]):(h=()=>{n&&d(!1)},_=[n],t[0]=n,t[1]=h,t[2]=_),(0,X.useEffect)(h,_);let v;t[3]!==i||t[4]!==a?(v=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=v):v=t[5];let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>d(!1),t[8]=x):x=t[8];let S=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,C;t[9]===S?C=t[10]:(C=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,S),t[9]=S,t[10]=C);let w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(_e,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>d(!0),t[12]=T):T=t[12];let E=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,D;t[13]===E?D=t[14]:(D=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,E),t[13]=E,t[14]=D);let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=A):A=t[15];let I=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),L;t[16]===I?L=t[17]:(L=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:I}),t[16]=I,t[17]=L);let R;t[18]!==i||t[19]!==l.cancel?(R=(0,Z.jsx)(ve,{asChild:!0,children:(0,Z.jsx)(j,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=R):R=t[20];let z=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,B;t[21]!==u||t[22]!==o?(B=()=>o(u),t[21]=u,t[22]=o,t[23]=B):B=t[23];let V;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t[24]=V):V=t[24];let H=i?l.disconnecting:l.disconnectAction,U;t[25]!==i||t[26]!==z||t[27]!==B||t[28]!==H?(U=(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,className:z,disabled:i,onClick:B,children:[V,H]}),t[25]=i,t[26]=z,t[27]=B,t[28]=H,t[29]=U):U=t[29];let W;return t[30]!==R||t[31]!==U?(W=(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[R,U]}),t[30]=R,t[31]=U,t[32]=W):W=t[32],(0,Z.jsx)(O,{open:n!==null,onOpenChange:v,children:(0,Z.jsxs)(N,{children:[y,(0,Z.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(F,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,Z.jsx)(P,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,Z.jsx)(ve,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:b})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[f?(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,f)}):null,(0,Z.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:x,className:C,children:[w,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:T,disabled:!n?.derivedUnderstandingCount,className:D,children:[A,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),L]})]})]}),W]})]})})}var Te=new Set([`overview`,`profile`,`understanding`,`sources`,`controls`]),Ee=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],De=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function Oe(e,t){return e.replace(`{{count}}`,String(t))}function ke(e,t){let n=Date.parse(e);return Number.isFinite(n)?G(n,t):e}function Ae(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Te.has(e)?e:`overview`}function je(){let e=(0,Y.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(L,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Z.jsx)(L,{className:`h-64 rounded-2xl`}),(0,Z.jsx)(L,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Me(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function Ne(e){let t=(0,Y.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(n.statement),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),b=n.status!==`active`,x=b?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===x?C=t[1]:(C=s(`rounded-xl border p-3.5`,x),t[0]=x,t[1]=C);let w;t[2]!==a||t[3]!==m||t[4]!==f||t[5]!==g||t[6]!==v||t[7]!==n||t[8]!==r||t[9]!==b||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(w=f?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{className:s(De,`min-h-20 resize-y`),value:m,onChange:e=>h(e.target.value),placeholder:i.updatePlaceholder}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{h(n.statement),p(!1)},children:i.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!m.trim(),onClick:()=>{u(m.trim()),p(!1)},children:i.save})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(T,{className:`size-3 text-accent`,"aria-hidden":!0}),Me(n,i)]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,Z.jsx)(`span`,{children:Oe(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,Z.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,ke(n.latestEvidenceAt,r))}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[b?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,Z.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,Z.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,Z.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:v,onClick:()=>{if(g){_(null);return}y(!0),B(n.id).then(e=>_(e.history)).finally(()=>y(!1))},children:[(0,Z.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,Z.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,Z.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,Z.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:ke(n.updatedAt,r)})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Oe(i.evidenceCount,n.evidenceCount)})]})]})]}),g?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),g.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,Z.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,Z.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:ke(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=m,t[4]=f,t[5]=g,t[6]=v,t[7]=n,t[8]=r,t[9]=b,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let E;return t[16]!==C||t[17]!==w?(E=(0,Z.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=E):E=t[18],E}function Pe(e){let t=(0,Y.c)(84),{source:n,language:r,t:i,onConfigure:a,onDisconnect:o}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.accountCount||t[1]!==n.accountLabel||t[2]!==n.accountOrdinal||t[3]!==i.sourceAccountFallback?(l=n.accountLabel??(n.accountCount&&n.accountCount>1&&n.accountOrdinal?i.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),t[0]=n.accountCount,t[1]=n.accountLabel,t[2]=n.accountOrdinal,t[3]=i.sourceAccountFallback,t[4]=l):l=t[4];let u=l,d;t[5]!==n.lastHealthStatus||t[6]!==i.healthIssue||t[7]!==i.healthOk||t[8]!==i.sourceHealth?(d=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[5]=n.lastHealthStatus,t[6]=i.healthIssue,t[7]=i.healthOk,t[8]=i.sourceHealth,t[9]=d):d=t[9];let f=d,p=`${i.manageSources}: ${n.displayName}`,m;t[10]===a?m=t[11]:(m=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[10]=a,t[11]=m);let h=n.displayName,g;t[12]===n?g=t[13]:(g=Ce(n),t[12]=n,t[13]=g);let _;t[14]!==n.displayName||t[15]!==g?(_=(0,Z.jsx)(be,{connector:{displayName:h,branding:g},size:`sm`}),t[14]=n.displayName,t[15]=g,t[16]=_):_=t[16];let v;t[17]===n.displayName?v=t[18]:(v=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[17]=n.displayName,t[18]=v);let y;t[19]===u?y=t[20]:(y=u?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:u}):null,t[19]=u,t[20]=y);let b;t[21]===n.description?b=t[22]:(b=(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[21]=n.description,t[22]=b);let x;t[23]!==b||t[24]!==v||t[25]!==y?(x=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[v,y,b]}),t[23]=b,t[24]=v,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==_?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[_,x]}),t[27]=x,t[28]=_,t[29]=S):S=t[29];let C=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,w;t[30]===C?w=t[31]:(w=s(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,C),t[30]=C,t[31]=w);let T;t[32]!==c||t[33]!==w?(T=(0,Z.jsx)(`span`,{className:w,children:c}),t[32]=c,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==S||t[36]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,T]}),t[35]=S,t[36]=T,t[37]=E):E=t[37];let D;t[38]!==n.access.context||t[39]!==i.sourceContext?(D=n.access.context?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[38]=n.access.context,t[39]=i.sourceContext,t[40]=D):D=t[40];let O;t[41]!==n.access.memory||t[42]!==i.sourceMemory?(O=n.access.memory?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[41]=n.access.memory,t[42]=i.sourceMemory,t[43]=O):O=t[43];let k;t[44]!==n.access.read||t[45]!==i.sourceRead?(k=n.access.read?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[44]=n.access.read,t[45]=i.sourceRead,t[46]=k):k=t[46];let A;t[47]!==n.access.write||t[48]!==i.sourceWrite?(A=n.access.write?(0,Z.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[47]=n.access.write,t[48]=i.sourceWrite,t[49]=A):A=t[49];let M;t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A?(M=(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[D,O,k,A]}),t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=M):M=t[54];let N;t[55]!==f||t[56]!==r||t[57]!==n.derivedUnderstandingCount||t[58]!==n.installed||t[59]!==n.knowledgeItemCount||t[60]!==n.lastActivityAt||t[61]!==n.lastSyncAt||t[62]!==n.lastSyncError||t[63]!==n.lastSyncStatus||t[64]!==i.sourceDerivedCount||t[65]!==i.sourceKnowledgeCount||t[66]!==i.sourceLastSync||t[67]!==i.sourceLastUsed||t[68]!==i.sourceNeverUsed||t[69]!==i.sourceSyncFailed?(N=n.installed?(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[f?(0,Z.jsx)(`p`,{children:f}):null,(0,Z.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,ke(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,Z.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,ke(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,Z.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,Z.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,Z.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[55]=f,t[56]=r,t[57]=n.derivedUnderstandingCount,t[58]=n.installed,t[59]=n.knowledgeItemCount,t[60]=n.lastActivityAt,t[61]=n.lastSyncAt,t[62]=n.lastSyncError,t[63]=n.lastSyncStatus,t[64]=i.sourceDerivedCount,t[65]=i.sourceKnowledgeCount,t[66]=i.sourceLastSync,t[67]=i.sourceLastUsed,t[68]=i.sourceNeverUsed,t[69]=i.sourceSyncFailed,t[70]=N):N=t[70];let P;t[71]!==o||t[72]!==n.installed||t[73]!==n.instanceId||t[74]!==i.disconnect?(P=n.installed&&n.instanceId?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),o()},children:i.disconnect})}):null,t[71]=o,t[72]=n.installed,t[73]=n.instanceId,t[74]=i.disconnect,t[75]=P):P=t[75];let F;return t[76]!==a||t[77]!==E||t[78]!==M||t[79]!==N||t[80]!==P||t[81]!==p||t[82]!==m?(F=(0,Z.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":p,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:m,children:[E,M,N,P]}),t[76]=a,t[77]=E,t[78]=M,t[79]=N,t[80]=P,t[81]=p,t[82]=m,t[83]=F):F=t[83],F}function Fe(e){let t=(0,Y.c)(63),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:o,onUpdate:c,onDelete:l}=e,[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(``),g=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,_;t[0]===g?_=t[1]:(_=s(`rounded-xl border p-4`,g),t[0]=g,t[1]=_);let v=i.playbookNames[n.id],y;t[2]===v?y=t[3]:(y=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:v}),t[2]=v,t[3]=y);let b;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(b=Oe(i.playbookRuleCount,n.rules.filter(Ie).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=b):b=t[6];let x;t[7]===b?x=t[8]:(x=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:b}),t[7]=b,t[8]=x);let C;t[9]!==y||t[10]!==x?(C=(0,Z.jsxs)(`div`,{children:[y,x]}),t[9]=y,t[10]=x,t[11]=C):C=t[11];let w=n.enabled?i.pausePlaybook:i.resumePlaybook,T;t[12]!==r||t[13]!==a||t[14]!==w?(T=(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:w}),t[12]=r,t[13]=a,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==C||t[17]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,T]}),t[16]=C,t[17]=T,t[18]=E):E=t[18];let D;t[19]!==r||t[20]!==f||t[21]!==m||t[22]!==l||t[23]!==c||t[24]!==n.rules||t[25]!==i.cancel||t[26]!==i.deleteRule||t[27]!==i.disableRule||t[28]!==i.edit||t[29]!==i.enableRule||t[30]!==i.moveDown||t[31]!==i.moveUp||t[32]!==i.save?(D=n.rules.map((e,t)=>(0,Z.jsx)(`li`,{className:s(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:f===e.id?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{className:s(De,`min-h-16 resize-y`),value:m,onChange:e=>h(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>p(null),children:i.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!m.trim(),onClick:()=>{c(e.id,{statement:m.trim()}),p(null)},children:i.save})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{p(e.id),h(e.statement)},children:[(0,Z.jsx)(S,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,Z.jsxs)(j,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,Z.jsx)(k,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]})]})},e.id)),t[19]=r,t[20]=f,t[21]=m,t[22]=l,t[23]=c,t[24]=n.rules,t[25]=i.cancel,t[26]=i.deleteRule,t[27]=i.disableRule,t[28]=i.edit,t[29]=i.enableRule,t[30]=i.moveDown,t[31]=i.moveUp,t[32]=i.save,t[33]=D):D=t[33];let O;t[34]===D?O=t[35]:(O=(0,Z.jsx)(`ul`,{className:`mt-3 space-y-2`,children:D}),t[34]=D,t[35]=O);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>d(e.target.value),t[36]=A):A=t[36];let M;t[37]!==u||t[38]!==i.newRulePlaceholder?(M=(0,Z.jsx)(`input`,{className:De,value:u,onChange:A,placeholder:i.newRulePlaceholder}),t[37]=u,t[38]=i.newRulePlaceholder,t[39]=M):M=t[39];let N;t[40]!==r||t[41]!==u?(N=r||!u.trim(),t[40]=r,t[41]=u,t[42]=N):N=t[42];let P;t[43]!==u||t[44]!==o?(P=()=>{o(u.trim()),d(``)},t[43]=u,t[44]=o,t[45]=P):P=t[45];let F;t[46]!==i.addRule||t[47]!==N||t[48]!==P?(F=(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:N,onClick:P,children:i.addRule}),t[46]=i.addRule,t[47]=N,t[48]=P,t[49]=F):F=t[49];let I;t[50]!==M||t[51]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[M,F]}),t[50]=M,t[51]=F,t[52]=I):I=t[52];let L=i.playbookRuleExamples[n.id],R;t[53]===L?R=t[54]:(R=(0,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-fg-subtle`,children:L}),t[53]=L,t[54]=R);let z;t[55]!==I||t[56]!==R?(z=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[I,R]}),t[55]=I,t[56]=R,t[57]=z):z=t[57];let B;return t[58]!==E||t[59]!==O||t[60]!==_||t[61]!==z?(B=(0,Z.jsxs)(`article`,{className:_,children:[E,O,z]}),t[58]=E,t[59]=O,t[60]=_,t[61]=z,t[62]=B):B=t[62],B}function Ie(e){return e.enabled}function Le(e){let t=(0,Y.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:o,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,Z.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=d);let f=n?l.meetSuggestedBody:l.meetBody,p;t[6]===f?p=t[7]:(p=(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:f}),t[6]=f,t[7]=p);let m;t[8]===l.callName?m=t[9]:(m=(0,Z.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=m);let h;t[10]===a?h=t[11]:(h=e=>a(e.target.value),t[10]=a,t[11]=h);let g;t[12]!==i||t[13]!==r||t[14]!==o?(g=e=>{e.key===`Enter`&&r.trim()&&!i&&o()},t[12]=i,t[13]=r,t[14]=o,t[15]=g):g=t[15];let _=l.meetPlaceholder,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=s(De,`h-10 flex-1 bg-surface-base/90`),t[16]=v):v=t[16];let y;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==h||t[20]!==g?(y=(0,Z.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,onChange:h,onKeyDown:g,placeholder:_,className:v}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=h,t[20]=g,t[21]=y):y=t[21];let b;t[22]!==i||t[23]!==r?(b=i||!r.trim(),t[22]=i,t[23]=r,t[24]=b):b=t[24];let x=i?l.meetSaving:l.meetSave,S;t[25]!==o||t[26]!==b||t[27]!==x?(S=(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:b,onClick:o,children:x}),t[25]=o,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==y||t[30]!==S||t[31]!==m?(C=(0,Z.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[m,y,S]}),t[29]=y,t[30]=S,t[31]=m,t[32]=C):C=t[32];let w;t[33]!==n||t[34]!==l.meetSource?(w=n?(0,Z.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,Z.jsx)(J,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=w):w=t[35];let T;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(T=(0,Z.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=T):T=t[39];let E;return t[40]!==C||t[41]!==w||t[42]!==T||t[43]!==d||t[44]!==p?(E=(0,Z.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,Z.jsxs)(`div`,{className:`relative max-w-2xl`,children:[d,p,C,w,T]})}),t[40]=C,t[41]=w,t[42]=T,t[43]=d,t[44]=p,t[45]=E):E=t[45],E}function Re(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,p]=i(),m=Ae(r.get(`tab`)),g=U(e=>e.setPageHeader),T=U(e=>e.clearPageHeader),{data:O,error:k,isLoading:M,mutate:N}=u(`/api/you`,E),[P,F]=(0,X.useState)(null),[L,B]=(0,X.useState)(!1),[G,ne]=(0,X.useState)(``),[ie,K]=(0,X.useState)(`preference`),[q,ve]=(0,X.useState)(null),[be,Y]=(0,X.useState)(!1),[Se,Ce]=(0,X.useState)(null),[Te,Ie]=(0,X.useState)(!1),[Re,ze]=(0,X.useState)(``),[Be,Ve]=(0,X.useState)(!1),[He,Ue]=(0,X.useState)(null),[We,Ge]=(0,X.useState)(!1),[Ke,qe]=(0,X.useState)(null),[Je,Ye]=(0,X.useState)(!1),[Xe,Ze]=(0,X.useState)(null),Qe=(0,X.useRef)(null),$e=(0,X.useRef)(null),Q=O?.profile??{callName:``,pronouns:``,timezone:``,notes:``},et=(0,X.useMemo)(()=>O?.understanding.filter(e=>e.status===`active`)??[],[O]),tt=(0,X.useMemo)(()=>O?.understanding.filter(e=>e.status!==`active`)??[],[O]),nt=(0,X.useMemo)(()=>new Map(Ee.map(e=>[e,et.filter(t=>t.facet===e)])),[et]),rt=He??O?.controls??null,it=O?.sources.filter(e=>e.installed&&e.enabled)??[],at=it.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status)),$=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),p(n,{replace:!0})},ot=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,X.useLayoutEffect)(()=>(g({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:null}),()=>T()),[T,g,t.subtitle,t.title]),(0,X.useEffect)(()=>{!O||O.profile.callName||ze(O.profileSetup.callNameSuggestion?.value??``)},[O,O?.profile.callName,O?.profileSetup.callNameSuggestion?.id]);async function st(e,n,r){F(e.id);try{let t=await ue(e.id,{action:n,content:r});await N(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),N()}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function ct(e,n){F(`consent:${e}`);try{await de(e,n),await N(),b({type:`success`,title:t.title,message:t.saved})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function lt(){let e=G.trim();if(e){F(`understanding:new`);try{await x({content:e,kind:ie}),ne(``),B(!1),await N(),b({type:`success`,title:t.understandingTitle,message:t.saved})}catch{b({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{F(null)}}}async function ut(){if(tt.length){F(`understanding:batch`);try{await I(tt.map(e=>e.id),`confirm`),await N()}catch{b({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{F(null)}}}async function dt(e,n){F(`conflict:${e}`);try{await he(e,n),await N()}catch{b({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{F(null)}}async function ft(e){F(`grant:${e}`);try{await le(e),await N()}catch{b({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{F(null)}}async function pt(r,i){F(`insight:${r.id}`);try{let t=await se(r.id,{action:i,uiLocale:e});await N(),i===`apply`&&t.href&&n(t.href)}catch{b({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{F(null)}}async function mt(e){F(`playbook:${e.id}`);try{await fe(e.id,!e.enabled),await N()}catch{b({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function ht(e,n){F(`playbook:${e}`);try{await n(),await N()}catch{b({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function gt(){if(q){F(q.id);try{await f(q.id);let e=q.id;ve(null),await N(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),N()}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}}async function _t(){if(Se){Ie(!0);try{let e=await W(Se);Y(!1),Ce(null),await N(t=>t&&{...t,...e},{revalidate:!1})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ie(!1)}}}async function vt(){let e=Re.trim();if(!(!e||Be)){Ve(!0);try{let t=await W({callName:e,timezone:Q.timezone||oe()});await N(e=>e&&{...e,...t},{revalidate:!1})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ve(!1)}}}async function yt(){if(!Be){Ve(!0);try{let e=await ce(`snooze`);await N(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ve(!1)}}}function bt(){Ce(Q),Y(!0),$(`profile`),requestAnimationFrame(()=>Qe.current?.scrollIntoView({behavior:`smooth`,block:`start`}))}function xt(e){K(e),B(!0),$(`understanding`)}async function St(){if(rt){Ge(!0);try{Ue(await pe(rt)),await N(),b({type:`success`,title:t.title,message:t.saved})}catch{b({type:`error`,title:t.title,message:t.saveError})}finally{Ge(!1)}}}async function Ct(e){if(!(!Ke?.instanceId||Je)){Ye(!0);try{let n=await z(Ke.instanceId,e);qe(null),await N(),b({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{b({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{Ye(!1)}}}async function wt(){if(!Xe){Ze(`export`);try{let e=await R(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{b({type:`error`,title:t.transferTitle,message:t.saveError})}finally{Ze(null)}}}async function Tt(e){if(!(!e||Xe)){Ze(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await te(JSON.parse(await e.text()));await N(),$(`understanding`,`review`),b({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{b({type:`error`,title:t.transferTitle,message:t.importError})}finally{$e.current&&($e.current.value=``),Ze(null)}}}return(0,Z.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(ye,{items:[{id:`overview`,label:t.tabs.overview,icon:re},{id:`profile`,label:t.tabs.profile,icon:w},{id:`understanding`,label:t.tabs.understanding,icon:ee,count:tt.length||void 0},{id:`sources`,label:t.tabs.sources,icon:_e},{id:`controls`,label:t.tabs.controls,icon:J}],activeTab:m,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`,className:`pr-8 sm:pr-1`,buttonClassName:`px-2.5 sm:px-3`}),(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 w-8 bg-gradient-to-l from-surface-panel to-transparent sm:hidden`,"aria-hidden":!0})]}),M?(0,Z.jsx)(je,{}):k||!O?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,O&&m===`overview`?(0,Z.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Q.callName&&O.profileSetup.shouldPrompt?(0,Z.jsx)(Le,{suggestion:O.profileSetup.callNameSuggestion,draft:Re,busy:Be,onDraftChange:ze,onSave:()=>void vt(),onLater:()=>void yt(),t}):null,tt.length>0||at.length>0||!Q.callName?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[tt.length>0?(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[Oe(t.reviewCount,tt.length),(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]}):null,at.length>0?(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[Oe(t.sourceIssues,at.length),(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]}):null,Q.callName?null:(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:bt,children:[t.completeProfile,(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/55 via-surface-panel to-surface-panel p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.heroTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.heroBody}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:et.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`sources`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:it.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl bg-surface-base/80 p-3 text-left`,onClick:()=>$(`understanding`,`review`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:tt.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.waitingReview})]})]})]}),O.insights.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(me,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.insightsHint}),(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:O.insights.map(e=>(0,Z.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?Oe(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void pt(e,`dismiss`),children:t.notNow}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void pt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(w,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`profile`),children:(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.callName||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.timezone||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.pronouns||`—`})]}),Q.notes?(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,Z.jsx)(`dd`,{className:`mt-1 line-clamp-2 text-sm leading-6 text-fg`,children:Q.notes})]}):null]})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(ee,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[et.slice(0,4).map(e=>(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),et.length===0?(0,Z.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]})]}):null,O&&m===`profile`?(0,Z.jsxs)(`div`,{id:`you-panel-profile`,role:`tabpanel`,"aria-labelledby":`you-tab-profile`,className:`space-y-5`,children:[(0,Z.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:t.profileOwnershipHint}),(0,Z.jsxs)(`section`,{ref:Qe,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(w,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.profileHint})]}),be?null:(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:bt,children:[(0,Z.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),be&&Se?(0,Z.jsxs)(`div`,{className:`mt-5`,children:[(0,Z.jsx)(xe,{value:Se,onChange:Ce,language:e,inputClassName:De,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>{Y(!1),Ce(null)},children:t.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:Te,onClick:()=>void _t(),children:Te?t.saving:t.save})]})]}):(0,Z.jsxs)(`dl`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.callName||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.timezone||`—`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,Z.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.pronouns||`—`})]}),(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,Z.jsx)(`dd`,{className:`mt-1 whitespace-pre-wrap text-sm leading-6 text-fg`,children:Q.notes||`—`})]})]})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.structuredContextTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.structuredContextHint}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`preference`),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addPreference}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addPreferenceHint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`boundary`),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addBoundary}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addBoundaryHint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>xt(`current_state`),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addCurrentFocus}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addCurrentFocusHint})]})]})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.playbooksHint}),O.playbooks.length>0?(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:O.playbooks.map(e=>(0,Z.jsx)(Fe,{playbook:e,busy:P===`playbook:${e.id}`,t,onToggleGroup:()=>void mt(e),onCreate:t=>void ht(e.id,()=>h(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void ht(e.id,()=>V(e.id,t,n)),onDelete:t=>void ht(e.id,()=>y(e.id,t))},e.id))}):(0,Z.jsx)(`p`,{className:`mt-4 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.emptyPlaybooks})]})]}):null,O&&m===`understanding`?(0,Z.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,Z.jsx)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs text-fg-muted`,children:t.memoryScope}),(0,Z.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),L?null:(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>B(!0),children:[(0,Z.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),L?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Z.jsx)(`textarea`,{className:s(De,`min-h-24 resize-y`),value:G,onChange:e=>ne(e.target.value),placeholder:t.understandingPlaceholder}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,Z.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,Z.jsx)(d,{value:ie,onChange:e=>K(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,Z.jsx)(ge,{value:e,children:t},e))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>{B(!1),ne(``)},children:t.cancel}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:!G.trim()||P===`understanding:new`,onClick:()=>void lt(),children:t.add})]})]})]}):null]}),O.conflictGroups.some(e=>e.unresolved)?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-3`,children:O.conflictGroups.filter(e=>e.unresolved).map(n=>(0,Z.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Me(r,t),` · `,ke(r.updatedAt,e)]})]}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:P===`conflict:${n.id}`,onClick:()=>void dt(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,O.consentRequests.length>0?(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),O.consentRequests.map(e=>(0,Z.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,Z.jsx)(j,{type:`button`,variant:`ghost`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`deny`),children:t.consentDeny}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`once`),children:t.consentOnce}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`session`),children:t.consentSession}),(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:P===`consent:${e.id}`,onClick:()=>void ct(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,tt.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,Z.jsx)(j,{type:`button`,variant:`secondary`,disabled:P===`understanding:batch`,onClick:()=>void ut(),children:t.reviewAll})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:tt.map(n=>(0,Z.jsx)(Ne,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ve(n)},n.id))})]}):et.length>0?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,Z.jsx)(o,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,Ee.map(n=>{let r=nt.get(n)??[];return r.length===0?null:(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,Z.jsx)(Ne,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void st(n,`confirm`),onReject:()=>void st(n,`reject`),onUpdate:e=>void st(n,`update`,e),onForget:()=>ve(n)},n.id))})]},n)}),O.understanding.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,O&&m===`sources`?(0,Z.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.sourcesHint})]}),(0,Z.jsxs)(j,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]})]}),O.sourceRecommendations.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.recommendationsHint}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:O.sourceRecommendations.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>ot({id:e.sourceId}),children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,Z.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:O.sources.map(n=>(0,Z.jsx)(Pe,{source:n,language:e,t,onConfigure:()=>ot(n),onDisconnect:()=>qe(n)},`${n.id}:${n.instanceId??`catalog`}`))}),O.sources.length===0?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,O&&m===`controls`&&rt?(0,Z.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.controlHint}),(0,Z.jsxs)(`div`,{className:`mt-4 max-w-2xl space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,Z.jsx)(d,{value:rt.mode,onChange:e=>Ue({...rt,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,Z.jsx)(ge,{value:e,children:t},e))})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,Z.jsx)(d,{value:rt.sensitiveWritePolicy,onChange:e=>Ue({...rt,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,Z.jsx)(ge,{value:e,children:t},e))})]}),(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-accent-soft/40 p-3 text-xs leading-5 text-fg-muted`,children:[(0,Z.jsx)(J,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:t.transientPromise})]}),(0,Z.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,Z.jsx)(j,{type:`button`,variant:`primary`,disabled:We,onClick:()=>void St(),children:We?t.saving:t.save})})]})]}),(0,Z.jsxs)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.actionBoundaryMovedTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.actionBoundaryMovedHint})]}),(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>n(`/settings/action-boundary`),children:[t.manageActionBoundary,(0,Z.jsx)(H,{className:`size-4`,"aria-hidden":!0})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),O.referenceGrants.length>0?(0,Z.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:O.referenceGrants.map(n=>(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${ke(n.expiresAt,e)}`:``]})]}),(0,Z.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:P===`grant:${n.id}`,onClick:()=>void ft(n.id),children:t.revoke})]},n.id))}):(0,Z.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:t.transferHint}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,disabled:Xe!==null,onClick:()=>void wt(),children:[(0,Z.jsx)(D,{className:`size-4`,"aria-hidden":!0}),Xe===`export`?t.exporting:t.exportAction]}),(0,Z.jsxs)(j,{type:`button`,variant:`secondary`,disabled:Xe!==null,onClick:()=>$e.current?.click(),children:[(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),Xe===`import`?t.importing:t.importAction]}),(0,Z.jsx)(`input`,{ref:$e,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>void Tt(e.target.files?.[0])})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:t.importPromise})]})]}):null,(0,Z.jsx)(v,{open:q!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void gt(),onCancel:()=>ve(null)}),(0,Z.jsx)(we,{source:Ke,language:e,busy:Je,onOpenChange:e=>{e||qe(null)},onConfirm:e=>void Ct(e)})]})}export{Re as UserContextPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-BQ_8x0bT.js";import{l as o,r as s,s as c}from"./locale-store-CPbGB_6l.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{$o as u,Bt as d,Fl as f,In as p,Ja as m,Kc as h,Ss as g,Vt as _,Ya as ee,dc as v,ps as y,su as b,ts as x,xs as S}from"./index-CHKe7nwC.js";var C=`/api/image/providers`;async function w(){return(await c(s(`/api/image/providers`)))?.payload?.providers??[]}var T=e(t(),1),te=n();function E(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function ne(e){return e?.apiKey?`••••••••••••`:``}function D(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:ne(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function O(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function k(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(p(n)&&p(r)))return n||(r?null:void 0)}function re(e,t,n){let r={};for(let i of e){let e=t[i]??E(),a=n[i]??E();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=k(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=O(e,a,`region`);c!==void 0&&(o.region=c);let l=O(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=O(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function A(e){let t=await c(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ie(e){Object.keys(e).length!==0&&(await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await m())}var j=r();function ae(e){let t=(0,te.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>A(n).then(M),t[0]=n,t[1]=c);let l=c,u=`img-cred-key-${n}`,d;t[2]!==a.apiKeyLabel||t[3]!==u?(d=(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:u,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=u,t[4]=d):d=t[4];let p;t[5]!==s||t[6]!==o?(p=o.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,j.jsxs)(`a`,{href:e.href,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:[_(e.kind,s),(0,j.jsx)(f,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=p):p=t[7];let m=`img-cred-key-${n}`,h;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==m||t[12]!==r?(h=(0,j.jsx)(y,{id:m,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=m,t[12]=r,t[13]=h):h=t[13];let g;return t[14]!==d||t[15]!==p||t[16]!==h?(g=(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[d,p,h]}),t[14]=d,t[15]=p,t[16]=h,t[17]=g):g=t[17],g}function M(e){return e.apiKey??null}function N(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S)}function oe(){return a(N(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var P=`__custom__`;function se(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:P}function ce(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:P}function le(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function ue(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function de(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function fe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function pe(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function me(e){let t=(0,te.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:p,credNoopFlash:m,updateCredRow:_,onDiscardCredentials:ee,onSaveCredentials:y,extensionIds:S,showExtensionLinks:C,showImageModelsLink:w,hideActions:ne,language:D,apiKeyLinkLabels:O,messages:k}=e,re=ne===void 0?!1:ne,A;t[0]===n?A=t[1]:(A=n.some(ye),t[0]=n,t[1]=A);let ie=A,M;t[2]===n?M=t[3]:(M=n.some(ve),t[2]=n,t[3]=M);let me=M,[F,be]=(0,T.useState)(_e),[I,L]=(0,T.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)fe(r[e.id]??E(),o[e.id]??E())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===k.credentialsIntro?W=t[15]:(W=(0,j.jsx)(`p`,{children:k.credentialsIntro}),t[14]=k.credentialsIntro,t[15]=W);let G;t[16]!==ie||t[17]!==k.regionHint?(G=ie?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.regionHint}):null,t[16]=ie,t[17]=k.regionHint,t[18]=G):G=t[18];let K;t[19]!==me||t[20]!==k.endpointPresetsHint?(K=me?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.endpointPresetsHint}):null,t[19]=me,t[20]=k.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==w||t[23]!==k.imageModelsLinkTitle||t[24]!==k.openImageModelsPage?(q=w?(0,j.jsx)(`p`,{children:(0,j.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:k.imageModelsLinkTitle,children:k.openImageModelsPage})}):null,t[22]=w,t[23]=k.imageModelsLinkTitle,t[24]=k.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,j.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===l?Y=t[32]:(Y=l?(0,j.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==m||t[35]!==p||t[36]!==c||t[37]!==re||t[38]!==ee||t[39]!==y||t[40]!==k.credentialsNothingToSave||t[41]!==k.credentialsSaved||t[42]!==k.discardCredentials||t[43]!==k.saveCredentials||t[44]!==k.savingCredentials?(X=re?null:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[p?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsSaved}):null,m?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsNothingToSave}):null,(0,j.jsx)(g,{type:`button`,variant:`secondary`,onClick:ee,disabled:!s||c,children:k.discardCredentials}),(0,j.jsx)(g,{type:`button`,variant:`primary`,onClick:y,disabled:!s||c,children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(h,{className:`size-3.5 animate-spin`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.savingCredentials})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(v,{className:`size-3.5`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.saveCredentials})]})})]}),t[33]=s,t[34]=m,t[35]=p,t[36]=c,t[37]=re,t[38]=ee,t[39]=y,t[40]=k.credentialsNothingToSave,t[41]=k.credentialsSaved,t[42]=k.discardCredentials,t[43]=k.saveCredentials,t[44]=k.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==O||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==D||t[52]!==C||t[53]!==n||t[54]!==k||t[55]!==U||t[56]!==_){let e;t[58]!==O||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==D||t[64]!==C||t[65]!==k||t[66]!==U||t[67]!==_?(e=e=>{let t=r[e.id]??E(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=fe(t,o[e.id]??E()),l=V(e.id),p=e.label??e.id,m=pe(k,e.models.length);return(0,j.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,j.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:p}),(0,j.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.unsavedChanges}):null,e.configured?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.configured}):(0,j.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:k.missingKey})]}),(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,j.jsx)(`span`,{children:m}),e.defaultModel?(0,j.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,j.jsx)(b,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`sr-only`,children:l?k.collapseProvider:k.expandProvider})]}),l?(0,j.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 p-4`,children:[s?(0,j.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:k.extensionSettingsLinkTitle,children:[(0,j.jsx)(f,{className:`size-3`}),k.openExtensionSettings]}):null,e.models.length>0?(0,j.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,j.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,j.jsx)(ae,{providerId:e.id,value:t.apiKey,onChange:t=>_(e.id,{apiKey:t}),apiKeyLinks:d(e.id,D),apiKeyLinkLabels:O,labels:{apiKeyLabel:k.apiKeyLabel,optionalPlaceholder:k.optionalPlaceholder,maskedHelp:k.apiKeyMaskedHelp,copy:k.apiKeyCopy,copied:k.apiKeyCopied,show:k.apiKeyShow,hide:k.apiKeyHide,notInConfigFile:k.apiKeyNotInConfigFile,loadFailed:k.apiKeyRevealFailed}}),n?.regions?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:k.regionLabel}),(0,j.jsxs)(u,{id:`img-cred-region-preset-${e.id}`,className:oe(),value:se(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){_(e.id,{region:``,imageBaseUrl:``});return}if(r===P){_(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&_(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,j.jsx)(x,{value:``,children:k.regionPresetDefault}),n.regions.map(e=>(0,j.jsx)(x,{value:e.value,children:le(k,e.value,e.label)},e.value)),(0,j.jsx)(x,{value:P,children:k.regionPresetCustom})]}),se(t,n.regions)===P?(0,j.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,j.jsx)(`input`,{type:`text`,className:N(),value:t.region,placeholder:`region`,onChange:t=>_(e.id,{region:t.target.value})}),(0,j.jsx)(`input`,{type:`url`,className:N(),value:t.imageBaseUrl,placeholder:k.imageBaseUrlLabel,onChange:t=>_(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:ue(k,n.baseUrlPresetKind)}),de(k,n.baseUrlPresetKind)?(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:de(k,n.baseUrlPresetKind)}):null,(0,j.jsxs)(u,{id:`img-cred-base-preset-${e.id}`,className:oe(),value:ce(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){_(e.id,{baseUrl:``});return}if(n===P){_(e.id,{baseUrl:``});return}_(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,j.jsx)(x,{value:``,children:k.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,j.jsx)(x,{value:P,children:k.baseUrlPresetCustom})]}),ce(t,n.baseUrlPresets)===P?(0,j.jsx)(`input`,{type:`url`,className:a(N(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>_(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&se(t,n.regions)!==P?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:k.imageBaseUrlLabel}),(0,j.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(N(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:k.imageBaseUrlPresetHint}),(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:k.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=O,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=D,t[64]=C,t[65]=k,t[66]=U,t[67]=_,t[68]=e):e=t[68],Z=n.map(e),t[46]=O,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=D,t[52]=C,t[53]=n,t[54]=k,t[55]=U,t[56]=_,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,j.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,j.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function he(e){return(0,j.jsx)(x,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=ee(o(e=>!!e.token)),n=t.data,r=(0,T.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,T.useRef)(!1),[a,c]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),[f,p]=(0,T.useState)(null),[m,h]=(0,T.useState)(!1),[g,_]=(0,T.useState)(!1),v=(0,T.useMemo)(()=>D(n?.payload?.config,r),[n?.payload?.config,r]),y=a??v,b=v;return{gwSwr:t,credDraft:y,credBaseline:b,credDirty:(0,T.useMemo)(()=>JSON.stringify(y)!==JSON.stringify(b),[y,b]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,T.useCallback)((e,t)=>{i.current=!0,c(n=>{let r=n??v,i=r[e]??E();return{...r,[e]:{...i,...t}}})},[v]),onDiscardCredentials:(0,T.useCallback)(()=>{i.current=!1,c(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,T.useCallback)(async e=>{let n=re(r,y,b);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ie(n),await t.mutate?.(),l(s(C)),i.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,y,b,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=be();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=I();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function K(){return G((await c(s(`/api/config`))).payload?.config??{})}async function q(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await c(s(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),m()}async function J(){let e=await c(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await c(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await c(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(){let e=await c(s(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(e){let t=await c(s(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Se(e){let t=await c(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function Ce(e){let t=(0,te.c)(15),{kind:n,providerId:r,fieldId:i,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,j.jsx)(y,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,j.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,w as m,Z as n,X as o,me as p,J as r,Q as s,Ce as t,$ as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./cn-JdwAhgNB.js";import{l as o,r as s,s as c}from"./locale-store-Dar-xqQr.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{$o as u,Bt as d,Fl as f,In as p,Ja as m,Kc as h,Ss as g,Vt as _,Ya as ee,dc as v,ps as y,su as b,ts as x,xs as S}from"./index-vq_cJZJC.js";var C=`/api/image/providers`;async function w(){return(await c(s(`/api/image/providers`)))?.payload?.providers??[]}var T=e(t(),1),te=n();function E(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function ne(e){return e?.apiKey?`••••••••••••`:``}function D(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:ne(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function O(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function k(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(p(n)&&p(r)))return n||(r?null:void 0)}function re(e,t,n){let r={};for(let i of e){let e=t[i]??E(),a=n[i]??E();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=k(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=O(e,a,`region`);c!==void 0&&(o.region=c);let l=O(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=O(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function A(e){let t=await c(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ie(e){Object.keys(e).length!==0&&(await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await m())}var j=r();function ae(e){let t=(0,te.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>A(n).then(M),t[0]=n,t[1]=c);let l=c,u=`img-cred-key-${n}`,d;t[2]!==a.apiKeyLabel||t[3]!==u?(d=(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:u,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=u,t[4]=d):d=t[4];let p;t[5]!==s||t[6]!==o?(p=o.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,j.jsxs)(`a`,{href:e.href,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:[_(e.kind,s),(0,j.jsx)(f,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=p):p=t[7];let m=`img-cred-key-${n}`,h;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==m||t[12]!==r?(h=(0,j.jsx)(y,{id:m,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=m,t[12]=r,t[13]=h):h=t[13];let g;return t[14]!==d||t[15]!==p||t[16]!==h?(g=(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[d,p,h]}),t[14]=d,t[15]=p,t[16]=h,t[17]=g):g=t[17],g}function M(e){return e.apiKey??null}function N(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S)}function oe(){return a(N(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var P=`__custom__`;function se(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:P}function ce(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:P}function le(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function ue(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function de(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function fe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function pe(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function me(e){let t=(0,te.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:p,credNoopFlash:m,updateCredRow:_,onDiscardCredentials:ee,onSaveCredentials:y,extensionIds:S,showExtensionLinks:C,showImageModelsLink:w,hideActions:ne,language:D,apiKeyLinkLabels:O,messages:k}=e,re=ne===void 0?!1:ne,A;t[0]===n?A=t[1]:(A=n.some(ye),t[0]=n,t[1]=A);let ie=A,M;t[2]===n?M=t[3]:(M=n.some(ve),t[2]=n,t[3]=M);let me=M,[F,be]=(0,T.useState)(_e),[I,L]=(0,T.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)fe(r[e.id]??E(),o[e.id]??E())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===k.credentialsIntro?W=t[15]:(W=(0,j.jsx)(`p`,{children:k.credentialsIntro}),t[14]=k.credentialsIntro,t[15]=W);let G;t[16]!==ie||t[17]!==k.regionHint?(G=ie?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.regionHint}):null,t[16]=ie,t[17]=k.regionHint,t[18]=G):G=t[18];let K;t[19]!==me||t[20]!==k.endpointPresetsHint?(K=me?(0,j.jsx)(`p`,{className:`text-fg-subtle`,children:k.endpointPresetsHint}):null,t[19]=me,t[20]=k.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==w||t[23]!==k.imageModelsLinkTitle||t[24]!==k.openImageModelsPage?(q=w?(0,j.jsx)(`p`,{children:(0,j.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:k.imageModelsLinkTitle,children:k.openImageModelsPage})}):null,t[22]=w,t[23]=k.imageModelsLinkTitle,t[24]=k.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,j.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===l?Y=t[32]:(Y=l?(0,j.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==m||t[35]!==p||t[36]!==c||t[37]!==re||t[38]!==ee||t[39]!==y||t[40]!==k.credentialsNothingToSave||t[41]!==k.credentialsSaved||t[42]!==k.discardCredentials||t[43]!==k.saveCredentials||t[44]!==k.savingCredentials?(X=re?null:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[p?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsSaved}):null,m?(0,j.jsx)(`span`,{className:`text-sm text-fg-muted`,children:k.credentialsNothingToSave}):null,(0,j.jsx)(g,{type:`button`,variant:`secondary`,onClick:ee,disabled:!s||c,children:k.discardCredentials}),(0,j.jsx)(g,{type:`button`,variant:`primary`,onClick:y,disabled:!s||c,children:c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(h,{className:`size-3.5 animate-spin`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.savingCredentials})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(v,{className:`size-3.5`}),(0,j.jsx)(`span`,{className:`ml-1.5`,children:k.saveCredentials})]})})]}),t[33]=s,t[34]=m,t[35]=p,t[36]=c,t[37]=re,t[38]=ee,t[39]=y,t[40]=k.credentialsNothingToSave,t[41]=k.credentialsSaved,t[42]=k.discardCredentials,t[43]=k.saveCredentials,t[44]=k.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==O||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==D||t[52]!==C||t[53]!==n||t[54]!==k||t[55]!==U||t[56]!==_){let e;t[58]!==O||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==D||t[64]!==C||t[65]!==k||t[66]!==U||t[67]!==_?(e=e=>{let t=r[e.id]??E(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=fe(t,o[e.id]??E()),l=V(e.id),p=e.label??e.id,m=pe(k,e.models.length);return(0,j.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,j.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:p}),(0,j.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.unsavedChanges}):null,e.configured?(0,j.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:k.configured}):(0,j.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:k.missingKey})]}),(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,j.jsx)(`span`,{children:m}),e.defaultModel?(0,j.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,j.jsx)(b,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`sr-only`,children:l?k.collapseProvider:k.expandProvider})]}),l?(0,j.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 p-4`,children:[s?(0,j.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:k.extensionSettingsLinkTitle,children:[(0,j.jsx)(f,{className:`size-3`}),k.openExtensionSettings]}):null,e.models.length>0?(0,j.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,j.jsxs)(`span`,{className:`text-fg-muted`,children:[k.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,j.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,j.jsx)(ae,{providerId:e.id,value:t.apiKey,onChange:t=>_(e.id,{apiKey:t}),apiKeyLinks:d(e.id,D),apiKeyLinkLabels:O,labels:{apiKeyLabel:k.apiKeyLabel,optionalPlaceholder:k.optionalPlaceholder,maskedHelp:k.apiKeyMaskedHelp,copy:k.apiKeyCopy,copied:k.apiKeyCopied,show:k.apiKeyShow,hide:k.apiKeyHide,notInConfigFile:k.apiKeyNotInConfigFile,loadFailed:k.apiKeyRevealFailed}}),n?.regions?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:k.regionLabel}),(0,j.jsxs)(u,{id:`img-cred-region-preset-${e.id}`,className:oe(),value:se(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){_(e.id,{region:``,imageBaseUrl:``});return}if(r===P){_(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&_(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,j.jsx)(x,{value:``,children:k.regionPresetDefault}),n.regions.map(e=>(0,j.jsx)(x,{value:e.value,children:le(k,e.value,e.label)},e.value)),(0,j.jsx)(x,{value:P,children:k.regionPresetCustom})]}),se(t,n.regions)===P?(0,j.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,j.jsx)(`input`,{type:`text`,className:N(),value:t.region,placeholder:`region`,onChange:t=>_(e.id,{region:t.target.value})}),(0,j.jsx)(`input`,{type:`url`,className:N(),value:t.imageBaseUrl,placeholder:k.imageBaseUrlLabel,onChange:t=>_(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:ue(k,n.baseUrlPresetKind)}),de(k,n.baseUrlPresetKind)?(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:de(k,n.baseUrlPresetKind)}):null,(0,j.jsxs)(u,{id:`img-cred-base-preset-${e.id}`,className:oe(),value:ce(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){_(e.id,{baseUrl:``});return}if(n===P){_(e.id,{baseUrl:``});return}_(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,j.jsx)(x,{value:``,children:k.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,j.jsx)(x,{value:P,children:k.baseUrlPresetCustom})]}),ce(t,n.baseUrlPresets)===P?(0,j.jsx)(`input`,{type:`url`,className:a(N(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>_(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&se(t,n.regions)!==P?(0,j.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:k.imageBaseUrlLabel}),(0,j.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(N(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:k.imageBaseUrlPresetHint}),(0,j.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:k.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=O,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=D,t[64]=C,t[65]=k,t[66]=U,t[67]=_,t[68]=e):e=t[68],Z=n.map(e),t[46]=O,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=D,t[52]=C,t[53]=n,t[54]=k,t[55]=U,t[56]=_,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,j.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,j.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function he(e){return(0,j.jsx)(x,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=ee(o(e=>!!e.token)),n=t.data,r=(0,T.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,T.useRef)(!1),[a,c]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),[f,p]=(0,T.useState)(null),[m,h]=(0,T.useState)(!1),[g,_]=(0,T.useState)(!1),v=(0,T.useMemo)(()=>D(n?.payload?.config,r),[n?.payload?.config,r]),y=a??v,b=v;return{gwSwr:t,credDraft:y,credBaseline:b,credDirty:(0,T.useMemo)(()=>JSON.stringify(y)!==JSON.stringify(b),[y,b]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,T.useCallback)((e,t)=>{i.current=!0,c(n=>{let r=n??v,i=r[e]??E();return{...r,[e]:{...i,...t}}})},[v]),onDiscardCredentials:(0,T.useCallback)(()=>{i.current=!1,c(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,T.useCallback)(async e=>{let n=re(r,y,b);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ie(n),await t.mutate?.(),l(s(C)),i.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,y,b,t])}}function be(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function I(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=be();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(L(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=I();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function W(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function G(e){let t=L(e)?e:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function K(){return G((await c(s(`/api/config`))).payload?.config??{})}async function q(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await c(s(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),m()}async function J(){let e=await c(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await c(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await c(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(){let e=await c(s(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(e){let t=await c(s(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function Se(e){let t=await c(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function Ce(e){let t=(0,te.c)(15),{kind:n,providerId:r,fieldId:i,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,j.jsx)(y,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,j.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,w as m,Z as n,X as o,me as p,J as r,Q as s,Ce as t,$ as u};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./messages-CxySDn9d.js";import{n as ee}from"./locale-store-Dar-xqQr.js";import{At as te,Co as ne,Cs as re,Do as ie,Fo as s,Io as ae,Kc as c,Lo as l,Mo as oe,No as se,Oo as u,Pl as ce,Po as le,Pt as ue,So as de,Ss as d,Tl as f,To as fe,Ts as p,Xa as m,au as pe,jo as me,kl as he,ko as ge,nc as h,ql as _e,su as ve,wo as ye,xl as be,xo as g}from"./index-vq_cJZJC.js";var _=e(t(),1),v=new Set([`completed`,`failed`,`canceled`]);function y(){return new Promise(e=>window.setTimeout(e,1200))}async function xe(e,t){let n=[],r=t.wait??y;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!v.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var b=n(),Se=[`folder_structure`,`recent_progress`,`next_steps`];function x(e){return e instanceof Error?e.message:String(e)}function S(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,v=i(),[y]=r(),S=y.get(`new`)===`1`,[C,w]=(0,_.useState)(`loading`),[T,E]=(0,_.useState)(null),[D,O]=(0,_.useState)(null),[k,A]=(0,_.useState)(!1),[j,M]=(0,_.useState)(null),[Ce,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)(``),[I,L]=(0,_.useState)(!1),[R,z]=(0,_.useState)(()=>new Set),[B,we]=(0,_.useState)(!1),[V,Te]=(0,_.useState)([]),[H,Ee]=(0,_.useState)(()=>new Set),[De,U]=(0,_.useState)([]),[Oe,ke]=(0,_.useState)(!1),[W,G]=(0,_.useState)({current:0,total:0}),K=(0,_.useRef)(!1),q=(0,_.useCallback)(e=>{g.getState().updateDirectoryRun(e),O(e),e.status===`completed`?(z(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),w(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?w(`error`):w(`running`)},[]),Ae=async()=>{A(!0),M(null);try{let e=await ye();if(!e.length){M(t.noCandidates);return}Te(e),Ee(new Set([e[0].rootPath])),w(`candidates`)}catch(e){M(x(e))}finally{A(!1)}},je=e=>{Ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Me=(0,_.useCallback)((e,t,n)=>{g.getState().updateDirectoryRun(e),O(e),G({current:t+1,total:n}),U(n=>{let r=[...n];return r[t]=e,r}),w(`running`)},[]),Ne=(0,_.useCallback)(e=>{U(t=>t.map(t=>t?.id===e.id?e:t))},[]),Pe=async()=>{let e=V.filter(e=>H.has(e.rootPath));if(!e.length)return;A(!0),M(null),U([]),G({current:1,total:e.length}),ke(!0),K.current=!1;let n=!1;try{let r=await xe(e,{grantDirectory:ge,startRun:le,fetchRun:u,shouldStop:()=>K.current,onRun:(e,t,r)=>{Me(e,t,r),n||(n=!0,g.getState().scanPersonalContext(e.id))},onError:(n,r,i)=>{G({current:i+1,total:e.length}),M(t.folderAnalysisFailed.replace(`{{folder}}`,r.displayName).replace(`{{error}}`,x(n)))}});if(K.current)return;let i=r.find(e=>e.status===`completed`)??r.at(-1);i?q(i):w(`candidates`)}catch(e){M(x(e)),w(`candidates`)}finally{ke(!1),A(!1)}},J=ue({onPicked:(0,_.useCallback)(async e=>{A(!0),M(null);try{E(await me(e)),w(`consent`)}catch(e){M(x(e)),w(`intro`)}finally{A(!1)}},[])});(0,_.useEffect)(()=>{let e=!1;return ie().then(async({enabled:t,state:n})=>{if(!e){if(!t){v(`/chat`,{replace:!0});return}if(!S&&n.activeRunId)try{let t=await u(n.activeRunId);e||q(t);return}catch{}e||w(`intro`)}}).catch(t=>{e||(M(x(t)),w(`intro`))}),()=>{e=!0}},[q,v,S]),(0,_.useEffect)(()=>{if(!D||C!==`running`||Oe)return;let e=!1,t=async()=>{try{let t=await u(D.id);e||q(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===D.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[q,Oe,C,D]);let Fe=async()=>{A(!0);try{await fe()}finally{v(`/chat`,{replace:!0})}},Ie=async()=>{if(T){A(!0),M(null),U([]),G({current:0,total:0});try{await ge(T.canonicalRootPath);let e=await le(T.canonicalRootPath);q(e),g.getState().scanPersonalContext(e.id)}catch(e){M(x(e)),w(`consent`)}finally{A(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;v(`/chat/${encodeURIComponent(e)}${n}`)},Le=e=>{O(e),we(!1),N(!1),L(!1),z(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?w(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?w(`error`):w(`running`)},Re=async()=>{D&&(K.current=!0,q(await ne(D.id)))},X=async(t,n)=>{if(!D)return;await se(D.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(D.sessionKey,r)},ze=async()=>{if(D){A(!0),M(null);try{let e=D.result?.profileCandidates??[],t=e.length>0?await ae(D.id,e.map(e=>({id:e.id,status:R.has(e.id)?`accepted`:`rejected`}))):D;await Promise.all((t.result?.workThreads??[]).filter(e=>e.userStatus===`unreviewed`).map(e=>l(e.id,{decision:`confirmed`})));let n=await s(t.id,`confirmed`);O(n),Ne(n),w(`recommendation`)}catch(e){M(x(e))}finally{A(!1)}}},Z=async e=>{if(!(!D||!P.trim())){A(!0),M(null);try{let t=D.result?.workThreads?.find(e=>e.horizon===`current`)??D.result?.workThreads?.[0];t&&await l(t.id,{decision:`corrected`,correctedSummary:P.trim()});let n=await s(D.id,e,P.trim());O(n),Y(n.sessionKey,P.trim())}catch(e){M(x(e)),A(!1)}}},Be=async()=>{if(D){A(!0);try{Y((await s(D.id,`dismissed`)).sessionKey)}catch(e){M(x(e)),A(!1)}}},Ve=async()=>{let e=D?.result?.workThreads?.find(e=>e.horizon===`current`)??D?.result?.workThreads?.[0];if(e){A(!0),M(null);try{await de(e.id),we(!0)}catch(e){M(x(e))}finally{A(!1)}}},Q=D?.result?.suggestions.find(e=>e.id===D.result?.primarySuggestionId)??D?.result?.suggestions[0],He=D?.result?.suggestions.filter(e=>e.id!==Q?.id)??[],Ue=e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis,We=De.filter(e=>e?.status===`completed`),$=We.length>1?(0,b.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,b.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:t.analysisResults}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:We.map(e=>{let t=V.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,b.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===D?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Le(e),children:t},e.id)})})]}):null;return(0,b.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,b.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,b.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,b.jsx)(re,{className:`size-11`})}),C===`loading`?(0,b.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,b.jsx)(m,{className:`mx-auto h-8 w-64`}),(0,b.jsx)(m,{className:`mx-auto h-4 w-full max-w-lg`}),(0,b.jsx)(m,{className:`mx-auto size-4/5 max-w-md`}),(0,b.jsx)(m,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,C===`intro`?(0,b.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,b.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,b.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,b.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,b.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,b.jsxs)(d,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void Ae(),disabled:k||J.picking,children:[k?(0,b.jsx)(c,{className:`size-4 animate-spin`}):(0,b.jsx)(h,{className:`size-4`}),t.quickScan]}),(0,b.jsxs)(d,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:J.pick,disabled:k||J.picking,children:[J.picking?(0,b.jsx)(c,{className:`size-4 animate-spin`}):(0,b.jsx)(f,{className:`size-4`}),t.chooseFolderManually]}),(0,b.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,b.jsx)(h,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,b.jsx)(`span`,{children:t.quickScanNote})]}),j?(0,b.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:j}):null]}),(0,b.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Fe(),disabled:k,children:t.skip})]}):null,C===`candidates`?(0,b.jsxs)(`section`,{"aria-labelledby":`work-discovery-candidates-title`,children:[(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.candidatesTitle}),(0,b.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.candidatesSubtitle})]}),(0,b.jsx)(`div`,{className:`mt-7 space-y-2`,children:V.map((e,n)=>{let r=H.has(e.rootPath);return(0,b.jsxs)(`button`,{type:`button`,"aria-pressed":r,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${r?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>je(e.rootPath),children:[(0,b.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${r?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,b.jsx)(a,{className:`size-3.5`})}),(0,b.jsx)(f,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,b.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),n===0?(0,b.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:t.recommendedCandidate}):null]}),(0,b.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,b.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,b.jsx)(`span`,{children:e.projectKind===`coding`?t.codingProject:e.projectKind===`general`?t.generalProject:t.unknownProject}),e.branch?(0,b.jsx)(`span`,{children:t.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,b.jsx)(`span`,{children:t.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,b.jsxs)(`div`,{className:`mt-5 flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,b.jsx)(h,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,b.jsx)(`span`,{children:t.multiFolderPrivacyNote})]}),j?(0,b.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:j}):null,(0,b.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,b.jsxs)(d,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:k||H.size===0,onClick:()=>void Pe(),children:[k?(0,b.jsx)(c,{className:`mr-2 size-4 animate-spin`}):null,t.analyzeSelected.replace(`{{count}}`,String(H.size))]}),(0,b.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:k,onClick:J.pick,children:t.chooseFolderManually})]}),(0,b.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>w(`intro`),children:t.back})]}):null,C===`consent`&&T?(0,b.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,b.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,b.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,b.jsx)(f,{className:`size-5 shrink-0 text-accent-fg`}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:T.displayName}),(0,b.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:T.canonicalRootPath})]}),(0,b.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:T.projectKind===`coding`?t.codingProject:T.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,b.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,b.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:T.fingerprint.branch?t.branchValue.replace(`{{branch}}`,T.fingerprint.branch):t.noGitBranch})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,b.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(T.fingerprint.changedFileCount))})]}),T.fingerprint.recentAreas.length>0?(0,b.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,b.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,b.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:T.fingerprint.recentAreas.map(e=>(0,b.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,b.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,b.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,b.jsx)(he,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,b.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,b.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,b.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,b.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,b.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,b.jsx)(h,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,b.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:T.remoteModel?t.providerDisclosure.replace(`{{provider}}`,T.provider):t.localDisclosure})]})]})]}),j?(0,b.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:j}):null,(0,b.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,b.jsxs)(d,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:k,onClick:()=>void Ie(),children:[k?(0,b.jsx)(c,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,b.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:k,onClick:J.pick,children:t.changeFolder})]}),(0,b.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void Fe(),children:t.skip})]}):null,C===`running`&&D?(0,b.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,b.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle}),W.total>1?(0,b.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:t.analyzingFolderProgress.replace(`{{current}}`,String(W.current)).replace(`{{total}}`,String(W.total))}):null]}),(0,b.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:Se.map((e,n)=>{let r=Math.max(0,Se.indexOf(D.stage??`folder_structure`)),i=n<r,o=n===r;return(0,b.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,b.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,b.jsx)(a,{className:`size-4`}):o?(0,b.jsx)(c,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,b.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,b.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,b.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:D.rootPath}),(0,b.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,b.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>v(`/chat`),children:t.continueInBackground}),(0,b.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Re(),children:t.cancelAnalysis})]})]}):null,C===`recognition`&&D?.result?(0,b.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,b.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:D.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),$,(0,b.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,b.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:D.result.projectSummary}),(0,b.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:D.result.currentState}),!D.result.lowConfidence&&Q?.evidence.length?(0,b.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,b.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,b.jsx)(be,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,b.jsxs)(`span`,{children:[e.path?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),D.result.workThreads?.length?(0,b.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.workThreadsTitle}),(0,b.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.workThreadsSubtitle}),(0,b.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:D.result.workThreads.map(e=>(0,b.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?t.workThreadCurrent:e.horizon===`ongoing`?t.workThreadOngoing:t.workThreadLongTerm}),(0,b.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,b.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,D.result.profileCandidates?.length?(0,b.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.profileCandidatesTitle}),(0,b.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.profileCandidatesSubtitle}),(0,b.jsx)(`div`,{className:`mt-3 space-y-2`,children:D.result.profileCandidates.map(e=>(0,b.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,b.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:R.has(e.id),onChange:()=>z(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,b.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,D.result.lowConfidence?(0,b.jsxs)(`div`,{className:`mt-5`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:D.result.contextQuestion}),(0,b.jsx)(`textarea`,{value:P,onChange:e=>F(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,b.jsx)(d,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:k||!P.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,b.jsxs)(d,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:k,onClick:()=>void ze(),children:[k?(0,b.jsx)(c,{className:`size-4 animate-spin`}):(0,b.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,b.jsx)(d,{variant:`secondary`,className:`h-11 flex-1`,disabled:k,onClick:()=>N(e=>!e),children:t.notQuiteRight})]}),Ce?(0,b.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,b.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,b.jsx)(`textarea`,{id:`work-discovery-correction`,value:P,onChange:e=>F(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,b.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,b.jsx)(d,{variant:`ghost`,disabled:k||!P.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,b.jsx)(d,{variant:`primary`,disabled:k||!P.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),j?(0,b.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:j}):null,(0,b.jsx)(`button`,{type:`button`,disabled:k,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Be(),children:t.openConversation})]}):null,C===`recommendation`&&D?.result&&Q?(0,b.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,b.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),$,(0,b.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,b.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,b.jsx)(pe,{className:`size-5`})}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,b.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,b.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,b.jsx)(_e,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,b.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ue(Q.risk)})]}),(0,b.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,b.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,b.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,b.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,b.jsx)(d,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,b.jsx)(d,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),D.result.workThreads?.length?(0,b.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:(0,b.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,b.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:B?(0,b.jsx)(a,{className:`size-4`}):(0,b.jsx)(ce,{className:`size-4`})}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:B?t.focusTrialActive:t.focusTrialTitle}),(0,b.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:B?t.focusTrialActiveDescription:t.focusTrialDescription}),B?null:(0,b.jsxs)(d,{className:`mt-3 h-9`,variant:`secondary`,disabled:k,onClick:()=>void Ve(),children:[k?(0,b.jsx)(c,{className:`size-4 animate-spin`}):(0,b.jsx)(ce,{className:`size-4`}),t.activateFocusTrial]})]})]})}):null,He.length>0?(0,b.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>L(e=>!e),children:[t.otherDirections,(0,b.jsx)(ve,{className:`size-4 transition-transform ${I?`rotate-180`:``}`})]}),I?(0,b.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:He.map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,b.jsx)(pe,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,b.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,b.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,b.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(D.sessionKey),children:t.doSomethingElse}),(0,b.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{N(!0),w(`recognition`)},children:t.correctUnderstanding})]})]}):null,C===`error`&&D?(0,b.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,b.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,b.jsx)(p,{className:`size-5`})}),(0,b.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,b.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:D.errorMessage}),(0,b.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,b.jsx)(d,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void oe(D.id).then(q),children:t.retry}),(0,b.jsx)(d,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{O(null),E(null),w(`intro`)},children:t.chooseDifferent})]}),(0,b.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(D.sessionKey),children:t.openConversation})]}):null]}),J.hasNativePicker?null:(0,b.jsx)(te,{open:J.modalOpen,onOpenChange:J.setModalOpen,initialAbsolutePath:T?.canonicalRootPath,onConfirm:J.confirmPick,wd:n})]})}export{S as WorkDiscoveryPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as s}from"./cn-BQ_8x0bT.js";import{t as c}from"./messages-DDsiqdJS.js";import{n as ee}from"./locale-store-CPbGB_6l.js";import{$o as l,Fl as te,Hs as u,Oa as ne,Rl as re,Rs as ie,Sc as d,Ss as f,Su as p,Vc as m,a as ae,bo as h,et as g,f as oe,hc as _,jc as se,kl as v,l as ce,m as le,mc as ue,o as de,p as fe,ru as y,s as b,ts as x,u as S,uu as C,xl as pe,yt as me}from"./index-CHKe7nwC.js";var w=n(),T=e(t(),1),E=r();function he(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function D(e){return e?g(new Date(e)):``}function ge(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function _e(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function O(e){let t=(0,w.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,E.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,E.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ve(e){let t=(0,w.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,E.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,E.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,E.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:D(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,E.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function k(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function A(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=k(i),s=0;for(let e of k(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function ye(e,t,n){return[...n].sort((n,r)=>A(e,t,r)-A(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=o(),t=i(),n=c(ee(e=>e.language)).projectDetailPage.workItems,[r,g]=(0,T.useState)(null),[w,k]=(0,T.useState)(null),[j,M]=(0,T.useState)([]),[N,be]=(0,T.useState)([]),[P,F]=(0,T.useState)(``),[I,L]=(0,T.useState)(``),[R,z]=(0,T.useState)(!0),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(null),W=(0,T.useRef)(null),G=h(e=>e.setPageHeader),K=h(e=>e.clearPageHeader),q=(0,T.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,T.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([ce(e),S(e).catch(()=>({events:[]}))]);g(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([ne(t.item.projectId).catch(()=>null),me().catch(()=>[])]),a=ye(t.item,r,i);k(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,T.useEffect)(()=>{J()},[J]);let Y=(0,T.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await oe(r.id);g(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,T.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await ae(r.id);g(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,T.useCallback)(async e=>{M((await S(e).catch(()=>({events:[]}))).events)},[]),xe=(0,T.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await fe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});g(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,T.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await le(r.id,e);g(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,T.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await de(r.id,e.id);g(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,T.useCallback)(async e=>{if(r){U(null);try{await b(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,T.useMemo)(()=>r?N.filter(e=>A(r,w,e)>0).slice(0,3):[],[r,w,N]),$=(0,T.useMemo)(()=>(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(f,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,E.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,E.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,E.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,T.useLayoutEffect)(()=>(G({startExtra:(0,E.jsx)(a,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":w?.name?n.detail.backToProject.replace(`{{name}}`,w.name):n.detail.backToProjects,children:(0,E.jsx)(p,{className:`size-4`,"aria-hidden":!0})}),main:(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,E.jsx)(C,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,E.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,E.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,w?.name||r.projectId,` · `,n.updated,`: `,D(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,w?.name,q,G,n,w]),R?(0,E.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,E.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,E.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,E.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,E.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,E.jsx)(p,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,E.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,E.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,E.jsx)(C,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,E.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,E.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,E.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,he(r.status)),children:n.statuses[r.status]}),(0,E.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,E.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,E.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,E.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,E.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,E.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,E.jsx)(O,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,E.jsx)(O,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,E.jsx)(O,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,E.jsx)(O,{label:n.updated,value:D(r.updatedAt)})]})]}),(0,E.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,E.jsxs)(`section`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,E.jsx)(v,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,E.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,E.jsx)(ve,{events:j,t:n})]}),(0,E.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,E.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,E.jsx)(pe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,E.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,E.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,E.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,E.jsxs)(l,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,E.jsx)(x,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,E.jsx)(x,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,E.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,E.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,E.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,E.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,E.jsxs)(f,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,E.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,E.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,E.jsx)(se,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,E.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,E.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,E.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base p-2 text-sm`,children:[(0,E.jsx)(v,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,E.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,ge(e.size)]})]}),(0,E.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,E.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})}),(0,E.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,E.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,E.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,E.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,E.jsxs)(a,{to:_e(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,E.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,E.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,E.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,E.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,E.jsxs)(a,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,E.jsx)(y,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`min-w-0 truncate`,children:w?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a,u as o}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-CxySDn9d.js";import{n as ee}from"./locale-store-Dar-xqQr.js";import{$o as l,Fl as te,Hs as u,Oa as ne,Rl as re,Rs as ie,Sc as d,Ss as f,Su as p,Vc as m,a as ae,bo as h,et as g,f as oe,hc as _,jc as se,kl as v,l as ce,m as le,mc as ue,o as de,p as fe,ru as y,s as b,ts as x,u as S,uu as C,xl as pe,yt as me}from"./index-vq_cJZJC.js";var w=n(),T=e(t(),1),E=r();function he(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function D(e){return e?g(new Date(e)):``}function ge(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function _e(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function O(e){let t=(0,w.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,E.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,E.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ve(e){let t=(0,w.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,E.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,E.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,E.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:D(e.createdAt)})]})},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,E.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function k(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function A(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=k(i),s=0;for(let e of k(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function ye(e,t,n){return[...n].sort((n,r)=>A(e,t,r)-A(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=o(),t=i(),n=c(ee(e=>e.language)).projectDetailPage.workItems,[r,g]=(0,T.useState)(null),[w,k]=(0,T.useState)(null),[j,M]=(0,T.useState)([]),[N,be]=(0,T.useState)([]),[P,F]=(0,T.useState)(``),[I,L]=(0,T.useState)(``),[R,z]=(0,T.useState)(!0),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(null),W=(0,T.useRef)(null),G=h(e=>e.setPageHeader),K=h(e=>e.clearPageHeader),q=(0,T.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,T.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([ce(e),S(e).catch(()=>({events:[]}))]);g(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([ne(t.item.projectId).catch(()=>null),me().catch(()=>[])]),a=ye(t.item,r,i);k(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,T.useEffect)(()=>{J()},[J]);let Y=(0,T.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await oe(r.id);g(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,T.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await ae(r.id);g(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,T.useCallback)(async e=>{M((await S(e).catch(()=>({events:[]}))).events)},[]),xe=(0,T.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await fe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});g(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,T.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await le(r.id,e);g(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,T.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await de(r.id,e.id);g(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,T.useCallback)(async e=>{if(r){U(null);try{await b(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,T.useMemo)(()=>r?N.filter(e=>A(r,w,e)>0).slice(0,3):[],[r,w,N]),$=(0,T.useMemo)(()=>(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(f,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,E.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,E.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,E.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,T.useLayoutEffect)(()=>(G({startExtra:(0,E.jsx)(a,{to:q,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":w?.name?n.detail.backToProject.replace(`{{name}}`,w.name):n.detail.backToProjects,children:(0,E.jsx)(p,{className:`size-4`,"aria-hidden":!0})}),main:(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,E.jsx)(C,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,E.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,E.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,w?.name||r.projectId,` · `,n.updated,`: `,D(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,w?.name,q,G,n,w]),R?(0,E.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,E.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,E.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,E.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,E.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,E.jsx)(p,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,E.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:H||n.detail.notFound})]}):(0,E.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,E.jsx)(C,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,E.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,E.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,E.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,he(r.status)),children:n.statuses[r.status]}),(0,E.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,E.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,E.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,E.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,E.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,E.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,E.jsx)(O,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,E.jsx)(O,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,E.jsx)(O,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,E.jsx)(O,{label:n.updated,value:D(r.updatedAt)})]})]}),(0,E.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,E.jsxs)(`section`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,E.jsx)(v,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,E.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,E.jsx)(ve,{events:j,t:n})]}),(0,E.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,E.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,E.jsx)(pe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,E.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,E.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,E.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,E.jsxs)(l,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,E.jsx)(x,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,E.jsx)(x,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,E.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,E.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,E.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,E.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,E.jsxs)(f,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,E.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,E.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,E.jsx)(se,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,E.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,E.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,E.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,E.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base p-2 text-sm`,children:[(0,E.jsx)(v,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,E.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,ge(e.size)]})]}),(0,E.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:n.attachments.download,"aria-label":n.attachments.download,disabled:B,onClick:()=>void we(e),children:(0,E.jsx)(re,{className:`size-3.5`,"aria-hidden":!0})}),(0,E.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:n.attachments.remove,"aria-label":n.attachments.remove,disabled:B,onClick:()=>void Ce(e),children:(0,E.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,E.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,E.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,E.jsxs)(a,{to:_e(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,E.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,E.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,E.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,E.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,E.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,E.jsxs)(a,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,E.jsx)(y,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,E.jsx)(`span`,{className:`min-w-0 truncate`,children:w?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};