@intent-hq/web 2.389.0 → 2.389.2

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 (148) hide show
  1. package/package.json +1 -1
  2. package/web/app/immutable/chunks/{R69_F6ow.js → -xQ9aHnN.js} +1 -1
  3. package/web/app/immutable/chunks/{B6CGcXmK.js → 0JJFb4pz.js} +1 -1
  4. package/web/app/immutable/chunks/{T6fchQhT.js → 1-L83W2E.js} +2 -2
  5. package/web/app/immutable/chunks/{CM3NPzxs.js → 1C8jE5xg.js} +1 -1
  6. package/web/app/immutable/chunks/{CFjHgtjF.js → 2Rvfwx05.js} +4 -4
  7. package/web/app/immutable/chunks/{BVXrO_xP.js → 36_0UmtU.js} +1 -1
  8. package/web/app/immutable/chunks/{k1pjOtcg.js → 4DKzLFxz.js} +2 -2
  9. package/web/app/immutable/chunks/{qWMP3EPi.js → 4mQbCgSg.js} +1 -1
  10. package/web/app/immutable/chunks/{HYdiaHV7.js → 6SYeyudR.js} +1 -1
  11. package/web/app/immutable/chunks/{Beb33qQi.js → B37_G9B8.js} +1 -1
  12. package/web/app/immutable/chunks/{CIuThArl.js → B3ZhJ2zS.js} +3 -3
  13. package/web/app/immutable/chunks/{C4sNRwZN.js → B6xkV8xv.js} +1 -1
  14. package/web/app/immutable/chunks/{Ba3e0br1.js → B9LAnui0.js} +1 -1
  15. package/web/app/immutable/chunks/{DVsXJTH5.js → BAMTcytp.js} +1 -1
  16. package/web/app/immutable/chunks/{B-r8Ld9c.js → BBPT3jzS.js} +1 -1
  17. package/web/app/immutable/chunks/{vJJhwCPu.js → BE9LyC4x.js} +1 -1
  18. package/web/app/immutable/chunks/{oBc79yRV.js → BFacF5Cc.js} +1 -1
  19. package/web/app/immutable/chunks/{B4JMAhvp.js → BFiq0x-M.js} +1 -1
  20. package/web/app/immutable/chunks/{Dl8k4QUp.js → BFpiydcV.js} +1 -1
  21. package/web/app/immutable/chunks/{DIPIWs2Q.js → BGN20Sak.js} +4 -4
  22. package/web/app/immutable/chunks/{DtluaQEg.js → BGyTNq2q.js} +4 -4
  23. package/web/app/immutable/chunks/{D63urNNT.js → BHd5Ycyv.js} +1 -1
  24. package/web/app/immutable/chunks/{BR02ohTI.js → BI-xeUgJ.js} +1 -1
  25. package/web/app/immutable/chunks/{DM3Yrkkb.js → BLhpk6cm.js} +1 -1
  26. package/web/app/immutable/chunks/{CRPk37P7.js → BOy6NFH3.js} +1 -1
  27. package/web/app/immutable/chunks/{hgE6oWwa.js → BPDTSRg_.js} +1 -1
  28. package/web/app/immutable/chunks/{Z4vtXCdu.js → BPueFkqz.js} +1 -1
  29. package/web/app/immutable/chunks/{mq9vi3Up.js → BQGkLFny.js} +3 -3
  30. package/web/app/immutable/chunks/{Da5bNPjQ.js → BVZ7Hw44.js} +1 -1
  31. package/web/app/immutable/chunks/{uftNwUIw.js → BYZgkpv-.js} +1 -1
  32. package/web/app/immutable/chunks/{D36a16oA.js → B_EH4rnd.js} +2 -2
  33. package/web/app/immutable/chunks/{sQSEv8Vy.js → BfgamEFW.js} +1 -1
  34. package/web/app/immutable/chunks/{DrF6vLLb.js → Bj2kxXBv.js} +1 -1
  35. package/web/app/immutable/chunks/Bk5Drm1a.js +12 -0
  36. package/web/app/immutable/chunks/{D2McplNW.js → BmGKJL-X.js} +1 -1
  37. package/web/app/immutable/chunks/{wX0L7qir.js → BnaA6Qz9.js} +3 -3
  38. package/web/app/immutable/chunks/{DZKOpbCv.js → BoToR9vg.js} +1 -1
  39. package/web/app/immutable/chunks/{x0vz7jUI.js → BpmuH_kK.js} +1 -1
  40. package/web/app/immutable/chunks/{BF_gPEg7.js → BwA1d-u1.js} +1 -1
  41. package/web/app/immutable/chunks/{JrdZaYjT.js → BxBhc8SK.js} +1 -1
  42. package/web/app/immutable/chunks/{Cy--ZUaj.js → ByH7GIW_.js} +2 -2
  43. package/web/app/immutable/chunks/{DZz-0U7K.js → Byqd0P12.js} +1 -1
  44. package/web/app/immutable/chunks/{xXDRZ4UR.js → C-AFiViU.js} +1 -1
  45. package/web/app/immutable/chunks/{gsePksRf.js → C0ar8e1U.js} +1 -1
  46. package/web/app/immutable/chunks/{Cp1B7D7t.js → C2PFxOOc.js} +1 -1
  47. package/web/app/immutable/chunks/{C3vs7E1W.js → C46oSs94.js} +1 -1
  48. package/web/app/immutable/chunks/{dEPZ-XrU.js → C6nQg0nK.js} +1 -1
  49. package/web/app/immutable/chunks/{BkYN9M7z.js → C87s6b1I.js} +1 -1
  50. package/web/app/immutable/chunks/{BNSbhHFY.js → C9HRYAK5.js} +1 -1
  51. package/web/app/immutable/chunks/{B-I8ZlVM.js → CIzdwtCK.js} +1 -1
  52. package/web/app/immutable/chunks/{C8A41C8K.js → CKjPe4ll.js} +1 -1
  53. package/web/app/immutable/chunks/{DUJ7Uicl.js → CLuP0_Is.js} +1 -1
  54. package/web/app/immutable/chunks/{BdNfyyl1.js → CO1JOjiw.js} +1 -1
  55. package/web/app/immutable/chunks/{BdQ54KL0.js → COli2nkv.js} +1 -1
  56. package/web/app/immutable/chunks/{DOmB999d.js → CPIfFszb.js} +1 -1
  57. package/web/app/immutable/chunks/{BIVpRSxo.js → CPlbtgfY.js} +2 -2
  58. package/web/app/immutable/chunks/{qtHim0jP.js → CSMPUzig.js} +1 -1
  59. package/web/app/immutable/chunks/{CdfbvT19.js → CT137GBc.js} +1 -1
  60. package/web/app/immutable/chunks/{C4JKtRY1.js → CW6t9rU8.js} +1 -1
  61. package/web/app/immutable/chunks/{86aXQThN.js → C_ps7SI2.js} +1 -1
  62. package/web/app/immutable/chunks/{fCCFSMRf.js → Cb1ltk9x.js} +3 -3
  63. package/web/app/immutable/chunks/{BwVhyX7o.js → Ccgqb2IM.js} +1 -1
  64. package/web/app/immutable/chunks/{DBwApbzS.js → Ce8WBTjF.js} +1 -1
  65. package/web/app/immutable/chunks/{Be-9sO50.js → Cg8YmoXY.js} +1 -1
  66. package/web/app/immutable/chunks/{Ci0dPfzv.js → Comxi6VB.js} +1 -1
  67. package/web/app/immutable/chunks/{zA4TFq_E.js → CpSE18tk.js} +1 -1
  68. package/web/app/immutable/chunks/{CmBouCgt.js → CrF2NvoU.js} +2 -2
  69. package/web/app/immutable/chunks/{Dsyh_lG5.js → Cs1c4sXg.js} +1 -1
  70. package/web/app/immutable/chunks/{g-pOypvE.js → Cx-w_9tt.js} +1 -1
  71. package/web/app/immutable/chunks/{DRbQVjcG.js → CzBMiZpT.js} +1 -1
  72. package/web/app/immutable/chunks/{oEGQGYxq.js → D0bUMHTb.js} +1 -1
  73. package/web/app/immutable/chunks/{BlTdGk3A.js → DB7VQKGS.js} +1 -1
  74. package/web/app/immutable/chunks/{BQGIKN0g.js → DBb8bRDA.js} +1 -1
  75. package/web/app/immutable/chunks/{DHz7ym-I.js → DBjXG7Re.js} +1 -1
  76. package/web/app/immutable/chunks/{iIsyEXfi.js → DBtTsT3h.js} +1 -1
  77. package/web/app/immutable/chunks/{5J_xNo3h.js → DC_3EQkj.js} +2 -2
  78. package/web/app/immutable/chunks/{s6Wn05Cg.js → DJAJF2aV.js} +1 -1
  79. package/web/app/immutable/chunks/{CqqkIXTJ.js → DLN1m_oc.js} +1 -1
  80. package/web/app/immutable/chunks/{Bm_geQt1.js → DP6e20em.js} +1 -1
  81. package/web/app/immutable/chunks/{DDVnHnMH.js → DP94l5zD.js} +3 -3
  82. package/web/app/immutable/chunks/{BE4rQlti.js → DPWgxx_r.js} +1 -1
  83. package/web/app/immutable/chunks/{D8EdnE4r.js → DROfA7cv.js} +1 -1
  84. package/web/app/immutable/chunks/{DN-c0DDt.js → DUc2opAY.js} +1 -1
  85. package/web/app/immutable/chunks/{0AIorxUa.js → DWlmiKMQ.js} +7 -7
  86. package/web/app/immutable/chunks/{KvHDUk_b.js → DaR1HweB.js} +2 -2
  87. package/web/app/immutable/chunks/{D3shmp0V.js → DdG0fpQR.js} +1 -1
  88. package/web/app/immutable/chunks/{ublLekYt.js → DeTo2B7W.js} +1 -1
  89. package/web/app/immutable/chunks/{BoCCPZlL.js → Dg6-yJwG.js} +1 -1
  90. package/web/app/immutable/chunks/{D3vsaFn3.js → DghicuZY.js} +1 -1
  91. package/web/app/immutable/chunks/{CXfRSojK.js → DhBCCByJ.js} +1 -1
  92. package/web/app/immutable/chunks/{C9szebIt.js → DiSTOpT2.js} +1 -1
  93. package/web/app/immutable/chunks/{BT5v4htV.js → DlYWQy9o.js} +1 -1
  94. package/web/app/immutable/chunks/{B91tdOJm.js → DmaxCRlh.js} +1 -1
  95. package/web/app/immutable/chunks/{D-q3diCz.js → DpSuNWKG.js} +1 -1
  96. package/web/app/immutable/chunks/{T7iqVsMb.js → Dq37igck.js} +1 -1
  97. package/web/app/immutable/chunks/{CheN8m7G.js → Du0sz9ah.js} +1 -1
  98. package/web/app/immutable/chunks/{CkTunFkP.js → DvKBDp7T.js} +1 -1
  99. package/web/app/immutable/chunks/{C4UYdkwZ.js → Dwp4DMqr.js} +1 -1
  100. package/web/app/immutable/chunks/{CeZGOup4.js → DzHCFW-E.js} +1 -1
  101. package/web/app/immutable/chunks/{CgzHyieN.js → FVGAeFGR.js} +1 -1
  102. package/web/app/immutable/chunks/{CB2iSm6U.js → F_CzStpc.js} +1 -1
  103. package/web/app/immutable/chunks/{Z2wqUYyr.js → HCeNaLBX.js} +2 -2
  104. package/web/app/immutable/chunks/{BhVbCtBE.js → HXrwONGg.js} +1 -1
  105. package/web/app/immutable/chunks/{CJ9ZGIU3.js → O_noOQCK.js} +1 -1
  106. package/web/app/immutable/chunks/{BwCICkMn.js → QzztRxOC.js} +1 -1
  107. package/web/app/immutable/chunks/{BWFaOHKx.js → ScJg5Frh.js} +1 -1
  108. package/web/app/immutable/chunks/{DCFeaWgZ.js → W8QLebuN.js} +1 -1
  109. package/web/app/immutable/chunks/{85NDZF0c.js → YH-zvTaG.js} +1 -1
  110. package/web/app/immutable/chunks/{2mfr9mCI.js → ZACNX8Dr.js} +1 -1
  111. package/web/app/immutable/chunks/{CUE71p7a.js → _O-9-CfM.js} +1 -1
  112. package/web/app/immutable/chunks/{CS9nZ0mb.js → a8-PvMdA.js} +1 -1
  113. package/web/app/immutable/chunks/{4VEtxogG.js → aXIBID0A.js} +1 -1
  114. package/web/app/immutable/chunks/{CrK7N1sc.js → eeYFFN2l.js} +1 -1
  115. package/web/app/immutable/chunks/{D5dii3q-.js → f5_5NkcH.js} +1 -1
  116. package/web/app/immutable/chunks/{Cmw8ZiCg.js → hr3XkGev.js} +1 -1
  117. package/web/app/immutable/chunks/{D17rwSNZ.js → ialDfbR3.js} +1 -1
  118. package/web/app/immutable/chunks/{nfiajAfR.js → j4CbH61f.js} +1 -1
  119. package/web/app/immutable/chunks/{Bmlx0yvl.js → kGnYVYAk.js} +2 -2
  120. package/web/app/immutable/chunks/{2sf1Yn-s.js → lPtzElq9.js} +1 -1
  121. package/web/app/immutable/chunks/{CeWx_dfN.js → mnUHiFkL.js} +1 -1
  122. package/web/app/immutable/chunks/{Di3tMG_J.js → pLgYa-qv.js} +1 -1
  123. package/web/app/immutable/chunks/{Bauem7Ke.js → qksfFGtg.js} +1 -1
  124. package/web/app/immutable/chunks/{ByZRLPfm.js → r9CLdeRr.js} +3 -3
  125. package/web/app/immutable/chunks/{DqRvDwkX.js → rRCDXSQW.js} +1 -1
  126. package/web/app/immutable/chunks/{97-360Ms.js → rhdxBxmR.js} +1 -1
  127. package/web/app/immutable/chunks/{CzFnnQhI.js → trGNLbxJ.js} +1 -1
  128. package/web/app/immutable/chunks/{Nthsb-68.js → y6JuXIK4.js} +1 -1
  129. package/web/app/immutable/entry/{app.Beuvfwpq.js → app.DJnjuiiE.js} +2 -2
  130. package/web/app/immutable/entry/start.DrjKV6rZ.js +1 -0
  131. package/web/app/immutable/nodes/{0.cL5zt7Bt.js → 0.CUxBVUWQ.js} +1 -1
  132. package/web/app/immutable/nodes/{1.Dj9s42wq.js → 1.CSjXQrGv.js} +1 -1
  133. package/web/app/immutable/nodes/{10.CQpwV39P.js → 10.BATprR9e.js} +1 -1
  134. package/web/app/immutable/nodes/{11.ryjds32c.js → 11.5ipin3q_.js} +1 -1
  135. package/web/app/immutable/nodes/{15.ffzaVnT8.js → 15.Dwvj0-lX.js} +1 -1
  136. package/web/app/immutable/nodes/{19.COuvk-IK.js → 19.8bZ2WiIx.js} +2 -2
  137. package/web/app/immutable/nodes/{2.CyeHTGza.js → 2.BhLocieZ.js} +1 -1
  138. package/web/app/immutable/nodes/{3.Cli5S3q6.js → 3.CZ0MN870.js} +1 -1
  139. package/web/app/immutable/nodes/{4.DnwVlUKb.js → 4.Jqmt7KB_.js} +1 -1
  140. package/web/app/immutable/nodes/{5.BBLKg00X.js → 5.QoAJLoN0.js} +1 -1
  141. package/web/app/immutable/nodes/{6.D_zrx8Je.js → 6.uLNlkxFf.js} +1 -1
  142. package/web/app/immutable/nodes/{7.CbiG1FxN.js → 7.BohHriQX.js} +1 -1
  143. package/web/app/immutable/nodes/{8.BqucsZP2.js → 8.BC5uGoFC.js} +1 -1
  144. package/web/app/immutable/nodes/{9.YctElBWI.js → 9.BnQAis5Y.js} +2 -2
  145. package/web/app/version.json +1 -1
  146. package/web/index.html +9 -9
  147. package/web/app/immutable/chunks/CndXvgyH.js +0 -12
  148. package/web/app/immutable/entry/start.dSf-uLxv.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intent-hq/web",
3
- "version": "2.389.0",
3
+ "version": "2.389.2",
4
4
  "description": "Intent in the browser: a standalone web server for Intent machines.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1 +1 @@
