@xopcai/xopc 0.0.164 → 0.0.166

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 (95) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-RpxkQtQ3.js → agent-avatar-dicebear-Tr2hgn4j.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-CxpwxMPE.js → agents-DZ69tC4K.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-DLdjfMXB.js → app-management-settings-panel-D7Nrbhez.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-C89-uxkq.js → appearance-settings-DNNbABFj.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-k-tZbaRB.js → apps-page-0zXIeywq.js} +1 -1
  9. package/dist/gateway/static/root/assets/{archive-plugin-CqbH5geE.js → archive-plugin-CizqFy4G.js} +1 -1
  10. package/dist/gateway/static/root/assets/{attachment-load-CeU4Qiot.js → attachment-load-DU8KjTua.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automation-suggestion-card-WiOuqXq9.js → automation-suggestion-card-3pqyIveW.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-Bdn3dgC_.js → automations-page-DSz3xDsi.js} +1 -1
  13. package/dist/gateway/static/root/assets/{binary-plugins-C5TdzrhJ.js → binary-plugins-CipUnsOr.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-BjvWhphG.js → block-editor-XoEq6qiv.js} +3 -3
  15. package/dist/gateway/static/root/assets/{browser-settings-page-GsVTGfGs.js → browser-settings-page-COYvq3y5.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-DXmzQ3nk.js → browser-workflow-inputs-DRH995XI.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-C1-ptRe4.js → browser-workflows-page-65edjhpz.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capabilities-settings-panel-6d4kVjzl.js → capabilities-settings-panel-LOQyfdsM.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-presets-api-C0pVlUyc.js → capability-presets-api-XL4h7dCK.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DCxy5Ls_.js → capability-presets-settings-panel-KPJFkt1h.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-Bg3P8k0f.js → channels-settings-D8nH0mve.js} +1 -1
  22. package/dist/gateway/static/root/assets/{connector-logo-CuI5w4qM.js → connector-logo-n4Hg41iD.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-6UR7yhIZ.js → connectors-page-jvRWZn3Y.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-BvG8vDXZ.js → desktop-pet-D4OzBOwm.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-CR__kZ8C.js → desktop-pet-settings-CDGezbaf.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-BblWMz3e.js → directory-picker-path-field-DmL4AUXQ.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-DHMPugDE.js → dreaming-settings-ClUcBKnd.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-ByVY1gZg.js → extension-debug-page-DsV_KUDM.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-DLCKKtbK.js → extension-page-DJv_G1jY.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-M-rhlFBC.js → extension-settings-page-DUAlJ4CU.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-DZHqhbXH.js → gateway-config-api-SVYgzqv7.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-CZswIehx.js → gateway-settings-YL6f2C_F.js} +1 -1
  33. package/dist/gateway/static/root/assets/{goal-create-dialog-TbyRfDas.js → goal-create-dialog-CJJe-4Co.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-detail-page-B-QBVOf2.js → goal-detail-page-Da9VMWRd.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goals-config-api-DMxG6f0N.js → goals-config-api-st_Itxa9.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-page-BGxki8BR.js → goals-page-B6pC7PYZ.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goals-settings-G-w1gCYD.js → goals-settings-BEZePZ5m.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-settings-Csb90R59.js → heartbeat-settings-DpeD9GQ9.js} +1 -1
  39. package/dist/gateway/static/root/assets/{index-CGwuxvzr.js → index-BhQMnKH1.js} +6 -6
  40. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C_Bl3YOr.js → keyboard-shortcuts-settings-fhssr2-J.js} +1 -1
  41. package/dist/gateway/static/root/assets/{local-app-workbench-page-BR2tBhO3.js → local-app-workbench-page-Ctia6lSG.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-apps-page-_8Rv-tSk.js → local-apps-page-DWF9rpWQ.js} +1 -1
  43. package/dist/gateway/static/root/assets/{logs-page-CwF0C_Z2.js → logs-page-D3gL6vHX.js} +1 -1
  44. package/dist/gateway/static/root/assets/{markdown-split-CZnZS6gq.js → markdown-split-BuduJ0Ev.js} +1 -1
  45. package/dist/gateway/static/root/assets/{media-plugins-C2XLYC6G.js → media-plugins-CLASZjhT.js} +1 -1
  46. package/dist/gateway/static/root/assets/{notes-page-BkuZxTFo.js → notes-page-ve3XiBDF.js} +1 -1
  47. package/dist/gateway/static/root/assets/{notes-workbench-CD4FADi7.js → notes-workbench-oHU532lp.js} +2 -2
  48. package/dist/gateway/static/root/assets/{page-tabs-DR2FGC4E.js → page-tabs-DU85jn98.js} +1 -1
  49. package/dist/gateway/static/root/assets/{preview-open-alternatives-B65O8wBL.js → preview-open-alternatives-CtchTuRQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{product-open-page-Cag-utLH.js → product-open-page-DFT6Fx6y.js} +1 -1
  51. package/dist/gateway/static/root/assets/{project-detail-page-COKtUblD.js → project-detail-page-Ceu0NoC1.js} +1 -1
  52. package/dist/gateway/static/root/assets/{projects-page-QYmqanBN.js → projects-page-CdpqOmO8.js} +1 -1
  53. package/dist/gateway/static/root/assets/{remote-access-hub-BU_gBU0f.js → remote-access-hub-D1NKLyiR.js} +1 -1
  54. package/dist/gateway/static/root/assets/{save-bar-controls-DCWpFnPc.js → save-bar-controls-CmcrHpMc.js} +1 -1
  55. package/dist/gateway/static/root/assets/{schedule-field-ClacZdvE.js → schedule-field-DmIkP6JV.js} +1 -1
  56. package/dist/gateway/static/root/assets/{schema-form-BVlbEipU.js → schema-form-Dkk9blN0.js} +1 -1
  57. package/dist/gateway/static/root/assets/{sessions-page-u-Pjbzfm.js → sessions-page-CMj_JaOk.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-advanced-gate-DR9Q2ZyF.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-form-section-GSNlQWSW.js → settings-form-section-CuQzWvg5.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-loading-skeleton-08Ae5sB_.js → settings-loading-skeleton-C5FNbyej.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-BseJD4I-.js → settings-page-a-A2yTGE.js} +1 -1
  62. package/dist/gateway/static/root/assets/{settings-page-layout-bSliH-Y3.js → settings-page-layout-MuXpamWD.js} +1 -1
  63. package/dist/gateway/static/root/assets/{setup-status-panel-CGRhJVlt.js → setup-status-panel-BUdh8FKY.js} +1 -1
  64. package/dist/gateway/static/root/assets/{share-preview-page-C114OpTx.js → share-preview-page-BfzzmTgg.js} +1 -1
  65. package/dist/gateway/static/root/assets/{shares-settings-BRFpWFgI.js → shares-settings-8a9qnLF8.js} +1 -1
  66. package/dist/gateway/static/root/assets/{skill-reload-api-cVjU2GnN.js → skill-reload-api-da5gLCer.js} +1 -1
  67. package/dist/gateway/static/root/assets/{skills-page-CoMTjtRT.js → skills-page-CmHj-CKY.js} +1 -1
  68. package/dist/gateway/static/root/assets/{system-settings-panel-El8cDcTY.js → system-settings-panel-CyhRkWMi.js} +1 -1
  69. package/dist/gateway/static/root/assets/{time-picker-CU7hhD8T.js → time-picker-WEPp3HrB.js} +1 -1
  70. package/dist/gateway/static/root/assets/{typed-models-lib-kToxD7Rc.js → typed-models-lib-Bi1uoxFR.js} +1 -1
  71. package/dist/gateway/static/root/assets/{user-context-page-C0xYCSXB.js → user-context-page-BObEyiim.js} +1 -1
  72. package/dist/gateway/static/root/assets/{voice-api-key-field-DzEpwYaU.js → voice-api-key-field-Gvgodhec.js} +1 -1
  73. package/dist/gateway/static/root/assets/{work-discovery-page-DakZqR85.js → work-discovery-page-BHnjvGH1.js} +1 -1
  74. package/dist/gateway/static/root/assets/{work-item-detail-page-CswqPbTT.js → work-item-detail-page-CQ8ybkxx.js} +1 -1
  75. package/dist/gateway/static/root/assets/{work-page-DYRXEk8m.js → work-page-D_U_En23.js} +1 -1
  76. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BwSxyVMM.js → workflow-run-setup-panel-B-Sk6gFn.js} +1 -1
  77. package/dist/gateway/static/root/assets/{workflows-page-CiLSYGuN.js → workflows-page-DT0pzfkz.js} +1 -1
  78. package/dist/gateway/static/root/index.html +1 -1
  79. package/dist/package.js +1 -1
  80. package/dist/src/agent/embedded/run-turn.js +9 -2
  81. package/dist/src/agent/index.js +1 -1
  82. package/dist/src/cli/commands/channels.js +1 -1
  83. package/dist/src/cli/commands/connectors.js +1 -1
  84. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  85. package/dist/src/cli/commands/models.js +1 -1
  86. package/dist/src/cli/commands/onboard.js +1 -1
  87. package/dist/src/extensions/sdk/index.js +1 -1
  88. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  89. package/dist/src/gateway/service.js +2 -2
  90. package/dist/src/providers/index.js +5 -2
  91. package/dist/src/providers/model-ref.d.ts +6 -0
  92. package/dist/src/providers/model-ref.js +15 -0
  93. package/dist/src/providers/model-registry.js +5 -2
  94. package/package.json +1 -1
  95. package/dist/gateway/static/root/assets/settings-advanced-gate-1Yck1PKq.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"./check-DUBLcKHA.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-C96Zjb0V.js";import{n as l}from"./locale-store-C_ax27uc.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$s as d,$t as f,Cu as p,Dl as m,Ds as h,Go as g,Gs as _,Gt as v,Ht as y,Is as b,Jo as x,Jt as S,Ko as C,Ks as w,Kt as T,Nc as E,Ns as D,Ou as O,Qt as k,Tl as A,To as j,Uo as M,Ut as N,Vs as P,Wo as F,Wt as I,Xl as L,Xt as R,Yo as z,Ys as B,Yt as V,Zl as H,Zo as U,Zt as W,_u as G,an as ee,cn as te,cs as K,en as ne,fl as re,fn as ie,fu as ae,hn as oe,in as se,lc as q,ln as ce,mn as le,ms as J,nn as ue,on as de,os as fe,pc as pe,ps as me,qo as he,qt as ge,rn as _e,ro as ve,sn as ye,tn as be,tr as xe,un as Se,uu as Ce,vt as we,zc as Te}from"./index-CGwuxvzr.js";import{t as Ee}from"./page-tabs-DR2FGC4E.js";import{t as De}from"./time-picker-CU7hhD8T.js";import{t as Oe}from"./connector-logo-CuI5w4qM.js";var Y=n(),X=e(t(),1),Z=r();function ke(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=()=>le.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=c);let[l,u]=(0,X.useState)(c),d;t[2]===n.timezone?d=t[3]:(d=()=>!!n.timezone&&!le.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=d);let[f,p]=(0,X.useState)(d),m;t[4]===n.pronouns?m=t[5]:(m=()=>!!n.pronouns&&!ie.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=m);let[g,_]=(0,X.useState)(m),v;bb0:{if(f){v=`__custom__`;break bb0}v=le.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),ie.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)(K,{value:``,children:i.pronounsPlaceholder}),t[28]=i.pronounsPlaceholder,t[29]=j);let M;t[30]===C?M=t[31]:(M=ie.map(e=>(0,Z.jsx)(K,{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)(K,{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)(fe,{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__`){p(!0);return}p(!1),u(``),x({timezone:e.target.value})},t[55]=x,t[56]=z);let B;t[57]===C?B=t[58]:(B=le.map(e=>(0,Z.jsx)(K,{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)(K,{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)(fe,{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`,h.press),t[67]=U):U=t[67];let W;t[68]===x?W=t[69]:(W=()=>{let e=oe();if(!e)return;let t=le.some(t=>t.value===e);p(!t),u(t?``:e),x({timezone:e})},t[68]=x,t[69]=W);let G;t[70]!==i.timezoneDetect||t[71]!==W?(G=(0,Z.jsx)(`button`,{type:`button`,className:U,onClick:W,children:i.timezoneDetect}),t[70]=i.timezoneDetect,t[71]=W,t[72]=G):G=t[72];let ee;t[73]!==H||t[74]!==G?(ee=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[H,G]}),t[73]=H,t[74]=G,t[75]=ee):ee=t[75];let te;t[76]!==l||t[77]!==o||t[78]!==f||t[79]!==x?(te=f?(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]=f,t[79]=x,t[80]=te):te=t[80];let ne;t[81]!==L||t[82]!==ee||t[83]!==te?(ne=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[L,ee,te]}),t[81]=L,t[82]=ee,t[83]=te,t[84]=ne):ne=t[84];let re;t[85]===i.notes?re=t[86]:(re=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.notes}),t[85]=i.notes,t[86]=re);let ae;t[87]===o?ae=t[88]:(ae=s(o,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=o,t[88]=ae);let se;t[89]===x?se=t[90]:(se=e=>x({notes:e.target.value}),t[89]=x,t[90]=se);let q;t[91]!==i.notesPlaceholder||t[92]!==ae||t[93]!==se||t[94]!==n.notes?(q=(0,Z.jsx)(`textarea`,{className:ae,value:n.notes,onChange:se,placeholder:i.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=i.notesPlaceholder,t[92]=ae,t[93]=se,t[94]=n.notes,t[95]=q):q=t[95];let ce;t[96]!==re||t[97]!==q?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[re,q]}),t[96]=re,t[97]=q,t[98]=ce):ce=t[98];let J;return t[99]!==D||t[100]!==I||t[101]!==ne||t[102]!==ce?(J=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[D,I,ne,ce]}),t[99]=D,t[100]=I,t[101]=ne,t[102]=ce,t[103]=J):J=t[103],J}var Ae={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function je(e){if(e.branding?.logoUrl)return e.branding;let t=Ae[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}function Me(e){let t=(0,Y.c)(57),{open:n,t:r,onOpenChange:i,onNavigate:a}=e,o;t[0]!==r.helpLearningBody||t[1]!==r.helpLearningTitle?(o={icon:p,title:r.helpLearningTitle,body:r.helpLearningBody},t[0]=r.helpLearningBody,t[1]=r.helpLearningTitle,t[2]=o):o=t[2];let c;t[3]!==r.helpSharingBody||t[4]!==r.helpSharingTitle?(c={icon:P,title:r.helpSharingTitle,body:r.helpSharingBody},t[3]=r.helpSharingBody,t[4]=r.helpSharingTitle,t[5]=c):c=t[5];let l;t[6]!==r.helpSourcesBody||t[7]!==r.helpSourcesTitle?(l={icon:H,title:r.helpSourcesTitle,body:r.helpSourcesBody},t[6]=r.helpSourcesBody,t[7]=r.helpSourcesTitle,t[8]=l):l=t[8];let u;t[9]!==r.helpControlBody||t[10]!==r.helpControlTitle?(u={icon:pe,title:r.helpControlTitle,body:r.helpControlBody},t[9]=r.helpControlBody,t[10]=r.helpControlTitle,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==c||t[14]!==l||t[15]!==u?(d=[o,c,l,u],t[12]=o,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16];let f=d,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(he,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,J)}),t[17]=m):m=t[17];let h;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(h=s(`fixed right-3 top-1/2 flex h-[min(44rem,calc(100dvh-1.5rem))] w-[min(30rem,calc(100vw-1.5rem))] -translate-y-1/2 flex-col overflow-hidden`,me,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`),t[18]=h):h=t[18];let _;t[19]===r.helpTitle?_=t[20]:(_=(0,Z.jsx)(z,{className:`text-base font-semibold text-fg`,children:r.helpTitle}),t[19]=r.helpTitle,t[20]=_);let v;t[21]===r.helpSubtitle?v=t[22]:(v=(0,Z.jsx)(C,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.helpSubtitle}),t[21]=r.helpSubtitle,t[22]=v);let y;t[23]!==_||t[24]!==v?(y=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[_,v]}),t[23]=_,t[24]=v,t[25]=y):y=t[25];let S;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(b,{className:`size-4`,"aria-hidden":!0}),t[26]=S):S=t[26];let w;t[27]===r.close?w=t[28]:(w=(0,Z.jsx)(F,{asChild:!0,children:(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r.close,children:S})}),t[27]=r.close,t[28]=w);let T;t[29]!==y||t[30]!==w?(T=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[y,w]}),t[29]=y,t[30]=w,t[31]=T):T=t[31];let E;t[32]===f?E=t[33]:(E=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-2`,children:f.map(Ne)}),t[32]=f,t[33]=E);let O;t[34]!==a||t[35]!==i?(O=()=>{i(!1),a(`sources`)},t[34]=a,t[35]=i,t[36]=O):O=t[36];let k;t[37]!==r.tabs.sources||t[38]!==O?(k=(0,Z.jsx)(D,{type:`button`,variant:`ghost`,onClick:O,children:r.tabs.sources}),t[37]=r.tabs.sources,t[38]=O,t[39]=k):k=t[39];let A;t[40]!==a||t[41]!==i?(A=()=>{i(!1),a(`controls`)},t[40]=a,t[41]=i,t[42]=A):A=t[42];let j;t[43]!==r.openPrivacyControls||t[44]!==A?(j=(0,Z.jsx)(D,{type:`button`,variant:`secondary`,onClick:A,children:r.openPrivacyControls}),t[43]=r.openPrivacyControls,t[44]=A,t[45]=j):j=t[45];let N;t[46]!==k||t[47]!==j?(N=(0,Z.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge px-5 py-4`,children:[k,j]}),t[46]=k,t[47]=j,t[48]=N):N=t[48];let I;t[49]!==T||t[50]!==E||t[51]!==N?(I=(0,Z.jsxs)(x,{children:[m,(0,Z.jsxs)(g,{className:h,children:[T,E,N]})]}),t[49]=T,t[50]=E,t[51]=N,t[52]=I):I=t[52];let L;return t[53]!==i||t[54]!==n||t[55]!==I?(L=(0,Z.jsx)(M,{open:n,onOpenChange:i,children:I}),t[53]=i,t[54]=n,t[55]=I,t[56]=L):L=t[56],L}function Ne(e){let{icon:t,title:n,body:r}=e;return(0,Z.jsxs)(`section`,{className:`flex gap-3 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-muted text-fg-muted`,children:(0,Z.jsx)(t,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r})]})]},n)}function Pe(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),p,m;t[0]===n?(p=t[1],m=t[2]):(p=()=>{n&&d(!1)},m=[n],t[0]=n,t[1]=p,t[2]=m),(0,X.useEffect)(p,m);let h;t[3]!==i||t[4]!==a?(h=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=h):h=t[5];let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(he,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=_):_=t[6];let v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(b,{className:`size-4`,"aria-hidden":!0}),t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>d(!1),t[8]=y):y=t[8];let S=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,T;t[9]===S?T=t[10]:(T=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,S),t[9]=S,t[10]=T);let E;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(H,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=E):E=t[11];let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>d(!0),t[12]=O):O=t[12];let k=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,A;t[13]===k?A=t[14]:(A=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,k),t[13]=k,t[14]=A);let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=j):j=t[15];let N=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),P;t[16]===N?P=t[17]:(P=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:N}),t[16]=N,t[17]=P);let I;t[18]!==i||t[19]!==l.cancel?(I=(0,Z.jsx)(F,{asChild:!0,children:(0,Z.jsx)(D,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=I):I=t[20];let L=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,R;t[21]!==u||t[22]!==o?(R=()=>o(u),t[21]=u,t[22]=o,t[23]=R):R=t[23];let V;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[24]=V):V=t[24];let U=i?l.disconnecting:l.disconnectAction,W;t[25]!==i||t[26]!==L||t[27]!==R||t[28]!==U?(W=(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,className:L,disabled:i,onClick:R,children:[V,U]}),t[25]=i,t[26]=L,t[27]=R,t[28]=U,t[29]=W):W=t[29];let G;return t[30]!==I||t[31]!==W?(G=(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[I,W]}),t[30]=I,t[31]=W,t[32]=G):G=t[32],(0,Z.jsx)(M,{open:n!==null,onOpenChange:h,children:(0,Z.jsxs)(x,{children:[_,(0,Z.jsxs)(g,{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)(z,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,Z.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,Z.jsx)(F,{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:v})})]}),(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:y,className:T,children:[E,(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:O,disabled:!n?.derivedUnderstandingCount,className:A,children:[j,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),P]})]})]}),G]})]})})}var Fe=new Set([`overview`,`profile`,`understanding`,`sources`,`controls`]),Ie=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],Le=`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 Re(e,t){return e.replace(`{{count}}`,String(t))}function ze(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Be(e,t){let n=Date.parse(e);return Number.isFinite(n)?we(n,t):e}function Ve(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Fe.has(e)?e:`overview`}function He(){let e=(0,Y.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(ve,{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)(ve,{className:`h-64 rounded-2xl`}),(0,Z.jsx)(ve,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Ue(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function We(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),x=n.status!==`active`,S=x?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===S?C=t[1]:(C=s(`rounded-xl border p-3.5`,S),t[0]=S,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]!==x||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(Le,`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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{h(n.statement),p(!1)},children:i.cancel}),(0,Z.jsx)(D,{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)(q,{className:`size-3 text-accent`,"aria-hidden":!0}),Ue(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:Re(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,Z.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,Be(n.latestEvidenceAt,r))}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(D,{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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,Z.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,Z.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:v,onClick:()=>{if(g){_(null);return}y(!0),V(n.id).then(e=>_(e.history)).finally(()=>y(!1))},children:[(0,Z.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,Z.jsx)(B,{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:Be(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:Re(i.evidenceCount,n.evidenceCount)})]}),n.confidence===void 0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceConfidence}),(0,Z.jsxs)(`dd`,{className:`mt-0.5 text-fg-muted`,children:[Math.round(n.confidence*100),`%`]})]}),n.validTo?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceValidUntil}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Be(n.validTo,r)})]}):null,n.expiresAt?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceExpires}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Be(n.expiresAt,r)})]}):null]})]}),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:Be(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]=x,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let T;return t[16]!==C||t[17]!==w?(T=(0,Z.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=T):T=t[18],T}function Ge(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=je(n),t[12]=n,t[13]=g);let _;t[14]!==n.displayName||t[15]!==g?(_=(0,Z.jsx)(Oe,{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 O;t[38]!==n.access.context||t[39]!==i.sourceContext?(O=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]=O):O=t[40];let k;t[41]!==n.access.memory||t[42]!==i.sourceMemory?(k=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]=k):k=t[43];let A;t[44]!==n.access.read||t[45]!==i.sourceRead?(A=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]=A):A=t[46];let j;t[47]!==n.access.write||t[48]!==i.sourceWrite?(j=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]=j):j=t[49];let M;t[50]!==O||t[51]!==k||t[52]!==A||t[53]!==j?(M=(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[O,k,A,j]}),t[50]=O,t[51]=k,t[52]=A,t[53]=j,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}}`,Be(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,Z.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,Be(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)(D,{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 Ke(e){let t=(0,Y.c)(70),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:o,onUpdate:c,onDelete:l,onRollback:u}=e,[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(``),_=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,v;t[0]===_?v=t[1]:(v=s(`rounded-xl border p-4`,_),t[0]=_,t[1]=v);let y=i.playbookNames[n.id],b;t[2]===y?b=t[3]:(b=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:y}),t[2]=y,t[3]=b);let x;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(x=Re(i.playbookRuleCount,n.rules.filter(Ye).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=x):x=t[6];let S;t[7]===x?S=t[8]:(S=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[7]=x,t[8]=S);let C;t[9]!==b||t[10]!==S?(C=(0,Z.jsxs)(`div`,{children:[b,S]}),t[9]=b,t[10]=S,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)(D,{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 O;t[19]!==r||t[20]!==p||t[21]!==h||t[22]!==l||t[23]!==u||t[24]!==c||t[25]!==n.rules||t[26]!==i.cancel||t[27]!==i.deleteRule||t[28]!==i.disableRule||t[29]!==i.edit||t[30]!==i.enableRule||t[31]!==i.moveDown||t[32]!==i.moveUp||t[33]!==i.rollbackRule||t[34]!==i.ruleChannelContext||t[35]!==i.ruleContextAny||t[36]!==i.ruleHistory||t[37]!==i.ruleSupportContext||t[38]!==i.ruleSupportNeeds||t[39]!==i.save?(O=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:p===e.id?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{className:s(Le,`min-h-16 resize-y`),value:h,onChange:e=>g(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>m(null),children:i.cancel}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!h.trim(),onClick:()=>{c(e.id,{statement:h.trim()}),m(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 grid grid-cols-2 gap-1`,children:[(0,Z.jsxs)(`label`,{className:`grid gap-1 text-[10px] text-fg-subtle`,children:[i.ruleSupportContext,(0,Z.jsxs)(fe,{value:e.context.supportNeed??``,disabled:r,onChange:t=>c(e.id,{context:{supportNeed:t.target.value||null}}),children:[(0,Z.jsx)(K,{value:``,children:i.ruleContextAny}),[`listen`,`clarify`,`advise`,`act`,`unknown`].map(e=>(0,Z.jsx)(K,{value:e,children:i.ruleSupportNeeds[e]},e))]})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-[10px] text-fg-subtle`,children:[i.ruleChannelContext,(0,Z.jsxs)(fe,{value:e.context.channel??``,disabled:r,onChange:t=>c(e.id,{context:{channel:t.target.value||null}}),children:[(0,Z.jsx)(K,{value:``,children:i.ruleContextAny}),[`webchat`,`telegram`,`weixin`,`feishu`,`cli`].map(Je)]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,Z.jsx)(D,{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)(D,{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)(D,{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)(D,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{m(e.id),g(e.statement)},children:[(0,Z.jsx)(Te,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,Z.jsx)(B,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]}),e.versions.length>1?(0,Z.jsxs)(`details`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-fg-subtle`,children:i.ruleHistory}),(0,Z.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.versions.filter(qe).map(t=>(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2 text-[11px]`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-fg-muted`,children:t.statement}),(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2`,disabled:r,onClick:()=>u(e.id,t.id),children:i.rollbackRule})]},t.id))})]}):null]})},e.id)),t[19]=r,t[20]=p,t[21]=h,t[22]=l,t[23]=u,t[24]=c,t[25]=n.rules,t[26]=i.cancel,t[27]=i.deleteRule,t[28]=i.disableRule,t[29]=i.edit,t[30]=i.enableRule,t[31]=i.moveDown,t[32]=i.moveUp,t[33]=i.rollbackRule,t[34]=i.ruleChannelContext,t[35]=i.ruleContextAny,t[36]=i.ruleHistory,t[37]=i.ruleSupportContext,t[38]=i.ruleSupportNeeds,t[39]=i.save,t[40]=O):O=t[40];let k;t[41]===O?k=t[42]:(k=(0,Z.jsx)(`ul`,{className:`mt-3 space-y-2`,children:O}),t[41]=O,t[42]=k);let A;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>f(e.target.value),t[43]=A):A=t[43];let j;t[44]!==d||t[45]!==i.newRulePlaceholder?(j=(0,Z.jsx)(`input`,{className:Le,value:d,onChange:A,placeholder:i.newRulePlaceholder}),t[44]=d,t[45]=i.newRulePlaceholder,t[46]=j):j=t[46];let M;t[47]!==r||t[48]!==d?(M=r||!d.trim(),t[47]=r,t[48]=d,t[49]=M):M=t[49];let N;t[50]!==d||t[51]!==o?(N=()=>{o(d.trim()),f(``)},t[50]=d,t[51]=o,t[52]=N):N=t[52];let P;t[53]!==i.addRule||t[54]!==M||t[55]!==N?(P=(0,Z.jsx)(D,{type:`button`,variant:`secondary`,disabled:M,onClick:N,children:i.addRule}),t[53]=i.addRule,t[54]=M,t[55]=N,t[56]=P):P=t[56];let F;t[57]!==j||t[58]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[j,P]}),t[57]=j,t[58]=P,t[59]=F):F=t[59];let I=i.playbookRuleExamples[n.id],L;t[60]===I?L=t[61]:(L=(0,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-fg-subtle`,children:I}),t[60]=I,t[61]=L);let R;t[62]!==F||t[63]!==L?(R=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[F,L]}),t[62]=F,t[63]=L,t[64]=R):R=t[64];let z;return t[65]!==E||t[66]!==k||t[67]!==v||t[68]!==R?(z=(0,Z.jsxs)(`article`,{className:v,children:[E,k,R]}),t[65]=E,t[66]=k,t[67]=v,t[68]=R,t[69]=z):z=t[69],z}function qe(e){return!e.current}function Je(e){return(0,Z.jsx)(K,{value:e,children:e},e)}function Ye(e){return e.enabled}function Xe(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(Le,`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)(D,{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)(pe,{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 Ze(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,h]=i(),g=Ve(r.get(`tab`)),b=j(e=>e.setPageHeader),x=j(e=>e.clearPageHeader),{data:C,error:w,isLoading:A,mutate:M}=u(`/api/you`,R),[P,F]=(0,X.useState)(null),[z,B]=(0,X.useState)(!1),[V,ie]=(0,X.useState)(``),[q,le]=(0,X.useState)(`preference`),[J,me]=(0,X.useState)(null),[he,ve]=(0,X.useState)(!1),[we,Oe]=(0,X.useState)(null),[Y,Ae]=(0,X.useState)(!1),[je,Ne]=(0,X.useState)(``),[Fe,qe]=(0,X.useState)(!1),[Je,Ye]=(0,X.useState)(null),[Ze,Qe]=(0,X.useState)(!1),[$e,et]=(0,X.useState)(!1),[tt,nt]=(0,X.useState)(!1),[rt,it]=(0,X.useState)(null),[at,ot]=(0,X.useState)(!1),[st,ct]=(0,X.useState)(null),[lt,ut]=(0,X.useState)(null),[dt,ft]=(0,X.useState)(!1),[pt,mt]=(0,X.useState)(null),ht=(0,X.useRef)(null),gt=(0,X.useRef)(null),Q=C?.profile??{callName:``,pronouns:``,timezone:``,notes:``},_t=(0,X.useMemo)(()=>C?.understanding.filter(e=>e.status===`active`)??[],[C]),vt=(0,X.useMemo)(()=>C?.understanding.filter(e=>e.status!==`active`)??[],[C]),yt=(0,X.useMemo)(()=>new Map(Ie.map(e=>[e,_t.filter(t=>t.facet===e)])),[_t]),bt=Je??C?.controls??null,xt=C?.sources.filter(e=>e.installed&&e.enabled)??[],St=xt.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status));async function Ct(e){if(!(!C||tt)){nt(!0);try{let t=await ee(e);await M({...C,relationship:t.relationship},{revalidate:!1})}catch{U({type:`error`,title:t.supportModeTitle,message:t.saveError})}finally{nt(!1)}}}let $=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),h(n,{replace:!0})},wt=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,X.useLayoutEffect)(()=>(b({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:(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2.5 text-xs`,onClick:()=>ot(!0),children:[(0,Z.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),t.howItWorks]})}),()=>x()),[x,b,t.howItWorks,t.subtitle,t.title]),(0,X.useEffect)(()=>{!C||C.profile.callName||Ne(C.profileSetup.callNameSuggestion?.value??``)},[C,C?.profile.callName,C?.profileSetup.callNameSuggestion?.id]);async function Tt(e,n,r){F(e.id);try{let t=await de(e.id,{action:n,content:r});await M(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}),M()}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function Et(e,n){F(`consent:${e}`);try{await v(e,n),await M(),U({type:`success`,title:t.title,message:t.saved})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function Dt(){let e=V.trim();if(e){F(`understanding:new`);try{await I({content:e,kind:q}),ie(``),B(!1),await M(),U({type:`success`,title:t.understandingTitle,message:t.saved})}catch{U({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{F(null)}}}async function Ot(){if(vt.length){F(`understanding:batch`);try{await y(vt.map(e=>e.id),`confirm`),await M()}catch{U({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{F(null)}}}async function kt(e,n){F(`conflict:${e}`);try{await f(e,n),await M()}catch{U({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{F(null)}}async function At(e){F(`grant:${e}`);try{await ne(e),await M()}catch{U({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{F(null)}}async function jt(r,i){F(`insight:${r.id}`);try{let t=await _e(r.id,{action:i,uiLocale:e});await M(),i===`apply`&&t.href&&n(t.href)}catch{U({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{F(null)}}async function Mt(e){F(`playbook:${e.id}`);try{await ue(e.id,!e.enabled),await M()}catch{U({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function Nt(e,n){F(`playbook:${e}`);try{await n(),await M()}catch{U({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function Pt(){if(J){F(J.id);try{await W(J.id);let e=J.id;me(null),await M(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),M()}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}}async function Ft(){if(we){Ae(!0);try{let e=await te(we);ve(!1),Oe(null),await M(t=>t&&{...t,...e},{revalidate:!1})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{Ae(!1)}}}async function It(){let e=je.trim();if(!(!e||Fe)){qe(!0);try{let t=await te({callName:e,timezone:Q.timezone||oe()});await M(e=>e&&{...e,...t},{revalidate:!1})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}async function Lt(){if(!Fe){qe(!0);try{let e=await ce(`snooze`);await M(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}function Rt(){Oe(Q),ve(!0),$(`profile`),requestAnimationFrame(()=>ht.current?.scrollIntoView({behavior:`smooth`,block:`start`}))}function zt(e){le(e),B(!0),$(`understanding`)}async function Bt(){if(bt){Qe(!0);try{Ye(await ye(bt)),await M(),U({type:`success`,title:t.title,message:t.saved})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{Qe(!1)}}}async function Vt(e){if(!($e||e===C?.trust.defaultActionLevel)){et(!0);try{let t=await Se(e);await M(e=>e&&{...e,trust:t},{revalidate:!1})}catch{U({type:`error`,title:t.trustTitle,message:t.saveError})}finally{et(!1),it(null)}}}async function Ht(e){if(!(!lt?.instanceId||dt)){ft(!0);try{let n=await ge(lt.instanceId,e);ut(null),await M(),U({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{U({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{ft(!1)}}}async function Ut(){if(!pt){mt(`export`);try{let e=await S(),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{U({type:`error`,title:t.transferTitle,message:t.saveError})}finally{mt(null)}}}async function Wt(e){if(!(!e||pt)){mt(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await k(JSON.parse(await e.text()));await M(),$(`understanding`,`review`),U({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{U({type:`error`,title:t.transferTitle,message:t.importError})}finally{gt.current&&(gt.current.value=``),ct(null),mt(null)}}}function Gt(){ct(null),gt.current&&(gt.current.value=``)}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)(Ee,{items:[{id:`overview`,label:t.tabs.overview,icon:m},{id:`profile`,label:t.tabs.profile,icon:Ce},{id:`understanding`,label:t.tabs.understanding,icon:p,count:vt.length||void 0},{id:`sources`,label:t.tabs.sources,icon:H},{id:`controls`,label:t.tabs.controls,icon:pe}],activeTab:g,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})]}),A?(0,Z.jsx)(He,{}):w||!C?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,C&&g===`overview`?(0,Z.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Q.callName&&C.profileSetup.shouldPrompt?(0,Z.jsx)(Xe,{suggestion:C.profileSetup.callNameSuggestion,draft:je,busy:Fe,onDraftChange:Ne,onSave:()=>void It(),onLater:()=>void Lt(),t}):null,vt.length>0||St.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:[vt.length>0?(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[Re(t.reviewCount,vt.length),(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]}):null,St.length>0?(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[Re(t.sourceIssues,St.length),(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]}):null,Q.callName?null:(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:Rt,children:[t.completeProfile,(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,Z.jsx)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsxs)(`div`,{className:`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-3 text-left hover:bg-surface-hover`,onClick:()=>$(`understanding`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:_t.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 border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>$(`sources`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:xt.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 border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>$(`understanding`,`review`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:vt.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.waitingReview})]})]})}),(0,Z.jsxs)(`section`,{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-4`,children:[(0,Z.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(m,{className:`size-4 text-accent`,"aria-hidden":!0}),t.supportModeTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.supportModeHint})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:t.supportModeTitle}),(0,Z.jsx)(fe,{value:C.relationship.supportMode,disabled:tt,onChange:e=>void Ct({supportMode:e.target.value}),children:Object.entries(t.supportModes).map(([e,t])=>(0,Z.jsx)(K,{value:e,children:t},e))})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 border-t border-edge-subtle pt-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:C.relationship.proactiveEnabled,disabled:tt,onChange:e=>void Ct({proactiveEnabled:e.target.checked})}),t.proactiveEnabled]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietStart,(0,Z.jsx)(De,{value:C.relationship.quietStart??``,disabled:tt,allowEmpty:!0,clearLabel:t.clearTime,ariaLabel:t.quietStart,onChange:e=>void Ct({quietStart:e||null})})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietEnd,(0,Z.jsx)(De,{value:C.relationship.quietEnd??``,disabled:tt,allowEmpty:!0,clearLabel:t.clearTime,ariaLabel:t.quietEnd,onChange:e=>void Ct({quietEnd:e||null})})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.blockedTopics,(0,Z.jsx)(`input`,{className:Le,defaultValue:C.relationship.blockedTopics.join(`, `),disabled:tt,onBlur:e=>void Ct({blockedTopics:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]})]})]}),C.insights.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,Z.jsx)(ze,{children:t.confirmedContextBadge})]}),(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:C.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?Re(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void jt(e,`dismiss`),children:t.notNow}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void jt(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)(Ce,{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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`profile`),children:(0,Z.jsx)(G,{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)(p,{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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[_t.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)),_t.length===0?(0,Z.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]})]}):null,C&&g===`profile`?(0,Z.jsxs)(`div`,{id:`you-panel-profile`,role:`tabpanel`,"aria-labelledby":`you-tab-profile`,className:`space-y-5`,children:[(0,Z.jsxs)(`section`,{ref:ht,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)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(Ce,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,Z.jsx)(ze,{children:t.onlyYouEditBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.profileHint})]}),he?null:(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:Rt,children:[(0,Z.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),he&&we?(0,Z.jsxs)(`div`,{className:`mt-5`,children:[(0,Z.jsx)(ke,{value:we,onChange:Oe,language:e,inputClassName:Le,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)(D,{type:`button`,variant:`ghost`,onClick:()=>{ve(!1),Oe(null)},children:t.cancel}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:Y,onClick:()=>void Ft(),children:Y?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.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:()=>zt(`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:()=>zt(`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:()=>zt(`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)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,Z.jsx)(ze,{children:t.affectsAgentsBadge})]}),C.playbooks.length>0?(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:C.playbooks.map(e=>(0,Z.jsx)(Ke,{playbook:e,busy:P===`playbook:${e.id}`,t,onToggleGroup:()=>void Mt(e),onCreate:t=>void Nt(e.id,()=>N(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void Nt(e.id,()=>se(e.id,t,n)),onDelete:t=>void Nt(e.id,()=>T(e.id,t)),onRollback:(t,n)=>void Nt(e.id,()=>be(e.id,t,n))},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,C&&g===`understanding`?(0,Z.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(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})]}),z?null:(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:()=>B(!0),children:[(0,Z.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),z?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Z.jsx)(`textarea`,{className:s(Le,`min-h-24 resize-y`),value:V,onChange:e=>ie(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)(fe,{value:q,onChange:e=>le(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,Z.jsx)(K,{value:e,children:t},e))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(D,{type:`button`,variant:`ghost`,onClick:()=>{B(!1),ie(``)},children:t.cancel}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:!V.trim()||P===`understanding:new`,onClick:()=>void Dt(),children:t.add})]})]})]}):null]}),C.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:C.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:[Ue(r,t),` · `,Be(r.updatedAt,e)]})]}),(0,Z.jsx)(D,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:P===`conflict:${n.id}`,onClick:()=>void kt(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,C.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})]}),C.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)(D,{type:`button`,variant:`ghost`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`deny`),children:t.consentDeny}),(0,Z.jsx)(D,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`once`),children:t.consentOnce}),(0,Z.jsx)(D,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`session`),children:t.consentSession}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,vt.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)(D,{type:`button`,variant:`secondary`,disabled:P===`understanding:batch`,onClick:()=>void Ot(),children:t.reviewAll})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:vt.map(n=>(0,Z.jsx)(We,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void Tt(n,`confirm`),onReject:()=>void Tt(n,`reject`),onUpdate:e=>void Tt(n,`update`,e),onForget:()=>me(n)},n.id))})]}):_t.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,Ie.map(n=>{let r=yt.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)(We,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void Tt(n,`confirm`),onReject:()=>void Tt(n,`reject`),onUpdate:e=>void Tt(n,`update`,e),onForget:()=>me(n)},n.id))})]},n)}),C.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,C&&g===`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.jsx)(`div`,{children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,Z.jsx)(ze,{children:t.personalContextBadge})]})}),(0,Z.jsxs)(D,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]})]}),C.sourceRecommendations.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(d,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,Z.jsx)(ze,{children:t.permissionsBeforeConnectBadge})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:C.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:()=>wt({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:C.sources.map(n=>(0,Z.jsx)(Ge,{source:n,language:e,t,onConfigure:()=>wt(n),onDisconnect:()=>ut(n)},`${n.id}:${n.instanceId??`catalog`}`))}),C.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,C&&g===`controls`&&bt?(0,Z.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,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 text-sm text-fg-muted`,children:t.controlHint}),(0,Z.jsxs)(`div`,{className:`mt-4 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)(fe,{value:bt.mode,onChange:e=>Ye({...bt,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,Z.jsx)(K,{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)(fe,{value:bt.sensitiveWritePolicy,onChange:e=>Ye({...bt,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,Z.jsx)(K,{value:e,children:t},e))}),(0,Z.jsx)(`span`,{className:`font-normal leading-5 text-fg-subtle`,children:t.sensitiveOptionHints[bt.sensitiveWritePolicy]})]}),(0,Z.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:Ze,onClick:()=>void Bt(),children:Ze?t.saving:t.save})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.trustTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.trustHint}),(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.trust.levels.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":e===C.trust.defaultActionLevel,disabled:$e,onClick:()=>{e!==C.trust.defaultActionLevel&&(e===`auto`?it(e):Vt(e))},className:s(`rounded-xl border p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,e===C.trust.defaultActionLevel?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:t.trustLevels[e]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),e===C.trust.defaultActionLevel?(0,Z.jsx)(`span`,{className:`mt-2 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e))})]})]}),(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}),C.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:C.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?` · ${Be(n.expiresAt,e)}`:``]})]}),(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:P===`grant:${n.id}`,onClick:()=>void At(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.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,disabled:pt!==null,onClick:()=>void Ut(),children:[(0,Z.jsx)(L,{className:`size-4`,"aria-hidden":!0}),pt===`export`?t.exporting:t.exportAction]}),(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,disabled:pt!==null,onClick:()=>gt.current?.click(),children:[(0,Z.jsx)(_,{className:`size-4`,"aria-hidden":!0}),pt===`import`?t.importing:t.importAction]}),(0,Z.jsx)(`input`,{ref:gt,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>ct(e.target.files?.[0]??null)})]})]})]}):null,(0,Z.jsx)(xe,{open:J!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void Pt(),onCancel:()=>me(null)}),(0,Z.jsx)(xe,{open:rt===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void Vt(`auto`),onCancel:()=>it(null)}),(0,Z.jsx)(xe,{open:st!==null,title:t.importConfirmTitle,description:t.importConfirmBody.replace(`{{name}}`,st?.name??``),confirmLabel:t.importConfirmAction,cancelLabel:t.cancel,onConfirm:()=>{let e=st;ct(null),Wt(e)},onCancel:Gt}),(0,Z.jsx)(Pe,{source:lt,language:e,busy:dt,onOpenChange:e=>{e||ut(null)},onConfirm:e=>void Ht(e)}),(0,Z.jsx)(Me,{open:at,t,onOpenChange:ot,onNavigate:$})]})}export{Ze 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-C96Zjb0V.js";import{n as l}from"./locale-store-C_ax27uc.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$s as d,$t as f,Cu as p,Dl as m,Ds as h,Go as g,Gs as _,Gt as v,Ht as y,Is as b,Jo as x,Jt as S,Ko as C,Ks as w,Kt as T,Nc as E,Ns as D,Ou as O,Qt as k,Tl as A,To as j,Uo as M,Ut as N,Vs as P,Wo as F,Wt as I,Xl as L,Xt as R,Yo as z,Ys as B,Yt as V,Zl as H,Zo as U,Zt as W,_u as G,an as ee,cn as te,cs as K,en as ne,fl as re,fn as ie,fu as ae,hn as oe,in as se,lc as q,ln as ce,mn as le,ms as J,nn as ue,on as de,os as fe,pc as pe,ps as me,qo as he,qt as ge,rn as _e,ro as ve,sn as ye,tn as be,tr as xe,un as Se,uu as Ce,vt as we,zc as Te}from"./index-BhQMnKH1.js";import{t as Ee}from"./page-tabs-DU85jn98.js";import{t as De}from"./time-picker-WEPp3HrB.js";import{t as Oe}from"./connector-logo-n4Hg41iD.js";var Y=n(),X=e(t(),1),Z=r();function ke(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=()=>le.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=c);let[l,u]=(0,X.useState)(c),d;t[2]===n.timezone?d=t[3]:(d=()=>!!n.timezone&&!le.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=d);let[f,p]=(0,X.useState)(d),m;t[4]===n.pronouns?m=t[5]:(m=()=>!!n.pronouns&&!ie.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=m);let[g,_]=(0,X.useState)(m),v;bb0:{if(f){v=`__custom__`;break bb0}v=le.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),ie.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)(K,{value:``,children:i.pronounsPlaceholder}),t[28]=i.pronounsPlaceholder,t[29]=j);let M;t[30]===C?M=t[31]:(M=ie.map(e=>(0,Z.jsx)(K,{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)(K,{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)(fe,{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__`){p(!0);return}p(!1),u(``),x({timezone:e.target.value})},t[55]=x,t[56]=z);let B;t[57]===C?B=t[58]:(B=le.map(e=>(0,Z.jsx)(K,{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)(K,{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)(fe,{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`,h.press),t[67]=U):U=t[67];let W;t[68]===x?W=t[69]:(W=()=>{let e=oe();if(!e)return;let t=le.some(t=>t.value===e);p(!t),u(t?``:e),x({timezone:e})},t[68]=x,t[69]=W);let G;t[70]!==i.timezoneDetect||t[71]!==W?(G=(0,Z.jsx)(`button`,{type:`button`,className:U,onClick:W,children:i.timezoneDetect}),t[70]=i.timezoneDetect,t[71]=W,t[72]=G):G=t[72];let ee;t[73]!==H||t[74]!==G?(ee=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[H,G]}),t[73]=H,t[74]=G,t[75]=ee):ee=t[75];let te;t[76]!==l||t[77]!==o||t[78]!==f||t[79]!==x?(te=f?(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]=f,t[79]=x,t[80]=te):te=t[80];let ne;t[81]!==L||t[82]!==ee||t[83]!==te?(ne=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[L,ee,te]}),t[81]=L,t[82]=ee,t[83]=te,t[84]=ne):ne=t[84];let re;t[85]===i.notes?re=t[86]:(re=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:i.notes}),t[85]=i.notes,t[86]=re);let ae;t[87]===o?ae=t[88]:(ae=s(o,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=o,t[88]=ae);let se;t[89]===x?se=t[90]:(se=e=>x({notes:e.target.value}),t[89]=x,t[90]=se);let q;t[91]!==i.notesPlaceholder||t[92]!==ae||t[93]!==se||t[94]!==n.notes?(q=(0,Z.jsx)(`textarea`,{className:ae,value:n.notes,onChange:se,placeholder:i.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=i.notesPlaceholder,t[92]=ae,t[93]=se,t[94]=n.notes,t[95]=q):q=t[95];let ce;t[96]!==re||t[97]!==q?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[re,q]}),t[96]=re,t[97]=q,t[98]=ce):ce=t[98];let J;return t[99]!==D||t[100]!==I||t[101]!==ne||t[102]!==ce?(J=(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[D,I,ne,ce]}),t[99]=D,t[100]=I,t[101]=ne,t[102]=ce,t[103]=J):J=t[103],J}var Ae={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function je(e){if(e.branding?.logoUrl)return e.branding;let t=Ae[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}function Me(e){let t=(0,Y.c)(57),{open:n,t:r,onOpenChange:i,onNavigate:a}=e,o;t[0]!==r.helpLearningBody||t[1]!==r.helpLearningTitle?(o={icon:p,title:r.helpLearningTitle,body:r.helpLearningBody},t[0]=r.helpLearningBody,t[1]=r.helpLearningTitle,t[2]=o):o=t[2];let c;t[3]!==r.helpSharingBody||t[4]!==r.helpSharingTitle?(c={icon:P,title:r.helpSharingTitle,body:r.helpSharingBody},t[3]=r.helpSharingBody,t[4]=r.helpSharingTitle,t[5]=c):c=t[5];let l;t[6]!==r.helpSourcesBody||t[7]!==r.helpSourcesTitle?(l={icon:H,title:r.helpSourcesTitle,body:r.helpSourcesBody},t[6]=r.helpSourcesBody,t[7]=r.helpSourcesTitle,t[8]=l):l=t[8];let u;t[9]!==r.helpControlBody||t[10]!==r.helpControlTitle?(u={icon:pe,title:r.helpControlTitle,body:r.helpControlBody},t[9]=r.helpControlBody,t[10]=r.helpControlTitle,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==c||t[14]!==l||t[15]!==u?(d=[o,c,l,u],t[12]=o,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16];let f=d,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(he,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,J)}),t[17]=m):m=t[17];let h;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(h=s(`fixed right-3 top-1/2 flex h-[min(44rem,calc(100dvh-1.5rem))] w-[min(30rem,calc(100vw-1.5rem))] -translate-y-1/2 flex-col overflow-hidden`,me,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`),t[18]=h):h=t[18];let _;t[19]===r.helpTitle?_=t[20]:(_=(0,Z.jsx)(z,{className:`text-base font-semibold text-fg`,children:r.helpTitle}),t[19]=r.helpTitle,t[20]=_);let v;t[21]===r.helpSubtitle?v=t[22]:(v=(0,Z.jsx)(C,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.helpSubtitle}),t[21]=r.helpSubtitle,t[22]=v);let y;t[23]!==_||t[24]!==v?(y=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[_,v]}),t[23]=_,t[24]=v,t[25]=y):y=t[25];let S;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(b,{className:`size-4`,"aria-hidden":!0}),t[26]=S):S=t[26];let w;t[27]===r.close?w=t[28]:(w=(0,Z.jsx)(F,{asChild:!0,children:(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r.close,children:S})}),t[27]=r.close,t[28]=w);let T;t[29]!==y||t[30]!==w?(T=(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[y,w]}),t[29]=y,t[30]=w,t[31]=T):T=t[31];let E;t[32]===f?E=t[33]:(E=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-2`,children:f.map(Ne)}),t[32]=f,t[33]=E);let O;t[34]!==a||t[35]!==i?(O=()=>{i(!1),a(`sources`)},t[34]=a,t[35]=i,t[36]=O):O=t[36];let k;t[37]!==r.tabs.sources||t[38]!==O?(k=(0,Z.jsx)(D,{type:`button`,variant:`ghost`,onClick:O,children:r.tabs.sources}),t[37]=r.tabs.sources,t[38]=O,t[39]=k):k=t[39];let A;t[40]!==a||t[41]!==i?(A=()=>{i(!1),a(`controls`)},t[40]=a,t[41]=i,t[42]=A):A=t[42];let j;t[43]!==r.openPrivacyControls||t[44]!==A?(j=(0,Z.jsx)(D,{type:`button`,variant:`secondary`,onClick:A,children:r.openPrivacyControls}),t[43]=r.openPrivacyControls,t[44]=A,t[45]=j):j=t[45];let N;t[46]!==k||t[47]!==j?(N=(0,Z.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge px-5 py-4`,children:[k,j]}),t[46]=k,t[47]=j,t[48]=N):N=t[48];let I;t[49]!==T||t[50]!==E||t[51]!==N?(I=(0,Z.jsxs)(x,{children:[m,(0,Z.jsxs)(g,{className:h,children:[T,E,N]})]}),t[49]=T,t[50]=E,t[51]=N,t[52]=I):I=t[52];let L;return t[53]!==i||t[54]!==n||t[55]!==I?(L=(0,Z.jsx)(M,{open:n,onOpenChange:i,children:I}),t[53]=i,t[54]=n,t[55]=I,t[56]=L):L=t[56],L}function Ne(e){let{icon:t,title:n,body:r}=e;return(0,Z.jsxs)(`section`,{className:`flex gap-3 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-muted text-fg-muted`,children:(0,Z.jsx)(t,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r})]})]},n)}function Pe(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),p,m;t[0]===n?(p=t[1],m=t[2]):(p=()=>{n&&d(!1)},m=[n],t[0]=n,t[1]=p,t[2]=m),(0,X.useEffect)(p,m);let h;t[3]!==i||t[4]!==a?(h=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=h):h=t[5];let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(he,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=_):_=t[6];let v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(b,{className:`size-4`,"aria-hidden":!0}),t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>d(!1),t[8]=y):y=t[8];let S=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,T;t[9]===S?T=t[10]:(T=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,S),t[9]=S,t[10]=T);let E;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(H,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=E):E=t[11];let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>d(!0),t[12]=O):O=t[12];let k=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,A;t[13]===k?A=t[14]:(A=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,k),t[13]=k,t[14]=A);let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Z.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=j):j=t[15];let N=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),P;t[16]===N?P=t[17]:(P=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:N}),t[16]=N,t[17]=P);let I;t[18]!==i||t[19]!==l.cancel?(I=(0,Z.jsx)(F,{asChild:!0,children:(0,Z.jsx)(D,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=I):I=t[20];let L=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,R;t[21]!==u||t[22]!==o?(R=()=>o(u),t[21]=u,t[22]=o,t[23]=R):R=t[23];let V;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[24]=V):V=t[24];let U=i?l.disconnecting:l.disconnectAction,W;t[25]!==i||t[26]!==L||t[27]!==R||t[28]!==U?(W=(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,className:L,disabled:i,onClick:R,children:[V,U]}),t[25]=i,t[26]=L,t[27]=R,t[28]=U,t[29]=W):W=t[29];let G;return t[30]!==I||t[31]!==W?(G=(0,Z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[I,W]}),t[30]=I,t[31]=W,t[32]=G):G=t[32],(0,Z.jsx)(M,{open:n!==null,onOpenChange:h,children:(0,Z.jsxs)(x,{children:[_,(0,Z.jsxs)(g,{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)(z,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,Z.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,Z.jsx)(F,{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:v})})]}),(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:y,className:T,children:[E,(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:O,disabled:!n?.derivedUnderstandingCount,className:A,children:[j,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),P]})]})]}),G]})]})})}var Fe=new Set([`overview`,`profile`,`understanding`,`sources`,`controls`]),Ie=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],Le=`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 Re(e,t){return e.replace(`{{count}}`,String(t))}function ze(e){let t=(0,Y.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Be(e,t){let n=Date.parse(e);return Number.isFinite(n)?we(n,t):e}function Ve(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Fe.has(e)?e:`overview`}function He(){let e=(0,Y.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(ve,{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)(ve,{className:`h-64 rounded-2xl`}),(0,Z.jsx)(ve,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Ue(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function We(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),x=n.status!==`active`,S=x?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,C;t[0]===S?C=t[1]:(C=s(`rounded-xl border p-3.5`,S),t[0]=S,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]!==x||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(Le,`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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{h(n.statement),p(!1)},children:i.cancel}),(0,Z.jsx)(D,{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)(q,{className:`size-3 text-accent`,"aria-hidden":!0}),Ue(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:Re(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,Z.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,Be(n.latestEvidenceAt,r))}):null]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(D,{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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,Z.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,Z.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:v,onClick:()=>{if(g){_(null);return}y(!0),V(n.id).then(e=>_(e.history)).finally(()=>y(!1))},children:[(0,Z.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,Z.jsx)(B,{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:Be(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:Re(i.evidenceCount,n.evidenceCount)})]}),n.confidence===void 0?null:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceConfidence}),(0,Z.jsxs)(`dd`,{className:`mt-0.5 text-fg-muted`,children:[Math.round(n.confidence*100),`%`]})]}),n.validTo?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceValidUntil}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Be(n.validTo,r)})]}):null,n.expiresAt?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceExpires}),(0,Z.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Be(n.expiresAt,r)})]}):null]})]}),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:Be(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]=x,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=w):w=t[15];let T;return t[16]!==C||t[17]!==w?(T=(0,Z.jsx)(`article`,{className:C,children:w}),t[16]=C,t[17]=w,t[18]=T):T=t[18],T}function Ge(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=je(n),t[12]=n,t[13]=g);let _;t[14]!==n.displayName||t[15]!==g?(_=(0,Z.jsx)(Oe,{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 O;t[38]!==n.access.context||t[39]!==i.sourceContext?(O=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]=O):O=t[40];let k;t[41]!==n.access.memory||t[42]!==i.sourceMemory?(k=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]=k):k=t[43];let A;t[44]!==n.access.read||t[45]!==i.sourceRead?(A=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]=A):A=t[46];let j;t[47]!==n.access.write||t[48]!==i.sourceWrite?(j=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]=j):j=t[49];let M;t[50]!==O||t[51]!==k||t[52]!==A||t[53]!==j?(M=(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[O,k,A,j]}),t[50]=O,t[51]=k,t[52]=A,t[53]=j,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}}`,Be(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,Z.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,Be(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)(D,{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 Ke(e){let t=(0,Y.c)(70),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:o,onUpdate:c,onDelete:l,onRollback:u}=e,[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(null),[h,g]=(0,X.useState)(``),_=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,v;t[0]===_?v=t[1]:(v=s(`rounded-xl border p-4`,_),t[0]=_,t[1]=v);let y=i.playbookNames[n.id],b;t[2]===y?b=t[3]:(b=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:y}),t[2]=y,t[3]=b);let x;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(x=Re(i.playbookRuleCount,n.rules.filter(Ye).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=x):x=t[6];let S;t[7]===x?S=t[8]:(S=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[7]=x,t[8]=S);let C;t[9]!==b||t[10]!==S?(C=(0,Z.jsxs)(`div`,{children:[b,S]}),t[9]=b,t[10]=S,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)(D,{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 O;t[19]!==r||t[20]!==p||t[21]!==h||t[22]!==l||t[23]!==u||t[24]!==c||t[25]!==n.rules||t[26]!==i.cancel||t[27]!==i.deleteRule||t[28]!==i.disableRule||t[29]!==i.edit||t[30]!==i.enableRule||t[31]!==i.moveDown||t[32]!==i.moveUp||t[33]!==i.rollbackRule||t[34]!==i.ruleChannelContext||t[35]!==i.ruleContextAny||t[36]!==i.ruleHistory||t[37]!==i.ruleSupportContext||t[38]!==i.ruleSupportNeeds||t[39]!==i.save?(O=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:p===e.id?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`textarea`,{className:s(Le,`min-h-16 resize-y`),value:h,onChange:e=>g(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>m(null),children:i.cancel}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!h.trim(),onClick:()=>{c(e.id,{statement:h.trim()}),m(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 grid grid-cols-2 gap-1`,children:[(0,Z.jsxs)(`label`,{className:`grid gap-1 text-[10px] text-fg-subtle`,children:[i.ruleSupportContext,(0,Z.jsxs)(fe,{value:e.context.supportNeed??``,disabled:r,onChange:t=>c(e.id,{context:{supportNeed:t.target.value||null}}),children:[(0,Z.jsx)(K,{value:``,children:i.ruleContextAny}),[`listen`,`clarify`,`advise`,`act`,`unknown`].map(e=>(0,Z.jsx)(K,{value:e,children:i.ruleSupportNeeds[e]},e))]})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-[10px] text-fg-subtle`,children:[i.ruleChannelContext,(0,Z.jsxs)(fe,{value:e.context.channel??``,disabled:r,onChange:t=>c(e.id,{context:{channel:t.target.value||null}}),children:[(0,Z.jsx)(K,{value:``,children:i.ruleContextAny}),[`webchat`,`telegram`,`weixin`,`feishu`,`cli`].map(Je)]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,Z.jsx)(D,{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)(D,{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)(D,{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)(D,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{m(e.id),g(e.statement)},children:[(0,Z.jsx)(Te,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,Z.jsx)(B,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]}),e.versions.length>1?(0,Z.jsxs)(`details`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-fg-subtle`,children:i.ruleHistory}),(0,Z.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.versions.filter(qe).map(t=>(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2 text-[11px]`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-fg-muted`,children:t.statement}),(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2`,disabled:r,onClick:()=>u(e.id,t.id),children:i.rollbackRule})]},t.id))})]}):null]})},e.id)),t[19]=r,t[20]=p,t[21]=h,t[22]=l,t[23]=u,t[24]=c,t[25]=n.rules,t[26]=i.cancel,t[27]=i.deleteRule,t[28]=i.disableRule,t[29]=i.edit,t[30]=i.enableRule,t[31]=i.moveDown,t[32]=i.moveUp,t[33]=i.rollbackRule,t[34]=i.ruleChannelContext,t[35]=i.ruleContextAny,t[36]=i.ruleHistory,t[37]=i.ruleSupportContext,t[38]=i.ruleSupportNeeds,t[39]=i.save,t[40]=O):O=t[40];let k;t[41]===O?k=t[42]:(k=(0,Z.jsx)(`ul`,{className:`mt-3 space-y-2`,children:O}),t[41]=O,t[42]=k);let A;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>f(e.target.value),t[43]=A):A=t[43];let j;t[44]!==d||t[45]!==i.newRulePlaceholder?(j=(0,Z.jsx)(`input`,{className:Le,value:d,onChange:A,placeholder:i.newRulePlaceholder}),t[44]=d,t[45]=i.newRulePlaceholder,t[46]=j):j=t[46];let M;t[47]!==r||t[48]!==d?(M=r||!d.trim(),t[47]=r,t[48]=d,t[49]=M):M=t[49];let N;t[50]!==d||t[51]!==o?(N=()=>{o(d.trim()),f(``)},t[50]=d,t[51]=o,t[52]=N):N=t[52];let P;t[53]!==i.addRule||t[54]!==M||t[55]!==N?(P=(0,Z.jsx)(D,{type:`button`,variant:`secondary`,disabled:M,onClick:N,children:i.addRule}),t[53]=i.addRule,t[54]=M,t[55]=N,t[56]=P):P=t[56];let F;t[57]!==j||t[58]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[j,P]}),t[57]=j,t[58]=P,t[59]=F):F=t[59];let I=i.playbookRuleExamples[n.id],L;t[60]===I?L=t[61]:(L=(0,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-fg-subtle`,children:I}),t[60]=I,t[61]=L);let R;t[62]!==F||t[63]!==L?(R=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[F,L]}),t[62]=F,t[63]=L,t[64]=R):R=t[64];let z;return t[65]!==E||t[66]!==k||t[67]!==v||t[68]!==R?(z=(0,Z.jsxs)(`article`,{className:v,children:[E,k,R]}),t[65]=E,t[66]=k,t[67]=v,t[68]=R,t[69]=z):z=t[69],z}function qe(e){return!e.current}function Je(e){return(0,Z.jsx)(K,{value:e,children:e},e)}function Ye(e){return e.enabled}function Xe(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(Le,`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)(D,{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)(pe,{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 Ze(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,h]=i(),g=Ve(r.get(`tab`)),b=j(e=>e.setPageHeader),x=j(e=>e.clearPageHeader),{data:C,error:w,isLoading:A,mutate:M}=u(`/api/you`,R),[P,F]=(0,X.useState)(null),[z,B]=(0,X.useState)(!1),[V,ie]=(0,X.useState)(``),[q,le]=(0,X.useState)(`preference`),[J,me]=(0,X.useState)(null),[he,ve]=(0,X.useState)(!1),[we,Oe]=(0,X.useState)(null),[Y,Ae]=(0,X.useState)(!1),[je,Ne]=(0,X.useState)(``),[Fe,qe]=(0,X.useState)(!1),[Je,Ye]=(0,X.useState)(null),[Ze,Qe]=(0,X.useState)(!1),[$e,et]=(0,X.useState)(!1),[tt,nt]=(0,X.useState)(!1),[rt,it]=(0,X.useState)(null),[at,ot]=(0,X.useState)(!1),[st,ct]=(0,X.useState)(null),[lt,ut]=(0,X.useState)(null),[dt,ft]=(0,X.useState)(!1),[pt,mt]=(0,X.useState)(null),ht=(0,X.useRef)(null),gt=(0,X.useRef)(null),Q=C?.profile??{callName:``,pronouns:``,timezone:``,notes:``},_t=(0,X.useMemo)(()=>C?.understanding.filter(e=>e.status===`active`)??[],[C]),vt=(0,X.useMemo)(()=>C?.understanding.filter(e=>e.status!==`active`)??[],[C]),yt=(0,X.useMemo)(()=>new Map(Ie.map(e=>[e,_t.filter(t=>t.facet===e)])),[_t]),bt=Je??C?.controls??null,xt=C?.sources.filter(e=>e.installed&&e.enabled)??[],St=xt.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status));async function Ct(e){if(!(!C||tt)){nt(!0);try{let t=await ee(e);await M({...C,relationship:t.relationship},{revalidate:!1})}catch{U({type:`error`,title:t.supportModeTitle,message:t.saveError})}finally{nt(!1)}}}let $=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),h(n,{replace:!0})},wt=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,X.useLayoutEffect)(()=>(b({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:(0,Z.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2.5 text-xs`,onClick:()=>ot(!0),children:[(0,Z.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),t.howItWorks]})}),()=>x()),[x,b,t.howItWorks,t.subtitle,t.title]),(0,X.useEffect)(()=>{!C||C.profile.callName||Ne(C.profileSetup.callNameSuggestion?.value??``)},[C,C?.profile.callName,C?.profileSetup.callNameSuggestion?.id]);async function Tt(e,n,r){F(e.id);try{let t=await de(e.id,{action:n,content:r});await M(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}),M()}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function Et(e,n){F(`consent:${e}`);try{await v(e,n),await M(),U({type:`success`,title:t.title,message:t.saved})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}async function Dt(){let e=V.trim();if(e){F(`understanding:new`);try{await I({content:e,kind:q}),ie(``),B(!1),await M(),U({type:`success`,title:t.understandingTitle,message:t.saved})}catch{U({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{F(null)}}}async function Ot(){if(vt.length){F(`understanding:batch`);try{await y(vt.map(e=>e.id),`confirm`),await M()}catch{U({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{F(null)}}}async function kt(e,n){F(`conflict:${e}`);try{await f(e,n),await M()}catch{U({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{F(null)}}async function At(e){F(`grant:${e}`);try{await ne(e),await M()}catch{U({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{F(null)}}async function jt(r,i){F(`insight:${r.id}`);try{let t=await _e(r.id,{action:i,uiLocale:e});await M(),i===`apply`&&t.href&&n(t.href)}catch{U({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{F(null)}}async function Mt(e){F(`playbook:${e.id}`);try{await ue(e.id,!e.enabled),await M()}catch{U({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function Nt(e,n){F(`playbook:${e}`);try{await n(),await M()}catch{U({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{F(null)}}async function Pt(){if(J){F(J.id);try{await W(J.id);let e=J.id;me(null),await M(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),M()}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{F(null)}}}async function Ft(){if(we){Ae(!0);try{let e=await te(we);ve(!1),Oe(null),await M(t=>t&&{...t,...e},{revalidate:!1})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{Ae(!1)}}}async function It(){let e=je.trim();if(!(!e||Fe)){qe(!0);try{let t=await te({callName:e,timezone:Q.timezone||oe()});await M(e=>e&&{...e,...t},{revalidate:!1})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}async function Lt(){if(!Fe){qe(!0);try{let e=await ce(`snooze`);await M(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}function Rt(){Oe(Q),ve(!0),$(`profile`),requestAnimationFrame(()=>ht.current?.scrollIntoView({behavior:`smooth`,block:`start`}))}function zt(e){le(e),B(!0),$(`understanding`)}async function Bt(){if(bt){Qe(!0);try{Ye(await ye(bt)),await M(),U({type:`success`,title:t.title,message:t.saved})}catch{U({type:`error`,title:t.title,message:t.saveError})}finally{Qe(!1)}}}async function Vt(e){if(!($e||e===C?.trust.defaultActionLevel)){et(!0);try{let t=await Se(e);await M(e=>e&&{...e,trust:t},{revalidate:!1})}catch{U({type:`error`,title:t.trustTitle,message:t.saveError})}finally{et(!1),it(null)}}}async function Ht(e){if(!(!lt?.instanceId||dt)){ft(!0);try{let n=await ge(lt.instanceId,e);ut(null),await M(),U({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{U({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{ft(!1)}}}async function Ut(){if(!pt){mt(`export`);try{let e=await S(),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{U({type:`error`,title:t.transferTitle,message:t.saveError})}finally{mt(null)}}}async function Wt(e){if(!(!e||pt)){mt(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await k(JSON.parse(await e.text()));await M(),$(`understanding`,`review`),U({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{U({type:`error`,title:t.transferTitle,message:t.importError})}finally{gt.current&&(gt.current.value=``),ct(null),mt(null)}}}function Gt(){ct(null),gt.current&&(gt.current.value=``)}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)(Ee,{items:[{id:`overview`,label:t.tabs.overview,icon:m},{id:`profile`,label:t.tabs.profile,icon:Ce},{id:`understanding`,label:t.tabs.understanding,icon:p,count:vt.length||void 0},{id:`sources`,label:t.tabs.sources,icon:H},{id:`controls`,label:t.tabs.controls,icon:pe}],activeTab:g,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})]}),A?(0,Z.jsx)(He,{}):w||!C?(0,Z.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,C&&g===`overview`?(0,Z.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Q.callName&&C.profileSetup.shouldPrompt?(0,Z.jsx)(Xe,{suggestion:C.profileSetup.callNameSuggestion,draft:je,busy:Fe,onDraftChange:Ne,onSave:()=>void It(),onLater:()=>void Lt(),t}):null,vt.length>0||St.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:[vt.length>0?(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[Re(t.reviewCount,vt.length),(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]}):null,St.length>0?(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[Re(t.sourceIssues,St.length),(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]}):null,Q.callName?null:(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:Rt,children:[t.completeProfile,(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,Z.jsx)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsxs)(`div`,{className:`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-3 text-left hover:bg-surface-hover`,onClick:()=>$(`understanding`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:_t.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 border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>$(`sources`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:xt.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 border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>$(`understanding`,`review`),children:[(0,Z.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:vt.length}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.waitingReview})]})]})}),(0,Z.jsxs)(`section`,{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-4`,children:[(0,Z.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(m,{className:`size-4 text-accent`,"aria-hidden":!0}),t.supportModeTitle]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.supportModeHint})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:t.supportModeTitle}),(0,Z.jsx)(fe,{value:C.relationship.supportMode,disabled:tt,onChange:e=>void Ct({supportMode:e.target.value}),children:Object.entries(t.supportModes).map(([e,t])=>(0,Z.jsx)(K,{value:e,children:t},e))})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 border-t border-edge-subtle pt-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:C.relationship.proactiveEnabled,disabled:tt,onChange:e=>void Ct({proactiveEnabled:e.target.checked})}),t.proactiveEnabled]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietStart,(0,Z.jsx)(De,{value:C.relationship.quietStart??``,disabled:tt,allowEmpty:!0,clearLabel:t.clearTime,ariaLabel:t.quietStart,onChange:e=>void Ct({quietStart:e||null})})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietEnd,(0,Z.jsx)(De,{value:C.relationship.quietEnd??``,disabled:tt,allowEmpty:!0,clearLabel:t.clearTime,ariaLabel:t.quietEnd,onChange:e=>void Ct({quietEnd:e||null})})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.blockedTopics,(0,Z.jsx)(`input`,{className:Le,defaultValue:C.relationship.blockedTopics.join(`, `),disabled:tt,onBlur:e=>void Ct({blockedTopics:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]})]})]}),C.insights.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,Z.jsx)(ze,{children:t.confirmedContextBadge})]}),(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:C.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?Re(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void jt(e,`dismiss`),children:t.notNow}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:P===`insight:${e.id}`,onClick:()=>void jt(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)(Ce,{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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`profile`),children:(0,Z.jsx)(G,{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)(p,{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)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[_t.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)),_t.length===0?(0,Z.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]})]}):null,C&&g===`profile`?(0,Z.jsxs)(`div`,{id:`you-panel-profile`,role:`tabpanel`,"aria-labelledby":`you-tab-profile`,className:`space-y-5`,children:[(0,Z.jsxs)(`section`,{ref:ht,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)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(Ce,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,Z.jsx)(ze,{children:t.onlyYouEditBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.profileHint})]}),he?null:(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:Rt,children:[(0,Z.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),he&&we?(0,Z.jsxs)(`div`,{className:`mt-5`,children:[(0,Z.jsx)(ke,{value:we,onChange:Oe,language:e,inputClassName:Le,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)(D,{type:`button`,variant:`ghost`,onClick:()=>{ve(!1),Oe(null)},children:t.cancel}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:Y,onClick:()=>void Ft(),children:Y?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.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:()=>zt(`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:()=>zt(`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:()=>zt(`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)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,Z.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,Z.jsx)(ze,{children:t.affectsAgentsBadge})]}),C.playbooks.length>0?(0,Z.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:C.playbooks.map(e=>(0,Z.jsx)(Ke,{playbook:e,busy:P===`playbook:${e.id}`,t,onToggleGroup:()=>void Mt(e),onCreate:t=>void Nt(e.id,()=>N(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void Nt(e.id,()=>se(e.id,t,n)),onDelete:t=>void Nt(e.id,()=>T(e.id,t)),onRollback:(t,n)=>void Nt(e.id,()=>be(e.id,t,n))},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,C&&g===`understanding`?(0,Z.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(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})]}),z?null:(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,onClick:()=>B(!0),children:[(0,Z.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),z?(0,Z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Z.jsx)(`textarea`,{className:s(Le,`min-h-24 resize-y`),value:V,onChange:e=>ie(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)(fe,{value:q,onChange:e=>le(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,Z.jsx)(K,{value:e,children:t},e))})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(D,{type:`button`,variant:`ghost`,onClick:()=>{B(!1),ie(``)},children:t.cancel}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:!V.trim()||P===`understanding:new`,onClick:()=>void Dt(),children:t.add})]})]})]}):null]}),C.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:C.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:[Ue(r,t),` · `,Be(r.updatedAt,e)]})]}),(0,Z.jsx)(D,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:P===`conflict:${n.id}`,onClick:()=>void kt(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,C.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})]}),C.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)(D,{type:`button`,variant:`ghost`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`deny`),children:t.consentDeny}),(0,Z.jsx)(D,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`once`),children:t.consentOnce}),(0,Z.jsx)(D,{type:`button`,variant:`secondary`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`session`),children:t.consentSession}),(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:P===`consent:${e.id}`,onClick:()=>void Et(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,vt.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)(D,{type:`button`,variant:`secondary`,disabled:P===`understanding:batch`,onClick:()=>void Ot(),children:t.reviewAll})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:vt.map(n=>(0,Z.jsx)(We,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void Tt(n,`confirm`),onReject:()=>void Tt(n,`reject`),onUpdate:e=>void Tt(n,`update`,e),onForget:()=>me(n)},n.id))})]}):_t.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,Ie.map(n=>{let r=yt.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)(We,{item:n,language:e,t,busy:P===n.id,onConfirm:()=>void Tt(n,`confirm`),onReject:()=>void Tt(n,`reject`),onUpdate:e=>void Tt(n,`update`,e),onForget:()=>me(n)},n.id))})]},n)}),C.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,C&&g===`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.jsx)(`div`,{children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,Z.jsx)(ze,{children:t.personalContextBadge})]})}),(0,Z.jsxs)(D,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,Z.jsx)(G,{className:`size-4`,"aria-hidden":!0})]})]}),C.sourceRecommendations.length>0?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Z.jsx)(d,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,Z.jsx)(ze,{children:t.permissionsBeforeConnectBadge})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:C.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:()=>wt({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:C.sources.map(n=>(0,Z.jsx)(Ge,{source:n,language:e,t,onConfigure:()=>wt(n),onDisconnect:()=>ut(n)},`${n.id}:${n.instanceId??`catalog`}`))}),C.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,C&&g===`controls`&&bt?(0,Z.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,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 text-sm text-fg-muted`,children:t.controlHint}),(0,Z.jsxs)(`div`,{className:`mt-4 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)(fe,{value:bt.mode,onChange:e=>Ye({...bt,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,Z.jsx)(K,{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)(fe,{value:bt.sensitiveWritePolicy,onChange:e=>Ye({...bt,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,Z.jsx)(K,{value:e,children:t},e))}),(0,Z.jsx)(`span`,{className:`font-normal leading-5 text-fg-subtle`,children:t.sensitiveOptionHints[bt.sensitiveWritePolicy]})]}),(0,Z.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,Z.jsx)(D,{type:`button`,variant:`primary`,disabled:Ze,onClick:()=>void Bt(),children:Ze?t.saving:t.save})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.trustTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.trustHint}),(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:C.trust.levels.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":e===C.trust.defaultActionLevel,disabled:$e,onClick:()=>{e!==C.trust.defaultActionLevel&&(e===`auto`?it(e):Vt(e))},className:s(`rounded-xl border p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,e===C.trust.defaultActionLevel?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:t.trustLevels[e]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),e===C.trust.defaultActionLevel?(0,Z.jsx)(`span`,{className:`mt-2 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e))})]})]}),(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}),C.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:C.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?` · ${Be(n.expiresAt,e)}`:``]})]}),(0,Z.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:P===`grant:${n.id}`,onClick:()=>void At(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.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,disabled:pt!==null,onClick:()=>void Ut(),children:[(0,Z.jsx)(L,{className:`size-4`,"aria-hidden":!0}),pt===`export`?t.exporting:t.exportAction]}),(0,Z.jsxs)(D,{type:`button`,variant:`secondary`,disabled:pt!==null,onClick:()=>gt.current?.click(),children:[(0,Z.jsx)(_,{className:`size-4`,"aria-hidden":!0}),pt===`import`?t.importing:t.importAction]}),(0,Z.jsx)(`input`,{ref:gt,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>ct(e.target.files?.[0]??null)})]})]})]}):null,(0,Z.jsx)(xe,{open:J!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void Pt(),onCancel:()=>me(null)}),(0,Z.jsx)(xe,{open:rt===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void Vt(`auto`),onCancel:()=>it(null)}),(0,Z.jsx)(xe,{open:st!==null,title:t.importConfirmTitle,description:t.importConfirmBody.replace(`{{name}}`,st?.name??``),confirmLabel:t.importConfirmAction,cancelLabel:t.cancel,onConfirm:()=>{let e=st;ct(null),Wt(e)},onCancel:Gt}),(0,Z.jsx)(Pe,{source:lt,language:e,busy:dt,onOpenChange:e=>{e||ut(null)},onConfirm:e=>void Ht(e)}),(0,Z.jsx)(Me,{open:at,t,onOpenChange:ot,onNavigate:$})]})}export{Ze as UserContextPage};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{r as i,s as a}from"./locale-store-C_ax27uc.js";import{to as o,ws as s}from"./index-CGwuxvzr.js";e();var c=t();function l(){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 u(){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 d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function p(e,t,n){let r=d(e.providers)?e.providers:void 0,i=r&&d(r[t])?r[t]:void 0;return{...n,...i??{}}}function m(e){let t=l();if(!d(e))return t;let n=f(e.provider),r=p(e,`alibaba`,t.alibaba??{}),i=p(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(d(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=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function h(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function g(e){let t=u();if(!d(e))return t;let n=h(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(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:p(e,`alibaba`,t.alibaba??{}),openai:p(e,`openai`,t.openai??{}),edge:p(e,`edge`,t.edge??{}),minimax:p(e,`minimax`,t.minimax??{}),"tts-local-cli":p(e,`tts-local-cli`,i)}}function _(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 v(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 y(e){let t=d(e)?e:{},n=d(t.voice)?t.voice:{},r=d(n.input)?n.input:{},i=d(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:m(t.stt),tts:g(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 b(){return y((await a(i(`/api/config`))).payload?.config??{})}async function x(e){await a(i(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:_(e.stt),tts:v(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await a(i(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),o()}async function S(){let e=await a(i(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function C(){let e=await a(i(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function w(){let e=await a(i(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function T(){let e=await a(i(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function E(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function D(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function O(e){let t=await a(i(`/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 k(e){let t=await a(i(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}var A=n();function j(e){let t=(0,c.c)(15),{kind:n,providerId:i,fieldId:a,value:o,onChange:l,labels:u,placeholder:d,className:f}=e,p=d===void 0?`sk-...`:d,m;t[0]!==n||t[1]!==i?(m=()=>k({kind:n,provider:i}).then(M),t[0]=n,t[1]=i,t[2]=m):m=t[2];let h=m,g;t[3]===f?g=t[4]:(g=r(`flex min-w-0 flex-col gap-1.5`,f),t[3]=f,t[4]=g);let _;t[5]!==a||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==h||t[10]!==o?(_=(0,A.jsx)(s,{id:a,value:o,onChange:l,placeholder:p,labels:u,reveal:h,loadFailedLabel:u.loadFailed,maskedHelp:u.maskedHelp,notInConfigFile:u.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=u,t[7]=l,t[8]=p,t[9]=h,t[10]=o,t[11]=_):_=t[11];let v;return t[12]!==g||t[13]!==_?(v=(0,A.jsx)(`div`,{className:g,children:_}),t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function M(e){return e.apiKey??null}export{b as a,y as c,O as d,C as i,x as l,T as n,w as o,S as r,E as s,j as t,D as u};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{r as i,s as a}from"./locale-store-C_ax27uc.js";import{to as o,ws as s}from"./index-BhQMnKH1.js";e();var c=t();function l(){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 u(){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 d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function p(e,t,n){let r=d(e.providers)?e.providers:void 0,i=r&&d(r[t])?r[t]:void 0;return{...n,...i??{}}}function m(e){let t=l();if(!d(e))return t;let n=f(e.provider),r=p(e,`alibaba`,t.alibaba??{}),i=p(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(d(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=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function h(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function g(e){let t=u();if(!d(e))return t;let n=h(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(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:p(e,`alibaba`,t.alibaba??{}),openai:p(e,`openai`,t.openai??{}),edge:p(e,`edge`,t.edge??{}),minimax:p(e,`minimax`,t.minimax??{}),"tts-local-cli":p(e,`tts-local-cli`,i)}}function _(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 v(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 y(e){let t=d(e)?e:{},n=d(t.voice)?t.voice:{},r=d(n.input)?n.input:{},i=d(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:m(t.stt),tts:g(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 b(){return y((await a(i(`/api/config`))).payload?.config??{})}async function x(e){await a(i(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:_(e.stt),tts:v(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await a(i(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),o()}async function S(){let e=await a(i(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function C(){let e=await a(i(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function w(){let e=await a(i(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function T(){let e=await a(i(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function E(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function D(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function O(e){let t=await a(i(`/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 k(e){let t=await a(i(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}var A=n();function j(e){let t=(0,c.c)(15),{kind:n,providerId:i,fieldId:a,value:o,onChange:l,labels:u,placeholder:d,className:f}=e,p=d===void 0?`sk-...`:d,m;t[0]!==n||t[1]!==i?(m=()=>k({kind:n,provider:i}).then(M),t[0]=n,t[1]=i,t[2]=m):m=t[2];let h=m,g;t[3]===f?g=t[4]:(g=r(`flex min-w-0 flex-col gap-1.5`,f),t[3]=f,t[4]=g);let _;t[5]!==a||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==h||t[10]!==o?(_=(0,A.jsx)(s,{id:a,value:o,onChange:l,placeholder:p,labels:u,reveal:h,loadFailedLabel:u.loadFailed,maskedHelp:u.maskedHelp,notInConfigFile:u.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=u,t[7]=l,t[8]=p,t[9]=h,t[10]=o,t[11]=_):_=t[11];let v;return t[12]!==g||t[13]!==_?(v=(0,A.jsx)(`div`,{className:g,children:_}),t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function M(e){return e.apiKey??null}export{b as a,y as c,O as d,C as i,x as l,T as n,w as o,S as r,E as s,j as t,D as u};
@@ -1 +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-C96Zjb0V.js";import{n as ee}from"./locale-store-C_ax27uc.js";import{Ao as te,At as ne,Bl as re,Bo as s,Do as ie,Eo as c,Gl as ae,Ho as oe,Il as l,Io as se,Is as ce,Lo as le,Ml as ue,Mo as de,No as u,Ns as d,Oo as fe,Po as pe,Ps as me,Pt as he,Ro as ge,Vo as _e,_u as f,au as ve,ko as ye,pc as p,rl as m,ro as h,yu as be,zo as xe}from"./index-CGwuxvzr.js";var g=e(t(),1),_=new Set([`completed`,`failed`,`canceled`]);function Se(){return new Promise(e=>window.setTimeout(e,1200))}async function Ce(e,t){let n=[],r=t.wait??Se;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);!_.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 v=n(),we=[`folder_structure`,`recent_progress`,`next_steps`];function y(e){return e instanceof Error?e.message:String(e)}function b(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,_=i(),[Se]=r(),b=Se.get(`new`)===`1`,[x,S]=(0,g.useState)(`loading`),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(null),[Te,j]=(0,g.useState)(!1),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(!1),[I,L]=(0,g.useState)(()=>new Set),[R,z]=(0,g.useState)(!1),[B,Ee]=(0,g.useState)([]),[V,De]=(0,g.useState)(()=>new Set),[Oe,H]=(0,g.useState)([]),[ke,Ae]=(0,g.useState)(!1),[U,W]=(0,g.useState)({current:0,total:0}),G=(0,g.useRef)(!1),K=(0,g.useCallback)(e=>{c.getState().updateDirectoryRun(e),E(e),e.status===`completed`?(L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),S(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?S(`error`):S(`running`)},[]),je=async()=>{O(!0),A(null);try{let e=await ye();if(!e.length){A(t.noCandidates);return}Ee(e),De(new Set([e[0].rootPath])),S(`candidates`)}catch(e){A(y(e))}finally{O(!1)}},Me=e=>{De(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ne=(0,g.useCallback)((e,t,n)=>{c.getState().updateDirectoryRun(e),E(e),W({current:t+1,total:n}),H(n=>{let r=[...n];return r[t]=e,r}),S(`running`)},[]),Pe=(0,g.useCallback)(e=>{H(t=>t.map(t=>t?.id===e.id?e:t))},[]),Fe=async()=>{let e=B.filter(e=>V.has(e.rootPath));if(!e.length)return;O(!0),A(null),H([]),W({current:1,total:e.length}),Ae(!0),G.current=!1;let n=!1;try{let r=await Ce(e,{grantDirectory:pe,startRun:xe,fetchRun:u,shouldStop:()=>G.current,onRun:(e,t,r)=>{Ne(e,t,r),n||(n=!0,c.getState().scanPersonalContext(e.id))},onError:(n,r,i)=>{W({current:i+1,total:e.length}),A(t.folderAnalysisFailed.replace(`{{folder}}`,r.displayName).replace(`{{error}}`,y(n)))}});if(G.current)return;let i=r.find(e=>e.status===`completed`)??r.at(-1);i?K(i):S(`candidates`)}catch(e){A(y(e)),S(`candidates`)}finally{Ae(!1),O(!1)}},q=he({onPicked:(0,g.useCallback)(async e=>{O(!0),A(null);try{w(await se(e)),S(`consent`)}catch(e){A(y(e)),S(`intro`)}finally{O(!1)}},[])});(0,g.useEffect)(()=>{let e=!1;return de().then(async({enabled:t,state:n})=>{if(!e){if(!t){_(`/chat`,{replace:!0});return}if(!b&&n.activeRunId)try{let t=await u(n.activeRunId);e||K(t);return}catch{}e||S(`intro`)}}).catch(t=>{e||(A(y(t)),S(`intro`))}),()=>{e=!0}},[K,_,b]),(0,g.useEffect)(()=>{if(!T||x!==`running`||ke)return;let e=!1,t=async()=>{try{let t=await u(T.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===T.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)}},[K,ke,x,T]);let J=async()=>{O(!0);try{await te()}finally{_(`/chat`,{replace:!0})}},Ie=async()=>{if(C){O(!0),A(null),H([]),W({current:0,total:0});try{await pe(C.canonicalRootPath);let e=await xe(C.canonicalRootPath);K(e),c.getState().scanPersonalContext(e.id)}catch(e){A(y(e)),S(`consent`)}finally{O(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;_(`/chat/${encodeURIComponent(e)}${n}`)},Le=e=>{E(e),z(!1),j(!1),F(!1),L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?S(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?S(`error`):S(`running`)},Re=async()=>{T&&(G.current=!0,K(await fe(T.id)))},X=async(t,n)=>{if(!T)return;await ge(T.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(T.sessionKey,r)},ze=async()=>{if(T){O(!0),A(null);try{let e=T.result?.profileCandidates??[],t=e.length>0?await _e(T.id,e.map(e=>({id:e.id,status:I.has(e.id)?`accepted`:`rejected`}))):T;await Promise.all((t.result?.workThreads??[]).filter(e=>e.userStatus===`unreviewed`).map(e=>oe(e.id,{decision:`confirmed`})));let n=await s(t.id,`confirmed`);E(n),Pe(n),S(`recommendation`)}catch(e){A(y(e))}finally{O(!1)}}},Z=async e=>{if(!(!T||!M.trim())){O(!0),A(null);try{let t=T.result?.workThreads?.find(e=>e.horizon===`current`)??T.result?.workThreads?.[0];t&&await oe(t.id,{decision:`corrected`,correctedSummary:M.trim()});let n=await s(T.id,e,M.trim());E(n),Y(n.sessionKey,M.trim())}catch(e){A(y(e)),O(!1)}}},Be=async()=>{if(T){O(!0);try{Y((await s(T.id,`dismissed`)).sessionKey)}catch(e){A(y(e)),O(!1)}}},Ve=async()=>{let e=T?.result?.workThreads?.find(e=>e.horizon===`current`)??T?.result?.workThreads?.[0];if(e){O(!0),A(null);try{await ie(e.id),z(!0)}catch(e){A(y(e))}finally{O(!1)}}},Q=T?.result?.suggestions.find(e=>e.id===T.result?.primarySuggestionId)??T?.result?.suggestions[0],He=T?.result?.suggestions.filter(e=>e.id!==Q?.id)??[],Ue=e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis,We=Oe.filter(e=>e?.status===`completed`),$=We.length>1?(0,v.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,v.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:t.analysisResults}),(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:We.map(e=>{let t=B.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,v.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===T?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Le(e),children:t},e.id)})})]}):null;return(0,v.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,v.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,v.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,v.jsx)(me,{className:`size-11`})}),x===`loading`?(0,v.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,v.jsx)(h,{className:`mx-auto h-8 w-64`}),(0,v.jsx)(h,{className:`mx-auto h-4 w-full max-w-lg`}),(0,v.jsx)(h,{className:`mx-auto size-4/5 max-w-md`}),(0,v.jsx)(h,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,x===`intro`?(0,v.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,v.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,v.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,v.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,v.jsxs)(d,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void je(),disabled:D||q.picking,children:[D?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(p,{className:`size-4`}),t.quickScan]}),(0,v.jsxs)(d,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:q.pick,disabled:D||q.picking,children:[q.picking?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(l,{className:`size-4`}),t.chooseFolderManually]}),(0,v.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,v.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`span`,{children:t.quickScanNote})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null]}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:D,children:t.skip})]}):null,x===`candidates`?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-candidates-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.candidatesTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.candidatesSubtitle})]}),(0,v.jsx)(`div`,{className:`mt-7 space-y-2`,children:B.map((e,n)=>{let r=V.has(e.rootPath);return(0,v.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:()=>Me(e.rootPath),children:[(0,v.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,v.jsx)(a,{className:`size-3.5`})}),(0,v.jsx)(l,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,v.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),n===0?(0,v.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,v.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,v.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,v.jsx)(`span`,{children:e.projectKind===`coding`?t.codingProject:e.projectKind===`general`?t.generalProject:t.unknownProject}),e.branch?(0,v.jsx)(`span`,{children:t.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,v.jsx)(`span`,{children:t.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,v.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,v.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`span`,{children:t.multiFolderPrivacyNote})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(d,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D||V.size===0,onClick:()=>void Fe(),children:[D?(0,v.jsx)(m,{className:`mr-2 size-4 animate-spin`}):null,t.analyzeSelected.replace(`{{count}}`,String(V.size))]}),(0,v.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:q.pick,children:t.chooseFolderManually})]}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>S(`intro`),children:t.back})]}):null,x===`consent`&&C?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,v.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,v.jsx)(l,{className:`size-5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:C.displayName}),(0,v.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:C.canonicalRootPath})]}),(0,v.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:C.projectKind===`coding`?t.codingProject:C.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,v.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:C.fingerprint.branch?t.branchValue.replace(`{{branch}}`,C.fingerprint.branch):t.noGitBranch})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(C.fingerprint.changedFileCount))})]}),C.fingerprint.recentAreas.length>0?(0,v.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,v.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:C.fingerprint.recentAreas.map(e=>(0,v.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,v.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(ce,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:C.remoteModel?t.providerDisclosure.replace(`{{provider}}`,C.provider):t.localDisclosure})]})]})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(d,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D,onClick:()=>void Ie(),children:[D?(0,v.jsx)(m,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,v.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:q.pick,children:t.changeFolder})]}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,x===`running`&&T?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle}),U.total>1?(0,v.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:t.analyzingFolderProgress.replace(`{{current}}`,String(U.current)).replace(`{{total}}`,String(U.total))}):null]}),(0,v.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:we.map((e,n)=>{let r=Math.max(0,we.indexOf(T.stage??`folder_structure`)),i=n<r,o=n===r;return(0,v.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,v.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,v.jsx)(a,{className:`size-4`}):o?(0,v.jsx)(m,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,v.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,v.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:T.rootPath}),(0,v.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,v.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>_(`/chat`),children:t.continueInBackground}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Re(),children:t.cancelAnalysis})]})]}):null,x===`recognition`&&T?.result?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,v.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:T.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),$,(0,v.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,v.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:T.result.projectSummary}),(0,v.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:T.result.currentState}),!T.result.lowConfidence&&Q?.evidence.length?(0,v.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,v.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,v.jsx)(ue,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`span`,{children:[e.path?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),T.result.workThreads?.length?(0,v.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.workThreadsTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.workThreadsSubtitle}),(0,v.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:T.result.workThreads.map(e=>(0,v.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.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,v.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,v.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,T.result.profileCandidates?.length?(0,v.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.profileCandidatesTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.profileCandidatesSubtitle}),(0,v.jsx)(`div`,{className:`mt-3 space-y-2`,children:T.result.profileCandidates.map(e=>(0,v.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,v.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:I.has(e.id),onChange:()=>L(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,v.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,T.result.lowConfidence?(0,v.jsxs)(`div`,{className:`mt-5`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:T.result.contextQuestion}),(0,v.jsx)(`textarea`,{value:M,onChange:e=>N(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,v.jsx)(d,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:D||!M.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(d,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D,onClick:()=>void ze(),children:[D?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,v.jsx)(d,{variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:()=>j(e=>!e),children:t.notQuiteRight})]}),Te?(0,v.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,v.jsx)(`textarea`,{id:`work-discovery-correction`,value:M,onChange:e=>N(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,v.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,v.jsx)(d,{variant:`ghost`,disabled:D||!M.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,v.jsx)(d,{variant:`primary`,disabled:D||!M.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsx)(`button`,{type:`button`,disabled:D,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,x===`recommendation`&&T?.result&&Q?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,v.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),$,(0,v.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,v.jsx)(f,{className:`size-5`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,v.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,v.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,v.jsx)(ve,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,v.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ue(Q.risk)})]}),(0,v.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,v.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,v.jsx)(d,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,v.jsx)(d,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),T.result.workThreads?.length?(0,v.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:R?(0,v.jsx)(a,{className:`size-4`}):(0,v.jsx)(ae,{className:`size-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:R?t.focusTrialActive:t.focusTrialTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:R?t.focusTrialActiveDescription:t.focusTrialDescription}),R?null:(0,v.jsxs)(d,{className:`mt-3 h-9`,variant:`secondary`,disabled:D,onClick:()=>void Ve(),children:[D?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(ae,{className:`size-4`}),t.activateFocusTrial]})]})]})}):null,He.length>0?(0,v.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,v.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:()=>F(e=>!e),children:[t.otherDirections,(0,v.jsx)(be,{className:`size-4 transition-transform ${P?`rotate-180`:``}`})]}),P?(0,v.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,v.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,v.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,v.jsxs)(`span`,{children:[(0,v.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,v.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,v.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(T.sessionKey),children:t.doSomethingElse}),(0,v.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{j(!0),S(`recognition`)},children:t.correctUnderstanding})]})]}):null,x===`error`&&T?(0,v.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,v.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,v.jsx)(ce,{className:`size-5`})}),(0,v.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,v.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:T.errorMessage}),(0,v.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsx)(d,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void le(T.id).then(K),children:t.retry}),(0,v.jsx)(d,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{E(null),w(null),S(`intro`)},children:t.chooseDifferent})]}),(0,v.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(T.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,v.jsx)(ne,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:C?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{b as WorkDiscoveryPage};
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-C96Zjb0V.js";import{n as ee}from"./locale-store-C_ax27uc.js";import{Ao as te,At as ne,Bl as re,Bo as s,Do as ie,Eo as c,Gl as ae,Ho as oe,Il as l,Io as se,Is as ce,Lo as le,Ml as ue,Mo as de,No as u,Ns as d,Oo as fe,Po as pe,Ps as me,Pt as he,Ro as ge,Vo as _e,_u as f,au as ve,ko as ye,pc as p,rl as m,ro as h,yu as be,zo as xe}from"./index-BhQMnKH1.js";var g=e(t(),1),_=new Set([`completed`,`failed`,`canceled`]);function Se(){return new Promise(e=>window.setTimeout(e,1200))}async function Ce(e,t){let n=[],r=t.wait??Se;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);!_.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 v=n(),we=[`folder_structure`,`recent_progress`,`next_steps`];function y(e){return e instanceof Error?e.message:String(e)}function b(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,_=i(),[Se]=r(),b=Se.get(`new`)===`1`,[x,S]=(0,g.useState)(`loading`),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(null),[Te,j]=(0,g.useState)(!1),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(!1),[I,L]=(0,g.useState)(()=>new Set),[R,z]=(0,g.useState)(!1),[B,Ee]=(0,g.useState)([]),[V,De]=(0,g.useState)(()=>new Set),[Oe,H]=(0,g.useState)([]),[ke,Ae]=(0,g.useState)(!1),[U,W]=(0,g.useState)({current:0,total:0}),G=(0,g.useRef)(!1),K=(0,g.useCallback)(e=>{c.getState().updateDirectoryRun(e),E(e),e.status===`completed`?(L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),S(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?S(`error`):S(`running`)},[]),je=async()=>{O(!0),A(null);try{let e=await ye();if(!e.length){A(t.noCandidates);return}Ee(e),De(new Set([e[0].rootPath])),S(`candidates`)}catch(e){A(y(e))}finally{O(!1)}},Me=e=>{De(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ne=(0,g.useCallback)((e,t,n)=>{c.getState().updateDirectoryRun(e),E(e),W({current:t+1,total:n}),H(n=>{let r=[...n];return r[t]=e,r}),S(`running`)},[]),Pe=(0,g.useCallback)(e=>{H(t=>t.map(t=>t?.id===e.id?e:t))},[]),Fe=async()=>{let e=B.filter(e=>V.has(e.rootPath));if(!e.length)return;O(!0),A(null),H([]),W({current:1,total:e.length}),Ae(!0),G.current=!1;let n=!1;try{let r=await Ce(e,{grantDirectory:pe,startRun:xe,fetchRun:u,shouldStop:()=>G.current,onRun:(e,t,r)=>{Ne(e,t,r),n||(n=!0,c.getState().scanPersonalContext(e.id))},onError:(n,r,i)=>{W({current:i+1,total:e.length}),A(t.folderAnalysisFailed.replace(`{{folder}}`,r.displayName).replace(`{{error}}`,y(n)))}});if(G.current)return;let i=r.find(e=>e.status===`completed`)??r.at(-1);i?K(i):S(`candidates`)}catch(e){A(y(e)),S(`candidates`)}finally{Ae(!1),O(!1)}},q=he({onPicked:(0,g.useCallback)(async e=>{O(!0),A(null);try{w(await se(e)),S(`consent`)}catch(e){A(y(e)),S(`intro`)}finally{O(!1)}},[])});(0,g.useEffect)(()=>{let e=!1;return de().then(async({enabled:t,state:n})=>{if(!e){if(!t){_(`/chat`,{replace:!0});return}if(!b&&n.activeRunId)try{let t=await u(n.activeRunId);e||K(t);return}catch{}e||S(`intro`)}}).catch(t=>{e||(A(y(t)),S(`intro`))}),()=>{e=!0}},[K,_,b]),(0,g.useEffect)(()=>{if(!T||x!==`running`||ke)return;let e=!1,t=async()=>{try{let t=await u(T.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===T.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)}},[K,ke,x,T]);let J=async()=>{O(!0);try{await te()}finally{_(`/chat`,{replace:!0})}},Ie=async()=>{if(C){O(!0),A(null),H([]),W({current:0,total:0});try{await pe(C.canonicalRootPath);let e=await xe(C.canonicalRootPath);K(e),c.getState().scanPersonalContext(e.id)}catch(e){A(y(e)),S(`consent`)}finally{O(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;_(`/chat/${encodeURIComponent(e)}${n}`)},Le=e=>{E(e),z(!1),j(!1),F(!1),L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?S(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?S(`error`):S(`running`)},Re=async()=>{T&&(G.current=!0,K(await fe(T.id)))},X=async(t,n)=>{if(!T)return;await ge(T.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(T.sessionKey,r)},ze=async()=>{if(T){O(!0),A(null);try{let e=T.result?.profileCandidates??[],t=e.length>0?await _e(T.id,e.map(e=>({id:e.id,status:I.has(e.id)?`accepted`:`rejected`}))):T;await Promise.all((t.result?.workThreads??[]).filter(e=>e.userStatus===`unreviewed`).map(e=>oe(e.id,{decision:`confirmed`})));let n=await s(t.id,`confirmed`);E(n),Pe(n),S(`recommendation`)}catch(e){A(y(e))}finally{O(!1)}}},Z=async e=>{if(!(!T||!M.trim())){O(!0),A(null);try{let t=T.result?.workThreads?.find(e=>e.horizon===`current`)??T.result?.workThreads?.[0];t&&await oe(t.id,{decision:`corrected`,correctedSummary:M.trim()});let n=await s(T.id,e,M.trim());E(n),Y(n.sessionKey,M.trim())}catch(e){A(y(e)),O(!1)}}},Be=async()=>{if(T){O(!0);try{Y((await s(T.id,`dismissed`)).sessionKey)}catch(e){A(y(e)),O(!1)}}},Ve=async()=>{let e=T?.result?.workThreads?.find(e=>e.horizon===`current`)??T?.result?.workThreads?.[0];if(e){O(!0),A(null);try{await ie(e.id),z(!0)}catch(e){A(y(e))}finally{O(!1)}}},Q=T?.result?.suggestions.find(e=>e.id===T.result?.primarySuggestionId)??T?.result?.suggestions[0],He=T?.result?.suggestions.filter(e=>e.id!==Q?.id)??[],Ue=e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis,We=Oe.filter(e=>e?.status===`completed`),$=We.length>1?(0,v.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,v.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:t.analysisResults}),(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:We.map(e=>{let t=B.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,v.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===T?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Le(e),children:t},e.id)})})]}):null;return(0,v.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,v.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,v.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,v.jsx)(me,{className:`size-11`})}),x===`loading`?(0,v.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,v.jsx)(h,{className:`mx-auto h-8 w-64`}),(0,v.jsx)(h,{className:`mx-auto h-4 w-full max-w-lg`}),(0,v.jsx)(h,{className:`mx-auto size-4/5 max-w-md`}),(0,v.jsx)(h,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,x===`intro`?(0,v.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,v.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,v.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,v.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,v.jsxs)(d,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void je(),disabled:D||q.picking,children:[D?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(p,{className:`size-4`}),t.quickScan]}),(0,v.jsxs)(d,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:q.pick,disabled:D||q.picking,children:[q.picking?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(l,{className:`size-4`}),t.chooseFolderManually]}),(0,v.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,v.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`span`,{children:t.quickScanNote})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null]}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:D,children:t.skip})]}):null,x===`candidates`?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-candidates-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.candidatesTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.candidatesSubtitle})]}),(0,v.jsx)(`div`,{className:`mt-7 space-y-2`,children:B.map((e,n)=>{let r=V.has(e.rootPath);return(0,v.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:()=>Me(e.rootPath),children:[(0,v.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,v.jsx)(a,{className:`size-3.5`})}),(0,v.jsx)(l,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,v.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),n===0?(0,v.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,v.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,v.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,v.jsx)(`span`,{children:e.projectKind===`coding`?t.codingProject:e.projectKind===`general`?t.generalProject:t.unknownProject}),e.branch?(0,v.jsx)(`span`,{children:t.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,v.jsx)(`span`,{children:t.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,v.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,v.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`span`,{children:t.multiFolderPrivacyNote})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(d,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D||V.size===0,onClick:()=>void Fe(),children:[D?(0,v.jsx)(m,{className:`mr-2 size-4 animate-spin`}):null,t.analyzeSelected.replace(`{{count}}`,String(V.size))]}),(0,v.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:q.pick,children:t.chooseFolderManually})]}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>S(`intro`),children:t.back})]}):null,x===`consent`&&C?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,v.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,v.jsx)(l,{className:`size-5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:C.displayName}),(0,v.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:C.canonicalRootPath})]}),(0,v.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:C.projectKind===`coding`?t.codingProject:C.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,v.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:C.fingerprint.branch?t.branchValue.replace(`{{branch}}`,C.fingerprint.branch):t.noGitBranch})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(C.fingerprint.changedFileCount))})]}),C.fingerprint.recentAreas.length>0?(0,v.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,v.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:C.fingerprint.recentAreas.map(e=>(0,v.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,v.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(ce,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:C.remoteModel?t.providerDisclosure.replace(`{{provider}}`,C.provider):t.localDisclosure})]})]})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(d,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D,onClick:()=>void Ie(),children:[D?(0,v.jsx)(m,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,v.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:q.pick,children:t.changeFolder})]}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,x===`running`&&T?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle}),U.total>1?(0,v.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:t.analyzingFolderProgress.replace(`{{current}}`,String(U.current)).replace(`{{total}}`,String(U.total))}):null]}),(0,v.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:we.map((e,n)=>{let r=Math.max(0,we.indexOf(T.stage??`folder_structure`)),i=n<r,o=n===r;return(0,v.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,v.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,v.jsx)(a,{className:`size-4`}):o?(0,v.jsx)(m,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,v.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,v.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:T.rootPath}),(0,v.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,v.jsx)(d,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>_(`/chat`),children:t.continueInBackground}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Re(),children:t.cancelAnalysis})]})]}):null,x===`recognition`&&T?.result?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,v.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:T.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),$,(0,v.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,v.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:T.result.projectSummary}),(0,v.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:T.result.currentState}),!T.result.lowConfidence&&Q?.evidence.length?(0,v.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,v.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,v.jsx)(ue,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`span`,{children:[e.path?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),T.result.workThreads?.length?(0,v.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.workThreadsTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.workThreadsSubtitle}),(0,v.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:T.result.workThreads.map(e=>(0,v.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.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,v.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,v.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,T.result.profileCandidates?.length?(0,v.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.profileCandidatesTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.profileCandidatesSubtitle}),(0,v.jsx)(`div`,{className:`mt-3 space-y-2`,children:T.result.profileCandidates.map(e=>(0,v.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,v.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:I.has(e.id),onChange:()=>L(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,v.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,T.result.lowConfidence?(0,v.jsxs)(`div`,{className:`mt-5`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:T.result.contextQuestion}),(0,v.jsx)(`textarea`,{value:M,onChange:e=>N(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,v.jsx)(d,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:D||!M.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(d,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D,onClick:()=>void ze(),children:[D?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,v.jsx)(d,{variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:()=>j(e=>!e),children:t.notQuiteRight})]}),Te?(0,v.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,v.jsx)(`textarea`,{id:`work-discovery-correction`,value:M,onChange:e=>N(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,v.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,v.jsx)(d,{variant:`ghost`,disabled:D||!M.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,v.jsx)(d,{variant:`primary`,disabled:D||!M.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsx)(`button`,{type:`button`,disabled:D,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,x===`recommendation`&&T?.result&&Q?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,v.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),$,(0,v.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,v.jsx)(f,{className:`size-5`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,v.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,v.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,v.jsx)(ve,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,v.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ue(Q.risk)})]}),(0,v.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,v.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,v.jsx)(d,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,v.jsx)(d,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),T.result.workThreads?.length?(0,v.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:R?(0,v.jsx)(a,{className:`size-4`}):(0,v.jsx)(ae,{className:`size-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:R?t.focusTrialActive:t.focusTrialTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:R?t.focusTrialActiveDescription:t.focusTrialDescription}),R?null:(0,v.jsxs)(d,{className:`mt-3 h-9`,variant:`secondary`,disabled:D,onClick:()=>void Ve(),children:[D?(0,v.jsx)(m,{className:`size-4 animate-spin`}):(0,v.jsx)(ae,{className:`size-4`}),t.activateFocusTrial]})]})]})}):null,He.length>0?(0,v.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,v.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:()=>F(e=>!e),children:[t.otherDirections,(0,v.jsx)(be,{className:`size-4 transition-transform ${P?`rotate-180`:``}`})]}),P?(0,v.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,v.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,v.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,v.jsxs)(`span`,{children:[(0,v.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,v.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,v.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(T.sessionKey),children:t.doSomethingElse}),(0,v.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{j(!0),S(`recognition`)},children:t.correctUnderstanding})]})]}):null,x===`error`&&T?(0,v.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,v.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,v.jsx)(ce,{className:`size-5`})}),(0,v.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,v.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:T.errorMessage}),(0,v.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsx)(d,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void le(T.id).then(K),children:t.retry}),(0,v.jsx)(d,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{E(null),w(null),S(`intro`)},children:t.chooseDifferent})]}),(0,v.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(T.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,v.jsx)(ne,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:C?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{b 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-JdwAhgNB.js";import{t as c}from"./messages-C96Zjb0V.js";import{n as ee}from"./locale-store-C_ax27uc.js";import{$s as l,A as te,Bl as u,Ec as ne,Fa as re,Fu as d,Hc as f,Kl as ie,Ml as ae,Nc as oe,Ns as p,Qc as m,Su as h,Tc as g,To as _,Xl as se,Ys as ce,a as le,cs as v,f as ue,hu as de,l as fe,m as pe,o as y,os as me,p as b,s as he,u as x,vt as S}from"./index-CGwuxvzr.js";var C=n(),w=e(t(),1),T=r();function ge(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 E(e){return e?S(new Date(e)):``}function _e(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 ve(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 D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.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,T.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,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.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,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(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,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(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=O(i),s=0;for(let e of O(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 A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(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,S]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=_(e=>e.setPageHeader),K=_(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([fe(e),x(e).catch(()=>({events:[]}))]);S(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([re(t.item.projectId).catch(()=>null),te().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await ue(r.id);S(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,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await le(r.id);S(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,w.useCallback)(async e=>{M((await x(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await b(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});S(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,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await pe(r.id,e);S(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await y(r.id,e.id);S(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await he(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),(0,T.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,w.useLayoutEffect)(()=>(G({startExtra:(0,T.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":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(d,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(0,T.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,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.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,T.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(d,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.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,T.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,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(u,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(ae,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(me,{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,T.jsx)(v,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(v,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.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,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.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,T.jsxs)(p,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(f,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.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,T.jsx)(u,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(e.size)]})]}),(0,T.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,T.jsx)(se,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.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,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(a,{to:ve(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,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.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,T.jsx)(de,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.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-C96Zjb0V.js";import{n as ee}from"./locale-store-C_ax27uc.js";import{$s as l,A as te,Bl as u,Ec as ne,Fa as re,Fu as d,Hc as f,Kl as ie,Ml as ae,Nc as oe,Ns as p,Qc as m,Su as h,Tc as g,To as _,Xl as se,Ys as ce,a as le,cs as v,f as ue,hu as de,l as fe,m as pe,o as y,os as me,p as b,s as he,u as x,vt as S}from"./index-BhQMnKH1.js";var C=n(),w=e(t(),1),T=r();function ge(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 E(e){return e?S(new Date(e)):``}function _e(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 ve(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 D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.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,T.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,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.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,T.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(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,T.jsx)(`div`,{className:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(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=O(i),s=0;for(let e of O(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 A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(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,S]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=_(e=>e.setPageHeader),K=_(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([fe(e),x(e).catch(()=>({events:[]}))]);S(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([re(t.item.projectId).catch(()=>null),te().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await ue(r.id);S(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,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await le(r.id);S(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,w.useCallback)(async e=>{M((await x(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await b(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});S(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,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await pe(r.id,e);S(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await y(r.id,e.id);S(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await he(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),(0,T.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,w.useLayoutEffect)(()=>(G({startExtra:(0,T.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":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(d,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(0,T.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,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(0,T.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,T.jsxs)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(d,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.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,T.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,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(h,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(u,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(ae,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(me,{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,T.jsx)(v,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(v,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.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,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.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,T.jsxs)(p,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(f,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(p,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.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,T.jsx)(u,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(e.size)]})]}),(0,T.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,T.jsx)(se,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.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,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(a,{to:ve(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,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.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,T.jsx)(de,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};