@decocms/mesh 2.10.0 → 2.11.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 (118) hide show
  1. package/dist/client/assets/{AlertCircle-BI-lv-P2.js → AlertCircle-C-YsmNug.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-WX776rGw.js → ArrowLeft-I0eE0ajz.js} +1 -1
  3. package/dist/client/assets/{Check-Dh23dmDM.js → Check-Bn7iaq_h.js} +1 -1
  4. package/dist/client/assets/{ChevronDown-CQl6wdMq.js → ChevronDown-CXsTFOR4.js} +1 -1
  5. package/dist/client/assets/{Clock-C2L66fjj.js → Clock-7YlOAEqw.js} +1 -1
  6. package/dist/client/assets/{Code01-BvYrq72o.js → Code01-Dp2-HwWV.js} +1 -1
  7. package/dist/client/assets/{Copy01-BX4_oHqx.js → Copy01-Cufxb7u1.js} +1 -1
  8. package/dist/client/assets/{DotsHorizontal-9lU8MC-X.js → DotsHorizontal-Cq3m_A8z.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-BBtotCm7.js → DotsVertical-BIpduKLf.js} +1 -1
  10. package/dist/client/assets/{File06-lv7rH_v1.js → File06-DD5RANl_.js} +1 -1
  11. package/dist/client/assets/{FilterLines-WZSp93Oe.js → FilterLines-1Ine1y4n.js} +1 -1
  12. package/dist/client/assets/{FlipBackward-CqqvNJYu.js → FlipBackward-DBqfxU3c.js} +1 -1
  13. package/dist/client/assets/{GitBranch01-DN-LFsG4.js → GitBranch01-BHo3ByP2.js} +1 -1
  14. package/dist/client/assets/{Grid01-bigl9l-5.js → Grid01-C578o4mm.js} +1 -1
  15. package/dist/client/assets/{Inbox01-BIZdM9VF.js → Inbox01-BtHWN2dX.js} +1 -1
  16. package/dist/client/assets/{InfoCircle-FggQ2WMl.js → InfoCircle-BkGKY7qc.js} +1 -1
  17. package/dist/client/assets/{Key01-BHIpjeh2.js → Key01-DYP1HQKa.js} +1 -1
  18. package/dist/client/assets/{LinkExternal01-YcVnQhq1.js → LinkExternal01-d5tCjGRk.js} +1 -1
  19. package/dist/client/assets/{Loading01-nz4zkIiQ.js → Loading01-BGeWv0Kv.js} +1 -1
  20. package/dist/client/assets/{Lock01-DJbaRRVq.js → Lock01-jWWo80rN.js} +1 -1
  21. package/dist/client/assets/{Play-Dy3YBriV.js → Play-B3EbuXEZ.js} +1 -1
  22. package/dist/client/assets/{Plus-DRzcJPy4.js → Plus-CgN71ZpK.js} +1 -1
  23. package/dist/client/assets/{SearchMd-CGgWiIHk.js → SearchMd-u2U3iAnY.js} +1 -1
  24. package/dist/client/assets/{Terminal-DDxodu0O.js → Terminal-Fj__rdxn.js} +1 -1
  25. package/dist/client/assets/{Trash01-Nn4emH5w.js → Trash01-Vutqn1RC.js} +1 -1
  26. package/dist/client/assets/{X-CSDtf13Z.js → X-P1RHfgBU.js} +1 -1
  27. package/dist/client/assets/{XClose-Da4Q_9Br.js → XClose-DeI9b46h.js} +1 -1
  28. package/dist/client/assets/{alert-dialog-BrdP9Xiy.js → alert-dialog-BApkfnBU.js} +1 -1
  29. package/dist/client/assets/{auth-BkX07Kdp.js → auth-B4yoGafc.js} +1 -1
  30. package/dist/client/assets/{auth-catchall-CgZMKj4U.js → auth-catchall-CbILVwsO.js} +1 -1
  31. package/dist/client/assets/{avatar-DVkpHhcq.js → avatar-HUmJyCrO.js} +1 -1
  32. package/dist/client/assets/{badge-DZOpuutl.js → badge-_9VZKl7s.js} +1 -1
  33. package/dist/client/assets/{card-VaGCmdRN.js → card-DUrBojml.js} +1 -1
  34. package/dist/client/assets/{checkbox-B6_pb64c.js → checkbox-y4VvHU-Y.js} +1 -1
  35. package/dist/client/assets/{collection-detail-BZTq36Jq.js → collection-detail-o5P4OEwm.js} +2 -2
  36. package/dist/client/assets/{collection-display-button-0kCgwjcX.js → collection-display-button-D_pspwv8.js} +1 -1
  37. package/dist/client/assets/{collection-header-C5jLEW4T.js → collection-header-DjAukiYw.js} +1 -1
  38. package/dist/client/assets/{collection-page-BxN-pfZ4.js → collection-page-DUwIO-4_.js} +1 -1
  39. package/dist/client/assets/{collection-search-DCk3URyd.js → collection-search-C8qrPxpe.js} +1 -1
  40. package/dist/client/assets/{collection-tab-BK4lXf-5.js → collection-tab-BtKR4Bs-.js} +1 -1
  41. package/dist/client/assets/{collection-table-wrapper-DbtYisXO.js → collection-table-wrapper-m6-zCmZ8.js} +1 -1
  42. package/dist/client/assets/{connection-card-CtcQXchE.js → connection-card-Bho36DLV.js} +1 -1
  43. package/dist/client/assets/connection-detail-DzUkx3x6.js +1 -0
  44. package/dist/client/assets/{connections-BkTTX2-6.js → connections-CGjqBYcN.js} +1 -1
  45. package/dist/client/assets/constants-CDd5Bb9b.js +1 -0
  46. package/dist/client/assets/{create-organization-dialog-BcohdvN6.js → create-organization-dialog-DJCSaeq_.js} +1 -1
  47. package/dist/client/assets/{dialog-rGW8NOdv.js → dialog-DPjf1g07.js} +1 -1
  48. package/dist/client/assets/{dropdown-menu-DEdU2p2E.js → dropdown-menu-JqpADJWR.js} +1 -1
  49. package/dist/client/assets/{empty-state-C6fFQCSt.js → empty-state-B1YgYZRX.js} +1 -1
  50. package/dist/client/assets/{env-vars-editor-DtIOMaFz.js → env-vars-editor-58M0X5HW.js} +1 -1
  51. package/dist/client/assets/{error-boundary-B28JvE1I.js → error-boundary-swyLIuj9.js} +1 -1
  52. package/dist/client/assets/{extract-connection-data-fJTZE6Hc.js → extract-connection-data-yHByD-hG.js} +1 -1
  53. package/dist/client/assets/{form-CE1tfcze.js → form-BNePwzri.js} +1 -1
  54. package/dist/client/assets/gateway-detail-7_rs5-Bk.js +1 -0
  55. package/dist/client/assets/gateways-LhzXTNdU.js +1 -0
  56. package/dist/client/assets/{home-lONkAboE.js → home-Dge_UN-5.js} +1 -1
  57. package/dist/client/assets/{index-CGbuv4sL.js → index-CZYkP-qE.js} +1 -1
  58. package/dist/client/assets/{index-Dc4mPG7D.js → index-D825aBGT.js} +2 -2
  59. package/dist/client/assets/{index-CJEYCkTv.js → index-Dd-uCtJP.js} +1 -1
  60. package/dist/client/assets/{index-DjBifmxL.js → index-DfsK7wxC.js} +31 -31
  61. package/dist/client/assets/{index-B-_GLG4a.js → index-sXi95TSr.js} +1 -1
  62. package/dist/client/assets/{input-CLQFaB_P.js → input-CUSLU-5Y.js} +1 -1
  63. package/dist/client/assets/{layout-D-qTqL0P.js → layout-DiLh4D4s.js} +1 -1
  64. package/dist/client/assets/{lazy-highlighter-CM_r6Qg6.js → lazy-highlighter-Bva2qxQ8.js} +1 -1
  65. package/dist/client/assets/{localstorage-keys-Csxol0-8.js → localstorage-keys-DCk__Bcu.js} +1 -1
  66. package/dist/client/assets/{login-CY0fBMtA.js → login-5v9kcVjq.js} +1 -1
  67. package/dist/client/assets/{mcp-oauth-DwoWo555.js → mcp-oauth-2LWG2fNF.js} +1 -1
  68. package/dist/client/assets/{mcp-server-detail-BfkMNCXA.js → mcp-server-detail-Bl4-1OcQ.js} +1 -1
  69. package/dist/client/assets/{members-DlfrW4qm.js → members-DUjkcn9b.js} +1 -1
  70. package/dist/client/assets/{monaco-editor-CGmVJ7Sz.js → monaco-editor-CXJFCG3L.js} +1 -1
  71. package/dist/client/assets/{monitoring-8m7n1ABH.js → monitoring-BxS1M7G9.js} +5 -5
  72. package/dist/client/assets/{oauth-callback-C3UTt1IM.js → oauth-callback-D352dL7W.js} +1 -1
  73. package/dist/client/assets/{page-CjTfwiJs.js → page-DJ2XmEDk.js} +1 -1
  74. package/dist/client/assets/page-DlLPoWnp.js +35 -0
  75. package/dist/client/assets/{pin-to-sidebar-button-DmlmCu_p.js → pin-to-sidebar-button-CxO4Rtia.js} +1 -1
  76. package/dist/client/assets/{popover-Bt6Irkfs.js → popover-CiuXmEMm.js} +1 -1
  77. package/dist/client/assets/{project-context-provider-jIErvTKU.js → project-context-provider-Y7j1MLG3.js} +1 -1
  78. package/dist/client/assets/{resizable-BDACILOB.js → resizable-CpuhJlAj.js} +1 -1
  79. package/dist/client/assets/{resource-tabs-B9UXtdu9.js → resource-tabs-DzYdyOT8.js} +1 -1
  80. package/dist/client/assets/{select-CXOQrDyU.js → select-BiK6lA7A.js} +1 -1
  81. package/dist/client/assets/{settings-Cml1v0xs.js → settings-BydLLEEd.js} +1 -1
  82. package/dist/client/assets/shell-layout-hT1WnhFU.js +3 -0
  83. package/dist/client/assets/{spinner-C-rDsJGC.js → spinner-D8JOERWZ.js} +1 -1
  84. package/dist/client/assets/{switch-C2oVrx7C.js → switch-CHSRGx1X.js} +1 -1
  85. package/dist/client/assets/{textarea-DxDFaLzd.js → textarea-DA688jdJ.js} +1 -1
  86. package/dist/client/assets/{thread-history-popover-D_x2TXEl.js → thread-history-popover-d49eUsmE.js} +13 -13
  87. package/dist/client/assets/{tool-set-selector-B03cDU_f.js → tool-set-selector-qCxd45H-.js} +1 -1
  88. package/dist/client/assets/{tools-list-CCvCpz3e.js → tools-list-aRycV8Sk.js} +1 -1
  89. package/dist/client/assets/{use-binding-C_WCv3Kw.js → use-binding-pQGzNysE.js} +1 -1
  90. package/dist/client/assets/{use-connection-D1oWmd80.js → use-connection-CJ5nWy0c.js} +1 -1
  91. package/dist/client/assets/{use-connection-resources-DAy5w-Ms.js → use-connection-resources-CrBNfIuI.js} +1 -1
  92. package/dist/client/assets/use-gateway-Cov2sDNb.js +1 -0
  93. package/dist/client/assets/{use-gateway-system-prompt-B0FWJC8i.js → use-gateway-system-prompt-D3bv_TPR.js} +1 -1
  94. package/dist/client/assets/{use-list-state-D9IMsf4Z.js → use-list-state-CUahB2OC.js} +1 -1
  95. package/dist/client/assets/{use-mcp-BSK2ddKq.js → use-mcp-Wds2Jlc5.js} +1 -1
  96. package/dist/client/assets/{use-members-BrVgN1Nv.js → use-members-BlHxrgPJ.js} +1 -1
  97. package/dist/client/assets/{use-mobile-BmTi-FB3.js → use-mobile-DSucR6ge.js} +1 -1
  98. package/dist/client/assets/{use-organization-settings-DPGpmRIO.js → use-organization-settings-zICyumVv.js} +1 -1
  99. package/dist/client/assets/{use-tool-call-B5UsmKnA.js → use-tool-call-CS4qR4o3.js} +1 -1
  100. package/dist/client/assets/useQuery-El_kGGDY.js +1 -0
  101. package/dist/client/assets/{value-Duay7dd7.js → value-BHNPJ9GX.js} +1 -1
  102. package/dist/client/assets/{view-mode-toggle-Q_4Hio7O.js → view-mode-toggle-Do1cIl7g.js} +1 -1
  103. package/dist/client/assets/well-known-mcp-D13f-8h2.js +1 -0
  104. package/dist/client/assets/{workflow-C6xPZGlX.js → workflow-C_xTbZed.js} +1 -1
  105. package/dist/client/index.html +1 -1
  106. package/dist/server/cli.js +145 -145
  107. package/dist/server/migrate.js +129 -129
  108. package/dist/server/server.js +140 -140
  109. package/package.json +1 -1
  110. package/dist/client/assets/connection-detail-Dtnc6jAX.js +0 -1
  111. package/dist/client/assets/constants-D7HtiX2k.js +0 -1
  112. package/dist/client/assets/gateway-detail-DpvUxeca.js +0 -1
  113. package/dist/client/assets/gateways-DPTsKKk2.js +0 -1
  114. package/dist/client/assets/page-Cm8i9onu.js +0 -35
  115. package/dist/client/assets/shell-layout-BC-hIRVP.js +0 -3
  116. package/dist/client/assets/use-gateway-DEBoqh3W.js +0 -1
  117. package/dist/client/assets/useQuery-CjN7yze9.js +0 -1
  118. package/dist/client/assets/well-known-mcp-7PcWXInp.js +0 -1