1
- import{t as ee,bo as i,bw as te,b as ae,br as qe,bs as xe,bq as He,bp as Ke,bm as N}from"./CLAmm_T1.js";import{bs as re,b_ as $,aD as t,W as h,bA as q,bn as se,c9 as v,aA as l,aB as z,bV as O,br as Ve,ca as Me,bH as T,a5 as Q,bl as Z,bS as M,bO as be,ay as B,a7 as ke,aw as ze,bz as Pe}from"./3SdAC2_C.js";import{f as W}from"./nxtepGjE.js";import{Y as Xe}from"./TB9r2XJy.js";import{F as I,cF as Ye,bF as Ae,d3 as Re,aC as Ge,cr as Je,bn as Qe,bi as Ze,bh as et,bg as tt}from"./DPttSllj.js";import{ay as at,aB as rt}from"./DQw0Iiac.js";import{f as st}from"./u4iPyMwH.js";import{g as nt,i as it,I as lt}from"./B1CKzIA2.js";import{s as E,g as ot,f as De}from"./CcJmuwXr.js";import{a as Te}from"./BF_gPEg7.js";import{i as S}from"./BFgvMDua.js";import{n as J,l as Ce,c as Le}from"./CfNIzRu8.js";import{m as ct}from"./Cu5e4npY.js";import{a as ut}from"./D8EdnE4r.js";import{al as mt,j as pe}from"./BQGIKN0g.js";var dt=z('<span class="svelte-dywwvd"></span>'),vt=z('<span class="waveform svelte-dywwvd" aria-hidden="true" data-dictation-waveform=""></span>');function Ue(w,a){if(new.target)return ee({component:Ue,...w});re(a,!0);let g=i(a,"levels",7);const r=v(()=>{const s=g().slice(-Te).map(m=>Number.isFinite(m)?Math.min(1,Math.max(0,m)):0);return[...new Array(Te-s.length).fill(0),...s]});var d={get levels(){return g()},set levels(s){g(s),l()},$set:te,$on:(s,m)=>ae(a,s,m)},_=vt();return nt(_,21,()=>t(r),it,(s,m)=>{var c=dt();let x;$(()=>{E(c,"data-level",t(m)),x=ot(c,"",x,{height:`${2+t(m)*12}px`})}),h(s,c)}),q(_),h(w,_),se(d)}var gt=z('<span class="dictation-meter svelte-1oz1rct"><span class="elapsed svelte-1oz1rct" data-dictation-elapsed=""> </span> <!></span>');function Fe(w,a){if(new.target)return ee({component:Fe,...w});re(a,!0);let g=i(a,"levels",7),r=i(a,"startedAt",7,null),d=i(a,"elapsed",7),_=O(Ve(Date.now()));Me(()=>{if(!(d()!==void 0||r()===null))return T(_,Date.now(),!0),Xe.subscribe(new Date(r()),()=>T(_,Date.now(),!0),"second")});const s=v(()=>d()??st(r()===null?0:t(_)-r()));var m={get levels(){return g()},set levels(u){g(u),l()},get startedAt(){return r()},set startedAt(u=null){r(u),l()},get elapsed(){return d()},set elapsed(u){d(u),l()},$set:te,$on:(u,R)=>ae(a,u,R)},c=gt(),x=Q(c),P=Z(x,!0),C=M(x,2);return Ue(C,{get levels(){return g()}}),q(c),$(()=>be(P,t(s))),h(w,c),se(m)}var ft=new Set(["$$slots","$$events","$$legacy","class"]),pt=z("<!> <!>",1);function bt(w,a){if(new.target)return ee({component:bt,...w});re(a,!0);const g=()=>xe(c,"$levels$",d),r=()=>xe(x,"$startedAt$",d),[d,_]=He();let s=i(a,"class",7,""),m=Ke(a,ft);const c=at(),x=rt();var P={get class(){return s()},set class(u=""){s(u),l()},$set:te,$on:(u,R)=>ae(a,u,R)};{let u=v(()=>`dictation-stop-pill ${s()}`.trim());W(w,qe({variant:"ghost",size:"sm",get class(){return t(u)},"aria-pressed":"true"},()=>m,{children:(R,H)=>{var p=pt(),U=B(p);I(U,{get icon(){return Ye},size:14});var j=M(U,2);Fe(j,{get levels(){return g()},get startedAt(){return r()}}),h(R,p)},$$slots:{default:!0}}))}var C=se(P);return _(),C}var ht=z('<img class="w-full h-full object-cover"/>'),_t=z('<div class="flex size-full items-center justify-center bg-muted text-subtle"><!></div>'),yt=z("<div><!> <!></div> <!>",1),wt=z('<span class="tabular-nums opacity-70 shrink-0" data-testid="attachment-upload-progress"> </span>'),xt=z("<!> <!>",1),kt=z('<div class="w-4 h-4 rounded overflow-hidden shrink-0"><img class="w-full h-full object-cover"/></div>'),zt=z('<div><!> <span class="font-medium truncate max-w-30"> </span> <!> <!></div>');function Pt(w,a){if(new.target)return ee({component:Pt,...w});re(a,!0);let g=i(a,"id",7),r=i(a,"name",7),d=i(a,"type",7,""),_=i(a,"size",7),s=i(a,"file",7),m=i(a,"imageData",7),c=i(a,"imageMimeType",7),x=i(a,"imageUrl",7),P=i(a,"onRemove",7),C=i(a,"class",7,""),u=i(a,"variant",7,"chip"),R=i(a,"thumbnailClass",7,"w-16 h-16"),H=i(a,"disabled",7,!1),p=i(a,"placementStatus",7,void 0),U=i(a,"placementProgress",7,void 0),j=i(a,"placementError",7,void 0),K=i(a,"onRetry",7),V=O(null);const ne=v(()=>mt(c()||d()||s()?.type));let ie=O(null);const y=v(()=>t(ne)?m()&&c()?`data:${pe(c())};base64,${m()}`:x()??t(ie):null);Me(()=>{if(t(ne)&&!(m()&&c())&&s()){const e=URL.createObjectURL(s());return T(ie,e,!0),()=>URL.revokeObjectURL(e)}T(ie,null)});const Se=v(()=>{if(d()==="folder")return Qe;const e=pe(d()||c()||s()?.type);return e.startsWith("image")?Ae:e.includes("javascript")||e.includes("typescript")||e.includes("json")?Ze:e.includes("text")||e.includes("markdown")?et:tt}),le=v(()=>pe(d()||c()||s()?.type).startsWith("image")),Ie=v(()=>{if(p()!=="failed")return;const e=N.chat_attachmentPreview_placementFailed_tooltip({name:r()});return j()?`${e} — ${j()}`:e}),he=v(()=>{if(p()!=="placing"||U()===void 0)return;const e=Math.max(0,Math.min(1,U()));return ct(e,{style:"percent",maximumFractionDigits:0})});let oe=O(!1),ce=O(null);function _e(){u()==="thumbnail"&&t(le)&&t(y)&&T(oe,!0)}function Ee(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),_e())}function $e(e){e.stopPropagation(),P()?.(g())}var je={get id(){return g()},set id(e){g(e),l()},get name(){return r()},set name(e){r(e),l()},get type(){return d()},set type(e=""){d(e),l()},get size(){return _()},set size(e){_(e),l()},get file(){return s()},set file(e){s(e),l()},get imageData(){return m()},set imageData(e){m(e),l()},get imageMimeType(){return c()},set imageMimeType(e){c(e),l()},get imageUrl(){return x()},set imageUrl(e){x(e),l()},get onRemove(){return P()},set onRemove(e){P(e),l()},get class(){return C()},set class(e=""){C(e),l()},get variant(){return u()},set variant(e="chip"){u(e),l()},get thumbnailClass(){return R()},set thumbnailClass(e="w-16 h-16"){R(e),l()},get disabled(){return H()},set disabled(e=!1){H(e),l()},get placementStatus(){return p()},set placementStatus(e=void 0){p(e),l()},get placementProgress(){return U()},set placementProgress(e=void 0){U(e),l()},get placementError(){return j()},set placementError(e=void 0){j(e),l()},get onRetry(){return K()},set onRetry(e){K(e),l()},$set:te,$on:(e,b)=>ae(a,e,b)},ye=ke(),Ne=B(ye);{var Oe=e=>{var b=yt(),D=B(b),X=Q(D);{let A=v(()=>N.chat_attachmentPreview_viewFullSize_ariaLabel({name:r()})),F=v(()=>H()||!t(y));W(X,{variant:"plain",wrapContent:!1,type:"button",get class(){return`${R()??""} rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity`},onclick:_e,onkeydown:Ee,get"aria-label"(){return t(A)},get title(){return r()},get disabled(){return t(F)},get ref(){return t(ce)},set ref(L){T(ce,L,!0)},children:(L,ve)=>{var Y=ke(),ge=B(Y);{var n=o=>{var f=ht();$(()=>{E(f,"src",t(y)),E(f,"alt",r())}),ze("error",f,()=>T(V,t(y),!0)),Pe(f),h(o,f)},k=o=>{var f=_t(),G=Q(f);I(G,{get icon(){return Ae},size:"15"}),q(f),h(o,f)};S(ge,o=>{t(y)?o(n):o(k,-1)})}h(L,Y)},$$slots:{default:!0}})}var ue=M(X,2);{var me=A=>{{let F=v(()=>N.chat_attachmentPreview_remove_ariaLabel({name:r()}));W(A,{variant:"ghost",size:"icon-xs",class:"absolute top-0.5 right-0.5 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity duration-spring-fast ease-spring-fast motion-reduce:transition-none bg-background/80 hover:bg-background shadow-sm",onclick:$e,get"aria-label"(){return t(F)},children:(L,ve)=>{I(L,{get icon(){return Re},size:"10"})},$$slots:{default:!0}})}};S(ue,A=>{P()&&A(me)})}q(D);var de=M(D,2);{let A=v(()=>t(y)??"");ut(de,{get imageUrl(){return t(A)},get imageName(){return r()},get openerElement(){return t(ce)},get open(){return t(oe)},set open(F){T(oe,F,!0)}})}$(()=>De(D,1,`relative group shrink-0 ${C()??""}`)),J(1,D,()=>Ce,()=>({tier:"moderate",y:0,scale:.9})),J(2,D,()=>Le,()=>({tier:"fast"})),h(e,b)},Be=e=>{var b=zt(),D=Q(b);{var X=n=>{var k=xt(),o=B(k);lt(o,{size:15,class:"opacity-50 shrink-0"});var f=M(o,2);{var G=fe=>{var we=wt(),We=Z(we,!0);$(()=>be(We,t(he))),h(fe,we)};S(f,fe=>{t(he)!==void 0&&fe(G)})}h(n,k)},ue=n=>{I(n,{get icon(){return Ge},size:"15",class:"shrink-0"})},me=n=>{var k=kt(),o=Z(k);$(()=>{E(o,"src",t(y)),E(o,"alt",r())}),ze("error",o,()=>T(V,t(y),!0)),Pe(o),h(n,k)},de=n=>{I(n,{get icon(){return t(Se)},size:"15",class:"opacity-30 shrink-0"})};S(D,n=>{p()==="placing"?n(X):p()==="failed"?n(ue,1):t(le)&&t(y)&&t(V)!==t(y)?n(me,2):n(de,-1)})}var A=M(D,2),F=Z(A,!0),L=M(A,2);{var ve=n=>{{let k=v(()=>N.chat_attachmentPreview_retryPlacement_ariaLabel({name:r()}));W(n,{variant:"ghost-light",size:"icon-xs",class:"shrink-0 -my-1",onclick:o=>{o.stopPropagation(),K()(g())},get"aria-label"(){return t(k)},"data-testid":"attachment-retry",children:(o,f)=>{I(o,{get icon(){return Je},size:"10"})},$$slots:{default:!0}})}};S(L,n=>{p()==="failed"&&K()&&n(ve)})}var Y=M(L,2);{var ge=n=>{{let k=v(()=>p()==="failed"?"":"opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),o=v(()=>N.chat_attachmentPreview_removeAttachment_ariaLabel());W(n,{variant:"ghost-light",size:"icon-xs",get class(){return`shrink-0 ${t(k)??""} transition-opacity duration-spring-fast ease-spring-fast motion-reduce:transition-none -my-1 -mr-1`},onclick:()=>P()(g()),get"aria-label"(){return t(o)},children:(f,G)=>{I(f,{get icon(){return Re},size:"10"})},$$slots:{default:!0}})}};S(Y,n=>{P()&&n(ge)})}q(b),$(()=>{De(b,1,`flex items-center gap-1.5 px-2 py-0.5 rounded text-xs whitespace-nowrap group shrink-0 ${p()==="failed"?"bg-danger-background/10 text-danger border border-danger/40":"bg-muted/70 text-subtle"} ${C()??""}`),E(b,"data-placement-status",p()),E(b,"title",t(Ie)),be(F,r())}),J(1,b,()=>Ce,()=>({tier:"moderate",y:0,scale:.9})),J(2,b,()=>Le,()=>({tier:"fast"})),h(e,b)};S(Ne,e=>{u()==="thumbnail"&&t(le)&&t(ne)&&(!t(y)||t(V)!==t(y))?e(Oe):e(Be,-1)})}return h(w,ye),se(je)}export{Pt as A,Fe as D,bt as a};
1
+ import{t as ee,bo as i,bw as te,b as ae,br as qe,bs as xe,bq as He,bp as Ke,bm as N}from"./CLAmm_T1.js";import{bs as re,b_ as $,aD as t,W as h,bA as q,bn as se,c9 as v,aA as l,aB as z,bV as O,br as Ve,ca as Me,bH as T,a5 as Q,bl as Z,bS as M,bO as be,ay as B,a7 as ke,aw as ze,bz as Pe}from"./3SdAC2_C.js";import{f as W}from"./nxtepGjE.js";import{Y as Xe}from"./TB9r2XJy.js";import{F as I,cF as Ye,bF as Ae,d3 as Re,aC as Ge,cr as Je,bn as Qe,bi as Ze,bh as et,bg as tt}from"./DPttSllj.js";import{ay as at,aB as rt}from"./DQw0Iiac.js";import{f as st}from"./u4iPyMwH.js";import{g as nt,i as it,I as lt}from"./B1CKzIA2.js";import{s as E,g as ot,f as De}from"./CcJmuwXr.js";import{a as Te}from"./BwA1d-u1.js";import{i as S}from"./BFgvMDua.js";import{n as J,l as Ce,c as Le}from"./CfNIzRu8.js";import{m as ct}from"./Cu5e4npY.js";import{a as ut}from"./DROfA7cv.js";import{al as mt,j as pe}from"./DBb8bRDA.js";var dt=z('<span class="svelte-dywwvd"></span>'),vt=z('<span class="waveform svelte-dywwvd" aria-hidden="true" data-dictation-waveform=""></span>');function Ue(w,a){if(new.target)return ee({component:Ue,...w});re(a,!0);let g=i(a,"levels",7);const r=v(()=>{const s=g().slice(-Te).map(m=>Number.isFinite(m)?Math.min(1,Math.max(0,m)):0);return[...new Array(Te-s.length).fill(0),...s]});var d={get levels(){return g()},set levels(s){g(s),l()},$set:te,$on:(s,m)=>ae(a,s,m)},_=vt();return nt(_,21,()=>t(r),it,(s,m)=>{var c=dt();let x;$(()=>{E(c,"data-level",t(m)),x=ot(c,"",x,{height:`${2+t(m)*12}px`})}),h(s,c)}),q(_),h(w,_),se(d)}var gt=z('<span class="dictation-meter svelte-1oz1rct"><span class="elapsed svelte-1oz1rct" data-dictation-elapsed=""> </span> <!></span>');function Fe(w,a){if(new.target)return ee({component:Fe,...w});re(a,!0);let g=i(a,"levels",7),r=i(a,"startedAt",7,null),d=i(a,"elapsed",7),_=O(Ve(Date.now()));Me(()=>{if(!(d()!==void 0||r()===null))return T(_,Date.now(),!0),Xe.subscribe(new Date(r()),()=>T(_,Date.now(),!0),"second")});const s=v(()=>d()??st(r()===null?0:t(_)-r()));var m={get levels(){return g()},set levels(u){g(u),l()},get startedAt(){return r()},set startedAt(u=null){r(u),l()},get elapsed(){return d()},set elapsed(u){d(u),l()},$set:te,$on:(u,R)=>ae(a,u,R)},c=gt(),x=Q(c),P=Z(x,!0),C=M(x,2);return Ue(C,{get levels(){return g()}}),q(c),$(()=>be(P,t(s))),h(w,c),se(m)}var ft=new Set(["$$slots","$$events","$$legacy","class"]),pt=z("<!> <!>",1);function bt(w,a){if(new.target)return ee({component:bt,...w});re(a,!0);const g=()=>xe(c,"$levels$",d),r=()=>xe(x,"$startedAt$",d),[d,_]=He();let s=i(a,"class",7,""),m=Ke(a,ft);const c=at(),x=rt();var P={get class(){return s()},set class(u=""){s(u),l()},$set:te,$on:(u,R)=>ae(a,u,R)};{let u=v(()=>`dictation-stop-pill ${s()}`.trim());W(w,qe({variant:"ghost",size:"sm",get class(){return t(u)},"aria-pressed":"true"},()=>m,{children:(R,H)=>{var p=pt(),U=B(p);I(U,{get icon(){return Ye},size:14});var j=M(U,2);Fe(j,{get levels(){return g()},get startedAt(){return r()}}),h(R,p)},$$slots:{default:!0}}))}var C=se(P);return _(),C}var ht=z('<img class="w-full h-full object-cover"/>'),_t=z('<div class="flex size-full items-center justify-center bg-muted text-subtle"><!></div>'),yt=z("<div><!> <!></div> <!>",1),wt=z('<span class="tabular-nums opacity-70 shrink-0" data-testid="attachment-upload-progress"> </span>'),xt=z("<!> <!>",1),kt=z('<div class="w-4 h-4 rounded overflow-hidden shrink-0"><img class="w-full h-full object-cover"/></div>'),zt=z('<div><!> <span class="font-medium truncate max-w-30"> </span> <!> <!></div>');function Pt(w,a){if(new.target)return ee({component:Pt,...w});re(a,!0);let g=i(a,"id",7),r=i(a,"name",7),d=i(a,"type",7,""),_=i(a,"size",7),s=i(a,"file",7),m=i(a,"imageData",7),c=i(a,"imageMimeType",7),x=i(a,"imageUrl",7),P=i(a,"onRemove",7),C=i(a,"class",7,""),u=i(a,"variant",7,"chip"),R=i(a,"thumbnailClass",7,"w-16 h-16"),H=i(a,"disabled",7,!1),p=i(a,"placementStatus",7,void 0),U=i(a,"placementProgress",7,void 0),j=i(a,"placementError",7,void 0),K=i(a,"onRetry",7),V=O(null);const ne=v(()=>mt(c()||d()||s()?.type));let ie=O(null);const y=v(()=>t(ne)?m()&&c()?`data:${pe(c())};base64,${m()}`:x()??t(ie):null);Me(()=>{if(t(ne)&&!(m()&&c())&&s()){const e=URL.createObjectURL(s());return T(ie,e,!0),()=>URL.revokeObjectURL(e)}T(ie,null)});const Se=v(()=>{if(d()==="folder")return Qe;const e=pe(d()||c()||s()?.type);return e.startsWith("image")?Ae:e.includes("javascript")||e.includes("typescript")||e.includes("json")?Ze:e.includes("text")||e.includes("markdown")?et:tt}),le=v(()=>pe(d()||c()||s()?.type).startsWith("image")),Ie=v(()=>{if(p()!=="failed")return;const e=N.chat_attachmentPreview_placementFailed_tooltip({name:r()});return j()?`${e} — ${j()}`:e}),he=v(()=>{if(p()!=="placing"||U()===void 0)return;const e=Math.max(0,Math.min(1,U()));return ct(e,{style:"percent",maximumFractionDigits:0})});let oe=O(!1),ce=O(null);function _e(){u()==="thumbnail"&&t(le)&&t(y)&&T(oe,!0)}function Ee(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),_e())}function $e(e){e.stopPropagation(),P()?.(g())}var je={get id(){return g()},set id(e){g(e),l()},get name(){return r()},set name(e){r(e),l()},get type(){return d()},set type(e=""){d(e),l()},get size(){return _()},set size(e){_(e),l()},get file(){return s()},set file(e){s(e),l()},get imageData(){return m()},set imageData(e){m(e),l()},get imageMimeType(){return c()},set imageMimeType(e){c(e),l()},get imageUrl(){return x()},set imageUrl(e){x(e),l()},get onRemove(){return P()},set onRemove(e){P(e),l()},get class(){return C()},set class(e=""){C(e),l()},get variant(){return u()},set variant(e="chip"){u(e),l()},get thumbnailClass(){return R()},set thumbnailClass(e="w-16 h-16"){R(e),l()},get disabled(){return H()},set disabled(e=!1){H(e),l()},get placementStatus(){return p()},set placementStatus(e=void 0){p(e),l()},get placementProgress(){return U()},set placementProgress(e=void 0){U(e),l()},get placementError(){return j()},set placementError(e=void 0){j(e),l()},get onRetry(){return K()},set onRetry(e){K(e),l()},$set:te,$on:(e,b)=>ae(a,e,b)},ye=ke(),Ne=B(ye);{var Oe=e=>{var b=yt(),D=B(b),X=Q(D);{let A=v(()=>N.chat_attachmentPreview_viewFullSize_ariaLabel({name:r()})),F=v(()=>H()||!t(y));W(X,{variant:"plain",wrapContent:!1,type:"button",get class(){return`${R()??""} rounded-lg overflow-hidden cursor-pointer hover:opacity-90 transition-opacity`},onclick:_e,onkeydown:Ee,get"aria-label"(){return t(A)},get title(){return r()},get disabled(){return t(F)},get ref(){return t(ce)},set ref(L){T(ce,L,!0)},children:(L,ve)=>{var Y=ke(),ge=B(Y);{var n=o=>{var f=ht();$(()=>{E(f,"src",t(y)),E(f,"alt",r())}),ze("error",f,()=>T(V,t(y),!0)),Pe(f),h(o,f)},k=o=>{var f=_t(),G=Q(f);I(G,{get icon(){return Ae},size:"15"}),q(f),h(o,f)};S(ge,o=>{t(y)?o(n):o(k,-1)})}h(L,Y)},$$slots:{default:!0}})}var ue=M(X,2);{var me=A=>{{let F=v(()=>N.chat_attachmentPreview_remove_ariaLabel({name:r()}));W(A,{variant:"ghost",size:"icon-xs",class:"absolute top-0.5 right-0.5 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity duration-spring-fast ease-spring-fast motion-reduce:transition-none bg-background/80 hover:bg-background shadow-sm",onclick:$e,get"aria-label"(){return t(F)},children:(L,ve)=>{I(L,{get icon(){return Re},size:"10"})},$$slots:{default:!0}})}};S(ue,A=>{P()&&A(me)})}q(D);var de=M(D,2);{let A=v(()=>t(y)??"");ut(de,{get imageUrl(){return t(A)},get imageName(){return r()},get openerElement(){return t(ce)},get open(){return t(oe)},set open(F){T(oe,F,!0)}})}$(()=>De(D,1,`relative group shrink-0 ${C()??""}`)),J(1,D,()=>Ce,()=>({tier:"moderate",y:0,scale:.9})),J(2,D,()=>Le,()=>({tier:"fast"})),h(e,b)},Be=e=>{var b=zt(),D=Q(b);{var X=n=>{var k=xt(),o=B(k);lt(o,{size:15,class:"opacity-50 shrink-0"});var f=M(o,2);{var G=fe=>{var we=wt(),We=Z(we,!0);$(()=>be(We,t(he))),h(fe,we)};S(f,fe=>{t(he)!==void 0&&fe(G)})}h(n,k)},ue=n=>{I(n,{get icon(){return Ge},size:"15",class:"shrink-0"})},me=n=>{var k=kt(),o=Z(k);$(()=>{E(o,"src",t(y)),E(o,"alt",r())}),ze("error",o,()=>T(V,t(y),!0)),Pe(o),h(n,k)},de=n=>{I(n,{get icon(){return t(Se)},size:"15",class:"opacity-30 shrink-0"})};S(D,n=>{p()==="placing"?n(X):p()==="failed"?n(ue,1):t(le)&&t(y)&&t(V)!==t(y)?n(me,2):n(de,-1)})}var A=M(D,2),F=Z(A,!0),L=M(A,2);{var ve=n=>{{let k=v(()=>N.chat_attachmentPreview_retryPlacement_ariaLabel({name:r()}));W(n,{variant:"ghost-light",size:"icon-xs",class:"shrink-0 -my-1",onclick:o=>{o.stopPropagation(),K()(g())},get"aria-label"(){return t(k)},"data-testid":"attachment-retry",children:(o,f)=>{I(o,{get icon(){return Je},size:"10"})},$$slots:{default:!0}})}};S(L,n=>{p()==="failed"&&K()&&n(ve)})}var Y=M(L,2);{var ge=n=>{{let k=v(()=>p()==="failed"?"":"opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),o=v(()=>N.chat_attachmentPreview_removeAttachment_ariaLabel());W(n,{variant:"ghost-light",size:"icon-xs",get class(){return`shrink-0 ${t(k)??""} transition-opacity duration-spring-fast ease-spring-fast motion-reduce:transition-none -my-1 -mr-1`},onclick:()=>P()(g()),get"aria-label"(){return t(o)},children:(f,G)=>{I(f,{get icon(){return Re},size:"10"})},$$slots:{default:!0}})}};S(Y,n=>{P()&&n(ge)})}q(b),$(()=>{De(b,1,`flex items-center gap-1.5 px-2 py-0.5 rounded text-xs whitespace-nowrap group shrink-0 ${p()==="failed"?"bg-danger-background/10 text-danger border border-danger/40":"bg-muted/70 text-subtle"} ${C()??""}`),E(b,"data-placement-status",p()),E(b,"title",t(Ie)),be(F,r())}),J(1,b,()=>Ce,()=>({tier:"moderate",y:0,scale:.9})),J(2,b,()=>Le,()=>({tier:"fast"})),h(e,b)};S(Ne,e=>{u()==="thumbnail"&&t(le)&&t(ne)&&(!t(y)||t(V)!==t(y))?e(Oe):e(Be,-1)})}return h(w,ye),se(je)}export{Pt as A,Fe as D,bt as a};
@@ -1,4 +1,4 @@
1
- var cQ=Object.defineProperty;var NB=Q=>{throw TypeError(Q)};var LQ=(Q,A,B)=>A in Q?cQ(Q,A,{enumerable:!0,configurable:!0,writable:!0,value:B}):Q[A]=B;var x=(Q,A,B)=>LQ(Q,typeof A!="symbol"?A+"":A,B),CB=(Q,A,B)=>A.has(Q)||NB("Cannot "+B);var g=(Q,A,B)=>(CB(Q,A,"read from private field"),B?B.call(Q):A.get(Q)),c=(Q,A,B)=>A.has(Q)?NB("Cannot add the same private member more than once"):A instanceof WeakSet?A.add(Q):A.set(Q,B),M=(Q,A,B,E)=>(CB(Q,A,"write to private field"),E?E.call(Q,B):A.set(Q,B),B),D=(Q,A,B)=>(CB(Q,A,"access private method"),B);var HB=(Q,A,B,E)=>({set _(I){M(Q,A,I,B)},get _(){return g(Q,A,E)}});import{a3 as tQ,r as hQ,Q as jQ}from"./DIPIWs2Q.js";import{B as oQ,D as YQ}from"./iIsyEXfi.js";const T=["none","attribute","attribute.jsx","boolean","comment","comment.doc","constant","constant.builtin","constructor","diff.minus","diff.plus","embedded","emphasis","emphasis.strong","function","function.definition","function.method","keyword","keyword.control","keyword.declaration","keyword.import","keyword.operator","label","namespace","number","operator","predictive","preproc","primary","property","property.json_key","punctuation","punctuation.bracket","punctuation.bracket.html","punctuation.bracket.jsx","punctuation.delimiter","punctuation.delimiter.html","punctuation.delimiter.jsx","punctuation.list_marker","punctuation.markup","punctuation.special","selector","selector.class","selector.id","string","string.escape","string.regex","string.special","string.special.symbol","tag","tag.doctype","tag.jsx","text.jsx","text.literal","title","type","type.builtin","type.class","variable","variable.parameter","variable.special","enum","hint","keyword.jsdoc","link_text","link_uri","selector.pseudo","tag.component.jsx","type.jsdoc","variable.jsdoc","variant","background","foreground"],aQ="--hls-",NQ=new TextEncoder,HQ=/^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i,nQ=/^color\(display-p3\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:\s*\/\s*[+-]?(?:\d+(?:\.\d*)?|\.\d+))?\s*\)$/i;function ZQ(Q){return typeof Q=="string"&&(HQ.test(Q.trim())||nQ.test(Q.trim()))}function FB(Q){return Q["editor.foreground"]??Q.text??Q.foreground}function uB(Q){return Q["editor.background"]??Q.background}const YB=["black","red","green","yellow","blue","magenta","cyan","white","bright_black","bright_red","bright_green","bright_yellow","bright_blue","bright_magenta","bright_cyan","bright_white"],eQ=["#000000","#cd3131","#0dbc79","#e5e510","#2472c8","#bc3fbc","#11a8cd","#e5e5e5","#666666","#f14c4c","#23d18b","#f5f543","#3b8eea","#d670d6","#29b8db","#ffffff"];function dQ(Q){return YB.map((A,B)=>zB({foreground:Q[`terminal.ansi.${A}`]},"foreground").color??eQ[B])}function OB(Q){return Q===null?"null":Q===void 0?"undefined":typeof Q=="string"?`the string ${JSON.stringify(Q)} (theme ids are not supported; import the theme object from "@pierre/highlights/themes")`:Array.isArray(Q)?"an array":typeof Q=="object"?"themes"in Q&&Array.isArray(Q.themes)?`a ThemeFamily whose first member is ${OB(Q.themes[0])}`:"an object without a `name`":`a ${typeof Q}`}function lQ(Q){return Q!=null&&typeof Q=="object"&&"name"in Q&&typeof Q.name=="string"&&Q.name!==""}function xQ(Q){const A=Q!=null&&typeof Q=="object"&&"themes"in Q&&Q.themes!=null?Q.themes[0]:Q;if(!lQ(A))throw new TypeError(`invalid theme: expected a Theme or ThemeFamily object, received ${OB(Q)}`);return A}function vB(Q,A){let B;for(let E=A;E!=="";){const I=Q[E];if(typeof I=="string")return{...B,color:I};if(I!=null&&typeof I=="object"&&(B??=I,I.color!=null))return{...B,color:I.color};const C=E.lastIndexOf(".");E=C<0?"":E.slice(0,C)}return B}function zB(Q,A){let B,E,I;return A==="background"?B=uB(Q):A==="foreground"?B=FB(Q):({color:B,font_style:E,font_weight:I}=vB(Q.syntax??{},A)??{},(E!=null||I!=null)&&(B??=FB(Q))),ZQ(B)?(B=B.trim().toLowerCase(),B.startsWith("#")&&(B.length<=5&&(B=B.replace(/[^#]/g,"$&$&")),B.length===9&&B.endsWith("ff")&&(B=B.slice(0,7)),B==="#00000000"&&(B=void 0))):B=void 0,{color:B,italic:E==="italic",weight:I!=null&&I>=100&&I<=900?Math.round(I/100)*100:0}}function zA(Q,A){return`var(${A}${Q.replace(/[._]/g,"-")})`}function gA(Q){return Q.replaceAll("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function $B(Q){const A=Q.map(w=>NQ.encode(w));let B=4+8*A.length;const E=new Uint8Array(B+A.reduce((w,G)=>w+G.length,0)),I=new DataView(E.buffer);let C=32;for(let w=0;w<A.length;w++)I.setUint32(4+8*w,B,!0),I.setUint32(8+8*w,A[w].length,!0),E.set(A[w],B),B+=A[w].length,w!==0&&(C=Math.max(C,A[w].length+32));return I.setUint32(0,C,!0),E}const nB=new WeakMap;function SB(Q,A=aQ){const B=xQ(Q),E=B.cssVariables===!0?A:"";let I=nB.get(B);const C=I?.get(E);if(C!==void 0)return C;const w=B.cssVariables===!0?rQ(B.name,A):typeof B.cssVariables=="object"?bQ(B):WQ(B);return I===void 0&&(I=new Map,nB.set(B,I)),I.set(E,w),w}function bQ(Q){const A=Q.cssVariables;if(typeof A!="object")throw new Error("Expected CSS palette");const B=A.prefix??"--hls-",E=R=>{const i=A.defaults?.[R];return`var(${B}${R}${i?`, ${i}`:""})`},I=new Array(T.length).fill(null),C=Q.style.syntax??{};for(let R=1;R<T.length;R++){const i=vB(C,T[R]);I[R]={color:E(i?.color??"foreground"),italic:i?.font_style==="italic",weight:i?.font_weight===void 0?0:Math.round(i.font_weight/100)*100}}const w=E(FB(Q.style)??"foreground"),G=E(uB(Q.style)??"background");let k,S;return{name:Q.name,styles:I,fg:w,bg:G,table:void 0,get htmlOpeners(){return k??=_B(I,w,G)},get ansi(){return S??=YB.map(R=>{const i=Q.style[`terminal.ansi.${R}`];return E(typeof i=="string"?i:`terminal-ansi-${R.replace("_","-")}`)})}}}function rQ(Q,A){let B;const E=()=>B??=TQ(A);let I;return{name:Q,get styles(){return E().styles},get fg(){return E().fg},get bg(){return E().bg},table:void 0,htmlOpeners:void 0,get ansi(){return I??=YB.map(C=>zA(`terminal.ansi.${C}`,A))}}}function TQ(Q){const A=new Array(T.length).fill(null);for(let B=1;B<T.length;B++)A[B]={color:zA(T[B],Q),italic:!1,weight:0};return{styles:A,fg:zA("foreground",Q),bg:zA("background",Q)}}function WQ(Q){const A=Q.style??{},B=new Array(T.length).fill(null),E=new Uint8Array(T.length*5);let I,C,w=!1;for(let S=1;S<T.length;S++){const R=T[S],i=zB(A,R),{color:F,italic:s,weight:J}=i,t=S*5;if(F!==void 0)if(F.startsWith("#")){const a=parseInt(F.slice(1,7),16);E[t]=a>>16,E[t+1]=a>>8&255,E[t+2]=a&255,E[t+3]=F.length===9?parseInt(F.slice(7),16):255}else w=!0;E[t+4]=(s?16:0)|J/100,!(F===void 0&&!s&&J===0)&&(R==="foreground"?I=F:R==="background"?C=F:B[S]=i)}let G,k;return{name:Q.name,styles:B,fg:I,bg:C,table:w?void 0:E,get htmlOpeners(){if(w)return G??=_B(B,I,C)},get ansi(){return k??=dQ(A)}}}function _B(Q,A,B){const E=[`<pre class="highlights" style="${gA((B===void 0?"":`background-color:${B};`)+(A===void 0?"":`color:${A}`))}"><code>`];for(let I=1;I<T.length;I++){const C=Q[I],w=`color:${C?.color??"inherit"}`+(C?.italic===!0?";font-style:italic":"")+(C!=null&&C.weight!==0?`;font-weight:${C.weight}`:"");E.push(`<span style="${gA(w)}">`)}return $B(E)}const XQ=new TextEncoder,yA=new Uint8Array(T.length);for(let Q=0;Q<T.length;Q++){const A=T[Q];A==="string.regex"?yA[Q]=3:A==="comment"||A.startsWith("comment.")?yA[Q]=1:(A==="string"||A.startsWith("string."))&&(yA[Q]=2)}const ZB=new WeakMap,eB=new WeakMap;let fQ=1;const dB=new WeakMap,lB=new WeakMap,xB=new WeakMap;let KQ=0;function PQ(Q){let A=xB.get(Q);return A===void 0&&(A=KQ++,xB.set(Q,A)),A}function bB(Q,A,B){const{name:E,styles:I,fg:C,bg:w,table:G}=Q;return{color:A,role:B,name:E,styles:I,fg:C,bg:w,table:G,get ansi(){return Q.ansi}}}function lA(Q){const{cssVariablePrefix:A}=Q;if(Q.themes==null)return[bB(SB(Q.theme,A),null,"single")];const B=Object.entries(Q.themes).filter(([,R])=>R!=null).sort(([R],[i])=>R<i?-1:1);if(B.length===0)throw new TypeError("themes must not be empty");const E=Q.defaultColor??"light";let I;if(E==="light-dark()"){const R=B.find(([F])=>F==="light"),i=B.find(([F])=>F==="dark");if(R===void 0||i===void 0)throw new TypeError("`themes` must contain `light` and `dark` when defaultColor is 'light-dark()'");B.splice(0,B.length,R,i),I=["light-dark","light-dark"]}else{if(E!==!1){const R=B.findIndex(([i])=>i===E);if(R<0)throw new TypeError(`\`themes\` must contain the defaultColor key \`${E}\``);B.unshift(...B.splice(R,1))}I=B.map((R,i)=>E!==!1&&i===0?"default":"variable")}const C=B.map(([,R])=>SB(R,A)),w=JSON.stringify(B.map(([R],i)=>[PQ(C[i]),I[i],R]));let G=lB.get(C[0]);const k=G?.get(w);if(k!==void 0)return k;const S=B.map(([R],i)=>bB(C[i],R,I[i]));if(G===void 0&&(G=new Map,lB.set(C[0],G)),G.set(w,S),G.size>128){const R=G.keys().next().value;R!==void 0&&G.delete(R)}return S}function xA(Q,A,B,E,I,C,w=0){const G={content:Q.slice(A,B),offset:A+w};if(I[0].role==="single"){const{styles:S,fg:R}=I[0],i=S[E];G.color=i?.color??R;let F=0;i?.italic===!0&&(F|=1),(i?.weight??0)>=600&&(F|=2),G.fontStyle=F}else G.htmlStyle=aB(I,E,C);const k=yA[E];return k!==0&&(G.type=k),G}function AQ(Q,A){let B=ZB.get(Q);B===void 0&&(B=new Map,ZB.set(Q,B));let E=B.get(A);return E===void 0&&(E=[],B.set(A,E)),E}function aB(Q,A,B){const E=AQ(Q,B);let I=E[A];if(I===void 0){if(Q[0].role==="light-dark")I=pQ(Q,A,B);else{I={};for(const{color:C,role:w,styles:G,fg:k}of Q){const S=G[A],R=w==="default";I[R?"color":B+C]=S?.color??k??"inherit",S?.italic===!0&&(I[R?"font-style":`${B}${C}-font-style`]="italic"),S!=null&&S.weight!==0&&(I[R?"font-weight":`${B}${C}-font-weight`]=String(S.weight))}}E[A]=I}return I}function VQ(Q,A){let B=eB.get(Q);B===void 0&&(B=new Map,eB.set(Q,B));const E=B.get(A);if(E!==void 0)return E??void 0;const I=Q.length;if(!(I<=255&&Q.every(J=>J.table!==void 0))){B.set(A,null);return}const C=Q.map(J=>J.role==="default"?new Uint8Array(0):XQ.encode(gA(`${A}${J.color}`))),w=32+16*I,G=w+384*I;let k=64,S=128,R=0;for(const{length:J}of C)k+=64+3*J,S+=48+2*J,R+=J;const i=new Uint8Array(G+R),F=new DataView(i.buffer);i[0]=I,i[1]=Q[0].role==="light-dark"?1:0,F.setUint32(4,w,!0),F.setUint32(8,k,!0),F.setUint32(12,S,!0),F.setUint32(16,fQ++,!0);let s=G;for(let J=0;J<I;J++){const t=32+16*J;F.setUint32(t,s,!0),F.setUint32(t+4,C[J].length,!0),F.setUint32(t+8,Q[J].role==="default"?1:0,!0),i.set(Q[J].table,w+384*J),i.set(C[J],s),s+=C[J].length}return B.set(A,i),i}function mQ(Q,A){let B=dB.get(Q);B===void 0&&(B=new Map,dB.set(Q,B));const E=B.get(A);if(E!==void 0)return E;const{fg:I,bg:C,rootStyle:w}=kB(Q,A),G=[`<pre class="highlights" style="${gA(w??`background-color:${C};color:${I}`)}"><code>`];for(let S=1;S<T.length;S++){const R=aB(Q,S,A);let i="";for(const F in R)i+=`${i===""?"":";"}${F}:${R[F]}`;G.push(`<span style="${gA(i)}">`)}const k=$B(G);return B.set(A,k),k}function pQ(Q,A,B){const[E,I]=Q,C=E.styles[A],w=I.styles[A],G=C?.color??E.fg??"currentcolor",k=w?.color??I.fg??"currentcolor",S={color:G===k?G:`light-dark(${G}, ${k})`},R=C?.italic===!0,i=w?.italic===!0;R&&i?S["font-style"]="italic":(R&&(S[`${B}light-font-style`]="italic"),i&&(S[`${B}dark-font-style`]="italic"));const F=C?.weight??0,s=w?.weight??0;return F!==0&&F===s?S["font-weight"]=String(F):(F!==0&&(S[`${B}light-font-weight`]=String(F)),s!==0&&(S[`${B}dark-font-weight`]=String(s))),S}function BQ(Q,A,B,E,I,C=0){const w=[],G=I??0,{styles:k,fg:S,role:R}=B[0],i=R==="single"?void 0:AQ(B,E);let F=0;for(let s=0;;s+=2){const J=s;for(;s<A.length&&A[s+1]!==4294967295;)s+=2;const t=s===J?F:A[s-2];let a;if(G>0&&t-F>=G)a=[xA(Q,F,t,0,B,E,C)];else{a=new Array((s-J)/2);let o=0;for(let n=J;n<s;n+=2){const Z=A[n];if(Z>F){const h=A[n+1];let L;if(i===void 0){const H=k[h];L={content:Q.slice(F,Z),offset:F+C,color:H?.color??S,fontStyle:(H?.italic===!0?1:0)|((H?.weight??0)>=600?2:0)}}else L={content:Q.slice(F,Z),offset:F+C,htmlStyle:i[h]??aB(B,h,E)};const y=yA[h];y!==0&&(L.type=y),a[o++]=L,F=Z}}a.length=o}if(w.push(a),s===A.length)break;F=A[s]}return w}function kB(Q,A){if(Q[0].role==="single")return{fg:Q[0].fg,bg:Q[0].bg,themeName:Q[0].name};const B=`highlights-themes ${Q.map(C=>C.name).join(" ")}`;if(Q[0].role==="light-dark"){const C=(w,G,k)=>{const S=w??k,R=G??k;return S===R?S:`light-dark(${S}, ${R})`};return{fg:C(Q[0].fg,Q[1].fg,"currentcolor"),bg:C(Q[0].bg,Q[1].bg,"transparent"),themeName:B}}const E=Q.map(C=>C.role==="default"?C.fg??"inherit":`${A}${C.color}:${C.fg??"inherit"}`).join(";"),I=Q.map(C=>C.role==="default"?C.bg??"inherit":`${A}${C.color}-bg:${C.bg??"inherit"}`).join(";");return{fg:E,bg:I,themeName:B,rootStyle:Q[0].role==="default"?void 0:`${E};${I}`}}const sB=1,QQ=2,EQ=4,IQ=8,CQ=16,gQ=32,rB=[0,sB,QQ,EQ,IQ,0,0,CQ,0,gQ],gB=[0,95,135,175,215,255],wB=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b\n]*(?:\x07|\x1b\\)|[ -/]*[0-~])/y;var wQ=class{constructor(){x(this,"fg",-1);x(this,"bg",-1);x(this,"flags",0);x(this,"styles",new Map)}};function bA(Q){return String(Q).toLowerCase()==="ansi"}function RB(Q,A){if(A<16)return Q.ansi[A];let B=A&16777215;if(A<232){const E=A-16;B=gB[E/36|0]<<16|gB[(E/6|0)%6]<<8|gB[E%6]}else A<256&&(B=(8+(A-232)*10)*65793);return`#${B.toString(16).padStart(6,"0")}`}function UB(Q,A,B,E,I=new wQ,C=0){const w=[],G=E??0;let k=[],S,R,i,F=Q.indexOf("\x1B"),s=0;for(;;){const J=Q.indexOf(`
1
+ var cQ=Object.defineProperty;var NB=Q=>{throw TypeError(Q)};var LQ=(Q,A,B)=>A in Q?cQ(Q,A,{enumerable:!0,configurable:!0,writable:!0,value:B}):Q[A]=B;var x=(Q,A,B)=>LQ(Q,typeof A!="symbol"?A+"":A,B),CB=(Q,A,B)=>A.has(Q)||NB("Cannot "+B);var g=(Q,A,B)=>(CB(Q,A,"read from private field"),B?B.call(Q):A.get(Q)),c=(Q,A,B)=>A.has(Q)?NB("Cannot add the same private member more than once"):A instanceof WeakSet?A.add(Q):A.set(Q,B),M=(Q,A,B,E)=>(CB(Q,A,"write to private field"),E?E.call(Q,B):A.set(Q,B),B),D=(Q,A,B)=>(CB(Q,A,"access private method"),B);var HB=(Q,A,B,E)=>({set _(I){M(Q,A,I,B)},get _(){return g(Q,A,E)}});import{a3 as tQ,r as hQ,Q as jQ}from"./BGN20Sak.js";import{B as oQ,D as YQ}from"./DBtTsT3h.js";const T=["none","attribute","attribute.jsx","boolean","comment","comment.doc","constant","constant.builtin","constructor","diff.minus","diff.plus","embedded","emphasis","emphasis.strong","function","function.definition","function.method","keyword","keyword.control","keyword.declaration","keyword.import","keyword.operator","label","namespace","number","operator","predictive","preproc","primary","property","property.json_key","punctuation","punctuation.bracket","punctuation.bracket.html","punctuation.bracket.jsx","punctuation.delimiter","punctuation.delimiter.html","punctuation.delimiter.jsx","punctuation.list_marker","punctuation.markup","punctuation.special","selector","selector.class","selector.id","string","string.escape","string.regex","string.special","string.special.symbol","tag","tag.doctype","tag.jsx","text.jsx","text.literal","title","type","type.builtin","type.class","variable","variable.parameter","variable.special","enum","hint","keyword.jsdoc","link_text","link_uri","selector.pseudo","tag.component.jsx","type.jsdoc","variable.jsdoc","variant","background","foreground"],aQ="--hls-",NQ=new TextEncoder,HQ=/^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i,nQ=/^color\(display-p3\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:\s*\/\s*[+-]?(?:\d+(?:\.\d*)?|\.\d+))?\s*\)$/i;function ZQ(Q){return typeof Q=="string"&&(HQ.test(Q.trim())||nQ.test(Q.trim()))}function FB(Q){return Q["editor.foreground"]??Q.text??Q.foreground}function uB(Q){return Q["editor.background"]??Q.background}const YB=["black","red","green","yellow","blue","magenta","cyan","white","bright_black","bright_red","bright_green","bright_yellow","bright_blue","bright_magenta","bright_cyan","bright_white"],eQ=["#000000","#cd3131","#0dbc79","#e5e510","#2472c8","#bc3fbc","#11a8cd","#e5e5e5","#666666","#f14c4c","#23d18b","#f5f543","#3b8eea","#d670d6","#29b8db","#ffffff"];function dQ(Q){return YB.map((A,B)=>zB({foreground:Q[`terminal.ansi.${A}`]},"foreground").color??eQ[B])}function OB(Q){return Q===null?"null":Q===void 0?"undefined":typeof Q=="string"?`the string ${JSON.stringify(Q)} (theme ids are not supported; import the theme object from "@pierre/highlights/themes")`:Array.isArray(Q)?"an array":typeof Q=="object"?"themes"in Q&&Array.isArray(Q.themes)?`a ThemeFamily whose first member is ${OB(Q.themes[0])}`:"an object without a `name`":`a ${typeof Q}`}function lQ(Q){return Q!=null&&typeof Q=="object"&&"name"in Q&&typeof Q.name=="string"&&Q.name!==""}function xQ(Q){const A=Q!=null&&typeof Q=="object"&&"themes"in Q&&Q.themes!=null?Q.themes[0]:Q;if(!lQ(A))throw new TypeError(`invalid theme: expected a Theme or ThemeFamily object, received ${OB(Q)}`);return A}function vB(Q,A){let B;for(let E=A;E!=="";){const I=Q[E];if(typeof I=="string")return{...B,color:I};if(I!=null&&typeof I=="object"&&(B??=I,I.color!=null))return{...B,color:I.color};const C=E.lastIndexOf(".");E=C<0?"":E.slice(0,C)}return B}function zB(Q,A){let B,E,I;return A==="background"?B=uB(Q):A==="foreground"?B=FB(Q):({color:B,font_style:E,font_weight:I}=vB(Q.syntax??{},A)??{},(E!=null||I!=null)&&(B??=FB(Q))),ZQ(B)?(B=B.trim().toLowerCase(),B.startsWith("#")&&(B.length<=5&&(B=B.replace(/[^#]/g,"$&$&")),B.length===9&&B.endsWith("ff")&&(B=B.slice(0,7)),B==="#00000000"&&(B=void 0))):B=void 0,{color:B,italic:E==="italic",weight:I!=null&&I>=100&&I<=900?Math.round(I/100)*100:0}}function zA(Q,A){return`var(${A}${Q.replace(/[._]/g,"-")})`}function gA(Q){return Q.replaceAll("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function $B(Q){const A=Q.map(w=>NQ.encode(w));let B=4+8*A.length;const E=new Uint8Array(B+A.reduce((w,G)=>w+G.length,0)),I=new DataView(E.buffer);let C=32;for(let w=0;w<A.length;w++)I.setUint32(4+8*w,B,!0),I.setUint32(8+8*w,A[w].length,!0),E.set(A[w],B),B+=A[w].length,w!==0&&(C=Math.max(C,A[w].length+32));return I.setUint32(0,C,!0),E}const nB=new WeakMap;function SB(Q,A=aQ){const B=xQ(Q),E=B.cssVariables===!0?A:"";let I=nB.get(B);const C=I?.get(E);if(C!==void 0)return C;const w=B.cssVariables===!0?rQ(B.name,A):typeof B.cssVariables=="object"?bQ(B):WQ(B);return I===void 0&&(I=new Map,nB.set(B,I)),I.set(E,w),w}function bQ(Q){const A=Q.cssVariables;if(typeof A!="object")throw new Error("Expected CSS palette");const B=A.prefix??"--hls-",E=R=>{const i=A.defaults?.[R];return`var(${B}${R}${i?`, ${i}`:""})`},I=new Array(T.length).fill(null),C=Q.style.syntax??{};for(let R=1;R<T.length;R++){const i=vB(C,T[R]);I[R]={color:E(i?.color??"foreground"),italic:i?.font_style==="italic",weight:i?.font_weight===void 0?0:Math.round(i.font_weight/100)*100}}const w=E(FB(Q.style)??"foreground"),G=E(uB(Q.style)??"background");let k,S;return{name:Q.name,styles:I,fg:w,bg:G,table:void 0,get htmlOpeners(){return k??=_B(I,w,G)},get ansi(){return S??=YB.map(R=>{const i=Q.style[`terminal.ansi.${R}`];return E(typeof i=="string"?i:`terminal-ansi-${R.replace("_","-")}`)})}}}function rQ(Q,A){let B;const E=()=>B??=TQ(A);let I;return{name:Q,get styles(){return E().styles},get fg(){return E().fg},get bg(){return E().bg},table:void 0,htmlOpeners:void 0,get ansi(){return I??=YB.map(C=>zA(`terminal.ansi.${C}`,A))}}}function TQ(Q){const A=new Array(T.length).fill(null);for(let B=1;B<T.length;B++)A[B]={color:zA(T[B],Q),italic:!1,weight:0};return{styles:A,fg:zA("foreground",Q),bg:zA("background",Q)}}function WQ(Q){const A=Q.style??{},B=new Array(T.length).fill(null),E=new Uint8Array(T.length*5);let I,C,w=!1;for(let S=1;S<T.length;S++){const R=T[S],i=zB(A,R),{color:F,italic:s,weight:J}=i,t=S*5;if(F!==void 0)if(F.startsWith("#")){const a=parseInt(F.slice(1,7),16);E[t]=a>>16,E[t+1]=a>>8&255,E[t+2]=a&255,E[t+3]=F.length===9?parseInt(F.slice(7),16):255}else w=!0;E[t+4]=(s?16:0)|J/100,!(F===void 0&&!s&&J===0)&&(R==="foreground"?I=F:R==="background"?C=F:B[S]=i)}let G,k;return{name:Q.name,styles:B,fg:I,bg:C,table:w?void 0:E,get htmlOpeners(){if(w)return G??=_B(B,I,C)},get ansi(){return k??=dQ(A)}}}function _B(Q,A,B){const E=[`<pre class="highlights" style="${gA((B===void 0?"":`background-color:${B};`)+(A===void 0?"":`color:${A}`))}"><code>`];for(let I=1;I<T.length;I++){const C=Q[I],w=`color:${C?.color??"inherit"}`+(C?.italic===!0?";font-style:italic":"")+(C!=null&&C.weight!==0?`;font-weight:${C.weight}`:"");E.push(`<span style="${gA(w)}">`)}return $B(E)}const XQ=new TextEncoder,yA=new Uint8Array(T.length);for(let Q=0;Q<T.length;Q++){const A=T[Q];A==="string.regex"?yA[Q]=3:A==="comment"||A.startsWith("comment.")?yA[Q]=1:(A==="string"||A.startsWith("string."))&&(yA[Q]=2)}const ZB=new WeakMap,eB=new WeakMap;let fQ=1;const dB=new WeakMap,lB=new WeakMap,xB=new WeakMap;let KQ=0;function PQ(Q){let A=xB.get(Q);return A===void 0&&(A=KQ++,xB.set(Q,A)),A}function bB(Q,A,B){const{name:E,styles:I,fg:C,bg:w,table:G}=Q;return{color:A,role:B,name:E,styles:I,fg:C,bg:w,table:G,get ansi(){return Q.ansi}}}function lA(Q){const{cssVariablePrefix:A}=Q;if(Q.themes==null)return[bB(SB(Q.theme,A),null,"single")];const B=Object.entries(Q.themes).filter(([,R])=>R!=null).sort(([R],[i])=>R<i?-1:1);if(B.length===0)throw new TypeError("themes must not be empty");const E=Q.defaultColor??"light";let I;if(E==="light-dark()"){const R=B.find(([F])=>F==="light"),i=B.find(([F])=>F==="dark");if(R===void 0||i===void 0)throw new TypeError("`themes` must contain `light` and `dark` when defaultColor is 'light-dark()'");B.splice(0,B.length,R,i),I=["light-dark","light-dark"]}else{if(E!==!1){const R=B.findIndex(([i])=>i===E);if(R<0)throw new TypeError(`\`themes\` must contain the defaultColor key \`${E}\``);B.unshift(...B.splice(R,1))}I=B.map((R,i)=>E!==!1&&i===0?"default":"variable")}const C=B.map(([,R])=>SB(R,A)),w=JSON.stringify(B.map(([R],i)=>[PQ(C[i]),I[i],R]));let G=lB.get(C[0]);const k=G?.get(w);if(k!==void 0)return k;const S=B.map(([R],i)=>bB(C[i],R,I[i]));if(G===void 0&&(G=new Map,lB.set(C[0],G)),G.set(w,S),G.size>128){const R=G.keys().next().value;R!==void 0&&G.delete(R)}return S}function xA(Q,A,B,E,I,C,w=0){const G={content:Q.slice(A,B),offset:A+w};if(I[0].role==="single"){const{styles:S,fg:R}=I[0],i=S[E];G.color=i?.color??R;let F=0;i?.italic===!0&&(F|=1),(i?.weight??0)>=600&&(F|=2),G.fontStyle=F}else G.htmlStyle=aB(I,E,C);const k=yA[E];return k!==0&&(G.type=k),G}function AQ(Q,A){let B=ZB.get(Q);B===void 0&&(B=new Map,ZB.set(Q,B));let E=B.get(A);return E===void 0&&(E=[],B.set(A,E)),E}function aB(Q,A,B){const E=AQ(Q,B);let I=E[A];if(I===void 0){if(Q[0].role==="light-dark")I=pQ(Q,A,B);else{I={};for(const{color:C,role:w,styles:G,fg:k}of Q){const S=G[A],R=w==="default";I[R?"color":B+C]=S?.color??k??"inherit",S?.italic===!0&&(I[R?"font-style":`${B}${C}-font-style`]="italic"),S!=null&&S.weight!==0&&(I[R?"font-weight":`${B}${C}-font-weight`]=String(S.weight))}}E[A]=I}return I}function VQ(Q,A){let B=eB.get(Q);B===void 0&&(B=new Map,eB.set(Q,B));const E=B.get(A);if(E!==void 0)return E??void 0;const I=Q.length;if(!(I<=255&&Q.every(J=>J.table!==void 0))){B.set(A,null);return}const C=Q.map(J=>J.role==="default"?new Uint8Array(0):XQ.encode(gA(`${A}${J.color}`))),w=32+16*I,G=w+384*I;let k=64,S=128,R=0;for(const{length:J}of C)k+=64+3*J,S+=48+2*J,R+=J;const i=new Uint8Array(G+R),F=new DataView(i.buffer);i[0]=I,i[1]=Q[0].role==="light-dark"?1:0,F.setUint32(4,w,!0),F.setUint32(8,k,!0),F.setUint32(12,S,!0),F.setUint32(16,fQ++,!0);let s=G;for(let J=0;J<I;J++){const t=32+16*J;F.setUint32(t,s,!0),F.setUint32(t+4,C[J].length,!0),F.setUint32(t+8,Q[J].role==="default"?1:0,!0),i.set(Q[J].table,w+384*J),i.set(C[J],s),s+=C[J].length}return B.set(A,i),i}function mQ(Q,A){let B=dB.get(Q);B===void 0&&(B=new Map,dB.set(Q,B));const E=B.get(A);if(E!==void 0)return E;const{fg:I,bg:C,rootStyle:w}=kB(Q,A),G=[`<pre class="highlights" style="${gA(w??`background-color:${C};color:${I}`)}"><code>`];for(let S=1;S<T.length;S++){const R=aB(Q,S,A);let i="";for(const F in R)i+=`${i===""?"":";"}${F}:${R[F]}`;G.push(`<span style="${gA(i)}">`)}const k=$B(G);return B.set(A,k),k}function pQ(Q,A,B){const[E,I]=Q,C=E.styles[A],w=I.styles[A],G=C?.color??E.fg??"currentcolor",k=w?.color??I.fg??"currentcolor",S={color:G===k?G:`light-dark(${G}, ${k})`},R=C?.italic===!0,i=w?.italic===!0;R&&i?S["font-style"]="italic":(R&&(S[`${B}light-font-style`]="italic"),i&&(S[`${B}dark-font-style`]="italic"));const F=C?.weight??0,s=w?.weight??0;return F!==0&&F===s?S["font-weight"]=String(F):(F!==0&&(S[`${B}light-font-weight`]=String(F)),s!==0&&(S[`${B}dark-font-weight`]=String(s))),S}function BQ(Q,A,B,E,I,C=0){const w=[],G=I??0,{styles:k,fg:S,role:R}=B[0],i=R==="single"?void 0:AQ(B,E);let F=0;for(let s=0;;s+=2){const J=s;for(;s<A.length&&A[s+1]!==4294967295;)s+=2;const t=s===J?F:A[s-2];let a;if(G>0&&t-F>=G)a=[xA(Q,F,t,0,B,E,C)];else{a=new Array((s-J)/2);let o=0;for(let n=J;n<s;n+=2){const Z=A[n];if(Z>F){const h=A[n+1];let L;if(i===void 0){const H=k[h];L={content:Q.slice(F,Z),offset:F+C,color:H?.color??S,fontStyle:(H?.italic===!0?1:0)|((H?.weight??0)>=600?2:0)}}else L={content:Q.slice(F,Z),offset:F+C,htmlStyle:i[h]??aB(B,h,E)};const y=yA[h];y!==0&&(L.type=y),a[o++]=L,F=Z}}a.length=o}if(w.push(a),s===A.length)break;F=A[s]}return w}function kB(Q,A){if(Q[0].role==="single")return{fg:Q[0].fg,bg:Q[0].bg,themeName:Q[0].name};const B=`highlights-themes ${Q.map(C=>C.name).join(" ")}`;if(Q[0].role==="light-dark"){const C=(w,G,k)=>{const S=w??k,R=G??k;return S===R?S:`light-dark(${S}, ${R})`};return{fg:C(Q[0].fg,Q[1].fg,"currentcolor"),bg:C(Q[0].bg,Q[1].bg,"transparent"),themeName:B}}const E=Q.map(C=>C.role==="default"?C.fg??"inherit":`${A}${C.color}:${C.fg??"inherit"}`).join(";"),I=Q.map(C=>C.role==="default"?C.bg??"inherit":`${A}${C.color}-bg:${C.bg??"inherit"}`).join(";");return{fg:E,bg:I,themeName:B,rootStyle:Q[0].role==="default"?void 0:`${E};${I}`}}const sB=1,QQ=2,EQ=4,IQ=8,CQ=16,gQ=32,rB=[0,sB,QQ,EQ,IQ,0,0,CQ,0,gQ],gB=[0,95,135,175,215,255],wB=/\x1b(?:\[([0-?]*)[ -/]*([@-~])|\][^\x07\x1b\n]*(?:\x07|\x1b\\)|[ -/]*[0-~])/y;var wQ=class{constructor(){x(this,"fg",-1);x(this,"bg",-1);x(this,"flags",0);x(this,"styles",new Map)}};function bA(Q){return String(Q).toLowerCase()==="ansi"}function RB(Q,A){if(A<16)return Q.ansi[A];let B=A&16777215;if(A<232){const E=A-16;B=gB[E/36|0]<<16|gB[(E/6|0)%6]<<8|gB[E%6]}else A<256&&(B=(8+(A-232)*10)*65793);return`#${B.toString(16).padStart(6,"0")}`}function UB(Q,A,B,E,I=new wQ,C=0){const w=[],G=E??0;let k=[],S,R,i,F=Q.indexOf("\x1B"),s=0;for(;;){const J=Q.indexOf(`
2
2
  `,s);let t=J<0?Q.length:J;J>s&&Q.charCodeAt(J-1)===13&&t--;const a=G>0&&t-s>=G;for(;s<t;){F>=0&&F<s&&(F=Q.indexOf("\x1B",s));let o=F>=0&&F<t?F:t,n=o,Z;if(o<t){wB.lastIndex=o;const h=wB.exec(Q);h===null?n=++o:(n=wB.lastIndex,h[2]==="m"&&!(h[1].charCodeAt(0)>=60)&&(Z=h[1]))}if(o>s&&a)R===void 0?(R=xA(Q,s,o,0,A,B,C),k.push(R)):R.content+=Q.slice(s,o);else if(o>s){if(S===void 0){const{fg:h,bg:L,flags:y}=I,H=`${h},${L},${y}`;if(S=I.styles.get(H),S===void 0){const m=((y&EQ)!==0?1:0)|((y&sB)!==0?2:0)|((y&IQ)!==0?4:0)|((y&gQ)!==0?8:0),z=A.map(e=>{let j=h<0?e.fg:RB(e,h),$=L<0?void 0:RB(e,L);return(y&CQ)!==0&&($=j,j=L<0?e.bg:RB(e,L)),(y&QQ)!==0&&j!==void 0&&(j=j.startsWith("#")?j.length===9?j.slice(0,7)+Math.round(parseInt(j.slice(7),16)/2).toString(16).padStart(2,"0"):`${j}80`:`color-mix(in srgb, ${j} 50%, transparent)`),[j,$]});if(A[0].role==="single"){const[e,j]=z[0];S=j===void 0?{color:e,fontStyle:m}:{color:e,bgColor:j,fontStyle:m}}else{const e=[];(m&1)!==0&&e.push(["font-style","italic"]),(m&2)!==0&&e.push(["font-weight","bold"]),(m&12)!==0&&e.push(["text-decoration",(m&12)===12?"underline line-through":(m&4)!==0?"underline":"line-through"]);const j={};if(A[0].role==="light-dark"){const[[$,pA],[qA,sA]]=z,wA=$??"currentcolor",HA=qA??"currentcolor";if(j.color=wA===HA?wA:`light-dark(${wA}, ${HA})`,pA!==void 0||sA!==void 0){const RA=pA??"transparent",uA=sA??"transparent";j["background-color"]=RA===uA?RA:`light-dark(${RA}, ${uA})`}for(const[RA,uA]of e)j[RA]=uA}else for(let $=0;$<A.length;$++){const[pA,qA]=z[$],sA=A[$].role==="default",wA=`${B}${A[$].color}`;j[sA?"color":wA]=pA??"inherit",qA!==void 0&&(j[sA?"background-color":`${wA}-bg`]=qA);for(const[HA,RA]of e)j[sA?HA:`${wA}-${HA}`]=RA}S={htmlStyle:j}}I.styles.set(H,S)}}R!==void 0&&i===S?R.content+=Q.slice(s,o):(R={content:Q.slice(s,o),offset:s+C,...S},i=S,k.push(R))}if(Z!==void 0){const h=Z.split(";");for(let L=0;L<h.length;L++){const y=Number(h[L]);if(y===0)I.fg=-1,I.bg=-1,I.flags=0;else if(y<10)I.flags|=rB[y]??0;else if(y>20&&y<30)I.flags&=~((rB[y-20]??0)|(y===22?sB:0));else if(y>=30&&y<38)I.fg=y-30;else if(y===39)I.fg=-1;else if(y>=40&&y<48)I.bg=y-40;else if(y===49)I.bg=-1;else if(y>=90&&y<98)I.fg=y-82;else if(y>=100&&y<108)I.bg=y-92;else if(y===38||y===48){const H=h[++L];let m=-1;if(H==="5"){const z=Number(h[++L]);Number.isInteger(z)&&z<256&&(m=z)}else if(H==="2"){const z=Number(h[L+1]),e=Number(h[L+2]),j=Number(h[L+3]);L+=3,z>=0&&e>=0&&j>=0&&(m=16777216|Math.min(z,255)<<16|Math.min(e,255)<<8|Math.min(j,255))}m>=0&&(y===38?I.fg=m:I.bg=m)}}S=void 0}s=n}if(w.push(k),J<0)return w;s=J+1,k=[],R=void 0}}const qQ={plain:0,plaintext:0,text:0,txt:0,abap:1,ada:2,adb:2,ads:2,"angular-html":3,apache:4,apacheconf:4,htaccess:4,apex:5,applescript:6,adoc:7,asciidoc:7,asm:8,assembly:8,mips:8,mipsasm:8,riscv:8,s:8,astro:9,awk:10,bash:11,sh:11,shell:11,shellscript:11,shellsession:11,zsh:11,bat:12,batch:12,batchfile:12,cmd:12,dos:12,bib:13,bibtex:13,bicep:14,blade:15,c:16,h:16,c3:17,clj:18,cljc:18,cljs:18,clojure:18,edn:18,cmake:19,cbl:20,cob:20,cobol:20,codeowners:21,codeql:22,ql:22,coffee:23,coffeescript:23,coq:24,rocq:24,"c++":25,cc:25,cpp:25,cxx:25,hh:25,hpp:25,hxx:25,"c#":26,cs:26,csharp:26,css:27,postcss:27,qss:27,csv:28,cu:29,cuda:29,cuh:29,cql:30,cypher:30,d:31,dart:32,dax:33,diff:34,"git-commit":34,"git-rebase":34,patch:34,containerfile:35,docker:35,dockerfile:35,dotenv:36,env:36,elixir:37,ex:37,exs:37,elm:38,erb:39,erl:40,erlang:40,hrl:40,fish:41,f03:42,f08:42,f90:42,f95:42,fortran:42,"fortran-free-form":42,f:43,f77:43,for:43,"fortran-fixed-form":43,"f#":44,fs:44,fsharp:44,fsi:44,fsx:44,gdresource:45,"godot-resource":45,tres:45,tscn:45,gd:46,gdscript:46,gdshader:47,gdshaderinc:47,"godot-shader":47,cucumber:48,feature:48,gherkin:48,gleam:49,comp:50,frag:50,geom:50,glsl:50,vert:50,gnuplot:51,gp:51,go:52,golang:52,gql:53,graphql:53,groq:54,gradle:55,groovy:55,gsh:55,gvy:55,gy:55,nextflow:55,"nextflow-groovy":55,nf:55,hack:56,haml:57,handlebars:58,hbs:58,mustache:58,haskell:59,hs:59,haxe:60,hx:60,hlsl:61,htm:62,html:62,"html-derivative":62,http:63,desktop:64,ini:64,properties:64,systemd:64,java:65,j2:66,jinja:66,jinja2:66,cjs:67,javascript:67,js:67,mjs:67,json:68,jsonc:68,json5:69,jsonl:70,jsonnet:71,libsonnet:71,jsx:72,jl:73,julia:73,just:74,justfile:74,kdl:75,kotlin:76,kt:76,kts:76,latex:77,tex:77,lean:78,lean4:78,less:79,liquid:80,cl:81,el:81,elisp:81,"emacs-lisp":81,lisp:81,lsp:81,racket:81,rkt:81,scheme:81,scm:81,llvm:82,log:83,lua:84,luau:85,make:86,makefile:86,mk:86,markdown:87,md:87,mdc:87,matlab:88,octave:88,mdx:89,mermaid:90,mmd:90,mbt:91,moonbit:91,nginx:92,nim:93,nix:94,m:95,mm:95,objc:95,objcpp:95,"objective-c":95,"objective-cpp":95,objectivec:95,ml:96,mli:96,ocaml:96,odin:97,openscad:98,scad:98,delphi:99,dpk:99,dpr:99,lpr:99,"object-pascal":99,objectpascal:99,pas:99,pascal:99,pp:99,perl:100,pl:100,pm:100,php:101,plsql:102,po:103,pot:103,potx:103,powerquery:104,pq:104,powershell:105,ps:105,ps1:105,psd1:105,psm1:105,pwsh:105,prisma:106,prolog:107,promql:108,proto:109,protobuf:109,jade:110,pug:110,puppet:111,py:112,python:112,qml:113,r:114,rscript:114,cshtml:115,razor:115,reg:116,rosmsg:117,restructuredtext:118,rst:118,rb:119,ruby:119,rs:120,rust:120,sas:121,sass:122,sbt:123,sc:123,scala:123,scss:124,shader:125,shaderlab:125,sol:126,solidity:126,sparql:127,sql:128,stata:129,styl:130,stylus:130,svelte:131,swift:132,tcl:133,hcl:134,terraform:134,tf:134,tfvars:134,toml:135,"angular-ts":136,cts:136,lit:136,mts:136,ts:136,"ts-tags":136,typescript:136,tsrx:137,tsv:138,tsx:139,ttl:140,turtle:140,twig:141,typ:142,typst:142,sv:143,svh:143,"system-verilog":143,systemverilog:143,verilog:143,vhd:144,vhdl:144,vim:145,viml:145,vimscript:145,vue:146,"vue-html":146,wasm:147,wat:147,wgsl:148,mathematica:149,wl:149,wolfram:149,svg:150,xml:150,xsd:150,xsl:150,xslt:150,yaml:151,yml:151,zig:152,zon:152},OA=new TextEncoder,RQ=new TextDecoder("utf-8",{ignoreBOM:!0}),$A=65536,TB=64,iA=81920,WB=[/^\p{ID_Start}$/u,/^[\u200C\u200D\p{ID_Continue}]$/u];let iB;const iQ=qQ;function QB(Q){const A=iQ[String(Q).toLowerCase()];if(typeof A!="number")throw new RangeError(`unknown lang: ${Q}`);return A}function uQ(Q){return typeof iQ[String(Q).toLowerCase()]=="number"||bA(Q)}var rA,TA,WA,XA,fA,P,DB,UA,JB,mB,IB=(mB=class{constructor(A){c(this,P);c(this,rA);c(this,TA);c(this,WA);c(this,XA);c(this,fA,new Uint8Array(0));x(this,"wasmModule");x(this,"instance");x(this,"memory");x(this,"buffer");x(this,"dv");x(this,"pageN");this.wasmModule=A;const B=new WebAssembly.Instance(A,{env:{is_id_start:(E,I)=>D(this,P,JB).call(this,E,I,0),is_id_continue:(E,I)=>D(this,P,JB).call(this,E,I,2)}});this.instance=B,this.memory=B.exports.memory,M(this,rA,B.exports.highlight),M(this,TA,B.exports.highlightStream),this.pageN=this.memory.buffer.byteLength/$A,this.buffer=new Uint8Array(this.memory.buffer),this.dv=new DataView(this.memory.buffer)}writeInput(A,B=0){if(typeof A=="string"){D(this,P,UA).call(this,B+A.length+96);let{read:E,written:I}=OA.encodeInto(A,this.buffer.subarray(iA+B,this.buffer.length-96));if(E<A.length){const C=A.slice(E);D(this,P,UA).call(this,B+I+C.length*3+96),I+=OA.encodeInto(C,this.buffer.subarray(iA+B+I,this.buffer.length-96)).written}return I}if(A instanceof ArrayBuffer&&(A=new Uint8Array(A)),!(A instanceof Uint8Array))throw new TypeError("input must be a string, Uint8Array, or ArrayBuffer");return D(this,P,UA).call(this,B+A.length+96),this.buffer.set(A,iA+B),A.length}codeToHtml(A,B){const E=B.cssVariablePrefix??"--hls-";if(bA(B.lang)){const i=lA(B),{fg:F,bg:s,rootStyle:J}=kB(i,E),t=yB(A),a=UB(t,i[0].role==="single"?[{...i[0],role:"default"}]:i,E);let o=`<pre class="highlights" style="${gA(J??(s===void 0?"":`background-color:${s};`)+(F===void 0?"":`color:${F}`))}"><code>`;for(let n=0,Z=-1;n<a.length;n++){n>0&&(Z=t.indexOf(`
3
3
  `,Z+1),o+=t.charCodeAt(Z-1)===13?`\r
4
4
  `:`
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/TB9r2XJy.js","/app/immutable/chunks/CLAmm_T1.js","/app/immutable/chunks/3SdAC2_C.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/UTM5G-w-.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/chunks/CcJmuwXr.js","/app/immutable/chunks/BwNrQXlF.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/D4ytz2EC.js","/app/immutable/chunks/B9vHutcJ.js","/app/immutable/chunks/Dms_DO28.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/BBFoj-dS.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/CMiilI_P.js","/app/immutable/chunks/B_QPRXJ5.js","/app/immutable/chunks/C2UL5Ler.js","/app/immutable/chunks/_UjuBCOJ.js","/app/immutable/chunks/DPttSllj.js","/app/immutable/chunks/BwH4Bvte.js","/app/immutable/chunks/BFgvMDua.js","/app/immutable/chunks/B1CKzIA2.js","/app/immutable/chunks/BGrimfDs.js","/app/immutable/chunks/Cu5e4npY.js","/app/immutable/chunks/Ctp-YfoS.js","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/BBWuirRW.js","/app/immutable/chunks/BbhtQrkZ.js","/app/immutable/chunks/B5aYN90J.js","/app/immutable/chunks/DONrLvvt.js","/app/immutable/chunks/qhd9g-fv.js","/app/immutable/chunks/yofTuS8P.js","/app/immutable/chunks/BjE6fvlI.js","/app/immutable/chunks/C4fj9uDh.js","/app/immutable/assets/register.CUyDR59i.css","/app/immutable/chunks/B0Z-1lwJ.js","/app/immutable/chunks/CQ409-Pj.js","/app/immutable/chunks/CgGsxeG7.js","/app/immutable/assets/terminal-manager.MhP_vFvK.css","/app/immutable/chunks/Be-9sO50.js","/app/immutable/chunks/BF_gPEg7.js","/app/immutable/chunks/CL3a4Hm1.js","/app/immutable/chunks/DQw0Iiac.js","/app/immutable/chunks/aZdb_rCN.js","/app/immutable/chunks/BPQFiQQc.js","/app/immutable/chunks/KnkAG0HD.js","/app/immutable/chunks/Cy--ZUaj.js","/app/immutable/chunks/DKwAaLwd.js"])))=>i.map(i=>d[i]);
2
- var F=Object.defineProperty;var $=(c,e,r)=>e in c?F(c,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[e]=r;var u=(c,e,r)=>$(c,typeof e!="symbol"?e+"":e,r);import{l as _}from"./ChTqQfQN.js";import{bm as b,_ as y}from"./CLAmm_T1.js";import{JH as k,CP as M}from"./B9vHutcJ.js";import{h as O}from"./TB9r2XJy.js";import{O as W}from"./DQw0Iiac.js";import{cP as L}from"./BQGIKN0g.js";import{u as x,b6 as U,bd as j}from"./BF_gPEg7.js";import{a as z}from"./TyAuxp07.js";const N={USE_DEFAULT_CONTEXT:{id:"use-default-context",type:"command",get label(){return b.chat_mentions_useDefaultContext_label()},get description(){return b.chat_mentions_useDefaultContext_description()},icon:"🔄",uri:"devspace://command/use-default-context"},CLEAR_CONTEXT:{id:"clear-context",type:"command",get label(){return b.chat_mentions_clearContext_label()},get description(){return b.chat_mentions_clearContext_description()},icon:"🗑️",uri:"devspace://command/clear-context"}};function ke(c){return"items"in c||"subgroups"in c}function B(c){if(!c||typeof c!="object")return!1;const e=c;return!(typeof e.id!="string"||typeof e.label!="string"||typeof e.uri!="string"||typeof e.type!="string"||e.subtitle!==void 0&&typeof e.subtitle!="string"||e.description!==void 0&&typeof e.description!="string"||e.icon!==void 0&&typeof e.icon!="string"||e.score!==void 0&&typeof e.score!="number"||e.group!==void 0&&typeof e.group!="string")}function g(c,e){if(!c||!e)return null;const r=c.toLowerCase(),s=e.toLowerCase();let t=0;for(let a=0;a<s.length&&t<r.length;a++)s[a]===r[t]&&t++;if(t!==r.length)return null;const i=K(r,s);return i?{score:V(r,s,i),matches:i}:null}function K(c,e){const r=[];let s=0;for(let t=0;t<c.length;t++){const i=c[t];let n=!1;for(let a=s;a<e.length;a++)if(e[a]===i){r.push(a),s=a+1,n=!0;break}if(!n)return null}return r}function V(c,e,r){let s=0;s+=1;let t=0;for(let l=1;l<r.length;l++)r[l]===r[l-1]+1&&(t+=.1);s+=t;let i=0;for(const l of r)(l===0||J(e,l))&&(i+=.15);s+=i,r[0]===0&&(s+=.2);const a=(r[r.length-1]-r[0])/e.length*.3;return s-=a,Math.min(s/2.5,1)}function J(c,e){if(e===0)return!0;const r=c[e],s=c[e-1];return r===r.toUpperCase()&&s===s.toLowerCase()||!/[a-z0-9]/i.test(s)}function H(c,e){if(!c||!e)return null;if(!c.includes("/"))return g(c,e);const r=c.split("/").filter(n=>n.length>0),s=e.split("/").filter(n=>n.length>0);if(r.length===0||s.length===0)return null;const t=G(r,s);return t?{score:X(r,s,t),matches:[]}:null}function G(c,e){const r=[];let s=0;for(let t=0;t<c.length;t++){const i=c[t];let n=!1;const a=t===c.length-1;for(let o=s;o<e.length;o++){const l=e[o];if(g(i,l)){r.push(o),s=o+1,n=!0;break}if(a){const p=l.split(".")[0],m=l.includes(".")?l.split(".").pop():"";if(m&&g(i,m)){r.push(o),s=o+1,n=!0;break}if(p&&g(i,p)){r.push(o),s=o+1,n=!0;break}}}if(!n)return null}return r}function X(c,e,r){let s=0;s+=1,s+=r.length*.2;let t=0;for(let n=1;n<r.length;n++)r[n]===r[n-1]+1&&(t+=.15);s+=t,r.length>0&&r[r.length-1]===e.length-1&&(s+=.3);for(let n=0;n<c.length&&n<r.length;n++){const a=c[n],o=e[r[n]];a.toLowerCase()===o.toLowerCase()&&(s+=.2)}return Math.min(s/3,1)}function R(c,e,r){return JSON.stringify({query:c,workspaceId:r.workspaceId,repoPath:r.repoPath,currentFile:r.currentFile,currentNote:r.currentNote,providers:e.map(s=>[s.id,s.getCacheKey?.(r)])})}const D="*",Ce=["member","note","agent","file","folder","script","terminal",D,"specialist"];function Q(c,e){if(e.length===0)return[...c].sort((t,i)=>(i.score??0)-(t.score??0));const r=new Map(e.map((t,i)=>[t,i])),s=r.get(D)??e.length;return c.map(t=>({candidate:t,rank:r.get(t.type)??s})).sort((t,i)=>t.rank-i.rank||(i.candidate.score??0)-(t.candidate.score??0)).map(({candidate:t})=>t)}function Y(c,e){const r=new Map;return c.filter(s=>{const t=r.get(s.type)??0;return r.set(s.type,t+1),t<e})}class Ie{constructor(e={}){u(this,"searchDebounceTimer",null);u(this,"currentAbortController",null);u(this,"cache",new Map);u(this,"config");u(this,"isSearching",!1);this.config={debounceMs:e.debounceMs??100,maxResults:e.maxResults??50,cacheMaxAge:e.cacheMaxAge??3e4,enableSemantic:e.enableSemantic??!1,enableLivePreview:e.enableLivePreview??!0,enableCollaboration:e.enableCollaboration??!1,typeOrder:e.typeOrder??[],maxResultsPerKind:e.maxResultsPerKind??20}}async search(e,r,s){this.cancelPendingSearch();const t=R(e,r,s),i=this.cache.get(t);if(i&&!this.isCacheExpired(i))return _.debug("[SearchService] Returning cached results for:",e),i.results;const n=new AbortController;this.currentAbortController=n;const a=n.signal;return new Promise((o,l)=>{this.isSearching=!0;let p=!1;const m=()=>{a.removeEventListener("abort",v),this.currentAbortController===n&&(this.currentAbortController=null,this.searchDebounceTimer=null,this.isSearching=!1)},w=f=>{p||(p=!0,m(),o(f))},d=f=>{p||(p=!0,m(),l(f))},v=()=>d(new DOMException("Search cancelled","AbortError"));a.addEventListener("abort",v,{once:!0});const h=async()=>{try{if(a.aborted){d(new DOMException("Search cancelled","AbortError"));return}_.debug("[SearchService] Searching with providers:",r.map(C=>C.id));const f=R(e,r,s),P=await Promise.all(r.map(C=>this.searchWithProvider(C,e,s,a)));if(a.aborted)return;if(f!==R(e,r,s)){w([]);return}const S=this.combineResults(P.flat()).filter(C=>B(C)),E=this.applyFuzzyMatching(e,S),A=Q(E,this.config.typeOrder),T=this.config.typeOrder.length>0?Y(A,this.config.maxResultsPerKind):A.slice(0,this.config.maxResults);this.cache.set(f,{results:T,timestamp:Date.now()}),_.debug(`[SearchService] Found ${T.length} results`),w(T)}catch(f){a.aborted?d(new DOMException("Search cancelled","AbortError")):(_.error("[SearchService] Search error:",f),d(f instanceof Error?f:new Error(String(f))))}};e?this.searchDebounceTimer=setTimeout(h,this.config.debounceMs):h()})}async searchWithProvider(e,r,s,t){try{const i={...s,signal:t},n=await e.search(r,i),a=e.scoreRelevance?.bind(e);return a?n.map(o=>({...o,score:a(o,s)})):n}catch(i){return t.aborted||_.error(`[SearchService] Provider ${e.id} search failed:`,i),[]}}combineResults(e){const r=new Set,s=[];for(const t of e){const i=`${t.type}:${t.uri}`;r.has(i)||(r.add(i),s.push(t))}return s}applyFuzzyMatching(e,r){if(!e||e.length===0)return r;const t=r.map(i=>{let n=0;const a=i.meta?.path||i.meta?.fullPath||(i.subtitle?`${i.subtitle}/${i.label}`:i.label);if(a){const l=H(e,a);l&&(n=Math.max(n,l.score*1.8))}const o=g(e,i.label);if(o&&(n=Math.max(n,o.score*1.5)),i.subtitle){const l=g(e,i.subtitle);l&&(n=Math.max(n,l.score))}if(i.description){const l=g(e,i.description);l&&(n=Math.max(n,l.score*.5))}return{...i,score:n>0?n:i.score??0}}).filter(i=>i.score>0);return t.length>0?t:r}cancelPendingSearch(){this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=null),this.currentAbortController&&(this.currentAbortController.abort(),this.currentAbortController=null)}isCacheExpired(e){return Date.now()-e.timestamp>this.config.cacheMaxAge}clearCache(){this.cache.clear()}isLoading(){return this.isSearching}destroy(){this.cancelPendingSearch(),this.clearCache()}}class Z{constructor(){u(this,"id","file");u(this,"triggers",["@file","@f"]);u(this,"default",!0);u(this,"supportsRanges",!0);u(this,"supportsLivePreview",!0);u(this,"recentFiles",new Set);u(this,"fileIconMap",{ts:"📘",tsx:"⚛️",js:"📜",jsx:"⚛️",svelte:"🔥",vue:"💚",py:"🐍",rs:"🦀",go:"🐹",java:"☕",cpp:"⚙️",c:"⚙️",h:"📎",md:"📝",json:"📋",yaml:"📋",yml:"📋",toml:"📋",xml:"📋",html:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sql:"🗃️",sh:"🖥️",bash:"🖥️",zsh:"🖥️",fish:"🖥️",dockerfile:"🐳",docker:"🐳",gitignore:"🚫",env:"🔐",lock:"🔒",test:"🧪",spec:"🧪"})}async search(e,r){_.debug("[FileProvider] Searching for:",{query:e,context:{workspaceId:r.workspaceId}});const s=r.workspaceId;if(!s)return[];try{const t=await O("search.fileNames",{workspaceId:s,pattern:e||"",limit:10}),n=(Array.isArray(t?.files)?t.files:[]).map(a=>{const o=a.split("/").pop()||a,l=o.split(".").pop()||"";return{id:`file-${a}`,label:o,type:"file",uri:`file:${a}`,description:a,subtitle:a,score:.5,meta:{path:a,fullPath:a,relativePath:a,extension:l,language:this.getLanguageFromExtension(l)}}});return this.deduplicateAndDistinguish(n)}catch(t){return _.error("[FileProvider] Search failed:",t),[]}}async searchRecent(e,r){if(!r.recentFiles||r.recentFiles.length===0)return[];const s=await Promise.all(r.recentFiles.filter(t=>e?g(e,t)!==null:!0).slice(0,3).map(t=>{const i=t.split("/").pop()||t,n=i.split(".").pop()||"";return this.fileToCandidate({path:t,name:i,extension:n})}));return s.forEach(t=>{this.recentFiles.add(t.uri)}),s}async searchContextual(e,r){return r.currentFile?[]:[]}async fileToCandidate(e){const r=this.getFileIcon(e.extension),s=e.path,t=this.formatPath(s);return{id:`file-${e.path}`,type:"file",label:e.name,subtitle:t,description:s,icon:r,uri:`devspace://file/${encodeURIComponent(e.path)}`,meta:{path:s,fullPath:e.path,lastModified:e.lastModified,size:e.size,language:e.language||this.getLanguageFromExtension(e.extension)}}}combineResults(...e){const r=new Set,s=[];for(const t of e)for(const i of t)r.has(i.uri)||(r.add(i.uri),s.push(i));return this.deduplicateAndDistinguish(s)}deduplicateAndDistinguish(e){const r=new Map;for(const t of e){const i=t.label;let n=r.get(i);n||(n=[],r.set(i,n)),n.push(t)}const s=[];for(const[t,i]of r.entries())if(i.length===1)s.push(i[0]);else{const n=this.distinguishDuplicates(i);s.push(...n)}return s}distinguishDuplicates(e){const r=e.map(t=>t.description||t.meta?.path||"");return e.map((t,i)=>{const n=r[i],a=r.filter((p,m)=>m!==i),o=n.split("/");let l="";for(let p=o.length;p>0;p--){const m=o.slice(-p).join("/");if(!a.some(d=>d.split("/").slice(-p).join("/")===m)||p===1){l=m;break}}return{...t,subtitle:l}})}groupResults(e){const r={recent:[],relevant:[],other:[]};for(const t of e)this.recentFiles.has(t.uri)?r.recent.push(t):(t.score??0)>.7?r.relevant.push(t):r.other.push(t);const s=[];return r.recent.length>0&&s.push(...r.recent.slice(0,3).map(t=>({...t,group:b.chat_mentions_recentFiles_group()}))),r.relevant.length>0&&s.push(...r.relevant.slice(0,5).map(t=>({...t,group:b.chat_mentions_mostRelevant_group()}))),r.other.length>0&&s.push(...r.other.slice(0,10).map(t=>({...t,group:b.chat_mentions_otherFiles_group()}))),s}scoreRelevance(e,r){let s=.5;if(this.recentFiles.has(e.uri)&&(s+=.2),r.currentFile&&e.meta?.path){const t=r.currentFile.substring(0,r.currentFile.lastIndexOf("/")),i=e.meta.path.substring(0,e.meta.path.lastIndexOf("/"));t===i&&(s+=.15)}return r.imports?.includes(e.meta?.path||"")&&(s+=.25),r.currentFile?.includes(".test.")&&e.meta?.path?.includes(".test.")&&(s+=.1),Math.min(s,1)}getGroups(){return[{id:"files-recent",label:b.chat_mentions_recentFiles_group(),icon:"🕐"},{id:"files-all",label:b.chat_mentions_allFiles_group(),icon:"📁"},{id:"files-tests",label:b.chat_mentions_testFiles_group(),icon:"🧪"}]}getFileIcon(e){return this.fileIconMap[e.toLowerCase()]||"📄"}formatPath(e){if(e.length>40){const r=e.split("/");if(r.length>2)return`.../${r.slice(-2).join("/")}`}return e}getLanguageFromExtension(e){return{ts:"typescript",tsx:"typescriptreact",js:"javascript",jsx:"javascriptreact",py:"python",rs:"rust",go:"go",java:"java",cpp:"cpp",c:"c",svelte:"svelte",vue:"vue",md:"markdown",json:"json",yaml:"yaml",yml:"yaml",html:"html",css:"css",scss:"scss",sql:"sql",sh:"shellscript"}[e.toLowerCase()]||"plaintext"}}class q{constructor(){u(this,"id","member")}getCacheKey(e){const r=k.state;return JSON.stringify({backendId:W.select(r),ownPrincipalId:r.presence.ownPrincipalId,members:e.workspaceId?L.select(r,e.workspaceId):[]})}async search(e,r){const{workspaceId:s}=r;if(!s)return[];const t=e.replace(/^@/,"").toLowerCase();return L.select(k.state,s).filter(i=>i.login.toLowerCase().includes(t)).map(i=>({id:`member-${i.principalId}`,type:"member",label:i.login,subtitle:i.identity?`${i.identity.provider==="github"?"GitHub":"GitLab"} · ${i.identity.host}`:void 0,description:i.displayName??void 0,icon:"👤",uri:`devspace://member/${encodeURIComponent(i.principalId)}?workspaceId=${encodeURIComponent(s)}`,score:.8,meta:{workspaceId:s,principalId:i.principalId,identity:i.identity,avatarUrl:i.avatarUrl??void 0}}))}}class ee{constructor(){u(this,"id","folder");u(this,"triggers",["@folder","@dir"])}async search(e,r){const s=r.workspaceId;if(!s)return[];try{const{backendRequest:t}=await y(async()=>{const{backendRequest:o}=await import("./TB9r2XJy.js").then(l=>l.j);return{backendRequest:o}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url),i=await t("search.fileNames",{workspaceId:s,pattern:e||"",limit:200}),n=Array.isArray(i?.files)?i.files:[],a=new Set;for(const o of n){const l=o.split("/");for(let p=1;p<l.length;p++)a.add(l.slice(0,p).join("/"))}return[...a].filter(o=>e?g(e,o.split("/").pop()||o)!==null:!0).slice(0,10).map(o=>({id:`folder-${o}`,type:"folder",label:o.split("/").pop()||o,description:o,icon:"📁",uri:`devspace://folder/${encodeURIComponent(o)}`,meta:{path:o,fullPath:o,relativePath:o}}))}catch(t){return _.debug("[FolderProvider] Failed to get folders:",t),[]}}}const te=10,re=.3;function se(c){const e=c.toLowerCase().split(/\s+/).filter(Boolean);return(r,s)=>{const t=r?g(c,r):null;if(t)return 1+t.score;if(s){const i=s.toLowerCase();if(e.every(n=>i.includes(n)))return re}return 0}}class ie{constructor(){u(this,"id","note");u(this,"triggers",["@note","@n"]);u(this,"supportsRanges",!0);u(this,"cachedNotes",[]);u(this,"lastCacheUpdate",0);u(this,"cacheTimeout",5e3)}async getSiblingWorkspaces(e){if(!e)return[];try{const[{store:r},{selectWorkspaceItems:s}]=await Promise.all([y(()=>import("./D4ytz2EC.js"),__vite__mapDeps([11,12,13,2,14,15,4,8,1,16,6,3,17,18]),import.meta.url),y(()=>import("./C2UL5Ler.js").then(n=>n.ef),__vite__mapDeps([19,6,4,1,2,12,13,14,15,8,16,3,20,21,22,23,7,9,24,0,5,10,25,26]),import.meta.url)]),t=s.select(r.state),i=t.find(n=>n.id===e);return!i||!i.repositoryPath?[]:t.filter(n=>n.id!==e&&n.repositoryPath===i.repositoryPath)}catch(r){return _.debug("[NoteProvider] Failed to get sibling workspaces:",r),[]}}async fetchNotesFromWorkspace(e,r){try{const[{store:s},{listSlimNotesRequested:t}]=await Promise.all([y(()=>import("./D4ytz2EC.js"),__vite__mapDeps([11,12,13,2,14,15,4,8,1,16,6,3,17,18]),import.meta.url),y(()=>import("./B9vHutcJ.js").then(n=>n.MP),__vite__mapDeps([12,13,2,14,15,4,8,1,16,6,3]),import.meta.url)]);return(await s.dispatch(t(e))).map(n=>({note:n,workspaceId:e,workspaceTitle:r}))}catch(s){_.debug(`[NoteProvider] Failed to fetch notes from workspace ${e}:`,s)}return[]}async search(e,r){if(!r.workspaceId)return[];const s=e.trim(),t=s?se(s):null;try{const i=await this.fetchNotesFromWorkspace(r.workspaceId),a=(await this.getSiblingWorkspaces(r.workspaceId)).map(d=>this.fetchNotesFromWorkspace(d.id,d.title)),l=(await Promise.all(a)).flat(),p=[...i,...l],w=(t?p.map(d=>({entry:d,score:t(d.note.title,d.note.content||d.note.contentPreview)})).filter(({score:d})=>d>0).sort((d,v)=>v.score-d.score):p.map(d=>({entry:d,score:void 0}))).slice(0,te).map(({entry:{note:d,workspaceId:v,workspaceTitle:h},score:f})=>{const P=v===r.workspaceId,I=P?void 0:b.chat_mentions_fromWorkspace_subtitle({workspace:h||v}),S=d.content||d.contentPreview;return{candidate:{id:d.id,type:"note",label:d.title||d.id||b.chat_mentions_untitledNote_label(),subtitle:I,description:S?`${S.substring(0,100)}...`:"",icon:"📝",uri:`devspace://note/${d.id}`,meta:{preview:S?.substring(0,200)||"",workspaceId:v,...P?{}:{isExternalLink:!0}}},score:f}});if(this.cachedNotes=w.map(({candidate:d})=>d),this.lastCacheUpdate=Date.now(),w.length>0)return w.map(({candidate:d,score:v})=>v!==void 0?{...d,score:v}:d)}catch(i){_.debug("[NoteProvider] Failed to fetch notes:",i)}return this.cachedNotes.length>0?t?this.cachedNotes.map(i=>({...i,score:t(i.label,i.meta?.preview)})).filter(i=>i.score>0).sort((i,n)=>n.score-i.score):this.cachedNotes:[]}getCachedNotes(){return Date.now()-this.lastCacheUpdate>this.cacheTimeout?[]:this.cachedNotes}}class ne{constructor(){u(this,"id","external");u(this,"triggers",["@docs","@external"])}async search(e,r){return[{id:"react-docs",label:"React Documentation",url:"https://react.dev",description:"Official React documentation"},{id:"mdn",label:"MDN Web Docs",url:"https://developer.mozilla.org",description:"Web technology documentation"},{id:"typescript",label:"TypeScript Handbook",url:"https://www.typescriptlang.org/docs/",description:"TypeScript documentation"}].filter(t=>!e||g(e,t.label)!==null).map(t=>({id:`external-${t.id}`,type:"external-source",label:t.label,description:t.description,icon:"📚",uri:`devspace://external/${t.id}`,meta:{url:t.url}}))}}class oe{constructor(){u(this,"id","rule");u(this,"triggers",["@rule","@intent"])}async search(e,r){return[{path:".intent/rules/cli.md",label:"CLI Rules"},{path:".intent/rules/frontend.md",label:"Frontend Rules"},{path:".intent/rules/python.md",label:"Python Rules"},{path:".intent/rules/sidecar.md",label:"Sidecar Rules"},{path:".intent/rules/systems.md",label:"Systems Rules"}].filter(t=>!e||g(e,t.label)!==null).map(t=>({id:t.path,type:"rule",label:t.label,subtitle:t.path,icon:"📚",uri:`devspace://rule/${encodeURIComponent(t.path)}`,meta:{path:t.path}}))}}class ae{constructor(){u(this,"id","task");u(this,"triggers",["@task","@todo"])}async search(e,r){return[{id:"task-1",label:"Implement authentication",status:"in_progress",assignee:"John Doe"},{id:"task-2",label:"Write tests",status:"not_started",assignee:"Jane Smith"},{id:"task-3",label:"Deploy to production",status:"completed",assignee:"Bob Johnson"}].filter(t=>!e||g(e,t.label)!==null).map(t=>({id:`task-${t.id}`,type:"task",label:t.label,subtitle:`${t.status} • ${t.assignee}`,icon:"📋",uri:`devspace://task/${t.id}`,meta:{taskStatus:t.status,assignee:t.assignee}}))}}class ce{constructor(){u(this,"id","personality");u(this,"triggers",["@personality","@persona"]);u(this,"personalities",[{id:"auggie-personality-agent-default",name:"Agent Auggie",description:"Default helpful AI assistant",icon:"🤖",temperature:.7,model:"default",promptToken:"auggie-personality-agent-default"},{id:"auggie-personality-prototyper",name:"Prototyper Auggie",description:"Specialized in rapid prototyping",icon:"⚡",temperature:.7,model:"default",promptToken:"auggie-personality-prototyper"},{id:"auggie-personality-brainstorm",name:"Brainstorm Auggie",description:"Creative ideation and exploration",icon:"💡",temperature:.7,model:"default",promptToken:"auggie-personality-brainstorm"},{id:"auggie-personality-reviewer",name:"Reviewer Auggie",description:"Code review and feedback",icon:"🔍",temperature:.7,model:"default",promptToken:"auggie-personality-reviewer"}])}async search(e,r){return this.personalities.filter(s=>!e||g(e,s.name)!==null).map(s=>({id:s.id,type:"personality",label:s.name,subtitle:`${s.model}`,description:s.description,icon:s.icon,uri:`devspace://personality/${s.id}`,meta:{promptToken:s.promptToken}}))}}class le{constructor(){u(this,"id","command");u(this,"triggers",["@cmd","@command"])}async search(e,r){return[N.USE_DEFAULT_CONTEXT,N.CLEAR_CONTEXT].filter(t=>!e||t.label.toLowerCase().includes(e.toLowerCase()))}}class ue{constructor(){u(this,"id","terminal");u(this,"triggers",["@terminal","@term"])}async search(e,r){try{const{terminalManager:s}=await y(async()=>{const{terminalManager:h}=await import("./Ctp-YfoS.js").then(f=>f.b);return{terminalManager:h}},__vite__mapDeps([27,2,1,28,29,3,4,30,31,12,13,14,15,8,16,6,0,5,7,9,10,32,20,33,34,35,36,37,38,39,25,40,41]),import.meta.url),{selectTerminals:t,selectTerminalDisplayName:i}=await y(async()=>{const{selectTerminals:h,selectTerminalDisplayName:f}=await import("./CgGsxeG7.js").then(P=>P.i);return{selectTerminals:h,selectTerminalDisplayName:f}},__vite__mapDeps([40,12,13,2,14,15,4,8,1,16,6,3]),import.meta.url),a=k.state;if(!r.workspaceId)return[];const o=t.select(a,r.workspaceId),l=s.loadTerminalMetadata(r.workspaceId),p=new Set,m=[];for(const h of o)p.add(h.id),m.push({id:h.id,name:i.select(a,r.workspaceId,h.id)});for(const h of l)p.has(h.terminalId)||(p.add(h.terminalId),m.push({id:h.terminalId,name:h.title||b.terminal_quakeOverlay_terminal_fallback()}));if(m.length===0)return[];const d=e?["terminal","term"].some(h=>h.startsWith(e.toLowerCase())||e.toLowerCase().startsWith(h)):!1;return(e&&!d?m.filter(h=>g(e,h.name)!==null):m).slice(0,10).map((h,f)=>({id:h.id,type:"terminal",label:h.name,subtitle:b.chat_mentions_terminalIndex_subtitle({index:f+1}),description:b.chat_mentions_terminalOutput_description(),icon:"💻",uri:`devspace://terminal/${encodeURIComponent(h.id)}`,meta:{workspaceId:r.workspaceId}}))}catch(s){return _.debug("[TerminalProvider] Failed to get terminals:",s),[]}}}class de{constructor(){u(this,"id","script");u(this,"triggers",["@script","@scripts"])}async search(e,r){try{const{selectScriptEntries:s}=await y(async()=>{const{selectScriptEntries:o}=await import("./Be-9sO50.js");return{selectScriptEntries:o}},__vite__mapDeps([42,12,13,2,14,15,4,8,1,16,6,3,43,19,20,21,22,23,7,9,24,0,5,10,25,26,44,29,28,45,46,47,48,31,49,50]),import.meta.url);if(!r.workspaceId)return[];const t=s.select(k.state,r.workspaceId);if(t.length===0)return[];const n=e?["script","scripts"].some(o=>o.startsWith(e.toLowerCase())||e.toLowerCase().startsWith(o)):!1;return(e&&!n?t.filter(o=>g(e,o.name)!==null||g(e,M(o))!==null):t).slice(0,10).map(o=>{const l=o.runtime.status,p=x(l)?b.chat_mentions_scriptRunning_label():l==="exited"?b.chat_mentions_scriptExited_label():b.chat_mentions_scriptIdle_label();return{id:o.id,type:"script",label:o.name,subtitle:`${p} · ${M(o)}`,description:b.chat_mentions_scriptOutput_description(),icon:"▶️",uri:`devspace://script/${encodeURIComponent(o.id)}`,meta:{workspaceId:r.workspaceId,command:o.command,status:x(l)?"ok":l==="exited"?"warning":void 0}}})}catch(s){return _.debug("[ScriptProvider] Failed to get scripts:",s),[]}}}class pe{constructor(){u(this,"id","specialist");u(this,"triggers",["@specialist","@spec"])}async search(e,r){try{const s=j.select(k.state);return!s||s.length===0?[]:s.filter(t=>e?g(e,t.name)!==null||g(e,t.id)!==null||g(e,t.description)!==null||g(e,"specialist")!==null:!0).map(t=>({id:`specialist-${t.id}`,type:"specialist",label:t.name,subtitle:t.description,description:t.description,icon:"👤",uri:`devspace://specialist/${encodeURIComponent(t.id)}`,group:"Specialists",score:.8,meta:{promptToken:`specialist/${t.id}`}})).slice(0,10)}catch(s){return _.debug("[SpecialistProvider] Failed to get specialists:",s),[]}}}class he{constructor(){u(this,"id","agent");u(this,"triggers",["@agent"])}async search(e,r){try{const{selectAllWorkspaceAgents:s}=await y(async()=>{const{selectAllWorkspaceAgents:a}=await import("./C2UL5Ler.js").then(o=>o.ec);return{selectAllWorkspaceAgents:a}},__vite__mapDeps([19,6,4,1,2,12,13,14,15,8,16,3,20,21,22,23,7,9,24,0,5,10,25,26]),import.meta.url),t=r.workspaceId;if(!t)return[];const i=s.select(k.state,t);if(i.length===0)return[];const n=[];for(const a of i){const o=a.id,l=a.name||o,p=a.metadata?.specialist||"";let m=a.metadata?.specialistName||"";if(p&&!m){const f=U.select(k.state,p);f&&(m=f.name)}if(e){const f=g(e,l)!==null,P=g(e,"agent")!==null,I=m&&g(e,m)!==null,S=p&&g(e,p)!==null;if(!f&&!P&&!I&&!S)continue}const w=a.isStreaming?"responding":a.status||"active",d=[];m?d.push(m):d.push("Agent"),d.push(w);const v=a.messages?.length||0;v>0&&d.push(`${v} msg${v!==1?"s":""}`);const h=a.lastActivity||a.lastModified;h&&!a.isStreaming&&d.push(z(new Date(h))),n.push({id:o,type:"agent",label:l,subtitle:d.join(" · "),description:m?b.chat_mentions_specialistAgentInWorkspace_description({specialist:m}):b.chat_mentions_agentInWorkspace_description(),icon:"🤖",uri:`devspace://agent/${encodeURIComponent(o)}`,group:b.chat_mentions_agents_group(),score:.7,meta:{workspaceId:t}})}return n.slice(0,10)}catch(s){return _.debug("[AgentProvider] Failed to get agents:",s),[]}}}class me{constructor(){u(this,"providers",new Map);u(this,"defaultProviders",[]);this.register(new Z),this.register(new ee),this.register(new ie),this.register(new ne),this.register(new oe),this.register(new ae),this.register(new ce),this.register(new le),this.register(new ue),this.register(new de),this.register(new he),this.register(new pe),this.register(new q),this.defaultProviders=["file","folder","note","terminal","script","agent","specialist","member"]}register(e){this.providers.set(e.id,e),_.debug("[ProviderRegistry] Registered provider:",e.id)}unregister(e){this.providers.delete(e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getDefault(){return this.defaultProviders.map(e=>this.providers.get(e)).filter(Boolean)}getByTrigger(e){return Array.from(this.providers.values()).filter(r=>r.triggers?.includes(e))}async searchAll(e,r){const s=e.startsWith("@")?this.getByTrigger(e.split(" ")[0]):this.getDefault();return(await Promise.all(s.map(i=>i.search(e,r)))).flat()}}const Te=new me;export{Ie as D,Ce as M,Q as a,ke as i,Te as p,R as s};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["/app/immutable/chunks/TB9r2XJy.js","/app/immutable/chunks/CLAmm_T1.js","/app/immutable/chunks/3SdAC2_C.js","/app/immutable/chunks/Bqd7fdCF.js","/app/immutable/chunks/CIyUrgF0.js","/app/immutable/chunks/UTM5G-w-.js","/app/immutable/chunks/uXuxG9cN.js","/app/immutable/chunks/CcJmuwXr.js","/app/immutable/chunks/BwNrQXlF.js","/app/immutable/assets/spinner.D_TRo5Hy.css","/app/immutable/assets/button.-yaUNjRS.css","/app/immutable/chunks/D4ytz2EC.js","/app/immutable/chunks/B9vHutcJ.js","/app/immutable/chunks/Dms_DO28.js","/app/immutable/chunks/ChTqQfQN.js","/app/immutable/chunks/BBFoj-dS.js","/app/immutable/chunks/DxwfiAWm.js","/app/immutable/chunks/CMiilI_P.js","/app/immutable/chunks/B_QPRXJ5.js","/app/immutable/chunks/C2UL5Ler.js","/app/immutable/chunks/_UjuBCOJ.js","/app/immutable/chunks/DPttSllj.js","/app/immutable/chunks/BwH4Bvte.js","/app/immutable/chunks/BFgvMDua.js","/app/immutable/chunks/B1CKzIA2.js","/app/immutable/chunks/BGrimfDs.js","/app/immutable/chunks/Cu5e4npY.js","/app/immutable/chunks/Ctp-YfoS.js","/app/immutable/chunks/BdWqymET.js","/app/immutable/chunks/BBWuirRW.js","/app/immutable/chunks/BbhtQrkZ.js","/app/immutable/chunks/B5aYN90J.js","/app/immutable/chunks/DONrLvvt.js","/app/immutable/chunks/qhd9g-fv.js","/app/immutable/chunks/yofTuS8P.js","/app/immutable/chunks/BjE6fvlI.js","/app/immutable/chunks/C4fj9uDh.js","/app/immutable/assets/register.CUyDR59i.css","/app/immutable/chunks/B0Z-1lwJ.js","/app/immutable/chunks/CQ409-Pj.js","/app/immutable/chunks/CgGsxeG7.js","/app/immutable/assets/terminal-manager.MhP_vFvK.css","/app/immutable/chunks/Cg8YmoXY.js","/app/immutable/chunks/BwA1d-u1.js","/app/immutable/chunks/CL3a4Hm1.js","/app/immutable/chunks/DQw0Iiac.js","/app/immutable/chunks/aZdb_rCN.js","/app/immutable/chunks/BPQFiQQc.js","/app/immutable/chunks/KnkAG0HD.js","/app/immutable/chunks/ByH7GIW_.js","/app/immutable/chunks/DKwAaLwd.js"])))=>i.map(i=>d[i]);
2
+ var F=Object.defineProperty;var $=(c,e,r)=>e in c?F(c,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[e]=r;var u=(c,e,r)=>$(c,typeof e!="symbol"?e+"":e,r);import{l as _}from"./ChTqQfQN.js";import{bm as b,_ as y}from"./CLAmm_T1.js";import{JH as k,CP as M}from"./B9vHutcJ.js";import{h as O}from"./TB9r2XJy.js";import{O as W}from"./DQw0Iiac.js";import{cP as L}from"./DBb8bRDA.js";import{u as x,b6 as U,bd as j}from"./BwA1d-u1.js";import{a as z}from"./TyAuxp07.js";const N={USE_DEFAULT_CONTEXT:{id:"use-default-context",type:"command",get label(){return b.chat_mentions_useDefaultContext_label()},get description(){return b.chat_mentions_useDefaultContext_description()},icon:"🔄",uri:"devspace://command/use-default-context"},CLEAR_CONTEXT:{id:"clear-context",type:"command",get label(){return b.chat_mentions_clearContext_label()},get description(){return b.chat_mentions_clearContext_description()},icon:"🗑️",uri:"devspace://command/clear-context"}};function ke(c){return"items"in c||"subgroups"in c}function B(c){if(!c||typeof c!="object")return!1;const e=c;return!(typeof e.id!="string"||typeof e.label!="string"||typeof e.uri!="string"||typeof e.type!="string"||e.subtitle!==void 0&&typeof e.subtitle!="string"||e.description!==void 0&&typeof e.description!="string"||e.icon!==void 0&&typeof e.icon!="string"||e.score!==void 0&&typeof e.score!="number"||e.group!==void 0&&typeof e.group!="string")}function g(c,e){if(!c||!e)return null;const r=c.toLowerCase(),s=e.toLowerCase();let t=0;for(let a=0;a<s.length&&t<r.length;a++)s[a]===r[t]&&t++;if(t!==r.length)return null;const i=K(r,s);return i?{score:V(r,s,i),matches:i}:null}function K(c,e){const r=[];let s=0;for(let t=0;t<c.length;t++){const i=c[t];let n=!1;for(let a=s;a<e.length;a++)if(e[a]===i){r.push(a),s=a+1,n=!0;break}if(!n)return null}return r}function V(c,e,r){let s=0;s+=1;let t=0;for(let l=1;l<r.length;l++)r[l]===r[l-1]+1&&(t+=.1);s+=t;let i=0;for(const l of r)(l===0||J(e,l))&&(i+=.15);s+=i,r[0]===0&&(s+=.2);const a=(r[r.length-1]-r[0])/e.length*.3;return s-=a,Math.min(s/2.5,1)}function J(c,e){if(e===0)return!0;const r=c[e],s=c[e-1];return r===r.toUpperCase()&&s===s.toLowerCase()||!/[a-z0-9]/i.test(s)}function H(c,e){if(!c||!e)return null;if(!c.includes("/"))return g(c,e);const r=c.split("/").filter(n=>n.length>0),s=e.split("/").filter(n=>n.length>0);if(r.length===0||s.length===0)return null;const t=G(r,s);return t?{score:X(r,s,t),matches:[]}:null}function G(c,e){const r=[];let s=0;for(let t=0;t<c.length;t++){const i=c[t];let n=!1;const a=t===c.length-1;for(let o=s;o<e.length;o++){const l=e[o];if(g(i,l)){r.push(o),s=o+1,n=!0;break}if(a){const p=l.split(".")[0],m=l.includes(".")?l.split(".").pop():"";if(m&&g(i,m)){r.push(o),s=o+1,n=!0;break}if(p&&g(i,p)){r.push(o),s=o+1,n=!0;break}}}if(!n)return null}return r}function X(c,e,r){let s=0;s+=1,s+=r.length*.2;let t=0;for(let n=1;n<r.length;n++)r[n]===r[n-1]+1&&(t+=.15);s+=t,r.length>0&&r[r.length-1]===e.length-1&&(s+=.3);for(let n=0;n<c.length&&n<r.length;n++){const a=c[n],o=e[r[n]];a.toLowerCase()===o.toLowerCase()&&(s+=.2)}return Math.min(s/3,1)}function R(c,e,r){return JSON.stringify({query:c,workspaceId:r.workspaceId,repoPath:r.repoPath,currentFile:r.currentFile,currentNote:r.currentNote,providers:e.map(s=>[s.id,s.getCacheKey?.(r)])})}const D="*",Ce=["member","note","agent","file","folder","script","terminal",D,"specialist"];function Q(c,e){if(e.length===0)return[...c].sort((t,i)=>(i.score??0)-(t.score??0));const r=new Map(e.map((t,i)=>[t,i])),s=r.get(D)??e.length;return c.map(t=>({candidate:t,rank:r.get(t.type)??s})).sort((t,i)=>t.rank-i.rank||(i.candidate.score??0)-(t.candidate.score??0)).map(({candidate:t})=>t)}function Y(c,e){const r=new Map;return c.filter(s=>{const t=r.get(s.type)??0;return r.set(s.type,t+1),t<e})}class Ie{constructor(e={}){u(this,"searchDebounceTimer",null);u(this,"currentAbortController",null);u(this,"cache",new Map);u(this,"config");u(this,"isSearching",!1);this.config={debounceMs:e.debounceMs??100,maxResults:e.maxResults??50,cacheMaxAge:e.cacheMaxAge??3e4,enableSemantic:e.enableSemantic??!1,enableLivePreview:e.enableLivePreview??!0,enableCollaboration:e.enableCollaboration??!1,typeOrder:e.typeOrder??[],maxResultsPerKind:e.maxResultsPerKind??20}}async search(e,r,s){this.cancelPendingSearch();const t=R(e,r,s),i=this.cache.get(t);if(i&&!this.isCacheExpired(i))return _.debug("[SearchService] Returning cached results for:",e),i.results;const n=new AbortController;this.currentAbortController=n;const a=n.signal;return new Promise((o,l)=>{this.isSearching=!0;let p=!1;const m=()=>{a.removeEventListener("abort",v),this.currentAbortController===n&&(this.currentAbortController=null,this.searchDebounceTimer=null,this.isSearching=!1)},w=f=>{p||(p=!0,m(),o(f))},d=f=>{p||(p=!0,m(),l(f))},v=()=>d(new DOMException("Search cancelled","AbortError"));a.addEventListener("abort",v,{once:!0});const h=async()=>{try{if(a.aborted){d(new DOMException("Search cancelled","AbortError"));return}_.debug("[SearchService] Searching with providers:",r.map(C=>C.id));const f=R(e,r,s),P=await Promise.all(r.map(C=>this.searchWithProvider(C,e,s,a)));if(a.aborted)return;if(f!==R(e,r,s)){w([]);return}const S=this.combineResults(P.flat()).filter(C=>B(C)),E=this.applyFuzzyMatching(e,S),A=Q(E,this.config.typeOrder),T=this.config.typeOrder.length>0?Y(A,this.config.maxResultsPerKind):A.slice(0,this.config.maxResults);this.cache.set(f,{results:T,timestamp:Date.now()}),_.debug(`[SearchService] Found ${T.length} results`),w(T)}catch(f){a.aborted?d(new DOMException("Search cancelled","AbortError")):(_.error("[SearchService] Search error:",f),d(f instanceof Error?f:new Error(String(f))))}};e?this.searchDebounceTimer=setTimeout(h,this.config.debounceMs):h()})}async searchWithProvider(e,r,s,t){try{const i={...s,signal:t},n=await e.search(r,i),a=e.scoreRelevance?.bind(e);return a?n.map(o=>({...o,score:a(o,s)})):n}catch(i){return t.aborted||_.error(`[SearchService] Provider ${e.id} search failed:`,i),[]}}combineResults(e){const r=new Set,s=[];for(const t of e){const i=`${t.type}:${t.uri}`;r.has(i)||(r.add(i),s.push(t))}return s}applyFuzzyMatching(e,r){if(!e||e.length===0)return r;const t=r.map(i=>{let n=0;const a=i.meta?.path||i.meta?.fullPath||(i.subtitle?`${i.subtitle}/${i.label}`:i.label);if(a){const l=H(e,a);l&&(n=Math.max(n,l.score*1.8))}const o=g(e,i.label);if(o&&(n=Math.max(n,o.score*1.5)),i.subtitle){const l=g(e,i.subtitle);l&&(n=Math.max(n,l.score))}if(i.description){const l=g(e,i.description);l&&(n=Math.max(n,l.score*.5))}return{...i,score:n>0?n:i.score??0}}).filter(i=>i.score>0);return t.length>0?t:r}cancelPendingSearch(){this.searchDebounceTimer&&(clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=null),this.currentAbortController&&(this.currentAbortController.abort(),this.currentAbortController=null)}isCacheExpired(e){return Date.now()-e.timestamp>this.config.cacheMaxAge}clearCache(){this.cache.clear()}isLoading(){return this.isSearching}destroy(){this.cancelPendingSearch(),this.clearCache()}}class Z{constructor(){u(this,"id","file");u(this,"triggers",["@file","@f"]);u(this,"default",!0);u(this,"supportsRanges",!0);u(this,"supportsLivePreview",!0);u(this,"recentFiles",new Set);u(this,"fileIconMap",{ts:"📘",tsx:"⚛️",js:"📜",jsx:"⚛️",svelte:"🔥",vue:"💚",py:"🐍",rs:"🦀",go:"🐹",java:"☕",cpp:"⚙️",c:"⚙️",h:"📎",md:"📝",json:"📋",yaml:"📋",yml:"📋",toml:"📋",xml:"📋",html:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sql:"🗃️",sh:"🖥️",bash:"🖥️",zsh:"🖥️",fish:"🖥️",dockerfile:"🐳",docker:"🐳",gitignore:"🚫",env:"🔐",lock:"🔒",test:"🧪",spec:"🧪"})}async search(e,r){_.debug("[FileProvider] Searching for:",{query:e,context:{workspaceId:r.workspaceId}});const s=r.workspaceId;if(!s)return[];try{const t=await O("search.fileNames",{workspaceId:s,pattern:e||"",limit:10}),n=(Array.isArray(t?.files)?t.files:[]).map(a=>{const o=a.split("/").pop()||a,l=o.split(".").pop()||"";return{id:`file-${a}`,label:o,type:"file",uri:`file:${a}`,description:a,subtitle:a,score:.5,meta:{path:a,fullPath:a,relativePath:a,extension:l,language:this.getLanguageFromExtension(l)}}});return this.deduplicateAndDistinguish(n)}catch(t){return _.error("[FileProvider] Search failed:",t),[]}}async searchRecent(e,r){if(!r.recentFiles||r.recentFiles.length===0)return[];const s=await Promise.all(r.recentFiles.filter(t=>e?g(e,t)!==null:!0).slice(0,3).map(t=>{const i=t.split("/").pop()||t,n=i.split(".").pop()||"";return this.fileToCandidate({path:t,name:i,extension:n})}));return s.forEach(t=>{this.recentFiles.add(t.uri)}),s}async searchContextual(e,r){return r.currentFile?[]:[]}async fileToCandidate(e){const r=this.getFileIcon(e.extension),s=e.path,t=this.formatPath(s);return{id:`file-${e.path}`,type:"file",label:e.name,subtitle:t,description:s,icon:r,uri:`devspace://file/${encodeURIComponent(e.path)}`,meta:{path:s,fullPath:e.path,lastModified:e.lastModified,size:e.size,language:e.language||this.getLanguageFromExtension(e.extension)}}}combineResults(...e){const r=new Set,s=[];for(const t of e)for(const i of t)r.has(i.uri)||(r.add(i.uri),s.push(i));return this.deduplicateAndDistinguish(s)}deduplicateAndDistinguish(e){const r=new Map;for(const t of e){const i=t.label;let n=r.get(i);n||(n=[],r.set(i,n)),n.push(t)}const s=[];for(const[t,i]of r.entries())if(i.length===1)s.push(i[0]);else{const n=this.distinguishDuplicates(i);s.push(...n)}return s}distinguishDuplicates(e){const r=e.map(t=>t.description||t.meta?.path||"");return e.map((t,i)=>{const n=r[i],a=r.filter((p,m)=>m!==i),o=n.split("/");let l="";for(let p=o.length;p>0;p--){const m=o.slice(-p).join("/");if(!a.some(d=>d.split("/").slice(-p).join("/")===m)||p===1){l=m;break}}return{...t,subtitle:l}})}groupResults(e){const r={recent:[],relevant:[],other:[]};for(const t of e)this.recentFiles.has(t.uri)?r.recent.push(t):(t.score??0)>.7?r.relevant.push(t):r.other.push(t);const s=[];return r.recent.length>0&&s.push(...r.recent.slice(0,3).map(t=>({...t,group:b.chat_mentions_recentFiles_group()}))),r.relevant.length>0&&s.push(...r.relevant.slice(0,5).map(t=>({...t,group:b.chat_mentions_mostRelevant_group()}))),r.other.length>0&&s.push(...r.other.slice(0,10).map(t=>({...t,group:b.chat_mentions_otherFiles_group()}))),s}scoreRelevance(e,r){let s=.5;if(this.recentFiles.has(e.uri)&&(s+=.2),r.currentFile&&e.meta?.path){const t=r.currentFile.substring(0,r.currentFile.lastIndexOf("/")),i=e.meta.path.substring(0,e.meta.path.lastIndexOf("/"));t===i&&(s+=.15)}return r.imports?.includes(e.meta?.path||"")&&(s+=.25),r.currentFile?.includes(".test.")&&e.meta?.path?.includes(".test.")&&(s+=.1),Math.min(s,1)}getGroups(){return[{id:"files-recent",label:b.chat_mentions_recentFiles_group(),icon:"🕐"},{id:"files-all",label:b.chat_mentions_allFiles_group(),icon:"📁"},{id:"files-tests",label:b.chat_mentions_testFiles_group(),icon:"🧪"}]}getFileIcon(e){return this.fileIconMap[e.toLowerCase()]||"📄"}formatPath(e){if(e.length>40){const r=e.split("/");if(r.length>2)return`.../${r.slice(-2).join("/")}`}return e}getLanguageFromExtension(e){return{ts:"typescript",tsx:"typescriptreact",js:"javascript",jsx:"javascriptreact",py:"python",rs:"rust",go:"go",java:"java",cpp:"cpp",c:"c",svelte:"svelte",vue:"vue",md:"markdown",json:"json",yaml:"yaml",yml:"yaml",html:"html",css:"css",scss:"scss",sql:"sql",sh:"shellscript"}[e.toLowerCase()]||"plaintext"}}class q{constructor(){u(this,"id","member")}getCacheKey(e){const r=k.state;return JSON.stringify({backendId:W.select(r),ownPrincipalId:r.presence.ownPrincipalId,members:e.workspaceId?L.select(r,e.workspaceId):[]})}async search(e,r){const{workspaceId:s}=r;if(!s)return[];const t=e.replace(/^@/,"").toLowerCase();return L.select(k.state,s).filter(i=>i.login.toLowerCase().includes(t)).map(i=>({id:`member-${i.principalId}`,type:"member",label:i.login,subtitle:i.identity?`${i.identity.provider==="github"?"GitHub":"GitLab"} · ${i.identity.host}`:void 0,description:i.displayName??void 0,icon:"👤",uri:`devspace://member/${encodeURIComponent(i.principalId)}?workspaceId=${encodeURIComponent(s)}`,score:.8,meta:{workspaceId:s,principalId:i.principalId,identity:i.identity,avatarUrl:i.avatarUrl??void 0}}))}}class ee{constructor(){u(this,"id","folder");u(this,"triggers",["@folder","@dir"])}async search(e,r){const s=r.workspaceId;if(!s)return[];try{const{backendRequest:t}=await y(async()=>{const{backendRequest:o}=await import("./TB9r2XJy.js").then(l=>l.j);return{backendRequest:o}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url),i=await t("search.fileNames",{workspaceId:s,pattern:e||"",limit:200}),n=Array.isArray(i?.files)?i.files:[],a=new Set;for(const o of n){const l=o.split("/");for(let p=1;p<l.length;p++)a.add(l.slice(0,p).join("/"))}return[...a].filter(o=>e?g(e,o.split("/").pop()||o)!==null:!0).slice(0,10).map(o=>({id:`folder-${o}`,type:"folder",label:o.split("/").pop()||o,description:o,icon:"📁",uri:`devspace://folder/${encodeURIComponent(o)}`,meta:{path:o,fullPath:o,relativePath:o}}))}catch(t){return _.debug("[FolderProvider] Failed to get folders:",t),[]}}}const te=10,re=.3;function se(c){const e=c.toLowerCase().split(/\s+/).filter(Boolean);return(r,s)=>{const t=r?g(c,r):null;if(t)return 1+t.score;if(s){const i=s.toLowerCase();if(e.every(n=>i.includes(n)))return re}return 0}}class ie{constructor(){u(this,"id","note");u(this,"triggers",["@note","@n"]);u(this,"supportsRanges",!0);u(this,"cachedNotes",[]);u(this,"lastCacheUpdate",0);u(this,"cacheTimeout",5e3)}async getSiblingWorkspaces(e){if(!e)return[];try{const[{store:r},{selectWorkspaceItems:s}]=await Promise.all([y(()=>import("./D4ytz2EC.js"),__vite__mapDeps([11,12,13,2,14,15,4,8,1,16,6,3,17,18]),import.meta.url),y(()=>import("./C2UL5Ler.js").then(n=>n.ef),__vite__mapDeps([19,6,4,1,2,12,13,14,15,8,16,3,20,21,22,23,7,9,24,0,5,10,25,26]),import.meta.url)]),t=s.select(r.state),i=t.find(n=>n.id===e);return!i||!i.repositoryPath?[]:t.filter(n=>n.id!==e&&n.repositoryPath===i.repositoryPath)}catch(r){return _.debug("[NoteProvider] Failed to get sibling workspaces:",r),[]}}async fetchNotesFromWorkspace(e,r){try{const[{store:s},{listSlimNotesRequested:t}]=await Promise.all([y(()=>import("./D4ytz2EC.js"),__vite__mapDeps([11,12,13,2,14,15,4,8,1,16,6,3,17,18]),import.meta.url),y(()=>import("./B9vHutcJ.js").then(n=>n.MP),__vite__mapDeps([12,13,2,14,15,4,8,1,16,6,3]),import.meta.url)]);return(await s.dispatch(t(e))).map(n=>({note:n,workspaceId:e,workspaceTitle:r}))}catch(s){_.debug(`[NoteProvider] Failed to fetch notes from workspace ${e}:`,s)}return[]}async search(e,r){if(!r.workspaceId)return[];const s=e.trim(),t=s?se(s):null;try{const i=await this.fetchNotesFromWorkspace(r.workspaceId),a=(await this.getSiblingWorkspaces(r.workspaceId)).map(d=>this.fetchNotesFromWorkspace(d.id,d.title)),l=(await Promise.all(a)).flat(),p=[...i,...l],w=(t?p.map(d=>({entry:d,score:t(d.note.title,d.note.content||d.note.contentPreview)})).filter(({score:d})=>d>0).sort((d,v)=>v.score-d.score):p.map(d=>({entry:d,score:void 0}))).slice(0,te).map(({entry:{note:d,workspaceId:v,workspaceTitle:h},score:f})=>{const P=v===r.workspaceId,I=P?void 0:b.chat_mentions_fromWorkspace_subtitle({workspace:h||v}),S=d.content||d.contentPreview;return{candidate:{id:d.id,type:"note",label:d.title||d.id||b.chat_mentions_untitledNote_label(),subtitle:I,description:S?`${S.substring(0,100)}...`:"",icon:"📝",uri:`devspace://note/${d.id}`,meta:{preview:S?.substring(0,200)||"",workspaceId:v,...P?{}:{isExternalLink:!0}}},score:f}});if(this.cachedNotes=w.map(({candidate:d})=>d),this.lastCacheUpdate=Date.now(),w.length>0)return w.map(({candidate:d,score:v})=>v!==void 0?{...d,score:v}:d)}catch(i){_.debug("[NoteProvider] Failed to fetch notes:",i)}return this.cachedNotes.length>0?t?this.cachedNotes.map(i=>({...i,score:t(i.label,i.meta?.preview)})).filter(i=>i.score>0).sort((i,n)=>n.score-i.score):this.cachedNotes:[]}getCachedNotes(){return Date.now()-this.lastCacheUpdate>this.cacheTimeout?[]:this.cachedNotes}}class ne{constructor(){u(this,"id","external");u(this,"triggers",["@docs","@external"])}async search(e,r){return[{id:"react-docs",label:"React Documentation",url:"https://react.dev",description:"Official React documentation"},{id:"mdn",label:"MDN Web Docs",url:"https://developer.mozilla.org",description:"Web technology documentation"},{id:"typescript",label:"TypeScript Handbook",url:"https://www.typescriptlang.org/docs/",description:"TypeScript documentation"}].filter(t=>!e||g(e,t.label)!==null).map(t=>({id:`external-${t.id}`,type:"external-source",label:t.label,description:t.description,icon:"📚",uri:`devspace://external/${t.id}`,meta:{url:t.url}}))}}class oe{constructor(){u(this,"id","rule");u(this,"triggers",["@rule","@intent"])}async search(e,r){return[{path:".intent/rules/cli.md",label:"CLI Rules"},{path:".intent/rules/frontend.md",label:"Frontend Rules"},{path:".intent/rules/python.md",label:"Python Rules"},{path:".intent/rules/sidecar.md",label:"Sidecar Rules"},{path:".intent/rules/systems.md",label:"Systems Rules"}].filter(t=>!e||g(e,t.label)!==null).map(t=>({id:t.path,type:"rule",label:t.label,subtitle:t.path,icon:"📚",uri:`devspace://rule/${encodeURIComponent(t.path)}`,meta:{path:t.path}}))}}class ae{constructor(){u(this,"id","task");u(this,"triggers",["@task","@todo"])}async search(e,r){return[{id:"task-1",label:"Implement authentication",status:"in_progress",assignee:"John Doe"},{id:"task-2",label:"Write tests",status:"not_started",assignee:"Jane Smith"},{id:"task-3",label:"Deploy to production",status:"completed",assignee:"Bob Johnson"}].filter(t=>!e||g(e,t.label)!==null).map(t=>({id:`task-${t.id}`,type:"task",label:t.label,subtitle:`${t.status} • ${t.assignee}`,icon:"📋",uri:`devspace://task/${t.id}`,meta:{taskStatus:t.status,assignee:t.assignee}}))}}class ce{constructor(){u(this,"id","personality");u(this,"triggers",["@personality","@persona"]);u(this,"personalities",[{id:"auggie-personality-agent-default",name:"Agent Auggie",description:"Default helpful AI assistant",icon:"🤖",temperature:.7,model:"default",promptToken:"auggie-personality-agent-default"},{id:"auggie-personality-prototyper",name:"Prototyper Auggie",description:"Specialized in rapid prototyping",icon:"⚡",temperature:.7,model:"default",promptToken:"auggie-personality-prototyper"},{id:"auggie-personality-brainstorm",name:"Brainstorm Auggie",description:"Creative ideation and exploration",icon:"💡",temperature:.7,model:"default",promptToken:"auggie-personality-brainstorm"},{id:"auggie-personality-reviewer",name:"Reviewer Auggie",description:"Code review and feedback",icon:"🔍",temperature:.7,model:"default",promptToken:"auggie-personality-reviewer"}])}async search(e,r){return this.personalities.filter(s=>!e||g(e,s.name)!==null).map(s=>({id:s.id,type:"personality",label:s.name,subtitle:`${s.model}`,description:s.description,icon:s.icon,uri:`devspace://personality/${s.id}`,meta:{promptToken:s.promptToken}}))}}class le{constructor(){u(this,"id","command");u(this,"triggers",["@cmd","@command"])}async search(e,r){return[N.USE_DEFAULT_CONTEXT,N.CLEAR_CONTEXT].filter(t=>!e||t.label.toLowerCase().includes(e.toLowerCase()))}}class ue{constructor(){u(this,"id","terminal");u(this,"triggers",["@terminal","@term"])}async search(e,r){try{const{terminalManager:s}=await y(async()=>{const{terminalManager:h}=await import("./Ctp-YfoS.js").then(f=>f.b);return{terminalManager:h}},__vite__mapDeps([27,2,1,28,29,3,4,30,31,12,13,14,15,8,16,6,0,5,7,9,10,32,20,33,34,35,36,37,38,39,25,40,41]),import.meta.url),{selectTerminals:t,selectTerminalDisplayName:i}=await y(async()=>{const{selectTerminals:h,selectTerminalDisplayName:f}=await import("./CgGsxeG7.js").then(P=>P.i);return{selectTerminals:h,selectTerminalDisplayName:f}},__vite__mapDeps([40,12,13,2,14,15,4,8,1,16,6,3]),import.meta.url),a=k.state;if(!r.workspaceId)return[];const o=t.select(a,r.workspaceId),l=s.loadTerminalMetadata(r.workspaceId),p=new Set,m=[];for(const h of o)p.add(h.id),m.push({id:h.id,name:i.select(a,r.workspaceId,h.id)});for(const h of l)p.has(h.terminalId)||(p.add(h.terminalId),m.push({id:h.terminalId,name:h.title||b.terminal_quakeOverlay_terminal_fallback()}));if(m.length===0)return[];const d=e?["terminal","term"].some(h=>h.startsWith(e.toLowerCase())||e.toLowerCase().startsWith(h)):!1;return(e&&!d?m.filter(h=>g(e,h.name)!==null):m).slice(0,10).map((h,f)=>({id:h.id,type:"terminal",label:h.name,subtitle:b.chat_mentions_terminalIndex_subtitle({index:f+1}),description:b.chat_mentions_terminalOutput_description(),icon:"💻",uri:`devspace://terminal/${encodeURIComponent(h.id)}`,meta:{workspaceId:r.workspaceId}}))}catch(s){return _.debug("[TerminalProvider] Failed to get terminals:",s),[]}}}class de{constructor(){u(this,"id","script");u(this,"triggers",["@script","@scripts"])}async search(e,r){try{const{selectScriptEntries:s}=await y(async()=>{const{selectScriptEntries:o}=await import("./Cg8YmoXY.js");return{selectScriptEntries:o}},__vite__mapDeps([42,12,13,2,14,15,4,8,1,16,6,3,43,19,20,21,22,23,7,9,24,0,5,10,25,26,44,29,28,45,46,47,48,31,49,50]),import.meta.url);if(!r.workspaceId)return[];const t=s.select(k.state,r.workspaceId);if(t.length===0)return[];const n=e?["script","scripts"].some(o=>o.startsWith(e.toLowerCase())||e.toLowerCase().startsWith(o)):!1;return(e&&!n?t.filter(o=>g(e,o.name)!==null||g(e,M(o))!==null):t).slice(0,10).map(o=>{const l=o.runtime.status,p=x(l)?b.chat_mentions_scriptRunning_label():l==="exited"?b.chat_mentions_scriptExited_label():b.chat_mentions_scriptIdle_label();return{id:o.id,type:"script",label:o.name,subtitle:`${p} · ${M(o)}`,description:b.chat_mentions_scriptOutput_description(),icon:"▶️",uri:`devspace://script/${encodeURIComponent(o.id)}`,meta:{workspaceId:r.workspaceId,command:o.command,status:x(l)?"ok":l==="exited"?"warning":void 0}}})}catch(s){return _.debug("[ScriptProvider] Failed to get scripts:",s),[]}}}class pe{constructor(){u(this,"id","specialist");u(this,"triggers",["@specialist","@spec"])}async search(e,r){try{const s=j.select(k.state);return!s||s.length===0?[]:s.filter(t=>e?g(e,t.name)!==null||g(e,t.id)!==null||g(e,t.description)!==null||g(e,"specialist")!==null:!0).map(t=>({id:`specialist-${t.id}`,type:"specialist",label:t.name,subtitle:t.description,description:t.description,icon:"👤",uri:`devspace://specialist/${encodeURIComponent(t.id)}`,group:"Specialists",score:.8,meta:{promptToken:`specialist/${t.id}`}})).slice(0,10)}catch(s){return _.debug("[SpecialistProvider] Failed to get specialists:",s),[]}}}class he{constructor(){u(this,"id","agent");u(this,"triggers",["@agent"])}async search(e,r){try{const{selectAllWorkspaceAgents:s}=await y(async()=>{const{selectAllWorkspaceAgents:a}=await import("./C2UL5Ler.js").then(o=>o.ec);return{selectAllWorkspaceAgents:a}},__vite__mapDeps([19,6,4,1,2,12,13,14,15,8,16,3,20,21,22,23,7,9,24,0,5,10,25,26]),import.meta.url),t=r.workspaceId;if(!t)return[];const i=s.select(k.state,t);if(i.length===0)return[];const n=[];for(const a of i){const o=a.id,l=a.name||o,p=a.metadata?.specialist||"";let m=a.metadata?.specialistName||"";if(p&&!m){const f=U.select(k.state,p);f&&(m=f.name)}if(e){const f=g(e,l)!==null,P=g(e,"agent")!==null,I=m&&g(e,m)!==null,S=p&&g(e,p)!==null;if(!f&&!P&&!I&&!S)continue}const w=a.isStreaming?"responding":a.status||"active",d=[];m?d.push(m):d.push("Agent"),d.push(w);const v=a.messages?.length||0;v>0&&d.push(`${v} msg${v!==1?"s":""}`);const h=a.lastActivity||a.lastModified;h&&!a.isStreaming&&d.push(z(new Date(h))),n.push({id:o,type:"agent",label:l,subtitle:d.join(" · "),description:m?b.chat_mentions_specialistAgentInWorkspace_description({specialist:m}):b.chat_mentions_agentInWorkspace_description(),icon:"🤖",uri:`devspace://agent/${encodeURIComponent(o)}`,group:b.chat_mentions_agents_group(),score:.7,meta:{workspaceId:t}})}return n.slice(0,10)}catch(s){return _.debug("[AgentProvider] Failed to get agents:",s),[]}}}class me{constructor(){u(this,"providers",new Map);u(this,"defaultProviders",[]);this.register(new Z),this.register(new ee),this.register(new ie),this.register(new ne),this.register(new oe),this.register(new ae),this.register(new ce),this.register(new le),this.register(new ue),this.register(new de),this.register(new he),this.register(new pe),this.register(new q),this.defaultProviders=["file","folder","note","terminal","script","agent","specialist","member"]}register(e){this.providers.set(e.id,e),_.debug("[ProviderRegistry] Registered provider:",e.id)}unregister(e){this.providers.delete(e)}get(e){return this.providers.get(e)}getAll(){return Array.from(this.providers.values())}getDefault(){return this.defaultProviders.map(e=>this.providers.get(e)).filter(Boolean)}getByTrigger(e){return Array.from(this.providers.values()).filter(r=>r.triggers?.includes(e))}async searchAll(e,r){const s=e.startsWith("@")?this.getByTrigger(e.split(" ")[0]):this.getDefault();return(await Promise.all(s.map(i=>i.search(e,r)))).flat()}}const Te=new me;export{Ie as D,Ce as M,Q as a,ke as i,Te as p,R as s};
@@ -1 +1 @@
1
- var De=Object.defineProperty;var Ce=(i,s,e)=>s in i?De(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e;var E=(i,s,e)=>Ce(i,typeof s!="symbol"?s+"":s,e);import{K as Le,P as ce,a6 as le,as as z,aC as ve}from"./DIPIWs2Q.js";import{b_ as we,c$ as ue,cr as de,cq as be}from"./BQGIKN0g.js";import{JH as p,Cg as Fe,bJ as ke,i as Ge,LM as me,ir as Ee,bV as Pe,Ec as H,CF as xe,fl as Ve,AL as Ue,e3 as fe,fh as _e,e2 as he,Be,Lq as $e,wy as Xe}from"./B9vHutcJ.js";import{aO as Se,dX as ge,A as K,P as Re,aK as Q}from"./C2UL5Ler.js";import{h as qe}from"./TB9r2XJy.js";import{c as W}from"./ChTqQfQN.js";import{a as We}from"./BdWqymET.js";import{m as j}from"./96V4v2iI.js";import"./3SdAC2_C.js";import{bm as n}from"./CLAmm_T1.js";import"./CcJmuwXr.js";import"./BwNrQXlF.js";import"./BbYWP3Ow.js";import{R as pe}from"./B5aYN90J.js";import{L as Ye}from"./CSiaiLHL.js";function ze(i,s){return i.some(e=>e.id===s.id)?i.map(e=>e.id===s.id?{...s,...s.author==null&&e.author!==void 0?{author:e.author}:{}}:e):[...i,s]}const Te="confirmUnslothModelSwitch";function He(i){if(!i||typeof i!="object")return!1;const{agentId:s,agentName:e,workspaceId:t,workspaceTitle:r}=i;return typeof s=="string"&&typeof e=="string"&&typeof t=="string"&&(r===null||typeof r=="string")}function Ke(i){for(let s=i,e=0;s&&e<4;e++){const t=s.data;if(t&&typeof t=="object"){const{code:r,currentModel:a,requestedModel:l,agents:o}=t;if(r==="unsloth-model-switch-confirmation-required"&&typeof a=="string"&&typeof l=="string"&&Array.isArray(o)&&o.every(He))return{currentModel:a,requestedModel:l,agents:o}}s=s.cause}}function bt(i){if(!i||!(Te in i))return i;const{[Te]:s,...e}=i;return Object.keys(e).length>0?e:void 0}const Z=typeof performance<"u"?performance:{now:()=>Date.now()},V=new We("PerformanceOptimizer"),w=class w{constructor(){E(this,"metricsBuffer");E(this,"metricsIndex",0);E(this,"metricsCount",0);E(this,"MAX_METRICS",500);E(this,"TARGET_RESPONSE_TIME",100);E(this,"memoCache",new Map);E(this,"MEMO_TTL",6e4);E(this,"MAX_CACHE_SIZE",100);E(this,"cacheHits",0);E(this,"cacheMisses",0);E(this,"pendingRequests",new Map);E(this,"requestQueue",[]);E(this,"cleanupInterval",null);this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.startCacheCleanup(),V.info("PerformanceOptimizer initialized")}static getInstance(){return w.instance||(w.instance=new w),w.instance}reset(){this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.metricsIndex=0,this.metricsCount=0,this.memoCache.clear(),this.pendingRequests.clear(),this.requestQueue=[],this.cacheHits=0,this.cacheMisses=0}clearCache(){this.memoCache.clear(),this.cacheHits=0,this.cacheMisses=0}async processBatch(s,e,t={}){const{batchSize:r=10,concurrency:a=4}=t,l=[];for(let o=0;o<s.length;o+=r){const _=s.slice(o,o+r).map((c,R)=>{const g=Math.floor(R/a)*10;return new Promise(d=>{setTimeout(async()=>{const k=await e(c);d(k)},g)})}),u=await Promise.all(_);l.push(...u)}return l}startCacheCleanup(){this.cleanupInterval=setInterval(()=>{this.cleanupCache()},3e4)}stopCacheCleanup(){this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null)}cleanupCache(){const s=Date.now(),e=[];this.memoCache.forEach((t,r)=>{s-t.timestamp>this.MEMO_TTL&&e.push(r)}),e.forEach(t=>this.memoCache.delete(t)),this.memoCache.size>this.MAX_CACHE_SIZE&&Array.from(this.memoCache.entries()).sort((a,l)=>a[1].hits-l[1].hits||a[1].timestamp-l[1].timestamp).slice(0,this.memoCache.size-this.MAX_CACHE_SIZE).forEach(([a])=>this.memoCache.delete(a))}async track(s,e,t={}){const r=Z.now();try{const a=t.cacheKey||s;if(t.memoize){const _=this.getMemoized(a);if(_!==void 0)return this.cacheHits++,V.debug("Memoized result used",{operation:s,cacheKey:a,hits:this.cacheHits}),_;this.cacheMisses++}if(t.coalesce){const _=this.pendingRequests.get(s);if(_)return V.debug("Request coalesced",{operation:s}),_}let l;t.coalesce?(l=t.timeout?this.withTimeout(e(),t.timeout):e(),this.pendingRequests.set(s,l)):l=t.timeout?this.withTimeout(e(),t.timeout):e();const o=await l;t.memoize&&this.memoize(a,o);const f=Z.now()-r;return this.recordMetric(s,f,!0,{strategy:t.priority||"normal",memoized:t.memoize||!1,coalesced:t.coalesce||!1}),f>this.TARGET_RESPONSE_TIME&&V.warn("Operation exceeded target time",{operation:s,duration:Math.round(f),target:this.TARGET_RESPONSE_TIME}),o}catch(a){const l=Z.now()-r;throw this.recordMetric(s,l,!1,{error:a instanceof Error?a.message:"Unknown error"}),a}finally{t.coalesce&&this.pendingRequests.delete(s)}}getStats(){if(this.metricsCount===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const s=[],e=this.metricsCount<this.MAX_METRICS?0:this.metricsIndex;for(let u=0;u<this.metricsCount;u++){const c=this.metricsBuffer[(e+u)%this.MAX_METRICS];c&&s.push(c)}if(s.length===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const t=s.sort((u,c)=>u.duration-c.duration);let r=0,a=0;const l=new Set;for(const u of s)a+=u.duration,u.success&&r++,u.duration>this.TARGET_RESPONSE_TIME&&l.add(u.operation);const o=a/s.length,f=Math.floor(t.length*.95),_=Math.floor(t.length*.99);return{avgResponseTime:Math.round(o),p95ResponseTime:Math.round(t[f]?.duration||0),p99ResponseTime:Math.round(t[_]?.duration||0),successRate:r/s.length*100,slowOperations:Array.from(l)}}getCacheStats(){const s=this.cacheHits+this.cacheMisses;return{size:this.memoCache.size,hitRate:s>0?this.cacheHits/s*100:0,hits:this.cacheHits,misses:this.cacheMisses}}getMemoized(s){const e=this.memoCache.get(s);if(e){if(Date.now()-e.timestamp>this.MEMO_TTL){this.memoCache.delete(s);return}return e.hits++,e.value}}memoize(s,e){const t=JSON.stringify(e).length;this.memoCache.set(s,{value:e,timestamp:Date.now(),hits:0,size:t}),this.memoCache.size>this.MAX_CACHE_SIZE&&this.cleanupCache()}async withTimeout(s,e){return Promise.race([s,new Promise((t,r)=>setTimeout(()=>r(new Error(`Operation timed out after ${e}ms`)),e))])}recordMetric(s,e,t,r){this.metricsBuffer[this.metricsIndex]={operation:s,duration:e,timestamp:Date.now(),success:t,metadata:r},this.metricsIndex=(this.metricsIndex+1)%this.MAX_METRICS,this.metricsCount<this.MAX_METRICS&&this.metricsCount++,e>this.TARGET_RESPONSE_TIME&&V.warn("Slow operation detected",{operation:s,duration:`${e.toFixed(2)}ms`,target:`${this.TARGET_RESPONSE_TIME}ms`,metadata:r})}};E(w,"instance");let te=w;const Qe=te.getInstance(),Ae={AGENT_CREATION:"https://docs.example.com/agent-creation",STREAMING:"https://docs.example.com/streaming-issues",STORAGE:"https://docs.example.com/storage-troubleshooting",MEMORY:"https://docs.example.com/memory-management",PROVIDER:"https://docs.example.com/provider-setup",GENERAL:"https://docs.example.com/help"},J={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_template({agentName:"{agentName}",details:"{details}"})},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_template({agentName:"{agentName}"})},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_template({details:"{details}"})},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_template({details:"{details}"})},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_template({sessionId:"{sessionId}"})},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_template()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_template({details:"{details}"})},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_template({details:"{details}"})},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_template({timeout:"{timeout}"})},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_template({attempt:"{attempt}",maxAttempts:"{maxAttempts}"})},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_template({attempts:"{attempts}"})},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_template({details:"{details}"})},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_template({details:"{details}"})},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_template({maxLength:"{maxLength}",currentLength:"{currentLength}"})},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_template({provider:"{provider}"})},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_template({provider:"{provider}",details:"{details}"})},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_template({provider:"{provider}"})},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_template({details:"{details}"})},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_template({details:"{details}"})},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_template({lastBackup:"{lastBackup}"})},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_template({currentUsage:"{currentUsage}",limit:"{limit}"})},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_template({count:"{count}",window:"{window}"})},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_template({current:"{current}",max:"{max}"})}},je={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_friendly()},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_friendly()},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_friendly()},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_friendly()},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_friendly()},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_friendly()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_friendly()},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_friendly()},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_friendly()},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_friendly()},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_friendly()},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_friendly()},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_friendly()},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_friendly()},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_friendly()},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_friendly()},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_friendly()},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_friendly()},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_friendly()},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_friendly()},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_friendly()},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_friendly()},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_friendly()}};function Ze(i){return(i.match(/{(\w+)}/g)||[]).map(e=>e.slice(1,-1))}function Je(i,s){return Ze(i).every(t=>t in s)}function Oe(i,s={}){return i.replace(/{(\w+)}/g,(e,t)=>String(s[t]??e))}function ee(i){const s=n.errors_cleanMessage_fallback_error();if(!i)return s;let e=i;return e=e.replace(/^.*?failed(?:\s+to\s+.*?)?\s+after\s+\d+\s+attempts:\s*/i,""),e=e.replace(/^Error invoking remote method '[^']+':(\s*Error:)?\s*/i,""),e=e.replace(/^(Error:\s*)+/i,""),e=e.replace(/\n\s*at .+/g,""),e=e.replace(/\s+/g," ").trim(),e||s}function et(i,s){return s&&J[i]&&Je(J[i],s)?Oe(J[i],s):je[i]||n.errors_userFriendly_fallback_error()}function tt(i){const e={AGENT_CREATION_FAILED:"AGENT_CREATION",AGENT_ALREADY_EXISTS:"AGENT_CREATION",INVALID_AGENT_CONFIG:"AGENT_CREATION",STREAM_CONNECTION_FAILED:"STREAMING",STREAM_TIMEOUT:"STREAMING",STREAM_INTERRUPTED:"STREAMING",STREAM_RECOVERY_FAILED:"STREAMING",STORAGE_READ_FAILED:"STORAGE",STORAGE_WRITE_FAILED:"STORAGE",STORAGE_CORRUPTED:"STORAGE",MEMORY_LIMIT_EXCEEDED:"MEMORY",RATE_LIMIT_EXCEEDED:"MEMORY",CONCURRENT_LIMIT_EXCEEDED:"MEMORY",PROVIDER_NOT_FOUND:"PROVIDER",PROVIDER_CONNECTION_FAILED:"PROVIDER",PROVIDER_PROCESS_DIED:"PROVIDER"}[i];return e?Ae[e]:Ae.GENERAL}const st={AGENT_CREATION_FAILED:[{action:"retry",description:"Try creating the agent again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify agent configuration in settings",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient memory and disk space",automatic:!1,priority:"medium"}],AGENT_ALREADY_EXISTS:[{action:"rename",description:"Choose a different name for the agent",automatic:!1,priority:"high"},{action:"delete-existing",description:"Delete the existing agent first",automatic:!1,priority:"medium"}],INVALID_AGENT_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],INVALID_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],SESSION_NOT_FOUND:[{action:"start-new",description:"Start a new agent session",automatic:!1,priority:"high"},{action:"check-history",description:"Check session history for recent sessions",automatic:!1,priority:"medium"}],SESSION_ALREADY_ACTIVE:[{action:"wait",description:"Wait for the current session to complete",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel the active session first",automatic:!1,priority:"high"}],SESSION_INITIALIZATION_FAILED:[{action:"retry",description:"Try initializing the session again",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient resources are available",automatic:!1,priority:"medium"}],MESSAGE_SEND_FAILED:[{action:"retry",description:"Try sending the message again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],MESSAGE_VALIDATION_FAILED:[{action:"review-config",description:"Review and correct the message format",automatic:!1,priority:"high"},{action:"check-config",description:"Check configuration for valid message format",automatic:!1,priority:"medium"}],MESSAGE_TOO_LONG:[{action:"retry",description:"Shorten the message and try again",automatic:!1,priority:"high"},{action:"batch",description:"Split the message into multiple parts",automatic:!1,priority:"medium"}],PROVIDER_NOT_FOUND:[{action:"check-config",description:"Verify provider is properly configured",automatic:!1,priority:"high"},{action:"recreate",description:"Install or reinstall the provider",automatic:!1,priority:"high"}],PROVIDER_CONNECTION_FAILED:[{action:"retry",description:"Try connecting to the provider again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify provider configuration",automatic:!1,priority:"high"}],STORAGE_READ_FAILED:[{action:"retry",description:"Try reading the data again",automatic:!1,priority:"high"},{action:"restore",description:"Restore from a recent backup",automatic:!1,priority:"medium"}],STORAGE_WRITE_FAILED:[{action:"retry",description:"Try saving again",automatic:!1,priority:"high"},{action:"check-resources",description:"Check available disk space",automatic:!1,priority:"high"}],STREAM_CONNECTION_FAILED:[{action:"retry",description:"Try connecting again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],STREAM_RECOVERY_FAILED:[{action:"restart",description:"Restart the agent",automatic:!1,priority:"high"},{action:"check-config",description:"Check error logs for more details",automatic:!1,priority:"medium"}],STREAM_INTERRUPTED:[{action:"reconnect",description:"Attempting automatic reconnection",automatic:!0,priority:"high"},{action:"retry",description:"Retry sending the message",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your internet connection",automatic:!1,priority:"medium"}],STREAM_TIMEOUT:[{action:"wait",description:"Wait for agent to complete processing",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel current operation",automatic:!1,priority:"medium"},{action:"increase-timeout",description:"Increase timeout in settings",automatic:!1,priority:"low"}],PROVIDER_PROCESS_DIED:[{action:"restart",description:"Restart agent process",automatic:!0,priority:"high"},{action:"recreate",description:"Create new agent session",automatic:!1,priority:"high"}],STORAGE_CORRUPTED:[{action:"restore",description:"Restore from backup",automatic:!1,priority:"high"},{action:"reset",description:"Reset agent data",automatic:!1,priority:"medium"}],MEMORY_LIMIT_EXCEEDED:[{action:"cleanup",description:"Close unused agents",automatic:!1,priority:"high"},{action:"increase-limit",description:"Increase memory limit in settings",automatic:!1,priority:"medium"}],RATE_LIMIT_EXCEEDED:[{action:"wait",description:"Wait before making more requests",automatic:!1,priority:"high"},{action:"batch",description:"Batch requests together",automatic:!1,priority:"medium"}],CONCURRENT_LIMIT_EXCEEDED:[{action:"close-agents",description:"Close some running agents",automatic:!1,priority:"high"},{action:"queue",description:"Queue operation for later",automatic:!1,priority:"medium"}]};function it(i){return st[i]||[{action:"retry",description:"Try the operation again",automatic:!1,priority:"high"}]}var N=(i=>(i.AGENT_CREATION_FAILED="AGENT_CREATION_FAILED",i.AGENT_ALREADY_EXISTS="AGENT_ALREADY_EXISTS",i.INVALID_AGENT_CONFIG="INVALID_AGENT_CONFIG",i.INVALID_CONFIG="INVALID_CONFIG",i.SESSION_NOT_FOUND="SESSION_NOT_FOUND",i.SESSION_ALREADY_ACTIVE="SESSION_ALREADY_ACTIVE",i.SESSION_INITIALIZATION_FAILED="SESSION_INITIALIZATION_FAILED",i.STREAM_CONNECTION_FAILED="STREAM_CONNECTION_FAILED",i.STREAM_TIMEOUT="STREAM_TIMEOUT",i.STREAM_INTERRUPTED="STREAM_INTERRUPTED",i.STREAM_RECOVERY_FAILED="STREAM_RECOVERY_FAILED",i.MESSAGE_SEND_FAILED="MESSAGE_SEND_FAILED",i.MESSAGE_VALIDATION_FAILED="MESSAGE_VALIDATION_FAILED",i.MESSAGE_TOO_LONG="MESSAGE_TOO_LONG",i.PROVIDER_NOT_FOUND="PROVIDER_NOT_FOUND",i.PROVIDER_CONNECTION_FAILED="PROVIDER_CONNECTION_FAILED",i.PROVIDER_PROCESS_DIED="PROVIDER_PROCESS_DIED",i.PROVIDER_UNAVAILABLE="PROVIDER_UNAVAILABLE",i.PROVIDER_ERROR="PROVIDER_ERROR",i.STORAGE_READ_FAILED="STORAGE_READ_FAILED",i.STORAGE_WRITE_FAILED="STORAGE_WRITE_FAILED",i.STORAGE_CORRUPTED="STORAGE_CORRUPTED",i.STORAGE_ERROR="STORAGE_ERROR",i.STORAGE_QUOTA_EXCEEDED="STORAGE_QUOTA_EXCEEDED",i.MEMORY_LIMIT_EXCEEDED="MEMORY_LIMIT_EXCEEDED",i.RATE_LIMIT_EXCEEDED="RATE_LIMIT_EXCEEDED",i.CONCURRENT_LIMIT_EXCEEDED="CONCURRENT_LIMIT_EXCEEDED",i.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",i.RESOURCE_EXHAUSTED="RESOURCE_EXHAUSTED",i.NETWORK_ERROR="NETWORK_ERROR",i.PERMISSION_DENIED="PERMISSION_DENIED",i.OPERATION_FAILED="OPERATION_FAILED",i.VALIDATION_ERROR="VALIDATION_ERROR",i.INVALID_RESPONSE="INVALID_RESPONSE",i.STATE_CORRUPTION="STATE_CORRUPTION",i.CONTEXT_OVERFLOW="CONTEXT_OVERFLOW",i))(N||{});class q extends Error{constructor(e,t,r={},a){super(e);E(this,"code");E(this,"context");E(this,"recoverySuggestions");E(this,"userMessage");E(this,"isRecoverable");E(this,"cause");this.name="AgentError",this.code=t,this.context={...r,timestamp:new Date,stackTrace:this.stack},this.userMessage=a?.userMessage||this.getDefaultUserMessage(t),this.recoverySuggestions=a?.recoverySuggestions||this.getDefaultRecoverySuggestions(t),this.isRecoverable=a?.isRecoverable??this.isErrorRecoverable(t),a?.cause&&(this.cause=a.cause)}getDefaultUserMessage(e){return et(e,this.context)}getDefaultRecoverySuggestions(e){return it(e)}isErrorRecoverable(e){return["STREAM_INTERRUPTED","STREAM_TIMEOUT","MESSAGE_SEND_FAILED","PROVIDER_PROCESS_DIED","STORAGE_READ_FAILED","STORAGE_WRITE_FAILED"].includes(e)}getHelpLink(){return tt(this.code)}formatMessage(e){return Oe(e,this.context)}toJSON(){return{name:this.name,code:this.code,message:this.message,userMessage:this.userMessage,context:this.context,recoverySuggestions:this.recoverySuggestions,isRecoverable:this.isRecoverable,helpLink:this.getHelpLink(),stack:this.stack}}}const rt={NON_RETRYABLE_ERRORS:["EACCES","EPERM","ENOSPC","EMFILE","permission","memory","fatal","process died","not available on your current plan","agent binary","rate limit","too many requests","hit your limit","you've hit your limit","quota exceeded"]};function re(i){const s=i.toLowerCase();for(const e of rt.NON_RETRYABLE_ERRORS)if(s.includes(e.toLowerCase()))return!0;return!1}const at="Agent already has an in-flight prompt. Message was not delivered.",v=W("ErrorBoundary"),b=class b{constructor(){}static getInstance(){return b.instance||(b.instance=new b),b.instance}async wrap(s,e,t={}){const{retries:r=pe.DEFAULT_ATTEMPTS,retryDelay:a=pe.BASE_DELAY,exponentialBackoff:l=!0,notify:o=!1,notifyOnRetry:f=!1,context:_={},onError:u,onRetry:c,shouldRetry:R=this.defaultShouldRetry}=t;let g=null,d=0;for(d=1;d<=r+1;d++)try{v.debug(`[${e}] Attempt ${d}/${r+1}`);const C=await s();return d>1&&v.info(`[${e}] Succeeded after ${d} attempts`),C}catch(C){if(g=C,v.error(`[${e}] Attempt ${d} failed`,{error:g.message,attempt:d,maxAttempts:r+1,context:_}),u?.(g,d),d<=r&&R(g)){const h=l?a*Math.pow(2,d-1):a;f&&j.warning(n.agent_errorBoundary_retrying_message({seconds:h/1e3})),c?.(d),v.info(`[${e}] Retrying in ${h}ms`),await this.sleep(h)}else break}const k=`${e} failed after ${d} attempt${d===1?"":"s"}: ${g?.message}`,P=ee(g?.message||n.agent_errorBoundary_generic_error()),D=g?.message?.toLowerCase()||"",$=D.includes("no available models")||D.includes("all models exhausted")||D.includes("all models unavailable");throw o&&!$&&j.error(P),new q(P,N.OPERATION_FAILED,{originalError:g?.message,detailedMessage:k,attempts:d,context:_})}async wrapVoid(s,e,t={}){await this.wrap(s,e,t)}wrapSync(s,e,t={}){try{return s()}catch(r){const a=r;throw v.error(`[${e}] Failed`,{error:a.message,context:t.context}),t.notify&&j.error(ee(a.message)),new q(ee(a.message),N.OPERATION_FAILED,t.context)}}defaultShouldRetry(s){const e=s.message.toLowerCase();return re(s.message)?!1:e.includes("network")||e.includes("timeout")?!0:s instanceof q?[N.NETWORK_ERROR,N.STREAM_TIMEOUT,N.STREAM_CONNECTION_FAILED,N.PROVIDER_CONNECTION_FAILED,N.PROVIDER_UNAVAILABLE].includes(s.code):!(e.includes("invalid")||e.includes("interrupted")||e.includes("cancel")||e.includes("not found")||e.includes("not available")||e.includes("404")||e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||e.includes("413")||e.includes("too long for the agent")||e.includes("request entity too large")||e.includes("payload too large")||e.includes("content too large")||e.includes("body too large")||e.includes("unauthorized")||e.includes("forbidden")||e.includes("401")||e.includes("403"))}sleep(s){return new Promise(e=>setTimeout(e,s))}async withTimeout(s,e,t){return Promise.race([s(),new Promise((r,a)=>setTimeout(()=>a(new q(`${t} timed out after ${e}ms`,N.STREAM_TIMEOUT)),e))])}async batchOperations(s,e,t={}){const{concurrency:r=5,continueOnError:a=!0,operationName:l="batch operation"}=t,o=[],f=[];for(let _=0;_<s.length;_+=r){const u=s.slice(_,_+r);(await Promise.allSettled(u.map(R=>e(R)))).forEach((R,g)=>{if(R.status==="fulfilled")o.push(R.value);else{const d=R.reason;if(f.push({item:u[g],error:d}),v.error(`[${l}] Batch item failed`,{item:u[g],error:d.message}),!a)throw d}})}return f.length>0&&v.warn(`[${l}] Completed with ${f.length} errors`),{results:o,errors:f}}};E(b,"instance");let se=b;const nt=se.getInstance(),ie=W("browser/index"),F=new Map,B=new Map;let U;function ot(i,s,e){for(const t of s)try{t(e)}catch(r){ie.error("Error in agent subscriber callback",{agentId:i,error:r})}}function ct(){if(U)return;let i=!1;U=p.createSelector(e=>e.agentSessions)().subscribe(()=>{if(!i){i=!0;return}if(F.size===0)return;const e=p.state;for(const[t,r]of F){const a=Se.select(e,t);B.get(t)!==a&&(B.set(t,a),ot(t,r,a))}})}function lt(){F.size>0||!U||(U(),U=void 0,B.clear())}function Ft(i,s,e){let t=F.get(i);const r=!t;t||(t=new Set,F.set(i,t)),t.add(s),ct();const a=p.state,l=Se.select(a,i);return r&&B.set(i,l),l?ie.debug("[subscribeToAgent] Initial callback data",{agentId:i,workspaceId:e??"current",hasSession:!0}):ie.debug("[subscribeToAgent] No session found",{agentId:i,workspaceId:e??"current"}),s(l),()=>{const o=F.get(i);o&&(o.delete(s),o.size===0&&(F.delete(i),B.delete(i))),lt()}}const y=W("ErrorRecovery"),ye={network:{maxRetries:3,initialBackoffMs:1e3,maxBackoffMs:1e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("connection")||s.includes("timeout")}},streaming:{maxRetries:5,initialBackoffMs:500,maxBackoffMs:5e3,backoffMultiplier:1.5,shouldRetry:(i,s)=>{if(s>=5)return!1;const e=i.message.toLowerCase();return e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||re(i.message)?!1:e.includes("stream")||e.includes("chunk")||e.includes("incomplete")}},persistence:{maxRetries:2,initialBackoffMs:100,maxBackoffMs:1e3,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("save")||s.includes("write")||s.includes("persist")}},rateLimit:{maxRetries:3,initialBackoffMs:5e3,maxBackoffMs:3e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("rate")||s.includes("limit")||s.includes("429")}}};class ut{constructor(){E(this,"listeners",new Map)}on(s,e){let t=this.listeners.get(s);t||(t=new Set,this.listeners.set(s,t)),t.add(e)}off(s,e){this.listeners.get(s)?.delete(e)}emit(s,...e){this.listeners.get(s)?.forEach(t=>{try{t(...e)}catch(r){y.error(`Error in event listener for ${s}:`,r)}})}removeAllListeners(){this.listeners.clear()}}class dt extends ut{constructor(){super(...arguments);E(this,"activeRecoveries",new Map);E(this,"recoveryStats",new Map)}async executeWithRecovery(e,t=ye.network,r){const a=Date.now(),l=new AbortController;r&&(this.cancelRecovery(r),this.activeRecoveries.set(r,l));let o,f=t.initialBackoffMs,_=0;for(let u=1;u<=t.maxRetries;u++){if(_=u,l.signal.aborted){y.info(`Recovery cancelled for operation ${r}`);break}try{y.debug(`Attempting operation (attempt ${u}/${t.maxRetries})`,{operationId:r});const c=await e();return this.updateStats(r,!0),this.emit("recovery:success",{operationId:r,attempt:u,duration:Date.now()-a}),r&&this.activeRecoveries.delete(r),{success:!0,data:c,attempts:u,totalTime:Date.now()-a}}catch(c){o=c,y.warn(`Operation failed (attempt ${u}/${t.maxRetries})`,{operationId:r,error:o.message});const R=o.message.toLowerCase();if(R.includes("interrupted")||R.includes("cancelled")||R.includes("canceled")){y.debug("User-initiated interruption/cancellation, not retrying",{operationId:r,error:o.message});break}if(R.includes("no available models")||R.includes("all models exhausted")||R.includes("all models unavailable")){y.debug("All models exhausted, not retrying",{operationId:r,error:o.message});break}if(re(o.message)){y.debug("Fatal error detected, not retrying",{operationId:r,error:o.message});break}if(!t.shouldRetry(o,u)){y.debug("Error not retryable, stopping recovery",{operationId:r,error:o.message});break}if(u<t.maxRetries){const g=Math.random()*.2*f,d=Math.min(f+g,t.maxBackoffMs);t.onRetry?.(u,d),this.emit("recovery:retry",{operationId:r,attempt:u,delay:d,error:o.message}),await this.delay(d,l.signal),f=Math.min(f*t.backoffMultiplier,t.maxBackoffMs)}}}return this.updateStats(r,!1),t.onFailure?.(o,_),this.emit("recovery:failure",{operationId:r,attempts:_,duration:Date.now()-a,error:o?.message}),r&&this.activeRecoveries.delete(r),{success:!1,error:o,attempts:_,totalTime:Date.now()-a}}cancelRecovery(e){const t=this.activeRecoveries.get(e);t&&(t.abort(),this.activeRecoveries.delete(e),y.info(`Cancelled recovery for operation ${e}`))}cancelAllRecoveries(){for(const[e,t]of this.activeRecoveries)t.abort(),y.info(`Cancelled recovery for operation ${e}`);this.activeRecoveries.clear()}getStats(e){if(e)return this.recoveryStats.get(e)||{successes:0,failures:0};const t={};for(const[r,a]of this.recoveryStats)t[r]=a;return t}clearStats(e){e?this.recoveryStats.delete(e):this.recoveryStats.clear()}isRetryable(e,t){const r=e.message.toLowerCase();if(t)switch(t){case"NETWORK":return r.includes("network")||r.includes("fetch");case"TIMEOUT":return r.includes("timeout")||r.includes("timed out");case"RATE_LIMIT":return r.includes("rate")||r.includes("limit")||r.includes("429");case"TEMPORARY":return r.includes("temporary")||r.includes("transient");case"CONFLICT":return r.includes("conflict")||r.includes("concurrent");default:return!1}return this.isRetryable(e,"NETWORK")||this.isRetryable(e,"TIMEOUT")||this.isRetryable(e,"RATE_LIMIT")||this.isRetryable(e,"TEMPORARY")||this.isRetryable(e,"CONFLICT")}delay(e,t){return new Promise((r,a)=>{const l=setTimeout(r,e);if(t){const o=()=>{clearTimeout(l),a(new Error("Delay aborted"))};t.addEventListener("abort",o);const f=r;r=()=>{t.removeEventListener("abort",o),f()}}})}updateStats(e,t){if(!e)return;const r=this.recoveryStats.get(e)||{successes:0,failures:0};t?r.successes++:r.failures++,this.recoveryStats.set(e,r)}dispose(){this.cancelAllRecoveries(),this.recoveryStats.clear(),this.removeAllListeners()}}const mt=new dt,O=new Ye({category:"WorkspaceMetrics"}),Et=100;class ft{constructor(){E(this,"metrics",new Map);E(this,"operations",new Map)}startWorkspaceCreation(s){const e=Date.now();for(this.metrics.delete(s),this.metrics.set(s,{workspaceId:s,creationStarted:e});this.metrics.size>Et;){const t=this.metrics.keys().next().value;if(t===void 0)break;this.metrics.delete(t)}O.info("Started tracking workspace creation",{workspaceId:s})}recordMilestone(s,e){const t=this.metrics.get(s);if(!t){O.warn("No metrics found for workspace",{workspaceId:s,milestone:e});return}const r=Date.now();switch(e){case"optimisticNavigation":t.optimisticNavigation=r;break;case"realWorkspaceCreated":t.realWorkspaceCreated=r;break;case"agentCreated":t.agentCreated=r;break;case"agentReady":t.agentReady=r;break;case"firstMessageSent":t.firstMessageSent=r;break;case"firstResponseReceived":t.firstResponseReceived=r;break;case"firstChunkReceived":t.firstChunkReceived=r;break;case"totalDuration":t.totalDuration=r;break;case"workspaceId":case"creationStarted":O.warn("Cannot update milestone",{milestone:e});return}const a=r-t.creationStarted;O.info(`Milestone: ${e}`,{workspaceId:s,elapsed:`${a}ms`,timestamp:r}),e==="firstResponseReceived"&&(t.totalDuration=r-t.creationStarted,this.logSummary(s))}startOperation(s,e){this.operations.set(s,{startTime:Date.now(),metadata:e})}endOperation(s,e){const t=this.operations.get(s);if(!t)return O.warn("Operation not found",{operationId:s}),null;const r=Date.now();return t.endTime=r,t.duration=r-t.startTime,e&&(t.metadata={...t.metadata,...e}),O.info("Operation completed",{operationId:s,duration:`${t.duration}ms`,metadata:t.metadata}),this.operations.delete(s),t.duration}getMetrics(s){return this.metrics.get(s)}logSummary(s){const e=this.metrics.get(s);if(!e)return;const t={workspaceId:s,totalDuration:`${e.totalDuration}ms`,stages:{optimisticNavigation:e.optimisticNavigation?`${e.optimisticNavigation-e.creationStarted}ms`:"N/A",realWorkspaceCreation:e.realWorkspaceCreated?`${e.realWorkspaceCreated-e.creationStarted}ms`:"N/A",agentCreation:e.agentCreated?`${e.agentCreated-e.creationStarted}ms`:"N/A",agentReady:e.agentReady?`${e.agentReady-e.creationStarted}ms`:"N/A",firstMessage:e.firstMessageSent?`${e.firstMessageSent-e.creationStarted}ms`:"N/A",firstResponse:e.firstResponseReceived?`${e.firstResponseReceived-e.creationStarted}ms`:"N/A"}};O.info("=== Workspace Creation Metrics Summary ===",t),O.info("Workspace Creation Metrics:",t)}clearMetrics(s){this.metrics.delete(s)}incrementAgentCreated(s){const e=this.metrics.get(s);e&&(e.agentCreated=Date.now(),O.info("Agent created",{workspaceId:s}))}incrementMessageSent(s){const e=this.metrics.get(s);e&&!e.firstMessageSent&&(e.firstMessageSent=Date.now(),O.info("First message sent",{workspaceId:s}))}}const _t=new ft,M=W("AgentSend");function A(i){p.dispatch(i)}function Ie(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function ht(i){const s=Ie(i)&&i.success===!0&&"data"in i?i.data:i;return!Ie(s)||s.success!==!1?!1:typeof s.error=="string"&&s.error.includes(at)}async function kt(i,s,e,t={}){const r=ge.select(p.state,e.id);if(!r)return;const a=Le(i,e.id),l=t.submission,o=!!l&&we.select(p.state,l.scope)?.supported===!0,f=(c,R,g=!1)=>{l&&A(Xe(l.scope,l.id,c,Date.now(),R,g))};let _=!1;const u=()=>(!l||_||be.select(p.state,l))&&r===ge.select(p.state,e.id)&&a.isCurrent(p.state.agentSessions?.byAgentId[i]?.workspaceId);return Qe.track(`sendMessage:${a.key}:${i}:${l?.id??"legacy"}`,async()=>{if(!u())return;M.debug(`Sending message to agent ${i}`,{contentLength:s.length,hasContextReferences:!!t.contextReferences?.length,model:t.model});let c=await p.dispatch(Fe(e.id,i));if(u()){if(!c)throw new Error(n.agent_streamLifecycle_sessionNotFound_error({agentId:i}));c={...c,isStreaming:c.isStreaming??!1};{if(c&&(c.status==="pending"||!c.id)&&!c.backendSessionId&&c.activationState!==K.ACTIVE&&c.activationState!==K.ACTIVATING){const h=e.id.startsWith("optimistic-"),Y=e.worktreePath||e.repositoryPath||e.path;if(!h&&Y){M.info("Activating pending session in sendMessage",{agentId:i,status:c.status,activationState:c.activationState,hasBackendSessionId:!!c.backendSessionId});const x=await p.dispatch(ke(e.id,i));if(!u())return;x&&(c=x)}else throw M.warn("Cannot activate agent - workspace not ready",{agentId:i,workspaceId:e.id,isOptimistic:h,hasWorktreePath:!!e.worktreePath,hasRepositoryPath:!!e.repositoryPath,hasPath:!!e.path}),new Error(n.agent_streamLifecycle_spaceNotReady_error())}else c&&c.status==="pending"&&c.backendSessionId&&(M.info("Fixing status for already-activated session",{agentId:i,backendSessionId:c.backendSessionId,activationState:c.activationState}),c={...c,status:Ge.Active,activationState:K.ACTIVE},A(me({...c,workspaceId:e.id})));if(!c)throw new Error(`Failed to get or create session for agent ${i}`);A(me({...c,workspaceId:e.id}));const g=[{type:"text",text:s}];if(t.imageBlocks)for(const h of t.imageBlocks)g.push({type:"image",...h.data!==void 0?{data:h.data}:{},...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.attachmentId!==void 0?{attachmentId:h.attachmentId}:{}});if(t.fileBlocks)for(const h of t.fileBlocks)g.push({type:"file",attachmentId:h.attachmentId,fileName:h.fileName,...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.size!==void 0?{size:h.size}:{}});const d=t.userAppMessageId??ce(),k=t.messageMetadata?.[Re],P={...t.contextReferences?.length?{contextReferences:t.contextReferences}:{},...k!==void 0?{[Re]:k}:{}},D={id:Ee(ue()),appMessageId:d,role:"user",contentBlocks:g,timestamp:new Date().toISOString(),metadata:{...P,...t.messageMetadata??{}}};o||(l&&(f("rejected"),_=!0),A(Pe(c.id,D))),A(H(c.id,!0));let $=!1,C;try{o||await p.dispatch(xe(e.id,i,!0,{allowTruncation:t.resetHistory}));const h=Ee(`msg_${ue()}`),Y=ce(),x=async()=>nt.wrap(async()=>{if(!u())return;M.info("Agent Service: Sending message to backend with image and file blocks",{agentId:i,sessionId:c.id,hasImageBlocks:!!t.imageBlocks,imageBlocksCount:t.imageBlocks?.length||0,imageBlockDetails:t.imageBlocks?.map(m=>({type:m.type,mimeType:m.mimeType,dataLength:m.data?.length||0}))||[],hasFileBlocks:!!t.fileBlocks,fileBlocksCount:t.fileBlocks?.length||0,fileBlockDetails:t.fileBlocks?.map(m=>({type:m.type,fileName:m.fileName,mimeType:m.mimeType,attachmentId:m.attachmentId,size:m.size}))||[]});const Me=t.model??t.modelId??c.model??void 0;A(Ve(i));const Ne=le(i,e.id),ne=p.state.chatState?.byAgentId[i]?.attemptGeneration??0,T=await qe("agent.sendMessage",{agentId:i,...o&&l?{messageId:l.id}:{},workspaceId:e.id,content:s,model:Me,contextReferences:t.contextReferences,imageBlocks:t.imageBlocks,fileBlocks:t.fileBlocks,noteIds:t.noteIds,stdinContext:t.stdinContext,assistantMessageId:h,userAppMessageId:d,assistantAppMessageId:Y,priority:t.priority,...t.messageMetadata?{messageMetadata:t.messageMetadata}:{}}).catch(m=>{if(u())throw Ke(m)&&(C=m),m});if(u()){if(ht(T)){M.info("Backend dropped duplicate in-flight prompt",{agentId:i,sessionId:c.id}),f("rejected");return}if(T&&typeof T=="object"&&"success"in T){if(!T.success){const m=T.error,I=typeof m=="string"?m:m?.message;throw $=!0,new Error(I||n.agent_streamLifecycle_sendToBackendFailed_error())}if("queued"in T&&T.queued===!0){if(M.info("sendMessage auto-queued by daemon (mid-turn or turn-startup race)",{agentId:i,sessionId:c.id,queuedMessageId:T.queuedMessage?.id}),(!o||!l||!de.select(p.state,l))&&A(H(c.id,!1)),o||A(Ue(c.id,D.id)),o){const I=T.queuedMessage,G=T.turnId,L=typeof G=="string"?G:I?.turnId;if(I&&typeof L=="string"){const S=fe(s,t),X=Q.select(p.state,i,e.id).find(oe=>oe.id===I.id||oe.turnId===L);A(_e(i,I.id,S,L,he(X??I,S),!X&&!!l&&de.select(p.state,l),ne))}f("accepted",I,!0),z(i,e.id);return}const m=T.queuedMessage;if(m){const I=T.turnId,G=typeof I=="string"?I:m.turnId;let L=m;if(u()&&le(i,e.id)===Ne){const S=Q.select(p.state,i,e.id),X=ze(S,m);A(Be(i,X,e.id))}else u()&&(M.debug("queued-response queue seed superseded by an authoritative snapshot; reconciling via hydrate",{agentId:i,queuedMessageId:m.id}),await z(i,e.id).catch(()=>{}),L=Q.select(p.state,i,e.id).find(S=>S.id===m.id||S.turnId===G));if(u()&&typeof G=="string"){const S=fe(s,t);A(_e(i,m.id,S,G,he(L??m,S),!L,ne))}else u()&&M.warn("auto-queued sendMessage response carried no turnId; retry record not parked",{agentId:i,queuedMessageId:m.id})}return}}o&&(f("accepted"),z(i,e.id),ve(i,e.id)),_t.incrementMessageSent(e.id)}},"send message",{retries:o?0:2,notify:!1,context:{agentId:i,workspace:e.id}}),ae=o?await x().then(()=>({success:!0,error:void 0})):await mt.executeWithRecovery(x,ye.streaming,`send-message-${i}`);if(!ae.success)throw ae.error||new Error(n.agent_streamLifecycle_sendFailed_error())}catch(h){if(!u())return;throw A(H(c.id,!1)),!o&&t.messageMetadata&&A($e(c.id,D.id,{metadata:P})),o&&f($||C?"rejected":"uncertain"),C??h}}}},{memoize:!1,coalesce:!0,priority:"high"})}export{Te as U,Ft as a,ee as c,ze as r,kt as s,Ke as u,bt as w};
1
+ var De=Object.defineProperty;var Ce=(i,s,e)=>s in i?De(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e;var E=(i,s,e)=>Ce(i,typeof s!="symbol"?s+"":s,e);import{K as Le,P as ce,a6 as le,as as z,aC as ve}from"./BGN20Sak.js";import{b_ as we,c$ as ue,cr as de,cq as be}from"./DBb8bRDA.js";import{JH as p,Cg as Fe,bJ as ke,i as Ge,LM as me,ir as Ee,bV as Pe,Ec as H,CF as xe,fl as Ve,AL as Ue,e3 as fe,fh as _e,e2 as he,Be,Lq as $e,wy as Xe}from"./B9vHutcJ.js";import{aO as Se,dX as ge,A as K,P as Re,aK as Q}from"./C2UL5Ler.js";import{h as qe}from"./TB9r2XJy.js";import{c as W}from"./ChTqQfQN.js";import{a as We}from"./BdWqymET.js";import{m as j}from"./96V4v2iI.js";import"./3SdAC2_C.js";import{bm as n}from"./CLAmm_T1.js";import"./CcJmuwXr.js";import"./BwNrQXlF.js";import"./BbYWP3Ow.js";import{R as pe}from"./B5aYN90J.js";import{L as Ye}from"./CSiaiLHL.js";function ze(i,s){return i.some(e=>e.id===s.id)?i.map(e=>e.id===s.id?{...s,...s.author==null&&e.author!==void 0?{author:e.author}:{}}:e):[...i,s]}const Te="confirmUnslothModelSwitch";function He(i){if(!i||typeof i!="object")return!1;const{agentId:s,agentName:e,workspaceId:t,workspaceTitle:r}=i;return typeof s=="string"&&typeof e=="string"&&typeof t=="string"&&(r===null||typeof r=="string")}function Ke(i){for(let s=i,e=0;s&&e<4;e++){const t=s.data;if(t&&typeof t=="object"){const{code:r,currentModel:a,requestedModel:l,agents:o}=t;if(r==="unsloth-model-switch-confirmation-required"&&typeof a=="string"&&typeof l=="string"&&Array.isArray(o)&&o.every(He))return{currentModel:a,requestedModel:l,agents:o}}s=s.cause}}function bt(i){if(!i||!(Te in i))return i;const{[Te]:s,...e}=i;return Object.keys(e).length>0?e:void 0}const Z=typeof performance<"u"?performance:{now:()=>Date.now()},V=new We("PerformanceOptimizer"),w=class w{constructor(){E(this,"metricsBuffer");E(this,"metricsIndex",0);E(this,"metricsCount",0);E(this,"MAX_METRICS",500);E(this,"TARGET_RESPONSE_TIME",100);E(this,"memoCache",new Map);E(this,"MEMO_TTL",6e4);E(this,"MAX_CACHE_SIZE",100);E(this,"cacheHits",0);E(this,"cacheMisses",0);E(this,"pendingRequests",new Map);E(this,"requestQueue",[]);E(this,"cleanupInterval",null);this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.startCacheCleanup(),V.info("PerformanceOptimizer initialized")}static getInstance(){return w.instance||(w.instance=new w),w.instance}reset(){this.metricsBuffer=new Array(this.MAX_METRICS).fill(null),this.metricsIndex=0,this.metricsCount=0,this.memoCache.clear(),this.pendingRequests.clear(),this.requestQueue=[],this.cacheHits=0,this.cacheMisses=0}clearCache(){this.memoCache.clear(),this.cacheHits=0,this.cacheMisses=0}async processBatch(s,e,t={}){const{batchSize:r=10,concurrency:a=4}=t,l=[];for(let o=0;o<s.length;o+=r){const _=s.slice(o,o+r).map((c,R)=>{const g=Math.floor(R/a)*10;return new Promise(d=>{setTimeout(async()=>{const k=await e(c);d(k)},g)})}),u=await Promise.all(_);l.push(...u)}return l}startCacheCleanup(){this.cleanupInterval=setInterval(()=>{this.cleanupCache()},3e4)}stopCacheCleanup(){this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null)}cleanupCache(){const s=Date.now(),e=[];this.memoCache.forEach((t,r)=>{s-t.timestamp>this.MEMO_TTL&&e.push(r)}),e.forEach(t=>this.memoCache.delete(t)),this.memoCache.size>this.MAX_CACHE_SIZE&&Array.from(this.memoCache.entries()).sort((a,l)=>a[1].hits-l[1].hits||a[1].timestamp-l[1].timestamp).slice(0,this.memoCache.size-this.MAX_CACHE_SIZE).forEach(([a])=>this.memoCache.delete(a))}async track(s,e,t={}){const r=Z.now();try{const a=t.cacheKey||s;if(t.memoize){const _=this.getMemoized(a);if(_!==void 0)return this.cacheHits++,V.debug("Memoized result used",{operation:s,cacheKey:a,hits:this.cacheHits}),_;this.cacheMisses++}if(t.coalesce){const _=this.pendingRequests.get(s);if(_)return V.debug("Request coalesced",{operation:s}),_}let l;t.coalesce?(l=t.timeout?this.withTimeout(e(),t.timeout):e(),this.pendingRequests.set(s,l)):l=t.timeout?this.withTimeout(e(),t.timeout):e();const o=await l;t.memoize&&this.memoize(a,o);const f=Z.now()-r;return this.recordMetric(s,f,!0,{strategy:t.priority||"normal",memoized:t.memoize||!1,coalesced:t.coalesce||!1}),f>this.TARGET_RESPONSE_TIME&&V.warn("Operation exceeded target time",{operation:s,duration:Math.round(f),target:this.TARGET_RESPONSE_TIME}),o}catch(a){const l=Z.now()-r;throw this.recordMetric(s,l,!1,{error:a instanceof Error?a.message:"Unknown error"}),a}finally{t.coalesce&&this.pendingRequests.delete(s)}}getStats(){if(this.metricsCount===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const s=[],e=this.metricsCount<this.MAX_METRICS?0:this.metricsIndex;for(let u=0;u<this.metricsCount;u++){const c=this.metricsBuffer[(e+u)%this.MAX_METRICS];c&&s.push(c)}if(s.length===0)return{avgResponseTime:0,p95ResponseTime:0,p99ResponseTime:0,successRate:100,slowOperations:[]};const t=s.sort((u,c)=>u.duration-c.duration);let r=0,a=0;const l=new Set;for(const u of s)a+=u.duration,u.success&&r++,u.duration>this.TARGET_RESPONSE_TIME&&l.add(u.operation);const o=a/s.length,f=Math.floor(t.length*.95),_=Math.floor(t.length*.99);return{avgResponseTime:Math.round(o),p95ResponseTime:Math.round(t[f]?.duration||0),p99ResponseTime:Math.round(t[_]?.duration||0),successRate:r/s.length*100,slowOperations:Array.from(l)}}getCacheStats(){const s=this.cacheHits+this.cacheMisses;return{size:this.memoCache.size,hitRate:s>0?this.cacheHits/s*100:0,hits:this.cacheHits,misses:this.cacheMisses}}getMemoized(s){const e=this.memoCache.get(s);if(e){if(Date.now()-e.timestamp>this.MEMO_TTL){this.memoCache.delete(s);return}return e.hits++,e.value}}memoize(s,e){const t=JSON.stringify(e).length;this.memoCache.set(s,{value:e,timestamp:Date.now(),hits:0,size:t}),this.memoCache.size>this.MAX_CACHE_SIZE&&this.cleanupCache()}async withTimeout(s,e){return Promise.race([s,new Promise((t,r)=>setTimeout(()=>r(new Error(`Operation timed out after ${e}ms`)),e))])}recordMetric(s,e,t,r){this.metricsBuffer[this.metricsIndex]={operation:s,duration:e,timestamp:Date.now(),success:t,metadata:r},this.metricsIndex=(this.metricsIndex+1)%this.MAX_METRICS,this.metricsCount<this.MAX_METRICS&&this.metricsCount++,e>this.TARGET_RESPONSE_TIME&&V.warn("Slow operation detected",{operation:s,duration:`${e.toFixed(2)}ms`,target:`${this.TARGET_RESPONSE_TIME}ms`,metadata:r})}};E(w,"instance");let te=w;const Qe=te.getInstance(),Ae={AGENT_CREATION:"https://docs.example.com/agent-creation",STREAMING:"https://docs.example.com/streaming-issues",STORAGE:"https://docs.example.com/storage-troubleshooting",MEMORY:"https://docs.example.com/memory-management",PROVIDER:"https://docs.example.com/provider-setup",GENERAL:"https://docs.example.com/help"},J={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_template({agentName:"{agentName}",details:"{details}"})},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_template({agentName:"{agentName}"})},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_template({details:"{details}"})},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_template({details:"{details}"})},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_template({sessionId:"{sessionId}"})},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_template()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_template({details:"{details}"})},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_template({details:"{details}"})},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_template({timeout:"{timeout}"})},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_template({attempt:"{attempt}",maxAttempts:"{maxAttempts}"})},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_template({attempts:"{attempts}"})},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_template({details:"{details}"})},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_template({details:"{details}"})},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_template({maxLength:"{maxLength}",currentLength:"{currentLength}"})},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_template({provider:"{provider}"})},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_template({provider:"{provider}",details:"{details}"})},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_template({provider:"{provider}"})},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_template({details:"{details}"})},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_template({details:"{details}"})},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_template({lastBackup:"{lastBackup}"})},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_template({currentUsage:"{currentUsage}",limit:"{limit}"})},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_template({count:"{count}",window:"{window}"})},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_template({current:"{current}",max:"{max}"})}},je={get AGENT_CREATION_FAILED(){return n.errors_catalog_agentCreationFailed_friendly()},get AGENT_ALREADY_EXISTS(){return n.errors_catalog_agentAlreadyExists_friendly()},get INVALID_AGENT_CONFIG(){return n.errors_catalog_invalidAgentConfig_friendly()},get INVALID_CONFIG(){return n.errors_catalog_invalidConfig_friendly()},get SESSION_NOT_FOUND(){return n.errors_catalog_sessionNotFound_friendly()},get SESSION_ALREADY_ACTIVE(){return n.errors_catalog_sessionAlreadyActive_friendly()},get SESSION_INITIALIZATION_FAILED(){return n.errors_catalog_sessionInitializationFailed_friendly()},get STREAM_CONNECTION_FAILED(){return n.errors_catalog_streamConnectionFailed_friendly()},get STREAM_TIMEOUT(){return n.errors_catalog_streamTimeout_friendly()},get STREAM_INTERRUPTED(){return n.errors_catalog_streamInterrupted_friendly()},get STREAM_RECOVERY_FAILED(){return n.errors_catalog_streamRecoveryFailed_friendly()},get MESSAGE_SEND_FAILED(){return n.errors_catalog_messageSendFailed_friendly()},get MESSAGE_VALIDATION_FAILED(){return n.errors_catalog_messageValidationFailed_friendly()},get MESSAGE_TOO_LONG(){return n.errors_catalog_messageTooLong_friendly()},get PROVIDER_NOT_FOUND(){return n.errors_catalog_providerNotFound_friendly()},get PROVIDER_CONNECTION_FAILED(){return n.errors_catalog_providerConnectionFailed_friendly()},get PROVIDER_PROCESS_DIED(){return n.errors_catalog_providerProcessDied_friendly()},get STORAGE_READ_FAILED(){return n.errors_catalog_storageReadFailed_friendly()},get STORAGE_WRITE_FAILED(){return n.errors_catalog_storageWriteFailed_friendly()},get STORAGE_CORRUPTED(){return n.errors_catalog_storageCorrupted_friendly()},get MEMORY_LIMIT_EXCEEDED(){return n.errors_catalog_memoryLimitExceeded_friendly()},get RATE_LIMIT_EXCEEDED(){return n.errors_catalog_rateLimitExceeded_friendly()},get CONCURRENT_LIMIT_EXCEEDED(){return n.errors_catalog_concurrentLimitExceeded_friendly()}};function Ze(i){return(i.match(/{(\w+)}/g)||[]).map(e=>e.slice(1,-1))}function Je(i,s){return Ze(i).every(t=>t in s)}function Oe(i,s={}){return i.replace(/{(\w+)}/g,(e,t)=>String(s[t]??e))}function ee(i){const s=n.errors_cleanMessage_fallback_error();if(!i)return s;let e=i;return e=e.replace(/^.*?failed(?:\s+to\s+.*?)?\s+after\s+\d+\s+attempts:\s*/i,""),e=e.replace(/^Error invoking remote method '[^']+':(\s*Error:)?\s*/i,""),e=e.replace(/^(Error:\s*)+/i,""),e=e.replace(/\n\s*at .+/g,""),e=e.replace(/\s+/g," ").trim(),e||s}function et(i,s){return s&&J[i]&&Je(J[i],s)?Oe(J[i],s):je[i]||n.errors_userFriendly_fallback_error()}function tt(i){const e={AGENT_CREATION_FAILED:"AGENT_CREATION",AGENT_ALREADY_EXISTS:"AGENT_CREATION",INVALID_AGENT_CONFIG:"AGENT_CREATION",STREAM_CONNECTION_FAILED:"STREAMING",STREAM_TIMEOUT:"STREAMING",STREAM_INTERRUPTED:"STREAMING",STREAM_RECOVERY_FAILED:"STREAMING",STORAGE_READ_FAILED:"STORAGE",STORAGE_WRITE_FAILED:"STORAGE",STORAGE_CORRUPTED:"STORAGE",MEMORY_LIMIT_EXCEEDED:"MEMORY",RATE_LIMIT_EXCEEDED:"MEMORY",CONCURRENT_LIMIT_EXCEEDED:"MEMORY",PROVIDER_NOT_FOUND:"PROVIDER",PROVIDER_CONNECTION_FAILED:"PROVIDER",PROVIDER_PROCESS_DIED:"PROVIDER"}[i];return e?Ae[e]:Ae.GENERAL}const st={AGENT_CREATION_FAILED:[{action:"retry",description:"Try creating the agent again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify agent configuration in settings",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient memory and disk space",automatic:!1,priority:"medium"}],AGENT_ALREADY_EXISTS:[{action:"rename",description:"Choose a different name for the agent",automatic:!1,priority:"high"},{action:"delete-existing",description:"Delete the existing agent first",automatic:!1,priority:"medium"}],INVALID_AGENT_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],INVALID_CONFIG:[{action:"review-config",description:"Review and correct the configuration",automatic:!1,priority:"high"},{action:"use-defaults",description:"Reset to default configuration",automatic:!1,priority:"medium"}],SESSION_NOT_FOUND:[{action:"start-new",description:"Start a new agent session",automatic:!1,priority:"high"},{action:"check-history",description:"Check session history for recent sessions",automatic:!1,priority:"medium"}],SESSION_ALREADY_ACTIVE:[{action:"wait",description:"Wait for the current session to complete",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel the active session first",automatic:!1,priority:"high"}],SESSION_INITIALIZATION_FAILED:[{action:"retry",description:"Try initializing the session again",automatic:!1,priority:"high"},{action:"check-resources",description:"Ensure sufficient resources are available",automatic:!1,priority:"medium"}],MESSAGE_SEND_FAILED:[{action:"retry",description:"Try sending the message again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],MESSAGE_VALIDATION_FAILED:[{action:"review-config",description:"Review and correct the message format",automatic:!1,priority:"high"},{action:"check-config",description:"Check configuration for valid message format",automatic:!1,priority:"medium"}],MESSAGE_TOO_LONG:[{action:"retry",description:"Shorten the message and try again",automatic:!1,priority:"high"},{action:"batch",description:"Split the message into multiple parts",automatic:!1,priority:"medium"}],PROVIDER_NOT_FOUND:[{action:"check-config",description:"Verify provider is properly configured",automatic:!1,priority:"high"},{action:"recreate",description:"Install or reinstall the provider",automatic:!1,priority:"high"}],PROVIDER_CONNECTION_FAILED:[{action:"retry",description:"Try connecting to the provider again",automatic:!1,priority:"high"},{action:"check-config",description:"Verify provider configuration",automatic:!1,priority:"high"}],STORAGE_READ_FAILED:[{action:"retry",description:"Try reading the data again",automatic:!1,priority:"high"},{action:"restore",description:"Restore from a recent backup",automatic:!1,priority:"medium"}],STORAGE_WRITE_FAILED:[{action:"retry",description:"Try saving again",automatic:!1,priority:"high"},{action:"check-resources",description:"Check available disk space",automatic:!1,priority:"high"}],STREAM_CONNECTION_FAILED:[{action:"retry",description:"Try connecting again",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your network connection",automatic:!1,priority:"high"}],STREAM_RECOVERY_FAILED:[{action:"restart",description:"Restart the agent",automatic:!1,priority:"high"},{action:"check-config",description:"Check error logs for more details",automatic:!1,priority:"medium"}],STREAM_INTERRUPTED:[{action:"reconnect",description:"Attempting automatic reconnection",automatic:!0,priority:"high"},{action:"retry",description:"Retry sending the message",automatic:!1,priority:"high"},{action:"check-connection",description:"Check your internet connection",automatic:!1,priority:"medium"}],STREAM_TIMEOUT:[{action:"wait",description:"Wait for agent to complete processing",automatic:!1,priority:"high"},{action:"cancel",description:"Cancel current operation",automatic:!1,priority:"medium"},{action:"increase-timeout",description:"Increase timeout in settings",automatic:!1,priority:"low"}],PROVIDER_PROCESS_DIED:[{action:"restart",description:"Restart agent process",automatic:!0,priority:"high"},{action:"recreate",description:"Create new agent session",automatic:!1,priority:"high"}],STORAGE_CORRUPTED:[{action:"restore",description:"Restore from backup",automatic:!1,priority:"high"},{action:"reset",description:"Reset agent data",automatic:!1,priority:"medium"}],MEMORY_LIMIT_EXCEEDED:[{action:"cleanup",description:"Close unused agents",automatic:!1,priority:"high"},{action:"increase-limit",description:"Increase memory limit in settings",automatic:!1,priority:"medium"}],RATE_LIMIT_EXCEEDED:[{action:"wait",description:"Wait before making more requests",automatic:!1,priority:"high"},{action:"batch",description:"Batch requests together",automatic:!1,priority:"medium"}],CONCURRENT_LIMIT_EXCEEDED:[{action:"close-agents",description:"Close some running agents",automatic:!1,priority:"high"},{action:"queue",description:"Queue operation for later",automatic:!1,priority:"medium"}]};function it(i){return st[i]||[{action:"retry",description:"Try the operation again",automatic:!1,priority:"high"}]}var N=(i=>(i.AGENT_CREATION_FAILED="AGENT_CREATION_FAILED",i.AGENT_ALREADY_EXISTS="AGENT_ALREADY_EXISTS",i.INVALID_AGENT_CONFIG="INVALID_AGENT_CONFIG",i.INVALID_CONFIG="INVALID_CONFIG",i.SESSION_NOT_FOUND="SESSION_NOT_FOUND",i.SESSION_ALREADY_ACTIVE="SESSION_ALREADY_ACTIVE",i.SESSION_INITIALIZATION_FAILED="SESSION_INITIALIZATION_FAILED",i.STREAM_CONNECTION_FAILED="STREAM_CONNECTION_FAILED",i.STREAM_TIMEOUT="STREAM_TIMEOUT",i.STREAM_INTERRUPTED="STREAM_INTERRUPTED",i.STREAM_RECOVERY_FAILED="STREAM_RECOVERY_FAILED",i.MESSAGE_SEND_FAILED="MESSAGE_SEND_FAILED",i.MESSAGE_VALIDATION_FAILED="MESSAGE_VALIDATION_FAILED",i.MESSAGE_TOO_LONG="MESSAGE_TOO_LONG",i.PROVIDER_NOT_FOUND="PROVIDER_NOT_FOUND",i.PROVIDER_CONNECTION_FAILED="PROVIDER_CONNECTION_FAILED",i.PROVIDER_PROCESS_DIED="PROVIDER_PROCESS_DIED",i.PROVIDER_UNAVAILABLE="PROVIDER_UNAVAILABLE",i.PROVIDER_ERROR="PROVIDER_ERROR",i.STORAGE_READ_FAILED="STORAGE_READ_FAILED",i.STORAGE_WRITE_FAILED="STORAGE_WRITE_FAILED",i.STORAGE_CORRUPTED="STORAGE_CORRUPTED",i.STORAGE_ERROR="STORAGE_ERROR",i.STORAGE_QUOTA_EXCEEDED="STORAGE_QUOTA_EXCEEDED",i.MEMORY_LIMIT_EXCEEDED="MEMORY_LIMIT_EXCEEDED",i.RATE_LIMIT_EXCEEDED="RATE_LIMIT_EXCEEDED",i.CONCURRENT_LIMIT_EXCEEDED="CONCURRENT_LIMIT_EXCEEDED",i.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",i.RESOURCE_EXHAUSTED="RESOURCE_EXHAUSTED",i.NETWORK_ERROR="NETWORK_ERROR",i.PERMISSION_DENIED="PERMISSION_DENIED",i.OPERATION_FAILED="OPERATION_FAILED",i.VALIDATION_ERROR="VALIDATION_ERROR",i.INVALID_RESPONSE="INVALID_RESPONSE",i.STATE_CORRUPTION="STATE_CORRUPTION",i.CONTEXT_OVERFLOW="CONTEXT_OVERFLOW",i))(N||{});class q extends Error{constructor(e,t,r={},a){super(e);E(this,"code");E(this,"context");E(this,"recoverySuggestions");E(this,"userMessage");E(this,"isRecoverable");E(this,"cause");this.name="AgentError",this.code=t,this.context={...r,timestamp:new Date,stackTrace:this.stack},this.userMessage=a?.userMessage||this.getDefaultUserMessage(t),this.recoverySuggestions=a?.recoverySuggestions||this.getDefaultRecoverySuggestions(t),this.isRecoverable=a?.isRecoverable??this.isErrorRecoverable(t),a?.cause&&(this.cause=a.cause)}getDefaultUserMessage(e){return et(e,this.context)}getDefaultRecoverySuggestions(e){return it(e)}isErrorRecoverable(e){return["STREAM_INTERRUPTED","STREAM_TIMEOUT","MESSAGE_SEND_FAILED","PROVIDER_PROCESS_DIED","STORAGE_READ_FAILED","STORAGE_WRITE_FAILED"].includes(e)}getHelpLink(){return tt(this.code)}formatMessage(e){return Oe(e,this.context)}toJSON(){return{name:this.name,code:this.code,message:this.message,userMessage:this.userMessage,context:this.context,recoverySuggestions:this.recoverySuggestions,isRecoverable:this.isRecoverable,helpLink:this.getHelpLink(),stack:this.stack}}}const rt={NON_RETRYABLE_ERRORS:["EACCES","EPERM","ENOSPC","EMFILE","permission","memory","fatal","process died","not available on your current plan","agent binary","rate limit","too many requests","hit your limit","you've hit your limit","quota exceeded"]};function re(i){const s=i.toLowerCase();for(const e of rt.NON_RETRYABLE_ERRORS)if(s.includes(e.toLowerCase()))return!0;return!1}const at="Agent already has an in-flight prompt. Message was not delivered.",v=W("ErrorBoundary"),b=class b{constructor(){}static getInstance(){return b.instance||(b.instance=new b),b.instance}async wrap(s,e,t={}){const{retries:r=pe.DEFAULT_ATTEMPTS,retryDelay:a=pe.BASE_DELAY,exponentialBackoff:l=!0,notify:o=!1,notifyOnRetry:f=!1,context:_={},onError:u,onRetry:c,shouldRetry:R=this.defaultShouldRetry}=t;let g=null,d=0;for(d=1;d<=r+1;d++)try{v.debug(`[${e}] Attempt ${d}/${r+1}`);const C=await s();return d>1&&v.info(`[${e}] Succeeded after ${d} attempts`),C}catch(C){if(g=C,v.error(`[${e}] Attempt ${d} failed`,{error:g.message,attempt:d,maxAttempts:r+1,context:_}),u?.(g,d),d<=r&&R(g)){const h=l?a*Math.pow(2,d-1):a;f&&j.warning(n.agent_errorBoundary_retrying_message({seconds:h/1e3})),c?.(d),v.info(`[${e}] Retrying in ${h}ms`),await this.sleep(h)}else break}const k=`${e} failed after ${d} attempt${d===1?"":"s"}: ${g?.message}`,P=ee(g?.message||n.agent_errorBoundary_generic_error()),D=g?.message?.toLowerCase()||"",$=D.includes("no available models")||D.includes("all models exhausted")||D.includes("all models unavailable");throw o&&!$&&j.error(P),new q(P,N.OPERATION_FAILED,{originalError:g?.message,detailedMessage:k,attempts:d,context:_})}async wrapVoid(s,e,t={}){await this.wrap(s,e,t)}wrapSync(s,e,t={}){try{return s()}catch(r){const a=r;throw v.error(`[${e}] Failed`,{error:a.message,context:t.context}),t.notify&&j.error(ee(a.message)),new q(ee(a.message),N.OPERATION_FAILED,t.context)}}defaultShouldRetry(s){const e=s.message.toLowerCase();return re(s.message)?!1:e.includes("network")||e.includes("timeout")?!0:s instanceof q?[N.NETWORK_ERROR,N.STREAM_TIMEOUT,N.STREAM_CONNECTION_FAILED,N.PROVIDER_CONNECTION_FAILED,N.PROVIDER_UNAVAILABLE].includes(s.code):!(e.includes("invalid")||e.includes("interrupted")||e.includes("cancel")||e.includes("not found")||e.includes("not available")||e.includes("404")||e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||e.includes("413")||e.includes("too long for the agent")||e.includes("request entity too large")||e.includes("payload too large")||e.includes("content too large")||e.includes("body too large")||e.includes("unauthorized")||e.includes("forbidden")||e.includes("401")||e.includes("403"))}sleep(s){return new Promise(e=>setTimeout(e,s))}async withTimeout(s,e,t){return Promise.race([s(),new Promise((r,a)=>setTimeout(()=>a(new q(`${t} timed out after ${e}ms`,N.STREAM_TIMEOUT)),e))])}async batchOperations(s,e,t={}){const{concurrency:r=5,continueOnError:a=!0,operationName:l="batch operation"}=t,o=[],f=[];for(let _=0;_<s.length;_+=r){const u=s.slice(_,_+r);(await Promise.allSettled(u.map(R=>e(R)))).forEach((R,g)=>{if(R.status==="fulfilled")o.push(R.value);else{const d=R.reason;if(f.push({item:u[g],error:d}),v.error(`[${l}] Batch item failed`,{item:u[g],error:d.message}),!a)throw d}})}return f.length>0&&v.warn(`[${l}] Completed with ${f.length} errors`),{results:o,errors:f}}};E(b,"instance");let se=b;const nt=se.getInstance(),ie=W("browser/index"),F=new Map,B=new Map;let U;function ot(i,s,e){for(const t of s)try{t(e)}catch(r){ie.error("Error in agent subscriber callback",{agentId:i,error:r})}}function ct(){if(U)return;let i=!1;U=p.createSelector(e=>e.agentSessions)().subscribe(()=>{if(!i){i=!0;return}if(F.size===0)return;const e=p.state;for(const[t,r]of F){const a=Se.select(e,t);B.get(t)!==a&&(B.set(t,a),ot(t,r,a))}})}function lt(){F.size>0||!U||(U(),U=void 0,B.clear())}function Ft(i,s,e){let t=F.get(i);const r=!t;t||(t=new Set,F.set(i,t)),t.add(s),ct();const a=p.state,l=Se.select(a,i);return r&&B.set(i,l),l?ie.debug("[subscribeToAgent] Initial callback data",{agentId:i,workspaceId:e??"current",hasSession:!0}):ie.debug("[subscribeToAgent] No session found",{agentId:i,workspaceId:e??"current"}),s(l),()=>{const o=F.get(i);o&&(o.delete(s),o.size===0&&(F.delete(i),B.delete(i))),lt()}}const y=W("ErrorRecovery"),ye={network:{maxRetries:3,initialBackoffMs:1e3,maxBackoffMs:1e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("network")||s.includes("fetch")||s.includes("connection")||s.includes("timeout")}},streaming:{maxRetries:5,initialBackoffMs:500,maxBackoffMs:5e3,backoffMultiplier:1.5,shouldRetry:(i,s)=>{if(s>=5)return!1;const e=i.message.toLowerCase();return e.includes("no available models")||e.includes("all models exhausted")||e.includes("all models unavailable")||re(i.message)?!1:e.includes("stream")||e.includes("chunk")||e.includes("incomplete")}},persistence:{maxRetries:2,initialBackoffMs:100,maxBackoffMs:1e3,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("save")||s.includes("write")||s.includes("persist")}},rateLimit:{maxRetries:3,initialBackoffMs:5e3,maxBackoffMs:3e4,backoffMultiplier:2,shouldRetry:i=>{const s=i.message.toLowerCase();return s.includes("rate")||s.includes("limit")||s.includes("429")}}};class ut{constructor(){E(this,"listeners",new Map)}on(s,e){let t=this.listeners.get(s);t||(t=new Set,this.listeners.set(s,t)),t.add(e)}off(s,e){this.listeners.get(s)?.delete(e)}emit(s,...e){this.listeners.get(s)?.forEach(t=>{try{t(...e)}catch(r){y.error(`Error in event listener for ${s}:`,r)}})}removeAllListeners(){this.listeners.clear()}}class dt extends ut{constructor(){super(...arguments);E(this,"activeRecoveries",new Map);E(this,"recoveryStats",new Map)}async executeWithRecovery(e,t=ye.network,r){const a=Date.now(),l=new AbortController;r&&(this.cancelRecovery(r),this.activeRecoveries.set(r,l));let o,f=t.initialBackoffMs,_=0;for(let u=1;u<=t.maxRetries;u++){if(_=u,l.signal.aborted){y.info(`Recovery cancelled for operation ${r}`);break}try{y.debug(`Attempting operation (attempt ${u}/${t.maxRetries})`,{operationId:r});const c=await e();return this.updateStats(r,!0),this.emit("recovery:success",{operationId:r,attempt:u,duration:Date.now()-a}),r&&this.activeRecoveries.delete(r),{success:!0,data:c,attempts:u,totalTime:Date.now()-a}}catch(c){o=c,y.warn(`Operation failed (attempt ${u}/${t.maxRetries})`,{operationId:r,error:o.message});const R=o.message.toLowerCase();if(R.includes("interrupted")||R.includes("cancelled")||R.includes("canceled")){y.debug("User-initiated interruption/cancellation, not retrying",{operationId:r,error:o.message});break}if(R.includes("no available models")||R.includes("all models exhausted")||R.includes("all models unavailable")){y.debug("All models exhausted, not retrying",{operationId:r,error:o.message});break}if(re(o.message)){y.debug("Fatal error detected, not retrying",{operationId:r,error:o.message});break}if(!t.shouldRetry(o,u)){y.debug("Error not retryable, stopping recovery",{operationId:r,error:o.message});break}if(u<t.maxRetries){const g=Math.random()*.2*f,d=Math.min(f+g,t.maxBackoffMs);t.onRetry?.(u,d),this.emit("recovery:retry",{operationId:r,attempt:u,delay:d,error:o.message}),await this.delay(d,l.signal),f=Math.min(f*t.backoffMultiplier,t.maxBackoffMs)}}}return this.updateStats(r,!1),t.onFailure?.(o,_),this.emit("recovery:failure",{operationId:r,attempts:_,duration:Date.now()-a,error:o?.message}),r&&this.activeRecoveries.delete(r),{success:!1,error:o,attempts:_,totalTime:Date.now()-a}}cancelRecovery(e){const t=this.activeRecoveries.get(e);t&&(t.abort(),this.activeRecoveries.delete(e),y.info(`Cancelled recovery for operation ${e}`))}cancelAllRecoveries(){for(const[e,t]of this.activeRecoveries)t.abort(),y.info(`Cancelled recovery for operation ${e}`);this.activeRecoveries.clear()}getStats(e){if(e)return this.recoveryStats.get(e)||{successes:0,failures:0};const t={};for(const[r,a]of this.recoveryStats)t[r]=a;return t}clearStats(e){e?this.recoveryStats.delete(e):this.recoveryStats.clear()}isRetryable(e,t){const r=e.message.toLowerCase();if(t)switch(t){case"NETWORK":return r.includes("network")||r.includes("fetch");case"TIMEOUT":return r.includes("timeout")||r.includes("timed out");case"RATE_LIMIT":return r.includes("rate")||r.includes("limit")||r.includes("429");case"TEMPORARY":return r.includes("temporary")||r.includes("transient");case"CONFLICT":return r.includes("conflict")||r.includes("concurrent");default:return!1}return this.isRetryable(e,"NETWORK")||this.isRetryable(e,"TIMEOUT")||this.isRetryable(e,"RATE_LIMIT")||this.isRetryable(e,"TEMPORARY")||this.isRetryable(e,"CONFLICT")}delay(e,t){return new Promise((r,a)=>{const l=setTimeout(r,e);if(t){const o=()=>{clearTimeout(l),a(new Error("Delay aborted"))};t.addEventListener("abort",o);const f=r;r=()=>{t.removeEventListener("abort",o),f()}}})}updateStats(e,t){if(!e)return;const r=this.recoveryStats.get(e)||{successes:0,failures:0};t?r.successes++:r.failures++,this.recoveryStats.set(e,r)}dispose(){this.cancelAllRecoveries(),this.recoveryStats.clear(),this.removeAllListeners()}}const mt=new dt,O=new Ye({category:"WorkspaceMetrics"}),Et=100;class ft{constructor(){E(this,"metrics",new Map);E(this,"operations",new Map)}startWorkspaceCreation(s){const e=Date.now();for(this.metrics.delete(s),this.metrics.set(s,{workspaceId:s,creationStarted:e});this.metrics.size>Et;){const t=this.metrics.keys().next().value;if(t===void 0)break;this.metrics.delete(t)}O.info("Started tracking workspace creation",{workspaceId:s})}recordMilestone(s,e){const t=this.metrics.get(s);if(!t){O.warn("No metrics found for workspace",{workspaceId:s,milestone:e});return}const r=Date.now();switch(e){case"optimisticNavigation":t.optimisticNavigation=r;break;case"realWorkspaceCreated":t.realWorkspaceCreated=r;break;case"agentCreated":t.agentCreated=r;break;case"agentReady":t.agentReady=r;break;case"firstMessageSent":t.firstMessageSent=r;break;case"firstResponseReceived":t.firstResponseReceived=r;break;case"firstChunkReceived":t.firstChunkReceived=r;break;case"totalDuration":t.totalDuration=r;break;case"workspaceId":case"creationStarted":O.warn("Cannot update milestone",{milestone:e});return}const a=r-t.creationStarted;O.info(`Milestone: ${e}`,{workspaceId:s,elapsed:`${a}ms`,timestamp:r}),e==="firstResponseReceived"&&(t.totalDuration=r-t.creationStarted,this.logSummary(s))}startOperation(s,e){this.operations.set(s,{startTime:Date.now(),metadata:e})}endOperation(s,e){const t=this.operations.get(s);if(!t)return O.warn("Operation not found",{operationId:s}),null;const r=Date.now();return t.endTime=r,t.duration=r-t.startTime,e&&(t.metadata={...t.metadata,...e}),O.info("Operation completed",{operationId:s,duration:`${t.duration}ms`,metadata:t.metadata}),this.operations.delete(s),t.duration}getMetrics(s){return this.metrics.get(s)}logSummary(s){const e=this.metrics.get(s);if(!e)return;const t={workspaceId:s,totalDuration:`${e.totalDuration}ms`,stages:{optimisticNavigation:e.optimisticNavigation?`${e.optimisticNavigation-e.creationStarted}ms`:"N/A",realWorkspaceCreation:e.realWorkspaceCreated?`${e.realWorkspaceCreated-e.creationStarted}ms`:"N/A",agentCreation:e.agentCreated?`${e.agentCreated-e.creationStarted}ms`:"N/A",agentReady:e.agentReady?`${e.agentReady-e.creationStarted}ms`:"N/A",firstMessage:e.firstMessageSent?`${e.firstMessageSent-e.creationStarted}ms`:"N/A",firstResponse:e.firstResponseReceived?`${e.firstResponseReceived-e.creationStarted}ms`:"N/A"}};O.info("=== Workspace Creation Metrics Summary ===",t),O.info("Workspace Creation Metrics:",t)}clearMetrics(s){this.metrics.delete(s)}incrementAgentCreated(s){const e=this.metrics.get(s);e&&(e.agentCreated=Date.now(),O.info("Agent created",{workspaceId:s}))}incrementMessageSent(s){const e=this.metrics.get(s);e&&!e.firstMessageSent&&(e.firstMessageSent=Date.now(),O.info("First message sent",{workspaceId:s}))}}const _t=new ft,M=W("AgentSend");function A(i){p.dispatch(i)}function Ie(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function ht(i){const s=Ie(i)&&i.success===!0&&"data"in i?i.data:i;return!Ie(s)||s.success!==!1?!1:typeof s.error=="string"&&s.error.includes(at)}async function kt(i,s,e,t={}){const r=ge.select(p.state,e.id);if(!r)return;const a=Le(i,e.id),l=t.submission,o=!!l&&we.select(p.state,l.scope)?.supported===!0,f=(c,R,g=!1)=>{l&&A(Xe(l.scope,l.id,c,Date.now(),R,g))};let _=!1;const u=()=>(!l||_||be.select(p.state,l))&&r===ge.select(p.state,e.id)&&a.isCurrent(p.state.agentSessions?.byAgentId[i]?.workspaceId);return Qe.track(`sendMessage:${a.key}:${i}:${l?.id??"legacy"}`,async()=>{if(!u())return;M.debug(`Sending message to agent ${i}`,{contentLength:s.length,hasContextReferences:!!t.contextReferences?.length,model:t.model});let c=await p.dispatch(Fe(e.id,i));if(u()){if(!c)throw new Error(n.agent_streamLifecycle_sessionNotFound_error({agentId:i}));c={...c,isStreaming:c.isStreaming??!1};{if(c&&(c.status==="pending"||!c.id)&&!c.backendSessionId&&c.activationState!==K.ACTIVE&&c.activationState!==K.ACTIVATING){const h=e.id.startsWith("optimistic-"),Y=e.worktreePath||e.repositoryPath||e.path;if(!h&&Y){M.info("Activating pending session in sendMessage",{agentId:i,status:c.status,activationState:c.activationState,hasBackendSessionId:!!c.backendSessionId});const x=await p.dispatch(ke(e.id,i));if(!u())return;x&&(c=x)}else throw M.warn("Cannot activate agent - workspace not ready",{agentId:i,workspaceId:e.id,isOptimistic:h,hasWorktreePath:!!e.worktreePath,hasRepositoryPath:!!e.repositoryPath,hasPath:!!e.path}),new Error(n.agent_streamLifecycle_spaceNotReady_error())}else c&&c.status==="pending"&&c.backendSessionId&&(M.info("Fixing status for already-activated session",{agentId:i,backendSessionId:c.backendSessionId,activationState:c.activationState}),c={...c,status:Ge.Active,activationState:K.ACTIVE},A(me({...c,workspaceId:e.id})));if(!c)throw new Error(`Failed to get or create session for agent ${i}`);A(me({...c,workspaceId:e.id}));const g=[{type:"text",text:s}];if(t.imageBlocks)for(const h of t.imageBlocks)g.push({type:"image",...h.data!==void 0?{data:h.data}:{},...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.attachmentId!==void 0?{attachmentId:h.attachmentId}:{}});if(t.fileBlocks)for(const h of t.fileBlocks)g.push({type:"file",attachmentId:h.attachmentId,fileName:h.fileName,...h.mimeType!==void 0?{mimeType:h.mimeType}:{},...h.size!==void 0?{size:h.size}:{}});const d=t.userAppMessageId??ce(),k=t.messageMetadata?.[Re],P={...t.contextReferences?.length?{contextReferences:t.contextReferences}:{},...k!==void 0?{[Re]:k}:{}},D={id:Ee(ue()),appMessageId:d,role:"user",contentBlocks:g,timestamp:new Date().toISOString(),metadata:{...P,...t.messageMetadata??{}}};o||(l&&(f("rejected"),_=!0),A(Pe(c.id,D))),A(H(c.id,!0));let $=!1,C;try{o||await p.dispatch(xe(e.id,i,!0,{allowTruncation:t.resetHistory}));const h=Ee(`msg_${ue()}`),Y=ce(),x=async()=>nt.wrap(async()=>{if(!u())return;M.info("Agent Service: Sending message to backend with image and file blocks",{agentId:i,sessionId:c.id,hasImageBlocks:!!t.imageBlocks,imageBlocksCount:t.imageBlocks?.length||0,imageBlockDetails:t.imageBlocks?.map(m=>({type:m.type,mimeType:m.mimeType,dataLength:m.data?.length||0}))||[],hasFileBlocks:!!t.fileBlocks,fileBlocksCount:t.fileBlocks?.length||0,fileBlockDetails:t.fileBlocks?.map(m=>({type:m.type,fileName:m.fileName,mimeType:m.mimeType,attachmentId:m.attachmentId,size:m.size}))||[]});const Me=t.model??t.modelId??c.model??void 0;A(Ve(i));const Ne=le(i,e.id),ne=p.state.chatState?.byAgentId[i]?.attemptGeneration??0,T=await qe("agent.sendMessage",{agentId:i,...o&&l?{messageId:l.id}:{},workspaceId:e.id,content:s,model:Me,contextReferences:t.contextReferences,imageBlocks:t.imageBlocks,fileBlocks:t.fileBlocks,noteIds:t.noteIds,stdinContext:t.stdinContext,assistantMessageId:h,userAppMessageId:d,assistantAppMessageId:Y,priority:t.priority,...t.messageMetadata?{messageMetadata:t.messageMetadata}:{}}).catch(m=>{if(u())throw Ke(m)&&(C=m),m});if(u()){if(ht(T)){M.info("Backend dropped duplicate in-flight prompt",{agentId:i,sessionId:c.id}),f("rejected");return}if(T&&typeof T=="object"&&"success"in T){if(!T.success){const m=T.error,I=typeof m=="string"?m:m?.message;throw $=!0,new Error(I||n.agent_streamLifecycle_sendToBackendFailed_error())}if("queued"in T&&T.queued===!0){if(M.info("sendMessage auto-queued by daemon (mid-turn or turn-startup race)",{agentId:i,sessionId:c.id,queuedMessageId:T.queuedMessage?.id}),(!o||!l||!de.select(p.state,l))&&A(H(c.id,!1)),o||A(Ue(c.id,D.id)),o){const I=T.queuedMessage,G=T.turnId,L=typeof G=="string"?G:I?.turnId;if(I&&typeof L=="string"){const S=fe(s,t),X=Q.select(p.state,i,e.id).find(oe=>oe.id===I.id||oe.turnId===L);A(_e(i,I.id,S,L,he(X??I,S),!X&&!!l&&de.select(p.state,l),ne))}f("accepted",I,!0),z(i,e.id);return}const m=T.queuedMessage;if(m){const I=T.turnId,G=typeof I=="string"?I:m.turnId;let L=m;if(u()&&le(i,e.id)===Ne){const S=Q.select(p.state,i,e.id),X=ze(S,m);A(Be(i,X,e.id))}else u()&&(M.debug("queued-response queue seed superseded by an authoritative snapshot; reconciling via hydrate",{agentId:i,queuedMessageId:m.id}),await z(i,e.id).catch(()=>{}),L=Q.select(p.state,i,e.id).find(S=>S.id===m.id||S.turnId===G));if(u()&&typeof G=="string"){const S=fe(s,t);A(_e(i,m.id,S,G,he(L??m,S),!L,ne))}else u()&&M.warn("auto-queued sendMessage response carried no turnId; retry record not parked",{agentId:i,queuedMessageId:m.id})}return}}o&&(f("accepted"),z(i,e.id),ve(i,e.id)),_t.incrementMessageSent(e.id)}},"send message",{retries:o?0:2,notify:!1,context:{agentId:i,workspace:e.id}}),ae=o?await x().then(()=>({success:!0,error:void 0})):await mt.executeWithRecovery(x,ye.streaming,`send-message-${i}`);if(!ae.success)throw ae.error||new Error(n.agent_streamLifecycle_sendFailed_error())}catch(h){if(!u())return;throw A(H(c.id,!1)),!o&&t.messageMetadata&&A($e(c.id,D.id,{metadata:P})),o&&f($||C?"rejected":"uncertain"),C??h}}}},{memoize:!1,coalesce:!0,priority:"high"})}export{Te as U,Ft as a,ee as c,ze as r,kt as s,Ke as u,bt as w};