@decocms/mesh 2.16.0 → 2.17.0

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 (159) hide show
  1. package/dist/client/assets/{AlertCircle-B2oZTglS.js → AlertCircle-DOBZDZTf.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-DNHIvCfQ.js → ArrowLeft-CiX5attk.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-B6oTANSV.js → ArrowUp-Cb5IgbXf.js} +1 -1
  4. package/dist/client/assets/{Check-BzuFSftX.js → Check-D_y2LGJG.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-BczYL0OZ.js → ChevronDown-CK8tBMwt.js} +1 -1
  6. package/dist/client/assets/{Code01-DNXaHLqw.js → Code01-CHaKquD7.js} +1 -1
  7. package/dist/client/assets/{Copy01-Biw66bGV.js → Copy01-DEYUyyKa.js} +1 -1
  8. package/dist/client/assets/{DotsHorizontal-ZLYpFz0w.js → DotsHorizontal-CJj2K5Fj.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-cBsSXBlU.js → DotsVertical-DBgin8Gd.js} +1 -1
  10. package/dist/client/assets/{Download01-Cq2AKtAL.js → Download01-D480FrAl.js} +1 -1
  11. package/dist/client/assets/{Edit01-BjOfQM8B.js → Edit01-C2wyoLl_.js} +1 -1
  12. package/dist/client/assets/{File06-BNhcqwLq.js → File06-Dss_qxDP.js} +1 -1
  13. package/dist/client/assets/{FilterLines-CoWRaycl.js → FilterLines-BIIc2m5u.js} +1 -1
  14. package/dist/client/assets/{FlipBackward-CuLGV5oo.js → FlipBackward-C6tD49bS.js} +1 -1
  15. package/dist/client/assets/{GitBranch01-DkToEQj6.js → GitBranch01-CCs9Y7UL.js} +1 -1
  16. package/dist/client/assets/{Grid01-uV0oBuV3.js → Grid01-CPcgzk-j.js} +1 -1
  17. package/dist/client/assets/{Home02-B5sox49B.js → Home02-B2DfszMd.js} +1 -1
  18. package/dist/client/assets/{Image01-DMLU_ak3.js → Image01-CWiMChMV.js} +1 -1
  19. package/dist/client/assets/{Inbox01-BfxyUVOc.js → Inbox01-E54Xv1AH.js} +1 -1
  20. package/dist/client/assets/{InfoCircle-D6SOLGfY.js → InfoCircle-C1Hk7qxK.js} +1 -1
  21. package/dist/client/assets/{Key01-DY1coeHQ.js → Key01-D3jgPHnl.js} +1 -1
  22. package/dist/client/assets/{LinkExternal01-DMezlNGG.js → LinkExternal01-DXt_okRr.js} +1 -1
  23. package/dist/client/assets/{List-CVC8X3kY.js → List-vJTsFkGC.js} +1 -1
  24. package/dist/client/assets/{Loading01-CvuvLhSA.js → Loading01-CXxLrMyp.js} +1 -1
  25. package/dist/client/assets/{Lock01-ByXncGT3.js → Lock01-C0IcfwAr.js} +1 -1
  26. package/dist/client/assets/{MessageChatSquare-Dd7UGbcR.js → MessageChatSquare-BAK3msQ9.js} +1 -1
  27. package/dist/client/assets/{Play-D53Ipg7b.js → Play-D5UR01Yp.js} +1 -1
  28. package/dist/client/assets/{Plus-emJv0cyE.js → Plus-BwqRnIpw.js} +1 -1
  29. package/dist/client/assets/{SearchMd-4bGqWhO7.js → SearchMd-B72GLhSo.js} +1 -1
  30. package/dist/client/assets/{Terminal-Dwvrrbxm.js → Terminal-C6oII67o.js} +1 -1
  31. package/dist/client/assets/{Trash01-C9fgHihQ.js → Trash01-pQsQJfD7.js} +1 -1
  32. package/dist/client/assets/{Upload01-CRvHyAuf.js → Upload01-CPXoheIk.js} +1 -1
  33. package/dist/client/assets/{X-DwZFSRlE.js → X-Ta7e64fd.js} +1 -1
  34. package/dist/client/assets/{XClose-bVRJhtCU.js → XClose-COWRVEvP.js} +1 -1
  35. package/dist/client/assets/{alert-dialog-NsN0mz0A.js → alert-dialog-CwDNNTWs.js} +1 -1
  36. package/dist/client/assets/{auth-catchall-CZQOowpQ.js → auth-catchall-DOIkjlbS.js} +1 -1
  37. package/dist/client/assets/{avatar-Bim2Jxhy.js → avatar-Bbu1o6br.js} +1 -1
  38. package/dist/client/assets/{badge-DbLa101x.js → badge-BF26aj7r.js} +1 -1
  39. package/dist/client/assets/{binder-52kHlP5R.js → binder-CZMsXyzM.js} +1 -1
  40. package/dist/client/assets/{button-CTJokKKi.js → button-CKEM3eQL.js} +1 -1
  41. package/dist/client/assets/{card-D3-N0Ziq.js → card-2L27xRvH.js} +1 -1
  42. package/dist/client/assets/{checkbox-Bio0mokg.js → checkbox-D-u8zfFA.js} +1 -1
  43. package/dist/client/assets/{collection-detail-kd5gJHzz.js → collection-detail-DRvlQkfI.js} +1 -1
  44. package/dist/client/assets/{collection-display-button-D4xA64Pp.js → collection-display-button-BRmjKmXA.js} +1 -1
  45. package/dist/client/assets/{collection-header-CDIKZA15.js → collection-header-DxthRGYV.js} +1 -1
  46. package/dist/client/assets/{collection-page-DkTZhP29.js → collection-page-D_yHhDuI.js} +1 -1
  47. package/dist/client/assets/{collection-search-NLGzx5Aj.js → collection-search-B1XW3AZu.js} +1 -1
  48. package/dist/client/assets/{collection-tab-CHEJ77P0.js → collection-tab-tjhO7Mrn.js} +1 -1
  49. package/dist/client/assets/{collection-table-wrapper-Cmwf3-Zd.js → collection-table-wrapper-D0Ju0-U8.js} +1 -1
  50. package/dist/client/assets/{connection-card-DSQeBo5D.js → connection-card-DtL0ugHI.js} +1 -1
  51. package/dist/client/assets/{connection-detail-BRtmbxOA.js → connection-detail-CfQ3feir.js} +1 -1
  52. package/dist/client/assets/{connection-CVA8jPCa.js → connection-iGG9vveH.js} +1 -1
  53. package/dist/client/assets/{connections-BQG75-F0.js → connections-D3zmX0Z9.js} +1 -1
  54. package/dist/client/assets/constants-rLrKmanL.js +1 -0
  55. package/dist/client/assets/{create-organization-dialog-Bax-UsKr.js → create-organization-dialog-eRNW8Qxh.js} +1 -1
  56. package/dist/client/assets/{dialog-Bn93qdaz.js → dialog-CDtau8Kt.js} +1 -1
  57. package/dist/client/assets/{dropdown-menu-BoZzHM67.js → dropdown-menu-wWS-zaMN.js} +1 -1
  58. package/dist/client/assets/{dynamic-plugin-layout-CQi3lnCP.js → dynamic-plugin-layout-DputRlYb.js} +1 -1
  59. package/dist/client/assets/{empty-state-Bcd1wXFS.js → empty-state-BHbK0lgC.js} +1 -1
  60. package/dist/client/assets/{empty-state-Dm-ohURa.js → empty-state-CVNEuxZY.js} +1 -1
  61. package/dist/client/assets/{env-vars-editor-ckaYIpuZ.js → env-vars-editor-C51mNjyA.js} +1 -1
  62. package/dist/client/assets/{error-boundary-BoSqgCtj.js → error-boundary-Bcxx4rfP.js} +1 -1
  63. package/dist/client/assets/{extract-connection-data-CxTJQ988.js → extract-connection-data-Dpmksiuo.js} +1 -1
  64. package/dist/client/assets/{file-browser-Dn-I1IiE.js → file-browser-BGJT68ml.js} +2 -2
  65. package/dist/client/assets/{form-CG-hsJ5c.js → form-V7XQlTI9.js} +1 -1
  66. package/dist/client/assets/{gateway-detail-BQDBMjd9.js → gateway-detail-Dwo3tRMv.js} +1 -1
  67. package/dist/client/assets/{gateways-DSACPdOv.js → gateways-zERSWoJy.js} +1 -1
  68. package/dist/client/assets/{grid-view-hvwfrwye.js → grid-view-D8luahOM.js} +1 -1
  69. package/dist/client/assets/{home-CeFBBPsp.js → home-BzIxKv5R.js} +1 -1
  70. package/dist/client/assets/{index-CmErlMVO.js → index-BuhwJgoT.js} +1 -1
  71. package/dist/client/assets/{index-2KSfo6Ol.css → index-CCciYu2S.css} +1 -1
  72. package/dist/client/assets/{index-EGRg6aHg.js → index-COEG5bG9.js} +1 -1
  73. package/dist/client/assets/{index-CRZ1ToW0.js → index-D93bwXlh.js} +1 -1
  74. package/dist/client/assets/{index-j6TJSjaV.js → index-Dm3KUy-5.js} +4 -4
  75. package/dist/client/assets/{index-CrProqmQ.js → index-H8waGLZX.js} +3 -3
  76. package/dist/client/assets/{infiniteQueryObserver-lRzj3Gw2.js → infiniteQueryObserver-CorNdPTl.js} +1 -1
  77. package/dist/client/assets/{input-DfBpU_ty.js → input-B_S0H_Hl.js} +1 -1
  78. package/dist/client/assets/{layout-AUAvH2H1.js → layout-CSDcjZIC.js} +1 -1
  79. package/dist/client/assets/{lazy-highlighter-VlHU8Y-l.js → lazy-highlighter-C9yEt-oj.js} +1 -1
  80. package/dist/client/assets/{localstorage-keys-CRSC1wcG.js → localstorage-keys-bcceq1xC.js} +1 -1
  81. package/dist/client/assets/{login-DuLQYRHx.js → login-BYnVwbER.js} +1 -1
  82. package/dist/client/assets/{mcp-oauth-BuyvGrP4.js → mcp-oauth-BQzIgGw8.js} +1 -1
  83. package/dist/client/assets/{mcp-server-card-CXVHhw09.js → mcp-server-card-_ATNoXTX.js} +1 -1
  84. package/dist/client/assets/{mcp-server-detail-DRgWtEnz.js → mcp-server-detail-DObA9nLB.js} +1 -1
  85. package/dist/client/assets/{members-D2GPpEvZ.js → members-BebBEAXI.js} +1 -1
  86. package/dist/client/assets/{monaco-editor-Ch4QGmXS.js → monaco-editor-DKdQnknl.js} +1 -1
  87. package/dist/client/assets/{monitoring-DvqA7AuH.js → monitoring-CDDlEqUx.js} +1 -1
  88. package/dist/client/assets/{oauth-callback-B2iJ-cIh.js → oauth-callback-gzfkrrQW.js} +1 -1
  89. package/dist/client/assets/{page-CTarFbC4.js → page-CLLgwmPE.js} +1 -1
  90. package/dist/client/assets/{page-CekK7zPt.js → page-Do6tc7Ak.js} +1 -1
  91. package/dist/client/assets/{pin-to-sidebar-button-BsMAQ8Vt.js → pin-to-sidebar-button-NqMT4AF7.js} +1 -1
  92. package/dist/client/assets/{plugin-empty-state-Dy73LUEA.js → plugin-empty-state-CsEwK0UI.js} +1 -1
  93. package/dist/client/assets/{plugin-header-B_tffoXS.js → plugin-header-DMvUkTVw.js} +1 -1
  94. package/dist/client/assets/{plugins-CR5Q-iDa.js → plugins-femIOaN7.js} +1 -1
  95. package/dist/client/assets/{popover-BZ-FzZWz.js → popover-CUHksX3w.js} +1 -1
  96. package/dist/client/assets/{project-context-provider-DaHOfM4z.js → project-context-provider-DTbOrAFq.js} +1 -1
  97. package/dist/client/assets/{registry-utils-D0mO6LZ4.js → registry-utils-C5W-BZ_1.js} +1 -1
  98. package/dist/client/assets/{resizable-BPD0-alN.js → resizable-BEUt05S8.js} +1 -1
  99. package/dist/client/assets/{resource-tabs-JnmKNHPF.js → resource-tabs-kfeiBQEL.js} +1 -1
  100. package/dist/client/assets/{select-IfWnHVgm.js → select-H2esePZI.js} +1 -1
  101. package/dist/client/assets/{settings-DjC9FBse.js → settings-DO0PkWA0.js} +1 -1
  102. package/dist/client/assets/{shell-layout-Bd8yx5uJ.js → shell-layout-Bx8F46Gf.js} +1 -1
  103. package/dist/client/assets/{spinner-C88Uk3Mq.js → spinner-BZhaf6l_.js} +1 -1
  104. package/dist/client/assets/{switch-DoEPJ6LK.js → switch-CIfCfD81.js} +1 -1
  105. package/dist/client/assets/{textarea-BqnrlDDE.js → textarea-CC9KHQpw.js} +1 -1
  106. package/dist/client/assets/{tool-set-selector-DRO7hzfM.js → tool-set-selector-Cty6fXdH.js} +1 -1
  107. package/dist/client/assets/{tools-list-CLVUgs1o.js → tools-list-rrG-PiCB.js} +1 -1
  108. package/dist/client/assets/{tooltip-NmHBw1SB.js → tooltip-DixY1Sbc.js} +1 -1
  109. package/dist/client/assets/{use-binding-BeRgkTto.js → use-binding-CPqdk4GE.js} +1 -1
  110. package/dist/client/assets/{use-collections-KXXQm2MI.js → use-collections-S6OVeMx0.js} +1 -1
  111. package/dist/client/assets/{use-connection-BpwLfga7.js → use-connection-C_QQYkok.js} +1 -1
  112. package/dist/client/assets/use-connection-resources-h_CY6VEc.js +1 -0
  113. package/dist/client/assets/{use-create-gateway-CCdAKPuZ.js → use-create-gateway-eDGGqEOS.js} +1 -1
  114. package/dist/client/assets/{use-gateway-CvXTgd1x.js → use-gateway-DMJjVwlU.js} +1 -1
  115. package/dist/client/assets/{use-gateway-system-prompt-DppzttmJ.js → use-gateway-system-prompt-CfIIyZId.js} +1 -1
  116. package/dist/client/assets/{use-list-state-lFbY6EbW.js → use-list-state-Bt6QEhtR.js} +1 -1
  117. package/dist/client/assets/{use-mcp-Dd1lbCPb.js → use-mcp-DuKh-Xf7.js} +1 -1
  118. package/dist/client/assets/{use-members-BPs6PrLQ.js → use-members-Hsme2FMs.js} +1 -1
  119. package/dist/client/assets/{use-mobile-C5bi3iKH.js → use-mobile-Bh6onNnL.js} +1 -1
  120. package/dist/client/assets/{use-organization-settings-D1QvFxpy.js → use-organization-settings-C4u9V1Gg.js} +1 -1
  121. package/dist/client/assets/{use-tool-call-VFE826W3.js → use-tool-call-BSVniqlJ.js} +1 -1
  122. package/dist/client/assets/useInfiniteQuery-BYo7uk8S.js +1 -0
  123. package/dist/client/assets/{useMutation-BTJq9RED.js → useMutation-DXyBs08e.js} +1 -1
  124. package/dist/client/assets/useQuery-9rHAo5k0.js +1 -0
  125. package/dist/client/assets/{value-_xkD4VBb.js → value-EQeDZr5M.js} +1 -1
  126. package/dist/client/assets/{view-mode-toggle-DcZ2e_Ag.js → view-mode-toggle-CoxeG-5F.js} +1 -1
  127. package/dist/client/assets/{workflow-B-4ovCZr.js → workflow-CdkAFtfl.js} +1 -1
  128. package/dist/client/index.html +2 -2
  129. package/dist/server/cli.js +208 -208
  130. package/dist/server/migrate.js +186 -186
  131. package/dist/server/server.js +202 -202
  132. package/package.json +1 -1
  133. package/dist/client/assets/constants-DDPe3rq3.js +0 -1
  134. package/dist/client/assets/use-connection-resources-LbJAvV0-.js +0 -1
  135. package/dist/client/assets/useInfiniteQuery-DwjnurDK.js +0 -1
  136. package/dist/client/assets/useQuery-5B4EpEmL.js +0 -1
  137. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/LICENSE +0 -47
  138. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/README.md +0 -82
  139. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.browser.d.ts +0 -11
  140. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.browser.mjs +0 -43
  141. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.cjs +0 -45
  142. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.cloudflare.cjs +0 -46
  143. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.cloudflare.d.ts +0 -11
  144. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.d.ts +0 -11
  145. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.mjs +0 -46
  146. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.wasm +0 -0
  147. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.d.mts +0 -83
  148. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.d.ts +0 -83
  149. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.js +0 -2
  150. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.js.map +0 -1
  151. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.mjs +0 -2
  152. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.mjs.map +0 -1
  153. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.d.mts +0 -20
  154. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.d.ts +0 -20
  155. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.js +0 -2
  156. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.js.map +0 -1
  157. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.mjs +0 -2
  158. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.mjs.map +0 -1
  159. package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/package.json +0 -61
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lazy-highlighter-VlHU8Y-l.js","assets/index-CrProqmQ.js","assets/index-2KSfo6Ol.css"])))=>i.map(i=>d[i]);
2
- import{r as j,c as Q,j as m,aH as id,aI as sd,aJ as ad,aK as nt,z as W,aL as Or,aM as $u,aN as ud,aO as od,aP as ld,L as Xe,J as Zn,I as sr,y as Te,aQ as te,aG as Pt,aR as cd,aS as Ae,_ as dd,X as as,v as us,x as os,K as He,d as Yu,t as Lr,a as qu,f as Vu,aT as fd,a5 as hd,a6 as ls,a8 as pd,a7 as md,aa as gd,as as bd,a3 as Ed,a9 as Td}from"./index-CrProqmQ.js";import{c as ae,B as $e}from"./button-CTJokKKi.js";import{i as xd}from"./X-DwZFSRlE.js";import{I as cs,E as _d}from"./empty-state-Dm-ohURa.js";import{u as zt}from"./project-context-provider-DaHOfM4z.js";import{a as ar,b as ur,P as or}from"./popover-BZ-FzZWz.js";import{T as yd}from"./textarea-BqnrlDDE.js";import{i as Wu}from"./AlertCircle-B2oZTglS.js";import{i as Ad,E as kd}from"./error-boundary-BoSqgCtj.js";import{i as Cd}from"./ArrowUp-B6oTANSV.js";import{t as Id}from"./ChevronDown-BczYL0OZ.js";import{u as Nd,i as ds}from"./use-gateway-CvXTgd1x.js";import{i as Sd}from"./Edit01-BjOfQM8B.js";import{U as wd,c as Rd}from"./connection-CVA8jPCa.js";import{b as Od}from"./use-collections-KXXQm2MI.js";import{u as Gu,a as Ld}from"./use-connection-BpwLfga7.js";import{b as vd}from"./use-binding-BeRgkTto.js";import{u as Xt}from"./useMutation-BTJq9RED.js";import{u as Dd}from"./use-gateway-system-prompt-DppzttmJ.js";import{u as vr,L as fs}from"./localstorage-keys-CRSC1wcG.js";import{I as Qu}from"./input-DfBpU_ty.js";import{T as xn,b as _n,a as hs,c as yn}from"./tooltip-NmHBw1SB.js";import{i as Yr}from"./Check-BzuFSftX.js";import{i as qr}from"./SearchMd-4bGqWhO7.js";import{u as Pd}from"./use-create-gateway-CCdAKPuZ.js";import{S as Md,a as Bd,b as Fd,c as Ud,d as Hd}from"./select-IfWnHVgm.js";import{i as jd}from"./File06-BNhcqwLq.js";import{c as zd,i as Xu}from"./Grid01-uV0oBuV3.js";import{a as $d}from"./Image01-DMLU_ak3.js";import{a as ps}from"./Copy01-Biw66bGV.js";import{i as Yd}from"./Terminal-Dwvrrbxm.js";import{M as Zu,s as na}from"./monaco-editor-Ch4QGmXS.js";import{b as qd,c as Vd,d as Wd,A as Gd,a as Qd,e as Xd,g as Zd,f as Kd}from"./alert-dialog-NsN0mz0A.js";import{O as Jd,b as ef,c as tf}from"./well-known-mcp-DOEdYmKO.js";import{g as nf}from"./generate-id-Dyweu44Y.js";import{s as rf}from"./Trash01-C9fgHihQ.js";var Kn;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},t.getValidEnumValues=i=>{const s=t.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),a={};for(const u of s)a[u]=i[u];return t.objectValues(a)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},t.find=(i,s)=>{for(const a of i)if(s(a))return a},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Kn||(Kn={}));var ra;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(ra||(ra={}));Kn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Kn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Dr extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let u=r,l=0;for(;l<a.path.length;){const o=a.path[l];l===a.path.length-1?(u[o]=u[o]||{_errors:[]},u[o]._errors.push(n(a))):u[o]=u[o]||{_errors:[]},u=u[o],l++}}};return i(this),r}static assert(e){if(!(e instanceof Dr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Dr.create=t=>new Dr(t);var ia;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(ia||(ia={}));var ne;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ne||(ne={}));const Ku=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));Ku.displayName="Atom02";const Ju=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"}));Ju.displayName="ChevronSelectorVertical";const eo=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));eo.displayName="Coins01";const to=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M9 14 4 9m0 0 5-5M4 9h6.4c3.36 0 5.04 0 6.324.654a6 6 0 0 1 2.622 2.622C20 13.56 20 15.24 20 18.6V20"}));to.displayName="CornerUpLeft";const no=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M6 16a4 4 0 0 0 4 4h4a4 4 0 0 0 0-8h-4a4 4 0 0 1 0-8h4a4 4 0 0 1 4 4m-6-6v20"}));no.displayName="CurrencyDollar";const ro=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m18 10-4-4M2.5 21.5l3.384-.376c.414-.046.62-.069.814-.131a2 2 0 0 0 .485-.234c.17-.111.317-.259.61-.553L21 7a2.828 2.828 0 1 0-4-4L3.794 16.206c-.294.294-.442.442-.553.611a2 2 0 0 0-.234.485c-.062.193-.085.4-.131.814L2.5 21.5Z"}));ro.displayName="Edit02";const io=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));io.displayName="Lightbulb01";const so=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m18 8 4 4m0 0-4 4m4-4H9m6-7.796A8.383 8.383 0 0 0 10.667 3C5.88 3 2 7.03 2 12s3.88 9 8.667 9A8.384 8.384 0 0 0 15 19.796"}));so.displayName="LogOut04";const Vr=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m6.5 13 .784 1.569c.266.53.399.796.576 1.026a3 3 0 0 0 .545.545c.23.177.495.31 1.026.575L11 17.5l-1.569.785c-.53.265-.796.398-1.026.575a3 3 0 0 0-.545.545c-.177.23-.31.495-.576 1.026L6.5 22l-.784-1.569c-.266-.53-.399-.796-.576-1.026a3 3 0 0 0-.545-.545c-.23-.177-.495-.31-1.026-.575L2 17.5l1.569-.785c.53-.265.796-.398 1.026-.575a3 3 0 0 0 .545-.545c.177-.23.31-.495.576-1.026L6.5 13ZM15 2l1.179 3.064c.282.734.423 1.1.642 1.409a3 3 0 0 0 .706.706c.309.22.675.36 1.409.642L22 9l-3.064 1.179c-.734.282-1.1.423-1.409.642a3 3 0 0 0-.706.706c-.22.309-.36.675-.642 1.409L15 16l-1.179-3.064c-.282-.734-.423-1.1-.642-1.409a3 3 0 0 0-.706-.706c-.309-.22-.675-.36-1.409-.642L8 9l3.064-1.179c.734-.282 1.1-.423 1.409-.642a3 3 0 0 0 .706-.706c.22-.309.36-.675.642-1.409L15 2Z"}));Vr.displayName="Stars01";const ao=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));ao.displayName="Stop";const uo=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));uo.displayName="Target04";const oo=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));oo.displayName="XCircle";function ze(t){const e=Q.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=ae("bg-accent animate-pulse rounded-md",n),e[3]=n,e[4]=i):i=e[4];let s;return e[5]!==r||e[6]!==i?(s=m.jsx("div",{"data-slot":"skeleton",className:i,...r}),e[5]=r,e[6]=i,e[7]=s):s=e[7],s}function sf(){const t=Q.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=fs.developerMode(),t[0]=e):e=t[0],vr(e,!1)}const sa=[{border:"border-purple-400",bg:"bg-purple-400",text:"text-white",bgLight:"bg-purple-400/10"},{border:"border-blue-400",bg:"bg-blue-400",text:"text-white",bgLight:"bg-blue-400/10"},{border:"border-indigo-400",bg:"bg-indigo-400",text:"text-white",bgLight:"bg-indigo-400/10"},{border:"border-violet-400",bg:"bg-violet-400",text:"text-white",bgLight:"bg-violet-400/10"},{border:"border-pink-400",bg:"bg-pink-400",text:"text-white",bgLight:"bg-pink-400/10"},{border:"border-fuchsia-400",bg:"bg-fuchsia-400",text:"text-white",bgLight:"bg-fuchsia-400/10"},{border:"border-emerald-400",bg:"bg-emerald-400",text:"text-white",bgLight:"bg-emerald-400/10"},{border:"border-teal-400",bg:"bg-teal-400",text:"text-white",bgLight:"bg-teal-400/10"},{border:"border-cyan-400",bg:"bg-cyan-400",text:"text-white",bgLight:"bg-cyan-400/10"},{border:"border-sky-400",bg:"bg-sky-400",text:"text-white",bgLight:"bg-sky-400/10"},{border:"border-orange-400",bg:"bg-orange-400",text:"text-white",bgLight:"bg-orange-400/10"},{border:"border-amber-400",bg:"bg-amber-400",text:"text-white",bgLight:"bg-amber-400/10"},{border:"border-rose-400",bg:"bg-rose-400",text:"text-white",bgLight:"bg-rose-400/10"},{border:"border-lime-400",bg:"bg-lime-400",text:"text-white",bgLight:"bg-lime-400/10"}];function af(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e)}function lo(t){if(t==null)return null;const n=af(t)%sa.length;return sa[n]}var co="vercel.ai.error",uf=Symbol.for(co),aa,ua,Ct=class fo extends(ua=Error,aa=uf,ua){constructor({name:e,message:n,cause:r}){super(n),this[aa]=!0,this.name=e,this.cause=r}static isInstance(e){return fo.hasMarker(e,co)}static hasMarker(e,n){const r=Symbol.for(n);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function ho(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var po="AI_InvalidArgumentError",mo=`vercel.ai.error.${po}`,of=Symbol.for(mo),oa,la,lf=class extends(la=Ct,oa=of,la){constructor({message:t,cause:e,argument:n}){super({name:po,message:t,cause:e}),this[oa]=!0,this.argument=n}static isInstance(t){return Ct.hasMarker(t,mo)}},go="AI_JSONParseError",bo=`vercel.ai.error.${go}`,cf=Symbol.for(bo),ca,da,fa=class extends(da=Ct,ca=cf,da){constructor({text:t,cause:e}){super({name:go,message:`JSON parsing failed: Text: ${t}.
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lazy-highlighter-C9yEt-oj.js","assets/index-H8waGLZX.js","assets/index-CCciYu2S.css"])))=>i.map(i=>d[i]);
2
+ import{r as j,c as Q,j as m,aH as id,aI as sd,aJ as ad,aK as nt,z as W,aL as Or,aM as $u,aN as ud,aO as od,aP as ld,L as Xe,J as Zn,I as sr,y as Te,aQ as te,aG as Pt,aR as cd,aS as Ae,_ as dd,X as as,v as us,x as os,K as He,d as Yu,t as Lr,a as qu,f as Vu,aT as fd,a5 as hd,a6 as ls,a8 as pd,a7 as md,aa as gd,as as bd,a3 as Ed,a9 as Td}from"./index-H8waGLZX.js";import{c as ae,B as $e}from"./button-CKEM3eQL.js";import{i as xd}from"./X-Ta7e64fd.js";import{I as cs,E as _d}from"./empty-state-CVNEuxZY.js";import{u as zt}from"./project-context-provider-DTbOrAFq.js";import{a as ar,b as ur,P as or}from"./popover-CUHksX3w.js";import{T as yd}from"./textarea-CC9KHQpw.js";import{i as Wu}from"./AlertCircle-DOBZDZTf.js";import{i as Ad,E as kd}from"./error-boundary-Bcxx4rfP.js";import{i as Cd}from"./ArrowUp-Cb5IgbXf.js";import{t as Id}from"./ChevronDown-CK8tBMwt.js";import{u as Nd,i as ds}from"./use-gateway-DMJjVwlU.js";import{i as Sd}from"./Edit01-C2wyoLl_.js";import{U as wd,c as Rd}from"./connection-iGG9vveH.js";import{b as Od}from"./use-collections-S6OVeMx0.js";import{u as Gu,a as Ld}from"./use-connection-C_QQYkok.js";import{b as vd}from"./use-binding-CPqdk4GE.js";import{u as Xt}from"./useMutation-DXyBs08e.js";import{u as Dd}from"./use-gateway-system-prompt-CfIIyZId.js";import{u as vr,L as fs}from"./localstorage-keys-bcceq1xC.js";import{I as Qu}from"./input-B_S0H_Hl.js";import{T as xn,b as _n,a as hs,c as yn}from"./tooltip-DixY1Sbc.js";import{i as Yr}from"./Check-D_y2LGJG.js";import{i as qr}from"./SearchMd-B72GLhSo.js";import{u as Pd}from"./use-create-gateway-eDGGqEOS.js";import{S as Md,a as Bd,b as Fd,c as Ud,d as Hd}from"./select-H2esePZI.js";import{i as jd}from"./File06-Dss_qxDP.js";import{c as zd,i as Xu}from"./Grid01-CPcgzk-j.js";import{a as $d}from"./Image01-CWiMChMV.js";import{a as ps}from"./Copy01-DEYUyyKa.js";import{i as Yd}from"./Terminal-C6oII67o.js";import{M as Zu,s as na}from"./monaco-editor-DKdQnknl.js";import{b as qd,c as Vd,d as Wd,A as Gd,a as Qd,e as Xd,g as Zd,f as Kd}from"./alert-dialog-CwDNNTWs.js";import{O as Jd,b as ef,c as tf}from"./well-known-mcp-DOEdYmKO.js";import{g as nf}from"./generate-id-Dyweu44Y.js";import{s as rf}from"./Trash01-pQsQJfD7.js";var Kn;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},t.getValidEnumValues=i=>{const s=t.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),a={};for(const u of s)a[u]=i[u];return t.objectValues(a)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},t.find=(i,s)=>{for(const a of i)if(s(a))return a},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Kn||(Kn={}));var ra;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(ra||(ra={}));Kn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Kn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Dr extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let u=r,l=0;for(;l<a.path.length;){const o=a.path[l];l===a.path.length-1?(u[o]=u[o]||{_errors:[]},u[o]._errors.push(n(a))):u[o]=u[o]||{_errors:[]},u=u[o],l++}}};return i(this),r}static assert(e){if(!(e instanceof Dr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Kn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Dr.create=t=>new Dr(t);var ia;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(ia||(ia={}));var ne;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ne||(ne={}));const Ku=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));Ku.displayName="Atom02";const Ju=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"}));Ju.displayName="ChevronSelectorVertical";const eo=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));eo.displayName="Coins01";const to=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M9 14 4 9m0 0 5-5M4 9h6.4c3.36 0 5.04 0 6.324.654a6 6 0 0 1 2.622 2.622C20 13.56 20 15.24 20 18.6V20"}));to.displayName="CornerUpLeft";const no=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M6 16a4 4 0 0 0 4 4h4a4 4 0 0 0 0-8h-4a4 4 0 0 1 0-8h4a4 4 0 0 1 4 4m-6-6v20"}));no.displayName="CurrencyDollar";const ro=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m18 10-4-4M2.5 21.5l3.384-.376c.414-.046.62-.069.814-.131a2 2 0 0 0 .485-.234c.17-.111.317-.259.61-.553L21 7a2.828 2.828 0 1 0-4-4L3.794 16.206c-.294.294-.442.442-.553.611a2 2 0 0 0-.234.485c-.062.193-.085.4-.131.814L2.5 21.5Z"}));ro.displayName="Edit02";const io=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));io.displayName="Lightbulb01";const so=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m18 8 4 4m0 0-4 4m4-4H9m6-7.796A8.383 8.383 0 0 0 10.667 3C5.88 3 2 7.03 2 12s3.88 9 8.667 9A8.384 8.384 0 0 0 15 19.796"}));so.displayName="LogOut04";const Vr=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m6.5 13 .784 1.569c.266.53.399.796.576 1.026a3 3 0 0 0 .545.545c.23.177.495.31 1.026.575L11 17.5l-1.569.785c-.53.265-.796.398-1.026.575a3 3 0 0 0-.545.545c-.177.23-.31.495-.576 1.026L6.5 22l-.784-1.569c-.266-.53-.399-.796-.576-1.026a3 3 0 0 0-.545-.545c-.23-.177-.495-.31-1.026-.575L2 17.5l1.569-.785c.53-.265.796-.398 1.026-.575a3 3 0 0 0 .545-.545c.177-.23.31-.495.576-1.026L6.5 13ZM15 2l1.179 3.064c.282.734.423 1.1.642 1.409a3 3 0 0 0 .706.706c.309.22.675.36 1.409.642L22 9l-3.064 1.179c-.734.282-1.1.423-1.409.642a3 3 0 0 0-.706.706c-.22.309-.36.675-.642 1.409L15 16l-1.179-3.064c-.282-.734-.423-1.1-.642-1.409a3 3 0 0 0-.706-.706c-.309-.22-.675-.36-1.409-.642L8 9l3.064-1.179c.734-.282 1.1-.423 1.409-.642a3 3 0 0 0 .706-.706c.22-.309.36-.675.642-1.409L15 2Z"}));Vr.displayName="Stars01";const ao=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));ao.displayName="Stop";const uo=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));uo.displayName="Target04";const oo=({size:t=24,color:e="currentColor",...n})=>j.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},j.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));oo.displayName="XCircle";function ze(t){const e=Q.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=ae("bg-accent animate-pulse rounded-md",n),e[3]=n,e[4]=i):i=e[4];let s;return e[5]!==r||e[6]!==i?(s=m.jsx("div",{"data-slot":"skeleton",className:i,...r}),e[5]=r,e[6]=i,e[7]=s):s=e[7],s}function sf(){const t=Q.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=fs.developerMode(),t[0]=e):e=t[0],vr(e,!1)}const sa=[{border:"border-purple-400",bg:"bg-purple-400",text:"text-white",bgLight:"bg-purple-400/10"},{border:"border-blue-400",bg:"bg-blue-400",text:"text-white",bgLight:"bg-blue-400/10"},{border:"border-indigo-400",bg:"bg-indigo-400",text:"text-white",bgLight:"bg-indigo-400/10"},{border:"border-violet-400",bg:"bg-violet-400",text:"text-white",bgLight:"bg-violet-400/10"},{border:"border-pink-400",bg:"bg-pink-400",text:"text-white",bgLight:"bg-pink-400/10"},{border:"border-fuchsia-400",bg:"bg-fuchsia-400",text:"text-white",bgLight:"bg-fuchsia-400/10"},{border:"border-emerald-400",bg:"bg-emerald-400",text:"text-white",bgLight:"bg-emerald-400/10"},{border:"border-teal-400",bg:"bg-teal-400",text:"text-white",bgLight:"bg-teal-400/10"},{border:"border-cyan-400",bg:"bg-cyan-400",text:"text-white",bgLight:"bg-cyan-400/10"},{border:"border-sky-400",bg:"bg-sky-400",text:"text-white",bgLight:"bg-sky-400/10"},{border:"border-orange-400",bg:"bg-orange-400",text:"text-white",bgLight:"bg-orange-400/10"},{border:"border-amber-400",bg:"bg-amber-400",text:"text-white",bgLight:"bg-amber-400/10"},{border:"border-rose-400",bg:"bg-rose-400",text:"text-white",bgLight:"bg-rose-400/10"},{border:"border-lime-400",bg:"bg-lime-400",text:"text-white",bgLight:"bg-lime-400/10"}];function af(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+((e<<5)-e);return Math.abs(e)}function lo(t){if(t==null)return null;const n=af(t)%sa.length;return sa[n]}var co="vercel.ai.error",uf=Symbol.for(co),aa,ua,Ct=class fo extends(ua=Error,aa=uf,ua){constructor({name:e,message:n,cause:r}){super(n),this[aa]=!0,this.name=e,this.cause=r}static isInstance(e){return fo.hasMarker(e,co)}static hasMarker(e,n){const r=Symbol.for(n);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function ho(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var po="AI_InvalidArgumentError",mo=`vercel.ai.error.${po}`,of=Symbol.for(mo),oa,la,lf=class extends(la=Ct,oa=of,la){constructor({message:t,cause:e,argument:n}){super({name:po,message:t,cause:e}),this[oa]=!0,this.argument=n}static isInstance(t){return Ct.hasMarker(t,mo)}},go="AI_JSONParseError",bo=`vercel.ai.error.${go}`,cf=Symbol.for(bo),ca,da,fa=class extends(da=Ct,ca=cf,da){constructor({text:t,cause:e}){super({name:go,message:`JSON parsing failed: Text: ${t}.
3
3
  Error message: ${ho(e)}`,cause:e}),this[ca]=!0,this.text=t}static isInstance(t){return Ct.hasMarker(t,bo)}},Eo="AI_TypeValidationError",To=`vercel.ai.error.${Eo}`,df=Symbol.for(To),ha,pa,gn=class Di extends(pa=Ct,ha=df,pa){constructor({value:e,cause:n}){super({name:Eo,message:`Type validation failed: Value: ${JSON.stringify(e)}.
4
4
  Error message: ${ho(n)}`,cause:n}),this[ha]=!0,this.value=e}static isInstance(e){return Ct.hasMarker(e,To)}static wrap({value:e,cause:n}){return Di.isInstance(n)&&n.value===e?n:new Di({value:e,cause:n})}},lr=({prefix:t,size:e=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const s=n.length,a=new Array(e);for(let u=0;u<e;u++)a[u]=n[Math.random()*s|0];return a.join("")};if(t==null)return i;if(n.includes(r))throw new lf({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${t}${r}${i()}`},ff=lr();function ma(t=globalThis){var e,n,r;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(r=(n=t.process)==null?void 0:n.versions)!=null&&r.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function Qt(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((n,r)=>{e[r.toLowerCase()]=n});else{Array.isArray(t)||(t=Object.entries(t));for(const[n,r]of t)r!=null&&(e[n.toLowerCase()]=r)}return e}function ga(t,...e){const n=new Headers(Qt(t)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...e].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var hf=/"__proto__"\s*:/,pf=/"constructor"\s*:/;function ba(t){const e=JSON.parse(t);return e===null||typeof e!="object"||hf.test(t)===!1&&pf.test(t)===!1?e:mf(e)}function mf(t){let e=[t];for(;e.length;){const n=e;e=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in r){const s=r[i];s&&typeof s=="object"&&e.push(s)}}}return t}function gf(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return ba(t)}try{return ba(t)}finally{Error.stackTraceLimit=e}}function ms(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:n}=t;if(n!=null)for(const r of Object.keys(n))n[r]=Wt(n[r])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(Wt):Wt(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(Wt)),t.allOf!=null&&(t.allOf=t.allOf.map(Wt)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(Wt));const{definitions:e}=t;if(e!=null)for(const n of Object.keys(e))e[n]=Wt(e[n]);return t}function Wt(t){return typeof t=="boolean"?t:ms(t)}var bf=Symbol("Let zodToJsonSchema decide on which parser to use"),Ea={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Ef=t=>typeof t=="string"?{...Ea,name:t}:{...Ea,...t};function ct(){return{}}function Tf(t,e){var n,r,i;const s={type:"array"};return(n=t.type)!=null&&n._def&&((i=(r=t.type)==null?void 0:r._def)==null?void 0:i.typeName)!==ne.ZodAny&&(s.items=be(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(s.minItems=t.minLength.value),t.maxLength&&(s.maxItems=t.maxLength.value),t.exactLength&&(s.minItems=t.exactLength.value,s.maxItems=t.exactLength.value),s}function xf(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const n of t.checks)switch(n.kind){case"min":n.inclusive?e.minimum=n.value:e.exclusiveMinimum=n.value;break;case"max":n.inclusive?e.maximum=n.value:e.exclusiveMaximum=n.value;break;case"multipleOf":e.multipleOf=n.value;break}return e}function _f(){return{type:"boolean"}}function xo(t,e){return be(t.type._def,e)}var yf=(t,e)=>be(t.innerType._def,e);function _o(t,e,n){const r=n??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,s)=>_o(t,e,i))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Af(t)}}var Af=t=>{const e={type:"integer",format:"unix-time"};for(const n of t.checks)switch(n.kind){case"min":e.minimum=n.value;break;case"max":e.maximum=n.value;break}return e};function kf(t,e){return{...be(t.innerType._def,e),default:t.defaultValue()}}function Cf(t,e){return e.effectStrategy==="input"?be(t.schema._def,e):ct()}function If(t){return{type:"string",enum:Array.from(t.values)}}var Nf=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Sf(t,e){const n=[be(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),be(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(Nf(i))r.push(...i.allOf);else{let s=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:a,...u}=i;s=u}r.push(s)}}),r.length?{allOf:r}:void 0}function wf(t){const e=typeof t.value;return e!=="bigint"&&e!=="number"&&e!=="boolean"&&e!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:e==="bigint"?"integer":e,const:t.value}}var ci=void 0,mt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ci===void 0&&(ci=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ci),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function yo(t,e){const n={type:"string"};if(t.checks)for(const r of t.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(e.emailStrategy){case"format:email":gt(n,"email",r.message,e);break;case"format:idn-email":gt(n,"idn-email",r.message,e);break;case"pattern:zod":Qe(n,mt.email,r.message,e);break}break;case"url":gt(n,"uri",r.message,e);break;case"uuid":gt(n,"uuid",r.message,e);break;case"regex":Qe(n,r.regex,r.message,e);break;case"cuid":Qe(n,mt.cuid,r.message,e);break;case"cuid2":Qe(n,mt.cuid2,r.message,e);break;case"startsWith":Qe(n,RegExp(`^${di(r.value,e)}`),r.message,e);break;case"endsWith":Qe(n,RegExp(`${di(r.value,e)}$`),r.message,e);break;case"datetime":gt(n,"date-time",r.message,e);break;case"date":gt(n,"date",r.message,e);break;case"time":gt(n,"time",r.message,e);break;case"duration":gt(n,"duration",r.message,e);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{Qe(n,RegExp(di(r.value,e)),r.message,e);break}case"ip":{r.version!=="v6"&&gt(n,"ipv4",r.message,e),r.version!=="v4"&&gt(n,"ipv6",r.message,e);break}case"base64url":Qe(n,mt.base64url,r.message,e);break;case"jwt":Qe(n,mt.jwt,r.message,e);break;case"cidr":{r.version!=="v6"&&Qe(n,mt.ipv4Cidr,r.message,e),r.version!=="v4"&&Qe(n,mt.ipv6Cidr,r.message,e);break}case"emoji":Qe(n,mt.emoji(),r.message,e);break;case"ulid":{Qe(n,mt.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{gt(n,"binary",r.message,e);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Qe(n,mt.base64,r.message,e);break}}break}case"nanoid":Qe(n,mt.nanoid,r.message,e)}return n}function di(t,e){return e.patternStrategy==="escape"?Of(t):t}var Rf=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Of(t){let e="";for(let n=0;n<t.length;n++)Rf.has(t[n])||(e+="\\"),e+=t[n];return e}function gt(t,e,n,r){var i;t.format||(i=t.anyOf)!=null&&i.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...n&&r.errorMessages&&{errorMessage:{format:n}}})):t.format=e}function Qe(t,e,n,r){var i;t.pattern||(i=t.allOf)!=null&&i.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Ta(e,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):t.pattern=Ta(e,r)}function Ta(t,e){var n;if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=r.i?t.source.toLowerCase():t.source;let s="",a=!1,u=!1,l=!1;for(let o=0;o<i.length;o++){if(a){s+=i[o],a=!1;continue}if(r.i){if(u){if(i[o].match(/[a-z]/)){l?(s+=i[o],s+=`${i[o-2]}-${i[o]}`.toUpperCase(),l=!1):i[o+1]==="-"&&((n=i[o+2])!=null&&n.match(/[a-z]/))?(s+=i[o],l=!0):s+=`${i[o]}${i[o].toUpperCase()}`;continue}}else if(i[o].match(/[a-z]/)){s+=`[${i[o]}${i[o].toUpperCase()}]`;continue}}if(r.m){if(i[o]==="^"){s+=`(^|(?<=[\r
5
5
  ]))`;continue}else if(i[o]==="$"){s+=`($|(?=[\r
@@ -18,7 +18,7 @@ ${a.join(`
18
18
 
19
19
  Help the user understand and work with this resource.`),e[1]=t,e[2]=i,e[3]=r.collectionName,e[4]=r.connectionId,e[5]=r.itemId,e[6]=s}else s=e[6];return s.join(`
20
20
 
21
- `)}function e0(){const t=Q.c(5),e=os(),{org:n}=zt();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const i=Yu(r);let s;return t[1]!==n||t[2]!==i||t[3]!==e?(s=a=>{const l=a.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!l||!l[1])return;const o=l[1],d=i.connectionId;if(!d)return;e.invalidateQueries({queryKey:He.collection(n.slug,d,o)});const f=o.toLowerCase().replace(/_/g," ");Lr.success(`${f} updated`)},t[1]=n,t[2]=i,t[3]=e,t[4]=s):s=t[4],s}function Yo(){const t=Q.c(2),e=Nd();let n;return t[0]!==e?(n=e??[],t[0]=e,t[1]=n):n=t[1],n}function t0(t){const e=Q.c(24),{gateway:n,isSelected:r}=t,i=r&&"bg-accent";let s;e[0]!==i?(s=ae("flex items-start gap-3 py-3 px-3 hover:bg-accent cursor-pointer rounded-xl transition-colors",i),e[0]=i,e[1]=s):s=e[1];let a;e[2]!==n.fallbackIcon?(a=n.fallbackIcon??m.jsx(ds,{}),e[2]=n.fallbackIcon,e[3]=a):a=e[3];let u;e[4]!==n.icon||e[5]!==n.title||e[6]!==a?(u=m.jsx(cs,{icon:n.icon,name:n.title,size:"sm",fallbackIcon:a,className:"size-10 rounded-xl border border-stone-200/60 shadow-sm shrink-0"}),e[4]=n.icon,e[5]=n.title,e[6]=a,e[7]=u):u=e[7];let l;e[8]!==n.title?(l=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:n.title}),e[8]=n.title,e[9]=l):l=e[9];let o;e[10]!==r?(o=r&&m.jsx(Yr,{size:16,className:"text-foreground shrink-0"}),e[10]=r,e[11]=o):o=e[11];let d;e[12]!==l||e[13]!==o?(d=m.jsxs("div",{className:"flex items-center justify-between",children:[l,o]}),e[12]=l,e[13]=o,e[14]=d):d=e[14];let f;e[15]!==n.description?(f=n.description&&m.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1 leading-relaxed",children:n.description}),e[15]=n.description,e[16]=f):f=e[16];let p;e[17]!==d||e[18]!==f?(p=m.jsxs("div",{className:"flex flex-col flex-1 min-w-0 gap-0.5",children:[d,f]}),e[17]=d,e[18]=f,e[19]=p):p=e[19];let h;return e[20]!==s||e[21]!==u||e[22]!==p?(h=m.jsxs("div",{className:s,children:[u,p]}),e[20]=s,e[21]=u,e[22]=p,e[23]=h):h=e[23],h}function qo(t){const e=Q.c(25),{gateways:n,selectedGatewayId:r,onGatewayChange:i,searchInputRef:s}=t,[a,u]=j.useState(""),l=j.useRef(null),o=s??l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={navigateOnCreate:!0},e[0]=d):d=e[0];const{createGateway:f,isCreating:p}=Pd(d);let h;e:{if(!a.trim()){h=n;break e}let P;if(e[1]!==n||e[2]!==a){const S=a.toLowerCase();P=n.filter(M=>M.title.toLowerCase().includes(S)||M.description?.toLowerCase().includes(S)),e[1]=n,e[2]=a,e[3]=P}else P=e[3];h=P}const g=h;let _;e[4]!==i?(_=P=>{i(P),u("")},e[4]=i,e[5]=_):_=e[5];const x=_;let E;e[6]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsx(qr,{size:16,className:"text-muted-foreground pointer-events-none shrink-0"}),e[6]=E):E=e[6];let C;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=P=>u(P.target.value),e[7]=C):C=e[7];let b;e[8]!==o||e[9]!==a?(b=m.jsx(Qu,{ref:o,type:"text",placeholder:"Search for an agent...",value:a,onChange:C,className:"flex-1 h-8 text-sm border-0 focus-visible:ring-0 focus-visible:ring-offset-0 shadow-none p-0"}),e[8]=o,e[9]=a,e[10]=b):b=e[10];const w=p?"Creating...":"Create Agent";let O;e[11]!==f||e[12]!==p||e[13]!==w?(O=m.jsx($e,{onClick:f,variant:"outline",size:"sm",className:"h-8 px-3 rounded-lg text-sm font-medium shrink-0",disabled:p,children:w}),e[11]=f,e[12]=p,e[13]=w,e[14]=O):O=e[14];let I;e[15]!==b||e[16]!==O?(I=m.jsx("div",{className:"border-b px-4 py-3 bg-background/95 backdrop-blur sticky top-0 z-10",children:m.jsxs("div",{className:"relative flex items-center gap-2",children:[E,b,O]})}),e[15]=b,e[16]=O,e[17]=I):I=e[17];let D;e[18]!==g||e[19]!==x||e[20]!==r?(D=m.jsx("div",{className:"overflow-y-auto p-1.5",children:g.length>0?m.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:g.map(P=>m.jsx("div",{role:"button",tabIndex:0,onClick:()=>x(P.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),x(P.id))},className:"outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl",children:m.jsx(t0,{gateway:P,isSelected:P.id===r})},P.id))}):m.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No agents found"})}),e[18]=g,e[19]=x,e[20]=r,e[21]=D):D=e[21];let B;return e[22]!==D||e[23]!==I?(B=m.jsxs("div",{className:"flex flex-col max-h-[400px]",children:[I,D]}),e[22]=D,e[23]=I,e[24]=B):B=e[24],B}function n0(t){const e=Q.c(37),{selectedGatewayId:n,onGatewayChange:r,gateways:i,className:s,placeholder:a,showTooltip:u,disabled:l}=t,o=a===void 0?"Select Agent":a,d=u===void 0?!0:u,f=l===void 0?!1:l,[p,h]=j.useState(!1),g=j.useRef(null),_=Yo(),x=i??_;let E,C;e[0]!==p?(E=()=>{p&&setTimeout(()=>{g.current?.focus()},0)},C=[p],e[0]=p,e[1]=E,e[2]=C):(E=e[1],C=e[2]),j.useEffect(E,C);let b;e[3]!==x||e[4]!==n?(b=n?x.find(re=>re.id===n):null,e[3]=x,e[4]=n,e[5]=b):b=e[5];const w=b;let O;e[6]!==r?(O=re=>{r(re),h(!1)},e[6]=r,e[7]=O):O=e[7];const I=O;let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=re=>{h(re)},e[8]=D):D=e[8];const B=D,P=f?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-accent";let S;e[9]!==s||e[10]!==P?(S=ae("flex items-center justify-center p-1 rounded-md transition-colors shrink-0",P,s),e[9]=s,e[10]=P,e[11]=S):S=e[11];let M;e[12]!==w?(M=w?m.jsx(cs,{icon:w.icon,name:w.title,size:"xs",fallbackIcon:w.fallbackIcon??m.jsx(ds,{size:12}),className:"size-5 rounded-md"}):m.jsx("img",{src:"/favicon.svg",alt:"Default Agent",className:"size-5 rounded-md"}),e[12]=w,e[13]=M):M=e[13];let $;e[14]!==f||e[15]!==o||e[16]!==S||e[17]!==M?($=m.jsx("button",{type:"button",disabled:f,className:S,"aria-label":o,children:M}),e[14]=f,e[15]=o,e[16]=S,e[17]=M,e[18]=$):$=e[18];const X=$,q=f?!1:p,U=f?void 0:B;let G;e[19]!==X?(G=m.jsx(_n,{asChild:!0,children:m.jsx(ar,{asChild:!0,children:X})}),e[19]=X,e[20]=G):G=e[20];let V;e[21]!==p||e[22]!==w?.title||e[23]!==d?(V=d&&!p&&m.jsx(xn,{side:"top",className:"text-xs",children:w?.title??"Choose an agent to chat with"}),e[21]=p,e[22]=w?.title,e[23]=d,e[24]=V):V=e[24];let K;e[25]!==G||e[26]!==V?(K=m.jsx(hs,{children:m.jsxs(yn,{children:[G,V]})}),e[25]=G,e[26]=V,e[27]=K):K=e[27];let J;e[28]!==x||e[29]!==I||e[30]!==n?(J=m.jsx(ur,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:m.jsx(qo,{gateways:x,selectedGatewayId:n,onGatewayChange:I,searchInputRef:g})}),e[28]=x,e[29]=I,e[30]=n,e[31]=J):J=e[31];let A;return e[32]!==q||e[33]!==U||e[34]!==K||e[35]!==J?(A=m.jsxs(or,{open:q,onOpenChange:U,children:[K,J]}),e[32]=q,e[33]=U,e[34]=K,e[35]=J,e[36]=A):A=e[36],A}const r0=["x-ai/grok-code-fast-1","anthropic/claude-sonnet-4.5","google/gemini-2.5-flash","xiaomi/mimo-v2-flash:free","google/gemini-3-flash-preview","deepseek/deepseek-v3.2","anthropic/claude-opus-4.5","x-ai/grok-4.1-fast","google/gemini-2.5-flash-lite","google/gemini-2.0-flash-001"],ji=new Map;r0.forEach((t,e)=>{ji.set(t,e)});function Ts(t){const e=Q.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={pageSize:999},e[0]=n):n=e[0];const r=Wh(t??void 0,n);let i;return e[1]!==r?(i=r.filter(s0).sort(i0),e[1]=r,e[2]=i):i=e[2],i}function i0(t,e){const n=ji.get(t.id),r=ji.get(e.id);return n!==void 0&&r!==void 0?n-r:n!==void 0?-1:r!==void 0?1:t.title.localeCompare(e.title)}function s0(t){return t.limits?.contextWindow&&t.limits?.maxOutputTokens}const a0={reasoning:{icon:m.jsx(Vr,{className:"size-4"}),label:"Reasoning"},"image-upload":{icon:m.jsx($d,{className:"size-4"}),label:"Can analyze images"},"file-upload":{icon:m.jsx(jd,{className:"size-4"}),label:"Can analyze files"},"web-search":{icon:m.jsx(qr,{className:"size-4"}),label:"Can search the web to answer questions"}};function Vo(t){const e=Q.c(10),{capability:n}=t,r=a0[n];let i,s;e[0]!==n||e[1]!==r?(i=r||{icon:null,label:n},s=i.label.split("-").map(u0).join(" "),e[0]=n,e[1]=r,e[2]=i,e[3]=s):(i=e[2],s=e[3]);const a=s;let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u={backgroundColor:"color-mix(in oklch, var(--chart-1) 15%, transparent)",color:"var(--chart-1)"},e[4]=u):u=e[4];let l;e[5]!==a?(l=m.jsx("span",{children:a}),e[5]=a,e[6]=l):l=e[6];let o;return e[7]!==i.icon||e[8]!==l?(o=m.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 px-1.5 rounded-md text-xs font-medium",style:u,children:[i.icon,l]}),e[7]=i.icon,e[8]=l,e[9]=o):o=e[9],o}function u0(t){return t.charAt(0).toUpperCase()+t.slice(1)}function o0(t){const e=Q.c(53),{model:n,compact:r}=t,i=r===void 0?!1:r;if(!n){let x;return e[0]===Symbol.for("react.memo_cache_sentinel")?(x=m.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Hover to preview"}),e[0]=x):x=e[0],x}const s=n.limits?.contextWindow||n.costs?.input||n.costs?.output||n.limits?.maxOutputTokens;if(!s&&!i){let x;e[1]!==n.logo||e[2]!==n.title?(x=n.logo&&m.jsx("img",{src:n.logo,className:"w-6 h-6",alt:n.title}),e[1]=n.logo,e[2]=n.title,e[3]=x):x=e[3];let E;e[4]!==n.title?(E=m.jsx("p",{className:"text-lg font-medium leading-7",children:n.title}),e[4]=n.title,e[5]=E):E=e[5];let C;e[6]!==x||e[7]!==E?(C=m.jsxs("div",{className:"flex items-center gap-3 py-2 px-0",children:[x,E]}),e[6]=x,e[7]=E,e[8]=C):C=e[8];let b;e[9]!==n.description?(b=n.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[9]=n.description,e[10]=b):b=e[10];let w;return e[11]!==C||e[12]!==b?(w=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[C,b]}),e[11]=C,e[12]=b,e[13]=w):w=e[13],w}if(!s&&i)return null;if(i){let x;e[14]!==n.limits?(x=n.limits?.contextWindow&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Context"}),m.jsxs("span",{className:"text-foreground font-medium",children:[n.limits.contextWindow.toLocaleString()," tokens"]})]}),e[14]=n.limits,e[15]=x):x=e[15];let E;e[16]!==n.costs?(E=n.costs?.input&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Input cost"}),m.jsxs("span",{className:"text-foreground font-medium",children:["$",n.costs.input.toFixed(2)," / 1M"]})]}),e[16]=n.costs,e[17]=E):E=e[17];let C;e[18]!==n.costs?(C=n.costs?.output&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Output cost"}),m.jsxs("span",{className:"text-foreground font-medium",children:["$",n.costs.output.toFixed(2)," / 1M"]})]}),e[18]=n.costs,e[19]=C):C=e[19];let b;e[20]!==n.limits?(b=n.limits?.maxOutputTokens&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),m.jsxs("span",{className:"text-foreground font-medium",children:[n.limits.maxOutputTokens.toLocaleString()," tokens"]})]}),e[20]=n.limits,e[21]=b):b=e[21];let w;return e[22]!==x||e[23]!==E||e[24]!==C||e[25]!==b?(w=m.jsxs("div",{className:"flex flex-col gap-2.5 pt-3 pb-3 px-3 rounded-b-lg text-xs",children:[x,E,C,b]}),e[22]=x,e[23]=E,e[24]=C,e[25]=b,e[26]=w):w=e[26],w}let a;e[27]!==n.logo||e[28]!==n.title?(a=n.logo&&m.jsx("img",{src:n.logo,className:"w-6 h-6 shrink-0",alt:n.title}),e[27]=n.logo,e[28]=n.title,e[29]=a):a=e[29];let u;e[30]!==n.title?(u=m.jsx("p",{className:"text-lg font-medium leading-7 wrap-break-word min-w-0",children:n.title}),e[30]=n.title,e[31]=u):u=e[31];let l;e[32]!==a||e[33]!==u?(l=m.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a,u]}),e[32]=a,e[33]=u,e[34]=l):l=e[34];let o;e[35]!==n.capabilities?(o=n.capabilities&&n.capabilities.length>0&&m.jsx("div",{className:"flex items-center gap-2",children:n.capabilities.map(l0)}),e[35]=n.capabilities,e[36]=o):o=e[36];let d;e[37]!==l||e[38]!==o?(d=m.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[l,o]}),e[37]=l,e[38]=o,e[39]=d):d=e[39];let f;e[40]!==n.limits?(f=n.limits?.contextWindow&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(zd,{className:"w-3.5 h-3.5 text-muted-foreground"}),m.jsx("p",{className:"text-sm text-foreground",children:"Context window"})]}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[n.limits.contextWindow.toLocaleString()," tokens"]})]}),e[40]=n.limits,e[41]=f):f=e[41];let p;e[42]!==n.costs?(p=(n.costs?.input||n.costs?.output)&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(no,{className:"w-3.5 h-3.5 text-muted-foreground"}),m.jsx("p",{className:"text-sm text-foreground",children:"Costs"})]}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.costs?.input!==null&&n.costs?.input!==void 0&&m.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",n.costs.input.toFixed(2)," / 1M tokens (input)"]}),n.costs?.output!==null&&n.costs?.output!==void 0&&m.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",n.costs.output.toFixed(2)," / 1M tokens (output)"]})]})]}),e[42]=n.costs,e[43]=p):p=e[43];let h;e[44]!==n.limits?(h=n.limits?.maxOutputTokens&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(so,{className:"w-4.5 h-4.5 text-muted-foreground/70"}),m.jsx("p",{className:"text-sm text-foreground",children:"Output limit"})]}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[n.limits.maxOutputTokens.toLocaleString()," token limit"]})]}),e[44]=n.limits,e[45]=h):h=e[45];let g;e[46]!==f||e[47]!==p||e[48]!==h?(g=m.jsxs("div",{className:"flex flex-col gap-4",children:[f,p,h]}),e[46]=f,e[47]=p,e[48]=h,e[49]=g):g=e[49];let _;return e[50]!==g||e[51]!==d?(_=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[d,g]}),e[50]=g,e[51]=d,e[52]=_):_=e[52],_}function l0(t){return m.jsx(Vo,{capability:t},t)}function c0(t){const e=Q.c(15),{model:n,onHover:r}=t;let i;e[0]!==n||e[1]!==r?(i=()=>r(n),e[0]=n,e[1]=r,e[2]=i):i=e[2];let s;e[3]!==n.logo||e[4]!==n.title?(s=n.logo&&m.jsx("img",{src:n.logo,className:"w-5 h-5 shrink-0",alt:n.title}),e[3]=n.logo,e[4]=n.title,e[5]=s):s=e[5];let a;e[6]!==n.title?(a=m.jsx("span",{className:"text-sm text-foreground flex-1 min-w-0 line-clamp-1",children:n.title}),e[6]=n.title,e[7]=a):a=e[7];let u;e[8]!==n.capabilities?(u=n.capabilities&&n.capabilities.length>0&&m.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:n.capabilities.slice(0,2).map(d0)}),e[8]=n.capabilities,e[9]=u):u=e[9];let l;return e[10]!==i||e[11]!==s||e[12]!==a||e[13]!==u?(l=m.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:i,children:[s,a,u]}),e[10]=i,e[11]=s,e[12]=a,e[13]=u,e[14]=l):l=e[14],l}function d0(t){return m.jsx(Vo,{capability:t},t)}function f0(t){const e=Q.c(10),{model:n,placeholder:r}=t,i=r===void 0?"Select model":r;if(!n){let l;return e[0]!==i?(l=m.jsx("span",{className:"text-sm text-muted-foreground",children:i}),e[0]=i,e[1]=l):l=e[1],l}let s;e[2]!==n.logo||e[3]!==n.title?(s=n.logo&&m.jsx("img",{src:n.logo,className:"w-5 h-5 shrink-0 rounded-sm",alt:n.title}),e[2]=n.logo,e[3]=n.title,e[4]=s):s=e[4];let a;e[5]!==n.title?(a=m.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors truncate min-w-0 hidden sm:inline-block",children:n.title}),e[5]=n.title,e[6]=a):a=e[6];let u;return e[7]!==s||e[8]!==a?(u=m.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[s,a]}),e[7]=s,e[8]=a,e[9]=u):u=e[9],u}function h0(){const t=Q.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:m.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4",children:[m.jsx(ze,{className:"size-4 shrink-0"}),m.jsx(ze,{className:"flex-1 h-6"}),m.jsx(ze,{className:"w-[140px] h-8 shrink-0"})]})}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[e,m.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2 space-y-1",children:Array.from({length:6}).map(p0)})]}),t[1]=n):n=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m.jsx(ze,{className:"size-6 shrink-0"}),m.jsx(ze,{className:"h-6 w-32"})]}),t[2]=r):r=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[r,m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ze,{className:"h-6 w-20 rounded-md"}),m.jsx(ze,{className:"h-6 w-24 rounded-md"})]})]}),t[3]=i):i=t[3];let s;t[4]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsx(ze,{className:"h-4 w-24"}),m.jsx(ze,{className:"h-4 w-32"})]}),t[4]=s):s=t[4];let a;return t[5]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[n,m.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[i,m.jsxs("div",{className:"flex flex-col gap-4",children:[s,m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsx(ze,{className:"h-4 w-16"}),m.jsx(ze,{className:"h-4 w-40"})]})]})]})})]}),t[5]=a):a=t[5],a}function p0(t,e){return m.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[m.jsx(ze,{className:"size-5 shrink-0 rounded-sm"}),m.jsx(ze,{className:"flex-1 h-4"}),m.jsx(ze,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function m0(t){const e=Q.c(39),{selectedModel:n,onModelChange:r,onClose:i,modelsConnections:s}=t,[a,u]=j.useState(null),[l,o]=j.useState(""),d=j.useRef(null),[f,p]=j.useState(n?.connectionId??null),h=bs(),g=s??h,_=Ts(f);let x,E;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{setTimeout(()=>{d.current?.focus()},0)},E=[],e[0]=x,e[1]=E):(x=e[0],E=e[1]),j.useEffect(x,E);let C;e[2]!==_||e[3]!==l?(C=l.trim()?_.filter(J=>{const A=l.toLowerCase();return J.title.toLowerCase().includes(A)||J.provider?.toLowerCase().includes(A)||J.description?.toLowerCase().includes(A)}):_,e[2]=_,e[3]=l,e[4]=C):C=e[4];const b=C;let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=J=>{p(J)},e[5]=w):w=e[5];const O=w;let I;e[6]!==_||e[7]!==i||e[8]!==r||e[9]!==f?(I=J=>{const A=_.find(re=>re.id===J);!A||!f||(r({id:A.id,connectionId:f,provider:A.provider??void 0}),o(""),i())},e[6]=_,e[7]=i,e[8]=r,e[9]=f,e[10]=I):I=e[10];const D=I;let B;e[11]===Symbol.for("react.memo_cache_sentinel")?(B=m.jsx(qr,{size:16,className:"text-muted-foreground shrink-0"}),e[11]=B):B=e[11];let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=J=>o(J.target.value),e[12]=P):P=e[12];let S;e[13]!==l?(S=m.jsx(Qu,{ref:d,type:"text",placeholder:"Search for a model...",value:l,onChange:P,className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"}),e[13]=l,e[14]=S):S=e[14];let M;e[15]!==g||e[16]!==f?(M=g.length>0&&m.jsxs(Md,{value:f??"",onValueChange:O,children:[m.jsxs(Bd,{size:"sm",className:"w-auto min-w-[140px] h-8 shrink-0 [&>svg:last-child]:hidden",onClick:b0,children:[m.jsx(Fd,{placeholder:"Select connection"}),m.jsx(Ju,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),m.jsx(Ud,{children:g.map(g0)})]}),e[15]=g,e[16]=f,e[17]=M):M=e[17];let $;e[18]!==S||e[19]!==M?($=m.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:m.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[B,S,M]})}),e[18]=S,e[19]=M,e[20]=$):$=e[20];let X;e[21]!==b||e[22]!==D||e[23]!==n?.id?(X=b.length>0?b.map(J=>{const A=J.id===n?.id;return m.jsx("div",{onClick:()=>D(J.id),className:ae("rounded-lg mb-1",A&&"bg-accent"),children:m.jsx(c0,{model:J,onHover:u})},J.id)}):m.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No models found"}),e[21]=b,e[22]=D,e[23]=n?.id,e[24]=X):X=e[24];let q;e[25]!==X?(q=m.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2",children:X}),e[25]=X,e[26]=q):q=e[26];let U;e[27]!==$||e[28]!==q?(U=m.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[$,q]}),e[27]=$,e[28]=q,e[29]=U):U=e[29];let G;e[30]!==a||e[31]!==_||e[32]!==n?(G=a||(n?_.find(J=>J.id===n.id):null)||null,e[30]=a,e[31]=_,e[32]=n,e[33]=G):G=e[33];let V;e[34]!==G?(V=m.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:m.jsx(o0,{model:G})}),e[34]=G,e[35]=V):V=e[35];let K;return e[36]!==U||e[37]!==V?(K=m.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[U,V]}),e[36]=U,e[37]=V,e[38]=K):K=e[38],K}function g0(t){return m.jsx(Hd,{value:t.id,children:m.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?m.jsx("img",{src:t.icon,alt:t.title,className:"w-4 h-4 rounded"}):m.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:t.title.slice(0,1).toUpperCase()}),m.jsx("span",{children:t.title})]})},t.id)}function b0(t){return t.stopPropagation()}function E0(t){const e=Q.c(23),{selectedModel:n,onModelChange:r,modelsConnections:i,variant:s,className:a,placeholder:u}=t,l=s===void 0?"borderless":s,o=u===void 0?"Select model":u,[d,f]=j.useState(!1),p=bs(),h=i??p,g=n?.connectionId??null,_=Ts(g);let x;e[0]!==_||e[1]!==n?(x=n?_.find(M=>M.id===n.id):void 0,e[0]=_,e[1]=n,e[2]=x):x=e[2];const E=x;if(h.length===0)return null;const C=l==="borderless"?"ghost":"outline",b=l==="borderless"&&"md:border-none";let w;e[3]!==a||e[4]!==b?(w=ae("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",b,a),e[3]=a,e[4]=b,e[5]=w):w=e[5];let O;e[6]!==E||e[7]!==o?(O=m.jsx(f0,{model:E,placeholder:o}),e[6]=E,e[7]=o,e[8]=O):O=e[8];let I;e[9]!==C||e[10]!==w||e[11]!==O?(I=m.jsx(ar,{asChild:!0,children:m.jsx($e,{variant:C,size:"sm",className:w,children:O})}),e[9]=C,e[10]=w,e[11]=O,e[12]=I):I=e[12];let D;e[13]===Symbol.for("react.memo_cache_sentinel")?(D=m.jsx(h0,{}),e[13]=D):D=e[13];let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=()=>f(!1),e[14]=B):B=e[14];let P;e[15]!==h||e[16]!==r||e[17]!==n?(P=m.jsx(ur,{className:"w-full md:w-auto p-0",align:"start",side:"bottom",sideOffset:8,children:m.jsx(j.Suspense,{fallback:D,children:m.jsx(m0,{selectedModel:n,onModelChange:r,onClose:B,modelsConnections:h})})}),e[15]=h,e[16]=r,e[17]=n,e[18]=P):P=e[18];let S;return e[19]!==d||e[20]!==P||e[21]!==I?(S=m.jsxs(or,{open:d,onOpenChange:f,children:[I,P]}),e[19]=d,e[20]=P,e[21]=I,e[22]=S):S=e[22],S}const T0=t=>new Mo({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:n={}})=>{const{system:r,...i}=n,s=r?{id:crypto.randomUUID(),role:"system",parts:[{type:"text",text:r}]}:null;return{body:{messages:s?[s,...e]:e,stream:!0,...i}}}}),Ca=(t,e)=>t?.find(n=>n.id===e)??t?.[0]??null,x0=(t,e)=>{const n=Q.c(14);let r;n[0]!==t?(r=fs.chatSelectedModel(t),n[0]=t,n[1]=r):r=n[1];const[i,s]=vr(r,null),a=i?.connectionId;let u;n[2]!==e||n[3]!==a?(u=Ca(e,a),n[2]=e,n[3]=a,n[4]=u):u=n[4];const l=u,o=Ts(l?.id??null),d=i?.id;let f;n[5]!==o||n[6]!==d?(f=Ca(o,d),n[5]=o,n[6]=d,n[7]=f):f=n[7];const p=f;let h;n[8]!==l||n[9]!==p?(h=p&&l?.id?{id:p.id,provider:p.provider,limits:p.limits,connectionId:l.id}:null,n[8]=l,n[9]=p,n[10]=h):h=n[10];const g=h;let _;return n[11]!==g||n[12]!==s?(_=[g,s],n[11]=g,n[12]=s,n[13]=_):_=n[13],_},Wo={inputValue:"",branchContext:null,finishReason:null};function _0(t,e){switch(e.type){case"SET_INPUT":return{...t,inputValue:e.payload};case"START_BRANCH":return{...t,branchContext:e.payload};case"CLEAR_BRANCH":return{...t,branchContext:null};case"SET_FINISH_REASON":return{...t,finishReason:e.payload};case"CLEAR_FINISH_REASON":return{...t,finishReason:null};case"RESET":return Wo;default:return t}}const Go=j.createContext(null),Qo=()=>crypto.randomUUID();function y0(t){const e=Q.c(75),{children:n}=t,{locator:r,org:i}=zt(),{data:s}=qu.useSession(),a=s?.user??null,[u,l]=j.useReducer(_0,Wo),o=zo(),d=$o(),{threads:f}=jo(),[p,h]=vr(fs.threadManagerState(r)+":active-id",N0),g=Kh(p),_=Yo(),[x,E]=vr(`${r}:selected-gateway-id`,null),C=bs(),[b,w]=x0(r,C),O=Jh(x),I=e0();let D;e[0]!==p||e[1]!==f?(D=f.find(le=>le.id===p)??null,e[0]=p,e[1]=f,e[2]=D):D=e[2];const B=D;let P;e[3]!==_||e[4]!==x?(P=x?_.find(le=>le.id===x)??null:null,e[3]=_,e[4]=x,e[5]=P):P=e[5];const S=P;let M;e[6]!==i.slug?(M=T0(i.slug),e[6]=i.slug,e[7]=M):M=e[7];const $=M;let X;e[8]!==p||e[9]!==r||e[10]!==d||e[11]!==S?.id||e[12]!==o?(X=async le=>{const{finishReason:v,messages:Y,isAbort:Z,isDisconnect:ue,isError:me}=le;if(l({type:"SET_FINISH_REASON",payload:v??null}),v!=="stop"||Z||ue||me)return;const je=Y.slice(-2).filter(Boolean);if(je.length!==2){console.warn("[chat] Expected 2 messages, got",je.length);return}d.insertMany.mutate(je);const xt=je.find(C0)?.parts?.find(k0)?.text.slice(0,100)||"",at=await Xh(r,p);if(!at){const vt=new Date().toISOString(),Vt={id:p,title:xt,created_at:vt,updated_at:vt,hidden:!1,gatewayId:S?.id};o.insert.mutate(Vt);return}o.update.mutate({id:p,updates:{title:at.title||xt,gatewayId:at.gatewayId||S?.id,updated_at:new Date().toISOString()}})},e[8]=p,e[9]=r,e[10]=d,e[11]=S?.id,e[12]=o,e[13]=X):X=e[13];const q=X,U=A0;let G;e[14]!==p||e[15]!==q||e[16]!==I||e[17]!==g||e[18]!==$?(G={id:p,messages:g,transport:$,onFinish:q,onToolCall:I,onError:U},e[14]=p,e[15]=q,e[16]=I,e[17]=g,e[18]=$,e[19]=G):G=e[19];const V=Vh(G),K=V.status==="submitted"||V.status==="streaming",J=V.messages.length===0;let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=le=>l({type:"SET_INPUT",payload:le}),e[20]=A):A=e[20];const re=A;let he;e[21]===Symbol.for("react.memo_cache_sentinel")?(he=le=>l({type:"START_BRANCH",payload:le}),e[21]=he):he=e[21];const N=he;let Ee;e[22]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>l({type:"CLEAR_BRANCH"}),e[22]=Ee):Ee=e[22];const ve=Ee;let fe;e[23]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>l({type:"RESET"}),e[23]=fe):fe=e[23];const We=fe;let Ie;e[24]!==h||e[25]!==o?(Ie=le=>{const v=le?.id||crypto.randomUUID(),Y=new Date().toISOString(),Z={id:v,title:le?.title||"",created_at:le?.created_at||Y,updated_at:le?.updated_at||Y,hidden:le?.hidden??!1,gatewayId:le?.gatewayId};return o.insert.mutate(Z),h(v),Z},e[24]=h,e[25]=o,e[26]=Ie):Ie=e[26];const Ne=Ie;let ye;e[27]!==p||e[28]!==h||e[29]!==o?(ye=le=>{o.update.mutate({id:le,updates:{hidden:!0,updated_at:new Date().toISOString()}}),p===le&&h(Qo())},e[27]=p,e[28]=h,e[29]=o,e[30]=ye):ye=e[30];const Be=ye;let Re;e[31]!==E?(Re=le=>{E(le)},e[31]=E,e[32]=Re):Re=e[32];const De=Re;let Oe;e[33]!==w?(Oe=le=>{w({id:le.id,connectionId:le.connectionId})},e[33]=w,e[34]=Oe):Oe=e[34];const Fe=Oe;let Se;e[35]!==p||e[36]!==V||e[37]!==O||e[38]!==K||e[39]!==S?.id||e[40]!==b||e[41]!==a?.image||e[42]!==a?.name?(Se=async le=>{if(!b){Lr.error("No model configured");return}if(!le?.trim()||K)return;re(""),ve(),l({type:"CLEAR_FINISH_REASON"});const v={created_at:new Date().toISOString(),thread_id:p,system:O,model:{id:b.id,connectionId:b.connectionId,provider:b.provider??void 0,limits:b.limits??void 0},gateway:{id:S?.id??null},user:{avatar:a?.image??void 0,name:a?.name??"you"}};await V.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:le}],metadata:v},{metadata:v})},e[35]=p,e[36]=V,e[37]=O,e[38]=K,e[39]=S?.id,e[40]=b,e[41]=a?.image,e[42]=a?.name,e[43]=Se):Se=e[43];const Ue=Se;let Ge;e[44]!==V?(Ge=()=>V.stop(),e[44]=V,e[45]=Ge):Ge=e[45];const Tt=Ge;let Je;e[46]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>l({type:"CLEAR_FINISH_REASON"}),e[46]=Je):Je=e[46];const qt=Je;let it;e[47]!==B||e[48]!==p||e[49]!==V.clearError||e[50]!==V.error||e[51]!==V.messages||e[52]!==V.setMessages||e[53]!==V.status||e[54]!==u.branchContext||e[55]!==u.finishReason||e[56]!==u.inputValue||e[57]!==Ne||e[58]!==_||e[59]!==Be||e[60]!==J||e[61]!==K||e[62]!==C||e[63]!==S||e[64]!==b||e[65]!==Ue||e[66]!==h||e[67]!==De||e[68]!==Fe||e[69]!==Tt||e[70]!==f?(it={inputValue:u.inputValue,branchContext:u.branchContext,setInputValue:re,startBranch:N,clearBranch:ve,resetInteraction:We,activeThreadId:p,activeThread:B,threads:f,createThread:Ne,setActiveThreadId:h,hideThread:Be,gateways:_,selectedGateway:S,setGatewayId:De,modelsConnections:C,selectedModel:b,setSelectedModel:Fe,messages:V.messages,chatStatus:V.status,isStreaming:K,isChatEmpty:J,sendMessage:Ue,stopStreaming:Tt,setMessages:V.setMessages,chatError:V.error,clearChatError:V.clearError,finishReason:u.finishReason,clearFinishReason:qt},e[47]=B,e[48]=p,e[49]=V.clearError,e[50]=V.error,e[51]=V.messages,e[52]=V.setMessages,e[53]=V.status,e[54]=u.branchContext,e[55]=u.finishReason,e[56]=u.inputValue,e[57]=Ne,e[58]=_,e[59]=Be,e[60]=J,e[61]=K,e[62]=C,e[63]=S,e[64]=b,e[65]=Ue,e[66]=h,e[67]=De,e[68]=Fe,e[69]=Tt,e[70]=f,e[71]=it):it=e[71];const dt=it;let st;return e[72]!==n||e[73]!==dt?(st=m.jsx(Go.Provider,{value:dt,children:n}),e[72]=n,e[73]=dt,e[74]=st):st=e[74],st}function A0(t){console.error("[chat] Chat error:",t)}function k0(t){return t.type==="text"}function C0(t){return t.parts?.find(I0)}function I0(t){return t.type==="text"}function N0(t){return t||Qo()}function An(){const t=j.useContext(Go);if(!t)throw new Error("useChat must be used within a ChatProvider");return t}const S0={openrouter:t=>{const e=t?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function w0(t){if(!t?.providerMetadata)return null;for(const e of Object.values(S0)){const n=e(t.providerMetadata);if(n!==null)return n}return null}function R0(t){return t.reduce((e,n)=>{const r=n.metadata?.usage;return r?{inputTokens:e.inputTokens+(r.inputTokens??0),outputTokens:e.outputTokens+(r.outputTokens??0),totalTokens:e.totalTokens+(r.totalTokens??0),cost:e.cost+(w0(r)??0)}:e},{inputTokens:0,outputTokens:0,totalTokens:0,cost:0})}function Xo(t){const e=Q.c(38),{messages:n}=t;let r,i,s,a,u,l,o,d,f,p,h,g;if(e[0]!==n){g=Symbol.for("react.early_return_sentinel");e:{const w=R0(n);if(!w){g=null;break e}const{totalTokens:O,inputTokens:I,outputTokens:D,cost:B}=w;if(s=B,!O&&!I&&!D){g=null;break e}i=yn;let P;e[13]===Symbol.for("react.memo_cache_sentinel")?(P=m.jsx(eo,{size:12}),e[13]=P):P=e[13];const S=m.jsxs($e,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap shrink-0",children:[P,m.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:O.toLocaleString()})]});e[14]!==S?(h=m.jsx(_n,{asChild:!0,children:S}),e[14]=S,e[15]=h):h=e[15],r=xn,f="top",p="font-mono text-[11px]",u="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",e[16]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("span",{className:"text-muted",children:"in"}),e[16]=l):l=e[16],o=m.jsx("span",{children:I.toLocaleString()}),e[17]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("span",{className:"text-muted",children:"out"}),e[17]=d):d=e[17],a=D.toLocaleString()}e[0]=n,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=u,e[6]=l,e[7]=o,e[8]=d,e[9]=f,e[10]=p,e[11]=h,e[12]=g}else r=e[1],i=e[2],s=e[3],a=e[4],u=e[5],l=e[6],o=e[7],d=e[8],f=e[9],p=e[10],h=e[11],g=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;let _;e[18]!==a?(_=m.jsx("span",{children:a}),e[18]=a,e[19]=_):_=e[19];let x;e[20]!==s?(x=s>0&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted",children:"cost"}),m.jsxs("span",{children:["$",s.toFixed(4)]})]}),e[20]=s,e[21]=x):x=e[21];let E;e[22]!==_||e[23]!==x||e[24]!==u||e[25]!==l||e[26]!==o||e[27]!==d?(E=m.jsxs("div",{className:u,children:[l,o,d,_,x]}),e[22]=_,e[23]=x,e[24]=u,e[25]=l,e[26]=o,e[27]=d,e[28]=E):E=e[28];let C;e[29]!==r||e[30]!==E||e[31]!==f||e[32]!==p?(C=m.jsx(r,{side:f,className:p,children:E}),e[29]=r,e[30]=E,e[31]=f,e[32]=p,e[33]=C):C=e[33];let b;return e[34]!==i||e[35]!==C||e[36]!==h?(b=m.jsxs(i,{children:[h,C]}),e[34]=i,e[35]=C,e[36]=h,e[37]=b):b=e[37],b}function O0({gatewayId:t,gateways:e,onGatewayChange:n,disabled:r=!1}){const[i,s]=j.useState(!1),a=j.useRef(null),u=Vu(),{org:l}=zt(),o=e.find(g=>g.id===t);if(!o)return null;j.useEffect(()=>{i&&setTimeout(()=>{a.current?.focus()},0)},[i]);const d=lo(t),f=g=>{g.stopPropagation(),n(null)},p=g=>{g.stopPropagation(),u({to:"/$org/gateways/$gatewayId",params:{org:l.slug,gatewayId:t}})},h=g=>{n(g),s(!1)};return m.jsxs("div",{className:ae("flex items-center justify-between px-3 py-1.5 rounded-t-xl",d?.bg),children:[m.jsxs(or,{open:i,onOpenChange:s,children:[m.jsx(ar,{asChild:!0,children:m.jsxs("button",{type:"button",disabled:r,className:ae("flex items-center gap-1.5 hover:opacity-80 transition-opacity",r?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[m.jsx(cs,{icon:o.icon,name:o.title,size:"2xs",fallbackIcon:o.fallbackIcon??m.jsx(ds,{size:10})}),m.jsx("span",{className:"text-xs text-white font-normal",children:o.title}),m.jsx(Id,{size:14,className:"text-white/50"})]})}),m.jsx(ur,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:m.jsx(qo,{gateways:e,selectedGatewayId:t,onGatewayChange:h,searchInputRef:a})})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("button",{type:"button",onClick:p,disabled:r,className:ae("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Edit gateway",children:m.jsx(Sd,{size:14,className:"text-white"})}),m.jsx("button",{type:"button",onClick:f,disabled:r,className:ae("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Reset to default",children:m.jsx(oo,{size:14,className:"text-white"})})]})]})}function L0(){const t=Q.c(120),{inputValue:e,setInputValue:n,branchContext:r,clearBranch:i,setActiveThreadId:s,gateways:a,selectedGateway:u,setGatewayId:l,modelsConnections:o,selectedModel:d,setSelectedModel:f,messages:p,isStreaming:h,sendMessage:g,stopStreaming:_,chatError:x,clearChatError:E,finishReason:C,clearFinishReason:b}=An();let w;t[0]!==e||t[1]!==h||t[2]!==d?(w=!h&&d&&e.trim().length>0,t[0]=e,t[1]=h,t[2]=d,t[3]=w):w=t[3];const O=w;let I;t[4]!==O||t[5]!==e||t[6]!==h||t[7]!==g||t[8]!==_?(I=Z=>{Z.preventDefault(),h?_():O&&g(e.trim())},t[4]=O,t[5]=e,t[6]=h,t[7]=g,t[8]=_,t[9]=I):I=t[9];const D=I;let B;t[10]!==O||t[11]!==e||t[12]!==g?(B=Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),O&&g(e.trim()))},t[10]=O,t[11]=e,t[12]=g,t[13]=B):B=t[13];const P=B;let S;t[14]!==r||t[15]!==i||t[16]!==s||t[17]!==n?(S=()=>{r&&(s(r.originalThreadId),i(),n(""))},t[14]=r,t[15]=i,t[16]=s,t[17]=n,t[18]=S):S=t[18];const M=S;let $;t[19]!==x||t[20]!==g?($=()=>{x&&g(`I encountered this error: ${x.message}. Can you help me fix it?`)},t[19]=x,t[20]=g,t[21]=$):$=t[21];const X=$;let q;t[22]!==g?(q=()=>{g("Please continue.")},t[22]=g,t[23]=q):q=t[23];const U=q;let G,V,K,J,A,re;if(t[24]!==r||t[25]!==x||t[26]!==i||t[27]!==E||t[28]!==b||t[29]!==C||t[30]!==U||t[31]!==X||t[32]!==M||t[33]!==u||t[34]!==d||t[35]!==n){const Z=u?lo(u.id):null;G=d?"Ask anything or @ for context":"Select a model to start chatting",J="flex flex-col gap-2 w-full min-h-42 justify-end",t[42]!==x||t[43]!==E||t[44]!==X?(A=x&&m.jsxs(vi,{variant:"danger",title:"Error occurred",description:x.message,icon:m.jsx(Wu,{size:16}),onDismiss:E,children:[m.jsx($e,{size:"sm",variant:"outline",onClick:X,className:"h-7 text-xs",children:"Fix in chat"}),m.jsx($e,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}),t[42]=x,t[43]=E,t[44]=X,t[45]=A):A=t[45],t[46]!==b||t[47]!==C||t[48]!==U?(re=C&&C!=="stop"&&m.jsx(vi,{variant:"warning",title:"Response incomplete",description:C==="length"?"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.":C==="content-filter"?"Response was filtered due to content policy.":C==="tool-calls"?"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working.":`Response stopped unexpectedly: ${C}`,icon:m.jsx(Ad,{size:16}),onDismiss:b,children:m.jsx($e,{size:"sm",variant:"outline",onClick:U,className:"h-7 text-xs",children:"Continue"})}),t[46]=b,t[47]=C,t[48]=U,t[49]=re):re=t[49],t[50]!==r||t[51]!==i||t[52]!==M||t[53]!==n?(V=r&&m.jsx(vi,{variant:"default",title:"Editing message (click to view original)",description:r.originalMessageText,icon:m.jsx(to,{size:14}),onDismiss:()=>{i(),n("")},children:m.jsx($e,{size:"sm",variant:"outline",onClick:M,className:"h-7 text-xs",children:"View original"})}),t[50]=r,t[51]=i,t[52]=M,t[53]=n,t[54]=V):V=t[54],K=ae("relative rounded-xl w-full flex flex-col",u&&"shadow-sm",Z?.bg),t[24]=r,t[25]=x,t[26]=i,t[27]=E,t[28]=b,t[29]=C,t[30]=U,t[31]=X,t[32]=M,t[33]=u,t[34]=d,t[35]=n,t[36]=G,t[37]=V,t[38]=K,t[39]=J,t[40]=A,t[41]=re}else G=t[36],V=t[37],K=t[38],J=t[39],A=t[40],re=t[41];let he;t[55]!==a||t[56]!==h||t[57]!==u||t[58]!==l?(he=u&&m.jsx(O0,{gatewayId:u.id,gateways:a,onGatewayChange:l,disabled:h}),t[55]=a,t[56]=h,t[57]=u,t[58]=l,t[59]=he):he=t[59];const N=!u&&"shadow-sm";let Ee;t[60]!==N?(Ee=ae("w-full relative rounded-xl min-h-[130px] flex flex-col border border-border bg-background",N),t[60]=N,t[61]=Ee):Ee=t[61];let ve;t[62]===Symbol.for("react.memo_cache_sentinel")?(ve={maxHeight:"164px"},t[62]=ve):ve=t[62];let fe;t[63]!==n?(fe=Z=>n(Z.target.value),t[63]=n,t[64]=fe):fe=t[64];const We=!d||h;let Ie;t[65]===Symbol.for("react.memo_cache_sentinel")?(Ie=ae("placeholder:text-muted-foreground resize-none focus-visible:ring-0 border-0 p-2 text-[15px]! min-h-[20px] w-full","rounded-none shadow-none","min-h-[20px] h-auto overflow-hidden"),t[65]=Ie):Ie=t[65];let Ne;t[66]!==P||t[67]!==e||t[68]!==G||t[69]!==fe||t[70]!==We?(Ne=m.jsx("div",{className:"relative flex flex-col gap-2 p-2.5 flex-1",children:m.jsx("div",{className:"overflow-y-auto relative flex-1",style:ve,children:m.jsx(yd,{rows:1,value:e,onChange:fe,onKeyDown:P,placeholder:G,disabled:We,className:Ie})})}),t[66]=P,t[67]=e,t[68]=G,t[69]=fe,t[70]=We,t[71]=Ne):Ne=t[71];let ye;t[72]!==a||t[73]!==h||t[74]!==u||t[75]!==l?(ye=!u&&m.jsx(n0,{selectedGatewayId:null,onGatewayChange:l,gateways:a,placeholder:"Agent",disabled:h}),t[72]=a,t[73]=h,t[74]=u,t[75]=l,t[76]=ye):ye=t[76];const Be=d??void 0;let Re;t[77]!==o||t[78]!==f||t[79]!==Be?(Re=m.jsx(E0,{selectedModel:Be,onModelChange:f,modelsConnections:o,placeholder:"Model",variant:"borderless"}),t[77]=o,t[78]=f,t[79]=Be,t[80]=Re):Re=t[80];let De;t[81]!==p?(De=m.jsx(Xo,{messages:p}),t[81]=p,t[82]=De):De=t[82];let Oe;t[83]!==ye||t[84]!==Re||t[85]!==De?(Oe=m.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[ye,Re,De]}),t[83]=ye,t[84]=Re,t[85]=De,t[86]=Oe):Oe=t[86];const Fe=h?"button":"submit";let Se;t[87]!==h||t[88]!==_?(Se=Z=>{h&&(Z.preventDefault(),Z.stopPropagation(),_())},t[87]=h,t[88]=_,t[89]=Se):Se=t[89];const Ue=O||h?"default":"ghost",Ge=!O&&!h,Tt=!O&&!h&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let Je;t[90]!==Tt?(Je=ae("size-8 rounded-full transition-all",Tt),t[90]=Tt,t[91]=Je):Je=t[91];const qt=h?"Stop generating":"Send message (Enter)";let it;t[92]!==h?(it=h?m.jsx(ao,{size:20}):m.jsx(Cd,{size:20}),t[92]=h,t[93]=it):it=t[93];let dt;t[94]!==Fe||t[95]!==Se||t[96]!==Ue||t[97]!==Ge||t[98]!==Je||t[99]!==qt||t[100]!==it?(dt=m.jsx("div",{className:"flex items-center gap-1",children:m.jsx($e,{type:Fe,onClick:Se,variant:Ue,size:"icon",disabled:Ge,className:Je,title:qt,children:it})}),t[94]=Fe,t[95]=Se,t[96]=Ue,t[97]=Ge,t[98]=Je,t[99]=qt,t[100]=it,t[101]=dt):dt=t[101];let st;t[102]!==Oe||t[103]!==dt?(st=m.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[Oe,dt]}),t[102]=Oe,t[103]=dt,t[104]=st):st=t[104];let le;t[105]!==D||t[106]!==Ee||t[107]!==Ne||t[108]!==st?(le=m.jsx("div",{className:"p-0.5",children:m.jsxs("form",{onSubmit:D,className:Ee,children:[Ne,st]})}),t[105]=D,t[106]=Ee,t[107]=Ne,t[108]=st,t[109]=le):le=t[109];let v;t[110]!==he||t[111]!==le||t[112]!==K?(v=m.jsxs("div",{className:K,children:[he,le]}),t[110]=he,t[111]=le,t[112]=K,t[113]=v):v=t[113];let Y;return t[114]!==V||t[115]!==v||t[116]!==J||t[117]!==A||t[118]!==re?(Y=m.jsxs("div",{className:J,children:[A,re,V,v]}),t[114]=V,t[115]=v,t[116]=J,t[117]=A,t[118]=re,t[119]=Y):Y=t[119],Y}async function v0(t){const e=`/mcp/gateway/${t}`,n={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const r=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mesh-chat",version:"1.0.0"}}})});if(!r.ok)return[];if((await r.json()).error)return[];const s=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!s.ok)return[];const a=await s.json();return a.error?[]:a.result?.prompts||[]}catch{return[]}}function D0(t){const e=Q.c(7);let n;e[0]!==t?(n=He.gatewayPrompts(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t?(r=()=>v0(t),e[2]=t,e[3]=r):r=e[3];let i;return e[4]!==n||e[5]!==r?(i={queryKey:n,queryFn:r,staleTime:6e4,retry:!1},e[4]=n,e[5]=r,e[6]=i):i=e[6],us(i)}const Ia=3;function P0(t){const e=Q.c(14),{prompt:n,onSelect:r}=t,i=n.description??n.name;let s;e[0]!==r||e[1]!==n?(s=()=>r(n),e[0]=r,e[1]=n,e[2]=s):s=e[2];const a=n.title??n.name;let u;if(e[3]!==a){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=/_/g,e[5]=f):f=e[5],u=a.replace(f," "),e[3]=a,e[4]=u}else u=e[4];let l;e[6]!==s||e[7]!==u?(l=m.jsx(_n,{asChild:!0,children:m.jsx("button",{type:"button",onClick:s,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:u})}),e[6]=s,e[7]=u,e[8]=l):l=e[8];let o;e[9]!==i?(o=m.jsx(xn,{side:"bottom",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:i})}),e[9]=i,e[10]=o):o=e[10];let d;return e[11]!==l||e[12]!==o?(d=m.jsxs(yn,{children:[l,o]}),e[11]=l,e[12]=o,e[13]=d):d=e[13],d}function M0(t){const e=Q.c(20),{prompts:n,onSelect:r,className:i}=t;if(n.length===0)return null;let s,a,u,l,o;if(e[0]!==i||e[1]!==r||e[2]!==n){const p=n.slice(0,Ia),h=n.slice(Ia),g=h.length>0;s=hs,o=300,e[8]!==i?(a=ae("flex flex-wrap items-center justify-center gap-2",i),e[8]=i,e[9]=a):a=e[9];let _;e[10]!==r?(_=x=>m.jsx(P0,{prompt:x,onSelect:r},x.name),e[10]=r,e[11]=_):_=e[11],u=p.map(_),l=g&&m.jsxs(or,{children:[m.jsx(ar,{asChild:!0,children:m.jsxs("button",{type:"button",className:"size-7 flex items-center justify-center text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:["+",h.length]})}),m.jsx(ur,{side:"bottom",align:"center",className:"w-auto p-2",children:m.jsx("div",{className:"flex flex-col gap-1",children:h.map(x=>{const E=x.description??x.name;return m.jsxs(yn,{children:[m.jsx(_n,{asChild:!0,children:m.jsx("button",{type:"button",onClick:()=>r(x),className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors cursor-pointer text-left",children:(x.title??x.name).replace(/_/g," ")})}),m.jsx(xn,{side:"right",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:E})})]},x.name)})})})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=s,e[4]=a,e[5]=u,e[6]=l,e[7]=o}else s=e[3],a=e[4],u=e[5],l=e[6],o=e[7];let d;e[12]!==a||e[13]!==u||e[14]!==l?(d=m.jsxs("div",{className:a,children:[u,l]}),e[12]=a,e[13]=u,e[14]=l,e[15]=d):d=e[15];let f;return e[16]!==s||e[17]!==o||e[18]!==d?(f=m.jsx(s,{delayDuration:o,children:d}),e[16]=s,e[17]=o,e[18]=d,e[19]=f):f=e[19],f}function B0(){const t=Q.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsxs(m.Fragment,{children:[m.jsx(ze,{className:"h-6 w-20 rounded-full border border-border"}),m.jsx(ze,{className:"h-6 w-24 rounded-full border border-border"})]}),t[0]=e):e=t[0],e}function F0(t){const e=Q.c(8),{className:n}=t,{selectedGateway:r}=An();let i;e[0]!==n?(i=ae("flex flex-wrap items-center justify-center gap-2",n),e[0]=n,e[1]=i):i=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={minHeight:"32px"},e[2]=s):s=e[2];let a;e[3]!==r?(a=r&&m.jsx(kd,{fallback:null,children:m.jsx(j.Suspense,{fallback:m.jsx(B0,{}),children:m.jsx(U0,{gatewayId:r.id})})},r.id),e[3]=r,e[4]=a):a=e[4];let u;return e[5]!==i||e[6]!==a?(u=m.jsx("div",{className:i,style:s,children:a}),e[5]=i,e[6]=a,e[7]=u):u=e[7],u}function U0(t){const e=Q.c(5),{gatewayId:n}=t,{sendMessage:r}=An(),{data:i}=D0(n);if(i.length===0)return null;let s;e[0]!==r?(s=u=>r(u.description??u.name),e[0]=r,e[1]=s):s=e[1];let a;return e[2]!==i||e[3]!==s?(a=m.jsx(M0,{prompts:i,onSelect:s}),e[2]=i,e[3]=s,e[4]=a):a=e[4],a}function H0(){const t=Q.c(3),[e,n]=j.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async a=>{await navigator.clipboard.writeText(a),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let s;return t[1]!==e?(s={handleCopy:i,copied:e},t[1]=e,t[2]=s):s=t[2],s}function xs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var rn=xs();function Zo(t){rn=t}var zn={exec:()=>null};function pe(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,s)=>{let a=typeof s=="string"?s:s.source;return a=a.replace(Ke.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var Ke={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},j0=/^(?:[ \t]*(?:\n|$))+/,z0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,$0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,dr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Y0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_s=/(?:[*+-]|\d{1,9}[.)])/,Ko=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Jo=pe(Ko).replace(/bull/g,_s).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),q0=pe(Ko).replace(/bull/g,_s).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ys=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,V0=/^[^\n]+/,As=/(?!\s*\])(?:\\.|[^\[\]\\])+/,W0=pe(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",As).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),G0=pe(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_s).getRegex(),Qr="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ks=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Q0=pe("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ks).replace("tag",Qr).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),el=pe(ys).replace("hr",dr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qr).getRegex(),X0=pe(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",el).getRegex(),Cs={blockquote:X0,code:z0,def:W0,fences:$0,heading:Y0,hr:dr,html:Q0,lheading:Jo,list:G0,newline:j0,paragraph:el,table:zn,text:V0},Na=pe("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",dr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qr).getRegex(),Z0={...Cs,lheading:q0,table:Na,paragraph:pe(ys).replace("hr",dr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Na).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qr).getRegex()},K0={...Cs,html:pe(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ks).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:pe(ys).replace("hr",dr).replace("heading",` *#{1,6} *[^
21
+ `)}function e0(){const t=Q.c(5),e=os(),{org:n}=zt();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const i=Yu(r);let s;return t[1]!==n||t[2]!==i||t[3]!==e?(s=a=>{const l=a.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!l||!l[1])return;const o=l[1],d=i.connectionId;if(!d)return;e.invalidateQueries({queryKey:He.collection(n.slug,d,o)});const f=o.toLowerCase().replace(/_/g," ");Lr.success(`${f} updated`)},t[1]=n,t[2]=i,t[3]=e,t[4]=s):s=t[4],s}function Yo(){const t=Q.c(2),e=Nd();let n;return t[0]!==e?(n=e??[],t[0]=e,t[1]=n):n=t[1],n}function t0(t){const e=Q.c(24),{gateway:n,isSelected:r}=t,i=r&&"bg-accent";let s;e[0]!==i?(s=ae("flex items-start gap-3 py-3 px-3 hover:bg-accent cursor-pointer rounded-xl transition-colors",i),e[0]=i,e[1]=s):s=e[1];let a;e[2]!==n.fallbackIcon?(a=n.fallbackIcon??m.jsx(ds,{}),e[2]=n.fallbackIcon,e[3]=a):a=e[3];let u;e[4]!==n.icon||e[5]!==n.title||e[6]!==a?(u=m.jsx(cs,{icon:n.icon,name:n.title,size:"sm",fallbackIcon:a,className:"size-10 rounded-xl border border-stone-200/60 shadow-sm shrink-0"}),e[4]=n.icon,e[5]=n.title,e[6]=a,e[7]=u):u=e[7];let l;e[8]!==n.title?(l=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:n.title}),e[8]=n.title,e[9]=l):l=e[9];let o;e[10]!==r?(o=r&&m.jsx(Yr,{size:16,className:"text-foreground shrink-0"}),e[10]=r,e[11]=o):o=e[11];let d;e[12]!==l||e[13]!==o?(d=m.jsxs("div",{className:"flex items-center justify-between",children:[l,o]}),e[12]=l,e[13]=o,e[14]=d):d=e[14];let f;e[15]!==n.description?(f=n.description&&m.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1 leading-relaxed",children:n.description}),e[15]=n.description,e[16]=f):f=e[16];let p;e[17]!==d||e[18]!==f?(p=m.jsxs("div",{className:"flex flex-col flex-1 min-w-0 gap-0.5",children:[d,f]}),e[17]=d,e[18]=f,e[19]=p):p=e[19];let h;return e[20]!==s||e[21]!==u||e[22]!==p?(h=m.jsxs("div",{className:s,children:[u,p]}),e[20]=s,e[21]=u,e[22]=p,e[23]=h):h=e[23],h}function qo(t){const e=Q.c(25),{gateways:n,selectedGatewayId:r,onGatewayChange:i,searchInputRef:s}=t,[a,u]=j.useState(""),l=j.useRef(null),o=s??l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={navigateOnCreate:!0},e[0]=d):d=e[0];const{createGateway:f,isCreating:p}=Pd(d);let h;e:{if(!a.trim()){h=n;break e}let P;if(e[1]!==n||e[2]!==a){const S=a.toLowerCase();P=n.filter(M=>M.title.toLowerCase().includes(S)||M.description?.toLowerCase().includes(S)),e[1]=n,e[2]=a,e[3]=P}else P=e[3];h=P}const g=h;let _;e[4]!==i?(_=P=>{i(P),u("")},e[4]=i,e[5]=_):_=e[5];const x=_;let E;e[6]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsx(qr,{size:16,className:"text-muted-foreground pointer-events-none shrink-0"}),e[6]=E):E=e[6];let C;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=P=>u(P.target.value),e[7]=C):C=e[7];let b;e[8]!==o||e[9]!==a?(b=m.jsx(Qu,{ref:o,type:"text",placeholder:"Search for an agent...",value:a,onChange:C,className:"flex-1 h-8 text-sm border-0 focus-visible:ring-0 focus-visible:ring-offset-0 shadow-none p-0"}),e[8]=o,e[9]=a,e[10]=b):b=e[10];const w=p?"Creating...":"Create Agent";let O;e[11]!==f||e[12]!==p||e[13]!==w?(O=m.jsx($e,{onClick:f,variant:"outline",size:"sm",className:"h-8 px-3 rounded-lg text-sm font-medium shrink-0",disabled:p,children:w}),e[11]=f,e[12]=p,e[13]=w,e[14]=O):O=e[14];let I;e[15]!==b||e[16]!==O?(I=m.jsx("div",{className:"border-b px-4 py-3 bg-background/95 backdrop-blur sticky top-0 z-10",children:m.jsxs("div",{className:"relative flex items-center gap-2",children:[E,b,O]})}),e[15]=b,e[16]=O,e[17]=I):I=e[17];let D;e[18]!==g||e[19]!==x||e[20]!==r?(D=m.jsx("div",{className:"overflow-y-auto p-1.5",children:g.length>0?m.jsx("div",{className:"grid grid-cols-2 gap-0.5",children:g.map(P=>m.jsx("div",{role:"button",tabIndex:0,onClick:()=>x(P.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),x(P.id))},className:"outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl",children:m.jsx(t0,{gateway:P,isSelected:P.id===r})},P.id))}):m.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No agents found"})}),e[18]=g,e[19]=x,e[20]=r,e[21]=D):D=e[21];let B;return e[22]!==D||e[23]!==I?(B=m.jsxs("div",{className:"flex flex-col max-h-[400px]",children:[I,D]}),e[22]=D,e[23]=I,e[24]=B):B=e[24],B}function n0(t){const e=Q.c(37),{selectedGatewayId:n,onGatewayChange:r,gateways:i,className:s,placeholder:a,showTooltip:u,disabled:l}=t,o=a===void 0?"Select Agent":a,d=u===void 0?!0:u,f=l===void 0?!1:l,[p,h]=j.useState(!1),g=j.useRef(null),_=Yo(),x=i??_;let E,C;e[0]!==p?(E=()=>{p&&setTimeout(()=>{g.current?.focus()},0)},C=[p],e[0]=p,e[1]=E,e[2]=C):(E=e[1],C=e[2]),j.useEffect(E,C);let b;e[3]!==x||e[4]!==n?(b=n?x.find(re=>re.id===n):null,e[3]=x,e[4]=n,e[5]=b):b=e[5];const w=b;let O;e[6]!==r?(O=re=>{r(re),h(!1)},e[6]=r,e[7]=O):O=e[7];const I=O;let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=re=>{h(re)},e[8]=D):D=e[8];const B=D,P=f?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-accent";let S;e[9]!==s||e[10]!==P?(S=ae("flex items-center justify-center p-1 rounded-md transition-colors shrink-0",P,s),e[9]=s,e[10]=P,e[11]=S):S=e[11];let M;e[12]!==w?(M=w?m.jsx(cs,{icon:w.icon,name:w.title,size:"xs",fallbackIcon:w.fallbackIcon??m.jsx(ds,{size:12}),className:"size-5 rounded-md"}):m.jsx("img",{src:"/favicon.svg",alt:"Default Agent",className:"size-5 rounded-md"}),e[12]=w,e[13]=M):M=e[13];let $;e[14]!==f||e[15]!==o||e[16]!==S||e[17]!==M?($=m.jsx("button",{type:"button",disabled:f,className:S,"aria-label":o,children:M}),e[14]=f,e[15]=o,e[16]=S,e[17]=M,e[18]=$):$=e[18];const X=$,q=f?!1:p,U=f?void 0:B;let G;e[19]!==X?(G=m.jsx(_n,{asChild:!0,children:m.jsx(ar,{asChild:!0,children:X})}),e[19]=X,e[20]=G):G=e[20];let V;e[21]!==p||e[22]!==w?.title||e[23]!==d?(V=d&&!p&&m.jsx(xn,{side:"top",className:"text-xs",children:w?.title??"Choose an agent to chat with"}),e[21]=p,e[22]=w?.title,e[23]=d,e[24]=V):V=e[24];let K;e[25]!==G||e[26]!==V?(K=m.jsx(hs,{children:m.jsxs(yn,{children:[G,V]})}),e[25]=G,e[26]=V,e[27]=K):K=e[27];let J;e[28]!==x||e[29]!==I||e[30]!==n?(J=m.jsx(ur,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:m.jsx(qo,{gateways:x,selectedGatewayId:n,onGatewayChange:I,searchInputRef:g})}),e[28]=x,e[29]=I,e[30]=n,e[31]=J):J=e[31];let A;return e[32]!==q||e[33]!==U||e[34]!==K||e[35]!==J?(A=m.jsxs(or,{open:q,onOpenChange:U,children:[K,J]}),e[32]=q,e[33]=U,e[34]=K,e[35]=J,e[36]=A):A=e[36],A}const r0=["x-ai/grok-code-fast-1","anthropic/claude-sonnet-4.5","google/gemini-2.5-flash","xiaomi/mimo-v2-flash:free","google/gemini-3-flash-preview","deepseek/deepseek-v3.2","anthropic/claude-opus-4.5","x-ai/grok-4.1-fast","google/gemini-2.5-flash-lite","google/gemini-2.0-flash-001"],ji=new Map;r0.forEach((t,e)=>{ji.set(t,e)});function Ts(t){const e=Q.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={pageSize:999},e[0]=n):n=e[0];const r=Wh(t??void 0,n);let i;return e[1]!==r?(i=r.filter(s0).sort(i0),e[1]=r,e[2]=i):i=e[2],i}function i0(t,e){const n=ji.get(t.id),r=ji.get(e.id);return n!==void 0&&r!==void 0?n-r:n!==void 0?-1:r!==void 0?1:t.title.localeCompare(e.title)}function s0(t){return t.limits?.contextWindow&&t.limits?.maxOutputTokens}const a0={reasoning:{icon:m.jsx(Vr,{className:"size-4"}),label:"Reasoning"},"image-upload":{icon:m.jsx($d,{className:"size-4"}),label:"Can analyze images"},"file-upload":{icon:m.jsx(jd,{className:"size-4"}),label:"Can analyze files"},"web-search":{icon:m.jsx(qr,{className:"size-4"}),label:"Can search the web to answer questions"}};function Vo(t){const e=Q.c(10),{capability:n}=t,r=a0[n];let i,s;e[0]!==n||e[1]!==r?(i=r||{icon:null,label:n},s=i.label.split("-").map(u0).join(" "),e[0]=n,e[1]=r,e[2]=i,e[3]=s):(i=e[2],s=e[3]);const a=s;let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u={backgroundColor:"color-mix(in oklch, var(--chart-1) 15%, transparent)",color:"var(--chart-1)"},e[4]=u):u=e[4];let l;e[5]!==a?(l=m.jsx("span",{children:a}),e[5]=a,e[6]=l):l=e[6];let o;return e[7]!==i.icon||e[8]!==l?(o=m.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 px-1.5 rounded-md text-xs font-medium",style:u,children:[i.icon,l]}),e[7]=i.icon,e[8]=l,e[9]=o):o=e[9],o}function u0(t){return t.charAt(0).toUpperCase()+t.slice(1)}function o0(t){const e=Q.c(53),{model:n,compact:r}=t,i=r===void 0?!1:r;if(!n){let x;return e[0]===Symbol.for("react.memo_cache_sentinel")?(x=m.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Hover to preview"}),e[0]=x):x=e[0],x}const s=n.limits?.contextWindow||n.costs?.input||n.costs?.output||n.limits?.maxOutputTokens;if(!s&&!i){let x;e[1]!==n.logo||e[2]!==n.title?(x=n.logo&&m.jsx("img",{src:n.logo,className:"w-6 h-6",alt:n.title}),e[1]=n.logo,e[2]=n.title,e[3]=x):x=e[3];let E;e[4]!==n.title?(E=m.jsx("p",{className:"text-lg font-medium leading-7",children:n.title}),e[4]=n.title,e[5]=E):E=e[5];let C;e[6]!==x||e[7]!==E?(C=m.jsxs("div",{className:"flex items-center gap-3 py-2 px-0",children:[x,E]}),e[6]=x,e[7]=E,e[8]=C):C=e[8];let b;e[9]!==n.description?(b=n.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[9]=n.description,e[10]=b):b=e[10];let w;return e[11]!==C||e[12]!==b?(w=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[C,b]}),e[11]=C,e[12]=b,e[13]=w):w=e[13],w}if(!s&&i)return null;if(i){let x;e[14]!==n.limits?(x=n.limits?.contextWindow&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Context"}),m.jsxs("span",{className:"text-foreground font-medium",children:[n.limits.contextWindow.toLocaleString()," tokens"]})]}),e[14]=n.limits,e[15]=x):x=e[15];let E;e[16]!==n.costs?(E=n.costs?.input&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Input cost"}),m.jsxs("span",{className:"text-foreground font-medium",children:["$",n.costs.input.toFixed(2)," / 1M"]})]}),e[16]=n.costs,e[17]=E):E=e[17];let C;e[18]!==n.costs?(C=n.costs?.output&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Output cost"}),m.jsxs("span",{className:"text-foreground font-medium",children:["$",n.costs.output.toFixed(2)," / 1M"]})]}),e[18]=n.costs,e[19]=C):C=e[19];let b;e[20]!==n.limits?(b=n.limits?.maxOutputTokens&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),m.jsxs("span",{className:"text-foreground font-medium",children:[n.limits.maxOutputTokens.toLocaleString()," tokens"]})]}),e[20]=n.limits,e[21]=b):b=e[21];let w;return e[22]!==x||e[23]!==E||e[24]!==C||e[25]!==b?(w=m.jsxs("div",{className:"flex flex-col gap-2.5 pt-3 pb-3 px-3 rounded-b-lg text-xs",children:[x,E,C,b]}),e[22]=x,e[23]=E,e[24]=C,e[25]=b,e[26]=w):w=e[26],w}let a;e[27]!==n.logo||e[28]!==n.title?(a=n.logo&&m.jsx("img",{src:n.logo,className:"w-6 h-6 shrink-0",alt:n.title}),e[27]=n.logo,e[28]=n.title,e[29]=a):a=e[29];let u;e[30]!==n.title?(u=m.jsx("p",{className:"text-lg font-medium leading-7 wrap-break-word min-w-0",children:n.title}),e[30]=n.title,e[31]=u):u=e[31];let l;e[32]!==a||e[33]!==u?(l=m.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a,u]}),e[32]=a,e[33]=u,e[34]=l):l=e[34];let o;e[35]!==n.capabilities?(o=n.capabilities&&n.capabilities.length>0&&m.jsx("div",{className:"flex items-center gap-2",children:n.capabilities.map(l0)}),e[35]=n.capabilities,e[36]=o):o=e[36];let d;e[37]!==l||e[38]!==o?(d=m.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[l,o]}),e[37]=l,e[38]=o,e[39]=d):d=e[39];let f;e[40]!==n.limits?(f=n.limits?.contextWindow&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(zd,{className:"w-3.5 h-3.5 text-muted-foreground"}),m.jsx("p",{className:"text-sm text-foreground",children:"Context window"})]}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[n.limits.contextWindow.toLocaleString()," tokens"]})]}),e[40]=n.limits,e[41]=f):f=e[41];let p;e[42]!==n.costs?(p=(n.costs?.input||n.costs?.output)&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(no,{className:"w-3.5 h-3.5 text-muted-foreground"}),m.jsx("p",{className:"text-sm text-foreground",children:"Costs"})]}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.costs?.input!==null&&n.costs?.input!==void 0&&m.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",n.costs.input.toFixed(2)," / 1M tokens (input)"]}),n.costs?.output!==null&&n.costs?.output!==void 0&&m.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",n.costs.output.toFixed(2)," / 1M tokens (output)"]})]})]}),e[42]=n.costs,e[43]=p):p=e[43];let h;e[44]!==n.limits?(h=n.limits?.maxOutputTokens&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(so,{className:"w-4.5 h-4.5 text-muted-foreground/70"}),m.jsx("p",{className:"text-sm text-foreground",children:"Output limit"})]}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[n.limits.maxOutputTokens.toLocaleString()," token limit"]})]}),e[44]=n.limits,e[45]=h):h=e[45];let g;e[46]!==f||e[47]!==p||e[48]!==h?(g=m.jsxs("div",{className:"flex flex-col gap-4",children:[f,p,h]}),e[46]=f,e[47]=p,e[48]=h,e[49]=g):g=e[49];let _;return e[50]!==g||e[51]!==d?(_=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[d,g]}),e[50]=g,e[51]=d,e[52]=_):_=e[52],_}function l0(t){return m.jsx(Vo,{capability:t},t)}function c0(t){const e=Q.c(15),{model:n,onHover:r}=t;let i;e[0]!==n||e[1]!==r?(i=()=>r(n),e[0]=n,e[1]=r,e[2]=i):i=e[2];let s;e[3]!==n.logo||e[4]!==n.title?(s=n.logo&&m.jsx("img",{src:n.logo,className:"w-5 h-5 shrink-0",alt:n.title}),e[3]=n.logo,e[4]=n.title,e[5]=s):s=e[5];let a;e[6]!==n.title?(a=m.jsx("span",{className:"text-sm text-foreground flex-1 min-w-0 line-clamp-1",children:n.title}),e[6]=n.title,e[7]=a):a=e[7];let u;e[8]!==n.capabilities?(u=n.capabilities&&n.capabilities.length>0&&m.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:n.capabilities.slice(0,2).map(d0)}),e[8]=n.capabilities,e[9]=u):u=e[9];let l;return e[10]!==i||e[11]!==s||e[12]!==a||e[13]!==u?(l=m.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:i,children:[s,a,u]}),e[10]=i,e[11]=s,e[12]=a,e[13]=u,e[14]=l):l=e[14],l}function d0(t){return m.jsx(Vo,{capability:t},t)}function f0(t){const e=Q.c(10),{model:n,placeholder:r}=t,i=r===void 0?"Select model":r;if(!n){let l;return e[0]!==i?(l=m.jsx("span",{className:"text-sm text-muted-foreground",children:i}),e[0]=i,e[1]=l):l=e[1],l}let s;e[2]!==n.logo||e[3]!==n.title?(s=n.logo&&m.jsx("img",{src:n.logo,className:"w-5 h-5 shrink-0 rounded-sm",alt:n.title}),e[2]=n.logo,e[3]=n.title,e[4]=s):s=e[4];let a;e[5]!==n.title?(a=m.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors truncate min-w-0 hidden sm:inline-block",children:n.title}),e[5]=n.title,e[6]=a):a=e[6];let u;return e[7]!==s||e[8]!==a?(u=m.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[s,a]}),e[7]=s,e[8]=a,e[9]=u):u=e[9],u}function h0(){const t=Q.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:m.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4",children:[m.jsx(ze,{className:"size-4 shrink-0"}),m.jsx(ze,{className:"flex-1 h-6"}),m.jsx(ze,{className:"w-[140px] h-8 shrink-0"})]})}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[e,m.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2 space-y-1",children:Array.from({length:6}).map(p0)})]}),t[1]=n):n=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m.jsx(ze,{className:"size-6 shrink-0"}),m.jsx(ze,{className:"h-6 w-32"})]}),t[2]=r):r=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[r,m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ze,{className:"h-6 w-20 rounded-md"}),m.jsx(ze,{className:"h-6 w-24 rounded-md"})]})]}),t[3]=i):i=t[3];let s;t[4]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsx(ze,{className:"h-4 w-24"}),m.jsx(ze,{className:"h-4 w-32"})]}),t[4]=s):s=t[4];let a;return t[5]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[n,m.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[i,m.jsxs("div",{className:"flex flex-col gap-4",children:[s,m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsx(ze,{className:"h-4 w-16"}),m.jsx(ze,{className:"h-4 w-40"})]})]})]})})]}),t[5]=a):a=t[5],a}function p0(t,e){return m.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[m.jsx(ze,{className:"size-5 shrink-0 rounded-sm"}),m.jsx(ze,{className:"flex-1 h-4"}),m.jsx(ze,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function m0(t){const e=Q.c(39),{selectedModel:n,onModelChange:r,onClose:i,modelsConnections:s}=t,[a,u]=j.useState(null),[l,o]=j.useState(""),d=j.useRef(null),[f,p]=j.useState(n?.connectionId??null),h=bs(),g=s??h,_=Ts(f);let x,E;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{setTimeout(()=>{d.current?.focus()},0)},E=[],e[0]=x,e[1]=E):(x=e[0],E=e[1]),j.useEffect(x,E);let C;e[2]!==_||e[3]!==l?(C=l.trim()?_.filter(J=>{const A=l.toLowerCase();return J.title.toLowerCase().includes(A)||J.provider?.toLowerCase().includes(A)||J.description?.toLowerCase().includes(A)}):_,e[2]=_,e[3]=l,e[4]=C):C=e[4];const b=C;let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=J=>{p(J)},e[5]=w):w=e[5];const O=w;let I;e[6]!==_||e[7]!==i||e[8]!==r||e[9]!==f?(I=J=>{const A=_.find(re=>re.id===J);!A||!f||(r({id:A.id,connectionId:f,provider:A.provider??void 0}),o(""),i())},e[6]=_,e[7]=i,e[8]=r,e[9]=f,e[10]=I):I=e[10];const D=I;let B;e[11]===Symbol.for("react.memo_cache_sentinel")?(B=m.jsx(qr,{size:16,className:"text-muted-foreground shrink-0"}),e[11]=B):B=e[11];let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=J=>o(J.target.value),e[12]=P):P=e[12];let S;e[13]!==l?(S=m.jsx(Qu,{ref:d,type:"text",placeholder:"Search for a model...",value:l,onChange:P,className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"}),e[13]=l,e[14]=S):S=e[14];let M;e[15]!==g||e[16]!==f?(M=g.length>0&&m.jsxs(Md,{value:f??"",onValueChange:O,children:[m.jsxs(Bd,{size:"sm",className:"w-auto min-w-[140px] h-8 shrink-0 [&>svg:last-child]:hidden",onClick:b0,children:[m.jsx(Fd,{placeholder:"Select connection"}),m.jsx(Ju,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),m.jsx(Ud,{children:g.map(g0)})]}),e[15]=g,e[16]=f,e[17]=M):M=e[17];let $;e[18]!==S||e[19]!==M?($=m.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:m.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[B,S,M]})}),e[18]=S,e[19]=M,e[20]=$):$=e[20];let X;e[21]!==b||e[22]!==D||e[23]!==n?.id?(X=b.length>0?b.map(J=>{const A=J.id===n?.id;return m.jsx("div",{onClick:()=>D(J.id),className:ae("rounded-lg mb-1",A&&"bg-accent"),children:m.jsx(c0,{model:J,onHover:u})},J.id)}):m.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No models found"}),e[21]=b,e[22]=D,e[23]=n?.id,e[24]=X):X=e[24];let q;e[25]!==X?(q=m.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2",children:X}),e[25]=X,e[26]=q):q=e[26];let U;e[27]!==$||e[28]!==q?(U=m.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[$,q]}),e[27]=$,e[28]=q,e[29]=U):U=e[29];let G;e[30]!==a||e[31]!==_||e[32]!==n?(G=a||(n?_.find(J=>J.id===n.id):null)||null,e[30]=a,e[31]=_,e[32]=n,e[33]=G):G=e[33];let V;e[34]!==G?(V=m.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:m.jsx(o0,{model:G})}),e[34]=G,e[35]=V):V=e[35];let K;return e[36]!==U||e[37]!==V?(K=m.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[U,V]}),e[36]=U,e[37]=V,e[38]=K):K=e[38],K}function g0(t){return m.jsx(Hd,{value:t.id,children:m.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?m.jsx("img",{src:t.icon,alt:t.title,className:"w-4 h-4 rounded"}):m.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:t.title.slice(0,1).toUpperCase()}),m.jsx("span",{children:t.title})]})},t.id)}function b0(t){return t.stopPropagation()}function E0(t){const e=Q.c(23),{selectedModel:n,onModelChange:r,modelsConnections:i,variant:s,className:a,placeholder:u}=t,l=s===void 0?"borderless":s,o=u===void 0?"Select model":u,[d,f]=j.useState(!1),p=bs(),h=i??p,g=n?.connectionId??null,_=Ts(g);let x;e[0]!==_||e[1]!==n?(x=n?_.find(M=>M.id===n.id):void 0,e[0]=_,e[1]=n,e[2]=x):x=e[2];const E=x;if(h.length===0)return null;const C=l==="borderless"?"ghost":"outline",b=l==="borderless"&&"md:border-none";let w;e[3]!==a||e[4]!==b?(w=ae("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",b,a),e[3]=a,e[4]=b,e[5]=w):w=e[5];let O;e[6]!==E||e[7]!==o?(O=m.jsx(f0,{model:E,placeholder:o}),e[6]=E,e[7]=o,e[8]=O):O=e[8];let I;e[9]!==C||e[10]!==w||e[11]!==O?(I=m.jsx(ar,{asChild:!0,children:m.jsx($e,{variant:C,size:"sm",className:w,children:O})}),e[9]=C,e[10]=w,e[11]=O,e[12]=I):I=e[12];let D;e[13]===Symbol.for("react.memo_cache_sentinel")?(D=m.jsx(h0,{}),e[13]=D):D=e[13];let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=()=>f(!1),e[14]=B):B=e[14];let P;e[15]!==h||e[16]!==r||e[17]!==n?(P=m.jsx(ur,{className:"w-full md:w-auto p-0",align:"start",side:"bottom",sideOffset:8,children:m.jsx(j.Suspense,{fallback:D,children:m.jsx(m0,{selectedModel:n,onModelChange:r,onClose:B,modelsConnections:h})})}),e[15]=h,e[16]=r,e[17]=n,e[18]=P):P=e[18];let S;return e[19]!==d||e[20]!==P||e[21]!==I?(S=m.jsxs(or,{open:d,onOpenChange:f,children:[I,P]}),e[19]=d,e[20]=P,e[21]=I,e[22]=S):S=e[22],S}const T0=t=>new Mo({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:n={}})=>{const{system:r,...i}=n,s=r?{id:crypto.randomUUID(),role:"system",parts:[{type:"text",text:r}]}:null;return{body:{messages:s?[s,...e]:e,stream:!0,...i}}}}),Ca=(t,e)=>t?.find(n=>n.id===e)??t?.[0]??null,x0=(t,e)=>{const n=Q.c(14);let r;n[0]!==t?(r=fs.chatSelectedModel(t),n[0]=t,n[1]=r):r=n[1];const[i,s]=vr(r,null),a=i?.connectionId;let u;n[2]!==e||n[3]!==a?(u=Ca(e,a),n[2]=e,n[3]=a,n[4]=u):u=n[4];const l=u,o=Ts(l?.id??null),d=i?.id;let f;n[5]!==o||n[6]!==d?(f=Ca(o,d),n[5]=o,n[6]=d,n[7]=f):f=n[7];const p=f;let h;n[8]!==l||n[9]!==p?(h=p&&l?.id?{id:p.id,provider:p.provider,limits:p.limits,connectionId:l.id}:null,n[8]=l,n[9]=p,n[10]=h):h=n[10];const g=h;let _;return n[11]!==g||n[12]!==s?(_=[g,s],n[11]=g,n[12]=s,n[13]=_):_=n[13],_},Wo={inputValue:"",branchContext:null,finishReason:null};function _0(t,e){switch(e.type){case"SET_INPUT":return{...t,inputValue:e.payload};case"START_BRANCH":return{...t,branchContext:e.payload};case"CLEAR_BRANCH":return{...t,branchContext:null};case"SET_FINISH_REASON":return{...t,finishReason:e.payload};case"CLEAR_FINISH_REASON":return{...t,finishReason:null};case"RESET":return Wo;default:return t}}const Go=j.createContext(null),Qo=()=>crypto.randomUUID();function y0(t){const e=Q.c(75),{children:n}=t,{locator:r,org:i}=zt(),{data:s}=qu.useSession(),a=s?.user??null,[u,l]=j.useReducer(_0,Wo),o=zo(),d=$o(),{threads:f}=jo(),[p,h]=vr(fs.threadManagerState(r)+":active-id",N0),g=Kh(p),_=Yo(),[x,E]=vr(`${r}:selected-gateway-id`,null),C=bs(),[b,w]=x0(r,C),O=Jh(x),I=e0();let D;e[0]!==p||e[1]!==f?(D=f.find(le=>le.id===p)??null,e[0]=p,e[1]=f,e[2]=D):D=e[2];const B=D;let P;e[3]!==_||e[4]!==x?(P=x?_.find(le=>le.id===x)??null:null,e[3]=_,e[4]=x,e[5]=P):P=e[5];const S=P;let M;e[6]!==i.slug?(M=T0(i.slug),e[6]=i.slug,e[7]=M):M=e[7];const $=M;let X;e[8]!==p||e[9]!==r||e[10]!==d||e[11]!==S?.id||e[12]!==o?(X=async le=>{const{finishReason:v,messages:Y,isAbort:Z,isDisconnect:ue,isError:me}=le;if(l({type:"SET_FINISH_REASON",payload:v??null}),v!=="stop"||Z||ue||me)return;const je=Y.slice(-2).filter(Boolean);if(je.length!==2){console.warn("[chat] Expected 2 messages, got",je.length);return}d.insertMany.mutate(je);const xt=je.find(C0)?.parts?.find(k0)?.text.slice(0,100)||"",at=await Xh(r,p);if(!at){const vt=new Date().toISOString(),Vt={id:p,title:xt,created_at:vt,updated_at:vt,hidden:!1,gatewayId:S?.id};o.insert.mutate(Vt);return}o.update.mutate({id:p,updates:{title:at.title||xt,gatewayId:at.gatewayId||S?.id,updated_at:new Date().toISOString()}})},e[8]=p,e[9]=r,e[10]=d,e[11]=S?.id,e[12]=o,e[13]=X):X=e[13];const q=X,U=A0;let G;e[14]!==p||e[15]!==q||e[16]!==I||e[17]!==g||e[18]!==$?(G={id:p,messages:g,transport:$,onFinish:q,onToolCall:I,onError:U},e[14]=p,e[15]=q,e[16]=I,e[17]=g,e[18]=$,e[19]=G):G=e[19];const V=Vh(G),K=V.status==="submitted"||V.status==="streaming",J=V.messages.length===0;let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=le=>l({type:"SET_INPUT",payload:le}),e[20]=A):A=e[20];const re=A;let he;e[21]===Symbol.for("react.memo_cache_sentinel")?(he=le=>l({type:"START_BRANCH",payload:le}),e[21]=he):he=e[21];const N=he;let Ee;e[22]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>l({type:"CLEAR_BRANCH"}),e[22]=Ee):Ee=e[22];const ve=Ee;let fe;e[23]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>l({type:"RESET"}),e[23]=fe):fe=e[23];const We=fe;let Ie;e[24]!==h||e[25]!==o?(Ie=le=>{const v=le?.id||crypto.randomUUID(),Y=new Date().toISOString(),Z={id:v,title:le?.title||"",created_at:le?.created_at||Y,updated_at:le?.updated_at||Y,hidden:le?.hidden??!1,gatewayId:le?.gatewayId};return o.insert.mutate(Z),h(v),Z},e[24]=h,e[25]=o,e[26]=Ie):Ie=e[26];const Ne=Ie;let ye;e[27]!==p||e[28]!==h||e[29]!==o?(ye=le=>{o.update.mutate({id:le,updates:{hidden:!0,updated_at:new Date().toISOString()}}),p===le&&h(Qo())},e[27]=p,e[28]=h,e[29]=o,e[30]=ye):ye=e[30];const Be=ye;let Re;e[31]!==E?(Re=le=>{E(le)},e[31]=E,e[32]=Re):Re=e[32];const De=Re;let Oe;e[33]!==w?(Oe=le=>{w({id:le.id,connectionId:le.connectionId})},e[33]=w,e[34]=Oe):Oe=e[34];const Fe=Oe;let Se;e[35]!==p||e[36]!==V||e[37]!==O||e[38]!==K||e[39]!==S?.id||e[40]!==b||e[41]!==a?.image||e[42]!==a?.name?(Se=async le=>{if(!b){Lr.error("No model configured");return}if(!le?.trim()||K)return;re(""),ve(),l({type:"CLEAR_FINISH_REASON"});const v={created_at:new Date().toISOString(),thread_id:p,system:O,model:{id:b.id,connectionId:b.connectionId,provider:b.provider??void 0,limits:b.limits??void 0},gateway:{id:S?.id??null},user:{avatar:a?.image??void 0,name:a?.name??"you"}};await V.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:le}],metadata:v},{metadata:v})},e[35]=p,e[36]=V,e[37]=O,e[38]=K,e[39]=S?.id,e[40]=b,e[41]=a?.image,e[42]=a?.name,e[43]=Se):Se=e[43];const Ue=Se;let Ge;e[44]!==V?(Ge=()=>V.stop(),e[44]=V,e[45]=Ge):Ge=e[45];const Tt=Ge;let Je;e[46]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>l({type:"CLEAR_FINISH_REASON"}),e[46]=Je):Je=e[46];const qt=Je;let it;e[47]!==B||e[48]!==p||e[49]!==V.clearError||e[50]!==V.error||e[51]!==V.messages||e[52]!==V.setMessages||e[53]!==V.status||e[54]!==u.branchContext||e[55]!==u.finishReason||e[56]!==u.inputValue||e[57]!==Ne||e[58]!==_||e[59]!==Be||e[60]!==J||e[61]!==K||e[62]!==C||e[63]!==S||e[64]!==b||e[65]!==Ue||e[66]!==h||e[67]!==De||e[68]!==Fe||e[69]!==Tt||e[70]!==f?(it={inputValue:u.inputValue,branchContext:u.branchContext,setInputValue:re,startBranch:N,clearBranch:ve,resetInteraction:We,activeThreadId:p,activeThread:B,threads:f,createThread:Ne,setActiveThreadId:h,hideThread:Be,gateways:_,selectedGateway:S,setGatewayId:De,modelsConnections:C,selectedModel:b,setSelectedModel:Fe,messages:V.messages,chatStatus:V.status,isStreaming:K,isChatEmpty:J,sendMessage:Ue,stopStreaming:Tt,setMessages:V.setMessages,chatError:V.error,clearChatError:V.clearError,finishReason:u.finishReason,clearFinishReason:qt},e[47]=B,e[48]=p,e[49]=V.clearError,e[50]=V.error,e[51]=V.messages,e[52]=V.setMessages,e[53]=V.status,e[54]=u.branchContext,e[55]=u.finishReason,e[56]=u.inputValue,e[57]=Ne,e[58]=_,e[59]=Be,e[60]=J,e[61]=K,e[62]=C,e[63]=S,e[64]=b,e[65]=Ue,e[66]=h,e[67]=De,e[68]=Fe,e[69]=Tt,e[70]=f,e[71]=it):it=e[71];const dt=it;let st;return e[72]!==n||e[73]!==dt?(st=m.jsx(Go.Provider,{value:dt,children:n}),e[72]=n,e[73]=dt,e[74]=st):st=e[74],st}function A0(t){console.error("[chat] Chat error:",t)}function k0(t){return t.type==="text"}function C0(t){return t.parts?.find(I0)}function I0(t){return t.type==="text"}function N0(t){return t||Qo()}function An(){const t=j.useContext(Go);if(!t)throw new Error("useChat must be used within a ChatProvider");return t}const S0={openrouter:t=>{const e=t?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function w0(t){if(!t?.providerMetadata)return null;for(const e of Object.values(S0)){const n=e(t.providerMetadata);if(n!==null)return n}return null}function R0(t){return t.reduce((e,n)=>{const r=n.metadata?.usage;return r?{inputTokens:e.inputTokens+(r.inputTokens??0),outputTokens:e.outputTokens+(r.outputTokens??0),totalTokens:e.totalTokens+(r.totalTokens??0),cost:e.cost+(w0(r)??0)}:e},{inputTokens:0,outputTokens:0,totalTokens:0,cost:0})}function Xo(t){const e=Q.c(38),{messages:n}=t;let r,i,s,a,u,l,o,d,f,p,h,g;if(e[0]!==n){g=Symbol.for("react.early_return_sentinel");e:{const w=R0(n);if(!w){g=null;break e}const{totalTokens:O,inputTokens:I,outputTokens:D,cost:B}=w;if(s=B,!O&&!I&&!D){g=null;break e}i=yn;let P;e[13]===Symbol.for("react.memo_cache_sentinel")?(P=m.jsx(eo,{size:12}),e[13]=P):P=e[13];const S=m.jsxs($e,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap shrink-0",children:[P,m.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:O.toLocaleString()})]});e[14]!==S?(h=m.jsx(_n,{asChild:!0,children:S}),e[14]=S,e[15]=h):h=e[15],r=xn,f="top",p="font-mono text-[11px]",u="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",e[16]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("span",{className:"text-muted",children:"in"}),e[16]=l):l=e[16],o=m.jsx("span",{children:I.toLocaleString()}),e[17]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("span",{className:"text-muted",children:"out"}),e[17]=d):d=e[17],a=D.toLocaleString()}e[0]=n,e[1]=r,e[2]=i,e[3]=s,e[4]=a,e[5]=u,e[6]=l,e[7]=o,e[8]=d,e[9]=f,e[10]=p,e[11]=h,e[12]=g}else r=e[1],i=e[2],s=e[3],a=e[4],u=e[5],l=e[6],o=e[7],d=e[8],f=e[9],p=e[10],h=e[11],g=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;let _;e[18]!==a?(_=m.jsx("span",{children:a}),e[18]=a,e[19]=_):_=e[19];let x;e[20]!==s?(x=s>0&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted",children:"cost"}),m.jsxs("span",{children:["$",s.toFixed(4)]})]}),e[20]=s,e[21]=x):x=e[21];let E;e[22]!==_||e[23]!==x||e[24]!==u||e[25]!==l||e[26]!==o||e[27]!==d?(E=m.jsxs("div",{className:u,children:[l,o,d,_,x]}),e[22]=_,e[23]=x,e[24]=u,e[25]=l,e[26]=o,e[27]=d,e[28]=E):E=e[28];let C;e[29]!==r||e[30]!==E||e[31]!==f||e[32]!==p?(C=m.jsx(r,{side:f,className:p,children:E}),e[29]=r,e[30]=E,e[31]=f,e[32]=p,e[33]=C):C=e[33];let b;return e[34]!==i||e[35]!==C||e[36]!==h?(b=m.jsxs(i,{children:[h,C]}),e[34]=i,e[35]=C,e[36]=h,e[37]=b):b=e[37],b}function O0({gatewayId:t,gateways:e,onGatewayChange:n,disabled:r=!1}){const[i,s]=j.useState(!1),a=j.useRef(null),u=Vu(),{org:l}=zt(),o=e.find(g=>g.id===t);if(!o)return null;j.useEffect(()=>{i&&setTimeout(()=>{a.current?.focus()},0)},[i]);const d=lo(t),f=g=>{g.stopPropagation(),n(null)},p=g=>{g.stopPropagation(),u({to:"/$org/gateways/$gatewayId",params:{org:l.slug,gatewayId:t}})},h=g=>{n(g),s(!1)};return m.jsxs("div",{className:ae("flex items-center justify-between px-3 py-1.5 rounded-t-xl",d?.bg),children:[m.jsxs(or,{open:i,onOpenChange:s,children:[m.jsx(ar,{asChild:!0,children:m.jsxs("button",{type:"button",disabled:r,className:ae("flex items-center gap-1.5 hover:opacity-80 transition-opacity",r?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[m.jsx(cs,{icon:o.icon,name:o.title,size:"2xs",fallbackIcon:o.fallbackIcon??m.jsx(ds,{size:10})}),m.jsx("span",{className:"text-xs text-white font-normal",children:o.title}),m.jsx(Id,{size:14,className:"text-white/50"})]})}),m.jsx(ur,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:m.jsx(qo,{gateways:e,selectedGatewayId:t,onGatewayChange:h,searchInputRef:a})})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("button",{type:"button",onClick:p,disabled:r,className:ae("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Edit gateway",children:m.jsx(Sd,{size:14,className:"text-white"})}),m.jsx("button",{type:"button",onClick:f,disabled:r,className:ae("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Reset to default",children:m.jsx(oo,{size:14,className:"text-white"})})]})]})}function L0(){const t=Q.c(120),{inputValue:e,setInputValue:n,branchContext:r,clearBranch:i,setActiveThreadId:s,gateways:a,selectedGateway:u,setGatewayId:l,modelsConnections:o,selectedModel:d,setSelectedModel:f,messages:p,isStreaming:h,sendMessage:g,stopStreaming:_,chatError:x,clearChatError:E,finishReason:C,clearFinishReason:b}=An();let w;t[0]!==e||t[1]!==h||t[2]!==d?(w=!h&&d&&e.trim().length>0,t[0]=e,t[1]=h,t[2]=d,t[3]=w):w=t[3];const O=w;let I;t[4]!==O||t[5]!==e||t[6]!==h||t[7]!==g||t[8]!==_?(I=Z=>{Z.preventDefault(),h?_():O&&g(e.trim())},t[4]=O,t[5]=e,t[6]=h,t[7]=g,t[8]=_,t[9]=I):I=t[9];const D=I;let B;t[10]!==O||t[11]!==e||t[12]!==g?(B=Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),O&&g(e.trim()))},t[10]=O,t[11]=e,t[12]=g,t[13]=B):B=t[13];const P=B;let S;t[14]!==r||t[15]!==i||t[16]!==s||t[17]!==n?(S=()=>{r&&(s(r.originalThreadId),i(),n(""))},t[14]=r,t[15]=i,t[16]=s,t[17]=n,t[18]=S):S=t[18];const M=S;let $;t[19]!==x||t[20]!==g?($=()=>{x&&g(`I encountered this error: ${x.message}. Can you help me fix it?`)},t[19]=x,t[20]=g,t[21]=$):$=t[21];const X=$;let q;t[22]!==g?(q=()=>{g("Please continue.")},t[22]=g,t[23]=q):q=t[23];const U=q;let G,V,K,J,A,re;if(t[24]!==r||t[25]!==x||t[26]!==i||t[27]!==E||t[28]!==b||t[29]!==C||t[30]!==U||t[31]!==X||t[32]!==M||t[33]!==u||t[34]!==d||t[35]!==n){const Z=u?lo(u.id):null;G=d?"Ask anything or @ for context":"Select a model to start chatting",J="flex flex-col gap-2 w-full min-h-42 justify-end",t[42]!==x||t[43]!==E||t[44]!==X?(A=x&&m.jsxs(vi,{variant:"danger",title:"Error occurred",description:x.message,icon:m.jsx(Wu,{size:16}),onDismiss:E,children:[m.jsx($e,{size:"sm",variant:"outline",onClick:X,className:"h-7 text-xs",children:"Fix in chat"}),m.jsx($e,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}),t[42]=x,t[43]=E,t[44]=X,t[45]=A):A=t[45],t[46]!==b||t[47]!==C||t[48]!==U?(re=C&&C!=="stop"&&m.jsx(vi,{variant:"warning",title:"Response incomplete",description:C==="length"?"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.":C==="content-filter"?"Response was filtered due to content policy.":C==="tool-calls"?"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working.":`Response stopped unexpectedly: ${C}`,icon:m.jsx(Ad,{size:16}),onDismiss:b,children:m.jsx($e,{size:"sm",variant:"outline",onClick:U,className:"h-7 text-xs",children:"Continue"})}),t[46]=b,t[47]=C,t[48]=U,t[49]=re):re=t[49],t[50]!==r||t[51]!==i||t[52]!==M||t[53]!==n?(V=r&&m.jsx(vi,{variant:"default",title:"Editing message (click to view original)",description:r.originalMessageText,icon:m.jsx(to,{size:14}),onDismiss:()=>{i(),n("")},children:m.jsx($e,{size:"sm",variant:"outline",onClick:M,className:"h-7 text-xs",children:"View original"})}),t[50]=r,t[51]=i,t[52]=M,t[53]=n,t[54]=V):V=t[54],K=ae("relative rounded-xl w-full flex flex-col",u&&"shadow-sm",Z?.bg),t[24]=r,t[25]=x,t[26]=i,t[27]=E,t[28]=b,t[29]=C,t[30]=U,t[31]=X,t[32]=M,t[33]=u,t[34]=d,t[35]=n,t[36]=G,t[37]=V,t[38]=K,t[39]=J,t[40]=A,t[41]=re}else G=t[36],V=t[37],K=t[38],J=t[39],A=t[40],re=t[41];let he;t[55]!==a||t[56]!==h||t[57]!==u||t[58]!==l?(he=u&&m.jsx(O0,{gatewayId:u.id,gateways:a,onGatewayChange:l,disabled:h}),t[55]=a,t[56]=h,t[57]=u,t[58]=l,t[59]=he):he=t[59];const N=!u&&"shadow-sm";let Ee;t[60]!==N?(Ee=ae("w-full relative rounded-xl min-h-[130px] flex flex-col border border-border bg-background",N),t[60]=N,t[61]=Ee):Ee=t[61];let ve;t[62]===Symbol.for("react.memo_cache_sentinel")?(ve={maxHeight:"164px"},t[62]=ve):ve=t[62];let fe;t[63]!==n?(fe=Z=>n(Z.target.value),t[63]=n,t[64]=fe):fe=t[64];const We=!d||h;let Ie;t[65]===Symbol.for("react.memo_cache_sentinel")?(Ie=ae("placeholder:text-muted-foreground resize-none focus-visible:ring-0 border-0 p-2 text-[15px]! min-h-[20px] w-full","rounded-none shadow-none","min-h-[20px] h-auto overflow-hidden"),t[65]=Ie):Ie=t[65];let Ne;t[66]!==P||t[67]!==e||t[68]!==G||t[69]!==fe||t[70]!==We?(Ne=m.jsx("div",{className:"relative flex flex-col gap-2 p-2.5 flex-1",children:m.jsx("div",{className:"overflow-y-auto relative flex-1",style:ve,children:m.jsx(yd,{rows:1,value:e,onChange:fe,onKeyDown:P,placeholder:G,disabled:We,className:Ie})})}),t[66]=P,t[67]=e,t[68]=G,t[69]=fe,t[70]=We,t[71]=Ne):Ne=t[71];let ye;t[72]!==a||t[73]!==h||t[74]!==u||t[75]!==l?(ye=!u&&m.jsx(n0,{selectedGatewayId:null,onGatewayChange:l,gateways:a,placeholder:"Agent",disabled:h}),t[72]=a,t[73]=h,t[74]=u,t[75]=l,t[76]=ye):ye=t[76];const Be=d??void 0;let Re;t[77]!==o||t[78]!==f||t[79]!==Be?(Re=m.jsx(E0,{selectedModel:Be,onModelChange:f,modelsConnections:o,placeholder:"Model",variant:"borderless"}),t[77]=o,t[78]=f,t[79]=Be,t[80]=Re):Re=t[80];let De;t[81]!==p?(De=m.jsx(Xo,{messages:p}),t[81]=p,t[82]=De):De=t[82];let Oe;t[83]!==ye||t[84]!==Re||t[85]!==De?(Oe=m.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[ye,Re,De]}),t[83]=ye,t[84]=Re,t[85]=De,t[86]=Oe):Oe=t[86];const Fe=h?"button":"submit";let Se;t[87]!==h||t[88]!==_?(Se=Z=>{h&&(Z.preventDefault(),Z.stopPropagation(),_())},t[87]=h,t[88]=_,t[89]=Se):Se=t[89];const Ue=O||h?"default":"ghost",Ge=!O&&!h,Tt=!O&&!h&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let Je;t[90]!==Tt?(Je=ae("size-8 rounded-full transition-all",Tt),t[90]=Tt,t[91]=Je):Je=t[91];const qt=h?"Stop generating":"Send message (Enter)";let it;t[92]!==h?(it=h?m.jsx(ao,{size:20}):m.jsx(Cd,{size:20}),t[92]=h,t[93]=it):it=t[93];let dt;t[94]!==Fe||t[95]!==Se||t[96]!==Ue||t[97]!==Ge||t[98]!==Je||t[99]!==qt||t[100]!==it?(dt=m.jsx("div",{className:"flex items-center gap-1",children:m.jsx($e,{type:Fe,onClick:Se,variant:Ue,size:"icon",disabled:Ge,className:Je,title:qt,children:it})}),t[94]=Fe,t[95]=Se,t[96]=Ue,t[97]=Ge,t[98]=Je,t[99]=qt,t[100]=it,t[101]=dt):dt=t[101];let st;t[102]!==Oe||t[103]!==dt?(st=m.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[Oe,dt]}),t[102]=Oe,t[103]=dt,t[104]=st):st=t[104];let le;t[105]!==D||t[106]!==Ee||t[107]!==Ne||t[108]!==st?(le=m.jsx("div",{className:"p-0.5",children:m.jsxs("form",{onSubmit:D,className:Ee,children:[Ne,st]})}),t[105]=D,t[106]=Ee,t[107]=Ne,t[108]=st,t[109]=le):le=t[109];let v;t[110]!==he||t[111]!==le||t[112]!==K?(v=m.jsxs("div",{className:K,children:[he,le]}),t[110]=he,t[111]=le,t[112]=K,t[113]=v):v=t[113];let Y;return t[114]!==V||t[115]!==v||t[116]!==J||t[117]!==A||t[118]!==re?(Y=m.jsxs("div",{className:J,children:[A,re,V,v]}),t[114]=V,t[115]=v,t[116]=J,t[117]=A,t[118]=re,t[119]=Y):Y=t[119],Y}async function v0(t){const e=`/mcp/gateway/${t}`,n={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const r=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{prompts:{}},clientInfo:{name:"mesh-chat",version:"1.0.0"}}})});if(!r.ok)return[];const i=await r.json();if(i.error)return[];const{capabilities:s}=i.result;if(!s?.prompts)return[];const a=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!a.ok)return[];const u=await a.json();return u.error?[]:u.result?.prompts||[]}catch{return[]}}function D0(t){const e=Q.c(7);let n;e[0]!==t?(n=He.gatewayPrompts(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t?(r=()=>v0(t),e[2]=t,e[3]=r):r=e[3];let i;return e[4]!==n||e[5]!==r?(i={queryKey:n,queryFn:r,staleTime:6e4,retry:!1},e[4]=n,e[5]=r,e[6]=i):i=e[6],us(i)}const Ia=3;function P0(t){const e=Q.c(14),{prompt:n,onSelect:r}=t,i=n.description??n.name;let s;e[0]!==r||e[1]!==n?(s=()=>r(n),e[0]=r,e[1]=n,e[2]=s):s=e[2];const a=n.title??n.name;let u;if(e[3]!==a){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=/_/g,e[5]=f):f=e[5],u=a.replace(f," "),e[3]=a,e[4]=u}else u=e[4];let l;e[6]!==s||e[7]!==u?(l=m.jsx(_n,{asChild:!0,children:m.jsx("button",{type:"button",onClick:s,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:u})}),e[6]=s,e[7]=u,e[8]=l):l=e[8];let o;e[9]!==i?(o=m.jsx(xn,{side:"bottom",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:i})}),e[9]=i,e[10]=o):o=e[10];let d;return e[11]!==l||e[12]!==o?(d=m.jsxs(yn,{children:[l,o]}),e[11]=l,e[12]=o,e[13]=d):d=e[13],d}function M0(t){const e=Q.c(20),{prompts:n,onSelect:r,className:i}=t;if(n.length===0)return null;let s,a,u,l,o;if(e[0]!==i||e[1]!==r||e[2]!==n){const p=n.slice(0,Ia),h=n.slice(Ia),g=h.length>0;s=hs,o=300,e[8]!==i?(a=ae("flex flex-wrap items-center justify-center gap-2",i),e[8]=i,e[9]=a):a=e[9];let _;e[10]!==r?(_=x=>m.jsx(P0,{prompt:x,onSelect:r},x.name),e[10]=r,e[11]=_):_=e[11],u=p.map(_),l=g&&m.jsxs(or,{children:[m.jsx(ar,{asChild:!0,children:m.jsxs("button",{type:"button",className:"size-7 flex items-center justify-center text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:["+",h.length]})}),m.jsx(ur,{side:"bottom",align:"center",className:"w-auto p-2",children:m.jsx("div",{className:"flex flex-col gap-1",children:h.map(x=>{const E=x.description??x.name;return m.jsxs(yn,{children:[m.jsx(_n,{asChild:!0,children:m.jsx("button",{type:"button",onClick:()=>r(x),className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors cursor-pointer text-left",children:(x.title??x.name).replace(/_/g," ")})}),m.jsx(xn,{side:"right",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:E})})]},x.name)})})})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=s,e[4]=a,e[5]=u,e[6]=l,e[7]=o}else s=e[3],a=e[4],u=e[5],l=e[6],o=e[7];let d;e[12]!==a||e[13]!==u||e[14]!==l?(d=m.jsxs("div",{className:a,children:[u,l]}),e[12]=a,e[13]=u,e[14]=l,e[15]=d):d=e[15];let f;return e[16]!==s||e[17]!==o||e[18]!==d?(f=m.jsx(s,{delayDuration:o,children:d}),e[16]=s,e[17]=o,e[18]=d,e[19]=f):f=e[19],f}function B0(){const t=Q.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsxs(m.Fragment,{children:[m.jsx(ze,{className:"h-6 w-20 rounded-full border border-border"}),m.jsx(ze,{className:"h-6 w-24 rounded-full border border-border"})]}),t[0]=e):e=t[0],e}function F0(t){const e=Q.c(8),{className:n}=t,{selectedGateway:r}=An();let i;e[0]!==n?(i=ae("flex flex-wrap items-center justify-center gap-2",n),e[0]=n,e[1]=i):i=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={minHeight:"32px"},e[2]=s):s=e[2];let a;e[3]!==r?(a=r&&m.jsx(kd,{fallback:null,children:m.jsx(j.Suspense,{fallback:m.jsx(B0,{}),children:m.jsx(U0,{gatewayId:r.id})})},r.id),e[3]=r,e[4]=a):a=e[4];let u;return e[5]!==i||e[6]!==a?(u=m.jsx("div",{className:i,style:s,children:a}),e[5]=i,e[6]=a,e[7]=u):u=e[7],u}function U0(t){const e=Q.c(5),{gatewayId:n}=t,{sendMessage:r}=An(),{data:i}=D0(n);if(i.length===0)return null;let s;e[0]!==r?(s=u=>r(u.description??u.name),e[0]=r,e[1]=s):s=e[1];let a;return e[2]!==i||e[3]!==s?(a=m.jsx(M0,{prompts:i,onSelect:s}),e[2]=i,e[3]=s,e[4]=a):a=e[4],a}function H0(){const t=Q.c(3),[e,n]=j.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async a=>{await navigator.clipboard.writeText(a),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let s;return t[1]!==e?(s={handleCopy:i,copied:e},t[1]=e,t[2]=s):s=t[2],s}function xs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var rn=xs();function Zo(t){rn=t}var zn={exec:()=>null};function pe(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,s)=>{let a=typeof s=="string"?s:s.source;return a=a.replace(Ke.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var Ke={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},j0=/^(?:[ \t]*(?:\n|$))+/,z0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,$0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,dr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Y0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_s=/(?:[*+-]|\d{1,9}[.)])/,Ko=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Jo=pe(Ko).replace(/bull/g,_s).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),q0=pe(Ko).replace(/bull/g,_s).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ys=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,V0=/^[^\n]+/,As=/(?!\s*\])(?:\\.|[^\[\]\\])+/,W0=pe(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",As).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),G0=pe(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_s).getRegex(),Qr="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ks=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Q0=pe("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ks).replace("tag",Qr).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),el=pe(ys).replace("hr",dr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qr).getRegex(),X0=pe(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",el).getRegex(),Cs={blockquote:X0,code:z0,def:W0,fences:$0,heading:Y0,hr:dr,html:Q0,lheading:Jo,list:G0,newline:j0,paragraph:el,table:zn,text:V0},Na=pe("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",dr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qr).getRegex(),Z0={...Cs,lheading:q0,table:Na,paragraph:pe(ys).replace("hr",dr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Na).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qr).getRegex()},K0={...Cs,html:pe(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ks).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:pe(ys).replace("hr",dr).replace("heading",` *#{1,6} *[^
22
22
  ]`).replace("lheading",Jo).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},J0=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ep=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,tl=/^( {2,}|\\)\n(?!\s*$)/,tp=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Xr=/[\p{P}\p{S}]/u,Is=/[\s\p{P}\p{S}]/u,nl=/[^\s\p{P}\p{S}]/u,np=pe(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Is).getRegex(),rl=/(?!~)[\p{P}\p{S}]/u,rp=/(?!~)[\s\p{P}\p{S}]/u,ip=/(?:[^\s\p{P}\p{S}]|~)/u,sp=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,il=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ap=pe(il,"u").replace(/punct/g,Xr).getRegex(),up=pe(il,"u").replace(/punct/g,rl).getRegex(),sl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",op=pe(sl,"gu").replace(/notPunctSpace/g,nl).replace(/punctSpace/g,Is).replace(/punct/g,Xr).getRegex(),lp=pe(sl,"gu").replace(/notPunctSpace/g,ip).replace(/punctSpace/g,rp).replace(/punct/g,rl).getRegex(),cp=pe("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,nl).replace(/punctSpace/g,Is).replace(/punct/g,Xr).getRegex(),dp=pe(/\\(punct)/,"gu").replace(/punct/g,Xr).getRegex(),fp=pe(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),hp=pe(ks).replace("(?:-->|$)","-->").getRegex(),pp=pe("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",hp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Pr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,mp=pe(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Pr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),al=pe(/^!?\[(label)\]\[(ref)\]/).replace("label",Pr).replace("ref",As).getRegex(),ul=pe(/^!?\[(ref)\](?:\[\])?/).replace("ref",As).getRegex(),gp=pe("reflink|nolink(?!\\()","g").replace("reflink",al).replace("nolink",ul).getRegex(),Ns={_backpedal:zn,anyPunctuation:dp,autolink:fp,blockSkip:sp,br:tl,code:ep,del:zn,emStrongLDelim:ap,emStrongRDelimAst:op,emStrongRDelimUnd:cp,escape:J0,link:mp,nolink:ul,punctuation:np,reflink:al,reflinkSearch:gp,tag:pp,text:tp,url:zn},bp={...Ns,link:pe(/^!?\[(label)\]\((.*?)\)/).replace("label",Pr).getRegex(),reflink:pe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Pr).getRegex()},zi={...Ns,emStrongRDelimAst:lp,emStrongLDelim:up,url:pe(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ep={...zi,br:pe(tl).replace("{2,}","*").getRegex(),text:pe(zi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Er={normal:Cs,gfm:Z0,pedantic:K0},wn={normal:Ns,gfm:zi,breaks:Ep,pedantic:bp},Tp={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Sa=t=>Tp[t];function yt(t,e){if(e){if(Ke.escapeTest.test(t))return t.replace(Ke.escapeReplace,Sa)}else if(Ke.escapeTestNoEncode.test(t))return t.replace(Ke.escapeReplaceNoEncode,Sa);return t}function wa(t){try{t=encodeURI(t).replace(Ke.percentDecode,"%")}catch{return null}return t}function Ra(t,e){const n=t.replace(Ke.findPipe,(s,a,u)=>{let l=!1,o=a;for(;--o>=0&&u[o]==="\\";)l=!l;return l?"|":" |"}),r=n.split(Ke.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ke.slashPipe,"|");return r}function Rn(t,e,n){const r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function xp(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Oa(t,e,n,r,i){const s=e.href,a=e.title||null,u=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;const l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:a,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,l}function _p(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
23
23
  `).map(s=>{const a=s.match(n.other.beginningSpace);if(a===null)return s;const[u]=a;return u.length>=i.length?s.slice(i.length):s}).join(`
24
24
  `)}var Mr=class{options;rules;lexer;constructor(t){this.options=t||rn}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Rn(n,`
@@ -102,6 +102,6 @@ Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An err
102
102
  `))+1))}const a="#".repeat(i),u=n.enter("headingAtx"),l=n.enter("phrasing");s.move(a+" ");let o=n.containerPhrasing(t,{before:"# ",after:`
103
103
  `,...s.current()});return/^[\t ]/.test(o)&&(o=ir(o.charCodeAt(0))+o.slice(1)),o=o?a+" "+o:a,n.options.closeAtx&&(o+=" "+a),l(),u(),o}Oc.peek=$x;function Oc(t){return t.value||""}function $x(){return"<"}Lc.peek=Yx;function Lc(t,e,n,r){const i=Ws(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let u=n.enter("label");const l=n.createTracker(r);let o=l.move("![");return o+=l.move(n.safe(t.alt,{before:o,after:"]",...l.current()})),o+=l.move("]("),u(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(u=n.enter("destinationLiteral"),o+=l.move("<"),o+=l.move(n.safe(t.url,{before:o,after:">",...l.current()})),o+=l.move(">")):(u=n.enter("destinationRaw"),o+=l.move(n.safe(t.url,{before:o,after:t.title?" ":")",...l.current()}))),u(),t.title&&(u=n.enter(`title${s}`),o+=l.move(" "+i),o+=l.move(n.safe(t.title,{before:o,after:i,...l.current()})),o+=l.move(i),u()),o+=l.move(")"),a(),o}function Yx(){return"!"}vc.peek=qx;function vc(t,e,n,r){const i=t.referenceType,s=n.enter("imageReference");let a=n.enter("label");const u=n.createTracker(r);let l=u.move("![");const o=n.safe(t.alt,{before:l,after:"]",...u.current()});l+=u.move(o+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(t),{before:l,after:"]",...u.current()});return a(),n.stack=d,s(),i==="full"||!o||o!==f?l+=u.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=u.move("]"),l}function qx(){return"!"}Dc.peek=Vx;function Dc(t,e,n){let r=t.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],u=n.compilePattern(a);let l;if(a.atBreak)for(;l=u.exec(r);){let o=l.index;r.charCodeAt(o)===10&&r.charCodeAt(o-1)===13&&o--,r=r.slice(0,o)+" "+r.slice(l.index+1)}}return i+r+i}function Vx(){return"`"}function Pc(t,e){const n=vs(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Mc.peek=Wx;function Mc(t,e,n,r){const i=Ws(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let u,l;if(Pc(t,n)){const d=n.stack;n.stack=[],u=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(t,{before:f,after:">",...a.current()})),f+=a.move(">"),u(),n.stack=d,f}u=n.enter("link"),l=n.enter("label");let o=a.move("[");return o+=a.move(n.containerPhrasing(t,{before:o,after:"](",...a.current()})),o+=a.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),o+=a.move("<"),o+=a.move(n.safe(t.url,{before:o,after:">",...a.current()})),o+=a.move(">")):(l=n.enter("destinationRaw"),o+=a.move(n.safe(t.url,{before:o,after:t.title?" ":")",...a.current()}))),l(),t.title&&(l=n.enter(`title${s}`),o+=a.move(" "+i),o+=a.move(n.safe(t.title,{before:o,after:i,...a.current()})),o+=a.move(i),l()),o+=a.move(")"),u(),o}function Wx(t,e,n){return Pc(t,n)?"<":"["}Bc.peek=Gx;function Bc(t,e,n,r){const i=t.referenceType,s=n.enter("linkReference");let a=n.enter("label");const u=n.createTracker(r);let l=u.move("[");const o=n.containerPhrasing(t,{before:l,after:"]",...u.current()});l+=u.move(o+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(t),{before:l,after:"]",...u.current()});return a(),n.stack=d,s(),i==="full"||!o||o!==f?l+=u.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=u.move("]"),l}function Gx(){return"["}function Gs(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Qx(t){const e=Gs(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Xx(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Fc(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Zx(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=t.ordered?Xx(n):Gs(n);const u=t.ordered?a==="."?")":".":Qx(n);let l=e&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!t.ordered){const d=t.children?t.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Fc(n)===a&&d){let f=-1;for(;++f<t.children.length;){const p=t.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=u),n.bulletCurrent=a;const o=n.containerFlow(t,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),o}function Kx(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Jx(t,e,n,r){const i=Kx(n);let s=n.bulletCurrent||Gs(n);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(a=Math.ceil(a/4)*4);const u=n.createTracker(r);u.move(s+" ".repeat(a-s.length)),u.shift(a);const l=n.enter("listItem"),o=n.indentLines(n.containerFlow(t,u.current()),d);return l(),o;function d(f,p,h){return p?(h?"":" ".repeat(a))+f:(h?s:s+" ".repeat(a-s.length))+f}}function e3(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(t,r);return s(),i(),a}const t3=ni(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function n3(t,e,n,r){return(t.children.some(function(a){return t3(a)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function r3(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Uc.peek=i3;function Uc(t,e,n,r){const i=r3(n),s=n.enter("strong"),a=n.createTracker(r),u=a.move(i+i);let l=a.move(n.containerPhrasing(t,{after:i,before:u,...a.current()}));const o=l.charCodeAt(0),d=$r(r.before.charCodeAt(r.before.length-1),o,i);d.inside&&(l=ir(o)+l.slice(1));const f=l.charCodeAt(l.length-1),p=$r(r.after.charCodeAt(0),f,i);p.inside&&(l=l.slice(0,-1)+ir(f));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},u+l+h}function i3(t,e,n){return n.options.strong||"*"}function s3(t,e,n,r){return n.safe(t.value,r)}function a3(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function u3(t,e,n){const r=(Fc(n)+(n.options.ruleSpaces?" ":"")).repeat(a3(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Hc={blockquote:Rx,break:Bu,code:Mx,definition:Fx,emphasis:Rc,hardBreak:Bu,heading:zx,html:Oc,image:Lc,imageReference:vc,inlineCode:Dc,link:Mc,linkReference:Bc,list:Zx,listItem:Jx,paragraph:e3,root:n3,strong:Uc,text:s3,thematicBreak:u3};function o3(){return{enter:{table:l3,tableData:Fu,tableHeader:Fu,tableRow:d3},exit:{codeText:f3,table:c3,tableData:Li,tableHeader:Li,tableRow:Li}}}function l3(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function c3(t){this.exit(t),this.data.inTable=void 0}function d3(t){this.enter({type:"tableRow",children:[]},t)}function Li(t){this.exit(t)}function Fu(t){this.enter({type:"tableCell",children:[]},t)}function f3(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,h3));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function h3(t,e){return e==="|"?e:t}function p3(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
104
104
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:l,tableRow:u}};function a(h,g,_,x){return o(d(h,_,x),h.align)}function u(h,g,_,x){const E=f(h,_,x),C=o([E]);return C.slice(0,C.indexOf(`
105
- `))}function l(h,g,_,x){const E=_.enter("tableCell"),C=_.enter("phrasing"),b=_.containerPhrasing(h,{...x,before:s,after:s});return C(),E(),b}function o(h,g){return Sx(h,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function d(h,g,_){const x=h.children;let E=-1;const C=[],b=g.enter("table");for(;++E<x.length;)C[E]=f(x[E],g,_);return b(),C}function f(h,g,_){const x=h.children;let E=-1;const C=[],b=g.enter("tableRow");for(;++E<x.length;)C[E]=l(x[E],h,g,_);return b(),C}function p(h,g,_){let x=Hc.inlineCode(h,g,_);return _.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function m3(){return{exit:{taskListCheckValueChecked:Uu,taskListCheckValueUnchecked:Uu,paragraph:b3}}}function g3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:E3}}}function Uu(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function b3(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,a;for(;++s<i.length;){const u=i[s];if(u.type==="paragraph"){a=u;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function E3(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",u=n.createTracker(r);s&&u.move(a);let l=Hc.listItem(t,e,n,{...r,...u.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,o)),l;function o(d){return d+a}}function T3(){return[ZT(),Ex(),yx(),o3(),m3()]}function x3(t){return{extensions:[KT(),Tx(t),Ax(),p3(t),g3()]}}const _3={tokenize:N3,partial:!0},jc={tokenize:S3,partial:!0},zc={tokenize:w3,partial:!0},$c={tokenize:R3,partial:!0},y3={tokenize:O3,partial:!0},Yc={name:"wwwAutolink",tokenize:C3,previous:Vc},qc={name:"protocolAutolink",tokenize:I3,previous:Wc},Lt={name:"emailAutolink",tokenize:k3,previous:Gc},Nt={};function A3(){return{text:Nt}}let Gt=48;for(;Gt<123;)Nt[Gt]=Lt,Gt++,Gt===58?Gt=65:Gt===91&&(Gt=97);Nt[43]=Lt;Nt[45]=Lt;Nt[46]=Lt;Nt[95]=Lt;Nt[72]=[Lt,qc];Nt[104]=[Lt,qc];Nt[87]=[Lt,Yc];Nt[119]=[Lt,Yc];function k3(t,e,n){const r=this;let i,s;return a;function a(f){return!ss(f)||!Gc.call(r,r.previous)||Qs(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),u(f))}function u(f){return ss(f)?(t.consume(f),u):f===64?(t.consume(f),l):n(f)}function l(f){return f===46?t.check(y3,d,o)(f):f===45||f===95||Ye(f)?(s=!0,t.consume(f),l):d(f)}function o(f){return t.consume(f),i=!0,l}function d(f){return s&&i&&Ze(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function C3(t,e,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Vc.call(r,r.previous)||Qs(r.events)?n(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(_3,t.attempt(jc,t.attempt(zc,s),n),n)(a))}function s(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function I3(t,e,n){const r=this;let i="",s=!1;return a;function a(f){return(f===72||f===104)&&Wc.call(r,r.previous)&&!Qs(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),u):n(f)}function u(f){if(Ze(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),u;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(f),l}return n(f)}function l(f){return f===47?(t.consume(f),s?o:(s=!0,l)):n(f)}function o(f){return f===null||Fr(f)||xe(f)||nn(f)||Jr(f)?n(f):t.attempt(jc,t.attempt(zc,d),n)(f)}function d(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function N3(t,e,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,t.consume(a),i):a===46&&r===3?(t.consume(a),s):n(a)}function s(a){return a===null?n(a):e(a)}}function S3(t,e,n){let r,i,s;return a;function a(o){return o===46||o===95?t.check($c,l,u)(o):o===null||xe(o)||nn(o)||o!==45&&Jr(o)?l(o):(s=!0,t.consume(o),a)}function u(o){return o===95?r=!0:(i=r,r=void 0),t.consume(o),a}function l(o){return i||r||!s?n(o):e(o)}}function w3(t,e){let n=0,r=0;return i;function i(a){return a===40?(n++,t.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check($c,e,s)(a):a===null||xe(a)||nn(a)?e(a):(t.consume(a),i)}function s(a){return a===41&&r++,t.consume(a),i}}function R3(t,e,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(t.consume(u),r):u===38?(t.consume(u),s):u===93?(t.consume(u),i):u===60||u===null||xe(u)||nn(u)?e(u):n(u)}function i(u){return u===null||u===40||u===91||xe(u)||nn(u)?e(u):r(u)}function s(u){return Ze(u)?a(u):n(u)}function a(u){return u===59?(t.consume(u),r):Ze(u)?(t.consume(u),a):n(u)}}function O3(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return Ye(s)?n(s):e(s)}}function Vc(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||xe(t)}function Wc(t){return!Ze(t)}function Gc(t){return!(t===47||ss(t))}function ss(t){return t===43||t===45||t===46||t===95||Ye(t)}function Qs(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const L3={tokenize:H3,partial:!0};function v3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:B3,continuation:{tokenize:F3},exit:U3}},text:{91:{name:"gfmFootnoteCall",tokenize:M3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:D3,resolveTo:P3}}}}function D3(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return u;function u(l){if(!a||!a._balanced)return n(l);const o=bt(r.sliceSerialize({start:a.end,end:r.now()}));return o.codePointAt(0)!==94||!s.includes(o.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function P3(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},u=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",a,e],["exit",a,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...u),t}function M3(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return u;function u(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",o)}function o(f){if(s>999||f===93&&!a||f===null||f===91||xe(f))return n(f);if(f===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(bt(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return xe(f)||(a=!0),s++,t.consume(f),f===92?d:o}function d(f){return f===91||f===92||f===93?(t.consume(f),s++,o):o(f)}}function B3(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,u;return l;function l(g){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),o}function o(g){return g===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):n(g)}function d(g){if(a>999||g===93&&!u||g===null||g===91||xe(g))return n(g);if(g===93){t.exit("chunkString");const _=t.exit("gfmFootnoteDefinitionLabelString");return s=bt(r.sliceSerialize(_)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return xe(g)||(u=!0),a++,t.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(t.consume(g),a++,d):d(g)}function p(g){return g===58?(t.enter("definitionMarker"),t.consume(g),t.exit("definitionMarker"),i.includes(s)||i.push(s),de(t,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return e(g)}}function F3(t,e,n){return t.check(pr,e,t.attempt(L3,e,n))}function U3(t){t.exit("gfmFootnoteDefinition")}function H3(t,e,n){const r=this;return de(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(s):n(s)}}function j3(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,u){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let o=l;for(;o--;)if(a[o][0]==="exit"&&a[o][1].type==="strikethroughSequenceTemporary"&&a[o][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[o][1].end.offset-a[o][1].start.offset){a[l][1].type="strikethroughSequence",a[o][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},a[o][1].start),end:Object.assign({},a[l][1].end)},f={type:"strikethroughText",start:Object.assign({},a[o][1].end),end:Object.assign({},a[l][1].start)},p=[["enter",d,u],["enter",a[o][1],u],["exit",a[o][1],u],["enter",f,u]],h=u.parser.constructs.insideSpan.null;h&&lt(p,p.length,0,ei(h,a.slice(o+1,l),u)),lt(p,p.length,0,[["exit",f,u],["enter",a[l][1],u],["exit",a[l][1],u],["exit",d,u]]),lt(a,o-1,l-o+3,p),l=o+p.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,u,l){const o=this.previous,d=this.events;let f=0;return p;function p(g){return o===126&&d[d.length-1][1].type!=="characterEscape"?l(g):(a.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const _=bn(o);if(g===126)return f>1?l(g):(a.consume(g),f++,h);if(f<2&&!n)return l(g);const x=a.exit("strikethroughSequenceTemporary"),E=bn(g);return x._open=!E||E===2&&!!_,x._close=!_||_===2&&!!E,u(g)}}}class z3{constructor(){this.map=[]}add(e,n,r){$3(this,e,n,r)}consume(e){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function $3(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function Y3(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function q3(){return{flow:{null:{name:"table",tokenize:V3,resolveAll:W3}}}}function V3(t,e,n){const r=this;let i=0,s=0,a;return u;function u(S){let M=r.events.length-1;for(;M>-1;){const q=r.events[M][1].type;if(q==="lineEnding"||q==="linePrefix")M--;else break}const $=M>-1?r.events[M][1].type:null,X=$==="tableHead"||$==="tableRow"?I:l;return X===I&&r.parser.lazy[r.now().line]?n(S):X(S)}function l(S){return t.enter("tableHead"),t.enter("tableRow"),o(S)}function o(S){return S===124||(a=!0,s+=1),d(S)}function d(S){return S===null?n(S):ee(S)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),h):n(S):oe(S)?de(t,d,"whitespace")(S):(s+=1,a&&(a=!1,i+=1),S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),a=!0,d):(t.enter("data"),f(S)))}function f(S){return S===null||S===124||xe(S)?(t.exit("data"),d(S)):(t.consume(S),S===92?p:f)}function p(S){return S===92||S===124?(t.consume(S),f):f(S)}function h(S){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(S):(t.enter("tableDelimiterRow"),a=!1,oe(S)?de(t,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):g(S))}function g(S){return S===45||S===58?x(S):S===124?(a=!0,t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),_):O(S)}function _(S){return oe(S)?de(t,x,"whitespace")(S):x(S)}function x(S){return S===58?(s+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),E):S===45?(s+=1,E(S)):S===null||ee(S)?w(S):O(S)}function E(S){return S===45?(t.enter("tableDelimiterFiller"),C(S)):O(S)}function C(S){return S===45?(t.consume(S),C):S===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(S))}function b(S){return oe(S)?de(t,w,"whitespace")(S):w(S)}function w(S){return S===124?g(S):S===null||ee(S)?!a||i!==s?O(S):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(S)):O(S)}function O(S){return n(S)}function I(S){return t.enter("tableRow"),D(S)}function D(S){return S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),D):S===null||ee(S)?(t.exit("tableRow"),e(S)):oe(S)?de(t,D,"whitespace")(S):(t.enter("data"),B(S))}function B(S){return S===null||S===124||xe(S)?(t.exit("data"),D(S)):(t.consume(S),S===92?P:B)}function P(S){return S===92||S===124?(t.consume(S),B):B(S)}}function W3(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],u=!1,l=0,o,d,f;const p=new z3;for(;++n<t.length;){const h=t[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(u=!1,l!==0&&(Hu(p,e,l,o,d),d=void 0,l=0),o={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",o,e]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],a=[0,n+1,0,0],u&&(u=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,e]])),i=g.type==="tableDelimiterRow"?2:d?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],f=Ar(p,e,s,i,void 0,f),s=[0,0,0,0]),a[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],f=Ar(p,e,s,i,void 0,f)),s=a,a=[s[1],n,0,0])):g.type==="tableHead"?(u=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],f=Ar(p,e,s,i,n,f)):a[1]!==0&&(f=Ar(p,e,a,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&Hu(p,e,l,o,d),p.consume(e.events),n=-1;++n<e.events.length;){const h=e.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Y3(e.events,n))}return t}function Ar(t,e,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(s.end=Object.assign({},hn(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=hn(e.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const o=hn(e.events,n[2]),d=hn(e.events,n[3]),f={type:u,start:Object.assign({},o),end:Object.assign({},d)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){const p=e.events[n[2]],h=e.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,_=n[3]-n[2]-1;t.add(g,_,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(s.end=Object.assign({},hn(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function Hu(t,e,n,r,i){const s=[],a=hn(e.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,e])),r.end=Object.assign({},a),s.push(["exit",r,e]),t.add(n+1,0,s)}function hn(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const G3={name:"tasklistCheck",tokenize:X3};function Q3(){return{text:{91:G3}}}function X3(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return xe(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),u):n(l)}function u(l){return ee(l)?e(l):oe(l)?t.check({tokenize:Z3},e,n)(l):n(l)}}function Z3(t,e,n){return de(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function K3(t){return Al([A3(),v3(),j3(t),q3(),Q3()])}const J3={};function e_(t){const e=this,n=t||J3,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(K3(n)),s.push(T3()),a.push(x3(n))}const t_=j.lazy(()=>fd(()=>import("./lazy-highlighter-VlHU8Y-l.js"),__vite__mapDeps([0,1,2])));function Qc(){const t=Q.c(3),[e,n]=j.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async a=>{await navigator.clipboard.writeText(a),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let s;return t[1]!==e?(s={handleCopy:i,copied:e},t[1]=e,t[2]=s):s=t[2],s}function n_(){const t=Q.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[85,70],t[0]=e):e=t[0];const n=e;let r;return t[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"p-4 font-mono text-sm",style:{background:"#2d2d2d",borderRadius:"0 0 0.5rem 0.5rem",overflow:"auto",minHeight:"4rem"},children:n.map(r_)}),t[1]=r):r=t[1],r}function r_(t,e){return m.jsxs("div",{className:"flex gap-2 items-center my-1",children:[e>2&&e<7&&m.jsx("div",{className:"w-4 h-4 rounded-sm opacity-40 animate-pulse",style:{background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.1}s`}}),e%4===0&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"3rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.12}s`}}),e%3===1&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"2.5rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.14}s`}}),m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:`${t}%`,background:"rgba(255, 255, 255, 0.1)",animationDelay:`${e*.1}s`}}),e%5===2&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"4rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.16}s`}})]},e)}function i_(t){const e=Q.c(12),n=j.useRef(null),{handleCopy:r,copied:i}=Qc(),s=s_;let a;e[0]!==r?(a=async()=>{const p=s(n.current);await r(p)},e[0]=r,e[1]=a):a=e[1];const u=a;let l;e[2]!==i?(l=i?m.jsx(Yr,{size:12}):m.jsx(ps,{size:12}),e[2]=i,e[3]=l):l=e[3];let o;e[4]!==u||e[5]!==l?(o=m.jsx("div",{className:"flex justify-end items-center",children:m.jsxs($e,{variant:"ghost",onClick:u,"aria-label":"Copy as CSV",className:"text-muted-foreground hover:text-foreground h-6 text-[10px]",type:"button",children:["Copy as CSV",l]})}),e[4]=u,e[5]=l,e[6]=o):o=e[6];let d;e[7]!==t?(d=m.jsx("div",{className:"overflow-x-auto mb-4 rounded-lg border border-border",children:m.jsx("table",{ref:n,...t,className:"min-w-full border-collapse text-sm",children:t.children})}),e[7]=t,e[8]=d):d=e[8];let f;return e[9]!==o||e[10]!==d?(f=m.jsxs(m.Fragment,{children:[o,d]}),e[9]=o,e[10]=d,e[11]=f):f=e[11],f}function s_(t){return t?Array.from(t.querySelectorAll("tr")).map(a_).join(`
105
+ `))}function l(h,g,_,x){const E=_.enter("tableCell"),C=_.enter("phrasing"),b=_.containerPhrasing(h,{...x,before:s,after:s});return C(),E(),b}function o(h,g){return Sx(h,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function d(h,g,_){const x=h.children;let E=-1;const C=[],b=g.enter("table");for(;++E<x.length;)C[E]=f(x[E],g,_);return b(),C}function f(h,g,_){const x=h.children;let E=-1;const C=[],b=g.enter("tableRow");for(;++E<x.length;)C[E]=l(x[E],h,g,_);return b(),C}function p(h,g,_){let x=Hc.inlineCode(h,g,_);return _.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function m3(){return{exit:{taskListCheckValueChecked:Uu,taskListCheckValueUnchecked:Uu,paragraph:b3}}}function g3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:E3}}}function Uu(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function b3(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,a;for(;++s<i.length;){const u=i[s];if(u.type==="paragraph"){a=u;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function E3(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",u=n.createTracker(r);s&&u.move(a);let l=Hc.listItem(t,e,n,{...r,...u.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,o)),l;function o(d){return d+a}}function T3(){return[ZT(),Ex(),yx(),o3(),m3()]}function x3(t){return{extensions:[KT(),Tx(t),Ax(),p3(t),g3()]}}const _3={tokenize:N3,partial:!0},jc={tokenize:S3,partial:!0},zc={tokenize:w3,partial:!0},$c={tokenize:R3,partial:!0},y3={tokenize:O3,partial:!0},Yc={name:"wwwAutolink",tokenize:C3,previous:Vc},qc={name:"protocolAutolink",tokenize:I3,previous:Wc},Lt={name:"emailAutolink",tokenize:k3,previous:Gc},Nt={};function A3(){return{text:Nt}}let Gt=48;for(;Gt<123;)Nt[Gt]=Lt,Gt++,Gt===58?Gt=65:Gt===91&&(Gt=97);Nt[43]=Lt;Nt[45]=Lt;Nt[46]=Lt;Nt[95]=Lt;Nt[72]=[Lt,qc];Nt[104]=[Lt,qc];Nt[87]=[Lt,Yc];Nt[119]=[Lt,Yc];function k3(t,e,n){const r=this;let i,s;return a;function a(f){return!ss(f)||!Gc.call(r,r.previous)||Qs(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),u(f))}function u(f){return ss(f)?(t.consume(f),u):f===64?(t.consume(f),l):n(f)}function l(f){return f===46?t.check(y3,d,o)(f):f===45||f===95||Ye(f)?(s=!0,t.consume(f),l):d(f)}function o(f){return t.consume(f),i=!0,l}function d(f){return s&&i&&Ze(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function C3(t,e,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Vc.call(r,r.previous)||Qs(r.events)?n(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(_3,t.attempt(jc,t.attempt(zc,s),n),n)(a))}function s(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function I3(t,e,n){const r=this;let i="",s=!1;return a;function a(f){return(f===72||f===104)&&Wc.call(r,r.previous)&&!Qs(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),u):n(f)}function u(f){if(Ze(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),u;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(f),l}return n(f)}function l(f){return f===47?(t.consume(f),s?o:(s=!0,l)):n(f)}function o(f){return f===null||Fr(f)||xe(f)||nn(f)||Jr(f)?n(f):t.attempt(jc,t.attempt(zc,d),n)(f)}function d(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function N3(t,e,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,t.consume(a),i):a===46&&r===3?(t.consume(a),s):n(a)}function s(a){return a===null?n(a):e(a)}}function S3(t,e,n){let r,i,s;return a;function a(o){return o===46||o===95?t.check($c,l,u)(o):o===null||xe(o)||nn(o)||o!==45&&Jr(o)?l(o):(s=!0,t.consume(o),a)}function u(o){return o===95?r=!0:(i=r,r=void 0),t.consume(o),a}function l(o){return i||r||!s?n(o):e(o)}}function w3(t,e){let n=0,r=0;return i;function i(a){return a===40?(n++,t.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check($c,e,s)(a):a===null||xe(a)||nn(a)?e(a):(t.consume(a),i)}function s(a){return a===41&&r++,t.consume(a),i}}function R3(t,e,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(t.consume(u),r):u===38?(t.consume(u),s):u===93?(t.consume(u),i):u===60||u===null||xe(u)||nn(u)?e(u):n(u)}function i(u){return u===null||u===40||u===91||xe(u)||nn(u)?e(u):r(u)}function s(u){return Ze(u)?a(u):n(u)}function a(u){return u===59?(t.consume(u),r):Ze(u)?(t.consume(u),a):n(u)}}function O3(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return Ye(s)?n(s):e(s)}}function Vc(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||xe(t)}function Wc(t){return!Ze(t)}function Gc(t){return!(t===47||ss(t))}function ss(t){return t===43||t===45||t===46||t===95||Ye(t)}function Qs(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const L3={tokenize:H3,partial:!0};function v3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:B3,continuation:{tokenize:F3},exit:U3}},text:{91:{name:"gfmFootnoteCall",tokenize:M3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:D3,resolveTo:P3}}}}function D3(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return u;function u(l){if(!a||!a._balanced)return n(l);const o=bt(r.sliceSerialize({start:a.end,end:r.now()}));return o.codePointAt(0)!==94||!s.includes(o.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function P3(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},u=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",a,e],["exit",a,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...u),t}function M3(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return u;function u(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",o)}function o(f){if(s>999||f===93&&!a||f===null||f===91||xe(f))return n(f);if(f===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(bt(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return xe(f)||(a=!0),s++,t.consume(f),f===92?d:o}function d(f){return f===91||f===92||f===93?(t.consume(f),s++,o):o(f)}}function B3(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,u;return l;function l(g){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),o}function o(g){return g===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):n(g)}function d(g){if(a>999||g===93&&!u||g===null||g===91||xe(g))return n(g);if(g===93){t.exit("chunkString");const _=t.exit("gfmFootnoteDefinitionLabelString");return s=bt(r.sliceSerialize(_)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return xe(g)||(u=!0),a++,t.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(t.consume(g),a++,d):d(g)}function p(g){return g===58?(t.enter("definitionMarker"),t.consume(g),t.exit("definitionMarker"),i.includes(s)||i.push(s),de(t,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return e(g)}}function F3(t,e,n){return t.check(pr,e,t.attempt(L3,e,n))}function U3(t){t.exit("gfmFootnoteDefinition")}function H3(t,e,n){const r=this;return de(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(s):n(s)}}function j3(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,u){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let o=l;for(;o--;)if(a[o][0]==="exit"&&a[o][1].type==="strikethroughSequenceTemporary"&&a[o][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[o][1].end.offset-a[o][1].start.offset){a[l][1].type="strikethroughSequence",a[o][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},a[o][1].start),end:Object.assign({},a[l][1].end)},f={type:"strikethroughText",start:Object.assign({},a[o][1].end),end:Object.assign({},a[l][1].start)},p=[["enter",d,u],["enter",a[o][1],u],["exit",a[o][1],u],["enter",f,u]],h=u.parser.constructs.insideSpan.null;h&&lt(p,p.length,0,ei(h,a.slice(o+1,l),u)),lt(p,p.length,0,[["exit",f,u],["enter",a[l][1],u],["exit",a[l][1],u],["exit",d,u]]),lt(a,o-1,l-o+3,p),l=o+p.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,u,l){const o=this.previous,d=this.events;let f=0;return p;function p(g){return o===126&&d[d.length-1][1].type!=="characterEscape"?l(g):(a.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const _=bn(o);if(g===126)return f>1?l(g):(a.consume(g),f++,h);if(f<2&&!n)return l(g);const x=a.exit("strikethroughSequenceTemporary"),E=bn(g);return x._open=!E||E===2&&!!_,x._close=!_||_===2&&!!E,u(g)}}}class z3{constructor(){this.map=[]}add(e,n,r){$3(this,e,n,r)}consume(e){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function $3(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function Y3(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function q3(){return{flow:{null:{name:"table",tokenize:V3,resolveAll:W3}}}}function V3(t,e,n){const r=this;let i=0,s=0,a;return u;function u(S){let M=r.events.length-1;for(;M>-1;){const q=r.events[M][1].type;if(q==="lineEnding"||q==="linePrefix")M--;else break}const $=M>-1?r.events[M][1].type:null,X=$==="tableHead"||$==="tableRow"?I:l;return X===I&&r.parser.lazy[r.now().line]?n(S):X(S)}function l(S){return t.enter("tableHead"),t.enter("tableRow"),o(S)}function o(S){return S===124||(a=!0,s+=1),d(S)}function d(S){return S===null?n(S):ee(S)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),h):n(S):oe(S)?de(t,d,"whitespace")(S):(s+=1,a&&(a=!1,i+=1),S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),a=!0,d):(t.enter("data"),f(S)))}function f(S){return S===null||S===124||xe(S)?(t.exit("data"),d(S)):(t.consume(S),S===92?p:f)}function p(S){return S===92||S===124?(t.consume(S),f):f(S)}function h(S){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(S):(t.enter("tableDelimiterRow"),a=!1,oe(S)?de(t,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):g(S))}function g(S){return S===45||S===58?x(S):S===124?(a=!0,t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),_):O(S)}function _(S){return oe(S)?de(t,x,"whitespace")(S):x(S)}function x(S){return S===58?(s+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),E):S===45?(s+=1,E(S)):S===null||ee(S)?w(S):O(S)}function E(S){return S===45?(t.enter("tableDelimiterFiller"),C(S)):O(S)}function C(S){return S===45?(t.consume(S),C):S===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(S))}function b(S){return oe(S)?de(t,w,"whitespace")(S):w(S)}function w(S){return S===124?g(S):S===null||ee(S)?!a||i!==s?O(S):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(S)):O(S)}function O(S){return n(S)}function I(S){return t.enter("tableRow"),D(S)}function D(S){return S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),D):S===null||ee(S)?(t.exit("tableRow"),e(S)):oe(S)?de(t,D,"whitespace")(S):(t.enter("data"),B(S))}function B(S){return S===null||S===124||xe(S)?(t.exit("data"),D(S)):(t.consume(S),S===92?P:B)}function P(S){return S===92||S===124?(t.consume(S),B):B(S)}}function W3(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],u=!1,l=0,o,d,f;const p=new z3;for(;++n<t.length;){const h=t[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(u=!1,l!==0&&(Hu(p,e,l,o,d),d=void 0,l=0),o={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",o,e]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],a=[0,n+1,0,0],u&&(u=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,e]])),i=g.type==="tableDelimiterRow"?2:d?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],f=Ar(p,e,s,i,void 0,f),s=[0,0,0,0]),a[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],f=Ar(p,e,s,i,void 0,f)),s=a,a=[s[1],n,0,0])):g.type==="tableHead"?(u=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(a[0]=a[1],f=Ar(p,e,s,i,n,f)):a[1]!==0&&(f=Ar(p,e,a,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&Hu(p,e,l,o,d),p.consume(e.events),n=-1;++n<e.events.length;){const h=e.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Y3(e.events,n))}return t}function Ar(t,e,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(s.end=Object.assign({},hn(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=hn(e.events,n[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const o=hn(e.events,n[2]),d=hn(e.events,n[3]),f={type:u,start:Object.assign({},o),end:Object.assign({},d)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){const p=e.events[n[2]],h=e.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,_=n[3]-n[2]-1;t.add(g,_,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(s.end=Object.assign({},hn(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function Hu(t,e,n,r,i){const s=[],a=hn(e.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,e])),r.end=Object.assign({},a),s.push(["exit",r,e]),t.add(n+1,0,s)}function hn(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const G3={name:"tasklistCheck",tokenize:X3};function Q3(){return{text:{91:G3}}}function X3(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return xe(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),u):n(l)}function u(l){return ee(l)?e(l):oe(l)?t.check({tokenize:Z3},e,n)(l):n(l)}}function Z3(t,e,n){return de(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function K3(t){return Al([A3(),v3(),j3(t),q3(),Q3()])}const J3={};function e_(t){const e=this,n=t||J3,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(K3(n)),s.push(T3()),a.push(x3(n))}const t_=j.lazy(()=>fd(()=>import("./lazy-highlighter-C9yEt-oj.js"),__vite__mapDeps([0,1,2])));function Qc(){const t=Q.c(3),[e,n]=j.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async a=>{await navigator.clipboard.writeText(a),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let s;return t[1]!==e?(s={handleCopy:i,copied:e},t[1]=e,t[2]=s):s=t[2],s}function n_(){const t=Q.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[85,70],t[0]=e):e=t[0];const n=e;let r;return t[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"p-4 font-mono text-sm",style:{background:"#2d2d2d",borderRadius:"0 0 0.5rem 0.5rem",overflow:"auto",minHeight:"4rem"},children:n.map(r_)}),t[1]=r):r=t[1],r}function r_(t,e){return m.jsxs("div",{className:"flex gap-2 items-center my-1",children:[e>2&&e<7&&m.jsx("div",{className:"w-4 h-4 rounded-sm opacity-40 animate-pulse",style:{background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.1}s`}}),e%4===0&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"3rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.12}s`}}),e%3===1&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"2.5rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.14}s`}}),m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:`${t}%`,background:"rgba(255, 255, 255, 0.1)",animationDelay:`${e*.1}s`}}),e%5===2&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"4rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.16}s`}})]},e)}function i_(t){const e=Q.c(12),n=j.useRef(null),{handleCopy:r,copied:i}=Qc(),s=s_;let a;e[0]!==r?(a=async()=>{const p=s(n.current);await r(p)},e[0]=r,e[1]=a):a=e[1];const u=a;let l;e[2]!==i?(l=i?m.jsx(Yr,{size:12}):m.jsx(ps,{size:12}),e[2]=i,e[3]=l):l=e[3];let o;e[4]!==u||e[5]!==l?(o=m.jsx("div",{className:"flex justify-end items-center",children:m.jsxs($e,{variant:"ghost",onClick:u,"aria-label":"Copy as CSV",className:"text-muted-foreground hover:text-foreground h-6 text-[10px]",type:"button",children:["Copy as CSV",l]})}),e[4]=u,e[5]=l,e[6]=o):o=e[6];let d;e[7]!==t?(d=m.jsx("div",{className:"overflow-x-auto mb-4 rounded-lg border border-border",children:m.jsx("table",{ref:n,...t,className:"min-w-full border-collapse text-sm",children:t.children})}),e[7]=t,e[8]=d):d=e[8];let f;return e[9]!==o||e[10]!==d?(f=m.jsxs(m.Fragment,{children:[o,d]}),e[9]=o,e[10]=d,e[11]=f):f=e[11],f}function s_(t){return t?Array.from(t.querySelectorAll("tr")).map(a_).join(`
106
106
  `):""}function a_(t){return Array.from(t.querySelectorAll("th,td")).map(u_).join(",")}function u_(t){let e=t.textContent||"";return e=e.replace(/"/g,'""'),e.search(/([",\n])/g)>=0&&(e=`"${e}"`),e}const o_=[e_],l_=[qT],c_={p:t=>m.jsx("p",{...t,className:"leading-relaxed text-[15px] mb-2 last:mb-0"}),strong:t=>m.jsx("strong",{...t,className:"font-bold"}),em:t=>m.jsx("em",{...t,className:"italic"}),a:t=>m.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer",className:"text-primary-dark hover:underline break-all font-medium"}),ul:t=>m.jsx("ul",{...t,className:"list-disc ml-6 my-4 space-y-2"}),ol:t=>m.jsx("ol",{...t,className:"list-decimal ml-6 my-4 space-y-2"}),li:t=>m.jsx("li",{...t,className:"leading-relaxed text-[15px]"}),code:t=>m.jsx("code",{...t,className:"px-1 py-0.5 bg-muted rounded text-[15px] font-mono break-all"}),pre:t=>m.jsx("pre",{...t,className:"flex w-full min-w-0 my-4 bg-muted rounded overflow-hidden",children:m.jsx("code",{className:"flex-1 min-w-0 p-4 text-[15px] font-mono whitespace-pre overflow-x-auto",children:t.children})}),table:t=>m.jsx(i_,{...t}),thead:t=>m.jsx("thead",{...t,className:"bg-muted",children:t.children}),tr:t=>m.jsx("tr",{...t,className:"even:bg-muted/50 border-b border-border last:border-0"}),th:t=>m.jsx("th",{...t,className:"px-4 py-2 text-left font-semibold text-muted-foreground border-b border-border"}),td:t=>m.jsx("td",{...t,className:"px-4 py-2 border-b border-border"})},Xc=j.memo(t=>{const e=Q.c(2),{content:n}=t;let r;return e[0]!==n?(r=m.jsx(wb,{remarkPlugins:o_,rehypePlugins:l_,components:c_,children:n}),e[0]=n,e[1]=r):r=e[1],r},(t,e)=>t.content===e.content);function d_(t){const e=Q.c(20),{language:n,content:r}=t,{handleCopy:i,copied:s}=Qc(),a=n||"text";let u;e[0]!==a?(u=m.jsx("span",{className:"text-xs font-mono uppercase text-muted-foreground tracking-widest select-none",children:a}),e[0]=a,e[1]=u):u=e[1];let l;e[2]!==r||e[3]!==i?(l=()=>i(r),e[2]=r,e[3]=i,e[4]=l):l=e[4];let o;e[5]!==s?(o=s?m.jsx(Yr,{size:14}):m.jsx(ps,{size:14}),e[5]=s,e[6]=o):o=e[6];let d;e[7]!==l||e[8]!==o?(d=m.jsx($e,{size:"icon",variant:"ghost",onClick:l,"aria-label":"Copy code",className:"text-muted-foreground hover:text-foreground rounded-lg h-8 w-8",children:o}),e[7]=l,e[8]=o,e[9]=d):d=e[9];let f;e[10]!==u||e[11]!==d?(f=m.jsxs("div",{className:"flex items-center justify-between p-1 pl-4 bg-muted border-b border-border",children:[u,d]}),e[10]=u,e[11]=d,e[12]=f):f=e[12];let p;e[13]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(n_,{}),e[13]=p):p=e[13];let h;e[14]!==r||e[15]!==n?(h=m.jsx(j.Suspense,{fallback:p,children:m.jsx(t_,{language:n,content:r})}),e[14]=r,e[15]=n,e[16]=h):h=e[16];let g;return e[17]!==f||e[18]!==h?(g=m.jsxs("div",{className:"my-4 rounded-lg bg-muted overflow-hidden border border-border grid min-w-0",children:[f,h]}),e[17]=f,e[18]=h,e[19]=g):g=e[19],g}Xc.displayName="MemoizedMarkdownBlock";const Xs=t=>{const e=Q.c(7),{id:n,text:r}=t;let i;e[0]!==r?(i=ge.lexer(r),e[0]=r,e[1]=i):i=e[1];const s=i;let a;if(e[2]!==s||e[3]!==n){let u;e[5]!==n?(u=(l,o)=>l.type==="code"?m.jsx(d_,{language:l.lang,content:l.text},`${n}-block_${o}`):m.jsx(Xc,{content:l.raw},`${n}-block_${o}`),e[5]=n,e[6]=u):u=e[6],a=s.map(u),e[2]=s,e[3]=n,e[4]=a}else a=e[4];return a};Xs.displayName="MemoizedMarkdown";function Zc(t){const e=Q.c(18),{id:n,part:r,copyable:i,extraActions:s,hasToolCallAfter:a}=t,u=i===void 0?!1:i,l=a===void 0?!1:a,{handleCopy:o}=H0(),[d,f]=j.useState(!1);let p;e[0]!==o||e[1]!==r.text?(p=async()=>{await o(r.text),f(!0),setTimeout(()=>f(!1),2e3)},e[0]=o,e[1]=r.text,e[2]=p):p=e[2];const h=p,g=u&&s,_=g||s,x=!l&&"mb-2";let E;e[3]!==x?(E=ae("group/part relative",x),e[3]=x,e[4]=E):E=e[4];let C;e[5]!==n||e[6]!==r.text?(C=m.jsx(Xs,{id:n,text:r.text}),e[5]=n,e[6]=r.text,e[7]=C):C=e[7];let b;e[8]!==s||e[9]!==h||e[10]!==d||e[11]!==_||e[12]!==g?(b=_&&m.jsx("div",{className:"flex w-full items-center text-xs text-muted-foreground opacity-0 pointer-events-none transition-all duration-200 group-hover/part:opacity-100 group-hover/part:pointer-events-auto mt-2",children:m.jsxs("div",{className:"flex items-center gap-1",children:[g&&m.jsx($e,{onClick:h,variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground size-6 whitespace-nowrap",children:d?m.jsx(Yr,{size:12}):m.jsx(ps,{size:12})}),s]})}),e[8]=s,e[9]=h,e[10]=d,e[11]=_,e[12]=g,e[13]=b):b=e[13];let w;return e[14]!==E||e[15]!==C||e[16]!==b?(w=m.jsxs("div",{className:E,children:[C,b]}),e[14]=E,e[15]=C,e[16]=b,e[17]=w):w=e[17],w}function f_(t){const e=Q.c(4),{output:n}=t;let r;if(e[0]!==n){const a=JSON.stringify(n,null,2);r=a.length>2e3?a.slice(0,2e3)+"...[TRUNCATED]":a,e[0]=n,e[1]=r}else r=e[1];const i=r;let s;return e[2]!==i?(s=m.jsx("div",{className:"h-full",children:m.jsx(Zu,{code:i,language:"json",height:"100%",readOnly:!0})}),e[2]=i,e[3]=s):s=e[3],s}var li="Collapsible",[h_,Dy]=hd(li),[p_,Zs]=h_(li),Kc=j.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:s,onOpenChange:a,...u}=t,[l,o]=gd({prop:r,defaultProp:i??!1,onChange:a,caller:li});return m.jsx(p_,{scope:n,disabled:s,contentId:bd(),open:l,onOpenToggle:j.useCallback(()=>o(d=>!d),[o]),children:m.jsx(ls.div,{"data-state":ta(l),"data-disabled":s?"":void 0,...u,ref:e})})});Kc.displayName=li;var Jc="CollapsibleTrigger",Ks=j.forwardRef((t,e)=>{const{__scopeCollapsible:n,...r}=t,i=Zs(Jc,n);return m.jsx(ls.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":ta(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:e,onClick:pd(t.onClick,i.onOpenToggle)})});Ks.displayName=Jc;var Js="CollapsibleContent",ea=j.forwardRef((t,e)=>{const{forceMount:n,...r}=t,i=Zs(Js,t.__scopeCollapsible);return m.jsx(md,{present:n||i.open,children:({present:s})=>m.jsx(m_,{...r,ref:e,present:s})})});ea.displayName=Js;var m_=j.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:r,children:i,...s}=t,a=Zs(Js,n),[u,l]=j.useState(r),o=j.useRef(null),d=Ed(e,o),f=j.useRef(0),p=f.current,h=j.useRef(0),g=h.current,_=a.open||u,x=j.useRef(_),E=j.useRef(void 0);return j.useEffect(()=>{const C=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(C)},[]),Td(()=>{const C=o.current;if(C){E.current=E.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const b=C.getBoundingClientRect();f.current=b.height,h.current=b.width,x.current||(C.style.transitionDuration=E.current.transitionDuration,C.style.animationName=E.current.animationName),l(r)}},[a.open,r]),m.jsx(ls.div,{"data-state":ta(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!_,...s,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:_&&i})});function ta(t){return t?"open":"closed"}var g_=Kc,Py=Ks,My=ea;function b_(t){const e=Q.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=m.jsx(g_,{"data-slot":"collapsible",...n}),e[2]=n,e[3]=r):r=e[3],r}function E_(t){const e=Q.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=m.jsx(Ks,{"data-slot":"collapsible-trigger",...n}),e[2]=n,e[3]=r):r=e[3],r}function T_(t){const e=Q.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=m.jsx(ea,{"data-slot":"collapsible-content",...n}),e[2]=n,e[3]=r):r=e[3],r}function x_(t){return t.split(/[_-]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function ju(t){const e=Q.c(70),{part:n,isFirstInSequence:r,isLastInSequence:i,hasNextToolCall:s}=t,a=r===void 0?!1:r,u=i===void 0?!1:i,l=s===void 0?!1:s,{state:o}=n;let d;e[0]!==n?(d="toolName"in n?n.toolName:n.type.replace("tool-",""),e[0]=n,e[1]=d):d=e[1];const f=d;let p;e[2]!==f?(p=x_(f),e[2]=f,e[3]=p):p=e[3];const h=p,[g,_]=j.useState(!1),[x]=sf(),E=(o==="input-streaming"||o==="input-available"||o==="output-available")&&!!n.input,C=o==="output-available",b=o==="output-error";if(!x){const ve=o==="input-streaming"||o==="input-available",fe=o==="output-available",We=o==="output-error",Ie=a&&"mt-2",Ne=u&&"mb-2";let ye;e[4]!==Ie||e[5]!==Ne?(ye=ae("flex items-center gap-1.5 py-2 opacity-75 relative",Ie,Ne),e[4]=Ie,e[5]=Ne,e[6]=ye):ye=e[6];let Be;e[7]===Symbol.for("react.memo_cache_sentinel")?(Be=m.jsx(Ku,{className:"size-4 text-muted-foreground shrink-0"}),e[7]=Be):Be=e[7];let Re;e[8]!==l?(Re=l&&m.jsx("div",{className:"absolute left-1/2 top-full w-px bg-border -translate-x-1/2",style:{height:"calc(100% + 1rem)"}}),e[8]=l,e[9]=Re):Re=e[9];let De;e[10]!==Re?(De=m.jsxs("div",{className:"relative shrink-0 flex items-center",children:[Be,Re]}),e[10]=Re,e[11]=De):De=e[11];let Oe;e[12]!==h||e[13]!==ve?(Oe=ve&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted-foreground shimmer",children:"Calling"})," ",m.jsxs("span",{className:"text-muted-foreground/75 shimmer",children:[h,"..."]})]}),e[12]=h,e[13]=ve,e[14]=Oe):Oe=e[14];let Fe;e[15]!==h||e[16]!==fe?(Fe=fe&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted-foreground",children:"Called"})," ",m.jsx("span",{className:"text-muted-foreground/75",children:h})]}),e[15]=h,e[16]=fe,e[17]=Fe):Fe=e[17];let Se;e[18]!==h||e[19]!==We?(Se=We&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-destructive/90",children:"Error calling"})," ",m.jsx("span",{className:"text-destructive/75",children:h})]}),e[18]=h,e[19]=We,e[20]=Se):Se=e[20];let Ue;e[21]!==Oe||e[22]!==Fe||e[23]!==Se?(Ue=m.jsxs("span",{className:"text-[15px]",children:[Oe,Fe,Se]}),e[21]=Oe,e[22]=Fe,e[23]=Se,e[24]=Ue):Ue=e[24];let Ge;return e[25]!==De||e[26]!==Ue||e[27]!==ye?(Ge=m.jsxs("div",{className:ye,children:[De,Ue]}),e[25]=De,e[26]=Ue,e[27]=ye,e[28]=Ge):Ge=e[28],Ge}let w;e[29]!==o?(w=o==="output-error"?m.jsx(Wu,{className:"size-4 text-destructive shrink-0"}):m.jsx(Yd,{className:ae("size-4 text-muted-foreground shrink-0",(o==="input-streaming"||o==="input-available")&&"shimmer")}),e[29]=o,e[30]=w):w=e[30];const O=o==="output-error"&&"text-destructive/90",I=(o==="input-streaming"||o==="input-available")&&"shimmer";let D;e[31]!==O||e[32]!==I?(D=ae("text-[15px] font-medium text-muted-foreground truncate",O,I),e[31]=O,e[32]=I,e[33]=D):D=e[33];const B=o==="input-streaming"&&`Streaming ${f} arguments`,P=o==="input-available"&&`Calling ${f}`,S=o==="output-available"&&`Called ${f}`,M=o==="output-error"&&`Error calling ${f}`;let $;e[34]!==B||e[35]!==P||e[36]!==S||e[37]!==M||e[38]!==D?($=m.jsxs("span",{className:D,children:[B,P,S,M]}),e[34]=B,e[35]=P,e[36]=S,e[37]=M,e[38]=D,e[39]=$):$=e[39];let X;e[40]!==$||e[41]!==w?(X=m.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[w,$]}),e[40]=$,e[41]=w,e[42]=X):X=e[42];const q=g&&"rotate-90";let U;e[43]!==q?(U=ae("size-4 text-muted-foreground transition-transform duration-200",q),e[43]=q,e[44]=U):U=e[44];let G;e[45]!==U?(G=m.jsx("div",{className:"flex items-center gap-2 shrink-0",children:m.jsx(Xu,{className:U})}),e[45]=U,e[46]=G):G=e[46];let V;e[47]!==X||e[48]!==G?(V=m.jsxs(E_,{className:"flex items-center gap-2 w-full cursor-pointer p-3 hover:bg-accent/50 transition-colors",children:[X,G]}),e[47]=X,e[48]=G,e[49]=V):V=e[49];let K;e[50]===Symbol.for("react.memo_cache_sentinel")?(K=m.jsx("div",{className:"w-4 relative shrink-0",children:m.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-0.25 bg-border"})}),e[50]=K):K=e[50];let J;e[51]!==n.input||e[52]!==E?(J=E&&m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("div",{className:"px-1 h-5 flex items-center",children:m.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Input"})}),m.jsx("div",{className:"border border-border rounded-lg p-2 h-full max-h-[200px]",children:m.jsx(Zu,{code:JSON.stringify(n.input,null,2),language:"json",foldOnMount:!0,height:"100%",readOnly:!0})})]}),e[51]=n.input,e[52]=E,e[53]=J):J=e[53];let A;e[54]!==n.output||e[55]!==C?(A=C&&m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("div",{className:"px-1 h-5 flex items-center",children:m.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Output"})}),m.jsx("div",{className:"border border-border rounded-lg max-h-[200px] overflow-auto p-2 h-full",children:m.jsx(f_,{output:n.output})})]}),e[54]=n.output,e[55]=C,e[56]=A):A=e[56];let re;e[57]!==n||e[58]!==b?(re=b&&m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("div",{className:"px-1 h-5 flex items-center",children:m.jsx("span",{className:"text-xs font-medium text-destructive/90",children:"Error"})}),m.jsx("div",{className:"border border-destructive/20 rounded-lg max-h-[200px] overflow-auto p-2 bg-destructive/10",children:m.jsx("pre",{className:"text-xs font-mono text-destructive whitespace-pre-wrap wrap-break-word",children:"errorText"in n&&typeof n.errorText=="string"?n.errorText:"An unknown error occurred"})})]}),e[57]=n,e[58]=b,e[59]=re):re=e[59];let he;e[60]!==J||e[61]!==A||e[62]!==re?(he=m.jsx(T_,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:m.jsxs("div",{className:"flex ml-[7px] px-3 pb-3",children:[K,m.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-w-0 pt-2",children:[J,A,re]})]})}),e[60]=J,e[61]=A,e[62]=re,e[63]=he):he=e[63];let N;e[64]!==V||e[65]!==he?(N=m.jsxs("div",{className:"border border-border/75 rounded-lg flex flex-col bg-background w-full min-w-0 overflow-hidden",children:[V,he]}),e[64]=V,e[65]=he,e[66]=N):N=e[66];let Ee;return e[67]!==g||e[68]!==N?(Ee=m.jsx("div",{className:"flex flex-col my-4 w-full min-w-0",children:m.jsx(b_,{open:g,onOpenChange:_,children:N})}),e[67]=g,e[68]=N,e[69]=Ee):Ee=e[69],Ee}const __={planning:{icon:m.jsx(uo,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves"},thinking:{icon:m.jsx(Vr,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking"}},y_=1200;function A_(){const t=Q.c(7),[e,n]=j.useState("planning");let r,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const l=setTimeout(()=>{n("thinking")},y_);return()=>{clearTimeout(l)}},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),j.useEffect(r,i);const s=__[e];let a;t[2]!==s.label?(a=m.jsxs("span",{className:"text-[15px] text-muted-foreground shimmer",children:[s.label,"..."]}),t[2]=s.label,t[3]=a):a=t[3];let u;return t[4]!==s.icon||t[5]!==a?(u=m.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:m.jsxs("span",{className:"flex items-center gap-1.5",children:[s.icon,a]})}),t[4]=s.icon,t[5]=a,t[6]=u):u=t[6],u}function k_(t){const e=Q.c(10),{duration:n,parts:r,id:i}=t,s=n/1e3;let a;e[0]!==s?(a=s.toFixed(1),e[0]=s,e[1]=a):a=e[1];const u=a,[l,o]=j.useState(!1),[d,f]=j.useState(!1);let p;if(e[2]!==i||e[3]!==d||e[4]!==l||e[5]!==r||e[6]!==u){const h=r.filter(I_),g=h.some(C_),_=g||d;let x,E;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(!0),E=()=>o(!1),e[8]=x,e[9]=E):(x=e[8],E=e[9]),p=m.jsxs("div",{className:"flex flex-col mb-2",children:[m.jsx("button",{type:"button",onClick:()=>!g&&f(!d),onMouseEnter:x,onMouseLeave:E,className:ae("flex items-center gap-1.5 py-2 opacity-60 transition-opacity",!g&&"cursor-pointer hover:opacity-100",g&&"cursor-default"),children:m.jsxs("span",{className:"flex items-center gap-1.5",children:[g?m.jsx(Vr,{className:"text-muted-foreground shrink-0 shimmer",size:14}):l?m.jsx(Xu,{className:ae("text-muted-foreground transition-transform shrink-0",d&&"rotate-90"),size:14}):m.jsx(io,{className:"text-muted-foreground shrink-0",size:14}),m.jsx("span",{className:ae("text-[15px] text-muted-foreground",g&&"shimmer"),children:g?"Thinking...":`Thought for ${u}s`})]})}),_&&m.jsx("div",{className:"ml-[6px] border-l-2 pl-4 mt-1 mb-2 max-h-[300px] overflow-y-auto",children:h.map((C,b)=>m.jsx("div",{className:"text-muted-foreground markdown-sm pb-2",children:m.jsx(Xs,{id:`${i}-reasoning-${b}`,text:C.text})},`${i}-reasoning-${b}`))})]}),e[2]=i,e[3]=d,e[4]=l,e[5]=r,e[6]=u,e[7]=p}else p=e[7];return p}function C_(t){return t.state==="streaming"}function I_(t){return t.type==="reasoning"}function N_(t){const e=Q.c(17),{part:n,id:r,usageStats:i,isFollowedByToolCall:s,isFirstToolCallInSequence:a,isLastToolCallInSequence:u,hasNextToolCall:l}=t;switch(n.type){case"dynamic-tool":{let o;return e[0]!==l||e[1]!==r||e[2]!==a||e[3]!==u||e[4]!==n?(o=m.jsx(ju,{part:n,id:r,isFirstInSequence:a,isLastInSequence:u,hasNextToolCall:l}),e[0]=l,e[1]=r,e[2]=a,e[3]=u,e[4]=n,e[5]=o):o=e[5],o}case"text":{let o;return e[6]!==r||e[7]!==s||e[8]!==n||e[9]!==i?(o=m.jsx(Zc,{id:r,part:n,extraActions:i,copyable:!0,hasToolCallAfter:s}),e[6]=r,e[7]=s,e[8]=n,e[9]=i,e[10]=o):o=e[10],o}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;default:if(n.type.startsWith("tool-")){const o=n;let d;return e[11]!==l||e[12]!==r||e[13]!==a||e[14]!==u||e[15]!==o?(d=m.jsx(ju,{part:o,id:r,isFirstInSequence:a,isLastInSequence:u,hasNextToolCall:l}),e[11]=l,e[12]=r,e[13]=a,e[14]=u,e[15]=o,e[16]=d):d=e[16],d}}throw new Error(`Unknown part type: ${n.type}`)}function S_(t){const e=Q.c(24),{message:n,status:r,className:i}=t,{id:s,parts:a}=n,o=r==="streaming"||r==="submitted",d=a.length>0;let f;e[0]!==a?(f=a.some(R_),e[0]=a,e[1]=f):f=e[1];const p=f;let h;e[2]!==o||e[3]!==a?(h=o&&a.some(w_),e[2]=o,e[3]=a,e[4]=h):h=e[4];const g=h;let _;if(e[5]!==n.metadata){const B=n.metadata?.reasoning_start_at?new Date(n.metadata.reasoning_start_at):null,P=n.metadata?.reasoning_end_at?new Date(n.metadata.reasoning_end_at):null;_=B!==null?(P??new Date).getTime()-B.getTime():null,e[5]=n.metadata,e[6]=_}else _=e[6];const x=_,E=d&&(p||g)&&x!==null;let C;e[7]!==n?(C=m.jsx(Xo,{messages:[n]}),e[7]=n,e[8]=C):C=e[8];const b=C;let w;e[9]!==i?(w=ae("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",i),e[9]=i,e[10]=w):w=e[10];let O;e[11]!==x||e[12]!==d||e[13]!==s||e[14]!==o||e[15]!==a||e[16]!==E||e[17]!==b?(O=d?m.jsxs(m.Fragment,{children:[E&&m.jsx(k_,{duration:x,parts:a,id:s}),a.map((B,P)=>{const S=a[P+1],M=a[P-1],$=S&&(S.type==="dynamic-tool"||S.type.startsWith("tool-")),X=B.type==="dynamic-tool"||B.type.startsWith("tool-"),q=M&&(M.type==="dynamic-tool"||M.type.startsWith("tool-")),U=S&&(S.type==="dynamic-tool"||S.type.startsWith("tool-")),G=X&&!q,V=X&&!U,K=X&&U;return m.jsx(N_,{part:B,id:s,usageStats:P===a.length-1?b:void 0,isFollowedByToolCall:$,isFirstToolCallInSequence:G,isLastToolCallInSequence:V,hasNextToolCall:K},`${s}-${P}`)})]}):o?m.jsx(A_,{}):null,e[11]=x,e[12]=d,e[13]=s,e[14]=o,e[15]=a,e[16]=E,e[17]=b,e[18]=O):O=e[18];let I;e[19]!==O?(I=m.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:m.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[15px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:O})}),e[19]=O,e[20]=I):I=e[20];let D;return e[21]!==w||e[22]!==I?(D=m.jsx("div",{className:w,children:I}),e[21]=w,e[22]=I,e[23]=D):D=e[23],D}function w_(t){return t.type==="reasoning"&&t.state==="streaming"}function R_(t){return t.type==="reasoning"}const ed=j.createContext(null);function td(t){const e=Q.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx(m.Fragment,{children:n}),e[0]=n,e[1]=r):r=e[1],r}function O_(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!j.isValidElement(r))continue;if(r.props?.message?.role==="assistant"){const s=t[n-1],a=j.isValidElement(s)&&s.props?.message?.role,u=s&&j.isValidElement(s)&&a==="user"?s:null;e.push({user:u,assistant:r})}}return e}function L_(t){const e=Q.c(27),{children:n,className:r,minHeightOffset:i}=t,s=j.useRef(null);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],e[0]=a):a=e[0];const u=j.useRef(a);let l,o,d,f,p,h,g;if(e[1]!==n||e[2]!==r||e[3]!==i){const C=j.Children.toArray(n),b=C[C.length-1];o=b&&j.isValidElement(b)&&b.type===td?b:null;const w=o?C.slice(0,-1):C,O=O_(w);let I;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=B=>{const P=u.current[B];if(P&&s.current){const S=s.current.offsetTop,M=P.offsetTop;s.current.scrollTo({top:M-S,behavior:"smooth"})}},e[11]=I):I=e[11];const D=I;l=ed.Provider,e[12]===Symbol.for("react.memo_cache_sentinel")?(g={scrollToPair:D},e[12]=g):g=e[12],p=s,e[13]!==r?(h=ae("w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",r),e[13]=r,e[14]=h):h=e[14],d="flex flex-col min-w-0 max-w-2xl mx-auto w-full",f=O.map((B,P)=>{const S=P===O.length-1;return m.jsxs("div",{ref:M=>{u.current[P]=M},className:"flex flex-col pb-2",style:S&&i?{minHeight:`calc(100vh - ${i}px)`}:void 0,children:[m.jsx("div",{className:"sticky top-0 z-50 bg-background w-full h-4"}),m.jsx("div",{className:"sticky mb-3 top-4 z-50",children:B.user&&j.isValidElement(B.user)?j.cloneElement(B.user,{pairIndex:P}):B.user}),B.assistant]},P)}),e[1]=n,e[2]=r,e[3]=i,e[4]=l,e[5]=o,e[6]=d,e[7]=f,e[8]=p,e[9]=h,e[10]=g}else l=e[4],o=e[5],d=e[6],f=e[7],p=e[8],h=e[9],g=e[10];let _;e[15]!==o||e[16]!==d||e[17]!==f?(_=m.jsxs("div",{className:d,children:[f,o]}),e[15]=o,e[16]=d,e[17]=f,e[18]=_):_=e[18];let x;e[19]!==p||e[20]!==h||e[21]!==_?(x=m.jsx("div",{ref:p,className:h,children:_}),e[19]=p,e[20]=h,e[21]=_,e[22]=x):x=e[22];let E;return e[23]!==l||e[24]!==g||e[25]!==x?(E=m.jsx(l,{value:g,children:x}),e[23]=l,e[24]=g,e[25]=x,e[26]=E):E=e[26],E}function v_(t){const e=Q.c(5),{locator:n}=zt(),r=$o(),i=zo();let s;return e[0]!==n||e[1]!==r||e[2]!==t||e[3]!==i?(s=async(u,l,o)=>{const d=await Ho(n,o),f=d.findIndex(x=>x.id===u);if(f===-1){console.warn(`[branch] Message ${u} not found in thread ${o}`);return}const p=d.slice(0,f).filter(D_),h=crypto.randomUUID(),g=new Date().toISOString(),_={id:h,title:"",created_at:g,updated_at:g,hidden:!1};if(await i.insert.mutateAsync(_),p.length>0){const x=p.map(E=>({...E,id:crypto.randomUUID(),metadata:{...E.metadata,thread_id:h,created_at:E.metadata?.created_at||g}}));await r.insertMany.mutateAsync(x)}t(h)},e[0]=n,e[1]=r,e[2]=t,e[3]=i,e[4]=s):s=e[4],s}function D_(t){return t.role!=="system"}function P_(t){const e=Q.c(18),{messageId:n,parts:r}=t,[i,s]=j.useState(!1),{setInputValue:a,startBranch:u,setActiveThreadId:l,activeThreadId:o}=An(),d=v_(l);let f;e[0]!==r?(f=r.filter(B_).map(M_).join(`
107
107
  `),e[0]=r,e[1]=f):f=e[1];const p=f;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=I=>{I.stopPropagation(),s(!0)},e[2]=h):h=e[2];const g=h;let _;e[3]!==o||e[4]!==d||e[5]!==n||e[6]!==p||e[7]!==a||e[8]!==u?(_=async()=>{await d(n,p,o),a(p),u({originalThreadId:o,originalMessageId:n,originalMessageText:p}),s(!1)},e[3]=o,e[4]=d,e[5]=n,e[6]=p,e[7]=a,e[8]=u,e[9]=_):_=e[9];const x=_;let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsx("div",{className:"flex justify-center items-end px-2 pb-1",children:m.jsxs(yn,{children:[m.jsx(_n,{asChild:!0,children:m.jsx($e,{onClick:g,variant:"ghost",size:"xs",className:"opacity-0 group-hover:opacity-100 hover:bg-gray-200/70 rounded-md transition-opacity text-muted-foreground hover:text-foreground aspect-square w-6 h-6 p-0",children:m.jsx(ro,{size:16,className:"p-0.5"})})}),m.jsx(xn,{side:"bottom",children:"Edit message"})]})}),e[10]=E):E=e[10];let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=m.jsxs(qd,{children:[m.jsx(Vd,{children:"Edit message?"}),m.jsx(Wd,{children:"This will create a new conversation branch from this point. The original conversation will remain unchanged."})]}),e[11]=C):C=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx(Gd,{children:"Cancel"}),e[12]=b):b=e[12];let w;e[13]!==x?(w=m.jsxs(Qd,{children:[C,m.jsxs(Xd,{children:[b,m.jsx(Zd,{onClick:x,children:"Confirm"})]})]}),e[13]=x,e[14]=w):w=e[14];let O;return e[15]!==i||e[16]!==w?(O=m.jsxs(m.Fragment,{children:[E,m.jsx(Kd,{open:i,onOpenChange:s,children:w})]}),e[15]=i,e[16]=w,e[17]=O):O=e[17],O}function M_(t){return t.text}function B_(t){return t.type==="text"}function F_(t){const e=Q.c(29),{message:n,className:r,pairIndex:i}=t,{id:s,parts:a}=n,u=j.useContext(ed),[l,o]=j.useState(!1);if(!a||a.length===0)return null;let d;e[0]!==u||e[1]!==i?(d=()=>{o(!0),i!==void 0&&u?.scrollToPair(i)},e[0]=u,e[1]=i,e[2]=d):d=e[2];const f=d;let p;e[3]!==r?(p=ae("message-block w-full min-w-0 group relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=p):p=e[4];let h,g;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>o(!0),g=()=>o(!1),e[5]=h,e[6]=g):(h=e[5],g=e[6]);const _=l?"overflow-auto opacity-100":"overflow-hidden opacity-99 mask-b-from-1%";let x;e[7]!==_?(x=ae("z-10 px-4 py-2 transition-opacity max-h-[120px] flex-1",_),e[7]=_,e[8]=x):x=e[8];let E;if(e[9]!==s||e[10]!==a){let D;e[12]!==s?(D=(B,P)=>B.type==="text"?m.jsx(Zc,{id:s,part:B},`${s}-${P}`):null,e[12]=s,e[13]=D):D=e[13],E=a.map(D),e[9]=s,e[10]=a,e[11]=E}else E=e[11];let C;e[14]!==E?(C=m.jsx("div",{children:E}),e[14]=E,e[15]=C):C=e[15];let b;e[16]!==x||e[17]!==C?(b=m.jsx("div",{className:x,children:C}),e[16]=x,e[17]=C,e[18]=b):b=e[18];let w;e[19]!==s||e[20]!==a?(w=m.jsx(P_,{messageId:s,parts:a}),e[19]=s,e[20]=a,e[21]=w):w=e[21];let O;e[22]!==f||e[23]!==w||e[24]!==b?(O=m.jsxs("div",{tabIndex:0,onClick:f,onFocus:h,onBlur:g,className:"w-full border min-w-0 shadow-xs rounded-lg text-[0.9375rem] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[b,w]}),e[22]=f,e[23]=w,e[24]=b,e[25]=O):O=e[25];let I;return e[26]!==O||e[27]!==p?(I=m.jsx(m.Fragment,{children:m.jsx("div",{className:p,children:O})}),e[26]=O,e[27]=p,e[28]=I):I=e[28],I}function U_({title:t="No model provider connected",description:e="Connect to a model provider to unlock AI-powered features.",org:n}){const[r,i]=j.useState(!1),s=Ld(),a=Vu(),{data:u}=qu.useSession(),l=Gu(),o=u?.user?.id??"",d=()=>{a({to:"/$org/mcps",params:{org:n.slug},search:{action:"create"}})},f=async()=>{if(!n.id||!o){Lr.error("Not authenticated");return}i(!0);try{const p=l?.find(_=>_.connection_url===ef);if(p){a({to:"/$org/mcps/$connectionId",params:{org:n.slug,connectionId:p.id}});return}const h=tf({id:nf("conn")}),g=await s.create.mutateAsync(h);a({to:"/$org/mcps/$connectionId",params:{org:n.slug,connectionId:g.id}})}catch(p){Lr.error(`Failed to connect OpenRouter: ${p instanceof Error?p.message:String(p)}`)}finally{i(!1)}};return m.jsx(_d,{image:m.jsx("img",{src:"/empty-state-openrouter.svg",alt:"",width:336,height:320,"aria-hidden":"true",className:"w-xs h-auto mask-radial-[100%_100%] mask-radial-from-20% mask-radial-to-50% mask-radial-at-center"}),title:t,description:e,actions:m.jsxs(m.Fragment,{children:[m.jsxs($e,{variant:"outline",onClick:f,disabled:r,children:[m.jsx("img",{src:Jd,alt:"OpenRouter",className:"size-4"}),r?"Installing...":"Install OpenRouter"]}),m.jsx($e,{variant:"outline",onClick:d,children:"Install Connection"})]})})}function H_(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5);return i<1?"now":i<60?`${i}m`:`${s}h`}function j_(t){const e=new Date,n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-7*864e5),s=new Date(n.getTime()-30*864e5),a=[],u=[],l=[],o=[],d=[];for(const p of t){const h=new Date(p.updated_at);h>=n?a.push(p):h>=r?u.push(p):h>=i?l.push(p):h>=s?o.push(p):d.push(p)}const f=[];return a.length>0&&f.push({label:"Today",threads:a,showRelativeTime:!0}),u.length>0&&f.push({label:"Yesterday",threads:u,showRelativeTime:!1}),l.length>0&&f.push({label:"7 days ago",threads:l,showRelativeTime:!1}),o.length>0&&f.push({label:"30 days ago",threads:o,showRelativeTime:!1}),d.length>0&&f.push({label:"Older",threads:d,showRelativeTime:!1}),f}function z_(t){const e=Q.c(49),{variant:n}=t,r=n===void 0?"icon":n,{threads:i,refetch:s}=jo(),{activeThreadId:a,setActiveThreadId:u,hideThread:l}=An(),[o,d]=j.useState("");let f,p,h,g,_,x,E,C,b,w,O,I;if(e[0]!==a||e[1]!==l||e[2]!==s||e[3]!==o||e[4]!==u||e[5]!==i||e[6]!==r){const $=o.trim()?i.filter(K=>(K.title||"New chat").toLowerCase().includes(o.toLowerCase())):i,X=j_($);let q;e[19]!==s?(q=K=>{K?s():d("")},e[19]=s,e[20]=q):q=e[20];const U=q;g=hs,h=yn,p=or,w=U,e[21]!==r?(O=m.jsx(_n,{asChild:!0,children:m.jsx(ar,{asChild:!0,children:r==="outline"?m.jsx($e,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input","aria-label":"Chat history",children:m.jsx(na,{size:16})}):m.jsx($e,{type:"button",variant:"ghost",size:"icon",className:"size-6 p-1 hover:bg-transparent","aria-label":"Chat history",children:m.jsx(na,{size:16,className:"text-muted-foreground hover:text-foreground transition-colors"})})})}),e[21]=r,e[22]=O):O=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(I=m.jsx(xn,{children:"Chat history"}),e[23]=I):I=e[23],f=ur,E="end",C="w-80 p-0";let G;e[24]===Symbol.for("react.memo_cache_sentinel")?(G=m.jsx(qr,{size:16,className:"text-muted-foreground shrink-0"}),e[24]=G):G=e[24];let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=K=>d(K.target.value),e[25]=V):V=e[25],e[26]!==o?(b=m.jsx("div",{className:"border-b",children:m.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[G,m.jsx("input",{type:"text",placeholder:"Search chats...",value:o,onChange:V,className:"flex-1 border-0 shadow-none focus:outline-none px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),e[26]=o,e[27]=b):b=e[27],_="max-h-[300px] overflow-y-auto",x=$.length===0?m.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:o.trim()?"No chats found":"No chats yet"}):X.map((K,J)=>m.jsxs("div",{children:[J>0&&m.jsx("div",{className:"border-t mx-3"}),m.jsx("div",{className:"px-3 py-1",children:m.jsx("span",{className:"text-xs font-medium text-muted-foreground tracking-wide",children:K.label})}),K.threads.map(A=>{const re=A.id===a;return m.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 hover:bg-accent cursor-pointer group ${re?"bg-accent/50":""}`,onClick:()=>u(A.id),children:[m.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[m.jsx("span",{className:"text-sm truncate",children:A.title||"New chat"}),m.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:re?"current":K.showRelativeTime?H_(A.updated_at):null})]}),m.jsx("button",{type:"button",onClick:he=>{he.stopPropagation(),l(A.id)},className:"opacity-0 cursor-pointer group/trash group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",title:"Remove chat",children:m.jsx(rf,{size:14,className:"text-muted-foreground group-hover/trash:text-destructive"})})]},A.id)})]},K.label)),e[0]=a,e[1]=l,e[2]=s,e[3]=o,e[4]=u,e[5]=i,e[6]=r,e[7]=f,e[8]=p,e[9]=h,e[10]=g,e[11]=_,e[12]=x,e[13]=E,e[14]=C,e[15]=b,e[16]=w,e[17]=O,e[18]=I}else f=e[7],p=e[8],h=e[9],g=e[10],_=e[11],x=e[12],E=e[13],C=e[14],b=e[15],w=e[16],O=e[17],I=e[18];let D;e[28]!==_||e[29]!==x?(D=m.jsx("div",{className:_,children:x}),e[28]=_,e[29]=x,e[30]=D):D=e[30];let B;e[31]!==f||e[32]!==D||e[33]!==E||e[34]!==C||e[35]!==b?(B=m.jsxs(f,{align:E,className:C,children:[b,D]}),e[31]=f,e[32]=D,e[33]=E,e[34]=C,e[35]=b,e[36]=B):B=e[36];let P;e[37]!==p||e[38]!==B||e[39]!==w||e[40]!==O||e[41]!==I?(P=m.jsxs(p,{onOpenChange:w,children:[O,I,B]}),e[37]=p,e[38]=B,e[39]=w,e[40]=O,e[41]=I,e[42]=P):P=e[42];let S;e[43]!==h||e[44]!==P?(S=m.jsx(h,{children:P}),e[43]=h,e[44]=P,e[45]=S):S=e[45];let M;return e[46]!==g||e[47]!==S?(M=m.jsx(g,{children:S}),e[46]=g,e[47]=S,e[48]=M):M=e[48],M}function $_(){const t=Q.c(7);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsxs("div",{className:"flex items-center gap-3",children:[e,m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),m.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),t[1]=n):n=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:m.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,m.jsxs("div",{className:"flex items-end gap-2",children:[m.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),m.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),t[2]=r):r=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:m.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[m.jsx(kr,{align:"right",width:"w-3/4"}),m.jsx(kr,{align:"left",width:"w-full",lines:3}),m.jsx(kr,{align:"right",width:"w-2/3"}),m.jsx(kr,{align:"left",width:"w-5/6",lines:2})]})}),t[3]=i):i=t[3];let s;t[4]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:m.jsx("div",{className:"relative flex-1",children:m.jsxs("div",{className:"space-y-2 p-2",children:[m.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),m.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),t[4]=s):s=t[4];let a;t[5]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"flex items-center gap-1",children:m.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),t[5]=a):a=t[5];let u;return t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsxs("div",{className:"flex h-full w-full flex-col bg-sidebar",children:[r,i,m.jsx("div",{className:"px-4 py-4",children:m.jsx("div",{className:"mx-auto w-full max-w-2xl",children:m.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl border border-border bg-background shadow-sm",children:[s,m.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[a,m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),m.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})})]}),t[6]=u):u=t[6],u}function kr(t){const e=Q.c(22),{align:n,width:r,lines:i}=t,s=r===void 0?"w-full":r,a=i===void 0?1:i,u=n==="right"?"flex-row-reverse":"flex-row";let l;e[0]!==u?(l=ae("flex w-full gap-4 px-4 py-2",u),e[0]=u,e[1]=l):l=e[1];const o=n==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let d;e[2]!==o?(d=ae("flex min-w-0 flex-col gap-2",o),e[2]=o,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=f):f=e[4];const p=n==="right"?"bg-muted":"bg-transparent border border-border/40";let h;e[5]!==p||e[6]!==s?(h=ae("min-w-0 rounded-2xl p-4",p,s),e[5]=p,e[6]=s,e[7]=h):h=e[7];let g;e[8]!==a?(g=Array.from({length:a}),e[8]=a,e[9]=g):g=e[9];let _;e[10]!==a||e[11]!==g?(_=m.jsx("div",{className:"space-y-2",children:g.map((b,w)=>m.jsx("div",{className:ae("h-3 rounded bg-muted-foreground/20 animate-pulse",w===a-1?"w-3/4":"w-full"),style:{animationDelay:`${w*.1}s`}},w))}),e[10]=a,e[11]=g,e[12]=_):_=e[12];let x;e[13]!==_||e[14]!==h?(x=m.jsx("div",{className:h,children:_}),e[13]=_,e[14]=h,e[15]=x):x=e[15];let E;e[16]!==x||e[17]!==d?(E=m.jsxs("div",{className:d,children:[f,x]}),e[16]=x,e[17]=d,e[18]=E):E=e[18];let C;return e[19]!==E||e[20]!==l?(C=m.jsx("div",{className:l,children:E}),e[19]=E,e[20]=l,e[21]=C):C=e[21],C}function Y_({messageCount:t,sentinelRef:e}){const n=j.useRef(t),r=j.useRef(0);t>n.current&&r.current!==t&&queueMicrotask(()=>{e.current?.scrollIntoView({behavior:"smooth",block:"start"}),r.current=t}),n.current=t}function zu(t,e){const n=j.Children.toArray(t);for(const r of n)if(j.isValidElement(r)&&r.type===e)return r;return null}function q_(t){const e=Q.c(5),{className:n,children:r}=t;let i;e[0]!==n?(i=ae("flex flex-col h-full w-full bg-sidebar transform-[translateZ(0)]",n),e[0]=n,e[1]=i):i=e[1];let s;return e[2]!==r||e[3]!==i?(s=m.jsx("div",{className:i,children:r}),e[2]=r,e[3]=i,e[4]=s):s=e[4],s}function V_(t){const e=Q.c(11),{children:n}=t;let r;e[0]!==n?(r=zu(n,nd),e[0]=n,e[1]=r):r=e[1];const i=r;let s;e[2]!==n?(s=zu(n,rd),e[2]=n,e[3]=s):s=e[3];const a=s,u=i?.props.children;let l;e[4]!==u?(l=m.jsx("div",{className:"flex items-center gap-2",children:u}),e[4]=u,e[5]=l):l=e[5];const o=a?.props.children;let d;e[6]!==o?(d=m.jsx("div",{className:"flex items-center gap-1",children:o}),e[6]=o,e[7]=d):d=e[7];let f;return e[8]!==l||e[9]!==d?(f=m.jsxs("div",{className:"flex h-12 items-center justify-between border-b border-border px-4 flex-none",children:[l,d]}),e[8]=l,e[9]=d,e[10]=f):f=e[10],f}function nd(t){const e=Q.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx(m.Fragment,{children:n}),e[0]=n,e[1]=r):r=e[1],r}function rd(t){const e=Q.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx(m.Fragment,{children:n}),e[0]=n,e[1]=r):r=e[1],r}function W_(t){const e=Q.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=ae("flex-1 min-h-0 overflow-y-auto",r),e[0]=r,e[1]=i):i=e[1];let s;return e[2]!==n||e[3]!==i?(s=m.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=s):s=e[4],s}function G_(t){const e=Q.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:n}),e[0]=n,e[1]=r):r=e[1],r}function Q_(t){const e=Q.c(12),{minHeightOffset:n}=t,r=n===void 0?240:n,{messages:i,chatStatus:s}=An(),a=j.useRef(null);let u;e[0]!==i.length?(u={messageCount:i.length,sentinelRef:a},e[0]=i.length,e[1]=u):u=e[1],Y_(u);let l;if(e[2]!==i||e[3]!==s){let f;e[5]!==i.length||e[6]!==s?(f=(p,h)=>p.role==="user"?m.jsx(F_,{message:p},p.id):p.role==="assistant"?m.jsx(S_,{message:p,status:h===i.length-1?s:void 0},p.id):null,e[5]=i.length,e[6]=s,e[7]=f):f=e[7],l=i.map(f),e[2]=i,e[3]=s,e[4]=l}else l=e[4];let o;e[8]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx(td,{children:m.jsx("div",{ref:a,className:"h-0"})}),e[8]=o):o=e[8];let d;return e[9]!==r||e[10]!==l?(d=m.jsxs(L_,{minHeightOffset:r,children:[l,o]}),e[9]=r,e[10]=l,e[11]=d):d=e[11],d}function X_(t){const e=Q.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=ae("flex-none w-full mx-auto p-2","max-w-2xl min-w-0",r),e[0]=r,e[1]=i):i=e[1];let s;return e[2]!==n||e[3]!==i?(s=m.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=s):s=e[4],s}function vi(t){const e=Q.c(24),{title:n,description:r,icon:i,variant:s,onDismiss:a,children:u}=t,l=s===void 0?"default":s;let o,d,f,p,h;if(e[0]!==u||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==l){const b={default:{container:"border-muted-foreground/30 bg-muted/50 hover:bg-muted transition-colors",icon:"text-muted-foreground",title:"text-muted-foreground",description:"text-muted-foreground/70"},danger:{container:"border-destructive/30 bg-destructive/5",icon:"text-destructive",title:"text-destructive font-medium",description:"text-muted-foreground"},warning:{container:"border-amber-500/30 bg-amber-500/5",icon:"text-amber-600 dark:text-amber-500",title:"text-amber-600 dark:text-amber-500 font-medium",description:"text-muted-foreground"}}[l];p=ae("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full",b.container),h=i&&m.jsx("div",{className:ae("mt-0.5 shrink-0",b.icon),children:i}),o="flex-1 min-w-0",d=n&&m.jsx("div",{className:ae("text-xs mb-1",b.title),children:n}),f=r&&m.jsx("div",{className:ae("text-xs line-clamp-2",b.description,u?"mb-2":""),children:r}),e[0]=u,e[1]=r,e[2]=i,e[3]=n,e[4]=l,e[5]=o,e[6]=d,e[7]=f,e[8]=p,e[9]=h}else o=e[5],d=e[6],f=e[7],p=e[8],h=e[9];let g;e[10]!==u?(g=u&&m.jsx("div",{className:"flex gap-2",children:u}),e[10]=u,e[11]=g):g=e[11];let _;e[12]!==o||e[13]!==d||e[14]!==f||e[15]!==g?(_=m.jsxs("div",{className:o,children:[d,f,g]}),e[12]=o,e[13]=d,e[14]=f,e[15]=g,e[16]=_):_=e[16];let x;e[17]!==a?(x=a&&m.jsx("button",{type:"button",onClick:a,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:m.jsx(xd,{size:14})}),e[17]=a,e[18]=x):x=e[18];let E;return e[19]!==p||e[20]!==h||e[21]!==_||e[22]!==x?(E=m.jsxs("div",{className:p,children:[h,_,x]}),e[19]=p,e[20]=h,e[21]=_,e[22]=x,e[23]=E):E=e[23],E}const By=Object.assign(q_,{Header:Object.assign(V_,{Left:nd,Right:rd}),Main:W_,Messages:Q_,EmptyState:G_,Footer:X_,Input:L0,Provider:y0,Skeleton:$_,IceBreakers:F0,NoLlmBindingEmptyState:U_,ThreadHistoryPopover:z_});export{By as C,n0 as G,E0 as M,g_ as R,ze as S,Py as T,An as a,Yo as b,ao as c,Dy as d,My as e,Ju as i,sf as u};