@@ -1 +1 @@
1
- import{r as c,ac as B,j as i,ad as C,aa as y,ai as I,af as M,aT as H,aS as z,c as A}from"./index-Dc4mPG7D.js";import{c as g}from"./input-CLQFaB_P.js";var b="Switch",[U]=B(b),[q,L]=U(b),E=c.forwardRef((s,e)=>{const{__scopeSwitch:t,name:r,checked:a,defaultChecked:n,required:o,disabled:d,value:u="on",onCheckedChange:k,form:l,...w}=s,[p,h]=c.useState(null),v=y(e,m=>h(m)),S=c.useRef(!1),x=p?l||!!p.closest("form"):!0,[f,N]=I({prop:a,defaultProp:n??!1,onChange:k,caller:b});return i.jsxs(q,{scope:t,checked:f,disabled:d,children:[i.jsx(C.button,{type:"button",role:"switch","aria-checked":f,"aria-required":o,"data-state":j(f),"data-disabled":d?"":void 0,disabled:d,value:u,...w,ref:v,onClick:M(s.onClick,m=>{N(T=>!T),x&&(S.current=m.isPropagationStopped(),S.current||m.stopPropagation())})}),x&&i.jsx(_,{control:p,bubbles:!S.current,name:r,value:u,checked:f,required:o,disabled:d,form:l,style:{transform:"translateX(-100%)"}})]})});E.displayName=b;var P="SwitchThumb",R=c.forwardRef((s,e)=>{const{__scopeSwitch:t,...r}=s,a=L(P,t);return i.jsx(C.span,{"data-state":j(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});R.displayName=P;var O="SwitchBubbleInput",_=c.forwardRef(({__scopeSwitch:s,control:e,checked:t,bubbles:r=!0,...a},n)=>{const o=c.useRef(null),d=y(o,n),u=H(t),k=z(e);return c.useEffect(()=>{const l=o.current;if(!l)return;const w=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==t&&h){const v=new Event("click",{bubbles:r});h.call(l,t),l.dispatchEvent(v)}},[u,t,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...a,tabIndex:-1,ref:d,style:{...a.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});_.displayName=O;function j(s){return s?"checked":"unchecked"}var $=E,D=R;function X(s){const e=A.c(9);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),e[3]=t,e[4]=a):a=e[4];let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(D,{"data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")}),e[5]=n):n=e[5];let o;return e[6]!==r||e[7]!==a?(o=i.jsx($,{"data-slot":"switch",className:a,...r,children:n}),e[6]=r,e[7]=a,e[8]=o):o=e[8],o}export{X as S};
1
+ import{r as c,ac as B,j as i,ad as C,aa as y,ai as I,af as M,aT as H,aS as z,c as A}from"./index-D825aBGT.js";import{c as g}from"./input-CUSLU-5Y.js";var b="Switch",[U]=B(b),[q,L]=U(b),E=c.forwardRef((s,e)=>{const{__scopeSwitch:t,name:r,checked:a,defaultChecked:n,required:o,disabled:d,value:u="on",onCheckedChange:k,form:l,...w}=s,[p,h]=c.useState(null),v=y(e,m=>h(m)),S=c.useRef(!1),x=p?l||!!p.closest("form"):!0,[f,N]=I({prop:a,defaultProp:n??!1,onChange:k,caller:b});return i.jsxs(q,{scope:t,checked:f,disabled:d,children:[i.jsx(C.button,{type:"button",role:"switch","aria-checked":f,"aria-required":o,"data-state":j(f),"data-disabled":d?"":void 0,disabled:d,value:u,...w,ref:v,onClick:M(s.onClick,m=>{N(T=>!T),x&&(S.current=m.isPropagationStopped(),S.current||m.stopPropagation())})}),x&&i.jsx(_,{control:p,bubbles:!S.current,name:r,value:u,checked:f,required:o,disabled:d,form:l,style:{transform:"translateX(-100%)"}})]})});E.displayName=b;var P="SwitchThumb",R=c.forwardRef((s,e)=>{const{__scopeSwitch:t,...r}=s,a=L(P,t);return i.jsx(C.span,{"data-state":j(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});R.displayName=P;var O="SwitchBubbleInput",_=c.forwardRef(({__scopeSwitch:s,control:e,checked:t,bubbles:r=!0,...a},n)=>{const o=c.useRef(null),d=y(o,n),u=H(t),k=z(e);return c.useEffect(()=>{const l=o.current;if(!l)return;const w=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==t&&h){const v=new Event("click",{bubbles:r});h.call(l,t),l.dispatchEvent(v)}},[u,t,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...a,tabIndex:-1,ref:d,style:{...a.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});_.displayName=O;function j(s){return s?"checked":"unchecked"}var $=E,D=R;function X(s){const e=A.c(9);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),e[3]=t,e[4]=a):a=e[4];let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(D,{"data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")}),e[5]=n):n=e[5];let o;return e[6]!==r||e[7]!==a?(o=i.jsx($,{"data-slot":"switch",className:a,...r,children:n}),e[6]=r,e[7]=a,e[8]=o):o=e[8],o}export{X as S};
@@ -1 +1 @@
1
- import{c as o,j as n}from"./index-Dc4mPG7D.js";import{c as l}from"./input-CLQFaB_P.js";function u(s){const e=o.c(8);let r,i;e[0]!==s?({className:r,...i}=s,e[0]=s,e[1]=r,e[2]=i):(r=e[1],i=e[2]);let t;e[3]!==r?(t=l("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-xl border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),e[3]=r,e[4]=t):t=e[4];let a;return e[5]!==i||e[6]!==t?(a=n.jsx("textarea",{"data-slot":"textarea",className:t,...i}),e[5]=i,e[6]=t,e[7]=a):a=e[7],a}export{u as T};
1
+ import{c as o,j as n}from"./index-D825aBGT.js";import{c as l}from"./input-CUSLU-5Y.js";function u(s){const e=o.c(8);let r,i;e[0]!==s?({className:r,...i}=s,e[0]=s,e[1]=r,e[2]=i):(r=e[1],i=e[2]);let t;e[3]!==r?(t=l("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-xl border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),e[3]=r,e[4]=t):t=e[4];let a;return e[5]!==i||e[6]!==t?(a=n.jsx("textarea",{"data-slot":"textarea",className:t,...i}),e[5]=i,e[6]=t,e[7]=a):a=e[7],a}export{u as T};
@@ -1,14 +1,14 @@
1
- import{c as W,j as m,s as sa,d as ra,K as _t,t as Ze,E as na,F as oa,H as $,w as h,_ as Re,I as wt,J as ia,L as la,M as ca,Q as Z,U as be,V as Ee,v as M,W as x,X,Y as ua,Z as O,$ as da,a0 as pa,r as J,k as ma,p as fa,f as ha}from"./index-Dc4mPG7D.js";import{c as he,B as Me}from"./input-CLQFaB_P.js";import{u as Et,c as qe,b as Je,T as We,a as It}from"./project-context-provider-jIErvTKU.js";import{E as ga}from"./use-binding-C_WCv3Kw.js";import{l as va,m as ya,n as ba,o as xa}from"./index-DjBifmxL.js";import{u as _a}from"./localstorage-keys-Csxol0-8.js";import{u as wa}from"./use-gateway-DEBoqh3W.js";import{u as Ea}from"./use-gateway-system-prompt-B0FWJC8i.js";import{P as St,a as Nt,b as Tt}from"./popover-Bt6Irkfs.js";import{a as Ia,E as Sa}from"./use-connection-D1oWmd80.js";import{O as Na,a as Ta,g as Aa}from"./well-known-mcp-7PcWXInp.js";import{g as Ca}from"./generate-id-Dyweu44Y.js";import{s as Xe}from"./Clock-C2L66fjj.js";import{i as Ra}from"./SearchMd-CGgWiIHk.js";import{s as Ma}from"./Trash01-Nn4emH5w.js";function Jr(){const t=W.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 a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=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]=a):a=t[1];let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=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:[a,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]=s):s=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=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(Te,{align:"right",width:"w-3/4"}),m.jsx(Te,{align:"left",width:"w-full",lines:3}),m.jsx(Te,{align:"right",width:"w-2/3"}),m.jsx(Te,{align:"left",width:"w-5/6",lines:2})]})}),t[3]=r):r=t[3];let n;t[4]===Symbol.for("react.memo_cache_sentinel")?(n=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]=n):n=t[4];let i;t[5]===Symbol.for("react.memo_cache_sentinel")?(i=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]=i):i=t[5];let o;return t[6]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsxs("div",{className:"flex h-full w-full flex-col bg-sidebar",children:[s,r,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:[n,m.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[i,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]=o):o=t[6],o}function Te(t){const e=W.c(22),{align:a,width:s,lines:r}=t,n=s===void 0?"w-full":s,i=r===void 0?1:r,o=a==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==o?(c=he("flex w-full gap-4 px-4 py-2",o),e[0]=o,e[1]=c):c=e[1];const l=a==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let p;e[2]!==l?(p=he("flex min-w-0 flex-col gap-2",l),e[2]=l,e[3]=p):p=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=u):u=e[4];const g=a==="right"?"bg-muted":"bg-transparent border border-border/40";let f;e[5]!==g||e[6]!==n?(f=he("min-w-0 rounded-2xl p-4",g,n),e[5]=g,e[6]=n,e[7]=f):f=e[7];let v;e[8]!==i?(v=Array.from({length:i}),e[8]=i,e[9]=v):v=e[9];let b;e[10]!==i||e[11]!==v?(b=m.jsx("div",{className:"space-y-2",children:v.map((d,T)=>m.jsx("div",{className:he("h-3 rounded bg-muted-foreground/20 animate-pulse",T===i-1?"w-3/4":"w-full"),style:{animationDelay:`${T*.1}s`}},T))}),e[10]=i,e[11]=v,e[12]=b):b=e[12];let y;e[13]!==b||e[14]!==f?(y=m.jsx("div",{className:f,children:b}),e[13]=b,e[14]=f,e[15]=y):y=e[15];let _;e[16]!==y||e[17]!==p?(_=m.jsxs("div",{className:p,children:[u,y]}),e[16]=y,e[17]=p,e[18]=_):_=e[18];let N;return e[19]!==_||e[20]!==c?(N=m.jsx("div",{className:c,children:_}),e[19]=_,e[20]=c,e[21]=N):N=e[21],N}var xe;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function a(r){throw new Error}t.assertNever=a,t.arrayToEnum=r=>{const n={};for(const i of r)n[i]=i;return n},t.getValidEnumValues=r=>{const n=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of n)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(n){return r[n]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const n=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&n.push(i);return n},t.find=(r,n)=>{for(const i of r)if(n(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,n=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}t.joinValues=s,t.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(xe||(xe={}));var Ke;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(Ke||(Ke={}));xe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);xe.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 Oe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(n){return n.message},s={_errors:[]},r=n=>{for(const i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(a(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(a(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return r(this),s}static assert(e){if(!(e instanceof Oe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,xe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),s=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];a[n]=a[n]||[],a[n].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}}Oe.create=t=>new Oe(t);var et;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(et||(et={}));var w;(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"})(w||(w={}));function Wr(){const t=W.c(5),e=sa(),{org:a}=Et();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},t[0]=s):s=t[0];const r=ra(s);let n;return t[1]!==a||t[2]!==r||t[3]!==e?(n=i=>{const c=i.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!c||!c[1])return;const l=c[1],p=r.connectionId;if(!p)return;e.invalidateQueries({queryKey:_t.collection(a.slug,p,l)});const u=l.toLowerCase().replace(/_/g," ");Ze.success(`${u} updated`)},t[1]=a,t[2]=r,t[3]=e,t[4]=n):n=t[4],n}var At="vercel.ai.error",Oa=Symbol.for(At),tt,at,ae=class Ct extends(at=Error,tt=Oa,at){constructor({name:e,message:a,cause:s}){super(a),this[tt]=!0,this.name=e,this.cause=s}static isInstance(e){return Ct.hasMarker(e,At)}static hasMarker(e,a){const s=Symbol.for(a);return e!=null&&typeof e=="object"&&s in e&&typeof e[s]=="boolean"&&e[s]===!0}};function Rt(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Mt="AI_InvalidArgumentError",Ot=`vercel.ai.error.${Mt}`,ja=Symbol.for(Ot),st,rt,Pa=class extends(rt=ae,st=ja,rt){constructor({message:t,cause:e,argument:a}){super({name:Mt,message:t,cause:e}),this[st]=!0,this.argument=a}static isInstance(t){return ae.hasMarker(t,Ot)}},jt="AI_JSONParseError",Pt=`vercel.ai.error.${jt}`,Da=Symbol.for(Pt),nt,ot,it=class extends(ot=ae,nt=Da,ot){constructor({text:t,cause:e}){super({name:jt,message:`JSON parsing failed: Text: ${t}.
2
- Error message: ${Rt(e)}`,cause:e}),this[nt]=!0,this.text=t}static isInstance(t){return ae.hasMarker(t,Pt)}},Dt="AI_TypeValidationError",kt=`vercel.ai.error.${Dt}`,ka=Symbol.for(kt),lt,ct,me=class $e extends(ct=ae,lt=ka,ct){constructor({value:e,cause:a}){super({name:Dt,message:`Type validation failed: Value: ${JSON.stringify(e)}.
3
- Error message: ${Rt(a)}`,cause:a}),this[lt]=!0,this.value=e}static isInstance(e){return ae.hasMarker(e,kt)}static wrap({value:e,cause:a}){return $e.isInstance(a)&&a.value===e?a:new $e({value:e,cause:a})}},Ie=({prefix:t,size:e=16,alphabet:a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const r=()=>{const n=a.length,i=new Array(e);for(let o=0;o<e;o++)i[o]=a[Math.random()*n|0];return i.join("")};if(t==null)return r;if(a.includes(s))throw new Pa({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${a}".`});return()=>`${t}${s}${r()}`},Za=Ie();function ut(t=globalThis){var e,a,s;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(s=(a=t.process)==null?void 0:a.versions)!=null&&s.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function ne(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((a,s)=>{e[s.toLowerCase()]=a});else{Array.isArray(t)||(t=Object.entries(t));for(const[a,s]of t)s!=null&&(e[a.toLowerCase()]=s)}return e}function dt(t,...e){const a=new Headers(ne(t)),s=a.get("user-agent")||"";return a.set("user-agent",[s,...e].filter(Boolean).join(" ")),Object.fromEntries(a.entries())}var $a=/"__proto__"\s*:/,La=/"constructor"\s*:/;function pt(t){const e=JSON.parse(t);return e===null||typeof e!="object"||$a.test(t)===!1&&La.test(t)===!1?e:Ua(e)}function Ua(t){let e=[t];for(;e.length;){const a=e;e=[];for(const s of a){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in s){const n=s[r];n&&typeof n=="object"&&e.push(n)}}}return t}function Fa(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return pt(t)}try{return pt(t)}finally{Error.stackTraceLimit=e}}function Ye(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:a}=t;if(a!=null)for(const s of Object.keys(a))a[s]=re(a[s])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(re):re(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(re)),t.allOf!=null&&(t.allOf=t.allOf.map(re)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(re));const{definitions:e}=t;if(e!=null)for(const a of Object.keys(e))e[a]=re(e[a]);return t}function re(t){return typeof t=="boolean"?t:Ye(t)}var Ba=Symbol("Let zodToJsonSchema decide on which parser to use"),mt={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"},za=t=>typeof t=="string"?{...mt,name:t}:{...mt,...t};function F(){return{}}function Va(t,e){var a,s,r;const n={type:"array"};return(a=t.type)!=null&&a._def&&((r=(s=t.type)==null?void 0:s._def)==null?void 0:r.typeName)!==w.ZodAny&&(n.items=R(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(n.minItems=t.minLength.value),t.maxLength&&(n.maxItems=t.maxLength.value),t.exactLength&&(n.minItems=t.exactLength.value,n.maxItems=t.exactLength.value),n}function qa(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function Ja(){return{type:"boolean"}}function Zt(t,e){return R(t.type._def,e)}var Wa=(t,e)=>R(t.innerType._def,e);function $t(t,e,a){const s=a??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,n)=>$t(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ya(t)}}var Ya=t=>{const e={type:"integer",format:"unix-time"};for(const a of t.checks)switch(a.kind){case"min":e.minimum=a.value;break;case"max":e.maximum=a.value;break}return e};function Ga(t,e){return{...R(t.innerType._def,e),default:t.defaultValue()}}function Ha(t,e){return e.effectStrategy==="input"?R(t.schema._def,e):F()}function Qa(t){return{type:"string",enum:Array.from(t.values)}}var Xa=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Ka(t,e){const a=[R(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),R(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(r=>!!r),s=[];return a.forEach(r=>{if(Xa(r))s.push(...r.allOf);else{let n=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:i,...o}=r;n=o}s.push(n)}}),s.length?{allOf:s}:void 0}function es(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 Pe=void 0,V={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:()=>(Pe===void 0&&(Pe=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pe),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 Lt(t,e){const a={type:"string"};if(t.checks)for(const s of t.checks)switch(s.kind){case"min":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value;break;case"max":a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"email":switch(e.emailStrategy){case"format:email":q(a,"email",s.message,e);break;case"format:idn-email":q(a,"idn-email",s.message,e);break;case"pattern:zod":k(a,V.email,s.message,e);break}break;case"url":q(a,"uri",s.message,e);break;case"uuid":q(a,"uuid",s.message,e);break;case"regex":k(a,s.regex,s.message,e);break;case"cuid":k(a,V.cuid,s.message,e);break;case"cuid2":k(a,V.cuid2,s.message,e);break;case"startsWith":k(a,RegExp(`^${De(s.value,e)}`),s.message,e);break;case"endsWith":k(a,RegExp(`${De(s.value,e)}$`),s.message,e);break;case"datetime":q(a,"date-time",s.message,e);break;case"date":q(a,"date",s.message,e);break;case"time":q(a,"time",s.message,e);break;case"duration":q(a,"duration",s.message,e);break;case"length":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value,a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"includes":{k(a,RegExp(De(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&q(a,"ipv4",s.message,e),s.version!=="v4"&&q(a,"ipv6",s.message,e);break}case"base64url":k(a,V.base64url,s.message,e);break;case"jwt":k(a,V.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&k(a,V.ipv4Cidr,s.message,e),s.version!=="v4"&&k(a,V.ipv6Cidr,s.message,e);break}case"emoji":k(a,V.emoji(),s.message,e);break;case"ulid":{k(a,V.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{q(a,"binary",s.message,e);break}case"contentEncoding:base64":{a.contentEncoding="base64";break}case"pattern:zod":{k(a,V.base64,s.message,e);break}}break}case"nanoid":k(a,V.nanoid,s.message,e)}return a}function De(t,e){return e.patternStrategy==="escape"?as(t):t}var ts=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function as(t){let e="";for(let a=0;a<t.length;a++)ts.has(t[a])||(e+="\\"),e+=t[a];return e}function q(t,e,a,s){var r;t.format||(r=t.anyOf)!=null&&r.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...a&&s.errorMessages&&{errorMessage:{format:a}}})):t.format=e}function k(t,e,a,s){var r;t.pattern||(r=t.allOf)!=null&&r.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:ft(e,s),...a&&s.errorMessages&&{errorMessage:{pattern:a}}})):t.pattern=ft(e,s)}function ft(t,e){var a;if(!e.applyRegexFlags||!t.flags)return t.source;const s={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},r=s.i?t.source.toLowerCase():t.source;let n="",i=!1,o=!1,c=!1;for(let l=0;l<r.length;l++){if(i){n+=r[l],i=!1;continue}if(s.i){if(o){if(r[l].match(/[a-z]/)){c?(n+=r[l],n+=`${r[l-2]}-${r[l]}`.toUpperCase(),c=!1):r[l+1]==="-"&&((a=r[l+2])!=null&&a.match(/[a-z]/))?(n+=r[l],c=!0):n+=`${r[l]}${r[l].toUpperCase()}`;continue}}else if(r[l].match(/[a-z]/)){n+=`[${r[l]}${r[l].toUpperCase()}]`;continue}}if(s.m){if(r[l]==="^"){n+=`(^|(?<=[\r
1
+ import{c as G,j as m,s as sa,d as ra,K as _t,t as Ze,E as na,F as oa,H as $,w as f,_ as Re,I as wt,J as ia,L as la,M as ca,Q as Z,U as be,V as Ee,v as M,W as x,X,Y as ua,Z as O,$ as da,a0 as pa,r as J,k as ma,p as ha,f as fa}from"./index-D825aBGT.js";import{c as fe,B as Me}from"./input-CUSLU-5Y.js";import{u as Et,c as qe,b as Je,T as We,a as It}from"./project-context-provider-Y7j1MLG3.js";import{E as ga}from"./use-binding-pQGzNysE.js";import{l as va,m as ya,n as ba,o as xa}from"./index-DfsK7wxC.js";import{u as _a}from"./use-gateway-Cov2sDNb.js";import{u as wa}from"./use-gateway-system-prompt-D3bv_TPR.js";import{P as St,a as Nt,b as Tt}from"./popover-CiuXmEMm.js";import{a as Ea,E as Ia}from"./use-connection-CJ5nWy0c.js";import{O as Sa,a as Na,g as Ta}from"./well-known-mcp-D13f-8h2.js";import{g as Aa}from"./generate-id-Dyweu44Y.js";import{s as Xe}from"./Clock-7YlOAEqw.js";import{i as Ca}from"./SearchMd-u2U3iAnY.js";import{s as Ra}from"./Trash01-Vutqn1RC.js";function zr(){const t=G.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 a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=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]=a):a=t[1];let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=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:[a,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]=s):s=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=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(Te,{align:"right",width:"w-3/4"}),m.jsx(Te,{align:"left",width:"w-full",lines:3}),m.jsx(Te,{align:"right",width:"w-2/3"}),m.jsx(Te,{align:"left",width:"w-5/6",lines:2})]})}),t[3]=r):r=t[3];let n;t[4]===Symbol.for("react.memo_cache_sentinel")?(n=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]=n):n=t[4];let i;t[5]===Symbol.for("react.memo_cache_sentinel")?(i=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]=i):i=t[5];let o;return t[6]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsxs("div",{className:"flex h-full w-full flex-col bg-sidebar",children:[s,r,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:[n,m.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[i,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]=o):o=t[6],o}function Te(t){const e=G.c(22),{align:a,width:s,lines:r}=t,n=s===void 0?"w-full":s,i=r===void 0?1:r,o=a==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==o?(c=fe("flex w-full gap-4 px-4 py-2",o),e[0]=o,e[1]=c):c=e[1];const l=a==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let p;e[2]!==l?(p=fe("flex min-w-0 flex-col gap-2",l),e[2]=l,e[3]=p):p=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=d):d=e[4];const g=a==="right"?"bg-muted":"bg-transparent border border-border/40";let h;e[5]!==g||e[6]!==n?(h=fe("min-w-0 rounded-2xl p-4",g,n),e[5]=g,e[6]=n,e[7]=h):h=e[7];let v;e[8]!==i?(v=Array.from({length:i}),e[8]=i,e[9]=v):v=e[9];let b;e[10]!==i||e[11]!==v?(b=m.jsx("div",{className:"space-y-2",children:v.map((u,T)=>m.jsx("div",{className:fe("h-3 rounded bg-muted-foreground/20 animate-pulse",T===i-1?"w-3/4":"w-full"),style:{animationDelay:`${T*.1}s`}},T))}),e[10]=i,e[11]=v,e[12]=b):b=e[12];let y;e[13]!==b||e[14]!==h?(y=m.jsx("div",{className:h,children:b}),e[13]=b,e[14]=h,e[15]=y):y=e[15];let _;e[16]!==y||e[17]!==p?(_=m.jsxs("div",{className:p,children:[d,y]}),e[16]=y,e[17]=p,e[18]=_):_=e[18];let N;return e[19]!==_||e[20]!==c?(N=m.jsx("div",{className:c,children:_}),e[19]=_,e[20]=c,e[21]=N):N=e[21],N}var xe;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function a(r){throw new Error}t.assertNever=a,t.arrayToEnum=r=>{const n={};for(const i of r)n[i]=i;return n},t.getValidEnumValues=r=>{const n=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of n)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(n){return r[n]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const n=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&n.push(i);return n},t.find=(r,n)=>{for(const i of r)if(n(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,n=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}t.joinValues=s,t.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(xe||(xe={}));var Ke;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(Ke||(Ke={}));xe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);xe.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 Oe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(n){return n.message},s={_errors:[]},r=n=>{for(const i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(a(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(a(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return r(this),s}static assert(e){if(!(e instanceof Oe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,xe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),s=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];a[n]=a[n]||[],a[n].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}}Oe.create=t=>new Oe(t);var et;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(et||(et={}));var w;(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"})(w||(w={}));function Vr(){const t=G.c(5),e=sa(),{org:a}=Et();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},t[0]=s):s=t[0];const r=ra(s);let n;return t[1]!==a||t[2]!==r||t[3]!==e?(n=i=>{const c=i.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!c||!c[1])return;const l=c[1],p=r.connectionId;if(!p)return;e.invalidateQueries({queryKey:_t.collection(a.slug,p,l)});const d=l.toLowerCase().replace(/_/g," ");Ze.success(`${d} updated`)},t[1]=a,t[2]=r,t[3]=e,t[4]=n):n=t[4],n}var At="vercel.ai.error",Ma=Symbol.for(At),tt,at,ae=class Ct extends(at=Error,tt=Ma,at){constructor({name:e,message:a,cause:s}){super(a),this[tt]=!0,this.name=e,this.cause=s}static isInstance(e){return Ct.hasMarker(e,At)}static hasMarker(e,a){const s=Symbol.for(a);return e!=null&&typeof e=="object"&&s in e&&typeof e[s]=="boolean"&&e[s]===!0}};function Rt(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Mt="AI_InvalidArgumentError",Ot=`vercel.ai.error.${Mt}`,Oa=Symbol.for(Ot),st,rt,ja=class extends(rt=ae,st=Oa,rt){constructor({message:t,cause:e,argument:a}){super({name:Mt,message:t,cause:e}),this[st]=!0,this.argument=a}static isInstance(t){return ae.hasMarker(t,Ot)}},jt="AI_JSONParseError",Pt=`vercel.ai.error.${jt}`,Pa=Symbol.for(Pt),nt,ot,it=class extends(ot=ae,nt=Pa,ot){constructor({text:t,cause:e}){super({name:jt,message:`JSON parsing failed: Text: ${t}.
2
+ Error message: ${Rt(e)}`,cause:e}),this[nt]=!0,this.text=t}static isInstance(t){return ae.hasMarker(t,Pt)}},Dt="AI_TypeValidationError",kt=`vercel.ai.error.${Dt}`,Da=Symbol.for(kt),lt,ct,me=class $e extends(ct=ae,lt=Da,ct){constructor({value:e,cause:a}){super({name:Dt,message:`Type validation failed: Value: ${JSON.stringify(e)}.
3
+ Error message: ${Rt(a)}`,cause:a}),this[lt]=!0,this.value=e}static isInstance(e){return ae.hasMarker(e,kt)}static wrap({value:e,cause:a}){return $e.isInstance(a)&&a.value===e?a:new $e({value:e,cause:a})}},Ie=({prefix:t,size:e=16,alphabet:a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const r=()=>{const n=a.length,i=new Array(e);for(let o=0;o<e;o++)i[o]=a[Math.random()*n|0];return i.join("")};if(t==null)return r;if(a.includes(s))throw new ja({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${a}".`});return()=>`${t}${s}${r()}`},ka=Ie();function ut(t=globalThis){var e,a,s;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(s=(a=t.process)==null?void 0:a.versions)!=null&&s.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function ne(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((a,s)=>{e[s.toLowerCase()]=a});else{Array.isArray(t)||(t=Object.entries(t));for(const[a,s]of t)s!=null&&(e[a.toLowerCase()]=s)}return e}function dt(t,...e){const a=new Headers(ne(t)),s=a.get("user-agent")||"";return a.set("user-agent",[s,...e].filter(Boolean).join(" ")),Object.fromEntries(a.entries())}var Za=/"__proto__"\s*:/,$a=/"constructor"\s*:/;function pt(t){const e=JSON.parse(t);return e===null||typeof e!="object"||Za.test(t)===!1&&$a.test(t)===!1?e:La(e)}function La(t){let e=[t];for(;e.length;){const a=e;e=[];for(const s of a){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in s){const n=s[r];n&&typeof n=="object"&&e.push(n)}}}return t}function Ua(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return pt(t)}try{return pt(t)}finally{Error.stackTraceLimit=e}}function Ye(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:a}=t;if(a!=null)for(const s of Object.keys(a))a[s]=re(a[s])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(re):re(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(re)),t.allOf!=null&&(t.allOf=t.allOf.map(re)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(re));const{definitions:e}=t;if(e!=null)for(const a of Object.keys(e))e[a]=re(e[a]);return t}function re(t){return typeof t=="boolean"?t:Ye(t)}var Fa=Symbol("Let zodToJsonSchema decide on which parser to use"),mt={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"},Ba=t=>typeof t=="string"?{...mt,name:t}:{...mt,...t};function F(){return{}}function za(t,e){var a,s,r;const n={type:"array"};return(a=t.type)!=null&&a._def&&((r=(s=t.type)==null?void 0:s._def)==null?void 0:r.typeName)!==w.ZodAny&&(n.items=R(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(n.minItems=t.minLength.value),t.maxLength&&(n.maxItems=t.maxLength.value),t.exactLength&&(n.minItems=t.exactLength.value,n.maxItems=t.exactLength.value),n}function Va(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function qa(){return{type:"boolean"}}function Zt(t,e){return R(t.type._def,e)}var Ja=(t,e)=>R(t.innerType._def,e);function $t(t,e,a){const s=a??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,n)=>$t(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Wa(t)}}var Wa=t=>{const e={type:"integer",format:"unix-time"};for(const a of t.checks)switch(a.kind){case"min":e.minimum=a.value;break;case"max":e.maximum=a.value;break}return e};function Ya(t,e){return{...R(t.innerType._def,e),default:t.defaultValue()}}function Ga(t,e){return e.effectStrategy==="input"?R(t.schema._def,e):F()}function Ha(t){return{type:"string",enum:Array.from(t.values)}}var Qa=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Xa(t,e){const a=[R(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),R(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(r=>!!r),s=[];return a.forEach(r=>{if(Qa(r))s.push(...r.allOf);else{let n=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:i,...o}=r;n=o}s.push(n)}}),s.length?{allOf:s}:void 0}function Ka(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 Pe=void 0,V={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:()=>(Pe===void 0&&(Pe=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pe),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 Lt(t,e){const a={type:"string"};if(t.checks)for(const s of t.checks)switch(s.kind){case"min":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value;break;case"max":a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"email":switch(e.emailStrategy){case"format:email":q(a,"email",s.message,e);break;case"format:idn-email":q(a,"idn-email",s.message,e);break;case"pattern:zod":k(a,V.email,s.message,e);break}break;case"url":q(a,"uri",s.message,e);break;case"uuid":q(a,"uuid",s.message,e);break;case"regex":k(a,s.regex,s.message,e);break;case"cuid":k(a,V.cuid,s.message,e);break;case"cuid2":k(a,V.cuid2,s.message,e);break;case"startsWith":k(a,RegExp(`^${De(s.value,e)}`),s.message,e);break;case"endsWith":k(a,RegExp(`${De(s.value,e)}$`),s.message,e);break;case"datetime":q(a,"date-time",s.message,e);break;case"date":q(a,"date",s.message,e);break;case"time":q(a,"time",s.message,e);break;case"duration":q(a,"duration",s.message,e);break;case"length":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value,a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"includes":{k(a,RegExp(De(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&q(a,"ipv4",s.message,e),s.version!=="v4"&&q(a,"ipv6",s.message,e);break}case"base64url":k(a,V.base64url,s.message,e);break;case"jwt":k(a,V.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&k(a,V.ipv4Cidr,s.message,e),s.version!=="v4"&&k(a,V.ipv6Cidr,s.message,e);break}case"emoji":k(a,V.emoji(),s.message,e);break;case"ulid":{k(a,V.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{q(a,"binary",s.message,e);break}case"contentEncoding:base64":{a.contentEncoding="base64";break}case"pattern:zod":{k(a,V.base64,s.message,e);break}}break}case"nanoid":k(a,V.nanoid,s.message,e)}return a}function De(t,e){return e.patternStrategy==="escape"?ts(t):t}var es=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ts(t){let e="";for(let a=0;a<t.length;a++)es.has(t[a])||(e+="\\"),e+=t[a];return e}function q(t,e,a,s){var r;t.format||(r=t.anyOf)!=null&&r.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...a&&s.errorMessages&&{errorMessage:{format:a}}})):t.format=e}function k(t,e,a,s){var r;t.pattern||(r=t.allOf)!=null&&r.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:ht(e,s),...a&&s.errorMessages&&{errorMessage:{pattern:a}}})):t.pattern=ht(e,s)}function ht(t,e){var a;if(!e.applyRegexFlags||!t.flags)return t.source;const s={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},r=s.i?t.source.toLowerCase():t.source;let n="",i=!1,o=!1,c=!1;for(let l=0;l<r.length;l++){if(i){n+=r[l],i=!1;continue}if(s.i){if(o){if(r[l].match(/[a-z]/)){c?(n+=r[l],n+=`${r[l-2]}-${r[l]}`.toUpperCase(),c=!1):r[l+1]==="-"&&((a=r[l+2])!=null&&a.match(/[a-z]/))?(n+=r[l],c=!0):n+=`${r[l]}${r[l].toUpperCase()}`;continue}}else if(r[l].match(/[a-z]/)){n+=`[${r[l]}${r[l].toUpperCase()}]`;continue}}if(s.m){if(r[l]==="^"){n+=`(^|(?<=[\r
4
4
  ]))`;continue}else if(r[l]==="$"){n+=`($|(?=[\r
5
5
  ]))`;continue}}if(s.s&&r[l]==="."){n+=o?`${r[l]}\r
6
6
  `:`[${r[l]}\r
7
- ]`;continue}n+=r[l],r[l]==="\\"?i=!0:o&&r[l]==="]"?o=!1:!o&&r[l]==="["&&(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return n}function Ut(t,e){var a,s,r,n,i,o;const c={type:"object",additionalProperties:(a=R(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?a:e.allowedAdditionalProperties};if(((s=t.keyType)==null?void 0:s._def.typeName)===w.ZodString&&((r=t.keyType._def.checks)!=null&&r.length)){const{type:l,...p}=Lt(t.keyType._def,e);return{...c,propertyNames:p}}else{if(((n=t.keyType)==null?void 0:n._def.typeName)===w.ZodEnum)return{...c,propertyNames:{enum:t.keyType._def.values}};if(((i=t.keyType)==null?void 0:i._def.typeName)===w.ZodBranded&&t.keyType._def.type._def.typeName===w.ZodString&&((o=t.keyType._def.type._def.checks)!=null&&o.length)){const{type:l,...p}=Zt(t.keyType._def,e);return{...c,propertyNames:p}}}return c}function ss(t,e){if(e.mapStrategy==="record")return Ut(t,e);const a=R(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||F(),s=R(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||F();return{type:"array",maxItems:125,items:{type:"array",items:[a,s],minItems:2,maxItems:2}}}function rs(t){const e=t.values,s=Object.keys(t.values).filter(n=>typeof e[e[n]]!="number").map(n=>e[n]),r=Array.from(new Set(s.map(n=>typeof n)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function ns(){return{not:F()}}function os(){return{type:"null"}}var Le={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function is(t,e){const a=t.options instanceof Map?Array.from(t.options.values()):t.options;if(a.every(s=>s._def.typeName in Le&&(!s._def.checks||!s._def.checks.length))){const s=a.reduce((r,n)=>{const i=Le[n._def.typeName];return i&&!r.includes(i)?[...r,i]:r},[]);return{type:s.length>1?s:s[0]}}else if(a.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){const s=a.reduce((r,n)=>{const i=typeof n._def.value;switch(i){case"string":case"number":case"boolean":return[...r,i];case"bigint":return[...r,"integer"];case"object":if(n._def.value===null)return[...r,"null"];default:return r}},[]);if(s.length===a.length){const r=s.filter((n,i,o)=>o.indexOf(n)===i);return{type:r.length>1?r:r[0],enum:a.reduce((n,i)=>n.includes(i._def.value)?n:[...n,i._def.value],[])}}}else if(a.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:a.reduce((s,r)=>[...s,...r._def.values.filter(n=>!s.includes(n))],[])};return ls(t,e)}var ls=(t,e)=>{const a=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,r)=>R(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return a.length?{anyOf:a}:void 0};function cs(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Le[t.innerType._def.typeName],"null"]};const a=R(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}function us(t){const e={type:"number"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"int":e.type="integer";break;case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function ds(t,e){const a={type:"object",properties:{}},s=[],r=t.shape();for(const i in r){let o=r[i];if(o===void 0||o._def===void 0)continue;const c=ms(o),l=R(o._def,{...e,currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]});l!==void 0&&(a.properties[i]=l,c||s.push(i))}s.length&&(a.required=s);const n=ps(t,e);return n!==void 0&&(a.additionalProperties=n),a}function ps(t,e){if(t.catchall._def.typeName!=="ZodNever")return R(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function ms(t){try{return t.isOptional()}catch{return!0}}var fs=(t,e)=>{var a;if(e.currentPath.toString()===((a=e.propertyPath)==null?void 0:a.toString()))return R(t.innerType._def,e);const s=R(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return s?{anyOf:[{not:F()},s]}:F()},hs=(t,e)=>{if(e.pipeStrategy==="input")return R(t.in._def,e);if(e.pipeStrategy==="output")return R(t.out._def,e);const a=R(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=R(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",a?"1":"0"]});return{allOf:[a,s].filter(r=>r!==void 0)}};function gs(t,e){return R(t.type._def,e)}function vs(t,e){const s={type:"array",uniqueItems:!0,items:R(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(s.minItems=t.minSize.value),t.maxSize&&(s.maxItems=t.maxSize.value),s}function ys(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((a,s)=>R(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[]),additionalItems:R(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((a,s)=>R(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[])}}function bs(){return{not:F()}}function xs(){return F()}var _s=(t,e)=>R(t.innerType._def,e),ws=(t,e,a)=>{switch(e){case w.ZodString:return Lt(t,a);case w.ZodNumber:return us(t);case w.ZodObject:return ds(t,a);case w.ZodBigInt:return qa(t);case w.ZodBoolean:return Ja();case w.ZodDate:return $t(t,a);case w.ZodUndefined:return bs();case w.ZodNull:return os();case w.ZodArray:return Va(t,a);case w.ZodUnion:case w.ZodDiscriminatedUnion:return is(t,a);case w.ZodIntersection:return Ka(t,a);case w.ZodTuple:return ys(t,a);case w.ZodRecord:return Ut(t,a);case w.ZodLiteral:return es(t);case w.ZodEnum:return Qa(t);case w.ZodNativeEnum:return rs(t);case w.ZodNullable:return cs(t,a);case w.ZodOptional:return fs(t,a);case w.ZodMap:return ss(t,a);case w.ZodSet:return vs(t,a);case w.ZodLazy:return()=>t.getter()._def;case w.ZodPromise:return gs(t,a);case w.ZodNaN:case w.ZodNever:return ns();case w.ZodEffects:return Ha(t,a);case w.ZodAny:return F();case w.ZodUnknown:return xs();case w.ZodDefault:return Ga(t,a);case w.ZodBranded:return Zt(t,a);case w.ZodReadonly:return _s(t,a);case w.ZodCatch:return Wa(t,a);case w.ZodPipeline:return hs(t,a);case w.ZodFunction:case w.ZodVoid:case w.ZodSymbol:return;default:return(s=>{})()}},Es=(t,e)=>{let a=0;for(;a<t.length&&a<e.length&&t[a]===e[a];a++);return[(t.length-a).toString(),...e.slice(a)].join("/")};function R(t,e,a=!1){var s;const r=e.seen.get(t);if(e.override){const c=(s=e.override)==null?void 0:s.call(e,t,e,r,a);if(c!==Ba)return c}if(r&&!a){const c=Is(r,e);if(c!==void 0)return c}const n={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,n);const i=ws(t,t.typeName,e),o=typeof i=="function"?R(i(),e):i;if(o&&Ss(t,e,o),e.postProcess){const c=e.postProcess(o,t,e);return n.jsonSchema=o,c}return n.jsonSchema=o,o}var Is=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Es(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((a,s)=>e.currentPath[s]===a)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),F()):e.$refStrategy==="seen"?F():void 0}},Ss=(t,e,a)=>(t.description&&(a.description=t.description),a),Ns=t=>{const e=za(t),a=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}},Ts=(t,e)=>{var a;const s=Ns(e);let r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[p,u])=>{var g;return{...l,[p]:(g=R(u._def,{...s,currentPath:[...s.basePath,s.definitionPath,p]},!0))!=null?g:F()}},{}):void 0;const n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=(a=R(t._def,n===void 0?s:{...s,currentPath:[...s.basePath,s.definitionPath,n]},!1))!=null?a:F(),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(i.title=o);const c=n===void 0?r?{...i,[s.definitionPath]:r}:i:{$ref:[...s.$refStrategy==="relative"?[]:s.basePath,s.definitionPath,n].join("/"),[s.definitionPath]:{...r,[n]:i}};return c.$schema="http://json-schema.org/draft-07/schema#",c},Ue=Symbol.for("vercel.ai.schema");function As(t){let e;return()=>(e==null&&(e=t()),e)}function je(t,{validate:e}={}){return{[Ue]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function Cs(t){return typeof t=="object"&&t!==null&&Ue in t&&t[Ue]===!0&&"jsonSchema"in t&&"validate"in t}function Ge(t){return t==null?je({properties:{},additionalProperties:!1}):Cs(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?Ft(t):Rs(t):t()}function Rs(t){return je(()=>Ye(t["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async e=>{const a=await t["~standard"].validate(e);return"value"in a?{success:!0,value:a.value}:{success:!1,error:new me({value:e,cause:a.issues})}}})}function Ms(t,e){var a;const s=(a=void 0)!=null?a:!1;return je(()=>Ts(t,{$refStrategy:s?"root":"none"}),{validate:async r=>{const n=await t.safeParseAsync(r);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Os(t,e){var a;const s=(a=void 0)!=null?a:!1;return je(()=>Ye(oa(t,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async r=>{const n=await na(t,r);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function js(t){return"_zod"in t}function Ft(t,e){return js(t)?Os(t):Ms(t)}async function ht({value:t,schema:e}){const a=await _e({value:t,schema:e});if(!a.success)throw me.wrap({value:t,cause:a.error});return a.value}async function _e({value:t,schema:e}){const a=Ge(e);try{if(a.validate==null)return{success:!0,value:t,rawValue:t};const s=await a.validate(t);return s.success?{success:!0,value:s.value,rawValue:t}:{success:!1,error:me.wrap({value:t,cause:s.error}),rawValue:t}}catch(s){return{success:!1,error:me.wrap({value:t,cause:s}),rawValue:t}}}async function oe({text:t,schema:e}){try{const a=Fa(t);return e==null?{success:!0,value:a,rawValue:a}:await _e({value:a,schema:e})}catch(a){return{success:!1,error:it.isInstance(a)?a:new it({text:t,cause:a}),rawValue:void 0}}}function Ps({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new ga).pipeThrough(new TransformStream({async transform({data:a},s){a!=="[DONE]"&&s.enqueue(await oe({text:a,schema:e}))}}))}async function ee(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var Ds=Object.defineProperty,ks=(t,e)=>{for(var a in e)Ds(t,a,{get:e[a],enumerable:!0})},Bt="AI_NoObjectGeneratedError",zt=`vercel.ai.error.${Bt}`,Zs=Symbol.for(zt),Vt,te=class extends ae{constructor({message:t="No object generated.",cause:e,text:a,response:s,usage:r,finishReason:n}){super({name:Bt,message:t,cause:e}),this[Vt]=!0,this.text=a,this.response=s,this.usage=r,this.finishReason=n}static isInstance(t){return ae.hasMarker(t,zt)}};Vt=Zs;var gt="6.0.33",qt=$([h(),Re(Uint8Array),Re(ArrayBuffer),wt(t=>{var e,a;return(a=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?a:!1},{message:"Must be a Buffer"})]),we=ia(()=>$([la(),h(),ca(),Z(),be(h(),we.optional()),Ee(we)])),S=be(h(),be(h(),we.optional())),Jt=M({type:x("text"),text:h(),providerOptions:S.optional()}),$s=M({type:x("image"),image:$([qt,Re(URL)]),mediaType:h().optional(),providerOptions:S.optional()}),Wt=M({type:x("file"),data:$([qt,Re(URL)]),filename:h().optional(),mediaType:h(),providerOptions:S.optional()}),Ls=M({type:x("reasoning"),text:h(),providerOptions:S.optional()}),Us=M({type:x("tool-call"),toolCallId:h(),toolName:h(),input:X(),providerOptions:S.optional(),providerExecuted:Z().optional()}),Fs=ua("type",[M({type:x("text"),value:h(),providerOptions:S.optional()}),M({type:x("json"),value:we,providerOptions:S.optional()}),M({type:x("execution-denied"),reason:h().optional(),providerOptions:S.optional()}),M({type:x("error-text"),value:h(),providerOptions:S.optional()}),M({type:x("error-json"),value:we,providerOptions:S.optional()}),M({type:x("content"),value:Ee($([M({type:x("text"),text:h(),providerOptions:S.optional()}),M({type:x("media"),data:h(),mediaType:h()}),M({type:x("file-data"),data:h(),mediaType:h(),filename:h().optional(),providerOptions:S.optional()}),M({type:x("file-url"),url:h(),providerOptions:S.optional()}),M({type:x("file-id"),fileId:$([h(),be(h(),h())]),providerOptions:S.optional()}),M({type:x("image-data"),data:h(),mediaType:h(),providerOptions:S.optional()}),M({type:x("image-url"),url:h(),providerOptions:S.optional()}),M({type:x("image-file-id"),fileId:$([h(),be(h(),h())]),providerOptions:S.optional()}),M({type:x("custom"),providerOptions:S.optional()})]))})]),Yt=M({type:x("tool-result"),toolCallId:h(),toolName:h(),output:Fs,providerOptions:S.optional()}),Bs=M({type:x("tool-approval-request"),approvalId:h(),toolCallId:h()}),zs=M({type:x("tool-approval-response"),approvalId:h(),approved:Z(),reason:h().optional()}),Vs=M({role:x("system"),content:h(),providerOptions:S.optional()}),qs=M({role:x("user"),content:$([h(),Ee($([Jt,$s,Wt]))]),providerOptions:S.optional()}),Js=M({role:x("assistant"),content:$([h(),Ee($([Jt,Wt,Ls,Us,Yt,Bs]))]),providerOptions:S.optional()}),Ws=M({role:x("tool"),content:Ee($([Yt,zs])),providerOptions:S.optional()});$([Vs,qs,Js,Ws]);function Gt(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const a={...t};for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(r===void 0)continue;const n=s in t?t[s]:void 0,i=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),o=n!=null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp);i&&o?a[s]=Gt(n,r):a[s]=r}return a}var Ys={};ks(Ys,{array:()=>Xs,choice:()=>Ks,json:()=>er,object:()=>Qs,text:()=>Hs});function Gs(t){const e=["ROOT"];let a=-1,s=null;function r(c,l,p){switch(c){case'"':{a=l,e.pop(),e.push(p),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{a=l,s=l,e.pop(),e.push(p),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=l,e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"{":{a=l,e.pop(),e.push(p),e.push("INSIDE_OBJECT_START");break}case"[":{a=l,e.pop(),e.push(p),e.push("INSIDE_ARRAY_START");break}}}function n(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{a=l,e.pop();break}}}function i(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=l,e.pop();break}}}for(let c=0;c<t.length;c++){const l=t[c];switch(e[e.length-1]){case"ROOT":r(l,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{a=c,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{l===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(l,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{n(l,c);break}case"INSIDE_STRING":{switch(l){case'"':{e.pop(),a=c;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:a=c}break}case"INSIDE_ARRAY_START":{l==="]"?(a=c,e.pop()):(a=c,r(l,c,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=c,e.pop();break}default:{a=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(l,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),a=c;break}case"INSIDE_NUMBER":{switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=c;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&n(l,c);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&n(l,c);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const u=t.substring(s,c+1);!"false".startsWith(u)&&!"true".startsWith(u)&&!"null".startsWith(u)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?n(l,c):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c)):a=c;break}}}let o=t.slice(0,a+1);for(let c=e.length-1;c>=0;c--)switch(e[c]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const p=t.substring(s,t.length);"true".startsWith(p)?o+="true".slice(p.length):"false".startsWith(p)?o+="false".slice(p.length):"null".startsWith(p)&&(o+="null".slice(p.length))}}return o}async function Se(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await oe({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await oe({text:Gs(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var Hs=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}},createElementStreamTransform(){}}),Qs=({schema:t,name:e,description:a})=>{const s=Ge(t);return{name:"object",responseFormat:ee(s.jsonSchema).then(r=>({type:"json",schema:r,...e!=null&&{name:e},...a!=null&&{description:a}})),async parseCompleteOutput({text:r},n){const i=await oe({text:r});if(!i.success)throw new te({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});const o=await _e({value:i.value,schema:s});if(!o.success)throw new te({message:"No object generated: response did not match schema.",cause:o.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});return o.value},async parsePartialOutput({text:r}){const n=await Se(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:n.value}}},createElementStreamTransform(){}}},Xs=({element:t,name:e,description:a})=>{const s=Ge(t);return{name:"array",responseFormat:ee(s.jsonSchema).then(r=>{const{$schema:n,...i}=r;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:i}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}}),async parseCompleteOutput({text:r},n){const i=await oe({text:r});if(!i.success)throw new te({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});const o=i.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new te({message:"No object generated: response did not match schema.",cause:new me({value:o,cause:"response must be an object with an elements array"}),text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});for(const c of o.elements){const l=await _e({value:c,schema:s});if(!l.success)throw new te({message:"No object generated: response did not match schema.",cause:l.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason})}return o.elements},async parsePartialOutput({text:r}){const n=await Se(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const i=n.value;if(i==null||typeof i!="object"||!("elements"in i)||!Array.isArray(i.elements))return;const o=n.state==="repaired-parse"&&i.elements.length>0?i.elements.slice(0,-1):i.elements,c=[];for(const l of o){const p=await _e({value:l,schema:s});p.success&&c.push(p.value)}return{partial:c}}}},createElementStreamTransform(){let r=0;return new TransformStream({transform({partialOutput:n},i){if(n!=null)for(;r<n.length;r++)i.enqueue(n[r])}})}}},Ks=({options:t,name:e,description:a})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}),async parseCompleteOutput({text:s},r){const n=await oe({text:s});if(!n.success)throw new te({message:"No object generated: could not parse the response.",cause:n.error,text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});const i=n.value;if(i==null||typeof i!="object"||!("result"in i)||typeof i.result!="string"||!t.includes(i.result))throw new te({message:"No object generated: response did not match schema.",cause:new me({value:i,cause:"response must be an object that contains a choice value."}),text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.result},async parsePartialOutput({text:s}){const r=await Se(s);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const n=r.value;if(n==null||typeof n!="object"||!("result"in n)||typeof n.result!="string")return;const i=t.filter(o=>o.startsWith(n.result));return r.state==="successful-parse"?i.includes(n.result)?{partial:n.result}:void 0:i.length===1?{partial:i[0]}:void 0}}},createElementStreamTransform(){}}),er=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:a},s){const r=await oe({text:a});if(!r.success)throw new te({message:"No object generated: could not parse the response.",cause:r.error,text:a,response:s.response,usage:s.usage,finishReason:s.finishReason});return r.value},async parsePartialOutput({text:a}){const s=await Se(a);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return s.value===void 0?void 0:{partial:s.value}}},createElementStreamTransform(){}});Ie({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
7
+ ]`;continue}n+=r[l],r[l]==="\\"?i=!0:o&&r[l]==="]"?o=!1:!o&&r[l]==="["&&(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return n}function Ut(t,e){var a,s,r,n,i,o;const c={type:"object",additionalProperties:(a=R(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?a:e.allowedAdditionalProperties};if(((s=t.keyType)==null?void 0:s._def.typeName)===w.ZodString&&((r=t.keyType._def.checks)!=null&&r.length)){const{type:l,...p}=Lt(t.keyType._def,e);return{...c,propertyNames:p}}else{if(((n=t.keyType)==null?void 0:n._def.typeName)===w.ZodEnum)return{...c,propertyNames:{enum:t.keyType._def.values}};if(((i=t.keyType)==null?void 0:i._def.typeName)===w.ZodBranded&&t.keyType._def.type._def.typeName===w.ZodString&&((o=t.keyType._def.type._def.checks)!=null&&o.length)){const{type:l,...p}=Zt(t.keyType._def,e);return{...c,propertyNames:p}}}return c}function as(t,e){if(e.mapStrategy==="record")return Ut(t,e);const a=R(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||F(),s=R(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||F();return{type:"array",maxItems:125,items:{type:"array",items:[a,s],minItems:2,maxItems:2}}}function ss(t){const e=t.values,s=Object.keys(t.values).filter(n=>typeof e[e[n]]!="number").map(n=>e[n]),r=Array.from(new Set(s.map(n=>typeof n)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function rs(){return{not:F()}}function ns(){return{type:"null"}}var Le={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function os(t,e){const a=t.options instanceof Map?Array.from(t.options.values()):t.options;if(a.every(s=>s._def.typeName in Le&&(!s._def.checks||!s._def.checks.length))){const s=a.reduce((r,n)=>{const i=Le[n._def.typeName];return i&&!r.includes(i)?[...r,i]:r},[]);return{type:s.length>1?s:s[0]}}else if(a.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){const s=a.reduce((r,n)=>{const i=typeof n._def.value;switch(i){case"string":case"number":case"boolean":return[...r,i];case"bigint":return[...r,"integer"];case"object":if(n._def.value===null)return[...r,"null"];default:return r}},[]);if(s.length===a.length){const r=s.filter((n,i,o)=>o.indexOf(n)===i);return{type:r.length>1?r:r[0],enum:a.reduce((n,i)=>n.includes(i._def.value)?n:[...n,i._def.value],[])}}}else if(a.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:a.reduce((s,r)=>[...s,...r._def.values.filter(n=>!s.includes(n))],[])};return is(t,e)}var is=(t,e)=>{const a=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,r)=>R(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return a.length?{anyOf:a}:void 0};function ls(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Le[t.innerType._def.typeName],"null"]};const a=R(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}function cs(t){const e={type:"number"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"int":e.type="integer";break;case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function us(t,e){const a={type:"object",properties:{}},s=[],r=t.shape();for(const i in r){let o=r[i];if(o===void 0||o._def===void 0)continue;const c=ps(o),l=R(o._def,{...e,currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]});l!==void 0&&(a.properties[i]=l,c||s.push(i))}s.length&&(a.required=s);const n=ds(t,e);return n!==void 0&&(a.additionalProperties=n),a}function ds(t,e){if(t.catchall._def.typeName!=="ZodNever")return R(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function ps(t){try{return t.isOptional()}catch{return!0}}var ms=(t,e)=>{var a;if(e.currentPath.toString()===((a=e.propertyPath)==null?void 0:a.toString()))return R(t.innerType._def,e);const s=R(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return s?{anyOf:[{not:F()},s]}:F()},hs=(t,e)=>{if(e.pipeStrategy==="input")return R(t.in._def,e);if(e.pipeStrategy==="output")return R(t.out._def,e);const a=R(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=R(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",a?"1":"0"]});return{allOf:[a,s].filter(r=>r!==void 0)}};function fs(t,e){return R(t.type._def,e)}function gs(t,e){const s={type:"array",uniqueItems:!0,items:R(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(s.minItems=t.minSize.value),t.maxSize&&(s.maxItems=t.maxSize.value),s}function vs(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((a,s)=>R(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[]),additionalItems:R(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((a,s)=>R(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[])}}function ys(){return{not:F()}}function bs(){return F()}var xs=(t,e)=>R(t.innerType._def,e),_s=(t,e,a)=>{switch(e){case w.ZodString:return Lt(t,a);case w.ZodNumber:return cs(t);case w.ZodObject:return us(t,a);case w.ZodBigInt:return Va(t);case w.ZodBoolean:return qa();case w.ZodDate:return $t(t,a);case w.ZodUndefined:return ys();case w.ZodNull:return ns();case w.ZodArray:return za(t,a);case w.ZodUnion:case w.ZodDiscriminatedUnion:return os(t,a);case w.ZodIntersection:return Xa(t,a);case w.ZodTuple:return vs(t,a);case w.ZodRecord:return Ut(t,a);case w.ZodLiteral:return Ka(t);case w.ZodEnum:return Ha(t);case w.ZodNativeEnum:return ss(t);case w.ZodNullable:return ls(t,a);case w.ZodOptional:return ms(t,a);case w.ZodMap:return as(t,a);case w.ZodSet:return gs(t,a);case w.ZodLazy:return()=>t.getter()._def;case w.ZodPromise:return fs(t,a);case w.ZodNaN:case w.ZodNever:return rs();case w.ZodEffects:return Ga(t,a);case w.ZodAny:return F();case w.ZodUnknown:return bs();case w.ZodDefault:return Ya(t,a);case w.ZodBranded:return Zt(t,a);case w.ZodReadonly:return xs(t,a);case w.ZodCatch:return Ja(t,a);case w.ZodPipeline:return hs(t,a);case w.ZodFunction:case w.ZodVoid:case w.ZodSymbol:return;default:return(s=>{})()}},ws=(t,e)=>{let a=0;for(;a<t.length&&a<e.length&&t[a]===e[a];a++);return[(t.length-a).toString(),...e.slice(a)].join("/")};function R(t,e,a=!1){var s;const r=e.seen.get(t);if(e.override){const c=(s=e.override)==null?void 0:s.call(e,t,e,r,a);if(c!==Fa)return c}if(r&&!a){const c=Es(r,e);if(c!==void 0)return c}const n={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,n);const i=_s(t,t.typeName,e),o=typeof i=="function"?R(i(),e):i;if(o&&Is(t,e,o),e.postProcess){const c=e.postProcess(o,t,e);return n.jsonSchema=o,c}return n.jsonSchema=o,o}var Es=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ws(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((a,s)=>e.currentPath[s]===a)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),F()):e.$refStrategy==="seen"?F():void 0}},Is=(t,e,a)=>(t.description&&(a.description=t.description),a),Ss=t=>{const e=Ba(t),a=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}},Ns=(t,e)=>{var a;const s=Ss(e);let r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[p,d])=>{var g;return{...l,[p]:(g=R(d._def,{...s,currentPath:[...s.basePath,s.definitionPath,p]},!0))!=null?g:F()}},{}):void 0;const n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=(a=R(t._def,n===void 0?s:{...s,currentPath:[...s.basePath,s.definitionPath,n]},!1))!=null?a:F(),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(i.title=o);const c=n===void 0?r?{...i,[s.definitionPath]:r}:i:{$ref:[...s.$refStrategy==="relative"?[]:s.basePath,s.definitionPath,n].join("/"),[s.definitionPath]:{...r,[n]:i}};return c.$schema="http://json-schema.org/draft-07/schema#",c},Ue=Symbol.for("vercel.ai.schema");function Ts(t){let e;return()=>(e==null&&(e=t()),e)}function je(t,{validate:e}={}){return{[Ue]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function As(t){return typeof t=="object"&&t!==null&&Ue in t&&t[Ue]===!0&&"jsonSchema"in t&&"validate"in t}function Ge(t){return t==null?je({properties:{},additionalProperties:!1}):As(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?Ft(t):Cs(t):t()}function Cs(t){return je(()=>Ye(t["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async e=>{const a=await t["~standard"].validate(e);return"value"in a?{success:!0,value:a.value}:{success:!1,error:new me({value:e,cause:a.issues})}}})}function Rs(t,e){var a;const s=(a=void 0)!=null?a:!1;return je(()=>Ns(t,{$refStrategy:s?"root":"none"}),{validate:async r=>{const n=await t.safeParseAsync(r);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Ms(t,e){var a;const s=(a=void 0)!=null?a:!1;return je(()=>Ye(oa(t,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async r=>{const n=await na(t,r);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Os(t){return"_zod"in t}function Ft(t,e){return Os(t)?Ms(t):Rs(t)}async function ft({value:t,schema:e}){const a=await _e({value:t,schema:e});if(!a.success)throw me.wrap({value:t,cause:a.error});return a.value}async function _e({value:t,schema:e}){const a=Ge(e);try{if(a.validate==null)return{success:!0,value:t,rawValue:t};const s=await a.validate(t);return s.success?{success:!0,value:s.value,rawValue:t}:{success:!1,error:me.wrap({value:t,cause:s.error}),rawValue:t}}catch(s){return{success:!1,error:me.wrap({value:t,cause:s}),rawValue:t}}}async function oe({text:t,schema:e}){try{const a=Ua(t);return e==null?{success:!0,value:a,rawValue:a}:await _e({value:a,schema:e})}catch(a){return{success:!1,error:it.isInstance(a)?a:new it({text:t,cause:a}),rawValue:void 0}}}function js({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new ga).pipeThrough(new TransformStream({async transform({data:a},s){a!=="[DONE]"&&s.enqueue(await oe({text:a,schema:e}))}}))}async function ee(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var Ps=Object.defineProperty,Ds=(t,e)=>{for(var a in e)Ps(t,a,{get:e[a],enumerable:!0})},Bt="AI_NoObjectGeneratedError",zt=`vercel.ai.error.${Bt}`,ks=Symbol.for(zt),Vt,te=class extends ae{constructor({message:t="No object generated.",cause:e,text:a,response:s,usage:r,finishReason:n}){super({name:Bt,message:t,cause:e}),this[Vt]=!0,this.text=a,this.response=s,this.usage=r,this.finishReason=n}static isInstance(t){return ae.hasMarker(t,zt)}};Vt=ks;var gt="6.0.33",qt=$([f(),Re(Uint8Array),Re(ArrayBuffer),wt(t=>{var e,a;return(a=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?a:!1},{message:"Must be a Buffer"})]),we=ia(()=>$([la(),f(),ca(),Z(),be(f(),we.optional()),Ee(we)])),S=be(f(),be(f(),we.optional())),Jt=M({type:x("text"),text:f(),providerOptions:S.optional()}),Zs=M({type:x("image"),image:$([qt,Re(URL)]),mediaType:f().optional(),providerOptions:S.optional()}),Wt=M({type:x("file"),data:$([qt,Re(URL)]),filename:f().optional(),mediaType:f(),providerOptions:S.optional()}),$s=M({type:x("reasoning"),text:f(),providerOptions:S.optional()}),Ls=M({type:x("tool-call"),toolCallId:f(),toolName:f(),input:X(),providerOptions:S.optional(),providerExecuted:Z().optional()}),Us=ua("type",[M({type:x("text"),value:f(),providerOptions:S.optional()}),M({type:x("json"),value:we,providerOptions:S.optional()}),M({type:x("execution-denied"),reason:f().optional(),providerOptions:S.optional()}),M({type:x("error-text"),value:f(),providerOptions:S.optional()}),M({type:x("error-json"),value:we,providerOptions:S.optional()}),M({type:x("content"),value:Ee($([M({type:x("text"),text:f(),providerOptions:S.optional()}),M({type:x("media"),data:f(),mediaType:f()}),M({type:x("file-data"),data:f(),mediaType:f(),filename:f().optional(),providerOptions:S.optional()}),M({type:x("file-url"),url:f(),providerOptions:S.optional()}),M({type:x("file-id"),fileId:$([f(),be(f(),f())]),providerOptions:S.optional()}),M({type:x("image-data"),data:f(),mediaType:f(),providerOptions:S.optional()}),M({type:x("image-url"),url:f(),providerOptions:S.optional()}),M({type:x("image-file-id"),fileId:$([f(),be(f(),f())]),providerOptions:S.optional()}),M({type:x("custom"),providerOptions:S.optional()})]))})]),Yt=M({type:x("tool-result"),toolCallId:f(),toolName:f(),output:Us,providerOptions:S.optional()}),Fs=M({type:x("tool-approval-request"),approvalId:f(),toolCallId:f()}),Bs=M({type:x("tool-approval-response"),approvalId:f(),approved:Z(),reason:f().optional()}),zs=M({role:x("system"),content:f(),providerOptions:S.optional()}),Vs=M({role:x("user"),content:$([f(),Ee($([Jt,Zs,Wt]))]),providerOptions:S.optional()}),qs=M({role:x("assistant"),content:$([f(),Ee($([Jt,Wt,$s,Ls,Yt,Fs]))]),providerOptions:S.optional()}),Js=M({role:x("tool"),content:Ee($([Yt,Bs])),providerOptions:S.optional()});$([zs,Vs,qs,Js]);function Gt(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const a={...t};for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(r===void 0)continue;const n=s in t?t[s]:void 0,i=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),o=n!=null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp);i&&o?a[s]=Gt(n,r):a[s]=r}return a}var Ws={};Ds(Ws,{array:()=>Qs,choice:()=>Xs,json:()=>Ks,object:()=>Hs,text:()=>Gs});function Ys(t){const e=["ROOT"];let a=-1,s=null;function r(c,l,p){switch(c){case'"':{a=l,e.pop(),e.push(p),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{a=l,s=l,e.pop(),e.push(p),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=l,e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"{":{a=l,e.pop(),e.push(p),e.push("INSIDE_OBJECT_START");break}case"[":{a=l,e.pop(),e.push(p),e.push("INSIDE_ARRAY_START");break}}}function n(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{a=l,e.pop();break}}}function i(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=l,e.pop();break}}}for(let c=0;c<t.length;c++){const l=t[c];switch(e[e.length-1]){case"ROOT":r(l,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{a=c,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{l===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(l,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{n(l,c);break}case"INSIDE_STRING":{switch(l){case'"':{e.pop(),a=c;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:a=c}break}case"INSIDE_ARRAY_START":{l==="]"?(a=c,e.pop()):(a=c,r(l,c,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=c,e.pop();break}default:{a=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(l,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),a=c;break}case"INSIDE_NUMBER":{switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=c;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&n(l,c);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&n(l,c);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const d=t.substring(s,c+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?n(l,c):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c)):a=c;break}}}let o=t.slice(0,a+1);for(let c=e.length-1;c>=0;c--)switch(e[c]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const p=t.substring(s,t.length);"true".startsWith(p)?o+="true".slice(p.length):"false".startsWith(p)?o+="false".slice(p.length):"null".startsWith(p)&&(o+="null".slice(p.length))}}return o}async function Se(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await oe({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await oe({text:Ys(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var Gs=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}},createElementStreamTransform(){}}),Hs=({schema:t,name:e,description:a})=>{const s=Ge(t);return{name:"object",responseFormat:ee(s.jsonSchema).then(r=>({type:"json",schema:r,...e!=null&&{name:e},...a!=null&&{description:a}})),async parseCompleteOutput({text:r},n){const i=await oe({text:r});if(!i.success)throw new te({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});const o=await _e({value:i.value,schema:s});if(!o.success)throw new te({message:"No object generated: response did not match schema.",cause:o.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});return o.value},async parsePartialOutput({text:r}){const n=await Se(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:n.value}}},createElementStreamTransform(){}}},Qs=({element:t,name:e,description:a})=>{const s=Ge(t);return{name:"array",responseFormat:ee(s.jsonSchema).then(r=>{const{$schema:n,...i}=r;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:i}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}}),async parseCompleteOutput({text:r},n){const i=await oe({text:r});if(!i.success)throw new te({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});const o=i.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new te({message:"No object generated: response did not match schema.",cause:new me({value:o,cause:"response must be an object with an elements array"}),text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});for(const c of o.elements){const l=await _e({value:c,schema:s});if(!l.success)throw new te({message:"No object generated: response did not match schema.",cause:l.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason})}return o.elements},async parsePartialOutput({text:r}){const n=await Se(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const i=n.value;if(i==null||typeof i!="object"||!("elements"in i)||!Array.isArray(i.elements))return;const o=n.state==="repaired-parse"&&i.elements.length>0?i.elements.slice(0,-1):i.elements,c=[];for(const l of o){const p=await _e({value:l,schema:s});p.success&&c.push(p.value)}return{partial:c}}}},createElementStreamTransform(){let r=0;return new TransformStream({transform({partialOutput:n},i){if(n!=null)for(;r<n.length;r++)i.enqueue(n[r])}})}}},Xs=({options:t,name:e,description:a})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}),async parseCompleteOutput({text:s},r){const n=await oe({text:s});if(!n.success)throw new te({message:"No object generated: could not parse the response.",cause:n.error,text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});const i=n.value;if(i==null||typeof i!="object"||!("result"in i)||typeof i.result!="string"||!t.includes(i.result))throw new te({message:"No object generated: response did not match schema.",cause:new me({value:i,cause:"response must be an object that contains a choice value."}),text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.result},async parsePartialOutput({text:s}){const r=await Se(s);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const n=r.value;if(n==null||typeof n!="object"||!("result"in n)||typeof n.result!="string")return;const i=t.filter(o=>o.startsWith(n.result));return r.state==="successful-parse"?i.includes(n.result)?{partial:n.result}:void 0:i.length===1?{partial:i[0]}:void 0}}},createElementStreamTransform(){}}),Ks=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:a},s){const r=await oe({text:a});if(!r.success)throw new te({message:"No object generated: could not parse the response.",cause:r.error,text:a,response:s.response,usage:s.usage,finishReason:s.finishReason});return r.value},async parsePartialOutput({text:a}){const s=await Se(a);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return s.value===void 0?void 0:{partial:s.value}}},createElementStreamTransform(){}});Ie({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
8
8
 
9
9
  `)},flush(t){t.enqueue(`data: [DONE]
10
10
 
11
- `)}})}});var tr=As(()=>Ft($([O({type:x("text-start"),id:h(),providerMetadata:S.optional()}),O({type:x("text-delta"),id:h(),delta:h(),providerMetadata:S.optional()}),O({type:x("text-end"),id:h(),providerMetadata:S.optional()}),O({type:x("error"),errorText:h()}),O({type:x("tool-input-start"),toolCallId:h(),toolName:h(),providerExecuted:Z().optional(),dynamic:Z().optional(),title:h().optional()}),O({type:x("tool-input-delta"),toolCallId:h(),inputTextDelta:h()}),O({type:x("tool-input-available"),toolCallId:h(),toolName:h(),input:X(),providerExecuted:Z().optional(),providerMetadata:S.optional(),dynamic:Z().optional(),title:h().optional()}),O({type:x("tool-input-error"),toolCallId:h(),toolName:h(),input:X(),providerExecuted:Z().optional(),providerMetadata:S.optional(),dynamic:Z().optional(),errorText:h(),title:h().optional()}),O({type:x("tool-approval-request"),approvalId:h(),toolCallId:h()}),O({type:x("tool-output-available"),toolCallId:h(),output:X(),providerExecuted:Z().optional(),dynamic:Z().optional(),preliminary:Z().optional()}),O({type:x("tool-output-error"),toolCallId:h(),errorText:h(),providerExecuted:Z().optional(),dynamic:Z().optional()}),O({type:x("tool-output-denied"),toolCallId:h()}),O({type:x("reasoning-start"),id:h(),providerMetadata:S.optional()}),O({type:x("reasoning-delta"),id:h(),delta:h(),providerMetadata:S.optional()}),O({type:x("reasoning-end"),id:h(),providerMetadata:S.optional()}),O({type:x("source-url"),sourceId:h(),url:h(),title:h().optional(),providerMetadata:S.optional()}),O({type:x("source-document"),sourceId:h(),mediaType:h(),title:h(),filename:h().optional(),providerMetadata:S.optional()}),O({type:x("file"),url:h(),mediaType:h(),providerMetadata:S.optional()}),O({type:wt(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:h().optional(),data:X(),transient:Z().optional()}),O({type:x("start-step")}),O({type:x("finish-step")}),O({type:x("start"),messageId:h().optional(),messageMetadata:X().optional()}),O({type:x("finish"),finishReason:da(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:X().optional()}),O({type:x("abort"),reason:h().optional()}),O({type:x("message-metadata"),messageMetadata:X()})])));function ar(t){return t.type.startsWith("data-")}function Fe(t){return t.type.startsWith("tool-")}function sr(t){return t.type==="dynamic-tool"}function Be(t){return Fe(t)||sr(t)}function vt(t){return t.type.split("-").slice(1).join("-")}function rr({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function nr({stream:t,messageMetadataSchema:e,dataPartSchemas:a,runUpdateMessageJob:s,onError:r,onToolCall:n,onData:i}){return t.pipeThrough(new TransformStream({async transform(o,c){await s(async({state:l,write:p})=>{var u,g,f,v;function b(d){const A=l.message.parts.filter(Be).find(E=>E.toolCallId===d);if(A==null)throw new Error(`no tool invocation found for tool call ${d}`);return A}function y(d){var T;const A=l.message.parts.find(P=>Fe(P)&&P.toolCallId===d.toolCallId),E=d,I=A;A!=null?(A.state=d.state,I.input=E.input,I.output=E.output,I.errorText=E.errorText,I.rawInput=E.rawInput,I.preliminary=E.preliminary,d.title!==void 0&&(I.title=d.title),I.providerExecuted=(T=E.providerExecuted)!=null?T:A.providerExecuted,E.providerMetadata!=null&&A.state==="input-available"&&(A.callProviderMetadata=E.providerMetadata)):l.message.parts.push({type:`tool-${d.toolName}`,toolCallId:d.toolCallId,state:d.state,title:d.title,input:E.input,output:E.output,rawInput:E.rawInput,errorText:E.errorText,providerExecuted:E.providerExecuted,preliminary:E.preliminary,...E.providerMetadata!=null?{callProviderMetadata:E.providerMetadata}:{}})}function _(d){var T,A;const E=l.message.parts.find(L=>L.type==="dynamic-tool"&&L.toolCallId===d.toolCallId),I=d,P=E;E!=null?(E.state=d.state,P.toolName=d.toolName,P.input=I.input,P.output=I.output,P.errorText=I.errorText,P.rawInput=(T=I.rawInput)!=null?T:P.rawInput,P.preliminary=I.preliminary,d.title!==void 0&&(P.title=d.title),P.providerExecuted=(A=I.providerExecuted)!=null?A:E.providerExecuted,I.providerMetadata!=null&&E.state==="input-available"&&(E.callProviderMetadata=I.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:d.toolName,toolCallId:d.toolCallId,state:d.state,input:I.input,output:I.output,errorText:I.errorText,preliminary:I.preliminary,providerExecuted:I.providerExecuted,title:d.title,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}async function N(d){if(d!=null){const T=l.message.metadata!=null?Gt(l.message.metadata,d):d;e!=null&&await ht({value:T,schema:e}),l.message.metadata=T}}switch(o.type){case"text-start":{const d={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};l.activeTextParts[o.id]=d,l.message.parts.push(d),p();break}case"text-delta":{const d=l.activeTextParts[o.id];d.text+=o.delta,d.providerMetadata=(u=o.providerMetadata)!=null?u:d.providerMetadata,p();break}case"text-end":{const d=l.activeTextParts[o.id];d.state="done",d.providerMetadata=(g=o.providerMetadata)!=null?g:d.providerMetadata,delete l.activeTextParts[o.id],p();break}case"reasoning-start":{const d={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};l.activeReasoningParts[o.id]=d,l.message.parts.push(d),p();break}case"reasoning-delta":{const d=l.activeReasoningParts[o.id];d.text+=o.delta,d.providerMetadata=(f=o.providerMetadata)!=null?f:d.providerMetadata,p();break}case"reasoning-end":{const d=l.activeReasoningParts[o.id];d.providerMetadata=(v=o.providerMetadata)!=null?v:d.providerMetadata,d.state="done",delete l.activeReasoningParts[o.id],p();break}case"file":{l.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url}),p();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),p();break}case"source-document":{l.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),p();break}case"tool-input-start":{const d=l.message.parts.filter(Fe);l.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:d.length,dynamic:o.dynamic,title:o.title},o.dynamic?_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title}),p();break}case"tool-input-delta":{const d=l.partialToolCalls[o.toolCallId];d.text+=o.inputTextDelta;const{value:T}=await Se(d.text);d.dynamic?_({toolCallId:o.toolCallId,toolName:d.toolName,state:"input-streaming",input:T,title:d.title}):y({toolCallId:o.toolCallId,toolName:d.toolName,state:"input-streaming",input:T,title:d.title}),p();break}case"tool-input-available":{o.dynamic?_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),p(),n&&!o.providerExecuted&&await n({toolCall:o});break}case"tool-input-error":{o.dynamic?_({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),p();break}case"tool-approval-request":{const d=b(o.toolCallId);d.state="approval-requested",d.approval={id:o.approvalId},p();break}case"tool-output-denied":{const d=b(o.toolCallId);d.state="output-denied",p();break}case"tool-output-available":{const d=b(o.toolCallId);d.type==="dynamic-tool"?_({toolCallId:o.toolCallId,toolName:d.toolName,state:"output-available",input:d.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,title:d.title}):y({toolCallId:o.toolCallId,toolName:vt(d),state:"output-available",input:d.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,title:d.title}),p();break}case"tool-output-error":{const d=b(o.toolCallId);d.type==="dynamic-tool"?_({toolCallId:o.toolCallId,toolName:d.toolName,state:"output-error",input:d.input,errorText:o.errorText,providerExecuted:o.providerExecuted,title:d.title}):y({toolCallId:o.toolCallId,toolName:vt(d),state:"output-error",input:d.input,rawInput:d.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,title:d.title}),p();break}case"start-step":{l.message.parts.push({type:"step-start"});break}case"finish-step":{l.activeTextParts={},l.activeReasoningParts={};break}case"start":{o.messageId!=null&&(l.message.id=o.messageId),await N(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&p();break}case"finish":{o.finishReason!=null&&(l.finishReason=o.finishReason),await N(o.messageMetadata),o.messageMetadata!=null&&p();break}case"message-metadata":{await N(o.messageMetadata),o.messageMetadata!=null&&p();break}case"error":{r?.(new Error(o.errorText));break}default:if(ar(o)){a?.[o.type]!=null&&await ht({value:o.data,schema:a[o.type]});const d=o;if(d.transient){i?.(d);break}const T=d.id!=null?l.message.parts.find(A=>d.type===A.type&&d.id===A.id):void 0;T!=null?T.data=d.data:l.message.parts.push(d),i?.(d),p()}}c.enqueue(o)})}}))}async function or({stream:t,onError:e}){const a=t.getReader();try{for(;;){const{done:s}=await a.read();if(s)break}}catch(s){e?.(s)}finally{a.releaseLock()}}Ie({prefix:"aitxt",size:24});Ie({prefix:"aiobj",size:24});var ir=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise((e,a)=>{this.queue.push(async()=>{try{await t(),e()}catch(s){a(s)}}),this.processQueue()})}};Ie({prefix:"aiobj",size:24});async function lr(t){if(t==null)return[];if(!globalThis.FileList||!(t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map(async e=>{const{name:a,type:s}=e,r=await new Promise((n,i)=>{const o=new FileReader;o.onload=c=>{var l;n((l=c.target)==null?void 0:l.result)},o.onerror=c=>i(c),o.readAsDataURL(e)});return{type:"file",mediaType:s,filename:a,url:r}}))}var cr=class{constructor({api:t="/api/chat",credentials:e,headers:a,body:s,fetch:r,prepareSendMessagesRequest:n,prepareReconnectToStreamRequest:i}){this.api=t,this.credentials=e,this.headers=a,this.body=s,this.fetch=r,this.prepareSendMessagesRequest=n,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:t,...e}){var a,s,r,n,i;const o=await ee(this.body),c=await ee(this.headers),l=await ee(this.credentials),p={...ne(c),...ne(e.headers)},u=await((a=this.prepareSendMessagesRequest)==null?void 0:a.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...o,...e.body},headers:p,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),g=(s=u?.api)!=null?s:this.api,f=u?.headers!==void 0?ne(u.headers):p,v=u?.body!==void 0?u.body:{...o,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},b=(r=u?.credentials)!=null?r:l,_=await((n=this.fetch)!=null?n:globalThis.fetch)(g,{method:"POST",headers:dt({"Content-Type":"application/json",...f},`ai-sdk/${gt}`,ut()),body:JSON.stringify(v),credentials:b,signal:t});if(!_.ok)throw new Error((i=await _.text())!=null?i:"Failed to fetch the chat response.");if(!_.body)throw new Error("The response body is empty.");return this.processResponseStream(_.body)}async reconnectToStream(t){var e,a,s,r,n;const i=await ee(this.body),o=await ee(this.headers),c=await ee(this.credentials),l={...ne(o),...ne(t.headers)},p=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...i,...t.body},headers:l,credentials:c,requestMetadata:t.metadata})),u=(a=p?.api)!=null?a:`${this.api}/${t.chatId}/stream`,g=p?.headers!==void 0?ne(p.headers):l,f=(s=p?.credentials)!=null?s:c,b=await((r=this.fetch)!=null?r:globalThis.fetch)(u,{method:"GET",headers:dt(g,`ai-sdk/${gt}`,ut()),credentials:f});if(b.status===204)return null;if(!b.ok)throw new Error((n=await b.text())!=null?n:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}},Ht=class extends cr{constructor(t={}){super(t)}processResponseStream(t){return Ps({stream:t,schema:tr}).pipeThrough(new TransformStream({async transform(e,a){if(!e.success)throw e.error;a.enqueue(e.value)}}))}},ur=class{constructor({generateId:t=Za,id:e=t(),transport:a=new Ht,messageMetadataSchema:s,dataPartSchemas:r,state:n,onError:i,onToolCall:o,onFinish:c,onData:l,sendAutomaticallyWhen:p}){this.activeResponse=void 0,this.jobExecutor=new ir,this.sendMessage=async(u,g)=>{var f,v,b,y;if(u==null){await this.makeRequest({trigger:"submit-message",messageId:(f=this.lastMessage)==null?void 0:f.id,...g});return}let _;if("text"in u||"files"in u?_={parts:[...Array.isArray(u.files)?u.files:await lr(u.files),..."text"in u&&u.text!=null?[{type:"text",text:u.text}]:[]]}:_=u,u.messageId!=null){const N=this.state.messages.findIndex(d=>d.id===u.messageId);if(N===-1)throw new Error(`message with id ${u.messageId} not found`);if(this.state.messages[N].role!=="user")throw new Error(`message with id ${u.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,N+1),this.state.replaceMessage(N,{..._,id:u.messageId,role:(v=_.role)!=null?v:"user",metadata:u.metadata})}else this.state.pushMessage({..._,id:(b=_.id)!=null?b:this.generateId(),role:(y=_.role)!=null?y:"user",metadata:u.metadata});await this.makeRequest({trigger:"submit-message",messageId:u.messageId,...g})},this.regenerate=async({messageId:u,...g}={})=>{const f=u==null?this.state.messages.length-1:this.state.messages.findIndex(v=>v.id===u);if(f===-1)throw new Error(`message ${u} not found`);this.state.messages=this.state.messages.slice(0,this.messages[f].role==="assistant"?f:f+1),await this.makeRequest({trigger:"regenerate-message",messageId:u,...g})},this.resumeStream=async(u={})=>{await this.makeRequest({trigger:"resume-stream",...u})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:u,approved:g,reason:f})=>this.jobExecutor.run(async()=>{var v,b;const y=this.state.messages,_=y[y.length-1],N=d=>Be(d)&&d.state==="approval-requested"&&d.approval.id===u?{...d,state:"approval-responded",approval:{id:u,approved:g,reason:f}}:d;this.state.replaceMessage(y.length-1,{..._,parts:_.parts.map(N)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(N)),this.status!=="streaming"&&this.status!=="submitted"&&((v=this.sendAutomaticallyWhen)!=null&&v.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(b=this.lastMessage)==null?void 0:b.id})}),this.addToolOutput=async({state:u="output-available",tool:g,toolCallId:f,output:v,errorText:b})=>this.jobExecutor.run(async()=>{var y,_;const N=this.state.messages,d=N[N.length-1],T=A=>Be(A)&&A.toolCallId===f?{...A,state:u,output:v,errorText:b}:A;this.state.replaceMessage(N.length-1,{...d,parts:d.parts.map(T)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(T)),this.status!=="streaming"&&this.status!=="submitted"&&((y=this.sendAutomaticallyWhen)!=null&&y.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var u;this.status!=="streaming"&&this.status!=="submitted"||(u=this.activeResponse)!=null&&u.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=a,this.generateId=t,this.messageMetadataSchema=s,this.dataPartSchemas=r,this.state=n,this.onError=i,this.onToolCall=o,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=p}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async makeRequest({trigger:t,metadata:e,headers:a,body:s,messageId:r}){var n,i,o,c;this.setStatus({status:"submitted",error:void 0});const l=this.lastMessage;let p=!1,u=!1,g=!1;try{const f={state:rr({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};f.abortController.signal.addEventListener("abort",()=>{p=!0}),this.activeResponse=f;let v;if(t==="resume-stream"){const y=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:a,body:s});if(y==null){this.setStatus({status:"ready"});return}v=y}else v=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:f.abortController.signal,metadata:e,headers:a,body:s,trigger:t,messageId:r});const b=y=>this.jobExecutor.run(()=>y({state:f.state,write:()=>{var _;this.setStatus({status:"streaming"}),f.state.message.id===((_=this.lastMessage)==null?void 0:_.id)?this.state.replaceMessage(this.state.messages.length-1,f.state.message):this.state.pushMessage(f.state.message)}}));await or({stream:nr({stream:v,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:b,onError:y=>{throw y}}),onError:y=>{throw y}}),this.setStatus({status:"ready"})}catch(f){if(p||f.name==="AbortError")return p=!0,this.setStatus({status:"ready"}),null;g=!0,f instanceof TypeError&&(f.message.toLowerCase().includes("fetch")||f.message.toLowerCase().includes("network"))&&(u=!0),this.onError&&f instanceof Error&&this.onError(f),this.setStatus({status:"error",error:f})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:p,isDisconnect:u,isError:g,finishReason:(n=this.activeResponse)==null?void 0:n.state.finishReason})}catch(f){console.error(f)}this.activeResponse=void 0}(o=this.sendAutomaticallyWhen)!=null&&o.call(this,{messages:this.state.messages})&&!g&&await this.makeRequest({trigger:"submit-message",messageId:(c=this.lastMessage)==null?void 0:c.id,metadata:e,headers:a,body:s})}},ke,yt;function dr(){if(yt)return ke;yt=1;function t(e,a){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let s,r=0;return function(...i){clearTimeout(s);const o=Date.now(),c=o-r,l=a-c;l<=0?(r=o,e.apply(this,i)):s=setTimeout(()=>{r=Date.now(),e.apply(this,i)},l)}}return ke=t,ke}var pr=dr();const mr=pa(pr);var Qt=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)},j=(t,e,a)=>(Qt(t,e,"read from private field"),a?a.call(t):e.get(t)),G=(t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)},K=(t,e,a,s)=>(Qt(t,e,"write to private field"),e.set(t,a),a);function fr(t,e){return e!=null?mr(t,e):t}var B,Ae,Ce,ge,ve,ye,de,ze,Ve,hr=class{constructor(t=[]){G(this,B,void 0),G(this,Ae,"ready"),G(this,Ce,void 0),G(this,ge,new Set),G(this,ve,new Set),G(this,ye,new Set),this.pushMessage=e=>{K(this,B,j(this,B).concat(e)),j(this,de).call(this)},this.popMessage=()=>{K(this,B,j(this,B).slice(0,-1)),j(this,de).call(this)},this.replaceMessage=(e,a)=>{K(this,B,[...j(this,B).slice(0,e),this.snapshot(a),...j(this,B).slice(e+1)]),j(this,de).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,a)=>{const s=a?fr(e,a):e;return j(this,ge).add(s),()=>{j(this,ge).delete(s)}},this["~registerStatusCallback"]=e=>(j(this,ve).add(e),()=>{j(this,ve).delete(e)}),this["~registerErrorCallback"]=e=>(j(this,ye).add(e),()=>{j(this,ye).delete(e)}),G(this,de,()=>{j(this,ge).forEach(e=>e())}),G(this,ze,()=>{j(this,ve).forEach(e=>e())}),G(this,Ve,()=>{j(this,ye).forEach(e=>e())}),K(this,B,t)}get status(){return j(this,Ae)}set status(t){K(this,Ae,t),j(this,ze).call(this)}get error(){return j(this,Ce)}set error(t){K(this,Ce,t),j(this,Ve).call(this)}get messages(){return j(this,B)}set messages(t){K(this,B,[...t]),j(this,de).call(this)}};B=new WeakMap;Ae=new WeakMap;Ce=new WeakMap;ge=new WeakMap;ve=new WeakMap;ye=new WeakMap;de=new WeakMap;ze=new WeakMap;Ve=new WeakMap;var pe,bt=class extends ur{constructor({messages:t,...e}){const a=new hr(t);super({...e,state:a}),G(this,pe,void 0),this["~registerMessagesCallback"]=(s,r)=>j(this,pe)["~registerMessagesCallback"](s,r),this["~registerStatusCallback"]=s=>j(this,pe)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>j(this,pe)["~registerErrorCallback"](s),K(this,pe,a)}};pe=new WeakMap;function gr({experimental_throttle:t,resume:e=!1,...a}={}){const s=J.useRef("chat"in a?{}:{onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});"chat"in a||(s.current={onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});const r={...a,onToolCall:g=>{var f,v;return(v=(f=s.current).onToolCall)==null?void 0:v.call(f,g)},onData:g=>{var f,v;return(v=(f=s.current).onData)==null?void 0:v.call(f,g)},onFinish:g=>{var f,v;return(v=(f=s.current).onFinish)==null?void 0:v.call(f,g)},onError:g=>{var f,v;return(v=(f=s.current).onError)==null?void 0:v.call(f,g)},sendAutomaticallyWhen:g=>{var f,v,b;return(b=(v=(f=s.current).sendAutomaticallyWhen)==null?void 0:v.call(f,g))!=null?b:!1}},n=J.useRef("chat"in a?a.chat:new bt(r));("chat"in a&&a.chat!==n.current||"id"in a&&n.current.id!==a.id)&&(n.current="chat"in a?a.chat:new bt(r));const o=J.useCallback(g=>n.current["~registerMessagesCallback"](g,t),[t,n.current.id]),c=J.useSyncExternalStore(o,()=>n.current.messages,()=>n.current.messages),l=J.useSyncExternalStore(n.current["~registerStatusCallback"],()=>n.current.status,()=>n.current.status),p=J.useSyncExternalStore(n.current["~registerErrorCallback"],()=>n.current.error,()=>n.current.error),u=J.useCallback(g=>{typeof g=="function"&&(g=g(n.current.messages)),n.current.messages=g},[n]);return J.useEffect(()=>{e&&n.current.resumeStream()},[e,n]),{id:n.current.id,messages:c,setMessages:u,sendMessage:n.current.sendMessage,regenerate:n.current.regenerate,clearError:n.current.clearError,stop:n.current.stop,error:p,resumeStream:n.current.resumeStream,status:l,addToolResult:n.current.addToolOutput,addToolOutput:n.current.addToolOutput,addToolApprovalResponse:n.current.addToolApprovalResponse}}const vr="You are a helpful assistant.",yr=t=>new Ht({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:a})=>({body:{messages:e,stream:!0,...a}})});function Yr(t){const e=W.c(37),{threadId:a,systemPrompt:s,onCreateThread:r,onError:n,onToolCall:i}=t,{org:o,locator:c}=Et(),{slug:l}=o,p=va(),u=ya(),[g,f]=J.useState(null),v=ba(a),b=s||vr;let y;e[0]!==b?(y={id:"system",role:"system",parts:[{type:"text",text:b}]},e[0]=b,e[1]=y):y=e[1];const N=y;let d;e[2]!==v||e[3]!==N?(d=[N,...v],e[2]=v,e[3]=N,e[4]=d):d=e[4];const T=d,A=`${a}:${b}`;let E;e[5]!==l?(E=yr(l),e[5]=l,e[6]=E):E=e[6];const I=E;let P;e[7]!==c||e[8]!==u||e[9]!==r||e[10]!==p||e[11]!==a?(P=async Y=>{const{finishReason:se,messages:Xt,isAbort:Kt,isDisconnect:ea,isError:ta}=Y;if(f(se??null),se!=="stop"||Kt||ea||ta)return;const Ne=Xt.slice(-2).filter(Boolean);if(Ne.length!==2){console.warn("[chat] Expected 2 messages, got",Ne.length);return}u.insertMany.mutate(Ne);const He=Ne.find(xr)?.parts?.find(br)?.text.slice(0,100)||"";if(!await xa(c,a)){if(r)r({id:a,title:He});else{const Qe=new Date().toISOString(),aa={id:a,title:He,created_at:Qe,updated_at:Qe,hidden:!1};p.insert.mutate(aa)}return}p.update.mutate({id:a,updates:{updated_at:new Date().toISOString()}})},e[7]=c,e[8]=u,e[9]=r,e[10]=p,e[11]=a,e[12]=P):P=e[12];const L=P;let U;e[13]!==n?(U=Y=>{console.error("[chat] Chat error:",Y),n?.(Y)},e[13]=n,e[14]=U):U=e[14];let H;e[15]!==T||e[16]!==A||e[17]!==L||e[18]!==i||e[19]!==U||e[20]!==I?(H={id:A,messages:T,transport:I,onFinish:L,onToolCall:i,onError:U},e[15]=T,e[16]=A,e[17]=L,e[18]=i,e[19]=U,e[20]=I,e[21]=H):H=e[21];const C=gr(H);let ie;e[22]!==C?(ie=async(Y,se)=>{!Y?.trim()||C.status==="submitted"||C.status==="streaming"||(f(null),await C.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:Y}],metadata:se},{metadata:se}))},e[22]=C,e[23]=ie):ie=e[23];const Q=ie,fe=C.messages[0]?.role==="system"?C.messages.length===1:C.messages.length===0,le=C.messages,ce=C.status;let D;e[24]!==C?(D=C.stop.bind(C),e[24]=C,e[25]=D):D=e[25];let ue;e[26]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>f(null),e[26]=ue):ue=e[26];let z;return e[27]!==C.clearError||e[28]!==C.error||e[29]!==C.messages||e[30]!==C.setMessages||e[31]!==C.status||e[32]!==g||e[33]!==fe||e[34]!==Q||e[35]!==D?(z={messages:le,status:ce,sendMessage:Q,stop:D,setMessages:C.setMessages,isEmpty:fe,error:C.error,clearError:C.clearError,finishReason:g,clearFinishReason:ue},e[27]=C.clearError,e[28]=C.error,e[29]=C.messages,e[30]=C.setMessages,e[31]=C.status,e[32]=g,e[33]=fe,e[34]=Q,e[35]=D,e[36]=z):z=e[36],z}function br(t){return t.type==="text"}function xr(t){return t.parts?.find(_r)}function _r(t){return t.type==="text"}function wr(t,e){return t.find(e)??t[0]}function Gr(t,e,a,s){const r=W.c(9),n=s===void 0?null:s,[i,o]=_a(t,n);let c;r[0]!==a||r[1]!==i?(c=g=>i!==null?a(g,i):!1,r[0]=a,r[1]=i,r[2]=c):c=r[2];let l;r[3]!==e||r[4]!==c?(l=wr(e,c),r[3]=e,r[4]=c,r[5]=l):l=r[5];const p=l;let u;return r[6]!==p||r[7]!==o?(u=[p,o],r[6]=p,r[7]=o,r[8]=u):u=r[8],u}function Er(t){const e=/\/[^/]+\/mcps\/([^/]+)\/([^/]+)\/([^/]+)/,a=t.match(e);return a&&a[1]&&a[2]&&a[3]?{connectionId:decodeURIComponent(a[1]),collectionName:decodeURIComponent(a[2]),itemId:decodeURIComponent(a[3])}:{connectionId:null,collectionName:null,itemId:null}}function Hr(t){const e=W.c(5),a=ma();let s;e[0]!==a.location.pathname?(s=Er(a.location.pathname),e[0]=a.location.pathname,e[1]=s):s=e[1];const{connectionId:r,collectionName:n,itemId:i}=s,o=wa();let c;e[2]!==t||e[3]!==o?(c=t?o.find(g=>g.id===t):null,e[2]=t,e[3]=o,e[4]=c):c=e[4];const l=c,[p]=Ea(t);let u=`You are an AI assistant running in an MCP Mesh environment.
11
+ `)}})}});var er=Ts(()=>Ft($([O({type:x("text-start"),id:f(),providerMetadata:S.optional()}),O({type:x("text-delta"),id:f(),delta:f(),providerMetadata:S.optional()}),O({type:x("text-end"),id:f(),providerMetadata:S.optional()}),O({type:x("error"),errorText:f()}),O({type:x("tool-input-start"),toolCallId:f(),toolName:f(),providerExecuted:Z().optional(),dynamic:Z().optional(),title:f().optional()}),O({type:x("tool-input-delta"),toolCallId:f(),inputTextDelta:f()}),O({type:x("tool-input-available"),toolCallId:f(),toolName:f(),input:X(),providerExecuted:Z().optional(),providerMetadata:S.optional(),dynamic:Z().optional(),title:f().optional()}),O({type:x("tool-input-error"),toolCallId:f(),toolName:f(),input:X(),providerExecuted:Z().optional(),providerMetadata:S.optional(),dynamic:Z().optional(),errorText:f(),title:f().optional()}),O({type:x("tool-approval-request"),approvalId:f(),toolCallId:f()}),O({type:x("tool-output-available"),toolCallId:f(),output:X(),providerExecuted:Z().optional(),dynamic:Z().optional(),preliminary:Z().optional()}),O({type:x("tool-output-error"),toolCallId:f(),errorText:f(),providerExecuted:Z().optional(),dynamic:Z().optional()}),O({type:x("tool-output-denied"),toolCallId:f()}),O({type:x("reasoning-start"),id:f(),providerMetadata:S.optional()}),O({type:x("reasoning-delta"),id:f(),delta:f(),providerMetadata:S.optional()}),O({type:x("reasoning-end"),id:f(),providerMetadata:S.optional()}),O({type:x("source-url"),sourceId:f(),url:f(),title:f().optional(),providerMetadata:S.optional()}),O({type:x("source-document"),sourceId:f(),mediaType:f(),title:f(),filename:f().optional(),providerMetadata:S.optional()}),O({type:x("file"),url:f(),mediaType:f(),providerMetadata:S.optional()}),O({type:wt(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:f().optional(),data:X(),transient:Z().optional()}),O({type:x("start-step")}),O({type:x("finish-step")}),O({type:x("start"),messageId:f().optional(),messageMetadata:X().optional()}),O({type:x("finish"),finishReason:da(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:X().optional()}),O({type:x("abort"),reason:f().optional()}),O({type:x("message-metadata"),messageMetadata:X()})])));function tr(t){return t.type.startsWith("data-")}function Fe(t){return t.type.startsWith("tool-")}function ar(t){return t.type==="dynamic-tool"}function Be(t){return Fe(t)||ar(t)}function vt(t){return t.type.split("-").slice(1).join("-")}function sr({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function rr({stream:t,messageMetadataSchema:e,dataPartSchemas:a,runUpdateMessageJob:s,onError:r,onToolCall:n,onData:i}){return t.pipeThrough(new TransformStream({async transform(o,c){await s(async({state:l,write:p})=>{var d,g,h,v;function b(u){const A=l.message.parts.filter(Be).find(E=>E.toolCallId===u);if(A==null)throw new Error(`no tool invocation found for tool call ${u}`);return A}function y(u){var T;const A=l.message.parts.find(P=>Fe(P)&&P.toolCallId===u.toolCallId),E=u,I=A;A!=null?(A.state=u.state,I.input=E.input,I.output=E.output,I.errorText=E.errorText,I.rawInput=E.rawInput,I.preliminary=E.preliminary,u.title!==void 0&&(I.title=u.title),I.providerExecuted=(T=E.providerExecuted)!=null?T:A.providerExecuted,E.providerMetadata!=null&&A.state==="input-available"&&(A.callProviderMetadata=E.providerMetadata)):l.message.parts.push({type:`tool-${u.toolName}`,toolCallId:u.toolCallId,state:u.state,title:u.title,input:E.input,output:E.output,rawInput:E.rawInput,errorText:E.errorText,providerExecuted:E.providerExecuted,preliminary:E.preliminary,...E.providerMetadata!=null?{callProviderMetadata:E.providerMetadata}:{}})}function _(u){var T,A;const E=l.message.parts.find(L=>L.type==="dynamic-tool"&&L.toolCallId===u.toolCallId),I=u,P=E;E!=null?(E.state=u.state,P.toolName=u.toolName,P.input=I.input,P.output=I.output,P.errorText=I.errorText,P.rawInput=(T=I.rawInput)!=null?T:P.rawInput,P.preliminary=I.preliminary,u.title!==void 0&&(P.title=u.title),P.providerExecuted=(A=I.providerExecuted)!=null?A:E.providerExecuted,I.providerMetadata!=null&&E.state==="input-available"&&(E.callProviderMetadata=I.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:u.toolName,toolCallId:u.toolCallId,state:u.state,input:I.input,output:I.output,errorText:I.errorText,preliminary:I.preliminary,providerExecuted:I.providerExecuted,title:u.title,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}async function N(u){if(u!=null){const T=l.message.metadata!=null?Gt(l.message.metadata,u):u;e!=null&&await ft({value:T,schema:e}),l.message.metadata=T}}switch(o.type){case"text-start":{const u={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};l.activeTextParts[o.id]=u,l.message.parts.push(u),p();break}case"text-delta":{const u=l.activeTextParts[o.id];u.text+=o.delta,u.providerMetadata=(d=o.providerMetadata)!=null?d:u.providerMetadata,p();break}case"text-end":{const u=l.activeTextParts[o.id];u.state="done",u.providerMetadata=(g=o.providerMetadata)!=null?g:u.providerMetadata,delete l.activeTextParts[o.id],p();break}case"reasoning-start":{const u={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};l.activeReasoningParts[o.id]=u,l.message.parts.push(u),p();break}case"reasoning-delta":{const u=l.activeReasoningParts[o.id];u.text+=o.delta,u.providerMetadata=(h=o.providerMetadata)!=null?h:u.providerMetadata,p();break}case"reasoning-end":{const u=l.activeReasoningParts[o.id];u.providerMetadata=(v=o.providerMetadata)!=null?v:u.providerMetadata,u.state="done",delete l.activeReasoningParts[o.id],p();break}case"file":{l.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url}),p();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),p();break}case"source-document":{l.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),p();break}case"tool-input-start":{const u=l.message.parts.filter(Fe);l.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:u.length,dynamic:o.dynamic,title:o.title},o.dynamic?_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title}),p();break}case"tool-input-delta":{const u=l.partialToolCalls[o.toolCallId];u.text+=o.inputTextDelta;const{value:T}=await Se(u.text);u.dynamic?_({toolCallId:o.toolCallId,toolName:u.toolName,state:"input-streaming",input:T,title:u.title}):y({toolCallId:o.toolCallId,toolName:u.toolName,state:"input-streaming",input:T,title:u.title}),p();break}case"tool-input-available":{o.dynamic?_({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),p(),n&&!o.providerExecuted&&await n({toolCall:o});break}case"tool-input-error":{o.dynamic?_({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),p();break}case"tool-approval-request":{const u=b(o.toolCallId);u.state="approval-requested",u.approval={id:o.approvalId},p();break}case"tool-output-denied":{const u=b(o.toolCallId);u.state="output-denied",p();break}case"tool-output-available":{const u=b(o.toolCallId);u.type==="dynamic-tool"?_({toolCallId:o.toolCallId,toolName:u.toolName,state:"output-available",input:u.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,title:u.title}):y({toolCallId:o.toolCallId,toolName:vt(u),state:"output-available",input:u.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,title:u.title}),p();break}case"tool-output-error":{const u=b(o.toolCallId);u.type==="dynamic-tool"?_({toolCallId:o.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:o.errorText,providerExecuted:o.providerExecuted,title:u.title}):y({toolCallId:o.toolCallId,toolName:vt(u),state:"output-error",input:u.input,rawInput:u.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,title:u.title}),p();break}case"start-step":{l.message.parts.push({type:"step-start"});break}case"finish-step":{l.activeTextParts={},l.activeReasoningParts={};break}case"start":{o.messageId!=null&&(l.message.id=o.messageId),await N(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&p();break}case"finish":{o.finishReason!=null&&(l.finishReason=o.finishReason),await N(o.messageMetadata),o.messageMetadata!=null&&p();break}case"message-metadata":{await N(o.messageMetadata),o.messageMetadata!=null&&p();break}case"error":{r?.(new Error(o.errorText));break}default:if(tr(o)){a?.[o.type]!=null&&await ft({value:o.data,schema:a[o.type]});const u=o;if(u.transient){i?.(u);break}const T=u.id!=null?l.message.parts.find(A=>u.type===A.type&&u.id===A.id):void 0;T!=null?T.data=u.data:l.message.parts.push(u),i?.(u),p()}}c.enqueue(o)})}}))}async function nr({stream:t,onError:e}){const a=t.getReader();try{for(;;){const{done:s}=await a.read();if(s)break}}catch(s){e?.(s)}finally{a.releaseLock()}}Ie({prefix:"aitxt",size:24});Ie({prefix:"aiobj",size:24});var or=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise((e,a)=>{this.queue.push(async()=>{try{await t(),e()}catch(s){a(s)}}),this.processQueue()})}};Ie({prefix:"aiobj",size:24});async function ir(t){if(t==null)return[];if(!globalThis.FileList||!(t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map(async e=>{const{name:a,type:s}=e,r=await new Promise((n,i)=>{const o=new FileReader;o.onload=c=>{var l;n((l=c.target)==null?void 0:l.result)},o.onerror=c=>i(c),o.readAsDataURL(e)});return{type:"file",mediaType:s,filename:a,url:r}}))}var lr=class{constructor({api:t="/api/chat",credentials:e,headers:a,body:s,fetch:r,prepareSendMessagesRequest:n,prepareReconnectToStreamRequest:i}){this.api=t,this.credentials=e,this.headers=a,this.body=s,this.fetch=r,this.prepareSendMessagesRequest=n,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:t,...e}){var a,s,r,n,i;const o=await ee(this.body),c=await ee(this.headers),l=await ee(this.credentials),p={...ne(c),...ne(e.headers)},d=await((a=this.prepareSendMessagesRequest)==null?void 0:a.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...o,...e.body},headers:p,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),g=(s=d?.api)!=null?s:this.api,h=d?.headers!==void 0?ne(d.headers):p,v=d?.body!==void 0?d.body:{...o,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},b=(r=d?.credentials)!=null?r:l,_=await((n=this.fetch)!=null?n:globalThis.fetch)(g,{method:"POST",headers:dt({"Content-Type":"application/json",...h},`ai-sdk/${gt}`,ut()),body:JSON.stringify(v),credentials:b,signal:t});if(!_.ok)throw new Error((i=await _.text())!=null?i:"Failed to fetch the chat response.");if(!_.body)throw new Error("The response body is empty.");return this.processResponseStream(_.body)}async reconnectToStream(t){var e,a,s,r,n;const i=await ee(this.body),o=await ee(this.headers),c=await ee(this.credentials),l={...ne(o),...ne(t.headers)},p=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...i,...t.body},headers:l,credentials:c,requestMetadata:t.metadata})),d=(a=p?.api)!=null?a:`${this.api}/${t.chatId}/stream`,g=p?.headers!==void 0?ne(p.headers):l,h=(s=p?.credentials)!=null?s:c,b=await((r=this.fetch)!=null?r:globalThis.fetch)(d,{method:"GET",headers:dt(g,`ai-sdk/${gt}`,ut()),credentials:h});if(b.status===204)return null;if(!b.ok)throw new Error((n=await b.text())!=null?n:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}},Ht=class extends lr{constructor(t={}){super(t)}processResponseStream(t){return js({stream:t,schema:er}).pipeThrough(new TransformStream({async transform(e,a){if(!e.success)throw e.error;a.enqueue(e.value)}}))}},cr=class{constructor({generateId:t=ka,id:e=t(),transport:a=new Ht,messageMetadataSchema:s,dataPartSchemas:r,state:n,onError:i,onToolCall:o,onFinish:c,onData:l,sendAutomaticallyWhen:p}){this.activeResponse=void 0,this.jobExecutor=new or,this.sendMessage=async(d,g)=>{var h,v,b,y;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...g});return}let _;if("text"in d||"files"in d?_={parts:[...Array.isArray(d.files)?d.files:await ir(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:_=d,d.messageId!=null){const N=this.state.messages.findIndex(u=>u.id===d.messageId);if(N===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[N].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,N+1),this.state.replaceMessage(N,{..._,id:d.messageId,role:(v=_.role)!=null?v:"user",metadata:d.metadata})}else this.state.pushMessage({..._,id:(b=_.id)!=null?b:this.generateId(),role:(y=_.role)!=null?y:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...g})},this.regenerate=async({messageId:d,...g}={})=>{const h=d==null?this.state.messages.length-1:this.state.messages.findIndex(v=>v.id===d);if(h===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...g})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:g,reason:h})=>this.jobExecutor.run(async()=>{var v,b;const y=this.state.messages,_=y[y.length-1],N=u=>Be(u)&&u.state==="approval-requested"&&u.approval.id===d?{...u,state:"approval-responded",approval:{id:d,approved:g,reason:h}}:u;this.state.replaceMessage(y.length-1,{..._,parts:_.parts.map(N)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(N)),this.status!=="streaming"&&this.status!=="submitted"&&((v=this.sendAutomaticallyWhen)!=null&&v.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(b=this.lastMessage)==null?void 0:b.id})}),this.addToolOutput=async({state:d="output-available",tool:g,toolCallId:h,output:v,errorText:b})=>this.jobExecutor.run(async()=>{var y,_;const N=this.state.messages,u=N[N.length-1],T=A=>Be(A)&&A.toolCallId===h?{...A,state:d,output:v,errorText:b}:A;this.state.replaceMessage(N.length-1,{...u,parts:u.parts.map(T)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(T)),this.status!=="streaming"&&this.status!=="submitted"&&((y=this.sendAutomaticallyWhen)!=null&&y.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=a,this.generateId=t,this.messageMetadataSchema=s,this.dataPartSchemas=r,this.state=n,this.onError=i,this.onToolCall=o,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=p}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async makeRequest({trigger:t,metadata:e,headers:a,body:s,messageId:r}){var n,i,o,c;this.setStatus({status:"submitted",error:void 0});const l=this.lastMessage;let p=!1,d=!1,g=!1;try{const h={state:sr({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{p=!0}),this.activeResponse=h;let v;if(t==="resume-stream"){const y=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:a,body:s});if(y==null){this.setStatus({status:"ready"});return}v=y}else v=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:e,headers:a,body:s,trigger:t,messageId:r});const b=y=>this.jobExecutor.run(()=>y({state:h.state,write:()=>{var _;this.setStatus({status:"streaming"}),h.state.message.id===((_=this.lastMessage)==null?void 0:_.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await nr({stream:rr({stream:v,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:b,onError:y=>{throw y}}),onError:y=>{throw y}}),this.setStatus({status:"ready"})}catch(h){if(p||h.name==="AbortError")return p=!0,this.setStatus({status:"ready"}),null;g=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:p,isDisconnect:d,isError:g,finishReason:(n=this.activeResponse)==null?void 0:n.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}(o=this.sendAutomaticallyWhen)!=null&&o.call(this,{messages:this.state.messages})&&!g&&await this.makeRequest({trigger:"submit-message",messageId:(c=this.lastMessage)==null?void 0:c.id,metadata:e,headers:a,body:s})}},ke,yt;function ur(){if(yt)return ke;yt=1;function t(e,a){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let s,r=0;return function(...i){clearTimeout(s);const o=Date.now(),c=o-r,l=a-c;l<=0?(r=o,e.apply(this,i)):s=setTimeout(()=>{r=Date.now(),e.apply(this,i)},l)}}return ke=t,ke}var dr=ur();const pr=pa(dr);var Qt=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)},j=(t,e,a)=>(Qt(t,e,"read from private field"),a?a.call(t):e.get(t)),Y=(t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)},K=(t,e,a,s)=>(Qt(t,e,"write to private field"),e.set(t,a),a);function mr(t,e){return e!=null?pr(t,e):t}var B,Ae,Ce,ge,ve,ye,de,ze,Ve,hr=class{constructor(t=[]){Y(this,B,void 0),Y(this,Ae,"ready"),Y(this,Ce,void 0),Y(this,ge,new Set),Y(this,ve,new Set),Y(this,ye,new Set),this.pushMessage=e=>{K(this,B,j(this,B).concat(e)),j(this,de).call(this)},this.popMessage=()=>{K(this,B,j(this,B).slice(0,-1)),j(this,de).call(this)},this.replaceMessage=(e,a)=>{K(this,B,[...j(this,B).slice(0,e),this.snapshot(a),...j(this,B).slice(e+1)]),j(this,de).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,a)=>{const s=a?mr(e,a):e;return j(this,ge).add(s),()=>{j(this,ge).delete(s)}},this["~registerStatusCallback"]=e=>(j(this,ve).add(e),()=>{j(this,ve).delete(e)}),this["~registerErrorCallback"]=e=>(j(this,ye).add(e),()=>{j(this,ye).delete(e)}),Y(this,de,()=>{j(this,ge).forEach(e=>e())}),Y(this,ze,()=>{j(this,ve).forEach(e=>e())}),Y(this,Ve,()=>{j(this,ye).forEach(e=>e())}),K(this,B,t)}get status(){return j(this,Ae)}set status(t){K(this,Ae,t),j(this,ze).call(this)}get error(){return j(this,Ce)}set error(t){K(this,Ce,t),j(this,Ve).call(this)}get messages(){return j(this,B)}set messages(t){K(this,B,[...t]),j(this,de).call(this)}};B=new WeakMap;Ae=new WeakMap;Ce=new WeakMap;ge=new WeakMap;ve=new WeakMap;ye=new WeakMap;de=new WeakMap;ze=new WeakMap;Ve=new WeakMap;var pe,bt=class extends cr{constructor({messages:t,...e}){const a=new hr(t);super({...e,state:a}),Y(this,pe,void 0),this["~registerMessagesCallback"]=(s,r)=>j(this,pe)["~registerMessagesCallback"](s,r),this["~registerStatusCallback"]=s=>j(this,pe)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>j(this,pe)["~registerErrorCallback"](s),K(this,pe,a)}};pe=new WeakMap;function fr({experimental_throttle:t,resume:e=!1,...a}={}){const s=J.useRef("chat"in a?{}:{onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});"chat"in a||(s.current={onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});const r={...a,onToolCall:g=>{var h,v;return(v=(h=s.current).onToolCall)==null?void 0:v.call(h,g)},onData:g=>{var h,v;return(v=(h=s.current).onData)==null?void 0:v.call(h,g)},onFinish:g=>{var h,v;return(v=(h=s.current).onFinish)==null?void 0:v.call(h,g)},onError:g=>{var h,v;return(v=(h=s.current).onError)==null?void 0:v.call(h,g)},sendAutomaticallyWhen:g=>{var h,v,b;return(b=(v=(h=s.current).sendAutomaticallyWhen)==null?void 0:v.call(h,g))!=null?b:!1}},n=J.useRef("chat"in a?a.chat:new bt(r));("chat"in a&&a.chat!==n.current||"id"in a&&n.current.id!==a.id)&&(n.current="chat"in a?a.chat:new bt(r));const o=J.useCallback(g=>n.current["~registerMessagesCallback"](g,t),[t,n.current.id]),c=J.useSyncExternalStore(o,()=>n.current.messages,()=>n.current.messages),l=J.useSyncExternalStore(n.current["~registerStatusCallback"],()=>n.current.status,()=>n.current.status),p=J.useSyncExternalStore(n.current["~registerErrorCallback"],()=>n.current.error,()=>n.current.error),d=J.useCallback(g=>{typeof g=="function"&&(g=g(n.current.messages)),n.current.messages=g},[n]);return J.useEffect(()=>{e&&n.current.resumeStream()},[e,n]),{id:n.current.id,messages:c,setMessages:d,sendMessage:n.current.sendMessage,regenerate:n.current.regenerate,clearError:n.current.clearError,stop:n.current.stop,error:p,resumeStream:n.current.resumeStream,status:l,addToolResult:n.current.addToolOutput,addToolOutput:n.current.addToolOutput,addToolApprovalResponse:n.current.addToolApprovalResponse}}const gr="You are a helpful assistant.",vr=t=>new Ht({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:a})=>({body:{messages:e,stream:!0,...a}})});function qr(t){const e=G.c(37),{threadId:a,systemPrompt:s,onCreateThread:r,onError:n,onToolCall:i}=t,{org:o,locator:c}=Et(),{slug:l}=o,p=va(),d=ya(),[g,h]=J.useState(null),v=ba(a),b=s||gr;let y;e[0]!==b?(y={id:"system",role:"system",parts:[{type:"text",text:b}]},e[0]=b,e[1]=y):y=e[1];const N=y;let u;e[2]!==v||e[3]!==N?(u=[N,...v],e[2]=v,e[3]=N,e[4]=u):u=e[4];const T=u,A=`${a}:${b}`;let E;e[5]!==l?(E=vr(l),e[5]=l,e[6]=E):E=e[6];const I=E;let P;e[7]!==c||e[8]!==d||e[9]!==r||e[10]!==p||e[11]!==a?(P=async W=>{const{finishReason:se,messages:Xt,isAbort:Kt,isDisconnect:ea,isError:ta}=W;if(h(se??null),se!=="stop"||Kt||ea||ta)return;const Ne=Xt.slice(-2).filter(Boolean);if(Ne.length!==2){console.warn("[chat] Expected 2 messages, got",Ne.length);return}d.insertMany.mutate(Ne);const He=Ne.find(br)?.parts?.find(yr)?.text.slice(0,100)||"";if(!await xa(c,a)){if(r)r({id:a,title:He});else{const Qe=new Date().toISOString(),aa={id:a,title:He,created_at:Qe,updated_at:Qe,hidden:!1};p.insert.mutate(aa)}return}p.update.mutate({id:a,updates:{updated_at:new Date().toISOString()}})},e[7]=c,e[8]=d,e[9]=r,e[10]=p,e[11]=a,e[12]=P):P=e[12];const L=P;let U;e[13]!==n?(U=W=>{console.error("[chat] Chat error:",W),n?.(W)},e[13]=n,e[14]=U):U=e[14];let H;e[15]!==T||e[16]!==A||e[17]!==L||e[18]!==i||e[19]!==U||e[20]!==I?(H={id:A,messages:T,transport:I,onFinish:L,onToolCall:i,onError:U},e[15]=T,e[16]=A,e[17]=L,e[18]=i,e[19]=U,e[20]=I,e[21]=H):H=e[21];const C=fr(H);let ie;e[22]!==C?(ie=async(W,se)=>{!W?.trim()||C.status==="submitted"||C.status==="streaming"||(h(null),await C.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:W}],metadata:se},{metadata:se}))},e[22]=C,e[23]=ie):ie=e[23];const Q=ie,he=C.messages[0]?.role==="system"?C.messages.length===1:C.messages.length===0,le=C.messages,ce=C.status;let D;e[24]!==C?(D=C.stop.bind(C),e[24]=C,e[25]=D):D=e[25];let ue;e[26]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>h(null),e[26]=ue):ue=e[26];let z;return e[27]!==C.clearError||e[28]!==C.error||e[29]!==C.messages||e[30]!==C.setMessages||e[31]!==C.status||e[32]!==g||e[33]!==he||e[34]!==Q||e[35]!==D?(z={messages:le,status:ce,sendMessage:Q,stop:D,setMessages:C.setMessages,isEmpty:he,error:C.error,clearError:C.clearError,finishReason:g,clearFinishReason:ue},e[27]=C.clearError,e[28]=C.error,e[29]=C.messages,e[30]=C.setMessages,e[31]=C.status,e[32]=g,e[33]=he,e[34]=Q,e[35]=D,e[36]=z):z=e[36],z}function yr(t){return t.type==="text"}function br(t){return t.parts?.find(xr)}function xr(t){return t.type==="text"}function _r(t){const e=/\/[^/]+\/mcps\/([^/]+)\/([^/]+)\/([^/]+)/,a=t.match(e);return a&&a[1]&&a[2]&&a[3]?{connectionId:decodeURIComponent(a[1]),collectionName:decodeURIComponent(a[2]),itemId:decodeURIComponent(a[3])}:{connectionId:null,collectionName:null,itemId:null}}function Jr(t){const e=G.c(5),a=ma();let s;e[0]!==a.location.pathname?(s=_r(a.location.pathname),e[0]=a.location.pathname,e[1]=s):s=e[1];const{connectionId:r,collectionName:n,itemId:i}=s,o=_a();let c;e[2]!==t||e[3]!==o?(c=t?o.find(g=>g.id===t):null,e[2]=t,e[3]=o,e[4]=c):c=e[4];const l=c,[p]=wa(t);let d=`You are an AI assistant running in an MCP Mesh environment.
12
12
 
13
13
  ## About MCP Mesh
14
14
  The Model Context Protocol (MCP) Mesh allows users to connect external Connections and expose their capabilities through Agents (also called Gateways). Each Agent provides access to a curated set of tools from connected Connections.
@@ -30,7 +30,7 @@ Follow these guidelines when interacting with users:
30
30
  - Describe the chosen tools to the user, explaining what they do and how they can help
31
31
  - Run code with the chosen tools to better answer the user's request
32
32
 
33
- 3. **Tool Execution**: When using tools, execute them thoughtfully and explain the results to provide a complete answer to the user's request.`;return t&&(u=`You are an AI assistant running in an MCP Mesh environment.
33
+ 3. **Tool Execution**: When using tools, execute them thoughtfully and explain the results to provide a complete answer to the user's request.`;return t&&(d=`You are an AI assistant running in an MCP Mesh environment.
34
34
 
35
35
  ## About MCP Mesh
36
36
  The Model Context Protocol (MCP) Mesh allows users to connect external Connections and expose their capabilities through Agents (also called Gateways). Each Agent provides access to a curated set of tools from connected Connections.
@@ -57,16 +57,16 @@ Follow these guidelines when interacting with users:
57
57
  ## Current Agent/Gateway
58
58
  You are talking to the user through the following Agent/Gateway:
59
59
  - Name: ${l?.title||"Unknown Agent"}
60
- - ID: ${t}`,p?.trim()&&(u=u+`
60
+ - ID: ${t}`,p?.trim()&&(d=d+`
61
61
 
62
62
  ## Agent Instructions
63
63
  The following are specific instructions for this agent:
64
64
 
65
- ${p}`)),(r||n||i)&&(u=u+`
65
+ ${p}`)),(r||n||i)&&(d=d+`
66
66
 
67
- ## Current Editing Context`,r&&(u=u+`
68
- - Connection ID: ${r}`),n&&(u=u+`
69
- - Collection Name: ${n}`),i&&(u=u+`
70
- - Item ID: ${i}`),u=u+`
67
+ ## Current Editing Context`,r&&(d=d+`
68
+ - Connection ID: ${r}`),n&&(d=d+`
69
+ - Collection Name: ${n}`),i&&(d=d+`
70
+ - Item ID: ${i}`),d=d+`
71
71
 
72
- Help the user understand and work with this resource.`),u}const xt=3;function Ir(t){const e=W.c(14),{prompt:a,onSelect:s}=t,r=a.description??a.name;let n;e[0]!==s||e[1]!==a?(n=()=>s(a),e[0]=s,e[1]=a,e[2]=n):n=e[2];const i=a.title??a.name;let o;if(e[3]!==i){let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=/_/g,e[5]=u):u=e[5],o=i.replace(u," "),e[3]=i,e[4]=o}else o=e[4];let c;e[6]!==n||e[7]!==o?(c=m.jsx(Je,{asChild:!0,children:m.jsx("button",{type:"button",onClick:n,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:o})}),e[6]=n,e[7]=o,e[8]=c):c=e[8];let l;e[9]!==r?(l=m.jsx(We,{side:"bottom",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:r})}),e[9]=r,e[10]=l):l=e[10];let p;return e[11]!==c||e[12]!==l?(p=m.jsxs(qe,{children:[c,l]}),e[11]=c,e[12]=l,e[13]=p):p=e[13],p}function Sr(t){const e=W.c(20),{prompts:a,onSelect:s,className:r}=t;if(a.length===0)return null;let n,i,o,c,l;if(e[0]!==r||e[1]!==s||e[2]!==a){const g=a.slice(0,xt),f=a.slice(xt),v=f.length>0;n=It,l=300,e[8]!==r?(i=he("flex flex-wrap items-center justify-center gap-2",r),e[8]=r,e[9]=i):i=e[9];let b;e[10]!==s?(b=y=>m.jsx(Ir,{prompt:y,onSelect:s},y.name),e[10]=s,e[11]=b):b=e[11],o=g.map(b),c=v&&m.jsxs(St,{children:[m.jsx(Nt,{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:["+",f.length]})}),m.jsx(Tt,{side:"bottom",align:"center",className:"w-auto p-2",children:m.jsx("div",{className:"flex flex-col gap-1",children:f.map(y=>{const _=y.description??y.name;return m.jsxs(qe,{children:[m.jsx(Je,{asChild:!0,children:m.jsx("button",{type:"button",onClick:()=>s(y),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:(y.title??y.name).replace(/_/g," ")})}),m.jsx(We,{side:"right",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:_})})]},y.name)})})})]}),e[0]=r,e[1]=s,e[2]=a,e[3]=n,e[4]=i,e[5]=o,e[6]=c,e[7]=l}else n=e[3],i=e[4],o=e[5],c=e[6],l=e[7];let p;e[12]!==i||e[13]!==o||e[14]!==c?(p=m.jsxs("div",{className:i,children:[o,c]}),e[12]=i,e[13]=o,e[14]=c,e[15]=p):p=e[15];let u;return e[16]!==n||e[17]!==l||e[18]!==p?(u=m.jsx(n,{delayDuration:l,children:p}),e[16]=n,e[17]=l,e[18]=p,e[19]=u):u=e[19],u}async function Nr(t){const e=`/mcp/gateway/${t}`,a={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const s=await fetch(e,{method:"POST",headers:a,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(!s.ok)return[];if((await s.json()).error)return[];const n=await fetch(e,{method:"POST",headers:a,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!n.ok)return[];const i=await n.json();return i.error?[]:i.result?.prompts||[]}catch{return[]}}function Tr(t){const e=W.c(7);let a;e[0]!==t?(a=_t.gatewayPrompts(t),e[0]=t,e[1]=a):a=e[1];let s;e[2]!==t?(s=()=>Nr(t),e[2]=t,e[3]=s):s=e[3];let r;return e[4]!==a||e[5]!==s?(r={queryKey:a,queryFn:s,staleTime:6e4,retry:!1},e[4]=a,e[5]=s,e[6]=r):r=e[6],fa(r)}function Qr(t){const e=W.c(4),{gatewayId:a,onSelect:s,className:r}=t,n=r===void 0?"mt-6":r,{data:i}=Tr(a);if(i.length===0)return null;let o;return e[0]!==n||e[1]!==s||e[2]!==i?(o=m.jsx(Sr,{prompts:i,onSelect:s,className:n}),e[0]=n,e[1]=s,e[2]=i,e[3]=o):o=e[3],o}function Xr({title:t="No model provider connected",description:e="Connect to a model provider to unlock AI-powered features.",orgSlug:a,orgId:s,userId:r,allConnections:n,onInstallMcpServer:i}){const[o,c]=J.useState(!1),l=Ia(),p=ha(),u=async()=>{if(!s||!r){Ze.error("Not authenticated");return}c(!0);try{const g=n?.find(b=>b.connection_url===Ta);if(g){p({to:"/$org/mcps/$connectionId",params:{org:a,connectionId:g.id}});return}const f=Aa({id:Ca("conn")}),v=await l.create.mutateAsync(f);p({to:"/$org/mcps/$connectionId",params:{org:a,connectionId:v.id}})}catch(g){Ze.error(`Failed to connect OpenRouter: ${g instanceof Error?g.message:String(g)}`)}finally{c(!1)}};return m.jsx(Sa,{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(Me,{variant:"outline",onClick:u,disabled:o,children:[m.jsx("img",{src:Na,alt:"OpenRouter",className:"size-4"}),o?"Installing...":"Install OpenRouter"]}),m.jsx(Me,{variant:"outline",onClick:i,children:"Install Connection"})]})})}function Ar(t){const e=new Date(t),s=new Date().getTime()-e.getTime(),r=Math.floor(s/6e4),n=Math.floor(s/36e5);return r<1?"now":r<60?`${r}m`:`${n}h`}function Cr(t){const e=new Date,a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),s=new Date(a.getTime()-864e5),r=new Date(a.getTime()-7*864e5),n=new Date(a.getTime()-30*864e5),i=[],o=[],c=[],l=[],p=[];for(const g of t){const f=new Date(g.updated_at);f>=a?i.push(g):f>=s?o.push(g):f>=r?c.push(g):f>=n?l.push(g):p.push(g)}const u=[];return i.length>0&&u.push({label:"Today",threads:i,showRelativeTime:!0}),o.length>0&&u.push({label:"Yesterday",threads:o,showRelativeTime:!1}),c.length>0&&u.push({label:"7 days ago",threads:c,showRelativeTime:!1}),l.length>0&&u.push({label:"30 days ago",threads:l,showRelativeTime:!1}),p.length>0&&u.push({label:"Older",threads:p,showRelativeTime:!1}),u}function Kr(t){const e=W.c(49),{threads:a,activeThreadId:s,onSelectThread:r,onRemoveThread:n,onOpen:i,variant:o}=t,c=o===void 0?"icon":o,[l,p]=J.useState("");let u,g,f,v,b,y,_,N,d,T,A,E;if(e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==l||e[5]!==a||e[6]!==c){const C=l.trim()?a.filter(D=>(D.title||"New chat").toLowerCase().includes(l.toLowerCase())):a,ie=Cr(C);let Q;e[19]!==i?(Q=D=>{D?i?.():p("")},e[19]=i,e[20]=Q):Q=e[20];const fe=Q;v=It,f=qe,g=St,T=fe,e[21]!==c?(A=m.jsx(Je,{asChild:!0,children:m.jsx(Nt,{asChild:!0,children:c==="outline"?m.jsx(Me,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input","aria-label":"Chat history",children:m.jsx(Xe,{size:16})}):m.jsx(Me,{type:"button",variant:"ghost",size:"icon",className:"size-6 p-1 hover:bg-transparent","aria-label":"Chat history",children:m.jsx(Xe,{size:16,className:"text-muted-foreground hover:text-foreground transition-colors"})})})}),e[21]=c,e[22]=A):A=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsx(We,{children:"Chat history"}),e[23]=E):E=e[23],u=Tt,_="end",N="w-80 p-0";let le;e[24]===Symbol.for("react.memo_cache_sentinel")?(le=m.jsx(Ra,{size:16,className:"text-muted-foreground shrink-0"}),e[24]=le):le=e[24];let ce;e[25]===Symbol.for("react.memo_cache_sentinel")?(ce=D=>p(D.target.value),e[25]=ce):ce=e[25],e[26]!==l?(d=m.jsx("div",{className:"border-b",children:m.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[le,m.jsx("input",{type:"text",placeholder:"Search chats...",value:l,onChange:ce,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]=l,e[27]=d):d=e[27],b="max-h-[300px] overflow-y-auto",y=C.length===0?m.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:l.trim()?"No chats found":"No chats yet"}):ie.map((D,ue)=>m.jsxs("div",{children:[ue>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:D.label})}),D.threads.map(z=>{const Y=z.id===s;return m.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 hover:bg-accent cursor-pointer group ${Y?"bg-accent/50":""}`,onClick:()=>r(z.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:z.title||"New chat"}),m.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Y?"current":D.showRelativeTime?Ar(z.updated_at):null})]}),m.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),n(z.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(Ma,{size:14,className:"text-muted-foreground group-hover/trash:text-destructive"})})]},z.id)})]},D.label)),e[0]=s,e[1]=i,e[2]=n,e[3]=r,e[4]=l,e[5]=a,e[6]=c,e[7]=u,e[8]=g,e[9]=f,e[10]=v,e[11]=b,e[12]=y,e[13]=_,e[14]=N,e[15]=d,e[16]=T,e[17]=A,e[18]=E}else u=e[7],g=e[8],f=e[9],v=e[10],b=e[11],y=e[12],_=e[13],N=e[14],d=e[15],T=e[16],A=e[17],E=e[18];let I;e[28]!==b||e[29]!==y?(I=m.jsx("div",{className:b,children:y}),e[28]=b,e[29]=y,e[30]=I):I=e[30];let P;e[31]!==u||e[32]!==I||e[33]!==_||e[34]!==N||e[35]!==d?(P=m.jsxs(u,{align:_,className:N,children:[d,I]}),e[31]=u,e[32]=I,e[33]=_,e[34]=N,e[35]=d,e[36]=P):P=e[36];let L;e[37]!==g||e[38]!==P||e[39]!==T||e[40]!==A||e[41]!==E?(L=m.jsxs(g,{onOpenChange:T,children:[A,E,P]}),e[37]=g,e[38]=P,e[39]=T,e[40]=A,e[41]=E,e[42]=L):L=e[42];let U;e[43]!==f||e[44]!==L?(U=m.jsx(f,{children:L}),e[43]=f,e[44]=L,e[45]=U):U=e[45];let H;return e[46]!==v||e[47]!==U?(H=m.jsx(v,{children:U}),e[46]=v,e[47]=U,e[48]=H):H=e[48],H}export{Jr as D,Qr as G,Xr as N,Kr as T,Hr as a,Wr as b,Yr as c,Gr as u};
72
+ Help the user understand and work with this resource.`),d}const xt=3;function wr(t){const e=G.c(14),{prompt:a,onSelect:s}=t,r=a.description??a.name;let n;e[0]!==s||e[1]!==a?(n=()=>s(a),e[0]=s,e[1]=a,e[2]=n):n=e[2];const i=a.title??a.name;let o;if(e[3]!==i){let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=/_/g,e[5]=d):d=e[5],o=i.replace(d," "),e[3]=i,e[4]=o}else o=e[4];let c;e[6]!==n||e[7]!==o?(c=m.jsx(Je,{asChild:!0,children:m.jsx("button",{type:"button",onClick:n,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:o})}),e[6]=n,e[7]=o,e[8]=c):c=e[8];let l;e[9]!==r?(l=m.jsx(We,{side:"bottom",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:r})}),e[9]=r,e[10]=l):l=e[10];let p;return e[11]!==c||e[12]!==l?(p=m.jsxs(qe,{children:[c,l]}),e[11]=c,e[12]=l,e[13]=p):p=e[13],p}function Er(t){const e=G.c(20),{prompts:a,onSelect:s,className:r}=t;if(a.length===0)return null;let n,i,o,c,l;if(e[0]!==r||e[1]!==s||e[2]!==a){const g=a.slice(0,xt),h=a.slice(xt),v=h.length>0;n=It,l=300,e[8]!==r?(i=fe("flex flex-wrap items-center justify-center gap-2",r),e[8]=r,e[9]=i):i=e[9];let b;e[10]!==s?(b=y=>m.jsx(wr,{prompt:y,onSelect:s},y.name),e[10]=s,e[11]=b):b=e[11],o=g.map(b),c=v&&m.jsxs(St,{children:[m.jsx(Nt,{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(Tt,{side:"bottom",align:"center",className:"w-auto p-2",children:m.jsx("div",{className:"flex flex-col gap-1",children:h.map(y=>{const _=y.description??y.name;return m.jsxs(qe,{children:[m.jsx(Je,{asChild:!0,children:m.jsx("button",{type:"button",onClick:()=>s(y),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:(y.title??y.name).replace(/_/g," ")})}),m.jsx(We,{side:"right",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:_})})]},y.name)})})})]}),e[0]=r,e[1]=s,e[2]=a,e[3]=n,e[4]=i,e[5]=o,e[6]=c,e[7]=l}else n=e[3],i=e[4],o=e[5],c=e[6],l=e[7];let p;e[12]!==i||e[13]!==o||e[14]!==c?(p=m.jsxs("div",{className:i,children:[o,c]}),e[12]=i,e[13]=o,e[14]=c,e[15]=p):p=e[15];let d;return e[16]!==n||e[17]!==l||e[18]!==p?(d=m.jsx(n,{delayDuration:l,children:p}),e[16]=n,e[17]=l,e[18]=p,e[19]=d):d=e[19],d}async function Ir(t){const e=`/mcp/gateway/${t}`,a={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const s=await fetch(e,{method:"POST",headers:a,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(!s.ok)return[];if((await s.json()).error)return[];const n=await fetch(e,{method:"POST",headers:a,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!n.ok)return[];const i=await n.json();return i.error?[]:i.result?.prompts||[]}catch{return[]}}function Sr(t){const e=G.c(7);let a;e[0]!==t?(a=_t.gatewayPrompts(t),e[0]=t,e[1]=a):a=e[1];let s;e[2]!==t?(s=()=>Ir(t),e[2]=t,e[3]=s):s=e[3];let r;return e[4]!==a||e[5]!==s?(r={queryKey:a,queryFn:s,staleTime:6e4,retry:!1},e[4]=a,e[5]=s,e[6]=r):r=e[6],ha(r)}function Wr(t){const e=G.c(4),{gatewayId:a,onSelect:s,className:r}=t,n=r===void 0?"mt-6":r,{data:i}=Sr(a);if(i.length===0)return null;let o;return e[0]!==n||e[1]!==s||e[2]!==i?(o=m.jsx(Er,{prompts:i,onSelect:s,className:n}),e[0]=n,e[1]=s,e[2]=i,e[3]=o):o=e[3],o}function Yr({title:t="No model provider connected",description:e="Connect to a model provider to unlock AI-powered features.",orgSlug:a,orgId:s,userId:r,allConnections:n,onInstallMcpServer:i}){const[o,c]=J.useState(!1),l=Ea(),p=fa(),d=async()=>{if(!s||!r){Ze.error("Not authenticated");return}c(!0);try{const g=n?.find(b=>b.connection_url===Na);if(g){p({to:"/$org/mcps/$connectionId",params:{org:a,connectionId:g.id}});return}const h=Ta({id:Aa("conn")}),v=await l.create.mutateAsync(h);p({to:"/$org/mcps/$connectionId",params:{org:a,connectionId:v.id}})}catch(g){Ze.error(`Failed to connect OpenRouter: ${g instanceof Error?g.message:String(g)}`)}finally{c(!1)}};return m.jsx(Ia,{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(Me,{variant:"outline",onClick:d,disabled:o,children:[m.jsx("img",{src:Sa,alt:"OpenRouter",className:"size-4"}),o?"Installing...":"Install OpenRouter"]}),m.jsx(Me,{variant:"outline",onClick:i,children:"Install Connection"})]})})}function Nr(t){const e=new Date(t),s=new Date().getTime()-e.getTime(),r=Math.floor(s/6e4),n=Math.floor(s/36e5);return r<1?"now":r<60?`${r}m`:`${n}h`}function Tr(t){const e=new Date,a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),s=new Date(a.getTime()-864e5),r=new Date(a.getTime()-7*864e5),n=new Date(a.getTime()-30*864e5),i=[],o=[],c=[],l=[],p=[];for(const g of t){const h=new Date(g.updated_at);h>=a?i.push(g):h>=s?o.push(g):h>=r?c.push(g):h>=n?l.push(g):p.push(g)}const d=[];return i.length>0&&d.push({label:"Today",threads:i,showRelativeTime:!0}),o.length>0&&d.push({label:"Yesterday",threads:o,showRelativeTime:!1}),c.length>0&&d.push({label:"7 days ago",threads:c,showRelativeTime:!1}),l.length>0&&d.push({label:"30 days ago",threads:l,showRelativeTime:!1}),p.length>0&&d.push({label:"Older",threads:p,showRelativeTime:!1}),d}function Gr(t){const e=G.c(49),{threads:a,activeThreadId:s,onSelectThread:r,onRemoveThread:n,onOpen:i,variant:o}=t,c=o===void 0?"icon":o,[l,p]=J.useState("");let d,g,h,v,b,y,_,N,u,T,A,E;if(e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==l||e[5]!==a||e[6]!==c){const C=l.trim()?a.filter(D=>(D.title||"New chat").toLowerCase().includes(l.toLowerCase())):a,ie=Tr(C);let Q;e[19]!==i?(Q=D=>{D?i?.():p("")},e[19]=i,e[20]=Q):Q=e[20];const he=Q;v=It,h=qe,g=St,T=he,e[21]!==c?(A=m.jsx(Je,{asChild:!0,children:m.jsx(Nt,{asChild:!0,children:c==="outline"?m.jsx(Me,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input","aria-label":"Chat history",children:m.jsx(Xe,{size:16})}):m.jsx(Me,{type:"button",variant:"ghost",size:"icon",className:"size-6 p-1 hover:bg-transparent","aria-label":"Chat history",children:m.jsx(Xe,{size:16,className:"text-muted-foreground hover:text-foreground transition-colors"})})})}),e[21]=c,e[22]=A):A=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsx(We,{children:"Chat history"}),e[23]=E):E=e[23],d=Tt,_="end",N="w-80 p-0";let le;e[24]===Symbol.for("react.memo_cache_sentinel")?(le=m.jsx(Ca,{size:16,className:"text-muted-foreground shrink-0"}),e[24]=le):le=e[24];let ce;e[25]===Symbol.for("react.memo_cache_sentinel")?(ce=D=>p(D.target.value),e[25]=ce):ce=e[25],e[26]!==l?(u=m.jsx("div",{className:"border-b",children:m.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[le,m.jsx("input",{type:"text",placeholder:"Search chats...",value:l,onChange:ce,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]=l,e[27]=u):u=e[27],b="max-h-[300px] overflow-y-auto",y=C.length===0?m.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:l.trim()?"No chats found":"No chats yet"}):ie.map((D,ue)=>m.jsxs("div",{children:[ue>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:D.label})}),D.threads.map(z=>{const W=z.id===s;return m.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 hover:bg-accent cursor-pointer group ${W?"bg-accent/50":""}`,onClick:()=>r(z.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:z.title||"New chat"}),m.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:W?"current":D.showRelativeTime?Nr(z.updated_at):null})]}),m.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),n(z.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(Ra,{size:14,className:"text-muted-foreground group-hover/trash:text-destructive"})})]},z.id)})]},D.label)),e[0]=s,e[1]=i,e[2]=n,e[3]=r,e[4]=l,e[5]=a,e[6]=c,e[7]=d,e[8]=g,e[9]=h,e[10]=v,e[11]=b,e[12]=y,e[13]=_,e[14]=N,e[15]=u,e[16]=T,e[17]=A,e[18]=E}else d=e[7],g=e[8],h=e[9],v=e[10],b=e[11],y=e[12],_=e[13],N=e[14],u=e[15],T=e[16],A=e[17],E=e[18];let I;e[28]!==b||e[29]!==y?(I=m.jsx("div",{className:b,children:y}),e[28]=b,e[29]=y,e[30]=I):I=e[30];let P;e[31]!==d||e[32]!==I||e[33]!==_||e[34]!==N||e[35]!==u?(P=m.jsxs(d,{align:_,className:N,children:[u,I]}),e[31]=d,e[32]=I,e[33]=_,e[34]=N,e[35]=u,e[36]=P):P=e[36];let L;e[37]!==g||e[38]!==P||e[39]!==T||e[40]!==A||e[41]!==E?(L=m.jsxs(g,{onOpenChange:T,children:[A,E,P]}),e[37]=g,e[38]=P,e[39]=T,e[40]=A,e[41]=E,e[42]=L):L=e[42];let U;e[43]!==h||e[44]!==L?(U=m.jsx(h,{children:L}),e[43]=h,e[44]=L,e[45]=U):U=e[45];let H;return e[46]!==v||e[47]!==U?(H=m.jsx(v,{children:U}),e[46]=v,e[47]=U,e[48]=H):H=e[48],H}export{zr as D,Wr as G,Yr as N,Gr as T,Vr as a,qr as b,Jr as u};
@@ -1 +1 @@
1
- import{r as v,c as z,j as t}from"./index-Dc4mPG7D.js";import{I as F,u as R}from"./use-connection-D1oWmd80.js";import{C as I}from"./checkbox-B6_pb64c.js";import{c as T,B as A}from"./input-CLQFaB_P.js";import{i as U}from"./ArrowLeft-WX776rGw.js";import{C as V}from"./collection-search-DCk3URyd.js";const q=v.memo(function(S){const e=z.c(21),{connection:o,isSelected:m,hasToolsEnabled:r,activeToolsCount:h,totalToolsCount:p,onSelect:g,onToggle:x}=S,u=m?"bg-accent/50":"hover:bg-muted/50";let i;e[0]!==u?(i=T("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",u),e[0]=u,e[1]=i):i=e[1];let c;e[2]!==o.icon||e[3]!==o.title?(c=t.jsx(F,{icon:o.icon,name:o.title,size:"xs"}),e[2]=o.icon,e[3]=o.title,e[4]=c):c=e[4];let f;e[5]!==o.title?(f=t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:o.title})}),e[5]=o.title,e[6]=f):f=e[6];let n;e[7]!==g||e[8]!==c||e[9]!==f?(n=t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:g,children:[c,f]}),e[7]=g,e[8]=c,e[9]=f,e[10]=n):n=e[10];let a;e[11]!==h||e[12]!==o.tools||e[13]!==r||e[14]!==x||e[15]!==p?(a=o.tools&&o.tools.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[h,"/",p]}),t.jsx(I,{checked:r,onCheckedChange:x,onClick:H})]}),e[11]=h,e[12]=o.tools,e[13]=r,e[14]=x,e[15]=p,e[16]=a):a=e[16];let N;return e[17]!==i||e[18]!==n||e[19]!==a?(N=t.jsxs("div",{className:i,children:[n,a]}),e[17]=i,e[18]=n,e[19]=a,e[20]=N):N=e[20],N}),G=v.memo(function(S){const e=z.c(18),{connectionId:o,tool:m,isSelected:r,onToggle:h}=S,p=`tool-${o}-${m.name}`,g=r?"text-foreground":"text-muted-foreground";let x;e[0]!==g?(x=T("text-sm font-medium",g),e[0]=g,e[1]=x):x=e[1];let u;e[2]!==x||e[3]!==m.name?(u=t.jsx("div",{className:"flex items-center gap-2 mb-1",children:t.jsx("span",{className:x,children:m.name})}),e[2]=x,e[3]=m.name,e[4]=u):u=e[4];let i;e[5]!==m.description?(i=m.description&&t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:m.description}),e[5]=m.description,e[6]=i):i=e[6];let c;e[7]!==u||e[8]!==i?(c=t.jsxs("div",{className:"flex-1 min-w-0",children:[u,i]}),e[7]=u,e[8]=i,e[9]=c):c=e[9];const f=`tool-${o}-${m.name}`;let n;e[10]!==r||e[11]!==h||e[12]!==f?(n=t.jsx("div",{className:"flex items-center shrink-0",children:t.jsx(I,{id:f,checked:r,onCheckedChange:h,onClick:J})}),e[10]=r,e[11]=h,e[12]=f,e[13]=n):n=e[13];let a;return e[14]!==p||e[15]!==c||e[16]!==n?(a=t.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:p,children:[c,n]}),e[14]=p,e[15]=c,e[16]=n,e[17]=a):a=e[17],a});function _({toolSet:d,onToolSetChange:S}){const[e,o]=v.useState(""),m=v.useDeferredValue(e),[r,h]=v.useState("all"),[p,g]=v.useState(!1),x=v.useRef(new Set(Object.keys(d))),u=R({searchTerm:m.trim()||void 0}),i=x.current,c=[...i.values()].map(s=>u.find(l=>l.id===s)).filter(s=>s!==void 0),f=u.filter(s=>!i.has(s.id)),n=[...c,...f],a=s=>{const l=d[s];return l!==void 0&&l.length>0},N=n.filter(s=>{if(r==="all")return!0;const l=a(s.id);return r==="selected"?l:r==="unselected"?!l:!0}),[M,$]=v.useState(n[0]?.id??null),b=M?n.find(s=>s.id===M)??null:null,E=b?.tools??[],B=(s,l)=>d[s]?.includes(l)??!1,D=(s,l)=>{const j=d[s]??[],k=j.includes(l),w={...d};if(k){const y=j.filter(C=>C!==l);y.length===0?delete w[s]:w[s]=y}else w[s]=[...j,l];S(w)},O=s=>{const l=n.find(C=>C.id===s);if(!l?.tools)return;const j=d[s]??[],k=l.tools.map(C=>C.name),w=j.length>0&&k.every(C=>j.includes(C)),y={...d};w?delete y[s]:(y[s]=k,$(s)),S(y)},P=s=>{$(s),g(!0)},Q=()=>{g(!1)};return t.jsxs("div",{className:"flex h-full",children:[t.jsxs("div",{className:T("w-full md:w-80 border-r border-border flex flex-col",p&&"hidden md:flex"),children:[t.jsx(V,{value:e,onChange:o,placeholder:"Search MCP Servers..."}),t.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[t.jsx("button",{onClick:()=>h("all"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),t.jsx("button",{onClick:()=>h("selected"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),t.jsx("button",{onClick:()=>h("unselected"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:N.length===0?t.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:e?"No connections found":r==="selected"?"No servers selected":r==="unselected"?"No unselected servers":"No connections available"}):t.jsx("div",{className:"p-2 space-y-1",children:N.map(s=>{const l=s.tools?.length??0,j=d[s.id]?.length??0;return t.jsx(q,{connection:s,isSelected:M===s.id,hasToolsEnabled:a(s.id),activeToolsCount:j,totalToolsCount:l,onSelect:()=>P(s.id),onToggle:()=>O(s.id)},s.id)})})})]}),t.jsx("div",{className:T("flex-1 flex-col",p?"flex":"hidden md:flex"),children:b?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[t.jsx(A,{variant:"ghost",size:"sm",onClick:Q,className:"h-8 w-8 p-0 shrink-0",children:t.jsx(U,{size:20})}),t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[t.jsx(F,{icon:b.icon,name:b.title,size:"sm"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:b.title}),b.description&&t.jsx("p",{className:"text-sm text-muted-foreground truncate",children:b.description})]})]})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:E.length===0?t.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):t.jsx("div",{className:"space-y-2",children:E.map(s=>t.jsx(G,{connectionId:b.id,tool:s,isSelected:B(b.id,s.name),onToggle:()=>D(b.id,s.name)},s.name))})})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function H(d){return d.stopPropagation()}function J(d){return d.stopPropagation()}export{_ as T};
1
+ import{r as v,c as z,j as t}from"./index-D825aBGT.js";import{I as F,u as R}from"./use-connection-CJ5nWy0c.js";import{C as I}from"./checkbox-y4VvHU-Y.js";import{c as T,B as A}from"./input-CUSLU-5Y.js";import{i as U}from"./ArrowLeft-I0eE0ajz.js";import{C as V}from"./collection-search-C8qrPxpe.js";const q=v.memo(function(S){const e=z.c(21),{connection:o,isSelected:m,hasToolsEnabled:r,activeToolsCount:h,totalToolsCount:p,onSelect:g,onToggle:x}=S,u=m?"bg-accent/50":"hover:bg-muted/50";let i;e[0]!==u?(i=T("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",u),e[0]=u,e[1]=i):i=e[1];let c;e[2]!==o.icon||e[3]!==o.title?(c=t.jsx(F,{icon:o.icon,name:o.title,size:"xs"}),e[2]=o.icon,e[3]=o.title,e[4]=c):c=e[4];let f;e[5]!==o.title?(f=t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:o.title})}),e[5]=o.title,e[6]=f):f=e[6];let n;e[7]!==g||e[8]!==c||e[9]!==f?(n=t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:g,children:[c,f]}),e[7]=g,e[8]=c,e[9]=f,e[10]=n):n=e[10];let a;e[11]!==h||e[12]!==o.tools||e[13]!==r||e[14]!==x||e[15]!==p?(a=o.tools&&o.tools.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[h,"/",p]}),t.jsx(I,{checked:r,onCheckedChange:x,onClick:H})]}),e[11]=h,e[12]=o.tools,e[13]=r,e[14]=x,e[15]=p,e[16]=a):a=e[16];let N;return e[17]!==i||e[18]!==n||e[19]!==a?(N=t.jsxs("div",{className:i,children:[n,a]}),e[17]=i,e[18]=n,e[19]=a,e[20]=N):N=e[20],N}),G=v.memo(function(S){const e=z.c(18),{connectionId:o,tool:m,isSelected:r,onToggle:h}=S,p=`tool-${o}-${m.name}`,g=r?"text-foreground":"text-muted-foreground";let x;e[0]!==g?(x=T("text-sm font-medium",g),e[0]=g,e[1]=x):x=e[1];let u;e[2]!==x||e[3]!==m.name?(u=t.jsx("div",{className:"flex items-center gap-2 mb-1",children:t.jsx("span",{className:x,children:m.name})}),e[2]=x,e[3]=m.name,e[4]=u):u=e[4];let i;e[5]!==m.description?(i=m.description&&t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:m.description}),e[5]=m.description,e[6]=i):i=e[6];let c;e[7]!==u||e[8]!==i?(c=t.jsxs("div",{className:"flex-1 min-w-0",children:[u,i]}),e[7]=u,e[8]=i,e[9]=c):c=e[9];const f=`tool-${o}-${m.name}`;let n;e[10]!==r||e[11]!==h||e[12]!==f?(n=t.jsx("div",{className:"flex items-center shrink-0",children:t.jsx(I,{id:f,checked:r,onCheckedChange:h,onClick:J})}),e[10]=r,e[11]=h,e[12]=f,e[13]=n):n=e[13];let a;return e[14]!==p||e[15]!==c||e[16]!==n?(a=t.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:p,children:[c,n]}),e[14]=p,e[15]=c,e[16]=n,e[17]=a):a=e[17],a});function _({toolSet:d,onToolSetChange:S}){const[e,o]=v.useState(""),m=v.useDeferredValue(e),[r,h]=v.useState("all"),[p,g]=v.useState(!1),x=v.useRef(new Set(Object.keys(d))),u=R({searchTerm:m.trim()||void 0}),i=x.current,c=[...i.values()].map(s=>u.find(l=>l.id===s)).filter(s=>s!==void 0),f=u.filter(s=>!i.has(s.id)),n=[...c,...f],a=s=>{const l=d[s];return l!==void 0&&l.length>0},N=n.filter(s=>{if(r==="all")return!0;const l=a(s.id);return r==="selected"?l:r==="unselected"?!l:!0}),[M,$]=v.useState(n[0]?.id??null),b=M?n.find(s=>s.id===M)??null:null,E=b?.tools??[],B=(s,l)=>d[s]?.includes(l)??!1,D=(s,l)=>{const j=d[s]??[],k=j.includes(l),w={...d};if(k){const y=j.filter(C=>C!==l);y.length===0?delete w[s]:w[s]=y}else w[s]=[...j,l];S(w)},O=s=>{const l=n.find(C=>C.id===s);if(!l?.tools)return;const j=d[s]??[],k=l.tools.map(C=>C.name),w=j.length>0&&k.every(C=>j.includes(C)),y={...d};w?delete y[s]:(y[s]=k,$(s)),S(y)},P=s=>{$(s),g(!0)},Q=()=>{g(!1)};return t.jsxs("div",{className:"flex h-full",children:[t.jsxs("div",{className:T("w-full md:w-80 border-r border-border flex flex-col",p&&"hidden md:flex"),children:[t.jsx(V,{value:e,onChange:o,placeholder:"Search MCP Servers..."}),t.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[t.jsx("button",{onClick:()=>h("all"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),t.jsx("button",{onClick:()=>h("selected"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),t.jsx("button",{onClick:()=>h("unselected"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:N.length===0?t.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:e?"No connections found":r==="selected"?"No servers selected":r==="unselected"?"No unselected servers":"No connections available"}):t.jsx("div",{className:"p-2 space-y-1",children:N.map(s=>{const l=s.tools?.length??0,j=d[s.id]?.length??0;return t.jsx(q,{connection:s,isSelected:M===s.id,hasToolsEnabled:a(s.id),activeToolsCount:j,totalToolsCount:l,onSelect:()=>P(s.id),onToggle:()=>O(s.id)},s.id)})})})]}),t.jsx("div",{className:T("flex-1 flex-col",p?"flex":"hidden md:flex"),children:b?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[t.jsx(A,{variant:"ghost",size:"sm",onClick:Q,className:"h-8 w-8 p-0 shrink-0",children:t.jsx(U,{size:20})}),t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[t.jsx(F,{icon:b.icon,name:b.title,size:"sm"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:b.title}),b.description&&t.jsx("p",{className:"text-sm text-muted-foreground truncate",children:b.description})]})]})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:E.length===0?t.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):t.jsx("div",{className:"space-y-2",children:E.map(s=>t.jsx(G,{connectionId:b.id,tool:s,isSelected:B(b.id,s.name),onToggle:()=>D(b.id,s.name)},s.name))})})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function H(d){return d.stopPropagation()}function J(d){return d.stopPropagation()}export{_ as T};
@@ -1 +1 @@
1
- import{K as B,j as t,c as O,f as Q,r as k}from"./index-Dc4mPG7D.js";import{u as U}from"./useQuery-CjN7yze9.js";import{i as W}from"./File06-lv7rH_v1.js";import{i as Y}from"./Loading01-nz4zkIiQ.js";import{e as J}from"./github-icon-Dp3wHhYE.js";import{C as P}from"./collection-display-button-0kCgwjcX.js";import{C as X}from"./collection-search-DCk3URyd.js";import{C as Z}from"./collection-table-wrapper-DbtYisXO.js";import{E as z,I as ee}from"./use-connection-D1oWmd80.js";import{C as te}from"./card-VaGCmdRN.js";import{V as se}from"./layout-D-qTqL0P.js";function oe(s){return s.replace(/<a[^>]*class="[^"]*anchor[^"]*"[^>]*>.*?<\/a>/gi,"")}function re(s){return s.replace(/<a\s+([^>]*href="[^"]*"[^>]*)>/gi,(e,i)=>i.includes("target=")?e.replace(/target="[^"]*"/gi,'target="_blank"'):`<a ${i} target="_blank" rel="noopener noreferrer">`)}function ne(s){let e=oe(s);return e=re(e),e}function we({repository:s}){const e=s?J(s):null,{data:i,isLoading:c}=U({queryKey:B.githubReadme(e?.owner,e?.repo),queryFn:async()=>{if(!e)return null;try{const l=await fetch(`https://api.github.com/repos/${e.owner}/${e.repo}/readme`,{headers:{Accept:"application/vnd.github.v3.html"}});if(!l.ok){if(l.status===404)return null;throw new Error(`Failed to fetch README: ${l.statusText}`)}const m=await l.text();return ne(m)}catch(l){return console.error("Error fetching README:",l),null}},enabled:!!e&&!!s,staleTime:3600*1e3,gcTime:1440*60*1e3});return c?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Y,{size:32,className:"animate-spin text-muted-foreground"})}):i?t.jsx("div",{className:"p-5 markdown-body",style:{backgroundColor:"transparent"},dangerouslySetInnerHTML:{__html:i}}):t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-6",children:[t.jsx(W,{size:48,className:"text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"README not found"}),t.jsx("p",{className:"text-muted-foreground max-w-md",children:"This repository doesn't have a README file, or it's not publicly accessible."})]})}function ve(s){const e=O.c(39),{tools:i,connectionId:c,org:l,onToolClick:m,showToolbar:L,emptyMessage:M}=s,D=L===void 0?!0:L,j=M===void 0?"This connection doesn't have any tools yet.":M,I=Q(),[n,$]=k.useState(""),[d,H]=k.useState("table"),[r,A]=k.useState("name"),[a,_]=k.useState("asc");let y;e[0]!==a||e[1]!==r?(y=o=>{r===o?(_(me),a==="desc"&&A(void 0)):(A(o),_("asc"))},e[0]=a,e[1]=r,e[2]=y):y=e[2];const u=y;let N;e[3]!==c||e[4]!==I||e[5]!==m||e[6]!==l?(N=o=>{m?m(o):c&&l&&I({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:l,connectionId:c,collectionName:"tools",itemId:encodeURIComponent(o.name)}})},e[3]=c,e[4]=I,e[5]=m,e[6]=l,e[7]=N):N=e[7];const w=N;let v;if(e[8]!==n||e[9]!==a||e[10]!==r||e[11]!==i){const o=!i||i.length===0?[]:n.trim()?(()=>{const R=n.toLowerCase();return i.filter(b=>b.name.toLowerCase().includes(R)||b.description&&b.description.toLowerCase().includes(R))})():i;v=!r||!a?o:[...o].sort((R,b)=>{const q=R[r]||"",G=b[r]||"",K=String(q).localeCompare(String(G));return a==="asc"?K:-K}),e[8]=n,e[9]=a,e[10]=r,e[11]=i,e[12]=v}else v=e[12];const g=v;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=[{id:"name",header:"Name",render:ce,sortable:!0},{id:"description",header:"Description",render:le,cellClassName:"flex-1",sortable:!0}],e[13]=C):C=e[13];const V=C;let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=V.filter(ie).map(ae),e[14]=S):S=e[14];const F=S;let f;e[15]!==u||e[16]!==D||e[17]!==a||e[18]!==r||e[19]!==d?(f=D&&t.jsx(se,{children:t.jsx(P,{viewMode:d,onViewModeChange:H,sortKey:r,sortDirection:a,onSort:u,sortOptions:F})}),e[15]=u,e[16]=D,e[17]=a,e[18]=r,e[19]=d,e[20]=f):f=e[20];let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=o=>{o.key==="Escape"&&($(""),o.target.blur())},e[21]=E):E=e[21];let p;e[22]!==n?(p=t.jsx(X,{value:n,onChange:$,placeholder:"Search tools...",onKeyDown:E}),e[22]=n,e[23]=p):p=e[23];let h;e[24]!==j||e[25]!==u||e[26]!==w||e[27]!==n||e[28]!==a||e[29]!==r||e[30]!==g||e[31]!==d?(h=d==="cards"?t.jsx("div",{className:"flex-1 overflow-auto p-5",children:g.length===0?t.jsx(z,{image:null,title:n?"No tools found":"No tools available",description:n?"Try adjusting your search terms":j}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:g.map(o=>t.jsx(te,{className:"cursor-pointer transition-colors",onClick:()=>w(o),children:t.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[t.jsx(ee,{icon:null,name:o.name,size:"md",className:"shrink-0 shadow-sm"}),t.jsxs("div",{className:"flex flex-col gap-0",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:o.name}),t.jsx("p",{className:"text-base text-muted-foreground line-clamp-2",children:o.description||"No description"})]})]})},o.name))})}):t.jsx(Z,{columns:V,data:g,isLoading:!1,sortKey:r,sortDirection:a,onSort:u,onRowClick:o=>w(o),emptyState:t.jsx(z,{image:null,title:n?"No tools found":"No tools available",description:n?"Try adjusting your search terms":j})}),e[24]=j,e[25]=u,e[26]=w,e[27]=n,e[28]=a,e[29]=r,e[30]=g,e[31]=d,e[32]=h):h=e[32];let x;e[33]!==p||e[34]!==h?(x=t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p,h]}),e[33]=p,e[34]=h,e[35]=x):x=e[35];let T;return e[36]!==x||e[37]!==f?(T=t.jsxs(t.Fragment,{children:[f,x]}),e[36]=x,e[37]=f,e[38]=T):T=e[38],T}function ae(s){return{id:s.id,label:typeof s.header=="string"?s.header:s.id}}function ie(s){return s.sortable}function le(s){return t.jsx("span",{className:"text-sm text-foreground",children:s.description||"—"})}function ce(s){return t.jsx("span",{className:"text-sm font-medium font-mono text-foreground",children:s.name})}function me(s){return s==="asc"?"desc":s==="desc"?null:"asc"}export{we as R,ve as T};
1
+ import{K as B,j as t,c as O,f as Q,r as k}from"./index-D825aBGT.js";import{u as U}from"./useQuery-El_kGGDY.js";import{i as W}from"./File06-DD5RANl_.js";import{i as Y}from"./Loading01-BGeWv0Kv.js";import{e as J}from"./github-icon-Dp3wHhYE.js";import{C as P}from"./collection-display-button-D_pspwv8.js";import{C as X}from"./collection-search-C8qrPxpe.js";import{C as Z}from"./collection-table-wrapper-m6-zCmZ8.js";import{E as z,I as ee}from"./use-connection-CJ5nWy0c.js";import{C as te}from"./card-DUrBojml.js";import{V as se}from"./layout-DiLh4D4s.js";function oe(s){return s.replace(/<a[^>]*class="[^"]*anchor[^"]*"[^>]*>.*?<\/a>/gi,"")}function re(s){return s.replace(/<a\s+([^>]*href="[^"]*"[^>]*)>/gi,(e,i)=>i.includes("target=")?e.replace(/target="[^"]*"/gi,'target="_blank"'):`<a ${i} target="_blank" rel="noopener noreferrer">`)}function ne(s){let e=oe(s);return e=re(e),e}function we({repository:s}){const e=s?J(s):null,{data:i,isLoading:c}=U({queryKey:B.githubReadme(e?.owner,e?.repo),queryFn:async()=>{if(!e)return null;try{const l=await fetch(`https://api.github.com/repos/${e.owner}/${e.repo}/readme`,{headers:{Accept:"application/vnd.github.v3.html"}});if(!l.ok){if(l.status===404)return null;throw new Error(`Failed to fetch README: ${l.statusText}`)}const m=await l.text();return ne(m)}catch(l){return console.error("Error fetching README:",l),null}},enabled:!!e&&!!s,staleTime:3600*1e3,gcTime:1440*60*1e3});return c?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Y,{size:32,className:"animate-spin text-muted-foreground"})}):i?t.jsx("div",{className:"p-5 markdown-body",style:{backgroundColor:"transparent"},dangerouslySetInnerHTML:{__html:i}}):t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-6",children:[t.jsx(W,{size:48,className:"text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"README not found"}),t.jsx("p",{className:"text-muted-foreground max-w-md",children:"This repository doesn't have a README file, or it's not publicly accessible."})]})}function ve(s){const e=O.c(39),{tools:i,connectionId:c,org:l,onToolClick:m,showToolbar:L,emptyMessage:M}=s,D=L===void 0?!0:L,j=M===void 0?"This connection doesn't have any tools yet.":M,I=Q(),[n,$]=k.useState(""),[d,H]=k.useState("table"),[r,A]=k.useState("name"),[a,_]=k.useState("asc");let y;e[0]!==a||e[1]!==r?(y=o=>{r===o?(_(me),a==="desc"&&A(void 0)):(A(o),_("asc"))},e[0]=a,e[1]=r,e[2]=y):y=e[2];const u=y;let N;e[3]!==c||e[4]!==I||e[5]!==m||e[6]!==l?(N=o=>{m?m(o):c&&l&&I({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:l,connectionId:c,collectionName:"tools",itemId:encodeURIComponent(o.name)}})},e[3]=c,e[4]=I,e[5]=m,e[6]=l,e[7]=N):N=e[7];const w=N;let v;if(e[8]!==n||e[9]!==a||e[10]!==r||e[11]!==i){const o=!i||i.length===0?[]:n.trim()?(()=>{const R=n.toLowerCase();return i.filter(b=>b.name.toLowerCase().includes(R)||b.description&&b.description.toLowerCase().includes(R))})():i;v=!r||!a?o:[...o].sort((R,b)=>{const q=R[r]||"",G=b[r]||"",K=String(q).localeCompare(String(G));return a==="asc"?K:-K}),e[8]=n,e[9]=a,e[10]=r,e[11]=i,e[12]=v}else v=e[12];const g=v;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=[{id:"name",header:"Name",render:ce,sortable:!0},{id:"description",header:"Description",render:le,cellClassName:"flex-1",sortable:!0}],e[13]=C):C=e[13];const V=C;let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=V.filter(ie).map(ae),e[14]=S):S=e[14];const F=S;let f;e[15]!==u||e[16]!==D||e[17]!==a||e[18]!==r||e[19]!==d?(f=D&&t.jsx(se,{children:t.jsx(P,{viewMode:d,onViewModeChange:H,sortKey:r,sortDirection:a,onSort:u,sortOptions:F})}),e[15]=u,e[16]=D,e[17]=a,e[18]=r,e[19]=d,e[20]=f):f=e[20];let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=o=>{o.key==="Escape"&&($(""),o.target.blur())},e[21]=E):E=e[21];let p;e[22]!==n?(p=t.jsx(X,{value:n,onChange:$,placeholder:"Search tools...",onKeyDown:E}),e[22]=n,e[23]=p):p=e[23];let h;e[24]!==j||e[25]!==u||e[26]!==w||e[27]!==n||e[28]!==a||e[29]!==r||e[30]!==g||e[31]!==d?(h=d==="cards"?t.jsx("div",{className:"flex-1 overflow-auto p-5",children:g.length===0?t.jsx(z,{image:null,title:n?"No tools found":"No tools available",description:n?"Try adjusting your search terms":j}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:g.map(o=>t.jsx(te,{className:"cursor-pointer transition-colors",onClick:()=>w(o),children:t.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[t.jsx(ee,{icon:null,name:o.name,size:"md",className:"shrink-0 shadow-sm"}),t.jsxs("div",{className:"flex flex-col gap-0",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:o.name}),t.jsx("p",{className:"text-base text-muted-foreground line-clamp-2",children:o.description||"No description"})]})]})},o.name))})}):t.jsx(Z,{columns:V,data:g,isLoading:!1,sortKey:r,sortDirection:a,onSort:u,onRowClick:o=>w(o),emptyState:t.jsx(z,{image:null,title:n?"No tools found":"No tools available",description:n?"Try adjusting your search terms":j})}),e[24]=j,e[25]=u,e[26]=w,e[27]=n,e[28]=a,e[29]=r,e[30]=g,e[31]=d,e[32]=h):h=e[32];let x;e[33]!==p||e[34]!==h?(x=t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p,h]}),e[33]=p,e[34]=h,e[35]=x):x=e[35];let T;return e[36]!==x||e[37]!==f?(T=t.jsxs(t.Fragment,{children:[f,x]}),e[36]=x,e[37]=f,e[38]=T):T=e[38],T}function ae(s){return{id:s.id,label:typeof s.header=="string"?s.header:s.id}}function ie(s){return s.sortable}function le(s){return t.jsx("span",{className:"text-sm text-foreground",children:s.description||"—"})}function ce(s){return t.jsx("span",{className:"text-sm font-medium font-mono text-foreground",children:s.name})}function me(s){return s==="asc"?"desc":s==="desc"?null:"asc"}export{we as R,ve as T};