@vertesia/ui 1.6.0-dev.20261008.064737Z → 1.6.0-dev.20261009.095813Z

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 (147) hide show
  1. package/README.md +24 -0
  2. package/lib/core/components/shadcn/button.d.ts +1 -0
  3. package/lib/core/components/shadcn/button.d.ts.map +1 -1
  4. package/lib/core/components/shadcn/button.js +2 -2
  5. package/lib/core/components/shadcn/button.js.map +1 -1
  6. package/lib/core/components/shadcn/selectBox.d.ts.map +1 -1
  7. package/lib/core/components/shadcn/selectBox.js +2 -2
  8. package/lib/core/components/shadcn/selectBox.js.map +1 -1
  9. package/lib/env/index.d.ts +1 -1
  10. package/lib/env/index.d.ts.map +1 -1
  11. package/lib/env/index.js +1 -1
  12. package/lib/env/index.js.map +1 -1
  13. package/lib/features/agent/chat/AskUserWidget.d.ts.map +1 -1
  14. package/lib/features/agent/chat/AskUserWidget.js +2 -1
  15. package/lib/features/agent/chat/AskUserWidget.js.map +1 -1
  16. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
  17. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +2 -253
  18. package/lib/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
  19. package/lib/features/agent/chat/ModernAgentOutput/CollapsibleAgentMarkdown.d.ts +1 -3
  20. package/lib/features/agent/chat/ModernAgentOutput/CollapsibleAgentMarkdown.d.ts.map +1 -1
  21. package/lib/features/agent/chat/ModernAgentOutput/CollapsibleAgentMarkdown.js +2 -8
  22. package/lib/features/agent/chat/ModernAgentOutput/CollapsibleAgentMarkdown.js.map +1 -1
  23. package/lib/features/agent/chat/ModernAgentOutput/agentMarkdownStyles.d.ts +4 -0
  24. package/lib/features/agent/chat/ModernAgentOutput/agentMarkdownStyles.d.ts.map +1 -0
  25. package/lib/features/agent/chat/ModernAgentOutput/agentMarkdownStyles.js +248 -0
  26. package/lib/features/agent/chat/ModernAgentOutput/agentMarkdownStyles.js.map +1 -0
  27. package/lib/i18n/locales/ar.json +1 -0
  28. package/lib/i18n/locales/de.json +1 -0
  29. package/lib/i18n/locales/en.json +1 -0
  30. package/lib/i18n/locales/es.json +1 -0
  31. package/lib/i18n/locales/fr.json +1 -0
  32. package/lib/i18n/locales/it.json +1 -0
  33. package/lib/i18n/locales/ja.json +1 -0
  34. package/lib/i18n/locales/ko.json +1 -0
  35. package/lib/i18n/locales/pt.json +1 -0
  36. package/lib/i18n/locales/ru.json +1 -0
  37. package/lib/i18n/locales/tr.json +1 -0
  38. package/lib/i18n/locales/zh-TW.json +1 -0
  39. package/lib/i18n/locales/zh.json +1 -0
  40. package/lib/session/auth/composable.d.ts +1 -5
  41. package/lib/session/auth/composable.d.ts.map +1 -1
  42. package/lib/session/auth/composable.js +1 -10
  43. package/lib/session/auth/composable.js.map +1 -1
  44. package/lib/session/auth/firebase.d.ts.map +1 -1
  45. package/lib/session/auth/firebase.js +8 -5
  46. package/lib/session/auth/firebase.js.map +1 -1
  47. package/lib/session/auth/oauth.d.ts.map +1 -1
  48. package/lib/session/auth/oauth.js +38 -14
  49. package/lib/session/auth/oauth.js.map +1 -1
  50. package/lib/session/auth/vertesiaHosts.d.ts +0 -40
  51. package/lib/session/auth/vertesiaHosts.d.ts.map +1 -1
  52. package/lib/session/auth/vertesiaHosts.js +2 -45
  53. package/lib/session/auth/vertesiaHosts.js.map +1 -1
  54. package/lib/session/index.d.ts +1 -1
  55. package/lib/session/index.d.ts.map +1 -1
  56. package/lib/session/index.js +1 -1
  57. package/lib/session/index.js.map +1 -1
  58. package/lib/session/scopeSelection.d.ts +4 -0
  59. package/lib/session/scopeSelection.d.ts.map +1 -1
  60. package/lib/session/scopeSelection.js +11 -0
  61. package/lib/session/scopeSelection.js.map +1 -1
  62. package/lib/vertesia-ui-core.js +2 -2
  63. package/lib/vertesia-ui-core.js.map +1 -1
  64. package/lib/vertesia-ui-env.js +1 -1
  65. package/lib/vertesia-ui-env.js.map +1 -1
  66. package/lib/vertesia-ui-features.js +242 -257
  67. package/lib/vertesia-ui-features.js.map +1 -1
  68. package/lib/vertesia-ui-i18n.1NWiB6fw.chunk.js +5 -0
  69. package/lib/vertesia-ui-i18n.1NWiB6fw.chunk.js.map +1 -0
  70. package/lib/vertesia-ui-i18n.6Ozlf6Ks.chunk.js +5 -0
  71. package/lib/vertesia-ui-i18n.6Ozlf6Ks.chunk.js.map +1 -0
  72. package/lib/vertesia-ui-i18n.AttJpg8U.chunk.js +5 -0
  73. package/lib/vertesia-ui-i18n.AttJpg8U.chunk.js.map +1 -0
  74. package/lib/vertesia-ui-i18n.BI_xdp49.chunk.js +5 -0
  75. package/lib/vertesia-ui-i18n.BI_xdp49.chunk.js.map +1 -0
  76. package/lib/vertesia-ui-i18n.C-2EEX6w.chunk.js +5 -0
  77. package/lib/vertesia-ui-i18n.C-2EEX6w.chunk.js.map +1 -0
  78. package/lib/vertesia-ui-i18n.CAmo54FO.chunk.js +5 -0
  79. package/lib/vertesia-ui-i18n.CAmo54FO.chunk.js.map +1 -0
  80. package/lib/vertesia-ui-i18n.CbBzmHNP.chunk.js +5 -0
  81. package/lib/vertesia-ui-i18n.CbBzmHNP.chunk.js.map +1 -0
  82. package/lib/vertesia-ui-i18n.DZgTzkIg.chunk.js +5 -0
  83. package/lib/vertesia-ui-i18n.DZgTzkIg.chunk.js.map +1 -0
  84. package/lib/vertesia-ui-i18n.DZsITxq5.chunk.js +5 -0
  85. package/lib/vertesia-ui-i18n.DZsITxq5.chunk.js.map +1 -0
  86. package/lib/vertesia-ui-i18n.Dbf2GHth.chunk.js +5 -0
  87. package/lib/vertesia-ui-i18n.Dbf2GHth.chunk.js.map +1 -0
  88. package/lib/vertesia-ui-i18n.js +2 -2
  89. package/lib/vertesia-ui-i18n.lleWnH5n.chunk.js +5 -0
  90. package/lib/vertesia-ui-i18n.lleWnH5n.chunk.js.map +1 -0
  91. package/lib/vertesia-ui-i18n.wG_XSkbr.chunk.js +5 -0
  92. package/lib/vertesia-ui-i18n.wG_XSkbr.chunk.js.map +1 -0
  93. package/lib/vertesia-ui-session.js +1 -1
  94. package/lib/vertesia-ui-session.js.map +1 -1
  95. package/package.json +7 -7
  96. package/src/core/components/shadcn/button.tsx +3 -2
  97. package/src/core/components/shadcn/selectBox.tsx +12 -4
  98. package/src/css/index.css +1 -1
  99. package/src/css/typography.css +111 -88
  100. package/src/env/index.ts +0 -2
  101. package/src/features/agent/chat/AskUserWidget.tsx +3 -1
  102. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +2 -253
  103. package/src/features/agent/chat/ModernAgentOutput/CollapsibleAgentMarkdown.tsx +2 -8
  104. package/src/features/agent/chat/ModernAgentOutput/agentMarkdownStyles.ts +248 -0
  105. package/src/i18n/locales/ar.json +1 -0
  106. package/src/i18n/locales/de.json +1 -0
  107. package/src/i18n/locales/en.json +1 -0
  108. package/src/i18n/locales/es.json +1 -0
  109. package/src/i18n/locales/fr.json +1 -0
  110. package/src/i18n/locales/it.json +1 -0
  111. package/src/i18n/locales/ja.json +1 -0
  112. package/src/i18n/locales/ko.json +1 -0
  113. package/src/i18n/locales/pt.json +1 -0
  114. package/src/i18n/locales/ru.json +1 -0
  115. package/src/i18n/locales/tr.json +1 -0
  116. package/src/i18n/locales/zh-TW.json +1 -0
  117. package/src/i18n/locales/zh.json +1 -0
  118. package/src/session/auth/composable.ts +1 -11
  119. package/src/session/auth/firebase.ts +9 -6
  120. package/src/session/auth/oauth.ts +39 -13
  121. package/src/session/auth/vertesiaHosts.ts +2 -47
  122. package/src/session/index.ts +1 -1
  123. package/src/session/scopeSelection.ts +13 -0
  124. package/lib/vertesia-ui-i18n.B0orbJb6.chunk.js +0 -5
  125. package/lib/vertesia-ui-i18n.B0orbJb6.chunk.js.map +0 -1
  126. package/lib/vertesia-ui-i18n.BChwIQVA.chunk.js +0 -5
  127. package/lib/vertesia-ui-i18n.BChwIQVA.chunk.js.map +0 -1
  128. package/lib/vertesia-ui-i18n.BTEcAVQm.chunk.js +0 -5
  129. package/lib/vertesia-ui-i18n.BTEcAVQm.chunk.js.map +0 -1
  130. package/lib/vertesia-ui-i18n.BeJQKbv7.chunk.js +0 -5
  131. package/lib/vertesia-ui-i18n.BeJQKbv7.chunk.js.map +0 -1
  132. package/lib/vertesia-ui-i18n.BpGr0-5g.chunk.js +0 -5
  133. package/lib/vertesia-ui-i18n.BpGr0-5g.chunk.js.map +0 -1
  134. package/lib/vertesia-ui-i18n.Bs8x-1wI.chunk.js +0 -5
  135. package/lib/vertesia-ui-i18n.Bs8x-1wI.chunk.js.map +0 -1
  136. package/lib/vertesia-ui-i18n.BymQoOm0.chunk.js +0 -5
  137. package/lib/vertesia-ui-i18n.BymQoOm0.chunk.js.map +0 -1
  138. package/lib/vertesia-ui-i18n.CNT_wabV.chunk.js +0 -5
  139. package/lib/vertesia-ui-i18n.CNT_wabV.chunk.js.map +0 -1
  140. package/lib/vertesia-ui-i18n.Cxh1iVk0.chunk.js +0 -5
  141. package/lib/vertesia-ui-i18n.Cxh1iVk0.chunk.js.map +0 -1
  142. package/lib/vertesia-ui-i18n.DLYCM9fV.chunk.js +0 -5
  143. package/lib/vertesia-ui-i18n.DLYCM9fV.chunk.js.map +0 -1
  144. package/lib/vertesia-ui-i18n.QvAVguDs.chunk.js +0 -5
  145. package/lib/vertesia-ui-i18n.QvAVguDs.chunk.js.map +0 -1
  146. package/lib/vertesia-ui-i18n.smozeSmI.chunk.js +0 -5
  147. package/lib/vertesia-ui-i18n.smozeSmI.chunk.js.map +0 -1
@@ -934,7 +934,7 @@ Q();function Cx(e){return e===`full_control`?`text-attention`:e===`auto_review`?
934
934
  function Vx(e,n){let r=B.createContext(n);r.displayName=e+`Context`;let i=/* @__PURE__ */ Bx(e=>{let{children:n,...i}=e,a=B.useMemo(()=>i,Object.values(i));return/* @__PURE__ */ t(r.Provider,{value:a,children:n})},`Provider`);i.displayName=e+`Provider`;function a(t,i={}){let{optional:a=!1}=i,o=B.useContext(r);if(o)return o;if(n!==void 0)return n;if(!a)throw Error(`\`${t}\` must be used within \`${e}\``)}return Bx(a,`useContext`),[i,a]}Bx(Vx,`createContext`);// @__NO_SIDE_EFFECTS__
935
935
  function Hx(e,n=[]){let r=[];function i(n,i){let a=B.createContext(i);a.displayName=n+`Context`;let o=r.length;r=[...r,i];let s=/* @__PURE__ */ Bx(n=>{let{scope:r,children:i,...s}=n,c=r?.[e]?.[o]||a,l=B.useMemo(()=>s,Object.values(s));return/* @__PURE__ */ t(c.Provider,{value:l,children:i})},`Provider`);s.displayName=n+`Provider`;function c(t,r,s={}){let{optional:c=!1}=s,l=r?.[e]?.[o]||a,u=B.useContext(l);if(u)return u;if(i!==void 0)return i;if(!c)throw Error(`\`${t}\` must be used within \`${n}\``)}return Bx(c,`useContext`),[s,c]}Bx(i,`createContext`);let a=/* @__PURE__ */ Bx(()=>{let t=r.map(e=>B.createContext(e));return/* @__PURE__ */ Bx(function(n){let r=n?.[e]||t;return B.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return a.scopeName=e,[i,Ux(a,...n)]}Bx(Hx,`createContextScope`);function Ux(...e){let t=e[0];if(e.length===1)return t;let n=/* @__PURE__ */ Bx(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return/* @__PURE__ */ Bx(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return B.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}Bx(Ux,`composeContextScopes`);var Wx=globalThis?.document?B.useLayoutEffect:()=>{},Gx=Object.defineProperty,Kx=(e,t)=>Gx(e,`name`,{value:t,configurable:!0}),qx=B.useId||(()=>void 0),Jx=0;function Yx(e){let[t,n]=B.useState(qx());return Wx(()=>{e||n(e=>e??String(Jx++))},[e]),e||(t?`radix-${t}`:``)}Kx(Yx,`useId`);var Xx=Object.defineProperty,Zx=(e,t)=>Xx(e,`name`,{value:t,configurable:!0}),Qx=B.useEffectEvent,$x=B.useInsertionEffect;function eS(e){if(typeof Qx==`function`)return Qx(e);let t=B.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof $x==`function`?$x(()=>{t.current=e}):Wx(()=>{t.current=e}),B.useMemo(()=>((...e)=>t.current?.(...e)),[])}Zx(eS,`useEffectEvent`);var tS=Object.defineProperty,nS=(e,t)=>tS(e,`name`,{value:t,configurable:!0}),rS=B.useInsertionEffect||Wx;function iS({prop:e,defaultProp:t,onChange:n=/* @__PURE__ */ nS(()=>{},`onChange`),caller:r}){let[i,a,o]=aS({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,B.useCallback(t=>{if(s){let n=oS(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}nS(iS,`useControllableState`);function aS({defaultProp:e,onChange:t}){let[n,r]=B.useState(e),i=B.useRef(n),a=B.useRef(t);return rS(()=>{a.current=t},[t]),B.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}nS(aS,`useUncontrolledState`);function oS(e){return typeof e==`function`}nS(oS,`isFunction`);var sS=Symbol(`RADIX:SYNC_STATE`);function cS(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=eS(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=B.useReducer((t,n)=>{if(n.type===sS)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=B.useRef(p);B.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=B.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return B.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:sS,state:i})},[i,d.state,c]),[h,f]}nS(cS,`useControllableStateReducer`);var lS=Object.defineProperty,uS=(e,t)=>lS(e,`name`,{value:t,configurable:!0});// @__NO_SIDE_EFFECTS__
936
936
  function dS(e){let t=B.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];bS(r)&&typeof wS==`function`&&(r=wS(r._payload)),B.Children.forEach(r,e=>{if(vS(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;bS(n)&&typeof wS==`function`&&(n=wS(n._payload)),a=hS(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=B.cloneElement(a,void 0,s):!o&&B.Children.count(r)===1&&B.isValidElement(r)&&(a=r);let c=a?_S(a):void 0,l=Rx(n,c);if(!a){if(r||r===0)throw Error(o?CS(e):SS(e));return r}let u=gS(i,a.props??{});return a.type!==B.Fragment&&(u.ref=n?l:c),B.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}uS(dS,`createSlot`);var fS=/* @__PURE__ */ dS(`Slot`),pS=Symbol.for(`radix.slottable`);// @__NO_SIDE_EFFECTS__
937
- function mS(e){let t=/* @__PURE__ */ uS(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=pS,t}uS(mS,`createSlottable`);var hS=/* @__PURE__ */ uS((e,t)=>{if(`child`in e.props){let t=e.props.child;return B.isValidElement(t)?B.cloneElement(t,void 0,e.props.children(t.props.children)):null}return B.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function gS(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}uS(gS,`mergeProps`);function _S(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}uS(_S,`getElementRef`);function vS(e){return B.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===pS}uS(vS,`isSlottable`);var yS=Symbol.for(`react.lazy`);function bS(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===yS&&`_payload`in e&&xS(e._payload)}uS(bS,`isLazyComponent`);function xS(e){return typeof e==`object`&&!!e&&`then`in e}uS(xS,`isPromiseLike`);var SS=/* @__PURE__ */ uS(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),CS=/* @__PURE__ */ uS(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),wS=B.use,TS=Object.defineProperty,ES=(e,t)=>TS(e,`name`,{value:t,configurable:!0}),DS=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,n)=>{let r=/* @__PURE__ */ dS(`Primitive.${n}`),i=B.forwardRef((e,i)=>{let{asChild:a,...o}=e,s=a?r:n;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),/* @__PURE__ */ t(s,{...o,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function OS(e,t){e&&rn.flushSync(()=>e.dispatchEvent(t))}ES(OS,`dispatchDiscreteCustomEvent`);var kS=Object.defineProperty,AS=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ ((e,t)=>kS(e,`name`,{value:t,configurable:!0}))(function(e,n){let{container:r,...i}=e,[a,o]=B.useState(!1);Wx(()=>o(!0),[]);let s=r||a&&globalThis?.document?.body;return s?rn.createPortal(/* @__PURE__ */ t(DS.div,{...i,ref:n}),s):null},`Portal`)),jS=Object.defineProperty,MS=(e,t)=>jS(e,`name`,{value:t,configurable:!0});function NS(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}MS(NS,`useStateMachine`);var PS=/* @__PURE__ */ MS(e=>{let{present:t,children:n}=e,r=FS(t),i=typeof n==`function`?n({present:r.isPresent}):B.Children.only(n),a=LS(r.ref,zS(i));return typeof n==`function`||r.isPresent?B.cloneElement(i,{ref:a}):null},`Presence`);function FS(e){let[t,n]=B.useState(),r=B.useRef(null),i=B.useRef(e),a=B.useRef(`none`),o=B.useRef(void 0),[s,c]=NS(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return B.useEffect(()=>{s===`mounted`?(a.current=o.current??RS(r.current),o.current=void 0):a.current=`none`},[s]),Wx(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=RS(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Wx(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=/* @__PURE__ */ MS(a=>{let o=RS(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=/* @__PURE__ */ MS(e=>{e.target===t&&(a.current=RS(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:B.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=RS(t)}else r.current=null;n(e)},[])}}MS(FS,`usePresence`);function IS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}MS(IS,`setRef`);function LS(...e){let t=B.useRef(e);return t.current=e,B.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=IS(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():IS(n[e],null)}}},[])}MS(LS,`useStableComposedRefs`);function RS(e){return e?.animationName||`none`}MS(RS,`getAnimationName`);function zS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}MS(zS,`getElementRef`);var BS=Object.defineProperty,VS=(e,t)=>BS(e,`name`,{value:t,configurable:!0}),HS=`Dialog`,[US,WS]=/* @__PURE__ */ Hx(HS),[GS,KS]=US(HS),qS=/* @__PURE__ */ VS(e=>{let{__scopeDialog:n,children:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=B.useRef(null),l=B.useRef(null),[u,d]=iS({prop:i,defaultProp:a??!1,onChange:o,caller:HS}),[f,p]=B.useState(0),[m,h]=B.useState(0);return/* @__PURE__ */ t(GS,{scope:n,triggerRef:c,contentRef:l,contentId:Yx(),titleId:Yx(),descriptionId:Yx(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:r})},`Dialog`),JS=`DialogPortal`,[YS,XS]=US(JS,{forceMount:void 0}),ZS=/* @__PURE__ */ VS(e=>{let{__scopeDialog:n,forceMount:r,children:i,container:a}=e,o=KS(JS,n);return/* @__PURE__ */ t(YS,{scope:n,forceMount:r,children:B.Children.map(i,e=>/* @__PURE__ */ t(PS,{present:r||o.open,children:/* @__PURE__ */ t(AS,{asChild:!0,container:a,children:e})}))})},`DialogPortal`),QS=`DialogOverlay`,$S=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=XS(QS,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=KS(QS,e.__scopeDialog);return o.modal?/* @__PURE__ */ t(PS,{present:i||o.open,children:/* @__PURE__ */ t(tC,{...a,ref:n})}):null},`DialogOverlay`)),eC=/* @__PURE__ */ dS(`DialogOverlay.RemoveScroll`),tC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(QS,r),o=Rx(n,tn());return/* @__PURE__ */ t(on,{as:eC,allowPinchZoom:!0,shards:[a.contentRef],children:/* @__PURE__ */ t(DS.div,{"data-state":pC(a.open),...i,ref:o,style:{pointerEvents:`auto`,...i.style}})})},`DialogOverlayImpl`)),nC=`DialogContent`,rC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=XS(nC,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=KS(nC,e.__scopeDialog);return/* @__PURE__ */ t(PS,{present:i||o.open,children:o.modal?/* @__PURE__ */ t(iC,{...a,ref:n}):/* @__PURE__ */ t(aC,{...a,ref:n})})},`DialogContent`)),iC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=KS(nC,e.__scopeDialog),i=B.useRef(null),a=Rx(n,r.contentRef,i);return B.useEffect(()=>{let e=i.current;if(e)return sn(e)},[]),/* @__PURE__ */ t(oC,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:kx(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:kx(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:kx(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),aC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=KS(nC,e.__scopeDialog),i=B.useRef(!1),a=B.useRef(!1);return/* @__PURE__ */ t(oC,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,t.detail.originalEvent.type===`pointerdown`&&(a.current=!0));let n=t.target;r.triggerRef.current?.contains(n)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&a.current&&t.preventDefault()}})},`DialogContentNonModal`)),oC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(n,r){let{__scopeDialog:i,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,...c}=n,l=KS(nC,i);return an(),/* @__PURE__ */ t(e,{children:/* @__PURE__ */ t(nn,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:/* @__PURE__ */ t(en,{role:`dialog`,id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":pC(l.open),...c,ref:r,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},`DialogContentImpl`)),sC=`DialogTitle`,cC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(sC,r),{setTitleCount:o}=a;return Wx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),/* @__PURE__ */ t(DS.h2,{id:a.titleId,...i,ref:n})},`DialogTitle`)),lC=`DialogDescription`,uC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(lC,r),{setDescriptionCount:o}=a;return Wx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),/* @__PURE__ */ t(DS.p,{id:a.descriptionId,...i,ref:n})},`DialogDescription`)),dC=`DialogClose`,fC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(dC,r);return/* @__PURE__ */ t(DS.button,{type:`button`,...i,ref:n,onClick:kx(e.onClick,()=>a.onOpenChange(!1))})},`DialogClose`));function pC(e){return e?`open`:`closed`}VS(pC,`getState`);function mC(...e){return ln(st(e))}const hC=pt(null);function gC({children:e}){let n=W(/* @__PURE__ */ new Map),r=W(/* @__PURE__ */ new Map),i=V(e=>n.current.get(e),[]),a=V((e,t)=>{n.current.set(e,t)},[]),o=V(async(e,t)=>{let i=n.current.get(e);if(i)return i;let a=r.current.get(e);if(a)return a;let o=t().then(t=>(n.current.set(e,t),r.current.delete(e),t)).catch(t=>{throw r.current.delete(e),t});return r.current.set(e,o),o},[]),s=ct.useMemo(()=>({getUrl:i,setUrl:a,getOrFetch:o}),[i,a,o]);return t(hC.Provider,{value:s,children:e})}function _C(){return yt(hC)}function vC(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function yC(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function bC(e){return`file:${e}`}Q();const xC=_t(()=>import(`react-vega`).then(({VegaEmbed:e})=>({default:e})));function SC({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-destructive text-destructive rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-destructive`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-destructive mt-1 max-w-xs truncate`,children:e})]})})}function CC(){return t(`output`,{className:`flex items-center justify-center w-full h-full`,children:t(wv,{className:`w-5 h-5 animate-spin text-muted`})})}function wC({isOpen:e,onClose:r,title:i,description:a,children:s}){let{t:c}=K();return t(qS,{open:e,onOpenChange:e=>!e&&r(),children:n(ZS,{children:[t($S,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(rC,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-card text-card-foreground rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:r,children:[t(fC,{asChild:!0,children:t(o,{variant:`unstyled`,onClick:r,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-card backdrop-blur-sm hover:bg-muted transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(xx,{className:`w-5 h-5 text-muted`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-border bg-muted rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(cC,{className:`text-base font-semibold text-card-foreground`,children:i||c(`agent.dashboard`)}),a&&t(uC,{className:`text-sm text-muted mt-0.5`,children:a})]})})]})]})})}function TC(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}function EC(e,t){return typeof window>`u`?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function DC(){let e=[1,2,3,4,5].map(e=>EC(`--chart-${e}`,`#3b82f6`));return{categorical:[...e,...e],blues:e,purples:e,greens:e,diverging:e}}function OC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kC(e){return OC(e)}function AC(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(MC(t,r)||a&&NC(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function jC(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function MC(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(MC(n,t))return!0}return!1}function NC(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function PC(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{kC(e)&&n.push(...PC(e,[...t,r,String(i)]))}):kC(i)&&n.push(...PC(i,[...t,r]))}return n}function FC(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!OC(n))break;i=n}let a=t[t.length-1],o=i[a];OC(o)&&(delete o.url,o.values=r)}return n}function IC(e){let t=DC(),n=EC(`--font-sans`,`system-ui, sans-serif`),r=EC(`--foreground`,`#18181b`),i=EC(`--muted`,`#71717a`),a=EC(`--border`,`#e4e4e7`);return{background:`transparent`,view:{stroke:`transparent`},range:{category:t.categorical,diverging:t.diverging,heatmap:t.purples,ramp:t.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80},axis:{labelColor:i,titleColor:r,gridColor:a,domainColor:a,tickColor:a,labelFont:n,titleFont:n,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:i,titleColor:r,labelFont:n,titleFont:n,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:r,font:n,fontSize:14,fontWeight:600}}}const LC=vt(function({spec:r,artifactRunId:i}){let{t:a}=K(),{title:s,description:c,options:l}=r,u=r.spec,[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(!1),y=W(null),b=W(null),x=W(null),{client:S}=q(),C=_C(),w=W(S);w.current=S;let T=W(C);T.current=C;let[E,D]=G(null),[O,k]=G(!1),[A,j]=G(null),M=l?.mode||`chart`,ee=M===`dashboard`,N=l?.enableFullscreen??ee,P=l?.height||TC(u,M);H(()=>{let e=PC(u);if(e.length===0){D(u),k(!1),j(null);return}i?console.info(`[VegaLiteChart] resolving artifacts with runId:`,i,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:i});let t=!1;return k(!0),j(null),(async()=>{let n=/* @__PURE__ */ new Map,r=w.current,a=T.current;for(let o of e)try{let e=o.path.join(`.`),t;if(i&&!vC(o.artifactPath)){let e=yC(i,o.artifactPath,`inline`);t=a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url}else{let e=bC(o.artifactPath);t=a?await a.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let{default:e}=await import(`papaparse`),t=await s.text();l=e.parse(t,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||j(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=FC(u,n);D(e),k(!1)}})(),()=>{t=!0}},[u,i]);let[F,te]=G(!1),I=W(!1);H(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==I.current&&(I.current=e,te(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[ne,L]=G(0),R=W(0);H(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==R.current&&(R.current=e,L(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return R.current=n,L(n),()=>{clearTimeout(e),t.disconnect()}},[]);let re=U(()=>PC(u).length>0,[u]),ie=U(()=>{if(re&&!E)return null;let e=E||u;return e?(l?.parameterValues&&(e=jC(e,l.parameterValues)),AC(e)):null},[E,u,re,l?.parameterValues]),ae=V((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>ae(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>ae(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>ae(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),oe=V((e,t=!1)=>{if(!ie)return null;let n=IC(F),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:ne>0?ne-24:500,i=`vconcat`in ie||`hconcat`in ie||`concat`in ie,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=ie;i&&r&&(o=ae(ie,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!ie.title?{title:s}:{},config:{...n,...ie.config}}},[ie,s,F,ne,ae]),se=V(async()=>{let e=_?b.current:y.current;if(e&&!p)try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),ce=V(async()=>{let e=_?b.current:y.current;if(e&&!d){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),le=V(e=>{y.current=e,g(null)},[]),ue=V(e=>{b.current=e},[]),de=V(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),fe=V(()=>{v(e=>!e)},[]);H(()=>{g(null)},[u]);let pe=({className:e})=>n(`div`,{className:mC(`flex items-center gap-2`,e),children:[n(o,{variant:`unstyled`,onClick:se,disabled:p,className:`text-xs px-2 py-1 rounded border border-border bg-muted text-muted hover:bg-muted/80 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:a(`agent.copyToClipboard`),children:[t(p?wh:Ig,{className:`w-3 h-3`}),a(p?`agent.copied`:`agent.copy`)]}),n(o,{variant:`unstyled`,onClick:ce,disabled:d,className:`text-xs px-2 py-1 rounded border border-border bg-muted text-muted hover:bg-muted/80 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:a(`agent.exportAsPng`),children:[t(Gg,{className:`w-3 h-3`}),a(d?`agent.exporting`:`agent.export`)]}),N&&n(o,{variant:`unstyled`,onClick:fe,className:`text-xs px-2 py-1 rounded border border-border bg-muted text-muted hover:bg-muted/80 cursor-pointer transition-colors flex items-center gap-1`,title:a(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?Zv:Nv,{className:`w-3 h-3`}),a(_?`agent.exit`:`agent.fullscreen`)]})]});if(O||re&&!E)return t(`div`,{className:`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-muted rounded`,style:{width:`100%`,height:P},children:n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(wv,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(A)return t(`div`,{className:`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:P},children:t(SC,{error:A,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:P},children:t(SC,{error:h,chartTitle:s})})]})});let me=oe(P),he=oe(0,!0);return me?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!me.data?.values,dataLength:me.data?.values?.length}),n(e,{children:[t(`div`,{className:mC(`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,ee&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||(ee?`Dashboard`:`Chart`)}),ee&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-info text-info`,children:`Interactive`})]}),t(pe,{})]}),c&&t(`span`,{className:`text-xs text-muted`,children:c}),t(`div`,{ref:x,className:`bg-card text-card-foreground rounded overflow-hidden`,style:{width:`100%`,height:P,minWidth:0},children:t(ft,{fallback:t(CC,{}),children:t(xC,{spec:me,onEmbed:e=>le(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})})]})}),n(wC,{isOpen:_,onClose:()=>v(!1),title:s||(ee?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:he&&t(ft,{fallback:t(CC,{}),children:t(xC,{spec:he,onEmbed:e=>ue(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(pe,{className:`bg-card rounded-lg shadow-lg p-2 border border-border`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function RC(e){return e.library===`vega-lite`&&typeof e.spec==`object`}function zC(e){return e.library===`recharts`||e.library===void 0}function BC(e){return typeof e.$schema==`string`&&e.$schema.includes(`vega`)}const VC=vt(function({spec:e,artifactRunId:r}){return RC(e)?t(LC,{spec:e,artifactRunId:r}):BC(e)?t(LC,{spec:{library:`vega-lite`,spec:e},artifactRunId:r}):n(`div`,{className:`my-5 rounded-lg border border-attention bg-attention p-4 text-sm text-attention`,children:[`Recharts chart rendering has been retired. Use a Vega-Lite chart spec (`,t(`code`,{children:`library: "vega-lite"`}),` with `,t(`code`,{children:`spec`}),`).`]})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function HC(e,t){return e===`live`?e:t===0?`live`:Math.min(Math.max(e,0),t-1)}function UC(e,t){return t===0?-1:e===`live`?t-1:Math.min(Math.max(e,0),t-1)}function WC(e,t){if(e.length===0)return null;let n=t===`live`?e.length:UC(t,e.length);for(let t=Math.min(n-1,e.length-1);t>=0;t--)if(e[t].type===J.QUESTION)return t;return null}function GC(e,t){if(e.length===0||t===`live`)return null;let n=UC(t,e.length);for(let t=n+1;t<e.length;t++)if(e[t].type===J.QUESTION)return t;return`live`}function KC(e,t,n){let r=n?HC(t,e.length):`live`,i=UC(r,e.length),a=!n||r===`live`,o=a?e:e.slice(0,i+1);return{cursor:r,cursorIndex:i,isLive:a,renderedMessageCount:o.length,displayedMessages:o}}function qC(e){let t=e.indexOf(`?`);return t===-1?new URLSearchParams:new URLSearchParams(e.slice(t+1))}function JC(){return typeof window<`u`}function YC(){if(!JC())return!1;let e=new URLSearchParams(window.location.search),t=qC(window.location.hash),n=e.get(`agentChatPlayback`)??t.get(`agentChatPlayback`);return n===`1`||n===`true`}const XC=JC,ZC=YC;Q();function QC({cursor:e,messages:r,onChangeCursor:i,className:a}){let{t:s}=K(),c=r.length,l=e===`live`,u=UC(e,c),d=c>0&&(l||u>0),f=!l&&c>0,p=c>0&&(l||u>0),m=!l&&c>0&&u<c-1,h=c===0?0:u+1,[g,_]=G(String(h));H(()=>{_(String(h))},[h]);let v=()=>{if(c!==0){if(e===`live`){i(c-1);return}i(Math.max(0,u-1))}},y=()=>{if(c!==0&&e!==`live`){if(u>=c-1){i(`live`);return}i(u+1)}},b=()=>{c!==0&&i(0)},x=()=>{c!==0&&i(c-1)},S=()=>{_(String(h))},C=(e,t=!1)=>{if(c===0){_(`0`);return}let n=Number.parseInt(e,10);if(!Number.isFinite(n)){t&&S();return}let r=Math.min(Math.max(n,1),c);_(String(r)),i(r-1)},w=e=>{c!==0&&C(e)},T=c>1,E=+!!T,D=Math.max(1,c),O=`size-7 rounded-lg text-muted hover:text-foreground disabled:opacity-35`,k=`${Math.max(3,String(c).length+1)}ch`;return n(`div`,{className:z(`inline-flex max-w-full flex-col gap-1 rounded-xl border border-border/70 bg-background/95 px-2 py-1 text-sm leading-none text-muted shadow-lg shadow-black/10 backdrop-blur`,a),"data-testid":`agent-test-playback-controls`,"data-playback-cursor":e,"data-live-message-count":c,"data-rendered-message-count":l?c:u+1,children:[n(`div`,{className:`flex max-w-full items-center gap-1`,children:[t(`span`,{className:`ms-2 me-1 font-medium leading-none text-foreground/80`,children:s(`agent.rewind.label`)}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToStart`),disabled:!p,onClick:b,className:O,children:t(Hh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.previousMessage`),disabled:!d,onClick:v,className:O,children:t(Ah,{className:`size-4`})}),n(`span`,{className:`inline-flex min-w-16 items-center justify-center gap-0.5 px-1 font-medium leading-none tabular-nums text-foreground/80`,"data-testid":`agent-test-playback-position`,children:[t(R,{type:`text`,variant:`unstyled`,size:`sm`,clearable:!1,inputMode:`numeric`,pattern:`[0-9]*`,value:g,"aria-label":s(`agent.rewind.positionInput`),disabled:c===0,onChange:e=>{let t=e.replace(/\D/g,``);_(t)},onBlur:e=>C(e.currentTarget.value,!0),onKeyDown:e=>{e.key===`Enter`&&(C(e.currentTarget.value,!0),e.currentTarget.blur())},style:{width:k},className:`h-7 w-auto rounded-md border border-transparent bg-transparent px-1 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none transition-colors hover:border-border focus:border-ring focus:bg-muted/30 disabled:opacity-50`}),t(`span`,{"aria-hidden":`true`,className:`text-muted`,children:`/`}),t(`span`,{className:`text-muted`,children:c})]}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.nextMessage`),disabled:!f,onClick:y,className:O,children:t(Nh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLatest`),disabled:!m,onClick:x,className:O,children:t(Gh,{className:`size-4`})}),t(o,{type:`button`,variant:l?`secondary`:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLive`),disabled:l,onClick:()=>i(`live`),className:z(O,l&&`bg-muted text-foreground`),children:t(Ny,{className:`size-4`})})]}),t(`div`,{className:`px-2 pb-1`,children:t(Ae,{min:E,max:D,step:1,value:[h],"aria-label":s(`agent.rewind.positionInput`),disabled:!T,onValueChange:([e])=>w(String(e)),className:`h-2`})})]})}var $C=typeof document<`u`?St:function(){};function ew(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ew(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ew(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function tw(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nw(e,t){let n=tw(e);return Math.round(t*n)/n}function rw(e){let t=B.useRef(e);return $C(()=>{t.current=e}),t}function iw(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=B.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=B.useState(r);ew(f,r)||p(r);let[m,h]=B.useState(null),[g,_]=B.useState(null),v=B.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=B.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=B.useRef(null),C=B.useRef(null),w=B.useRef(u),T=c!=null,E=rw(c),D=rw(i),O=rw(l),k=B.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Bn(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!ew(w.current,t)&&(w.current=t,rn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);$C(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=B.useRef(!1);$C(()=>(A.current=!0,()=>{A.current=!1}),[]),$C(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=B.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=B.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=B.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=nw(M.floating,u.x),r=nw(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...tw(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return B.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:ee}),[u,k,j,M,ee])}const aw=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Rn({element:r.current,padding:i}).fn(n):r?Rn({element:r,padding:i}).fn(n):{}}}},ow=(e,t)=>{let n=Wn(e);return{name:n.name,fn:n.fn,options:[e,t]}},sw=(e,t)=>{let n=Gn(e);return{name:n.name,fn:n.fn,options:[e,t]}},cw=(e,t)=>({fn:Un(e).fn,options:[e,t]}),lw=(e,t)=>{let n=Vn(e);return{name:n.name,fn:n.fn,options:[e,t]}},uw=(e,t)=>{let n=Kn(e);return{name:n.name,fn:n.fn,options:[e,t]}},dw=(e,t)=>{let n=Hn(e);return{name:n.name,fn:n.fn,options:[e,t]}},fw=(e,t)=>{let n=aw(e);return{name:n.name,fn:n.fn,options:[e,t]}};var pw=Object.defineProperty,mw=(e,t)=>pw(e,`name`,{value:t,configurable:!0});function hw(e){let t=B.useRef(e);return B.useEffect(()=>{t.current=e}),B.useMemo(()=>((...e)=>t.current?.(...e)),[])}mw(hw,`useCallbackRef`);var gw=Object.defineProperty,_w=(e,t)=>gw(e,`name`,{value:t,configurable:!0});function vw(e){let[t,n]=B.useState(void 0);return Wx(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}_w(vw,`useSize`);var yw=Object.defineProperty,bw=(e,t)=>yw(e,`name`,{value:t,configurable:!0}),xw=`Popper`,[Sw,Cw]=/* @__PURE__ */ Hx(xw),[ww,Tw]=Sw(xw),Ew=/* @__PURE__ */ bw(e=>{let{__scopePopper:n,children:r}=e,[i,a]=B.useState(null),[o,s]=B.useState(void 0);return/* @__PURE__ */ t(ww,{scope:n,anchor:i,onAnchorChange:a,placementState:o,setPlacementState:s,children:r})},`Popper`),Dw=`PopperAnchor`,Ow=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ bw(function(e,n){let{__scopePopper:r,virtualRef:i,...a}=e,o=Tw(Dw,r),s=B.useRef(null),c=o.onAnchorChange,l=Rx(n,B.useCallback(e=>{s.current=e,e&&c(e)},[c])),u=B.useRef(null);B.useEffect(()=>{if(!i)return;let e=u.current;u.current=i.current,e!==u.current&&c(u.current)});let d=o.placementState&&Fw(o.placementState),f=d?.[0],p=d?.[1];return i?null:/* @__PURE__ */ t(DS.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...a,ref:l})},`PopperAnchor`)),kw=`PopperContent`,[Aw,jw]=Sw(kw),Mw=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ bw(function(e,n){let{__scopePopper:r,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=Tw(kw,r),[v,y]=B.useState(null),b=Rx(n,y),[x,S]=B.useState(null),C=vw(x),w=C?.width??0,T=C?.height??0,E=i+(o===`center`?``:`-`+o),D=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(u)?u:[u],k=O.length>0,A={padding:D,boundary:O.filter(Nw),altBoundary:k},{refs:j,floatingStyles:M,placement:ee,isPositioned:N,middlewareData:P}=iw({strategy:`fixed`,placement:E,whileElementsMounted:/* @__PURE__ */ bw((...e)=>zn(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[ow({mainAxis:a+T,alignmentAxis:s}),l&&sw({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?cw():void 0,...A}),l&&lw({...A}),uw({...A,apply:/* @__PURE__ */ bw(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&fw({element:x,padding:c}),Pw({arrowWidth:w,arrowHeight:T}),p&&dw({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),F=_.setPlacementState;Wx(()=>(F(ee),()=>{F(void 0)}),[ee,F]);let[te,I]=Fw(ee),ne=hw(h);Wx(()=>{N&&ne?.()},[N,ne]);let L=P.arrow?.x,R=P.arrow?.y,re=P.arrow?.centerOffset!==0,[ie,ae]=B.useState();return Wx(()=>{v&&ae(window.getComputedStyle(v).zIndex)},[v]),/* @__PURE__ */ t(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:N?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ie,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:/* @__PURE__ */ t(Aw,{scope:r,placedSide:te,placedAlign:I,onArrowChange:S,arrowX:L,arrowY:R,shouldHideArrow:re,children:/* @__PURE__ */ t(DS.div,{"data-side":te,"data-align":I,...g,ref:b,style:{...g.style,animation:N?g.style?.animation:`none`}})})})},`PopperContent`));function Nw(e){return e!==null}bw(Nw,`isNotNull`);var Pw=/* @__PURE__ */ bw(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Fw(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Fw(e){let[t,n=`center`]=e.split(`-`);return[t,n]}bw(Fw,`getSideAndAlignFromPlacement`);var Iw=Ew,Lw=Ow,Rw=Mw,zw=Object.defineProperty,Bw=(e,t)=>zw(e,`name`,{value:t,configurable:!0}),Vw=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Hw=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Bw(function(e,n){return/* @__PURE__ */ t(DS.span,{...e,ref:n,style:{...Vw,...e.style}})},`VisuallyHidden`)),Uw=Object.defineProperty,Ww=(e,t)=>Uw(e,`name`,{value:t,configurable:!0}),[Gw,Kw]=/* @__PURE__ */ Hx(`Tooltip`,[Cw]),qw=Cw(),Jw=`TooltipProvider`,Yw=700,Xw=`tooltip.open`,[Zw,Qw]=Gw(Jw),$w=/* @__PURE__ */ Ww(e=>{let{__scopeTooltip:n,delayDuration:r=Yw,skipDelayDuration:i=300,disableHoverableContent:a=!1,children:o}=e,s=B.useRef(!0),c=B.useRef(!1),l=B.useRef(0);return B.useEffect(()=>{let e=l.current;return()=>window.clearTimeout(e)},[]),/* @__PURE__ */ t(Zw,{scope:n,isOpenDelayedRef:s,delayDuration:r,onOpen:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),s.current=!1)},[i]),onClose:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.current=!0,i))},[i]),isPointerInTransitRef:c,onPointerInTransitChange:B.useCallback(e=>{c.current=e},[]),disableHoverableContent:a,children:o})},`TooltipProvider`),eT=`Tooltip`,[tT,nT]=Gw(eT),rT=/* @__PURE__ */ Ww(e=>{let{__scopeTooltip:n,children:r,open:i,defaultOpen:a,onOpenChange:o,disableHoverableContent:s,delayDuration:c}=e,l=Qw(eT,e.__scopeTooltip),u=qw(n),[d,f]=B.useState(null),[p,m]=B.useState(void 0),h=Yx(),g=B.useRef(0),_=s??l.disableHoverableContent,v=c??l.delayDuration,y=B.useRef(!1),[b,x]=iS({prop:i,defaultProp:a??!1,onChange:/* @__PURE__ */ Ww(e=>{e?(l.onOpen(),document.dispatchEvent(new CustomEvent(Xw))):l.onClose(),o?.(e)},`onChange`),caller:eT}),S=B.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=B.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);B.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]);let E=p??h;return/* @__PURE__ */ t(Iw,{...u,children:/* @__PURE__ */ t(tT,{scope:n,contentId:E,setContentId:m,open:b,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:B.useCallback(()=>{l.isOpenDelayedRef.current?T():C()},[l.isOpenDelayedRef,T,C]),onTriggerLeave:B.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:r})})},`Tooltip`),iT=`TooltipTrigger`,aT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,n){let{__scopeTooltip:r,...i}=e,a=nT(iT,r),o=Qw(iT,r),s=qw(r),c=Rx(n,B.useRef(null),a.onTriggerChange),l=B.useRef(!1),u=B.useRef(!1),d=B.useCallback(()=>l.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),/* @__PURE__ */ t(Lw,{asChild:!0,...s,children:/* @__PURE__ */ t(DS.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:kx(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:kx(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:kx(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:kx(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:kx(e.onBlur,a.onClose),onClick:kx(e.onClick,a.onClose)})})},`TooltipTrigger`)),oT=`TooltipPortal`,[sT,cT]=Gw(oT,{forceMount:void 0}),lT=/* @__PURE__ */ Ww(e=>{let{__scopeTooltip:n,forceMount:r,children:i,container:a}=e,o=nT(oT,n);return/* @__PURE__ */ t(sT,{scope:n,forceMount:r,children:/* @__PURE__ */ t(PS,{present:r||o.open,children:/* @__PURE__ */ t(AS,{asChild:!0,container:a,children:i})})})},`TooltipPortal`),uT=`TooltipContent`,dT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,n){let r=cT(uT,e.__scopeTooltip),{forceMount:i=r.forceMount,side:a=`top`,...o}=e,s=nT(uT,e.__scopeTooltip);return/* @__PURE__ */ t(PS,{present:i||s.open,children:s.disableHoverableContent?/* @__PURE__ */ t(mT,{side:a,...o,ref:n}):/* @__PURE__ */ t(fT,{side:a,...o,ref:n})})},`TooltipContent`)),fT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,n){let r=nT(uT,e.__scopeTooltip),i=Qw(uT,e.__scopeTooltip),a=B.useRef(null),o=Rx(n,a),[s,c]=B.useState(null),{trigger:l,onClose:u}=r,d=a.current,{onPointerInTransitChange:f}=i,p=B.useCallback(()=>{c(null),f(!1)},[f]),m=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=gT(r,hT(r,n.getBoundingClientRect())),a=_T(t.getBoundingClientRect()),o=yT([...i,...a]);c(o),f(!0)},[f]);return B.useEffect(()=>()=>p(),[p]),B.useEffect(()=>{if(l&&d){let e=/* @__PURE__ */ Ww(e=>m(e,d),`handleTriggerLeave`),t=/* @__PURE__ */ Ww(e=>m(e,l),`handleContentLeave`);return l.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{l.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[l,d,m,p]),B.useEffect(()=>{if(s){let e=/* @__PURE__ */ Ww(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||d?.contains(t),i=!vT(n,s);r?p():i&&(p(),u())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[l,d,s,u,p]),/* @__PURE__ */ t(mT,{...e,ref:o})},`TooltipContentHoverable`)),pT=/* @__PURE__ */ mS(`TooltipContent`),mT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,r){let{__scopeTooltip:i,children:a,"aria-label":o,id:s,onEscapeKeyDown:c,onPointerDownOutside:l,...u}=e,d=nT(uT,i),f=qw(i),{onClose:p}=d;B.useEffect(()=>(document.addEventListener(Xw,p),()=>document.removeEventListener(Xw,p)),[p]),B.useEffect(()=>{if(d.trigger){let e=/* @__PURE__ */ Ww(e=>{e.target instanceof Node&&e.target.contains(d.trigger)&&p()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[d.trigger,p]);let{setContentId:m}=d;return Wx(()=>(m(s),()=>{m(void 0)}),[s,m]),/* @__PURE__ */ t(en,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:/* @__PURE__ */ n(Rw,{"data-state":d.stateAttribute,role:o?void 0:`tooltip`,id:o?void 0:d.contentId,...f,...u,ref:r,style:{...u.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[/* @__PURE__ */ t(pT,{children:a}),o?/* @__PURE__ */ t(Hw,{id:d.contentId,role:`tooltip`,children:o}):null]})})},`TooltipContentImpl`));function hT(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Ww(hT,`getExitSideFromRect`);function gT(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Ww(gT,`getPaddedExitPoints`);function _T(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Ww(_T,`getPointsFromRect`);function vT(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Ww(vT,`isPointInPolygon`);function yT(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),bT(t)}Ww(yT,`getHull`);function bT(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Ww(bT,`getHullPresorted`);var xT=$w,ST=rT,CT=aT,wT=lT,TT=dT;const ET=ct.createContext(void 0);function DT(){return ct.useContext(ET)}const OT=xT,kT=ST,AT=CT,jT=B.forwardRef(({className:e,sideOffset:n=4,side:r=`top`,...i},a)=>{let o=DT();return t(wT,{container:o,children:t(TT,{ref:a,sideOffset:n,side:r,style:{zIndex:100},className:mC(`max-w-[90vw]`,`z-50 overflow-hidden rounded-md bg-tooltips border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});jT.displayName=TT.displayName;function MT({description:e,children:r,size:i=`sm`,placement:a=`top`,className:o,asChild:s}){let[c,l]=B.useState(!1),u=B.useRef(!1);return B.useEffect(()=>{let e=()=>{l(!1),u.current=!0,requestAnimationFrame(()=>{u.current=!1})};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},[]),t(OT,{delayDuration:0,children:n(kT,{open:c,onOpenChange:e=>{u.current||l(e)},children:[t(AT,{className:`cursor-pointer`,asChild:s,children:r}),t(jT,{side:a,className:`px-3 py-1.5 max-w-${i} text-${i} px-3 ${o}`,children:e})]})})}Q();const NT=/* @__PURE__ */ new Set;function PT(e,t,n){H(()=>{t&&!NT.has(e)&&(NT.add(e),console.warn(`[@vertesia/ui] ${e} is deprecated: ${n}`))},[t,n,e])}function FT(e){return B.Children.toArray(e).some(e=>{if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`)return!0;if(B.isValidElement(e)){let t=e.props;return t[`aria-hidden`]===!0||t[`aria-hidden`]===`true`?!1:FT(t.children)}return!1})}const IT=Ln(`hover:cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{destructive:`bg-destructive text-destructive ring-1 ring-inset ring-destructive/50 shadow-xs hover:bg-destructive/50`,outline:`border border-input bg-background shadow-xs hover:bg-muted ring-inset`,secondary:`bg-info text-info shadow-xs hover:bg-mixer-info/10 ring-inset`,ghost:`hover:bg-muted/50 ring-inset`,link:`text-foreground underline-offset-4 hover:underline ring-inset`,primary:`bg-primary text-primary shadow-xs hover:bg-primary/90 ring-inset`,unstyled:``},size:{xs:`h-7 rounded px-2 py-1 text-xs gap-x-1`,sm:`h-8 rounded px-3 text-xs`,md:`h-9 rounded-md px-4 py-2`,lg:`h-10 rounded-md px-3`,xl:`rounded-md px-3.5 py-2.5 text-sm gap-x-2`,icon:`p-0 m-0 rounded-full`,none:``}},defaultVariants:{variant:`primary`,size:`md`}}),LT=B.forwardRef(({className:r,variant:i,size:a,asChild:o=!1,alt:s,isDisabled:c,isLoading:l,title:u,tooltipPlacement:d=`top`,onClick:f,type:p,...m},h)=>{PT(`Button.alt`,s!==void 0,"use `title` instead — it drives the same tooltip and the accessible name. `alt` remains an alias for one release.");let g=o?fS:`button`,_=o?p:p??`button`,v=u??s,y=m[`aria-label`]??s??(FT(m.children)?void 0:u),b=o?m.children:n(e,{children:[l&&t(wv,{className:`animate-spin`}),m.children]}),x=t(g,{className:mC(IT({variant:i,size:a}),r),disabled:c||l||m.disabled,ref:h,onClick:f,type:_,autoFocus:!1,...m,"aria-label":y,children:b});return v?t(MT,{description:v,asChild:!0,className:`cursor-pointer`,size:`xs`,placement:d,children:x}):x});LT.displayName=`Button`;const RT=B.forwardRef(({size:e,content:n,toast:r,className:i,alt:a,"aria-label":o,...s},c)=>{let[l,u]=G(!1),{t:d}=K();PT(`CopyButton.alt`,a!==void 0,"use aria-label for the accessible name. `alt` is forwarded for one release.");let f=e=>{e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{u(!0),setTimeout(()=>u(!1),2e3),r?.toast&&r.toast({status:`success`,title:r.message||d(`misc.copiedToClipboard`),duration:2e3})}).catch(e=>{console.error(`Failed to copy text: `,e),r?.toast&&r.toast({status:`error`,title:d(`misc.failedToCopy`),duration:2e3})})},p=o??a??d(`misc.copy`);return t(LT,{ref:c,className:mC(i),variant:`unstyled`,size:e||`sm`,onClick:f,...s,title:p,children:l?t(wh,{className:`text-success`}):t(Ig,{className:`size-4`})})});RT.displayName=`CopyButton`;function zT(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e(t))}}const BT=Ln(`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium`,{variants:{variant:{default:`text-foreground bg-muted`,secondary:`bg-secondary text-info`,destructive:`bg-destructive text-destructive`,attention:`bg-attention text-attention`,success:`bg-success text-success`,info:`bg-info text-info`,done:`bg-done text-done`,outline:`bg-transparent border border-border text-foreground`}},defaultVariants:{variant:`default`}});function VT({className:e,variant:n,children:r,onClick:i,...a}){let o=i?{role:`button`,tabIndex:0,onClick:i,onKeyDown:zT(i)}:{};return t(`span`,{className:mC(BT({variant:n}),e),...o,...a,children:r})}Ln(`inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-border`,{variants:{variant:{default:``,success:``,destructive:``,attention:``,done:``,info:``,outline:``}},defaultVariants:{variant:`default`}}),Ln(`h-1.5 w-1.5`,{variants:{variant:{default:`fill-foreground`,success:`fill-success`,destructive:`fill-destructive`,attention:`fill-attention`,done:`fill-done`,info:`fill-info`,outline:`fill-foreground`}},defaultVariants:{variant:`default`}});function HT({children:e}){return t(`span`,{style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`},children:e})}Q();const UT=pt(!1);function WT({children:e}){return t(UT.Provider,{value:!0,children:e})}function GT({className:e,children:r,isOpen:i,onClose:a,description:o=`Modal Description`,noCloseButton:s=!1,allowOverflow:c=!1,disableCloseOnClickOutside:l=!1,size:u=`md`,action:d}){let f=e=>{e||a()};function p(){switch(u){case`sm`:return`max-w-[20vw]`;case`md`:return`max-w-[60vw] lg:max-w-[40vw]`;case`lg`:return`max-w-[80vw] md:max-w-[60vw]`;case`xl`:return`max-w-[95vw] lg:max-w-[80vw]`;case`full`:return`h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)]`;default:return`max-w-[60vw] lg:max-w-[40vw]`}}return n(JT,{open:i,onOpenChange:e=>{(!l||e)&&f(e)},children:[c&&t(ZT,{className:`z-50 fixed inset-0 bg-black/80`}),t(HT,{children:t($T,{children:o})}),n(QT,{className:mC(`min-h-20 p-4`,`fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 sm:rounded-lg`,p(),e),children:[t(`div`,{className:`top-4 end-4 absolute`,children:n(`div`,{className:`flex gap-2`,children:[d&&d,!s&&t(XT,{onClick:()=>f(!1),asChild:!0,autoFocus:!1,children:t(LT,{variant:`outline`,title:`Close`,className:`data-[state=open]:bg-muted opacity-70 hover:opacity-100 rounded-sm focus:outline-none focus:ring-2 focus:ring-ring ring-offset-background focus:ring-offset-2 data-[state=open]:text-muted transition-opacity disabled:pointer-events-none`,children:t(xx,{className:`size-4`})})})]})}),t(WT,{children:r})]})]})}const KT=({children:e,show:r=!0,className:i,description:a,showDivider:o=!1,...s})=>r?n(eE,{className:mC(o?`border-b-solid border-b border-b-1 pb-2 mb-4`:``,`text-lg font-semibold leading-6 tracking-tight`,{"py-2":!a},i),...s,children:[e,a&&t($T,{className:`text-sm !font-normal text-muted pb-2`,children:a})]}):n(HT,{children:[t(eE,{children:e}),a&&t($T,{children:a})]}),qT=({children:e,className:n,...r})=>t(`div`,{className:mC(`text-sm max-h-[80vh] overflow-y-auto`,n),...r,children:e}),JT=qS,YT=ZS,XT=fC,ZT=B.forwardRef(({className:e,...n},r)=>t($S,{ref:r,className:mC(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...n}));ZT.displayName=$S.displayName;const QT=B.forwardRef(({className:e,children:r,...i},a)=>{let o=DT();return n(YT,{container:o,children:[t(ZT,{}),t(rC,{ref:a,className:mC(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...i,children:r})]})});QT.displayName=rC.displayName;const $T=B.forwardRef(({className:e,...n},r)=>t(uC,{ref:r,className:mC(`text-sm text-muted`,e),...n}));$T.displayName=uC.displayName;const eE=B.forwardRef(({className:e,...n},r)=>t(cC,{ref:r,className:mC(`text-lg font-semibold leading-none tracking-tight`,e),...n}));eE.displayName=cC.displayName;var tE=Object.defineProperty,nE=(e,t)=>tE(e,`name`,{value:t,configurable:!0});// @__NO_SIDE_EFFECTS__
937
+ function mS(e){let t=/* @__PURE__ */ uS(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=pS,t}uS(mS,`createSlottable`);var hS=/* @__PURE__ */ uS((e,t)=>{if(`child`in e.props){let t=e.props.child;return B.isValidElement(t)?B.cloneElement(t,void 0,e.props.children(t.props.children)):null}return B.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function gS(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}uS(gS,`mergeProps`);function _S(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}uS(_S,`getElementRef`);function vS(e){return B.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===pS}uS(vS,`isSlottable`);var yS=Symbol.for(`react.lazy`);function bS(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===yS&&`_payload`in e&&xS(e._payload)}uS(bS,`isLazyComponent`);function xS(e){return typeof e==`object`&&!!e&&`then`in e}uS(xS,`isPromiseLike`);var SS=/* @__PURE__ */ uS(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),CS=/* @__PURE__ */ uS(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),wS=B.use,TS=Object.defineProperty,ES=(e,t)=>TS(e,`name`,{value:t,configurable:!0}),DS=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,n)=>{let r=/* @__PURE__ */ dS(`Primitive.${n}`),i=B.forwardRef((e,i)=>{let{asChild:a,...o}=e,s=a?r:n;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),/* @__PURE__ */ t(s,{...o,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function OS(e,t){e&&rn.flushSync(()=>e.dispatchEvent(t))}ES(OS,`dispatchDiscreteCustomEvent`);var kS=Object.defineProperty,AS=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ ((e,t)=>kS(e,`name`,{value:t,configurable:!0}))(function(e,n){let{container:r,...i}=e,[a,o]=B.useState(!1);Wx(()=>o(!0),[]);let s=r||a&&globalThis?.document?.body;return s?rn.createPortal(/* @__PURE__ */ t(DS.div,{...i,ref:n}),s):null},`Portal`)),jS=Object.defineProperty,MS=(e,t)=>jS(e,`name`,{value:t,configurable:!0});function NS(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}MS(NS,`useStateMachine`);var PS=/* @__PURE__ */ MS(e=>{let{present:t,children:n}=e,r=FS(t),i=typeof n==`function`?n({present:r.isPresent}):B.Children.only(n),a=LS(r.ref,zS(i));return typeof n==`function`||r.isPresent?B.cloneElement(i,{ref:a}):null},`Presence`);function FS(e){let[t,n]=B.useState(),r=B.useRef(null),i=B.useRef(e),a=B.useRef(`none`),o=B.useRef(void 0),[s,c]=NS(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return B.useEffect(()=>{s===`mounted`?(a.current=o.current??RS(r.current),o.current=void 0):a.current=`none`},[s]),Wx(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=RS(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Wx(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=/* @__PURE__ */ MS(a=>{let o=RS(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=/* @__PURE__ */ MS(e=>{e.target===t&&(a.current=RS(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:B.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=RS(t)}else r.current=null;n(e)},[])}}MS(FS,`usePresence`);function IS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}MS(IS,`setRef`);function LS(...e){let t=B.useRef(e);return t.current=e,B.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=IS(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():IS(n[e],null)}}},[])}MS(LS,`useStableComposedRefs`);function RS(e){return e?.animationName||`none`}MS(RS,`getAnimationName`);function zS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}MS(zS,`getElementRef`);var BS=Object.defineProperty,VS=(e,t)=>BS(e,`name`,{value:t,configurable:!0}),HS=`Dialog`,[US,WS]=/* @__PURE__ */ Hx(HS),[GS,KS]=US(HS),qS=/* @__PURE__ */ VS(e=>{let{__scopeDialog:n,children:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=B.useRef(null),l=B.useRef(null),[u,d]=iS({prop:i,defaultProp:a??!1,onChange:o,caller:HS}),[f,p]=B.useState(0),[m,h]=B.useState(0);return/* @__PURE__ */ t(GS,{scope:n,triggerRef:c,contentRef:l,contentId:Yx(),titleId:Yx(),descriptionId:Yx(),titlePresent:f>0,descriptionPresent:m>0,setTitleCount:p,setDescriptionCount:h,open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:r})},`Dialog`),JS=`DialogPortal`,[YS,XS]=US(JS,{forceMount:void 0}),ZS=/* @__PURE__ */ VS(e=>{let{__scopeDialog:n,forceMount:r,children:i,container:a}=e,o=KS(JS,n);return/* @__PURE__ */ t(YS,{scope:n,forceMount:r,children:B.Children.map(i,e=>/* @__PURE__ */ t(PS,{present:r||o.open,children:/* @__PURE__ */ t(AS,{asChild:!0,container:a,children:e})}))})},`DialogPortal`),QS=`DialogOverlay`,$S=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=XS(QS,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=KS(QS,e.__scopeDialog);return o.modal?/* @__PURE__ */ t(PS,{present:i||o.open,children:/* @__PURE__ */ t(tC,{...a,ref:n})}):null},`DialogOverlay`)),eC=/* @__PURE__ */ dS(`DialogOverlay.RemoveScroll`),tC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(QS,r),o=Rx(n,tn());return/* @__PURE__ */ t(on,{as:eC,allowPinchZoom:!0,shards:[a.contentRef],children:/* @__PURE__ */ t(DS.div,{"data-state":pC(a.open),...i,ref:o,style:{pointerEvents:`auto`,...i.style}})})},`DialogOverlayImpl`)),nC=`DialogContent`,rC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=XS(nC,e.__scopeDialog),{forceMount:i=r.forceMount,...a}=e,o=KS(nC,e.__scopeDialog);return/* @__PURE__ */ t(PS,{present:i||o.open,children:o.modal?/* @__PURE__ */ t(iC,{...a,ref:n}):/* @__PURE__ */ t(aC,{...a,ref:n})})},`DialogContent`)),iC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=KS(nC,e.__scopeDialog),i=B.useRef(null),a=Rx(n,r.contentRef,i);return B.useEffect(()=>{let e=i.current;if(e)return sn(e)},[]),/* @__PURE__ */ t(oC,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:kx(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:kx(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:kx(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),aC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let r=KS(nC,e.__scopeDialog),i=B.useRef(!1),a=B.useRef(!1);return/* @__PURE__ */ t(oC,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,t.detail.originalEvent.type===`pointerdown`&&(a.current=!0));let n=t.target;r.triggerRef.current?.contains(n)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&a.current&&t.preventDefault()}})},`DialogContentNonModal`)),oC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(n,r){let{__scopeDialog:i,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,...c}=n,l=KS(nC,i);return an(),/* @__PURE__ */ t(e,{children:/* @__PURE__ */ t(nn,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:o,onUnmountAutoFocus:s,children:/* @__PURE__ */ t(en,{role:`dialog`,id:l.contentId,"aria-describedby":l.descriptionPresent?l.descriptionId:void 0,"aria-labelledby":l.titlePresent?l.titleId:void 0,"data-state":pC(l.open),...c,ref:r,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})},`DialogContentImpl`)),sC=`DialogTitle`,cC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(sC,r),{setTitleCount:o}=a;return Wx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),/* @__PURE__ */ t(DS.h2,{id:a.titleId,...i,ref:n})},`DialogTitle`)),lC=`DialogDescription`,uC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(lC,r),{setDescriptionCount:o}=a;return Wx(()=>(o(e=>e+1),()=>o(e=>e-1)),[o]),/* @__PURE__ */ t(DS.p,{id:a.descriptionId,...i,ref:n})},`DialogDescription`)),dC=`DialogClose`,fC=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ VS(function(e,n){let{__scopeDialog:r,...i}=e,a=KS(dC,r);return/* @__PURE__ */ t(DS.button,{type:`button`,...i,ref:n,onClick:kx(e.onClick,()=>a.onOpenChange(!1))})},`DialogClose`));function pC(e){return e?`open`:`closed`}VS(pC,`getState`);function mC(...e){return ln(st(e))}const hC=pt(null);function gC({children:e}){let n=W(/* @__PURE__ */ new Map),r=W(/* @__PURE__ */ new Map),i=V(e=>n.current.get(e),[]),a=V((e,t)=>{n.current.set(e,t)},[]),o=V(async(e,t)=>{let i=n.current.get(e);if(i)return i;let a=r.current.get(e);if(a)return a;let o=t().then(t=>(n.current.set(e,t),r.current.delete(e),t)).catch(t=>{throw r.current.delete(e),t});return r.current.set(e,o),o},[]),s=ct.useMemo(()=>({getUrl:i,setUrl:a,getOrFetch:o}),[i,a,o]);return t(hC.Provider,{value:s,children:e})}function _C(){return yt(hC)}function vC(e){return e.startsWith(`agents/`)||e.startsWith(`documents/`)}function yC(e,t,n=`inline`){return`artifact:${e}:${t}:${n}`}function bC(e){return`file:${e}`}Q();const xC=_t(()=>import(`react-vega`).then(({VegaEmbed:e})=>({default:e})));function SC({error:e,chartTitle:r}){return t(`div`,{className:`flex items-center justify-center h-full bg-destructive text-destructive rounded-md p-4`,children:n(`div`,{className:`text-center`,children:[n(`p`,{className:`text-sm font-medium text-destructive`,children:[`Cannot render `,r||`Vega-Lite`,` chart`]}),t(`p`,{className:`text-xs text-destructive mt-1 max-w-xs truncate`,children:e})]})})}function CC(){return t(`output`,{className:`flex items-center justify-center w-full h-full`,children:t(wv,{className:`w-5 h-5 animate-spin text-muted`})})}function wC({isOpen:e,onClose:r,title:i,description:a,children:s}){let{t:c}=K();return t(qS,{open:e,onOpenChange:e=>!e&&r(),children:n(ZS,{children:[t($S,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm transition-all duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`}),n(rC,{className:`fixed inset-2 sm:inset-4 z-50 flex flex-col bg-card text-card-foreground rounded-xl shadow-2xl transition-all duration-300 ease-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-98 data-[state=open]:zoom-in-98 data-[state=closed]:slide-out-to-bottom-2 data-[state=open]:slide-in-from-bottom-2`,onEscapeKeyDown:r,children:[t(fC,{asChild:!0,children:t(o,{variant:`unstyled`,onClick:r,className:`absolute top-3 end-3 z-10 p-2 rounded-lg bg-card backdrop-blur-sm hover:bg-muted transition-colors duration-150 shadow-sm`,"aria-label":c(`agent.closeFullscreen`),children:t(xx,{className:`w-5 h-5 text-muted`})})}),t(`div`,{className:`flex-1 overflow-auto p-4 sm:p-6 animate-in fade-in-0 duration-500 delay-150`,children:s}),t(`div`,{className:`flex items-center justify-between px-4 sm:px-6 py-3 border-t border-border bg-muted rounded-b-xl`,children:n(`div`,{className:`flex flex-col`,children:[t(cC,{className:`text-base font-semibold text-card-foreground`,children:i||c(`agent.dashboard`)}),a&&t(uC,{className:`text-sm text-muted mt-0.5`,children:a})]})})]})]})})}function TC(e,t){if(t===`chart`)return 280;let n=1;if(e.vconcat)n=Array.isArray(e.vconcat)?e.vconcat.length:1;else if(e.concat){let t=e.columns||2,r=Array.isArray(e.concat)?e.concat.length:1;n=Math.ceil(r/t)}else e.facet&&(n=2);return Math.max(500,n*280+40)}function EC(e,t){return typeof window>`u`?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function DC(){let e=[1,2,3,4,5].map(e=>EC(`--chart-${e}`,`#3b82f6`));return{categorical:[...e,...e],blues:e,purples:e,greens:e,diverging:e}}function OC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kC(e){return OC(e)}function AC(e){let t=JSON.parse(JSON.stringify(e)),n=[`vconcat`,`hconcat`,`concat`];if(!n.some(e=>Array.isArray(t[e])))return t;let r=[];if(Array.isArray(t.params))for(let e of t.params)e&&typeof e==`object`&&e.name&&e.select&&r.push({name:e.name,param:e});if(r.length===0)return t;for(let{name:e,param:i}of r){let r=i.select?.fields||[],a=i.select?.bind===`legend`,o=null;for(let e of n)if(Array.isArray(t[e])){o=t[e];break}if(!o||o.length===0)continue;let s=0;for(let e=0;e<o.length;e++){let t=o[e];if(MC(t,r)||a&&NC(t,r)){s=e;break}}let c=o[s];c.params||=[],c.params.push(i),t.params=(t.params??[]).filter(t=>t.name!==e)}return Array.isArray(t.params)&&t.params.length===0&&delete t.params,t}function jC(e,t){if(!t||Object.keys(t).length===0)return e;let n=JSON.parse(JSON.stringify(e)),r=e=>{for(let n of e)n.name&&n.name in t&&(n.value=t[n.name])};Array.isArray(n.params)&&r(n.params);let i=e=>{if(Array.isArray(e)){for(let t of e)if(Array.isArray(t.params)&&r(t.params),t.vconcat&&i(t.vconcat),t.hconcat&&i(t.hconcat),t.concat&&i(t.concat),Array.isArray(t.layer))for(let e of t.layer)Array.isArray(e.params)&&r(e.params)}};if(n.vconcat&&i(n.vconcat),n.hconcat&&i(n.hconcat),n.concat&&i(n.concat),Array.isArray(n.layer))for(let e of n.layer)e&&Array.isArray(e.params)&&r(e.params);return n}function MC(e,t){if(!e?.encoding)return!1;for(let n of t)for(let t of Object.values(e.encoding))if(t.field===n)return!0;if(Array.isArray(e.layer)){for(let n of e.layer)if(MC(n,t))return!0}return!1}function NC(e,t){if(!e)return!1;let n=e=>{if(!e)return!1;let n=e.color?.field;return!!n&&t.includes(n)};if(n(e.encoding))return!0;if(Array.isArray(e.layer)){for(let t of e.layer)if(n(t.encoding))return!0}return!1}function PC(e,t=[]){let n=[];if(!e||typeof e!=`object`)return n;if(e.data&&typeof e.data==`object`){let r=e.data.url;typeof r==`string`&&r.startsWith(`artifact:`)&&n.push({path:[...t,`data`],artifactPath:r.replace(/^artifact:/,``).trim()})}for(let r of[`layer`,`vconcat`,`hconcat`,`concat`,`spec`,`repeat`,`facet`])if(r in e){let i=e[r];Array.isArray(i)?i.forEach((e,i)=>{kC(e)&&n.push(...PC(e,[...t,r,String(i)]))}):kC(i)&&n.push(...PC(i,[...t,r]))}return n}function FC(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of t){let t=e.split(`.`),i=n;for(let e=0;e<t.length-1;e++){let n=i[t[e]];if(!OC(n))break;i=n}let a=t[t.length-1],o=i[a];OC(o)&&(delete o.url,o.values=r)}return n}function IC(e){let t=DC(),n=EC(`--font-sans`,`system-ui, sans-serif`),r=EC(`--foreground`,`#18181b`),i=EC(`--muted`,`#71717a`),a=EC(`--border`,`#e4e4e7`);return{background:`transparent`,view:{stroke:`transparent`},range:{category:t.categorical,diverging:t.diverging,heatmap:t.purples,ramp:t.blues},mark:{tooltip:!0},bar:{tooltip:!0,cornerRadiusTopLeft:4,cornerRadiusTopRight:4},line:{tooltip:!0,strokeWidth:2.5,strokeCap:`round`},point:{tooltip:!0,size:60,filled:!0},area:{tooltip:!0,fillOpacity:.7,line:!0},rect:{tooltip:!0,cornerRadius:2},arc:{tooltip:!0,cornerRadius:4},circle:{tooltip:!0,size:80},axis:{labelColor:i,titleColor:r,gridColor:a,domainColor:a,tickColor:a,labelFont:n,titleFont:n,labelFontSize:11,titleFontSize:12,titleFontWeight:500},legend:{labelColor:i,titleColor:r,labelFont:n,titleFont:n,labelFontSize:11,titleFontSize:12,symbolSize:100},title:{color:r,font:n,fontSize:14,fontWeight:600}}}const LC=vt(function({spec:r,artifactRunId:i}){let{t:a}=K(),{title:s,description:c,options:l}=r,u=r.spec,[d,f]=G(!1),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(!1),y=W(null),b=W(null),x=W(null),{client:S}=q(),C=_C(),w=W(S);w.current=S;let T=W(C);T.current=C;let[E,D]=G(null),[O,k]=G(!1),[A,j]=G(null),M=l?.mode||`chart`,ee=M===`dashboard`,N=l?.enableFullscreen??ee,P=l?.height||TC(u,M);H(()=>{let e=PC(u);if(e.length===0){D(u),k(!1),j(null);return}i?console.info(`[VegaLiteChart] resolving artifacts with runId:`,i,e.map(e=>e.artifactPath)):console.warn(`[VegaLiteChart] artifact references found but artifactRunId is missing!`,{references:e.map(e=>e.artifactPath),artifactRunId:i});let t=!1;return k(!0),j(null),(async()=>{let n=/* @__PURE__ */ new Map,r=w.current,a=T.current;for(let o of e)try{let e=o.path.join(`.`),t;if(i&&!vC(o.artifactPath)){let e=yC(i,o.artifactPath,`inline`);t=a?await a.getOrFetch(e,async()=>(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url):(await r.files.getArtifactDownloadUrl(i,o.artifactPath,`inline`)).url}else{let e=bC(o.artifactPath);t=a?await a.getOrFetch(e,async()=>(await r.files.getDownloadUrl(o.artifactPath)).url):(await r.files.getDownloadUrl(o.artifactPath)).url}let s=await fetch(t);if(!s.ok)throw Error(`Failed to fetch artifact data: ${s.statusText}`);let c=o.artifactPath.toLowerCase().endsWith(`.csv`),l;if(c){let{default:e}=await import(`papaparse`),t=await s.text();l=e.parse(t,{header:!0,skipEmptyLines:!0,dynamicTyping:!0}).data}else{let e=await s.json();l=Array.isArray(e)?e:[e]}n.set(e,l)}catch(e){console.error(`Failed to resolve artifact: ${o.artifactPath}`,e),t||j(`Failed to load data from artifact: ${o.artifactPath}`);return}if(!t){let e=FC(u,n);D(e),k(!1)}})(),()=>{t=!0}},[u,i]);let[F,te]=G(!1),I=W(!1);H(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`);e!==I.current&&(I.current=e,te(e))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let[ne,L]=G(0),R=W(0);H(()=>{if(!x.current)return;let e,t=new ResizeObserver(t=>{clearTimeout(e),e=setTimeout(()=>{let e=t[0]?.contentRect.width;e&&e!==R.current&&(R.current=e,L(e))},100)});t.observe(x.current);let n=x.current.clientWidth;return R.current=n,L(n),()=>{clearTimeout(e),t.disconnect()}},[]);let re=U(()=>PC(u).length>0,[u]),ie=U(()=>{if(re&&!E)return null;let e=E||u;return e?(l?.parameterValues&&(e=jC(e,l.parameterValues)),AC(e)):null},[E,u,re,l?.parameterValues]),ae=V((e,t)=>{if(!e||typeof e!=`object`)return e;if(e.hconcat&&Array.isArray(e.hconcat)){let n=e.hconcat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,hconcat:e.hconcat.map(e=>ae(e,i))}}if(e.vconcat&&Array.isArray(e.vconcat))return{...e,vconcat:e.vconcat.map(e=>ae(e,t))};if(e.concat&&Array.isArray(e.concat)){let n=e.columns??e.concat.length,r=(e.spacing??10)*(n-1),i=Math.floor((t-r)/n);return{...e,concat:e.concat.map(e=>ae(e,i))}}let n=e.width;return n===`container`||typeof n==`number`&&n>t?{...e,width:t}:e},[]),oe=V((e,t=!1)=>{if(!ie)return null;let n=IC(F),r=t?typeof window<`u`?Math.min(window.innerWidth-80,1400):1200:ne>0?ne-24:500,i=`vconcat`in ie||`hconcat`in ie||`concat`in ie,a=i?{type:`pad`,contains:`padding`}:{type:`fit`,contains:`padding`},o=ie;i&&r&&(o=ae(ie,r));let c=o.width,l=i?void 0:c===`container`?r:c??r,{width:u,...d}=o;return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,...!i&&l?{width:l}:{},height:t?void 0:e,autosize:a,...i?o:d,...s&&!ie.title?{title:s}:{},config:{...n,...ie.config}}},[ie,s,F,ne,ae]),se=V(async()=>{let e=_?b.current:y.current;if(e&&!p)try{(await e.toCanvas(2)).toBlob(async e=>{e&&(await navigator.clipboard.write([new ClipboardItem({"image/png":e})]),m(!0),setTimeout(()=>m(!1),2e3))},`image/png`)}catch(e){console.error(`Failed to copy chart:`,e)}},[p,_]),ce=V(async()=>{let e=_?b.current:y.current;if(e&&!d){f(!0);try{let t=await e.toImageURL(`png`,2),n=document.createElement(`a`);n.download=`${s||`chart`}.png`,n.href=t,n.click()}catch(e){console.error(`Failed to export chart:`,e)}finally{f(!1)}}},[s,d,_]),le=V(e=>{y.current=e,g(null)},[]),ue=V(e=>{b.current=e},[]),de=V(e=>{console.error(`Vega-Lite rendering error:`,e),g(e instanceof Error?e.message:`Unknown error`)},[]),fe=V(()=>{v(e=>!e)},[]);H(()=>{g(null)},[u]);let pe=({className:e})=>n(`div`,{className:mC(`flex items-center gap-2`,e),children:[n(o,{variant:`unstyled`,onClick:se,disabled:p,className:`text-xs px-2 py-1 rounded border border-border bg-muted text-muted hover:bg-muted/80 cursor-pointer transition-colors disabled:opacity-50 flex items-center gap-1`,title:a(`agent.copyToClipboard`),children:[t(p?wh:Ig,{className:`w-3 h-3`}),a(p?`agent.copied`:`agent.copy`)]}),n(o,{variant:`unstyled`,onClick:ce,disabled:d,className:`text-xs px-2 py-1 rounded border border-border bg-muted text-muted hover:bg-muted/80 cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1`,title:a(`agent.exportAsPng`),children:[t(Gg,{className:`w-3 h-3`}),a(d?`agent.exporting`:`agent.export`)]}),N&&n(o,{variant:`unstyled`,onClick:fe,className:`text-xs px-2 py-1 rounded border border-border bg-muted text-muted hover:bg-muted/80 cursor-pointer transition-colors flex items-center gap-1`,title:a(_?`agent.exitFullscreen`:`agent.fullscreen`),children:[t(_?Zv:Nv,{className:`w-3 h-3`}),a(_?`agent.exit`:`agent.fullscreen`)]})]});if(O||re&&!E)return t(`div`,{className:`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||`Chart`})}),t(`div`,{className:`flex items-center justify-center bg-muted rounded`,style:{width:`100%`,height:P},children:n(`div`,{className:`flex items-center gap-2 text-muted`,children:[t(wv,{className:`w-5 h-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading data from artifacts...`})]})})]})});if(A)return t(`div`,{className:`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:P},children:t(SC,{error:A,chartTitle:s})})]})});if(h)return t(`div`,{className:`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||`Chart`})}),t(`div`,{style:{width:`100%`,height:P},children:t(SC,{error:h,chartTitle:s})})]})});let me=oe(P),he=oe(0,!0);return me?(typeof window<`u`&&localStorage.getItem(`DEBUG_VEGA_RENDERS`)&&console.log(`VegaLite rendering with spec:`,{title:s,hasData:!!me.data?.values,dataLength:me.data?.values?.length}),n(e,{children:[t(`div`,{className:mC(`bg-card text-card-foreground rounded-lg border border-border shadow-sm`,ee&&`border-2`),children:n(`div`,{className:`flex flex-col gap-2 p-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`div`,{className:`flex items-center gap-2`,children:[t(`span`,{className:`font-medium text-sm text-card-foreground`,children:s||(ee?`Dashboard`:`Chart`)}),ee&&t(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-info text-info`,children:`Interactive`})]}),t(pe,{})]}),c&&t(`span`,{className:`text-xs text-muted`,children:c}),t(`div`,{ref:x,className:`bg-card text-card-foreground rounded overflow-hidden`,style:{width:`100%`,height:P,minWidth:0},children:t(ft,{fallback:t(CC,{}),children:t(xC,{spec:me,onEmbed:e=>le(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})})]})}),n(wC,{isOpen:_,onClose:()=>v(!1),title:s||(ee?`Dashboard`:`Chart`),description:c,children:[t(`div`,{className:`w-full h-full min-h-[calc(100vh-200px)]`,children:he&&t(ft,{fallback:t(CC,{}),children:t(xC,{spec:he,onEmbed:e=>ue(e.view),onError:de,options:{renderer:l?.renderer||`canvas`,actions:!1}})})}),t(`div`,{className:`absolute bottom-6 end-6`,children:t(pe,{className:`bg-card rounded-lg shadow-lg p-2 border border-border`})})]})]})):null},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function RC(e){return e.library===`vega-lite`&&typeof e.spec==`object`}function zC(e){return e.library===`recharts`||e.library===void 0}function BC(e){return typeof e.$schema==`string`&&e.$schema.includes(`vega`)}const VC=vt(function({spec:e,artifactRunId:r}){return RC(e)?t(LC,{spec:e,artifactRunId:r}):BC(e)?t(LC,{spec:{library:`vega-lite`,spec:e},artifactRunId:r}):n(`div`,{className:`my-5 rounded-lg border border-attention bg-attention p-4 text-sm text-attention`,children:[`Recharts chart rendering has been retired. Use a Vega-Lite chart spec (`,t(`code`,{children:`library: "vega-lite"`}),` with `,t(`code`,{children:`spec`}),`).`]})},(e,t)=>JSON.stringify(e.spec)===JSON.stringify(t.spec)&&e.artifactRunId===t.artifactRunId);function HC(e,t){return e===`live`?e:t===0?`live`:Math.min(Math.max(e,0),t-1)}function UC(e,t){return t===0?-1:e===`live`?t-1:Math.min(Math.max(e,0),t-1)}function WC(e,t){if(e.length===0)return null;let n=t===`live`?e.length:UC(t,e.length);for(let t=Math.min(n-1,e.length-1);t>=0;t--)if(e[t].type===J.QUESTION)return t;return null}function GC(e,t){if(e.length===0||t===`live`)return null;let n=UC(t,e.length);for(let t=n+1;t<e.length;t++)if(e[t].type===J.QUESTION)return t;return`live`}function KC(e,t,n){let r=n?HC(t,e.length):`live`,i=UC(r,e.length),a=!n||r===`live`,o=a?e:e.slice(0,i+1);return{cursor:r,cursorIndex:i,isLive:a,renderedMessageCount:o.length,displayedMessages:o}}function qC(e){let t=e.indexOf(`?`);return t===-1?new URLSearchParams:new URLSearchParams(e.slice(t+1))}function JC(){return typeof window<`u`}function YC(){if(!JC())return!1;let e=new URLSearchParams(window.location.search),t=qC(window.location.hash),n=e.get(`agentChatPlayback`)??t.get(`agentChatPlayback`);return n===`1`||n===`true`}const XC=JC,ZC=YC;Q();function QC({cursor:e,messages:r,onChangeCursor:i,className:a}){let{t:s}=K(),c=r.length,l=e===`live`,u=UC(e,c),d=c>0&&(l||u>0),f=!l&&c>0,p=c>0&&(l||u>0),m=!l&&c>0&&u<c-1,h=c===0?0:u+1,[g,_]=G(String(h));H(()=>{_(String(h))},[h]);let v=()=>{if(c!==0){if(e===`live`){i(c-1);return}i(Math.max(0,u-1))}},y=()=>{if(c!==0&&e!==`live`){if(u>=c-1){i(`live`);return}i(u+1)}},b=()=>{c!==0&&i(0)},x=()=>{c!==0&&i(c-1)},S=()=>{_(String(h))},C=(e,t=!1)=>{if(c===0){_(`0`);return}let n=Number.parseInt(e,10);if(!Number.isFinite(n)){t&&S();return}let r=Math.min(Math.max(n,1),c);_(String(r)),i(r-1)},w=e=>{c!==0&&C(e)},T=c>1,E=+!!T,D=Math.max(1,c),O=`size-7 rounded-lg text-muted hover:text-foreground disabled:opacity-35`,k=`${Math.max(3,String(c).length+1)}ch`;return n(`div`,{className:z(`inline-flex max-w-full flex-col gap-1 rounded-xl border border-border/70 bg-background/95 px-2 py-1 text-sm leading-none text-muted shadow-lg shadow-black/10 backdrop-blur`,a),"data-testid":`agent-test-playback-controls`,"data-playback-cursor":e,"data-live-message-count":c,"data-rendered-message-count":l?c:u+1,children:[n(`div`,{className:`flex max-w-full items-center gap-1`,children:[t(`span`,{className:`ms-2 me-1 font-medium leading-none text-foreground/80`,children:s(`agent.rewind.label`)}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToStart`),disabled:!p,onClick:b,className:O,children:t(Hh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.previousMessage`),disabled:!d,onClick:v,className:O,children:t(Ah,{className:`size-4`})}),n(`span`,{className:`inline-flex min-w-16 items-center justify-center gap-0.5 px-1 font-medium leading-none tabular-nums text-foreground/80`,"data-testid":`agent-test-playback-position`,children:[t(R,{type:`text`,variant:`unstyled`,size:`sm`,clearable:!1,inputMode:`numeric`,pattern:`[0-9]*`,value:g,"aria-label":s(`agent.rewind.positionInput`),disabled:c===0,onChange:e=>{let t=e.replace(/\D/g,``);_(t)},onBlur:e=>C(e.currentTarget.value,!0),onKeyDown:e=>{e.key===`Enter`&&(C(e.currentTarget.value,!0),e.currentTarget.blur())},style:{width:k},className:`h-7 w-auto rounded-md border border-transparent bg-transparent px-1 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none transition-colors hover:border-border focus:border-ring focus:bg-muted/30 disabled:opacity-50`}),t(`span`,{"aria-hidden":`true`,className:`text-muted`,children:`/`}),t(`span`,{className:`text-muted`,children:c})]}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.nextMessage`),disabled:!f,onClick:y,className:O,children:t(Nh,{className:`size-4`})}),t(o,{type:`button`,variant:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLatest`),disabled:!m,onClick:x,className:O,children:t(Gh,{className:`size-4`})}),t(o,{type:`button`,variant:l?`secondary`:`ghost`,size:`icon`,title:s(`agent.rewind.jumpToLive`),disabled:l,onClick:()=>i(`live`),className:z(O,l&&`bg-muted text-foreground`),children:t(Ny,{className:`size-4`})})]}),t(`div`,{className:`px-2 pb-1`,children:t(Ae,{min:E,max:D,step:1,value:[h],"aria-label":s(`agent.rewind.positionInput`),disabled:!T,onValueChange:([e])=>w(String(e)),className:`h-2`})})]})}var $C=typeof document<`u`?St:function(){};function ew(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ew(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ew(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function tw(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nw(e,t){let n=tw(e);return Math.round(t*n)/n}function rw(e){let t=B.useRef(e);return $C(()=>{t.current=e}),t}function iw(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=B.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=B.useState(r);ew(f,r)||p(r);let[m,h]=B.useState(null),[g,_]=B.useState(null),v=B.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=B.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=B.useRef(null),C=B.useRef(null),w=B.useRef(u),T=c!=null,E=rw(c),D=rw(i),O=rw(l),k=B.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Bn(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!ew(w.current,t)&&(w.current=t,rn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);$C(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=B.useRef(!1);$C(()=>(A.current=!0,()=>{A.current=!1}),[]),$C(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=B.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=B.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=B.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=nw(M.floating,u.x),r=nw(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...tw(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return B.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:ee}),[u,k,j,M,ee])}const aw=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Rn({element:r.current,padding:i}).fn(n):r?Rn({element:r,padding:i}).fn(n):{}}}},ow=(e,t)=>{let n=Wn(e);return{name:n.name,fn:n.fn,options:[e,t]}},sw=(e,t)=>{let n=Gn(e);return{name:n.name,fn:n.fn,options:[e,t]}},cw=(e,t)=>({fn:Un(e).fn,options:[e,t]}),lw=(e,t)=>{let n=Vn(e);return{name:n.name,fn:n.fn,options:[e,t]}},uw=(e,t)=>{let n=Kn(e);return{name:n.name,fn:n.fn,options:[e,t]}},dw=(e,t)=>{let n=Hn(e);return{name:n.name,fn:n.fn,options:[e,t]}},fw=(e,t)=>{let n=aw(e);return{name:n.name,fn:n.fn,options:[e,t]}};var pw=Object.defineProperty,mw=(e,t)=>pw(e,`name`,{value:t,configurable:!0});function hw(e){let t=B.useRef(e);return B.useEffect(()=>{t.current=e}),B.useMemo(()=>((...e)=>t.current?.(...e)),[])}mw(hw,`useCallbackRef`);var gw=Object.defineProperty,_w=(e,t)=>gw(e,`name`,{value:t,configurable:!0});function vw(e){let[t,n]=B.useState(void 0);return Wx(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}_w(vw,`useSize`);var yw=Object.defineProperty,bw=(e,t)=>yw(e,`name`,{value:t,configurable:!0}),xw=`Popper`,[Sw,Cw]=/* @__PURE__ */ Hx(xw),[ww,Tw]=Sw(xw),Ew=/* @__PURE__ */ bw(e=>{let{__scopePopper:n,children:r}=e,[i,a]=B.useState(null),[o,s]=B.useState(void 0);return/* @__PURE__ */ t(ww,{scope:n,anchor:i,onAnchorChange:a,placementState:o,setPlacementState:s,children:r})},`Popper`),Dw=`PopperAnchor`,Ow=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ bw(function(e,n){let{__scopePopper:r,virtualRef:i,...a}=e,o=Tw(Dw,r),s=B.useRef(null),c=o.onAnchorChange,l=Rx(n,B.useCallback(e=>{s.current=e,e&&c(e)},[c])),u=B.useRef(null);B.useEffect(()=>{if(!i)return;let e=u.current;u.current=i.current,e!==u.current&&c(u.current)});let d=o.placementState&&Fw(o.placementState),f=d?.[0],p=d?.[1];return i?null:/* @__PURE__ */ t(DS.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...a,ref:l})},`PopperAnchor`)),kw=`PopperContent`,[Aw,jw]=Sw(kw),Mw=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ bw(function(e,n){let{__scopePopper:r,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=Tw(kw,r),[v,y]=B.useState(null),b=Rx(n,y),[x,S]=B.useState(null),C=vw(x),w=C?.width??0,T=C?.height??0,E=i+(o===`center`?``:`-`+o),D=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(u)?u:[u],k=O.length>0,A={padding:D,boundary:O.filter(Nw),altBoundary:k},{refs:j,floatingStyles:M,placement:ee,isPositioned:N,middlewareData:P}=iw({strategy:`fixed`,placement:E,whileElementsMounted:/* @__PURE__ */ bw((...e)=>zn(...e,{animationFrame:m===`always`}),`whileElementsMounted`),elements:{reference:_.anchor},middleware:[ow({mainAxis:a+T,alignmentAxis:s}),l&&sw({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?cw():void 0,...A}),l&&lw({...A}),uw({...A,apply:/* @__PURE__ */ bw(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&fw({element:x,padding:c}),Pw({arrowWidth:w,arrowHeight:T}),p&&dw({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),F=_.setPlacementState;Wx(()=>(F(ee),()=>{F(void 0)}),[ee,F]);let[te,I]=Fw(ee),ne=hw(h);Wx(()=>{N&&ne?.()},[N,ne]);let L=P.arrow?.x,R=P.arrow?.y,re=P.arrow?.centerOffset!==0,[ie,ae]=B.useState();return Wx(()=>{v&&ae(window.getComputedStyle(v).zIndex)},[v]),/* @__PURE__ */ t(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:N?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ie,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:/* @__PURE__ */ t(Aw,{scope:r,placedSide:te,placedAlign:I,onArrowChange:S,arrowX:L,arrowY:R,shouldHideArrow:re,children:/* @__PURE__ */ t(DS.div,{"data-side":te,"data-align":I,...g,ref:b,style:{...g.style,animation:N?g.style?.animation:`none`}})})})},`PopperContent`));function Nw(e){return e!==null}bw(Nw,`isNotNull`);var Pw=/* @__PURE__ */ bw(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Fw(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Fw(e){let[t,n=`center`]=e.split(`-`);return[t,n]}bw(Fw,`getSideAndAlignFromPlacement`);var Iw=Ew,Lw=Ow,Rw=Mw,zw=Object.defineProperty,Bw=(e,t)=>zw(e,`name`,{value:t,configurable:!0}),Vw=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Hw=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Bw(function(e,n){return/* @__PURE__ */ t(DS.span,{...e,ref:n,style:{...Vw,...e.style}})},`VisuallyHidden`)),Uw=Object.defineProperty,Ww=(e,t)=>Uw(e,`name`,{value:t,configurable:!0}),[Gw,Kw]=/* @__PURE__ */ Hx(`Tooltip`,[Cw]),qw=Cw(),Jw=`TooltipProvider`,Yw=700,Xw=`tooltip.open`,[Zw,Qw]=Gw(Jw),$w=/* @__PURE__ */ Ww(e=>{let{__scopeTooltip:n,delayDuration:r=Yw,skipDelayDuration:i=300,disableHoverableContent:a=!1,children:o}=e,s=B.useRef(!0),c=B.useRef(!1),l=B.useRef(0);return B.useEffect(()=>{let e=l.current;return()=>window.clearTimeout(e)},[]),/* @__PURE__ */ t(Zw,{scope:n,isOpenDelayedRef:s,delayDuration:r,onOpen:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),s.current=!1)},[i]),onClose:B.useCallback(()=>{i<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.current=!0,i))},[i]),isPointerInTransitRef:c,onPointerInTransitChange:B.useCallback(e=>{c.current=e},[]),disableHoverableContent:a,children:o})},`TooltipProvider`),eT=`Tooltip`,[tT,nT]=Gw(eT),rT=/* @__PURE__ */ Ww(e=>{let{__scopeTooltip:n,children:r,open:i,defaultOpen:a,onOpenChange:o,disableHoverableContent:s,delayDuration:c}=e,l=Qw(eT,e.__scopeTooltip),u=qw(n),[d,f]=B.useState(null),[p,m]=B.useState(void 0),h=Yx(),g=B.useRef(0),_=s??l.disableHoverableContent,v=c??l.delayDuration,y=B.useRef(!1),[b,x]=iS({prop:i,defaultProp:a??!1,onChange:/* @__PURE__ */ Ww(e=>{e?(l.onOpen(),document.dispatchEvent(new CustomEvent(Xw))):l.onClose(),o?.(e)},`onChange`),caller:eT}),S=B.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y.current=!1,x(!0)},[x]),w=B.useCallback(()=>{window.clearTimeout(g.current),g.current=0,x(!1)},[x]),T=B.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{y.current=!0,x(!0),g.current=0},v)},[v,x]);B.useEffect(()=>()=>{g.current&&=(window.clearTimeout(g.current),0)},[]);let E=p??h;return/* @__PURE__ */ t(Iw,{...u,children:/* @__PURE__ */ t(tT,{scope:n,contentId:E,setContentId:m,open:b,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:B.useCallback(()=>{l.isOpenDelayedRef.current?T():C()},[l.isOpenDelayedRef,T,C]),onTriggerLeave:B.useCallback(()=>{_?w():(window.clearTimeout(g.current),g.current=0)},[w,_]),onOpen:C,onClose:w,disableHoverableContent:_,children:r})})},`Tooltip`),iT=`TooltipTrigger`,aT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,n){let{__scopeTooltip:r,...i}=e,a=nT(iT,r),o=Qw(iT,r),s=qw(r),c=Rx(n,B.useRef(null),a.onTriggerChange),l=B.useRef(!1),u=B.useRef(!1),d=B.useCallback(()=>l.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),/* @__PURE__ */ t(Lw,{asChild:!0,...s,children:/* @__PURE__ */ t(DS.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:kx(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:kx(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:kx(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:kx(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:kx(e.onBlur,a.onClose),onClick:kx(e.onClick,a.onClose)})})},`TooltipTrigger`)),oT=`TooltipPortal`,[sT,cT]=Gw(oT,{forceMount:void 0}),lT=/* @__PURE__ */ Ww(e=>{let{__scopeTooltip:n,forceMount:r,children:i,container:a}=e,o=nT(oT,n);return/* @__PURE__ */ t(sT,{scope:n,forceMount:r,children:/* @__PURE__ */ t(PS,{present:r||o.open,children:/* @__PURE__ */ t(AS,{asChild:!0,container:a,children:i})})})},`TooltipPortal`),uT=`TooltipContent`,dT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,n){let r=cT(uT,e.__scopeTooltip),{forceMount:i=r.forceMount,side:a=`top`,...o}=e,s=nT(uT,e.__scopeTooltip);return/* @__PURE__ */ t(PS,{present:i||s.open,children:s.disableHoverableContent?/* @__PURE__ */ t(mT,{side:a,...o,ref:n}):/* @__PURE__ */ t(fT,{side:a,...o,ref:n})})},`TooltipContent`)),fT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,n){let r=nT(uT,e.__scopeTooltip),i=Qw(uT,e.__scopeTooltip),a=B.useRef(null),o=Rx(n,a),[s,c]=B.useState(null),{trigger:l,onClose:u}=r,d=a.current,{onPointerInTransitChange:f}=i,p=B.useCallback(()=>{c(null),f(!1)},[f]),m=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=gT(r,hT(r,n.getBoundingClientRect())),a=_T(t.getBoundingClientRect()),o=yT([...i,...a]);c(o),f(!0)},[f]);return B.useEffect(()=>()=>p(),[p]),B.useEffect(()=>{if(l&&d){let e=/* @__PURE__ */ Ww(e=>m(e,d),`handleTriggerLeave`),t=/* @__PURE__ */ Ww(e=>m(e,l),`handleContentLeave`);return l.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{l.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[l,d,m,p]),B.useEffect(()=>{if(s){let e=/* @__PURE__ */ Ww(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=l?.contains(t)||d?.contains(t),i=!vT(n,s);r?p():i&&(p(),u())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[l,d,s,u,p]),/* @__PURE__ */ t(mT,{...e,ref:o})},`TooltipContentHoverable`)),pT=/* @__PURE__ */ mS(`TooltipContent`),mT=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ Ww(function(e,r){let{__scopeTooltip:i,children:a,"aria-label":o,id:s,onEscapeKeyDown:c,onPointerDownOutside:l,...u}=e,d=nT(uT,i),f=qw(i),{onClose:p}=d;B.useEffect(()=>(document.addEventListener(Xw,p),()=>document.removeEventListener(Xw,p)),[p]),B.useEffect(()=>{if(d.trigger){let e=/* @__PURE__ */ Ww(e=>{e.target instanceof Node&&e.target.contains(d.trigger)&&p()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[d.trigger,p]);let{setContentId:m}=d;return Wx(()=>(m(s),()=>{m(void 0)}),[s,m]),/* @__PURE__ */ t(en,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:/* @__PURE__ */ n(Rw,{"data-state":d.stateAttribute,role:o?void 0:`tooltip`,id:o?void 0:d.contentId,...f,...u,ref:r,style:{...u.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[/* @__PURE__ */ t(pT,{children:a}),o?/* @__PURE__ */ t(Hw,{id:d.contentId,role:`tooltip`,children:o}):null]})})},`TooltipContentImpl`));function hT(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Ww(hT,`getExitSideFromRect`);function gT(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Ww(gT,`getPaddedExitPoints`);function _T(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Ww(_T,`getPointsFromRect`);function vT(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Ww(vT,`isPointInPolygon`);function yT(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),bT(t)}Ww(yT,`getHull`);function bT(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Ww(bT,`getHullPresorted`);var xT=$w,ST=rT,CT=aT,wT=lT,TT=dT;const ET=ct.createContext(void 0);function DT(){return ct.useContext(ET)}const OT=xT,kT=ST,AT=CT,jT=B.forwardRef(({className:e,sideOffset:n=4,side:r=`top`,...i},a)=>{let o=DT();return t(wT,{container:o,children:t(TT,{ref:a,sideOffset:n,side:r,style:{zIndex:100},className:mC(`max-w-[90vw]`,`z-50 overflow-hidden rounded-md bg-tooltips border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...i})})});jT.displayName=TT.displayName;function MT({description:e,children:r,size:i=`sm`,placement:a=`top`,className:o,asChild:s}){let[c,l]=B.useState(!1),u=B.useRef(!1);return B.useEffect(()=>{let e=()=>{l(!1),u.current=!0,requestAnimationFrame(()=>{u.current=!1})};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},[]),t(OT,{delayDuration:0,children:n(kT,{open:c,onOpenChange:e=>{u.current||l(e)},children:[t(AT,{className:`cursor-pointer`,asChild:s,children:r}),t(jT,{side:a,className:`px-3 py-1.5 max-w-${i} text-${i} px-3 ${o}`,children:e})]})})}Q();const NT=/* @__PURE__ */ new Set;function PT(e,t,n){H(()=>{t&&!NT.has(e)&&(NT.add(e),console.warn(`[@vertesia/ui] ${e} is deprecated: ${n}`))},[t,n,e])}function FT(e){return B.Children.toArray(e).some(e=>{if(typeof e==`string`)return e.trim().length>0;if(typeof e==`number`)return!0;if(B.isValidElement(e)){let t=e.props;return t[`aria-hidden`]===!0||t[`aria-hidden`]===`true`?!1:FT(t.children)}return!1})}const IT=Ln(`hover:cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{destructive:`bg-destructive text-destructive ring-1 ring-inset ring-destructive/50 shadow-xs hover:bg-destructive/50`,outline:`border border-input bg-background shadow-xs hover:bg-muted ring-inset`,secondary:`bg-info text-info shadow-xs hover:bg-mixer-info/10 ring-inset`,ghost:`hover:bg-muted/50 ring-inset`,link:`text-foreground underline-offset-4 hover:underline ring-inset`,primary:`bg-primary text-primary shadow-xs hover:bg-primary/90 ring-inset`,unstyled:``},size:{xs:`h-7 rounded px-2 py-1 text-xs gap-x-1`,sm:`h-8 rounded px-3 text-xs`,md:`h-9 rounded-md px-4 py-2`,lg:`h-10 rounded-md px-3`,xl:`rounded-md px-3.5 py-2.5 text-sm gap-x-2`,icon:`p-0 m-0 rounded-full`,none:``}},defaultVariants:{variant:`primary`,size:`md`}}),LT=B.forwardRef(({className:r,variant:i,size:a,asChild:o=!1,alt:s,isDisabled:c,isLoading:l,title:u,tooltipPlacement:d=`top`,onClick:f,type:p,...m},h)=>{PT(`Button.alt`,s!==void 0,"use `title` instead — it drives the same tooltip and the accessible name. `alt` remains an alias for one release.");let g=o?fS:`button`,_=o?p:p??`button`,v=u??s,y=m[`aria-label`]??s??(FT(m.children)?void 0:u),b=o?m.children:n(e,{children:[l&&t(wv,{className:`animate-spin`}),m.children]}),x=t(g,{className:mC(IT({variant:i,size:a}),r),disabled:c||l||m.disabled,ref:h,onClick:f,type:_,autoFocus:!1,...m,"aria-label":y,children:b});return v?t(MT,{description:v,asChild:!0,className:`cursor-pointer`,size:`xs`,placement:d,children:x}):x});LT.displayName=`Button`;const RT=B.forwardRef(({size:e,content:n,toast:r,className:i,alt:a,BtnIcon:o,"aria-label":s,...c},l)=>{let[u,d]=G(!1),{t:f}=K();PT(`CopyButton.alt`,a!==void 0,"use aria-label for the accessible name. `alt` is forwarded for one release.");let p=e=>{e.stopPropagation(),navigator.clipboard.writeText(n).then(()=>{d(!0),setTimeout(()=>d(!1),2e3),r?.toast&&r.toast({status:`success`,title:r.message||f(`misc.copiedToClipboard`),duration:2e3})}).catch(e=>{console.error(`Failed to copy text: `,e),r?.toast&&r.toast({status:`error`,title:f(`misc.failedToCopy`),duration:2e3})})},m=s??a??f(`misc.copy`);return t(LT,{ref:l,className:mC(i),variant:`unstyled`,size:e||`sm`,onClick:p,...c,title:m,children:u?t(wh,{className:`text-success`}):o??t(Ig,{className:`size-4`})})});RT.displayName=`CopyButton`;function zT(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e(t))}}const BT=Ln(`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium`,{variants:{variant:{default:`text-foreground bg-muted`,secondary:`bg-secondary text-info`,destructive:`bg-destructive text-destructive`,attention:`bg-attention text-attention`,success:`bg-success text-success`,info:`bg-info text-info`,done:`bg-done text-done`,outline:`bg-transparent border border-border text-foreground`}},defaultVariants:{variant:`default`}});function VT({className:e,variant:n,children:r,onClick:i,...a}){let o=i?{role:`button`,tabIndex:0,onClick:i,onKeyDown:zT(i)}:{};return t(`span`,{className:mC(BT({variant:n}),e),...o,...a,children:r})}Ln(`inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ring-border`,{variants:{variant:{default:``,success:``,destructive:``,attention:``,done:``,info:``,outline:``}},defaultVariants:{variant:`default`}}),Ln(`h-1.5 w-1.5`,{variants:{variant:{default:`fill-foreground`,success:`fill-success`,destructive:`fill-destructive`,attention:`fill-attention`,done:`fill-done`,info:`fill-info`,outline:`fill-foreground`}},defaultVariants:{variant:`default`}});function HT({children:e}){return t(`span`,{style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`},children:e})}Q();const UT=pt(!1);function WT({children:e}){return t(UT.Provider,{value:!0,children:e})}function GT({className:e,children:r,isOpen:i,onClose:a,description:o=`Modal Description`,noCloseButton:s=!1,allowOverflow:c=!1,disableCloseOnClickOutside:l=!1,size:u=`md`,action:d}){let f=e=>{e||a()};function p(){switch(u){case`sm`:return`max-w-[20vw]`;case`md`:return`max-w-[60vw] lg:max-w-[40vw]`;case`lg`:return`max-w-[80vw] md:max-w-[60vw]`;case`xl`:return`max-w-[95vw] lg:max-w-[80vw]`;case`full`:return`h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)]`;default:return`max-w-[60vw] lg:max-w-[40vw]`}}return n(JT,{open:i,onOpenChange:e=>{(!l||e)&&f(e)},children:[c&&t(ZT,{className:`z-50 fixed inset-0 bg-black/80`}),t(HT,{children:t($T,{children:o})}),n(QT,{className:mC(`min-h-20 p-4`,`fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 sm:rounded-lg`,p(),e),children:[t(`div`,{className:`top-4 end-4 absolute`,children:n(`div`,{className:`flex gap-2`,children:[d&&d,!s&&t(XT,{onClick:()=>f(!1),asChild:!0,autoFocus:!1,children:t(LT,{variant:`outline`,title:`Close`,className:`data-[state=open]:bg-muted opacity-70 hover:opacity-100 rounded-sm focus:outline-none focus:ring-2 focus:ring-ring ring-offset-background focus:ring-offset-2 data-[state=open]:text-muted transition-opacity disabled:pointer-events-none`,children:t(xx,{className:`size-4`})})})]})}),t(WT,{children:r})]})]})}const KT=({children:e,show:r=!0,className:i,description:a,showDivider:o=!1,...s})=>r?n(eE,{className:mC(o?`border-b-solid border-b border-b-1 pb-2 mb-4`:``,`text-lg font-semibold leading-6 tracking-tight`,{"py-2":!a},i),...s,children:[e,a&&t($T,{className:`text-sm !font-normal text-muted pb-2`,children:a})]}):n(HT,{children:[t(eE,{children:e}),a&&t($T,{children:a})]}),qT=({children:e,className:n,...r})=>t(`div`,{className:mC(`text-sm max-h-[80vh] overflow-y-auto`,n),...r,children:e}),JT=qS,YT=ZS,XT=fC,ZT=B.forwardRef(({className:e,...n},r)=>t($S,{ref:r,className:mC(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...n}));ZT.displayName=$S.displayName;const QT=B.forwardRef(({className:e,children:r,...i},a)=>{let o=DT();return n(YT,{container:o,children:[t(ZT,{}),t(rC,{ref:a,className:mC(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...i,children:r})]})});QT.displayName=rC.displayName;const $T=B.forwardRef(({className:e,...n},r)=>t(uC,{ref:r,className:mC(`text-sm text-muted`,e),...n}));$T.displayName=uC.displayName;const eE=B.forwardRef(({className:e,...n},r)=>t(cC,{ref:r,className:mC(`text-lg font-semibold leading-none tracking-tight`,e),...n}));eE.displayName=cC.displayName;var tE=Object.defineProperty,nE=(e,t)=>tE(e,`name`,{value:t,configurable:!0});// @__NO_SIDE_EFFECTS__
938
938
  function rE(e){let n=e+`CollectionProvider`,[r,i]=/* @__PURE__ */ Hx(n),[a,o]=r(n,{collectionRef:{current:null},itemMap:/* @__PURE__ */ new Map}),s=/* @__PURE__ */ nE(e=>{let{scope:n,children:r}=e,i=B.useRef(null),o=B.useRef(/* @__PURE__ */ new Map).current;return/* @__PURE__ */ t(a,{scope:n,itemMap:o,collectionRef:i,children:r})},`CollectionProvider`);s.displayName=n;let c=e+`CollectionSlot`,l=/* @__PURE__ */ dS(c),u=B.forwardRef((e,n)=>{let{scope:r,children:i}=e,a=Rx(n,o(c,r).collectionRef);return/* @__PURE__ */ t(l,{ref:a,children:i})});u.displayName=c;let d=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=/* @__PURE__ */ dS(d),m=B.forwardRef((e,n)=>{let{scope:r,children:i,...a}=e,s=B.useRef(null),c=Rx(n,s),l=o(d,r);return B.useEffect(()=>(l.itemMap.set(s,{ref:s,...a}),()=>void l.itemMap.delete(s))),/* @__PURE__ */ t(p,{[f]:``,ref:c,children:i})});m.displayName=d;function h(t){let n=o(e+`CollectionConsumer`,t);return B.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return nE(h,`useCollection`),[{Provider:s,Slot:u,ItemSlot:m},h,i]}nE(rE,`createCollection`);var iE=/* @__PURE__ */ new WeakMap,aE=class e extends Map{static{nE(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],iE.set(this,!0)}set(e,t){return iE.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=cE(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=oE(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=oE(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return oE(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function oE(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=sE(e,t);return n===-1?void 0:e[n]}nE(oE,`at`);function sE(e,t){let n=e.length,r=cE(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}nE(sE,`toSafeIndex`);function cE(e){return e!==e||e===0?0:Math.trunc(e)}nE(cE,`toSafeInteger`);// @__NO_SIDE_EFFECTS__
939
939
  function lE(e){let n=e+`CollectionProvider`,[r,i]=/* @__PURE__ */ Hx(n),[a,o]=r(n,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new aE,setItemMap:/* @__PURE__ */ nE(()=>void 0,`setItemMap`)}),s=/* @__PURE__ */ nE(({state:e,...n})=>e?/* @__PURE__ */ t(l,{...n,state:e}):/* @__PURE__ */ t(c,{...n}),`CollectionProvider`);s.displayName=n;let c=/* @__PURE__ */ nE(e=>{let n=g();return/* @__PURE__ */ t(l,{...e,state:n})},`CollectionInit`);c.displayName=n+`Init`;let l=/* @__PURE__ */ nE(e=>{let{scope:n,children:r,state:i}=e,o=B.useRef(null),[s,c]=B.useState(null),l=Rx(o,c),[u,d]=i;return B.useEffect(()=>{if(!s)return;let e=pE(()=>{});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s]),/* @__PURE__ */ t(a,{scope:n,itemMap:u,setItemMap:d,collectionRef:l,collectionRefObject:o,collectionElement:s,children:r})},`CollectionProviderImpl`);l.displayName=n+`Impl`;let u=e+`CollectionSlot`,d=/* @__PURE__ */ dS(u),f=B.forwardRef((e,n)=>{let{scope:r,children:i}=e,a=Rx(n,o(u,r).collectionRef);return/* @__PURE__ */ t(d,{ref:a,children:i})});f.displayName=u;let p=e+`CollectionItemSlot`,m=/* @__PURE__ */ dS(p),h=B.forwardRef((e,n)=>{let{scope:r,children:i,...a}=e,s=B.useRef(null),[c,l]=B.useState(null),u=Rx(n,s,l),{setItemMap:d}=o(p,r),f=B.useRef(a);uE(f.current,a)||(f.current=a);let h=f.current;return B.useEffect(()=>{let e=h;return d(t=>c?t.has(c)?t.set(c,{...e,element:c}).toSorted(fE):(t.set(c,{...e,element:c}),t.toSorted(fE)):t),()=>{d(e=>!c||!e.has(c)?e:(e.delete(c),new aE(e)))}},[c,h,d]),/* @__PURE__ */ t(m,{"data-radix-collection-item":``,ref:u,children:i})});h.displayName=p;function g(){return B.useState(new aE)}nE(g,`useInitCollection`);function _(t){let{itemMap:n}=o(e+`CollectionConsumer`,t);return n}return nE(_,`useCollection`),[{Provider:s,Slot:f,ItemSlot:h},{createCollectionScope:i,useCollection:_,useInitCollection:g}]}nE(lE,`createCollection`);function uE(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}nE(uE,`shallowEqual`);function dE(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}nE(dE,`isElementPreceding`);function fE(e,t){return!e[1].element||!t[1].element?0:dE(e[1].element,t[1].element)?-1:1}nE(fE,`sortByDocumentPosition`);function pE(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}nE(pE,`getChildListObserver`);var mE=Object.defineProperty,hE=(e,t)=>mE(e,`name`,{value:t,configurable:!0}),gE=!1;function _E(){let[e,t]=B.useState(gE);return B.useEffect(()=>{gE||(gE=!0,t(!0))},[]),e}hE(_E,`useIsHydrated`);var vE=B.useSyncExternalStore;function yE(){return()=>{}}hE(yE,`subscribe`);function bE(){return vE(yE,()=>!0,()=>!1)}hE(bE,`useIsHydratedModern`);var xE=typeof vE==`function`?bE:_E,SE=Object.defineProperty,CE=(e,t)=>SE(e,`name`,{value:t,configurable:!0}),wE=`rovingFocusGroup.onEntryFocus`,TE={bubbles:!1,cancelable:!0},EE=`RovingFocusGroup`,[DE,OE,kE]=/* @__PURE__ */ rE(EE),[AE,jE]=/* @__PURE__ */ Hx(EE,[kE]),[ME,NE]=AE(EE),PE=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ CE(function(e,n){return/* @__PURE__ */ t(DE.Provider,{scope:e.__scopeRovingFocusGroup,children:/* @__PURE__ */ t(DE.Slot,{scope:e.__scopeRovingFocusGroup,children:/* @__PURE__ */ t(FE,{...e,ref:n})})})},`RovingFocusGroup`)),FE=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ CE(function(e,n){let{__scopeRovingFocusGroup:r,orientation:i,loop:a=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=B.useRef(null),m=Rx(n,p),h=Jn(o),[g,_]=iS({prop:s,defaultProp:c??null,onChange:l,caller:EE}),[v,y]=B.useState(!1),b=hw(u),x=OE(r),S=B.useRef(!1),[C,w]=B.useState(0);return B.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(wE,b),()=>e.removeEventListener(wE,b)},[b]),/* @__PURE__ */ t(ME,{scope:r,orientation:i,dir:h,loop:a,currentTabStopId:g,onItemFocus:B.useCallback(e=>_(e),[_]),onItemShiftTab:B.useCallback(()=>y(!0),[]),onFocusableItemAdd:B.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>w(e=>e-1),[]),children:/* @__PURE__ */ t(DS.div,{tabIndex:v||C===0?-1:0,"data-orientation":i,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:kx(e.onMouseDown,()=>{S.current=!0}),onFocus:kx(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(wE,TE);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);VE([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),d)}}S.current=!1}),onBlur:kx(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),IE=`RovingFocusGroupItem`,LE=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ CE(function(e,n){let{__scopeRovingFocusGroup:r,focusable:i=!0,active:a=!1,tabStopId:o,children:s,...c}=e,l=Yx(),u=o||l,d=NE(IE,r),f=d.currentTabStopId===u,p=OE(r),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=d,_=xE();return Wx(()=>{if(_&&i)return m(),()=>h()},[_,i,m,h]),B.useEffect(()=>{if(!_&&i)return m(),()=>h()},[_,i,m,h]),/* @__PURE__ */ t(DE.ItemSlot,{scope:r,id:u,focusable:i,active:a,children:/* @__PURE__ */ t(DS.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...c,ref:n,onMouseDown:kx(e.onMouseDown,e=>{i?d.onItemFocus(u):e.preventDefault()}),onFocus:kx(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:kx(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=BE(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?HE(n,r+1):n.slice(r+1)}setTimeout(()=>VE(n))}}),children:typeof s==`function`?s({isCurrentTabStop:f,hasTabStop:g!=null}):s})})},`RovingFocusGroupItem`)),RE={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function zE(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}CE(zE,`getDirectionAwareKey`);function BE(e,t,n){let r=zE(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return RE[r]}CE(BE,`getFocusIntent`);function VE(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}CE(VE,`focusFirst`);function HE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}CE(HE,`wrapArray`);var UE=PE,WE=LE,GE=Object.defineProperty,KE=(e,t)=>GE(e,`name`,{value:t,configurable:!0}),qE=[`Enter`,` `],JE=[`ArrowDown`,`PageUp`,`Home`],YE=[`ArrowUp`,`PageDown`,`End`],XE=[...JE,...YE];[...qE],[...qE];var ZE=`Menu`,[QE,$E,eD]=/* @__PURE__ */ rE(ZE),[tD,nD]=/* @__PURE__ */ Hx(ZE,[eD,Cw,jE]),rD=Cw(),iD=jE(),[aD,oD]=tD(ZE),[sD,cD]=tD(ZE),lD=/* @__PURE__ */ KE(e=>{let{__scopeMenu:n,open:r=!1,children:i,dir:a,onOpenChange:o,modal:s=!0}=e,c=rD(n),[l,u]=B.useState(null),d=B.useRef(!1),f=hw(o),p=Jn(a);return B.useEffect(()=>{let e=/* @__PURE__ */ KE(()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=/* @__PURE__ */ KE(()=>d.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),B.useEffect(()=>{if(!r)return;let e=/* @__PURE__ */ KE(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[r,f]),/* @__PURE__ */ t(Iw,{...c,children:/* @__PURE__ */ t(aD,{scope:n,open:r,onOpenChange:f,content:l,onContentChange:u,children:/* @__PURE__ */ t(sD,{scope:n,onClose:B.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:s,children:i})})})},`Menu`),uD=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ KE(function(e,n){let{__scopeMenu:r,...i}=e,a=rD(r);return/* @__PURE__ */ t(Lw,{...a,...i,ref:n})},`MenuAnchor`)),dD=`MenuPortal`,[fD,pD]=tD(dD,{forceMount:void 0}),mD=/* @__PURE__ */ KE(e=>{let{__scopeMenu:n,forceMount:r,children:i,container:a}=e,o=oD(dD,n);return/* @__PURE__ */ t(fD,{scope:n,forceMount:r,children:/* @__PURE__ */ t(PS,{present:r||o.open,children:/* @__PURE__ */ t(AS,{asChild:!0,container:a,children:i})})})},`MenuPortal`),hD=`MenuContent`,[gD,_D]=tD(hD),vD=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ KE(function(e,n){let r=pD(hD,e.__scopeMenu),{forceMount:i=r.forceMount,...a}=e,o=oD(hD,e.__scopeMenu),s=cD(hD,e.__scopeMenu);return/* @__PURE__ */ t(QE.Provider,{scope:e.__scopeMenu,children:/* @__PURE__ */ t(PS,{present:i||o.open,children:/* @__PURE__ */ t(QE.Slot,{scope:e.__scopeMenu,children:s.modal?/* @__PURE__ */ t(yD,{...a,ref:n}):/* @__PURE__ */ t(bD,{...a,ref:n})})})})},`MenuContent`)),yD=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ KE(function(e,n){let r=oD(hD,e.__scopeMenu),i=B.useRef(null),a=Rx(n,i);return B.useEffect(()=>{let e=i.current;if(e)return sn(e)},[]),/* @__PURE__ */ t(SD,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:kx(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},`MenuRootContentModal`)),bD=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ KE(function(e,n){let r=oD(hD,e.__scopeMenu);return/* @__PURE__ */ t(SD,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},`MenuRootContentNonModal`)),xD=/* @__PURE__ */ dS(`MenuContent.ScrollLock`),SD=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ KE(function(e,n){let{__scopeMenu:r,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=oD(hD,r),v=cD(hD,r),y=rD(r),b=iD(r),x=$E(r),[S,C]=B.useState(null),w=B.useRef(null),T=Rx(n,w,_.onContentChange),E=B.useRef(0),D=B.useRef(``),O=B.useRef(0),k=B.useRef(null),A=B.useRef(`right`),j=B.useRef(0),M=h?on:B.Fragment,ee=h?{as:xD,allowPinchZoom:!0}:void 0,N=/* @__PURE__ */ KE(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=RD(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(/* @__PURE__ */ KE((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`))(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);B.useEffect(()=>()=>window.clearTimeout(E.current),[]),an();let P=B.useCallback(e=>A.current===k.current?.side&&BD(e,k.current?.area),[]);return/* @__PURE__ */ t(gD,{scope:r,searchRef:D,onItemEnter:B.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:B.useCallback(e=>{P(e)||(w.current?.focus(),C(null))},[P]),onTriggerLeave:B.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:O,onPointerGraceIntentChange:B.useCallback(e=>{k.current=e},[]),children:/* @__PURE__ */ t(M,{...ee,children:/* @__PURE__ */ t(nn,{asChild:!0,trapped:a,onMountAutoFocus:kx(o,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:/* @__PURE__ */ t(en,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:/* @__PURE__ */ t(UE,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:i,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:kx(l,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:/* @__PURE__ */ t(Rw,{role:`menu`,"aria-orientation":`vertical`,"data-state":ND(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:kx(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=w.current;if(e.target!==i||!XE.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);YE.includes(e.key)&&a.reverse(),ID(a)}),onBlur:kx(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:kx(e.onPointerMove,VD(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),CD=`MenuItem`,wD=`menu.itemSelect`,TD=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ KE(function(e,n){let{disabled:r=!1,onSelect:i,...a}=e,o=B.useRef(null),s=cD(CD,e.__scopeMenu),c=_D(CD,e.__scopeMenu),l=Rx(n,o),u=B.useRef(!1),d=/* @__PURE__ */ KE(()=>{let e=o.current;if(!r&&e){let t=new CustomEvent(wD,{bubbles:!0,cancelable:!0});e.addEventListener(wD,e=>i?.(e),{once:!0}),OS(e,t),t.defaultPrevented?u.current=!1:s.onClose()}},`handleSelect`);return/* @__PURE__ */ t(ED,{...a,ref:l,disabled:r,onClick:kx(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:kx(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:kx(e.onKeyDown,e=>{r||e.target!==e.currentTarget||(c.searchRef.current===``||e.key!==` `)&&qE.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),ED=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ KE(function(e,n){let{__scopeMenu:r,disabled:i=!1,textValue:a,...o}=e,s=_D(CD,r),c=iD(r),l=B.useRef(null),u=Rx(n,l),[d,f]=B.useState(!1),[p,m]=B.useState(``);return B.useEffect(()=>{let e=l.current;e&&m((e.textContent??``).trim())},[o.children]),/* @__PURE__ */ t(QE.ItemSlot,{scope:r,disabled:i,textValue:a??p,children:/* @__PURE__ */ t(WE,{asChild:!0,...c,focusable:!i,children:/* @__PURE__ */ t(DS.div,{role:`menuitem`,"data-highlighted":d?``:void 0,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,...o,ref:u,onPointerMove:kx(e.onPointerMove,VD(e=>{i?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:kx(e.onPointerLeave,VD(e=>s.onItemLeave(e))),onFocus:kx(e.onFocus,()=>f(!0)),onBlur:kx(e.onBlur,()=>f(!1))})})})},`MenuItemImpl`)),[DD,OD]=tD(`MenuRadioGroup`,{value:void 0,onValueChange:/* @__PURE__ */ KE(()=>{},`onValueChange`)}),[kD,AD]=tD(`MenuItemIndicator`,{checked:!1}),[jD,MD]=tD(`MenuSub`);function ND(e){return e?`open`:`closed`}KE(ND,`getOpenState`);function PD(e){return e===`indeterminate`}KE(PD,`isIndeterminate`);function FD(e){return PD(e)?`indeterminate`:e?`checked`:`unchecked`}KE(FD,`getCheckedState`);function ID(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}KE(ID,`focusFirst`);function LD(e,t){return e.map((n,r)=>e[(t+r)%e.length])}KE(LD,`wrapArray`);function RD(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=LD(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}KE(RD,`getNextMatch`);function zD(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}KE(zD,`isPointInPolygon`);function BD(e,t){return t?zD({x:e.clientX,y:e.clientY},t):!1}KE(BD,`isPointerInGraceArea`);function VD(e){return t=>t.pointerType===`mouse`?e(t):void 0}KE(VD,`whenMouse`);var HD=lD,UD=uD,WD=mD,GD=vD,KD=TD,qD=Object.defineProperty,JD=(e,t)=>qD(e,`name`,{value:t,configurable:!0}),YD=`DropdownMenu`,[XD,ZD]=/* @__PURE__ */ Hx(YD,[nD]),QD=nD(),[$D,eO]=XD(YD),tO=/* @__PURE__ */ JD(e=>{let{__scopeDropdownMenu:n,children:r,dir:i,open:a,defaultOpen:o,onOpenChange:s,modal:c=!0}=e,l=QD(n),u=B.useRef(null),[d,f]=iS({prop:a,defaultProp:o??!1,onChange:s,caller:YD});return/* @__PURE__ */ t($D,{scope:n,triggerId:Yx(),triggerRef:u,contentId:Yx(),open:d,onOpenChange:f,onOpenToggle:B.useCallback(()=>f(e=>!e),[f]),modal:c,children:/* @__PURE__ */ t(HD,{...l,open:d,onOpenChange:f,dir:i,modal:c,children:r})})},`DropdownMenu`),nO=`DropdownMenuTrigger`,rO=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ JD(function(e,n){let{__scopeDropdownMenu:r,disabled:i=!1,...a}=e,o=eO(nO,r),s=QD(r),c=Rx(n,o.triggerRef);return/* @__PURE__ */ t(UD,{asChild:!0,...s,children:/* @__PURE__ */ t(DS.button,{type:`button`,id:o.triggerId,"aria-haspopup":`menu`,"aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:c,onPointerDown:kx(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:kx(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&o.onOpenToggle(),e.key===`ArrowDown`&&o.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),iO=/* @__PURE__ */ JD(e=>{let{__scopeDropdownMenu:n,...r}=e,i=QD(n);return/* @__PURE__ */ t(WD,{...i,...r})},`DropdownMenuPortal`),aO=`DropdownMenuContent`,oO=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ JD(function(e,n){let{__scopeDropdownMenu:r,...i}=e,a=eO(aO,r),o=QD(r),s=B.useRef(!1);return/* @__PURE__ */ t(GD,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...i,ref:n,onCloseAutoFocus:kx(e.onCloseAutoFocus,e=>{s.current||a.triggerRef.current?.focus(),s.current=!1,e.preventDefault()}),onInteractOutside:kx(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!a.modal||r)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),sO=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ JD(function(e,n){let{__scopeDropdownMenu:r,...i}=e,a=QD(r);return/* @__PURE__ */ t(KD,{...a,...i,ref:n})},`DropdownMenuItem`)),cO=tO,lO=rO,uO=iO,dO=oO,fO=sO;const pO=B.createContext(!1);function mO({...e}){return t(cO,{"data-slot":`dropdown-menu`,...e})}function hO({...e}){return t(lO,{"data-slot":`dropdown-menu-trigger`,...e})}function gO({className:e,align:n=`start`,sideOffset:r=4,...i}){return t(uO,{children:t(dO,{"data-slot":`dropdown-menu-content`,sideOffset:r,align:n,className:mC(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto data-[state=closed]:overflow-hidden`,e),...i})})}function _O({className:e,inset:n,variant:r=`default`,...i}){return t(fO,{"data-slot":`dropdown-menu-item`,"data-inset":n,"data-variant":r,className:mC(`hover:bg-muted focus:bg-muted data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive gap-2 rounded-md px-1.5 py-1 text-sm data-inset:ps-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),...i})}const vO={left:`start`,center:`center`,right:`end`};function yO({trigger:e,children:r,align:i=`right`,hover:a}){let[o,s]=B.useState(!1),c=B.useRef(null);return a?n(`div`,{className:`relative inline-flex`,onMouseEnter:()=>{c.current&&clearTimeout(c.current),s(!0)},onMouseLeave:()=>{c.current=setTimeout(()=>s(!1),80)},children:[e,o&&t(`div`,{className:mC(`absolute top-full pt-1 z-50`,i===`right`?`end-0`:i===`center`?`left-1/2 -translate-x-1/2`:`start-0`),children:t(`div`,{className:`min-w-32 rounded-lg p-1 shadow-md ring-1 ring-foreground/10 bg-popover text-popover-foreground`,children:t(pO.Provider,{value:!0,children:r})})})]}):n(mO,{children:[t(hO,{asChild:!0,children:t(`span`,{className:`-m-1.5 flex items-center p-1.5`,children:e})}),t(gO,{align:vO[i],className:`w-max`,children:r})]})}function bO({children:e,href:n,onClick:r,isDisabled:i=!1,variant:a=`default`,className:o}){let s=B.useContext(pO),c=mC(`w-full gap-2 rounded-md px-1.5 py-1 text-sm text-nowrap [&_svg:not([class*='size-'])]:size-4 flex cursor-default items-center select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,a===`destructive`?`text-destructive`:``,i?`pointer-events-none opacity-50`:`hover:bg-muted focus:bg-muted`,o);return s?n?t(`a`,{href:n,className:c,children:e}):t(`button`,{type:`button`,className:c,disabled:i,onClick:e=>{e.stopPropagation(),r?.(e)},children:e}):t(_O,{className:mC(`data-[disabled]:pointer-events-none data-[disabled]:opacity-50 text-nowrap`,o),disabled:i,variant:a,onClick:e=>{e.stopPropagation(),r?.(e)},asChild:!!n,children:n?t(`a`,{href:n,children:e}):e})}Yn.extend(Zn),Yn.extend(Xn);var xO=Yn,SO=Object.defineProperty,CO=(e,t)=>SO(e,`name`,{value:t,configurable:!0}),wO=`Switch`,[TO,EO]=/* @__PURE__ */ Hx(wO),[DO,OO]=TO(wO);function kO(e){let{__scopeSwitch:n,checked:r,children:i,defaultChecked:a,disabled:o,form:s,name:c,onCheckedChange:l,required:u,value:d=`on`,internal_do_not_use_render:f}=e,[p,m]=iS({prop:r,defaultProp:a??!1,onChange:l,caller:wO}),[h,g]=B.useState(null),[_,v]=B.useState(null),y=B.useRef(!1),[b,x]=B.useReducer(e=>e+1,0),S={checked:p,setChecked:m,disabled:o,control:h,setControl:g,name:c,form:s,value:d,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:u,defaultChecked:a,isFormControl:!h||!!s||!!h.closest(`form`),bubbleInput:_,setBubbleInput:v};return/* @__PURE__ */ t(DO,{scope:n,...S,children:LO(f)?f(S):i})}CO(kO,`SwitchProvider`);var AO=`SwitchTrigger`,jO=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ CO(function({__scopeSwitch:e,onClick:n,...r},i){let{control:a,form:o,value:s,disabled:c,checked:l,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,onUserInteraction:m,isFormControl:h,bubbleInput:g}=OO(AO,e),_=Rx(i,d),v=B.useRef(l);return B.useEffect(()=>{let e=o?a?.ownerDocument.getElementById(o):a?.form;if(e instanceof HTMLFormElement){let t=/* @__PURE__ */ CO(()=>f(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,o,f]),/* @__PURE__ */ t(DS.button,{type:`button`,role:`switch`,"aria-checked":l,"aria-required":u,"data-state":RO(l),"data-disabled":c?``:void 0,disabled:c,value:s,...r,ref:_,onClick:kx(n,e=>{m(),f(e=>!e),g&&h&&(p.current=e.isPropagationStopped(),p.current||e.stopPropagation())})})},`SwitchTrigger`)),MO=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ CO(function(r,i){let{__scopeSwitch:a,name:o,checked:s,defaultChecked:c,required:l,disabled:u,value:d,onCheckedChange:f,form:p,...m}=r;return/* @__PURE__ */ t(kO,{__scopeSwitch:a,checked:s,defaultChecked:c,disabled:u,required:l,onCheckedChange:f,name:o,form:p,value:d,internal_do_not_use_render:({isFormControl:r})=>/* @__PURE__ */ n(e,{children:[/* @__PURE__ */ t(jO,{...m,ref:i,__scopeSwitch:a}),r&&/* @__PURE__ */ t(IO,{__scopeSwitch:a})]})})},`Switch`)),NO=`SwitchThumb`,PO=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ CO(function(e,n){let{__scopeSwitch:r,...i}=e,a=OO(NO,r);return/* @__PURE__ */ t(DS.span,{"data-state":RO(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:n})},`SwitchThumb`)),FO=`SwitchBubbleInput`,IO=/* @__PURE__ */ B.forwardRef(/* @__PURE__ */ CO(function({__scopeSwitch:e,onClick:n,...r},i){let{control:a,hasConsumerStoppedPropagationRef:o,userInteractionCount:s,checked:c,defaultChecked:l,required:u,disabled:d,name:f,value:p,form:m,bubbleInput:h,setBubbleInput:g}=OO(FO,e),_=Rx(i,g),v=vw(a),y=B.useRef(!1),b=B.useRef(c),x=B.useRef(s);B.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=s!==x.current;x.current=s;let i=b.current!==c;b.current=c;let a=!(r&&o.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:a});n.call(e,c),e.dispatchEvent(t),y.current=!1}},[h,c,o,s]);let S=B.useRef(c);return/* @__PURE__ */ t(DS.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:l??S.current,required:u,disabled:d,name:f,value:p,form:m,...r,tabIndex:-1,ref:_,onClick:kx(n,e=>{y.current&&e.stopPropagation()}),style:{...r.style,...v,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function LO(e){return typeof e==`function`}CO(LO,`isFunction`);function RO(e){return e?`checked`:`unchecked`}CO(RO,`getState`);const zO={sm:[`h-5 w-8`,`size-3`,`translate-x-4 rtl:-translate-x-4`],md:[`h-6 w-11`,`size-4`,`translate-x-6 rtl:-translate-x-6`],lg:[`h-8 w-16`,`size-6`,`translate-x-9 rtl:-translate-x-9`]};function BO({className:e,size:r=`md`,value:i,onChange:a,children:o,disabled:s,...c}){let[l,u,d]=zO[r],f=t(MO,{"data-slot":`switch`,checked:i,onCheckedChange:a,disabled:s,...c,className:mC(`data-[state=checked]:bg-primary data-[state=unchecked]:bg-muted 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:aria-invalid:border-destructive/50 shrink-0 rounded-full border focus-visible:ring-3 aria-invalid:ring-3 peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,l,!o&&e),children:t(PO,{"data-slot":`switch-thumb`,className:mC(`bg-white rounded-full pointer-events-none block ring-0 transition-transform`,u,i?d:`translate-x-1 rtl:-translate-x-1`)})});return o?n(`div`,{className:mC(`flex items-center`,e),children:[f,t(`span`,{className:`px-2`,children:o})]}):f}function VO(e){switch(e){case`xs`:return`size-2`;case`sm`:return`size-3`;case`md`:return`size-4`;case`lg`:return`size-5`;case`xl`:return`size-7`;case`2xl`:return`size-10`;default:throw Error(`Unexpected size: ${e}`)}}const HO=pt(void 0);HO.Provider;function UO({size:e,className:r}){let i=VO(e||`md`),a=yt(HO);return a?t(a,{className:ot(i,r)}):n(`svg`,{className:ot(`animate-[spin_0.8s_linear_infinite] text-info`,i,r),xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,role:`img`,"aria-label":`Loading`,children:[t(`title`,{children:`Loading`}),t(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),t(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}function WO(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`oauth-complete`&&`success`in e&&typeof e.success==`boolean`}function GO({onComplete:e,onError:t}){let n=W(null),r=W(e),i=W(t);return H(()=>{r.current=e,i.current=t},[e,t]),H(()=>()=>{n.current&&=(n.current(),null)},[]),{openOAuthPopup:e=>{n.current&&=(n.current(),null);let t=window.screenX+(window.outerWidth-600)/2,a=window.screenY+(window.outerHeight-700)/2,o=window.open(e,`oauth_popup`,`width=600,height=700,left=${t},top=${a},popup=yes`),s=!1,c=null,l=new BroadcastChannel(`oauth-callback`);l.addEventListener(`message`,e=>{WO(e.data)&&(s=!0,l.close(),c&&clearInterval(c),r.current(),!e.data.success&&e.data.error&&i.current?.(e.data.error),n.current=null)}),o&&(c=setInterval(()=>{o.closed&&(c&&clearInterval(c),l.close(),s||r.current(),n.current=null)},1e3)),n.current=()=>{l.close(),c&&clearInterval(c)}}}}Q();function KO({appId:r,collectionId:i,collectionName:a,authenticated:o,onAuthChange:s,onError:c,variant:l=`default`,showLabel:u=!1,showDisconnect:d=!1,readOnly:f=!1}){let{client:p}=q(),{t:m}=K(),[h,g]=G(null),[_,v]=G(o===void 0&&!f),[y,b]=G(!1),[x,S]=G(!1),C=o??h?.authenticated??!1,w=a??i,T=`h-6 w-32 justify-center px-2 text-xs`,E=V(async()=>{if(o!==void 0){v(!1);return}if(f){v(!1);return}try{v(!0);let e=await p.remoteMcpConnections.getCollectionStatus(r,i);g(e)}catch(e){console.error(`[RemoteMcpConnectionButton] Failed to load OAuth status:`,e)}finally{v(!1)}},[p,r,i,o,f]);H(()=>{E()},[E]);let{openOAuthPopup:D}=GO({onComplete:()=>{b(!1),E(),s?.()},onError:e=>{console.error(`OAuth failed:`,e),b(!1)}}),O=async()=>{try{b(!0),c?.(null);let e=await p.remoteMcpConnections.authorize(r,i);e.connected?(b(!1),await E(),s?.()):e.authorization_url?D(e.authorization_url):(c?.(`${w}: Authorization URL not provided by server`),b(!1))}catch(e){console.error(`Failed to authorize:`,e);let t=(e instanceof Error?e.original_message??e.message:`Failed to connect`).replace(/^[A-Za-z\s]+:\s/,``);c?.(`${w}: ${t}`),b(!1)}},k=async()=>{try{S(!0),await p.remoteMcpConnections.disconnect(r,i),await E(),s?.()}catch(e){console.error(`Failed to disconnect:`,e)}finally{S(!1)}};return _?l===`compact`?t(LT,{variant:`outline`,size:`sm`,disabled:!0,className:T,title:m(`mcpConnections.checkingStatus`),children:t(UO,{className:`size-3`})}):t(`div`,{className:`flex items-center gap-2 text-sm`,children:t(UO,{className:`size-4`})}):l===`full`?C?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-sm text-foreground`,children:[w,`:`]}),n(`div`,{className:`flex items-center gap-1 text-success text-sm`,children:[t(og,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connected`)})]}),d&&t(LT,{variant:`ghost`,size:`sm`,onClick:k,disabled:x,children:x?t(UO,{className:`size-4`}):m(`mcpOAuth.disconnect`)})]}):n(`div`,{className:`flex items-center gap-2 text-sm`,children:[u&&n(`span`,{className:`font-medium text-foreground`,children:[w,`:`]}),t(LT,{variant:`ghost`,size:`sm`,onClick:O,disabled:y,children:y?n(e,{children:[t(UO,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticating`)})]}):n(e,{children:[t(lb,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.authenticate`)})]})})]}):C?l===`compact`?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),!f&&d&&t(LT,{variant:`outline`,size:`sm`,onClick:k,disabled:x,className:T,children:x?t(UO,{className:`size-3`}):n(e,{children:[t(Zb,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.disconnect`)})]})})]}):n(`div`,{className:`flex items-center gap-1 text-success`,children:[t(og,{className:`size-4`}),t(`span`,{className:`text-sm`,children:m(`mcpOAuth.connected`)})]}):l===`compact`?f?n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[a,`:`]}),t(`div`,{className:`flex items-center gap-1 text-muted`,children:t(`span`,{className:`text-xs`,children:m(`mcpOAuth.notConnected`)})})]}):n(`div`,{className:`flex items-center gap-2`,children:[u&&n(`span`,{className:`font-medium text-xs text-foreground`,children:[w,`:`]}),t(LT,{variant:`outline`,size:`sm`,onClick:O,disabled:y,className:T,children:y?n(e,{children:[t(UO,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(fv,{className:`size-3`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})]}):t(LT,{variant:`outline`,size:`sm`,onClick:O,disabled:f||y,children:y?n(e,{children:[t(UO,{className:`size-4`}),t(`span`,{children:m(`mcpOAuth.connecting`)})]}):n(e,{children:[t(fv,{className:`size-4 me-1`}),t(`span`,{children:m(`mcpOAuth.connect`)})]})})}function qO(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}const JO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XO={};function ZO(e,t){return((t||XO).jsx?YO:JO).test(e)}const QO=/[ \t\n\f\r]/g;function $O(e){return typeof e==`object`?e.type===`text`&&ek(e.value):ek(e)}function ek(e){return e.replace(QO,``)===``}var tk=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};tk.prototype.normal={},tk.prototype.property={},tk.prototype.space=void 0;function nk(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new tk(n,r,t)}function rk(e){return e.toLowerCase()}var ik=class{constructor(e,t){this.attribute=t,this.property=e}};ik.prototype.attribute=``,ik.prototype.booleanish=!1,ik.prototype.boolean=!1,ik.prototype.commaOrSpaceSeparated=!1,ik.prototype.commaSeparated=!1,ik.prototype.defined=!1,ik.prototype.mustUseProperty=!1,ik.prototype.number=!1,ik.prototype.overloadedBoolean=!1,ik.prototype.property=``,ik.prototype.spaceSeparated=!1,ik.prototype.space=void 0;var ak=/* @__PURE__ */ yr({boolean:()=>sk,booleanish:()=>ck,commaOrSpaceSeparated:()=>fk,commaSeparated:()=>dk,number:()=>$,overloadedBoolean:()=>lk,spaceSeparated:()=>uk});let ok=0;const sk=pk(),ck=pk(),lk=pk(),$=pk(),uk=pk(),dk=pk(),fk=pk();function pk(){return 2**++ok}const mk=Object.keys(ak);var hk=class extends ik{constructor(e,t,n,r){let i=-1;if(super(e,t),gk(this,`space`,r),typeof n==`number`)for(;++i<mk.length;){let e=mk[i];gk(this,mk[i],(n&ak[e])===ak[e])}}};hk.prototype.defined=!0;function gk(e,t,n){n&&(e[t]=n)}function _k(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new hk(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[rk(r)]=r,n[rk(a.attribute)]=r}return new tk(t,n,e.space)}const vk=_k({properties:{ariaActiveDescendant:null,ariaAtomic:ck,ariaAutoComplete:null,ariaBusy:ck,ariaChecked:ck,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:uk,ariaCurrent:null,ariaDescribedBy:uk,ariaDetails:null,ariaDisabled:ck,ariaDropEffect:uk,ariaErrorMessage:null,ariaExpanded:ck,ariaFlowTo:uk,ariaGrabbed:ck,ariaHasPopup:null,ariaHidden:ck,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:uk,ariaLevel:$,ariaLive:null,ariaModal:ck,ariaMultiLine:ck,ariaMultiSelectable:ck,ariaOrientation:null,ariaOwns:uk,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:ck,ariaReadOnly:ck,ariaRelevant:null,ariaRequired:ck,ariaRoleDescription:uk,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:ck,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function yk(e,t){return t in e?e[t]:t}function bk(e,t){return yk(e,t.toLowerCase())}const xk=_k({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:dk,acceptCharset:uk,accessKey:uk,action:null,allow:null,allowFullScreen:sk,allowPaymentRequest:sk,allowUserMedia:sk,alpha:sk,alt:null,as:null,async:sk,autoCapitalize:null,autoComplete:uk,autoFocus:sk,autoPlay:sk,blocking:uk,capture:null,charSet:null,checked:sk,cite:null,className:uk,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:ck,controls:sk,controlsList:uk,coords:$|dk,crossOrigin:null,data:null,dateTime:null,decoding:null,default:sk,defer:sk,dir:null,dirName:null,disabled:sk,download:lk,draggable:ck,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:sk,formTarget:null,headers:uk,height:$,hidden:lk,high:$,href:null,hrefLang:null,htmlFor:uk,httpEquiv:uk,id:null,imageSizes:null,imageSrcSet:null,inert:sk,inputMode:null,integrity:null,is:null,isMap:sk,itemId:null,itemProp:uk,itemRef:uk,itemScope:sk,itemType:uk,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:sk,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:sk,muted:sk,name:null,nonce:null,noModule:sk,noValidate:sk,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:sk,optimum:$,pattern:null,ping:uk,placeholder:null,playsInline:sk,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:sk,referrerPolicy:null,rel:uk,required:sk,reversed:sk,rows:$,rowSpan:$,sandbox:uk,scope:null,scoped:sk,seamless:sk,selected:sk,shadowRootClonable:sk,shadowRootCustomElementRegistry:sk,shadowRootDelegatesFocus:sk,shadowRootMode:null,shadowRootSerializable:sk,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:ck,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:sk,useMap:null,value:ck,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:uk,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:sk,declare:sk,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:sk,noHref:sk,noShade:sk,noWrap:sk,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:ck,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:sk,disablePictureInPicture:sk,disableRemotePlayback:sk,exportParts:dk,part:uk,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:bk}),Sk=_k({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:fk,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:uk,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:sk,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:dk,g2:dk,glyphName:dk,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:fk,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:uk,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:fk,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:fk,rev:fk,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:fk,requiredFeatures:fk,requiredFonts:fk,requiredFormats:fk,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:fk,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:fk,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:fk,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:yk}),Ck=_k({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),wk=_k({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:bk}),Tk=_k({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Ek={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Dk=/[A-Z]/g,Ok=/-[a-z]/g,kk=/^data[-\w.:]+$/i;function Ak(e,t){let n=rk(t),r=t,i=ik;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&kk.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Ok,Mk);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Ok.test(e)){let n=e.replace(Dk,jk);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=hk}return new i(r,t)}function jk(e){return`-`+e.toLowerCase()}function Mk(e){return e.charAt(1).toUpperCase()}const Nk=nk([vk,xk,Ck,wk,Tk],`html`),Pk=nk([vk,Sk,Ck,wk,Tk],`svg`);function Fk(e){return e.join(` `).trim()}function Ik(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var n=1,r=1;function i(e){var t=e.match(zk);t&&(n+=t.length);var i=e.lastIndexOf(Kk);r=~i?e.length-i:r+e.length}function a(){var e={line:n,column:r};return function(t){return t.position=new o(e),l(),t}}function o(e){this.start=e,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(i){var a=/* @__PURE__ */ Error(t.source+`:`+n+`:`+r+`: `+i);if(a.reason=i,a.filename=t.source,a.line=n,a.column=r,a.source=e,!t.silent)throw a}function c(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function l(){c(Bk)}function u(e){var t;for(e||=[];t=d();)t!==!1&&e.push(t);return e}function d(){var t=a();if(qk==e.charAt(0)&&Jk==e.charAt(1)){for(var n=2;Yk!=e.charAt(n)&&(Jk!=e.charAt(n)||qk!=e.charAt(n+1));)++n;if(n+=2,Yk===e.charAt(n-1))return s(`End of comment missing`);var o=e.slice(2,n-2);return r+=2,i(o),e=e.slice(n),r+=2,t({type:Xk,comment:o})}}function f(){var e=a(),t=c(Vk);if(t){if(d(),!c(Hk))return s(`property missing ':'`);var n=c(Uk),r=e({type:Zk,property:Lk(t[0].replace(Rk,Yk)),value:n?Lk(n[0].replace(Rk,Yk)):Yk});return c(Wk),r}}function p(){var e=[];u(e);for(var t;t=f();)t!==!1&&(e.push(t),u(e));return e}return l(),p()}function Lk(e){return e?e.replace(Gk,Yk):Yk}var Rk,zk,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk=Y((()=>{Rk=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,zk=/\n/g,Bk=/^\s*/,Vk=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Hk=/^:\s*/,Uk=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Wk=/^[;\s]*/,Gk=/^\s+|\s+$/g,Kk=`
940
940
  `,qk=`/`,Jk=`*`,Yk=``,Xk=`comment`,Zk=`declaration`})),$k=/* @__PURE__ */ yr({default:()=>eA});function eA(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=Ik(e),i=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:a}=e;i?t(r,a,e):a&&(n||={},n[r]=a)}),n}var tA=Y((()=>{Qk()})),nA=/* @__PURE__ */ vr((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),rA=/* @__PURE__ */ vr(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})((tA(),Sr($k))),r=nA();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i}));const iA=oA(`end`),aA=oA(`start`);function oA(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function sA(e){let t=aA(e),n=iA(e);if(t&&n)return{start:t,end:n}}function cA(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?uA(e.position):`start`in e||`end`in e?uA(e):`line`in e||`column`in e?lA(e):``}function lA(e){return dA(e&&e.line)+`:`+dA(e&&e.column)}function uA(e){return lA(e&&e.start)+`-`+lA(e&&e.end)}function dA(e){return e&&typeof e==`number`?e:1}var fA=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=cA(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};fA.prototype.file=``,fA.prototype.name=``,fA.prototype.reason=``,fA.prototype.message=``,fA.prototype.stack=``,fA.prototype.column=void 0,fA.prototype.line=void 0,fA.prototype.ancestors=void 0,fA.prototype.cause=void 0,fA.prototype.fatal=void 0,fA.prototype.place=void 0,fA.prototype.ruleId=void 0,fA.prototype.source=void 0;var pA=/* @__PURE__ */ xr(rA(),1);const mA={}.hasOwnProperty,hA=/* @__PURE__ */ new Map,gA=/[A-Z]/g,_A=/* @__PURE__ */ new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),vA=/* @__PURE__ */ new Set([`td`,`th`]),yA=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function bA(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=jA(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=AA(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Pk:Nk,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=xA(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function xA(e,t,n){if(t.type===`element`)return SA(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return CA(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return TA(e,t,n);if(t.type===`mdxjsEsm`)return wA(e,t);if(t.type===`root`)return EA(e,t,n);if(t.type===`text`)return DA(e,t)}function SA(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Pk,e.schema=i),e.ancestors.push(t);let a=LA(e,t.tagName,!1),o=MA(e,t),s=PA(e,t);return _A.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!$O(e)})),OA(e,o,a,t),kA(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function CA(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}RA(e,t.position)}function wA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);RA(e,t.position)}function TA(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Pk,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:LA(e,t.name,!0),o=NA(e,t),s=PA(e,t);return OA(e,o,a,t),kA(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function EA(e,t,n){let r={};return kA(r,PA(e,t)),e.create(t,e.Fragment,r,n)}function DA(e,t){return t.value}function OA(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function kA(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function AA(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function jA(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=aA(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function MA(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&mA.call(t.properties,i)){let a=FA(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&vA.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function NA(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else RA(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else RA(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function PA(e,t){let n=[],r=-1,i=e.passKeys?/* @__PURE__ */ new Map:hA;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=xA(e,a,o);s!==void 0&&n.push(s)}return n}function FA(e,t,n){let r=Ak(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?qO(n):Fk(n)),r.property===`style`){let t=typeof n==`object`?n:IA(e,String(n));return e.stylePropertyNameCase===`css`&&(t=zA(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Ek[r.property]||r.property:r.attribute,n]}}function IA(e,t){try{return(0,pA.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new fA("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=yA+`#cannot-parse-style-attribute`,r}}function LA(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=ZO(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=ZO(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return mA.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);RA(e)}function RA(e,t){let n=new fA("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=yA+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function zA(e){let t={},n;for(n in e)mA.call(e,n)&&(t[BA(n)]=e[n]);return t}function BA(e){let t=e.replace(gA,VA);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function VA(e){return`-`+e.toLowerCase()}const HA={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},UA={};function WA(e,t){let n=t||UA;return GA(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function GA(e,t,n){if(qA(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return KA(e.children,t,n)}return Array.isArray(e)?KA(e,t,n):``}function KA(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=GA(e[i],t,n);return r.join(``)}function qA(e){return!!(e&&typeof e==`object`)}const JA=document.createElement(`i`);function YA(e){let t=`&`+e+`;`;JA.innerHTML=t;let n=JA.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function XA(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function ZA(e,t){return e.length>0?(XA(e,e.length,0,t),e):t}const QA={}.hasOwnProperty;function $A(e){let t={},n=-1;for(;++n<e.length;)ej(t,e[n]);return t}function ej(e,t){let n;for(n in t){let r=(QA.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){QA.call(r,a)||(r[a]=[]);let e=i[a];tj(r[a],Array.isArray(e)?e:e?[e]:[])}}}function tj(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);XA(e,0,0,r)}function nj(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function rj(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}const ij=gj(/[A-Za-z]/),aj=gj(/[\dA-Za-z]/),oj=gj(/[#-'*+\--9=?A-Z^-~]/);function sj(e){return e!==null&&(e<32||e===127)}const cj=gj(/\d/),lj=gj(/[\dA-Fa-f]/),uj=gj(/[!-/:-@[-`{-~]/);function dj(e){return e!==null&&e<-2}function fj(e){return e!==null&&(e<0||e===32)}function pj(e){return e===-2||e===-1||e===32}const mj=gj(/\p{P}|\p{S}/u),hj=gj(/\s/);function gj(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function _j(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&aj(e.charCodeAt(n+1))&&aj(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function vj(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return pj(r)?(e.enter(n),s(r)):t(r)}function s(r){return pj(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}const yj={tokenize:bj};function bj(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),vj(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return dj(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}const xj={tokenize:Cj},Sj={tokenize:wj};function Cj(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return XA(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Sj,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Sj,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return dj(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;XA(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function wj(e,t,n){return vj(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Tj(e){if(e===null||fj(e)||hj(e))return 1;if(mj(e))return 2}function Ej(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Dj={name:`attention`,resolveAll:Oj,tokenize:kj};function Oj(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Aj(d,-c),Aj(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ZA(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=ZA(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=ZA(l,Ej(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ZA(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=ZA(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,XA(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function kj(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Tj(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Tj(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Aj(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const jj={name:`autolink`,tokenize:Mj};function Mj(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return ij(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||aj(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||aj(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||sj(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):oj(t)?(e.consume(t),l):n(t)}function u(e){return aj(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||aj(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}const Nj={partial:!0,tokenize:Pj};function Pj(e,t,n){return r;function r(t){return pj(t)?vj(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||dj(e)?t(e):n(e)}}const Fj={continuation:{tokenize:Lj},exit:Rj,name:`blockQuote`,tokenize:Ij};function Ij(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return pj(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Lj(e,t,n){let r=this;return i;function i(t){return pj(t)?vj(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Fj,t,n)(r)}}function Rj(e){e.exit(`blockQuote`)}const zj={name:`characterEscape`,tokenize:Bj};function Bj(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return uj(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}const Vj={name:`characterReference`,tokenize:Hj};function Hj(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=aj,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=lj,u):(e.enter(`characterReferenceValue`),a=7,o=cj,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===aj&&!YA(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}const Uj={partial:!0,tokenize:Kj},Wj={concrete:!0,name:`codeFenced`,tokenize:Gj};function Gj(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),pj(t)?vj(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||dj(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Uj,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||dj(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):pj(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),vj(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||dj(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||dj(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&pj(t)?vj(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||dj(t)?e.check(Uj,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||dj(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),pj(t)?vj(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),pj(t)?vj(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||dj(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Kj(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const qj={name:`codeIndented`,tokenize:Yj},Jj={partial:!0,tokenize:Xj};function Yj(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),vj(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):dj(t)?e.attempt(Jj,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||dj(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Xj(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):dj(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):vj(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):dj(e)?i(e):n(e)}}const Zj={name:`codeText`,previous:$j,resolve:Qj,tokenize:eM};function Qj(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function $j(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function eM(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):dj(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||dj(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var tM=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&nM(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),nM(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),nM(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);nM(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);nM(this.left,t.reverse())}}}};function nM(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function rM(e){let t={},n=-1,r,i,a,o,s,c,l,u=new tM(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,iM(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return XA(e,0,1/0,u.slice(0)),!l}function iM(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}const aM={resolve:sM,tokenize:cM},oM={partial:!0,tokenize:lM};function sM(e){return rM(e),e}function cM(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):dj(t)?e.check(oM,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function lM(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),vj(e,a,`linePrefix`)}function a(i){if(i===null||dj(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function uM(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||sj(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||dj(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||fj(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||sj(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function dM(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||
@@ -994,16 +994,16 @@ if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r)
994
994
  `,before:c,encode:[`$`],...a.current()})),t()}return c+=a.move(`
995
995
  `),i&&(c+=a.move(i+`
996
996
  `)),c+=a.move(o),s(),c}function r(e,n,r){let i=e.value||``,a=1;for(t||a++;RegExp(`(^|[^$])`+`\\$`.repeat(a)+`([^$]|$)`).test(i);)a++;let o=`$`.repeat(a);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` `+i+` `);let s=-1;for(;++s<r.unsafe.length;){let e=r.unsafe[s];if(!e.atBreak)continue;let t=r.compilePattern(e),n;for(;n=t.exec(i);){let e=n.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=i.slice(0,e)+` `+i.slice(n.index+1)}}return o+i+o}function i(){return`$`}}const $B={tokenize:tV,concrete:!0,name:`mathFlow`},eV={tokenize:nV,partial:!0};function tV(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){return e.enter(`mathFlow`),e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),c(t)}function c(t){return t===36?(e.consume(t),o++,c):o<2?n(t):(e.exit(`mathFlowFenceSequence`),vj(e,l,`whitespace`)(t))}function l(t){return t===null||dj(t)?d(t):(e.enter(`mathFlowFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===null||dj(t)?(e.exit(`chunkString`),e.exit(`mathFlowFenceMeta`),d(t)):t===36?n(t):(e.consume(t),u)}function d(n){return e.exit(`mathFlowFence`),r.interrupt?t(n):e.attempt(eV,f,g)(n)}function f(t){return e.attempt({tokenize:_,partial:!0},g,p)(t)}function p(t){return(a?vj(e,m,`linePrefix`,a+1):m)(t)}function m(t){return t===null?g(t):dj(t)?e.attempt(eV,f,g)(t):(e.enter(`mathFlowValue`),h(t))}function h(t){return t===null||dj(t)?(e.exit(`mathFlowValue`),m(t)):(e.consume(t),h)}function g(n){return e.exit(`mathFlow`),t(n)}function _(e,t,n){let i=0;return vj(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4);function a(t){return e.enter(`mathFlowFence`),e.enter(`mathFlowFenceSequence`),s(t)}function s(t){return t===36?(i++,e.consume(t),s):i<o?n(t):(e.exit(`mathFlowFenceSequence`),vj(e,c,`whitespace`)(t))}function c(r){return r===null||dj(r)?(e.exit(`mathFlowFence`),t(r)):n(r)}}}function nV(e,t,n){let r=this;return i;function i(n){return n===null?t(n):(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function rV(e){let t=(e||{}).singleDollarTextMath;return t??=!0,{tokenize:n,resolve:iV,previous:aV,name:`mathText`};function n(e,n,r){let i=0,a,o;return s;function s(t){return e.enter(`mathText`),e.enter(`mathTextSequence`),c(t)}function c(n){return n===36?(e.consume(n),i++,c):i<2&&!t?r(n):(e.exit(`mathTextSequence`),l(n))}function l(t){return t===null?r(t):t===36?(o=e.enter(`mathTextSequence`),a=0,d(t)):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),l):dj(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),l):(e.enter(`mathTextData`),u(t))}function u(t){return t===null||t===32||t===36||dj(t)?(e.exit(`mathTextData`),l(t)):(e.consume(t),u)}function d(t){return t===36?(e.consume(t),a++,d):a===i?(e.exit(`mathTextSequence`),e.exit(`mathText`),n(t)):(o.type=`mathTextData`,u(t))}}}function iV(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`mathTextData`){e[t][1].type=`mathTextPadding`,e[n][1].type=`mathTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`mathTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function aV(e){return e!==36||this.events[this.events.length-1][1].type===`characterEscape`}function oV(e){return{flow:{36:$B},text:{36:rV(e)}}}const sV={};function cV(e){let t=this,n=e||sV,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(oV(n)),a.push(ZB()),o.push(QB(n))}const lV=(function(e){if(e==null)return mV;if(typeof e==`string`)return fV(e);if(typeof e==`object`)return Array.isArray(e)?uV(e):dV(e);if(typeof e==`function`)return pV(e);throw Error(`Expected function, string, or object as test`)});function uV(e){let t=[],n=-1;for(;++n<e.length;)t[n]=lV(e[n]);return pV(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].call(this,...e))return!0;return!1}}function dV(e){return pV(t);function t(t){let n;for(n in e)if(t[n]!==e[n])return!1;return!0}}function fV(e){return pV(t);function t(t){return t&&t.type===e}}function pV(e){return t;function t(t,...n){return!!(t&&typeof t==`object`&&`type`in t&&e.call(this,t,...n))}}function mV(){return!0}function hV(e){return e}const gV=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null);let i=lV(t),a=r?-1:1;o(e,void 0,[])();function o(e,s,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+hV(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=[],u,d,f;if((!t||i(e,s,c[c.length-1]||null))&&(l=_V(n(e,c)),l[0]===!1))return l;if(e.children&&l[0]!==`skip`)for(d=(r?e.children.length:-1)+a,f=c.concat(e);d>-1&&d<e.children.length;){if(u=o(e.children[d],d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+a}return l}}});function _V(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:[e]}const vV=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null),gV(e,t,i,r);function i(e,t){let r=t[t.length-1];return n(e,r?r.children.indexOf(e):null,r)}});function yV(){return e=>{vV(e,[`text`],(e,t,n)=>{if(e.type!==`text`)return;let{value:r}=e,i=r.split(/\^/);if(i.length===1||i.length%2==0)return;let a=i.map((e,t)=>t%2==0?{type:`text`,value:e}:{type:`superscript`,data:{hName:`sup`},children:[{type:`text`,value:e}]});n.children.splice(t,1,...a)}),vV(e,[`text`],(e,t,n)=>{if(e.type!==`text`)return;let{value:r}=e,i=r.split(/\~/);if(i.length===1||i.length%2==0)return;let a=i.map((e,t)=>t%2==0?{type:`text`,value:e}:{type:`subscript`,data:{hName:`sub`},children:[{type:`text`,value:e}]});n.children.splice(t,1,...a)})}}const bV=ct.createContext({});function xV({children:e,artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}){let o=U(()=>({artifactRunId:n,onProposalSelect:r,onProposalSubmit:i,MarkdownRenderer:a}),[n,r,i,a]);return t(bV.Provider,{value:o,children:e})}function SV(){return ct.useContext(bV)}const CV=pt(null);function wV(){return yt(CV)}Q();const TV={chart:{icon:vh,label:`chart`,defaultHeight:200},mermaid:{icon:I_,label:`diagram`,defaultHeight:150},proposal:{icon:Gv,label:`options`,defaultHeight:100},code:{icon:Ng,label:`code`,defaultHeight:80},image:{icon:Z_,label:`image`,defaultHeight:150},link:{icon:vv,label:`link`,defaultHeight:24},expand:{icon:Gg,label:`content`,defaultHeight:100},table:{icon:Nb,label:`table`,defaultHeight:150},markdown:{icon:h_,label:`content`,defaultHeight:100},"fusion-fragment":{icon:Ng,label:`fragment`,defaultHeight:150}};function EV({type:e,error:r,onRetry:i,message:a,height:s}){let c=TV[e],l=s??c.defaultHeight,u=e===`link`;if(r)return n(`div`,{className:`flex items-center gap-2 rounded border border-destructive/30 bg-destructive/5 text-destructive ${u?`inline-flex px-2 py-1 text-sm`:`p-4`}`,style:u?void 0:{minHeight:l},children:[n(`span`,{className:`text-destructive`,children:[`Failed to load `,c.label]}),i&&t(o,{variant:`unstyled`,onClick:i,className:`ms-2 rounded bg-destructive/10 px-2 py-1 text-xs hover:bg-destructive/20 transition-colors text-destructive`,children:`Retry`})]});let d=c.icon;return u?n(`span`,{className:`inline-flex items-center gap-1 text-muted animate-pulse`,children:[t(d,{className:`h-3 w-3`}),t(`span`,{children:a||`Loading ${c.label}...`})]}):n(`div`,{className:`flex flex-col items-center justify-center gap-3 rounded border border-border bg-muted/30 animate-pulse`,style:{minHeight:l},children:[t(d,{className:`h-8 w-8 text-muted`}),t(`span`,{className:`text-sm text-muted`,children:a||`Loading ${c.label}...`}),t(`div`,{className:`flex gap-1`,children:[...[,,,]].map((e,n)=>t(`div`,{className:`h-2 w-2 rounded-full bg-muted animate-bounce`,style:{animationDelay:`${n*150}ms`}},`dot-${n}`))})]})}var DV=class extends ct.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`CodeBlock rendering error (${this.props.type}):`,e,t),this.props.onError?.(e)}handleRetry=()=>{this.setState({hasError:!1,error:void 0})};render(){if(this.state.hasError){let{type:e,fallbackCode:r}=this.props;return n(`div`,{className:`space-y-2`,children:[t(EV,{type:e,error:this.state.error?.message||`Rendering failed`,onRetry:this.handleRetry}),r&&n(`details`,{className:`text-sm`,children:[t(`summary`,{className:`cursor-pointer text-muted hover:text-foreground`,children:`Show raw content`}),t(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted/50 p-2 text-xs`,children:t(`code`,{children:r})})]})]})}return this.props.children}};function OV(e,t,n){let r=t.split(`.`).pop()?.toLowerCase();if(r===`svg`)return`mockup`;if([`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(r||``))return`image`;if(r===`md`)return`markdown`;if(r===`csv`)return`table`;if(n===`json`&&typeof e==`object`&&e){let t=e;if(typeof t.$schema==`string`&&t.$schema.includes(`vega`)||t.library===`vega-lite`&&`spec`in t)return`vega-lite`;if(`template`in t&&`data`in t)return`fusion-fragment`;if(Array.isArray(e)&&e.length>0&&typeof e[0]==`object`)return`table`}return`code`}function kV(e){if(typeof e!=`object`||!e)return null;let t=e;return t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`&&t.spec!==null?t:typeof t.$schema==`string`&&t.$schema.includes(`vega`)?{library:`vega-lite`,spec:t}:null}function AV({content:e}){let{headers:r,rows:i}=U(()=>{if(!Array.isArray(e)||e.length===0)return{headers:[],rows:[]};let t=e[0];if(typeof t!=`object`||!t)return{headers:[],rows:[]};let n=Object.keys(t);return{headers:n,rows:e.map(e=>n.map(t=>{let n=e[t];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}))}},[e]);return r.length===0?t(EV,{type:`table`,error:`No table data found`}):n(`div`,{className:`overflow-x-auto`,children:[n(`table`,{className:`min-w-full text-sm border-collapse`,children:[t(`thead`,{children:t(`tr`,{className:`border-b`,children:r.map(e=>t(`th`,{className:`px-3 py-2 text-start font-medium text-muted`,children:e},e))})}),t(`tbody`,{children:i.slice(0,100).map((e,n)=>t(`tr`,{className:`border-b border-muted/20`,children:e.map((e,n)=>t(`td`,{className:`px-3 py-2`,children:e},`cell-${n}`))},`row-${n}`))})]}),i.length>100&&n(`div`,{className:`text-sm text-muted py-2`,children:[`Showing 100 of `,i.length,` rows`]})]})}function jV({content:e,path:n}){let r=n.split(`.`).pop()?.toLowerCase()||``,i=typeof e==`string`?e:JSON.stringify(e,null,2);return t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{className:`language-${r}`,children:i})})}function MV(e){return tr.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`use`],FORBID_TAGS:[`foreignObject`]})}function NV(e){return e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;if(!/viewBox/i.test(n)){let e=/\swidth\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n),t=/\sheight\s*=\s*["']?(\d+(?:\.\d+)?)/i.exec(n);e&&t&&(n+=` viewBox="0 0 ${e[1]} ${t[1]}"`)}return n=n.replace(/\swidth\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``).replace(/\sheight\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i,``),/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}function PV({content:e}){let n=U(()=>{let t=typeof e==`string`?e.trim():``;return t?NV(MV(t)):null},[e]);return n?t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}}):t(EV,{type:`expand`,error:`Empty mockup`})}function FV({content:e,path:n}){let r=typeof e==`string`?e:``,i=n.split(`/`).pop()||`Artifact image`;return t(`img`,{src:r,alt:i,className:`max-w-full h-auto rounded`,loading:`lazy`})}function IV({content:e,renderType:n,path:r,runId:i,contentType:a}){let{MarkdownRenderer:o}=SV();switch(U(()=>n===`auto`?OV(e,r,a):n,[e,r,a,n])){case`chart`:{let n=kV(e);return n?t(DV,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(LC,{spec:n,artifactRunId:i})}):t(EV,{type:`chart`,error:`Only Vega-Lite charts are supported. Recharts rendering has been retired.`})}case`vega-lite`:{let n=kV(e);return n?t(DV,{type:`chart`,fallbackCode:JSON.stringify(e,null,2),children:t(LC,{spec:n,artifactRunId:i})}):t(EV,{type:`chart`,error:`Invalid Vega-Lite specification`})}case`fusion-fragment`:{let n=e;return console.log(`[ArtifactContentRenderer] fusion-fragment:`,{hasTemplate:!!n.template,hasData:!!n.data,runId:i,hasVegaLiteChart:!!LC}),n.template&&n.data?t(DV,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t(er,{data:n.data,ChartComponent:LC,artifactRunId:i,children:t($n,{code:JSON.stringify(n.template),data:n.data})})}):t(DV,{type:`fusion-fragment`,fallbackCode:JSON.stringify(e,null,2),children:t($n,{code:JSON.stringify(e)})})}case`table`:return t(DV,{type:`table`,fallbackCode:JSON.stringify(e,null,2),children:t(AV,{content:e})});case`markdown`:{let n=typeof e==`string`?e:String(e);return t(DV,{type:`markdown`,fallbackCode:n,children:o?t(o,{artifactRunId:i,children:n}):t(`pre`,{className:`overflow-x-auto p-3 bg-muted/10 rounded text-sm`,children:t(`code`,{children:n})})})}case`mockup`:return t(DV,{type:`expand`,fallbackCode:typeof e==`string`?e:r,children:t(PV,{content:e})});case`image`:return t(DV,{type:`image`,fallbackCode:r,children:t(FV,{content:e,path:r})});default:return t(jV,{content:e,path:r})}}const LV=`Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function RV(e){let t=e.trim(),n=``,r=!1,i=!1;for(let e=0;e<t.length;e++){let a=t[e],o=e>0?t[e-1]:``;if(a===`"`&&!i&&o!==`\\`){r=!r,n+=a;continue}if(a===`'`&&!r&&o!==`\\`){i=!i,n+=a;continue}if((r||i)&&a===`\\`){let r=e;for(;t[r]===`\\`;)r++;if(t[r]===`n`){n+=`<br/>`,e=r;continue}}n+=a}return n}function zV(e){return e.replace(/<svg([^<>]*)>/i,(e,t)=>{let n=t.replace(/\swidth="[^"]*"/i,``).replace(/\sheight="[^"]*"/i,``);return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};width:100%;height:auto;display:block;max-width:100%;"`):n+=` style="width:100%;height:auto;display:block;max-width:100%;"`,/preserveAspectRatio=/i.test(n)||(n+=` preserveAspectRatio="xMidYMid meet"`),`<svg${n}>`})}let BV;function VV(){return BV||=import(`mermaid`).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`default`,securityLevel:`loose`,fontFamily:LV,suppressErrorRendering:!0,flowchart:{htmlLabels:!0,useMaxWidth:!0,nodeSpacing:40,rankSpacing:50,padding:12},sequence:{useMaxWidth:!0},themeVariables:{fontFamily:LV}}),e)),BV}function HV({code:e,className:n}){let r=W(null),[i,a]=G(null),[o,s]=G(null),c=bt().replace(/:/g,`_`);return H(()=>{let t=!1;return(async()=>{if(!e.trim()){a(null),s(null);return}try{s(null);let n=`mermaid-${c}-${Date.now()}`,r=RV(e),{svg:i}=await(await VV()).render(n,r),o=zV(i);t||a(o)}catch(e){if(!t){let t=e instanceof Error?e.message:`Failed to render mermaid diagram`;s(t),a(null)}}})(),()=>{t=!0}},[e,c]),o?null:i?t(`div`,{ref:r,className:`my-4 w-full overflow-x-auto [&_svg]:mx-auto [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-w-full ${n||``}`,dangerouslySetInnerHTML:{__html:i}}):t(`div`,{className:`my-4 p-4 bg-muted rounded-lg animate-pulse ${n||``}`,children:t(`div`,{className:`h-32 bg-muted rounded`})})}function UV(e){switch(e.split(`.`).pop()?.toLowerCase()){case`json`:return`json`;case`md`:case`txt`:case`csv`:case`yaml`:case`yml`:return`text`;case`png`:case`jpg`:case`jpeg`:case`gif`:case`webp`:case`pdf`:return`binary`;default:return`text`}}function WV({runId:e,path:t,parseJson:n=!0}){let{client:r}=q(),i=_C(),a=W(r);a.current=r;let o=W(i);o.current=i;let[s,c]=G({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l=V(async()=>{if(!e){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No run ID provided`,contentType:void 0});return}if(!t){c({data:void 0,rawContent:void 0,isLoading:!1,error:`No artifact path provided`,contentType:void 0});return}c(e=>({...e,isLoading:!0,error:void 0}));let r=a.current,i=o.current,s=UV(t);try{let a=yC(e,t,`inline`),o;o=i?await i.getOrFetch(a,async()=>(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url):(await r.files.getArtifactDownloadUrl(e,t,`inline`)).url;let l=await fetch(o);if(!l.ok)throw Error(`Failed to fetch artifact: ${l.status} ${l.statusText}`);if(s===`binary`){c({data:o,rawContent:void 0,isLoading:!1,error:void 0,contentType:s,etag:l.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`)});return}let u=await l.text(),d;if(n&&s===`json`)try{d=JSON.parse(u)}catch{d=u}else d=u;c({data:d,rawContent:u,isLoading:!1,error:void 0,contentType:s,etag:l.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`)})}catch(e){let n=e instanceof Error?e.message:`Failed to fetch artifact`;console.error(`Failed to fetch artifact content:`,t,e),c({data:void 0,rawContent:void 0,isLoading:!1,error:n,contentType:s})}},[e,t,n]);H(()=>{l()},[l]);let u=V(()=>{c({data:void 0,rawContent:void 0,isLoading:!0,error:void 0,contentType:void 0}),l()},[l]);return{data:s.data,rawContent:s.rawContent,isLoading:s.isLoading,error:s.error,contentType:s.contentType,etag:s.etag,retry:u}}function GV(e){let t=e.trim();if(t.length<2)return!0;if(!t.startsWith(`{`))return!1;try{return JSON.parse(t),!1}catch(e){let n=e instanceof Error?e.message:``,r=[`unexpected end`,`unterminated string`,`expected`,`unexpected token`],i=n.toLowerCase();if(r.some(e=>i.includes(e))){let e=0,n=0,r=!1,i=!1;for(let a of t){if(i){i=!1;continue}if(a===`\\`){i=!0;continue}if(a===`"`){r=!r;continue}r||(a===`{`?e++:a===`}`?e--:a===`[`?n++:a===`]`&&n--)}return e>0||n>0||r}return!1}}function KV(e){try{let t=e.trim(),n=t.indexOf(`{`),r=t.lastIndexOf(`}`);return n!==-1&&r>n&&(t=t.slice(n,r+1)),JSON.parse(t)}catch{return null}}function qV(e){let t=typeof e.$schema==`string`&&e.$schema.includes(`vega`),n=e.library===`vega-lite`&&`spec`in e;return t||n?`vega-lite`:null}function JV({code:e}){let{artifactRunId:n}=SV();n||console.warn(`[VegaLiteCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=U(()=>GV(e),[e]),i=U(()=>{if(r)return null;let t=KV(e);return t?{library:`vega-lite`,spec:t}:null},[e,r]);return r?t(EV,{type:`chart`,message:`Loading chart...`}):i?t(DV,{type:`chart`,fallbackCode:e,children:t(LC,{spec:i,artifactRunId:n})}):t(EV,{type:`chart`,error:`Invalid Vega-Lite specification`})}function YV({code:e}){let{artifactRunId:n}=SV();n||console.warn(`[ChartCodeBlockHandler] artifactRunId is missing from CodeBlockContext`);let r=U(()=>GV(e),[e]),i=U(()=>{if(r)return null;let t=KV(e);return!t||!qV(t)?null:t.library===`vega-lite`&&`spec`in t&&typeof t.spec==`object`?t:{library:`vega-lite`,spec:t}},[e,r]);return r?t(EV,{type:`chart`,message:`Loading chart...`}):i?t(DV,{type:`chart`,fallbackCode:e,children:t(LC,{spec:i,artifactRunId:n})}):t(EV,{type:`chart`,error:`Invalid Vega-Lite chart specification`})}function XV({code:e}){let n=e.trim();return n?t(DV,{type:`mermaid`,fallbackCode:e,children:t(HV,{code:n})}):t(EV,{type:`mermaid`,error:`Empty diagram`})}function ZV({code:e}){let n=U(()=>{let t=e.trim();return t?NV(MV(t)):null},[e]);return n?t(DV,{type:`code`,fallbackCode:e,children:t(`div`,{style:{margin:`16px 0`,width:`100%`,overflowX:`auto`},dangerouslySetInnerHTML:{__html:n}})}):t(EV,{type:`code`,error:`Empty mockup`})}function QV({code:e,language:n}){let{artifactRunId:r}=SV(),i=e.trim(),a=U(()=>{if(!n?.includes(`:`))return`auto`;let e=n.split(`:`)[1];return[`chart`,`vega-lite`,`table`,`markdown`,`fusion-fragment`,`mockup`,`code`,`image`,`auto`].includes(e)?e:`auto`},[n]),{data:o,isLoading:s,error:c,contentType:l}=WV({runId:r,path:i});return r?s?t(EV,{type:`expand`,message:`Loading ${i}...`}):c?t(EV,{type:`expand`,error:`Failed to load artifact: ${c}`}):o===void 0?t(EV,{type:`expand`,error:`No content found in artifact`}):t(IV,{content:o,renderType:a,path:i,runId:r,contentType:l}):t(EV,{type:`expand`,error:`No artifact run ID available`})}function $V(e){return e?.startsWith(`expand`)??!1}function eH(){return{chart:YV,"vega-lite":JV,vegalite:JV,mermaid:XV,mockup:ZV,svg:ZV}}const tH=/* @__PURE__ */ new Set([`store`,`document`,`collection`,`interaction`,`prompt`,`agent`,`workflow`,`process`,`run`]);function nH(e){return e.trim().replace(/^\/+/,``)}function rH(e){if(e.startsWith(`artifact:`))return{scheme:`artifact`,path:e.slice(9).trim()};if(e.startsWith(`image:`))return{scheme:`image`,path:e.slice(6).trim()};let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);if(tH.has(n))return{scheme:n,path:nH(e.slice(t+1))}}return{scheme:`standard`,path:e}}function iH({rawUrl:e,artifactRunId:t,disposition:n=`inline`}){let{client:r}=q(),i=_C(),a=W(r);a.current=r;let o=W(i);o.current=i;let{scheme:s,path:c}=rH(e),[l,u]=G(()=>{if(s===`standard`)return{url:e,isLoading:!1,error:void 0};if(i&&(s===`artifact`||s===`image`)){let e;e=s===`artifact`&&t&&!vC(c)?yC(t,c,n):bC(c);let r=i.getUrl(e);if(r)return{url:r,isLoading:!1,error:void 0}}return{url:void 0,isLoading:!0,error:void 0}}),d=V(async()=>{if(s===`standard`)return;if(s!==`artifact`&&s!==`image`){u({url:void 0,isLoading:!1,error:`Unknown scheme: ${s}`});return}u(e=>({...e,isLoading:!0,error:void 0}));let e=a.current,r=o.current;try{let i;if(s===`artifact`){if(t&&!vC(c)){let a=yC(t,c,n);i=r?await r.getOrFetch(a,async()=>(await e.files.getArtifactDownloadUrl(t,c,n)).url):(await e.files.getArtifactDownloadUrl(t,c,n)).url}else{let t=bC(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}}else{let t=bC(c);i=r?await r.getOrFetch(t,async()=>(await e.files.getDownloadUrl(c)).url):(await e.files.getDownloadUrl(c)).url}u({url:i,isLoading:!1,error:void 0})}catch(e){let t=e instanceof Error?e.message:`Failed to resolve URL`;console.error(`Failed to resolve URL:`,c,e),u({url:void 0,isLoading:!1,error:t})}},[s,c,t,n]);H(()=>{if(l.url&&!l.error)return;let e=!1;return e||(async()=>{await d()})(),()=>{e=!0}},[d,l.url,l.error]);let f=V(()=>{u({url:void 0,isLoading:!0,error:void 0}),d()},[d]);return{url:l.url,isLoading:l.isLoading,error:l.error,scheme:s,retry:f}}function aH({src:e,alt:r,caption:i,className:a,artifactRunId:o}){let s=e||``,{scheme:c}=rH(s);return c===`standard`?n(`figure`,{className:`my-4`,children:[t(`img`,{src:e,alt:r,className:a}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):t(oH,{rawSrc:s,alt:r,caption:i,artifactRunId:o,className:a})}function oH({rawSrc:e,alt:r,caption:i,artifactRunId:a,className:o}){let{url:s,isLoading:c,error:l,retry:u}=iH({rawUrl:e,artifactRunId:a,disposition:`inline`});return c?t(EV,{type:`image`,message:r?`Loading ${r}...`:void 0}):l?t(EV,{type:`image`,error:l,onRetry:u}):s?n(`figure`,{className:`my-4`,children:[t(`img`,{src:s,alt:r,className:o}),t(`figcaption`,{className:`mt-2 text-sm text-muted text-center italic`,children:i})]}):null}function sH({node:e,src:n,alt:r,className:i,artifactRunId:a,ExistingImg:o,...s}){let c=n||``,{scheme:l}=rH(c);return l===`standard`?typeof o==`function`?t(o,{node:e,src:n,alt:r,...s}):t(`img`,{src:n,alt:r,className:i,...s}):t(cH,{rawSrc:c,alt:r,artifactRunId:a,className:i,rest:s})}function cH({rawSrc:e,alt:n,artifactRunId:r,className:i,rest:a}){let{url:o,isLoading:s,error:c,retry:l}=iH({rawUrl:e,artifactRunId:r,disposition:`inline`});return s?t(EV,{type:`image`,message:n?`Loading ${n}...`:void 0}):c?t(EV,{type:`image`,error:c,onRetry:l}):o?t(`img`,{src:o,alt:n,className:i,...a}):null}const lH=pt(()=>({kind:`none`}));lH.Provider;function uH(){return yt(lH)}const dH={store:`document`,document:`document`,collection:`collection`,interaction:`interaction`,prompt:`prompt`,agent:`agent`,workflow:`workflow`,process:`process`,run:`interaction_run`};function fH(e){let t=e.indexOf(`:`);if(t<=0)return;let n=e.slice(0,t);if(!Object.hasOwn(dH,n))return;let r=e.slice(t+1).trim().replace(/^\/+/,``);if(r)return{type:dH[n],id:r}}function pH({node:e,href:n,children:r,className:i,artifactRunId:a,onArtifactOpen:o,ExistingLink:s,...c}){let l=n||``,u=fH(l);if(u)return t(mH,{resource:u,rawHref:l,artifactRunId:a,className:i,ExistingLink:s,rest:c,children:r});let{scheme:d,path:f}=rH(l);return d===`standard`?typeof s==`function`?t(s,{node:e,href:n,className:i,...c,children:r}):t(`a`,{href:n,...c,className:i,target:`_blank`,rel:`noopener noreferrer`,children:r}):t(hH,{rawHref:l,artifactRunId:a,artifactPath:d===`artifact`?f:void 0,onArtifactOpen:o,className:i,rest:c,children:r})}function mH({resource:e,rawHref:n,artifactRunId:r,className:i,children:a,ExistingLink:s,rest:c}){let l=uH()(e,{workflowRunId:r,source:`markdown`,rawHref:n});return l.kind===`navigate`?typeof s==`function`?t(s,{href:l.href,className:i,...c,children:a}):t(`a`,{href:l.href,...c,className:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):l.kind===`activate`?t(o,{variant:`link`,size:`none`,className:i,onClick:l.onActivate,children:a}):t(`span`,{className:i,children:a})}function hH({rawHref:e,artifactRunId:n,artifactPath:r,onArtifactOpen:i,className:a,children:o,rest:s}){let{url:c,isLoading:l,error:u,retry:d}=iH({rawUrl:e,artifactRunId:n,disposition:`attachment`});return l?t(`span`,{className:`inline-flex items-center gap-1 text-muted`,children:t(EV,{type:`link`})}):u?t(`span`,{className:`inline-flex items-center gap-1`,children:t(EV,{type:`link`,error:u,onRetry:d})}):t(`a`,{href:c||`#`,...s,className:a,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{r&&/\.md$/i.test(r)&&i&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&(e.preventDefault(),i(r))},children:o})}const gH=[`artifact:`,`image:`,`store:`,`document://`,`collection:`,`interaction:`,`prompt:`,`agent:`,`workflow:`,`process:`,`run:`],_H=/(!?\[[^[\]\n]*\]\()((?:artifact:|image:|store:|document:\/\/|collection:|interaction:|prompt:|agent:|workflow:|process:|run:)[^)[\n]+)(\))/g,vH=/`[^`\n]*`/g,yH=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,bH=/\s+("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\([^)]*\))\s*$/;function xH(e){return gH.some(t=>e.startsWith(t))}function SH(e){let t=e.trim();if(t.startsWith(`<`)){let n=t.indexOf(`>`);if(n>0&&xH(t.slice(1,n).trim()))return e}let n=t.match(bH)?.index??-1,r=(n>=0?t.slice(0,n):t).trim(),i=n>=0?t.slice(n):``;return xH(r)?`<${r}>${i}`:e}function CH(e){return e.replace(_H,(e,t,n,r)=>`${t}${SH(n)}${r}`)}function wH(e){let t=``,n=0;for(let r of e.matchAll(vH))t+=CH(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=CH(e.slice(n)),t}function TH(e){if(!e||!gH.some(t=>e.includes(t)))return e;let t=``,n=0;for(let r of e.matchAll(yH))t+=wH(e.slice(n,r.index)),t+=r[0],n=r.index+r[0].length;return t+=wH(e.slice(n)),t}const EH=/^([ \t]*):::([^\n]*?):::[ \t]*$/gm,DH=/^\w+/;function OH(e){return e?.includes(`:::`)?e.replace(EH,(e,t,n)=>{let r=n.trim(),i=DH.exec(r);if(!i)return e;let a=i[0],o=r.slice(a.length).trim();return o?`${t}:::${a}\n${t}${o}\n${t}:::`:`${t}::${a}`}):e}const kH=/(^|\n)(`{3,}|~{3,})[^\n]*\n[\s\S]*?\n\2(?=\n|$)/g,AH=/`[^`\n]*`/g,jH=/\\\$/g,MH=/\\[^\s]/,NH=/[{}]/,PH=/[_^][\w{]/,FH=/^[a-zA-Z]$/,IH=/^[a-zA-Z]\s*=/,LH=/^\s/,RH=/\s$/,zH=/[+*/-]$/,BH=/\^[+-]$/,VH=/^\d[\d,]*(?:\.\d+)?[kKmMbB]?[)\]*_,;:.!?]+\s+[a-zA-Z]{2,}(?!\w)/,HH=/^\d/;function UH(e){return MH.test(e)||NH.test(e)||PH.test(e)||FH.test(e)||IH.test(e)}function WH(e){return LH.test(e)||RH.test(e)||zH.test(e)&&!BH.test(e)?!0:GH(e)}function GH(e){return VH.test(e)?!0:HH.test(e)&&KH(e)}function KH(e){let t=0;for(let n of e)if(n===`(`||n===`[`?t++:(n===`)`||n===`]`)&&t--,t<0)return!0;return t!==0}function qH(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]===`$`&&!(n>0&&e[n-1]===`\\`)){if(n+1<e.length&&e[n+1]===`$`){n++;continue}n>0&&e[n-1]===`$`&&(n<2||e[n-2]!==`\\`)||t.push(n)}return t}function JH(e,t,n){let r=e.slice(t+1,n);return r.length===0||r.includes(`
997
- `)?null:r}const YH={currency:`\\$`,escapedInLatex:`\\text{\\textdollar}`};function XH(e,t){let n=qH(e);if(n.length<2)return e;let r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=Array(n.length-1);for(let t=0;t<n.length-1;t++)a[t]=JH(e,n[t],n[t+1]);let o=[];for(let e=0;e<n.length-1;e++){if(r.has(e))continue;let t=a[e];t!==null&&UH(t)&&!GH(t)&&(r.add(e),r.add(e+1),o.push([n[e],n[e+1]]))}let s=0;for(;s<n.length;){if(r.has(s)){s++;continue}let e=s+1;for(;e<n.length&&r.has(e);)e++;if(e>=n.length)break;if(e>s+1){i.add(n[s]),s++;continue}let t=a[s];if(t===null){s++;continue}WH(t)&&(i.add(n[s]),i.add(n[e])),r.add(s),r.add(e),s=e+1}for(let e=0;e<n.length;e++)r.has(e)||e+1<n.length&&r.has(e+1)&&i.add(n[e]);if(i.size===0&&o.length===0)return e;let c=[],l=0,u=Array.from(i).sort((e,t)=>e-t),d=0,f=0;for(;d<u.length||f<o.length;){let n=d<u.length?u[d]:1/0;if(n<(f<o.length?o[f][0]:1/0))n>l&&c.push(e.slice(l,n)),c.push(t.currency),l=n+1,d++;else{let[n,r]=o[f];n>l&&c.push(e.slice(l,n));let i=e.slice(n,r+1);for(c.push(i.replace(jH,t.escapedInLatex)),l=r+1;d<u.length&&u[d]<=r;)d++;f++}}return l<e.length&&c.push(e.slice(l)),c.join(``)}function ZH(e,t){let n=[],r=0;for(let i of e.matchAll(AH))n.push(XH(e.slice(r,i.index),t)),n.push(i[0]),r=i.index+i[0].length;return n.push(XH(e.slice(r),t)),n.join(``)}function QH(e,t){let n=[],r=0;for(let i of e.matchAll(kH))n.push(ZH(e.slice(r,i.index),t)),n.push(i[0]),r=i.index+i[0].length;return n.push(ZH(e.slice(r),t)),n.join(``)}function $H(e){return e?.includes(`$`)?QH(e,YH):e}const eU=[[8352,8384],[57344,63743]];function tU(e){for(let[t,n]of eU)for(let r=t;r<=n;r++){let t=String.fromCharCode(r);if(!e.includes(t))return t}}function nU(e){if(!e?.includes(`$`))return{markdown:e};let t=tU(e);return t?{markdown:QH(e,{currency:t,escapedInLatex:`\\${t}`}),mask:t}:{markdown:e}}const rU={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},iU={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function aU(){return(e,t)=>{YP(e,(e,n,r)=>{if(e.type===`textDirective`){let i=e.position?.start.offset,a=e.position?.end.offset;if(r&&n!==void 0&&i!==void 0&&a!==void 0){let o={type:`text`,value:t.toString().slice(i,a),position:e.position};r.children[n]=o}return KP}if(e.type!==`containerDirective`&&e.type!==`leafDirective`)return;let i=e;i.data||={};let a=i.data,o=i.attributes||{},s=i.name;if(s===`pagebreak`){a.hName=`hr`,a.hProperties={className:`md-pagebreak`};return}if(s===`columns`){a.hName=`div`,a.hProperties={className:`md-columns`};return}if(s===`column`){a.hName=`div`;let e={className:`md-column`};o.width&&(e.style=`flex-basis:${o.width};flex-grow:0;flex-shrink:0`),a.hProperties=e;return}if(s in rU){a.hName=`div`,a.hProperties={className:`md-callout ${rU[s]}`,"data-callout-type":s};let e=iU[s];if(e&&i.children){let t={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};i.children.unshift(t)}return}a.hName=`div`,a.hProperties={className:`md-${s}`,...Object.fromEntries(Object.entries(o).filter(([e])=>e!==`class`))},o.class&&(a.hProperties.className+=` ${o.class}`)})}}const oU=[`value`,`url`,`title`,`alt`];function sU({mask:e}){let t=`\\${e}`;return n=>{YP(n,n=>{let r=n;if(r.type===`inlineMath`){if(typeof r.value!=`string`)return;let e=r.value.split(t).join(`\\text{\\textdollar}`);r.value=e;for(let t of r.data?.hChildren??[])t.type===`text`&&(t.value=e);return}for(let t of oU){let n=r[t];typeof n==`string`&&(r[t]=n.split(e).join(`$`))}})}}const cU=/(?:^|[^\\])\$/,lU=[];let uU,dU;function fU(){return dU||=import(`rehype-katex`).then(({default:e})=>(uU=e,e)),dU}function pU(e){let t=ct.useMemo(()=>cU.test(e),[e]),[n,r]=ct.useState(()=>uU);return ct.useEffect(()=>{if(!t||n)return;let e=!1;return fU().then(t=>{e||r(()=>t)}).catch(e=>{console.error(`Failed to load KaTeX; math will render unstyled`,e)}),()=>{e=!0}},[t,n]),ct.useMemo(()=>n?[n]:lU,[n])}const mU=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`,`interaction:`,`prompt:`,`agent:`,`workflow:`,`process:`,`run:`];function hU(e){return mU.some(t=>e.startsWith(t))?e:ZF(e)}function gU(){return e=>{YP(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[KP,t]})}}const _U=eH();function vU({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,onArtifactOpen:o,className:s,codeClassName:c,inlineCodeClassName:l,linkClassName:u,imageClassName:d,onProposalSelect:f,onProposalSubmit:p,preserveSourcePositions:m=!1}){let h=wV(),{markdown:g,mask:_}=ct.useMemo(()=>m?nU(e):{markdown:OH(TH($H(e)))},[e,m]),v=ct.useMemo(()=>{let e=[GB,qL,aU,JB,jI,yV,cV,..._?[[sU,{mask:_}]]:[],...r];return i&&e.push(gU),e},[r,i,_]),y=pU(g),b=ct.useMemo(()=>({handlers:{...kI}}),[]),x=ct.useMemo(()=>{let e=n||{},r=e.code,i=e.a,s=e.img,f=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),s=!o,u=o?o[1]:``;if(!s&&u){if(h){let e=h.getComponent(u);if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}if($V(u)){let e=String(i||``).trim();return t(QV,{code:e,language:u})}let e=_U[u];if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:s?`px-1.5 py-0.5 rounded ${l||``}`:` ${c||``}`,children:i})},p=e=>{let{node:n,href:r,children:s,...c}=e;return t(pH,{node:n,href:r,className:u,artifactRunId:a,onArtifactOpen:o,ExistingLink:typeof i==`function`?i:void 0,...c,children:s})},m=e=>{let{node:n,src:r,alt:i,title:o,...c}=e;return o?t(aH,{src:r,alt:i,caption:o,className:d,artifactRunId:a}):t(sH,{node:n,src:r,alt:i,className:d,artifactRunId:a,ExistingImg:typeof s==`function`?s:void 0,...c})};return{...e,code:f,a:p,img:m}},[n,a,o,h,c,l,u,d]),S=t(xV,{artifactRunId:a,onProposalSelect:f,onProposalSubmit:p,MarkdownRenderer:vU,children:t(qF,{remarkPlugins:v,rehypePlugins:y,remarkRehypeOptions:b,components:x,urlTransform:hU,children:g})});return s?t(`div`,{className:`md-content ${s}`,children:S}):t(`div`,{className:`md-content`,children:S})}Q();function yU(e){return Array.isArray(e)&&e.every(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let{id:t,label:n,description:r}=e;return typeof t==`string`&&typeof n==`string`&&(r==null||typeof r==`string`)})}const bU={default:{border:`border-s-attention`,bg:`bg-attention`,icon:`text-attention`},warning:{border:`border-s-destructive`,bg:`bg-destructive`,icon:`text-destructive`},info:{border:`border-s-info`,bg:`bg-info`,icon:`text-info`},success:{border:`border-s-success`,bg:`bg-success`,icon:`text-success`}},xU={default:fg,warning:eg,info:Gv,success:rg},SU=`max-h-80 overflow-y-auto overscroll-contain pe-2`;function CU({question:r,description:i,options:a,onSelect:s,onMultiSelect:c,onSubmit:l,allowFreeResponse:u=!1,multiSelect:d=!1,placeholder:f,submitLabel:p,isLoading:m=!1,icon:h,variant:g=`default`,hideIcon:_=!1,hideBorder:v=!1,compact:y=!1,answered:b=!1,headerAction:x,responseControlsId:S,responseControlsHidden:C=!1,className:w,cardClassName:T,headerClassName:E,iconClassName:D,questionClassName:O,descriptionClassName:k,optionsClassName:A,buttonClassName:j,inputContainerClassName:M,inputClassName:ee,submitButtonClassName:N}){let{t:P}=K(),F=f??P(`agent.typeYourResponse`),te=p??P(`agent.send`),[I,ne]=ct.useState(``),[L,R]=ct.useState(/* @__PURE__ */ new Set),re=ct.useRef(null),ie=bU[g],ae=xU[g],oe=yU(a),se=oe?a:[],ce=ct.useRef(!1);ct.useEffect(()=>{a===void 0||oe||ce.current||(ce.current=!0,qn.logger.warn(`AskUserWidget received invalid options; rendering without options`,{vertesia:{component:`AskUserWidget`,received_type:typeof a}}))},[a,oe]);let le=e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ue=()=>{L.size>0&&c&&(c(Array.from(L)),R(/* @__PURE__ */ new Set))},de=()=>{I.trim()&&l&&(l(I.trim()),ne(``))},fe=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),de())},pe=v?``:`border-s-4 ${ie.border}`;if(y){let a=h||t(ae,{className:`size-4`}),c=t(`div`,{className:z(`agent-ask-question text-sm leading-6 text-foreground/85`,O),children:t(vU,{children:r})});return b?t(`div`,{className:z(`my-1.5 font-sans`,w),children:n(`div`,{className:SU,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,k),children:i})]})}):t(`div`,{className:z(`my-2 font-sans`,w),children:n(`div`,{className:z(`rounded-lg border border-border bg-background/60 shadow-none`,T),children:[t(`div`,{className:z(`px-3 py-2`,E),children:n(`div`,{className:`flex items-start gap-2.5`,children:[!_&&t(`div`,{className:z(`mt-1 flex-shrink-0 text-attention`,D),children:a}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:SU,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,k),children:i})]})}),x]})}),n(`div`,{id:S,hidden:C,children:[se.length>0&&t(`div`,{className:z(`flex flex-col gap-1.5 px-3 pb-3 pt-0`,A),children:d?n(e,{children:[se.map(e=>{let r=L.has(e.id);return n(`label`,{className:z(`flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-start transition-colors`,r?`border-info/60 bg-info/10`:`border-border bg-background/70 hover:bg-mixer-muted/15`,m&&`cursor-not-allowed opacity-50`,j),children:[t(`input`,{type:`checkbox`,checked:r,onChange:()=>le(e.id),disabled:m,className:`mt-1 size-4 rounded border-border bg-background text-info focus:ring-info`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id)}),t(`div`,{className:`pt-1`,children:n(o,{size:`sm`,onClick:ue,disabled:m||L.size===0,className:`inline-flex items-center gap-2`,children:[t(rb,{className:`size-4`}),L.size>0?P(`agent.submitSelectionCount`,{count:L.size}):P(`agent.submitSelection`)]})})]}):se.map(e=>n(`button`,{type:`button`,onClick:()=>s?.(e.id),disabled:m,className:z(`flex w-full cursor-pointer items-start gap-2.5 rounded-md border border-border bg-background/70 px-3 py-2 text-start transition-colors`,`hover:bg-mixer-muted/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,m&&`cursor-not-allowed opacity-50`,j),children:[t(`span`,{className:`mt-1 size-4 flex-shrink-0 rounded-full border border-border`,"aria-hidden":`true`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id))}),u&&t(`div`,{className:z(`px-3 pb-3 pt-0`,M),children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:re,type:`text`,value:I,onChange:e=>ne(e.target.value),onKeyDown:fe,placeholder:F,disabled:m,className:z(`min-w-0 flex-1 rounded-md border border-border bg-background/70 px-3 py-2 text-sm text-foreground focus:border-transparent focus:ring-2 focus:ring-ring`,ee)}),t(o,{size:`sm`,onClick:de,disabled:m||!I.trim(),className:N,children:m?`...`:te})]})})]})]})})}return t(`div`,{className:`my-4 font-sans ${w||``}`,children:n(`div`,{className:`${pe} ${ie.bg} rounded-e-lg shadow-sm ${T||``}`,children:[t(`div`,{className:`px-4 py-3 ${E||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[!_&&t(`div`,{className:`flex-shrink-0 mt-0.5 ${ie.icon} ${D||``}`,children:h||t(ae,{className:`size-5`})}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:SU,children:[t(`div`,{className:`agent-ask-question vprose prose prose-sm max-w-none text-foreground ${O||``}`,children:t(vU,{children:r})}),i&&t(`p`,{className:`mt-1 text-sm text-muted ${k||``}`,children:i})]})}),x]})}),n(`div`,{id:S,hidden:C,children:[se.length>0&&t(`div`,{className:`px-4 pb-3 pt-1 ${A||``}`,children:d?n(`div`,{className:`space-y-2`,children:[se.map(e=>n(`label`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors
998
- ${L.has(e.id)?`bg-info border border-info`:`bg-card text-card-foreground border border-border hover:bg-muted`}
999
- ${m?`opacity-50 cursor-not-allowed`:``}`,children:[t(`input`,{type:`checkbox`,checked:L.has(e.id),onChange:()=>le(e.id),disabled:m,className:`mt-0.5 w-4 h-4 rounded border-border text-info focus:ring-info bg-background`}),n(`div`,{className:`flex-1 overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground break-words`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]},e.id)),t(`div`,{className:`pt-2`,children:n(o,{size:`sm`,onClick:ue,disabled:m||L.size===0,className:`flex items-center gap-2`,children:[t(rb,{className:`size-4`}),L.size>0?P(`agent.submitSelectionCount`,{count:L.size}):P(`agent.submitSelection`)]})})]}):t(`div`,{className:`flex flex-col gap-2 w-full`,children:se.map(e=>t(o,{variant:`unstyled`,onClick:()=>s?.(e.id),disabled:m,className:`w-full h-auto whitespace-normal text-start px-4 py-3 rounded-lg border border-border
997
+ `)?null:r}const YH={currency:`\\$`,escapedInLatex:`\\text{\\textdollar}`};function XH(e,t){let n=qH(e);if(n.length<2)return e;let r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=Array(n.length-1);for(let t=0;t<n.length-1;t++)a[t]=JH(e,n[t],n[t+1]);let o=[];for(let e=0;e<n.length-1;e++){if(r.has(e))continue;let t=a[e];t!==null&&UH(t)&&!GH(t)&&(r.add(e),r.add(e+1),o.push([n[e],n[e+1]]))}let s=0;for(;s<n.length;){if(r.has(s)){s++;continue}let e=s+1;for(;e<n.length&&r.has(e);)e++;if(e>=n.length)break;if(e>s+1){i.add(n[s]),s++;continue}let t=a[s];if(t===null){s++;continue}WH(t)&&(i.add(n[s]),i.add(n[e])),r.add(s),r.add(e),s=e+1}for(let e=0;e<n.length;e++)r.has(e)||e+1<n.length&&r.has(e+1)&&i.add(n[e]);if(i.size===0&&o.length===0)return e;let c=[],l=0,u=Array.from(i).sort((e,t)=>e-t),d=0,f=0;for(;d<u.length||f<o.length;){let n=d<u.length?u[d]:1/0;if(n<(f<o.length?o[f][0]:1/0))n>l&&c.push(e.slice(l,n)),c.push(t.currency),l=n+1,d++;else{let[n,r]=o[f];n>l&&c.push(e.slice(l,n));let i=e.slice(n,r+1);for(c.push(i.replace(jH,t.escapedInLatex)),l=r+1;d<u.length&&u[d]<=r;)d++;f++}}return l<e.length&&c.push(e.slice(l)),c.join(``)}function ZH(e,t){let n=[],r=0;for(let i of e.matchAll(AH))n.push(XH(e.slice(r,i.index),t)),n.push(i[0]),r=i.index+i[0].length;return n.push(XH(e.slice(r),t)),n.join(``)}function QH(e,t){let n=[],r=0;for(let i of e.matchAll(kH))n.push(ZH(e.slice(r,i.index),t)),n.push(i[0]),r=i.index+i[0].length;return n.push(ZH(e.slice(r),t)),n.join(``)}function $H(e){return e?.includes(`$`)?QH(e,YH):e}const eU=[[8352,8384],[57344,63743]];function tU(e){for(let[t,n]of eU)for(let r=t;r<=n;r++){let t=String.fromCharCode(r);if(!e.includes(t))return t}}function nU(e){if(!e?.includes(`$`))return{markdown:e};let t=tU(e);return t?{markdown:QH(e,{currency:t,escapedInLatex:`\\${t}`}),mask:t}:{markdown:e}}const rU={note:`md-callout-info`,tip:`md-callout-info`,warning:`md-callout-attention`,important:`md-callout-attention`,caution:`md-callout-destructive`},iU={note:`Note`,tip:`Tip`,warning:`Warning`,important:`Important`,caution:`Caution`};function aU(){return(e,t)=>{YP(e,(e,n,r)=>{if(e.type===`textDirective`){let i=e.position?.start.offset,a=e.position?.end.offset;if(r&&n!==void 0&&i!==void 0&&a!==void 0){let o={type:`text`,value:t.toString().slice(i,a),position:e.position};r.children[n]=o}return KP}if(e.type!==`containerDirective`&&e.type!==`leafDirective`)return;let i=e;i.data||={};let a=i.data,o=i.attributes||{},s=i.name;if(s===`pagebreak`){a.hName=`hr`,a.hProperties={className:`md-pagebreak`};return}if(s===`columns`){a.hName=`div`,a.hProperties={className:`md-columns`};return}if(s===`column`){a.hName=`div`;let e={className:`md-column`};o.width&&(e.style=`flex-basis:${o.width};flex-grow:0;flex-shrink:0`),a.hProperties=e;return}if(s in rU){a.hName=`div`,a.hProperties={className:`md-callout ${rU[s]}`,"data-callout-type":s};let e=iU[s];if(e&&i.children){let t={type:`paragraph`,data:{hName:`p`,hProperties:{className:`md-callout-title`}},children:[{type:`text`,value:e}]};i.children.unshift(t)}return}a.hName=`div`,a.hProperties={className:`md-${s}`,...Object.fromEntries(Object.entries(o).filter(([e])=>e!==`class`))},o.class&&(a.hProperties.className+=` ${o.class}`)})}}const oU=[`value`,`url`,`title`,`alt`];function sU({mask:e}){let t=`\\${e}`;return n=>{YP(n,n=>{let r=n;if(r.type===`inlineMath`){if(typeof r.value!=`string`)return;let e=r.value.split(t).join(`\\text{\\textdollar}`);r.value=e;for(let t of r.data?.hChildren??[])t.type===`text`&&(t.value=e);return}for(let t of oU){let n=r[t];typeof n==`string`&&(r[t]=n.split(e).join(`$`))}})}}const cU=/(?:^|[^\\])\$/,lU=[];let uU,dU;function fU(){return dU||=import(`rehype-katex`).then(({default:e})=>(uU=e,e)),dU}function pU(e){let t=ct.useMemo(()=>cU.test(e),[e]),[n,r]=ct.useState(()=>uU);return ct.useEffect(()=>{if(!t||n)return;let e=!1;return fU().then(t=>{e||r(()=>t)}).catch(e=>{console.error(`Failed to load KaTeX; math will render unstyled`,e)}),()=>{e=!0}},[t,n]),ct.useMemo(()=>n?[n]:lU,[n])}const mU=[`artifact:`,`image:`,`store:`,`document:`,`document://`,`collection:`,`interaction:`,`prompt:`,`agent:`,`workflow:`,`process:`,`run:`];function hU(e){return mU.some(t=>e.startsWith(t))?e:ZF(e)}function gU(){return e=>{YP(e,`html`,(e,t,n)=>{let r=e,i=n;if(typeof r.value==`string`&&/<!--[\s\S]*?-->/.test(r.value)&&i?.children&&typeof t==`number`)return i.children.splice(t,1),[KP,t]})}}const _U=eH();function vU({children:e,components:n,remarkPlugins:r=[],removeComments:i=!0,artifactRunId:a,onArtifactOpen:o,className:s,codeClassName:c,inlineCodeClassName:l,linkClassName:u,imageClassName:d,onProposalSelect:f,onProposalSubmit:p,preserveSourcePositions:m=!1}){let h=wV(),{markdown:g,mask:_}=ct.useMemo(()=>m?nU(e):{markdown:OH(TH($H(e)))},[e,m]),v=ct.useMemo(()=>{let e=[GB,qL,aU,JB,jI,yV,cV,..._?[[sU,{mask:_}]]:[],...r];return i&&e.push(gU),e},[r,i,_]),y=pU(g),b=ct.useMemo(()=>({handlers:{...kI}}),[]),x=ct.useMemo(()=>{let e=n||{},r=e.code,i=e.a,s=e.img,f=({node:e,className:n,children:i,...a})=>{let o=/language-([\w-]+)/.exec(n||``),s=!o,u=o?o[1]:``;if(!s&&u){if(h){let e=h.getComponent(u);if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}if($V(u)){let e=String(i||``).trim();return t(QV,{code:e,language:u})}let e=_U[u];if(e){let n=String(i||``).trim();return t(e,{code:n,language:u})}}return typeof r==`function`?t(r,{node:e,className:n,...a,children:i}):t(`code`,{...a,className:s?`px-1.5 py-0.5 rounded ${l||``}`:` ${c||``}`,children:i})},p=e=>{let{node:n,href:r,children:s,...c}=e;return t(pH,{node:n,href:r,className:u,artifactRunId:a,onArtifactOpen:o,ExistingLink:typeof i==`function`?i:void 0,...c,children:s})},m=e=>{let{node:n,src:r,alt:i,title:o,...c}=e;return o?t(aH,{src:r,alt:i,caption:o,className:d,artifactRunId:a}):t(sH,{node:n,src:r,alt:i,className:d,artifactRunId:a,ExistingImg:typeof s==`function`?s:void 0,...c})};return{...e,code:f,a:p,img:m}},[n,a,o,h,c,l,u,d]),S=t(xV,{artifactRunId:a,onProposalSelect:f,onProposalSubmit:p,MarkdownRenderer:vU,children:t(qF,{remarkPlugins:v,rehypePlugins:y,remarkRehypeOptions:b,components:x,urlTransform:hU,children:g})});return s?t(`div`,{className:`md-content ${s}`,children:S}):t(`div`,{className:`md-content`,children:S})}Q();function yU(e){return Array.isArray(e)&&e.every(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let{id:t,label:n,description:r}=e;return typeof t==`string`&&typeof n==`string`&&(r==null||typeof r==`string`)})}const bU={default:{border:`border-s-attention`,bg:`bg-attention`,icon:`text-attention`},warning:{border:`border-s-destructive`,bg:`bg-destructive`,icon:`text-destructive`},info:{border:`border-s-info`,bg:`bg-info`,icon:`text-info`},success:{border:`border-s-success`,bg:`bg-success`,icon:`text-success`}},xU={default:fg,warning:eg,info:Gv,success:rg},SU=`max-h-80 overflow-y-auto overscroll-contain pe-2`;function CU({question:r,description:i,options:a,onSelect:s,onMultiSelect:c,onSubmit:l,allowFreeResponse:u=!1,multiSelect:d=!1,placeholder:f,submitLabel:p,isLoading:m=!1,icon:h,variant:g=`default`,hideIcon:_=!1,hideBorder:v=!1,compact:y=!1,answered:b=!1,headerAction:x,responseControlsId:S,responseControlsHidden:C=!1,className:w,cardClassName:T,headerClassName:E,iconClassName:D,questionClassName:O,descriptionClassName:k,optionsClassName:A,buttonClassName:j,inputContainerClassName:M,inputClassName:ee,submitButtonClassName:N}){let{t:P}=K(),F=p??P(`agent.send`),[te,I]=ct.useState(``),[ne,L]=ct.useState(/* @__PURE__ */ new Set),R=ct.useRef(null),re=bU[g],ie=xU[g],ae=yU(a),oe=ae?a:[],se=f??(oe.length>0?P(`agent.typeDifferentResponse`):P(`agent.typeYourResponse`)),ce=ct.useRef(!1);ct.useEffect(()=>{a===void 0||ae||ce.current||(ce.current=!0,qn.logger.warn(`AskUserWidget received invalid options; rendering without options`,{vertesia:{component:`AskUserWidget`,received_type:typeof a}}))},[a,ae]);let le=e=>{L(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ue=()=>{ne.size>0&&c&&(c(Array.from(ne)),L(/* @__PURE__ */ new Set))},de=()=>{te.trim()&&l&&(l(te.trim()),I(``))},fe=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),de())},pe=v?``:`border-s-4 ${re.border}`;if(y){let a=h||t(ie,{className:`size-4`}),c=t(`div`,{className:z(`agent-ask-question text-sm leading-6 text-foreground/85`,O),children:t(vU,{children:r})});return b?t(`div`,{className:z(`my-1.5 font-sans`,w),children:n(`div`,{className:SU,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,k),children:i})]})}):t(`div`,{className:z(`my-2 font-sans`,w),children:n(`div`,{className:z(`rounded-lg border border-border bg-background/60 shadow-none`,T),children:[t(`div`,{className:z(`px-3 py-2`,E),children:n(`div`,{className:`flex items-start gap-2.5`,children:[!_&&t(`div`,{className:z(`mt-1 flex-shrink-0 text-attention`,D),children:a}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:SU,children:[c,i&&t(`p`,{className:z(`mt-1 text-xs leading-5 text-muted`,k),children:i})]})}),x]})}),n(`div`,{id:S,hidden:C,children:[oe.length>0&&t(`div`,{className:z(`flex flex-col gap-1.5 px-3 pb-3 pt-0`,A),children:d?n(e,{children:[oe.map(e=>{let r=ne.has(e.id);return n(`label`,{className:z(`flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-start transition-colors`,r?`border-info/60 bg-info/10`:`border-border bg-background/70 hover:bg-mixer-muted/15`,m&&`cursor-not-allowed opacity-50`,j),children:[t(`input`,{type:`checkbox`,checked:r,onChange:()=>le(e.id),disabled:m,className:`mt-1 size-4 rounded border-border bg-background text-info focus:ring-info`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id)}),t(`div`,{className:`pt-1`,children:n(o,{size:`sm`,onClick:ue,disabled:m||ne.size===0,className:`inline-flex items-center gap-2`,children:[t(rb,{className:`size-4`}),ne.size>0?P(`agent.submitSelectionCount`,{count:ne.size}):P(`agent.submitSelection`)]})})]}):oe.map(e=>n(`button`,{type:`button`,onClick:()=>s?.(e.id),disabled:m,className:z(`flex w-full cursor-pointer items-start gap-2.5 rounded-md border border-border bg-background/70 px-3 py-2 text-start transition-colors`,`hover:bg-mixer-muted/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,m&&`cursor-not-allowed opacity-50`,j),children:[t(`span`,{className:`mt-1 size-4 flex-shrink-0 rounded-full border border-border`,"aria-hidden":`true`}),n(`span`,{className:`min-w-0 flex-1`,children:[n(`span`,{className:`flex items-center gap-2 text-sm font-medium leading-5 text-foreground`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`span`,{className:`mt-0.5 block break-words text-xs leading-5 text-muted`,children:e.description})]})]},e.id))}),u&&t(`div`,{className:z(`px-3 pb-3 pt-0`,M),children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:R,type:`text`,value:te,onChange:e=>I(e.target.value),onKeyDown:fe,placeholder:se,disabled:m,className:z(`min-w-0 flex-1 rounded-md border border-border bg-background/70 px-3 py-2 text-sm text-foreground focus:border-transparent focus:ring-2 focus:ring-ring`,ee)}),t(o,{size:`sm`,onClick:de,disabled:m||!te.trim(),className:N,children:m?`...`:F})]})})]})]})})}return t(`div`,{className:`my-4 font-sans ${w||``}`,children:n(`div`,{className:`${pe} ${re.bg} rounded-e-lg shadow-sm ${T||``}`,children:[t(`div`,{className:`px-4 py-3 ${E||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[!_&&t(`div`,{className:`flex-shrink-0 mt-0.5 ${re.icon} ${D||``}`,children:h||t(ie,{className:`size-5`})}),t(`div`,{className:`min-w-0 flex-1`,children:n(`div`,{className:SU,children:[t(`div`,{className:`agent-ask-question vprose prose prose-sm max-w-none text-foreground ${O||``}`,children:t(vU,{children:r})}),i&&t(`p`,{className:`mt-1 text-sm text-muted ${k||``}`,children:i})]})}),x]})}),n(`div`,{id:S,hidden:C,children:[oe.length>0&&t(`div`,{className:`px-4 pb-3 pt-1 ${A||``}`,children:d?n(`div`,{className:`space-y-2`,children:[oe.map(e=>n(`label`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg cursor-pointer transition-colors
998
+ ${ne.has(e.id)?`bg-info border border-info`:`bg-card text-card-foreground border border-border hover:bg-muted`}
999
+ ${m?`opacity-50 cursor-not-allowed`:``}`,children:[t(`input`,{type:`checkbox`,checked:ne.has(e.id),onChange:()=>le(e.id),disabled:m,className:`mt-0.5 w-4 h-4 rounded border-border text-info focus:ring-info bg-background`}),n(`div`,{className:`flex-1 overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground break-words`,children:[e.icon,t(`span`,{className:`break-words`,children:e.label})]}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]},e.id)),t(`div`,{className:`pt-2`,children:n(o,{size:`sm`,onClick:ue,disabled:m||ne.size===0,className:`flex items-center gap-2`,children:[t(rb,{className:`size-4`}),ne.size>0?P(`agent.submitSelectionCount`,{count:ne.size}):P(`agent.submitSelection`)]})})]}):t(`div`,{className:`flex flex-col gap-2 w-full`,children:oe.map(e=>t(o,{variant:`unstyled`,onClick:()=>s?.(e.id),disabled:m,className:`w-full h-auto whitespace-normal text-start px-4 py-3 rounded-lg border border-border
1000
1000
  bg-card text-card-foreground
1001
1001
  hover:bg-muted hover:border-border
1002
1002
  focus:outline-none focus:ring-2 focus:ring-info focus:ring-offset-1
1003
1003
  transition-colors
1004
1004
  ${m?`opacity-50 cursor-not-allowed`:`cursor-pointer`}
1005
- ${j||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[e.icon&&t(`span`,{className:`flex-shrink-0 mt-0.5 text-muted`,children:e.icon}),n(`div`,{className:`flex-1 overflow-hidden`,children:[t(`div`,{className:`font-medium text-sm text-foreground break-words text-center`,children:e.label}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]})},e.id))})}),u&&t(`div`,{className:`px-4 pb-3 pt-1 ${M||``}`,children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:re,type:`text`,value:I,onChange:e=>ne(e.target.value),onKeyDown:fe,placeholder:F,disabled:m,className:`flex-1 px-3 py-2 text-sm border border-border rounded-md bg-card text-card-foreground focus:ring-2 focus:ring-info focus:border-transparent ${ee||``}`}),t(o,{size:`sm`,onClick:de,disabled:m||!I.trim(),className:N,children:m?`...`:te})]})})]})]})})}function wU({question:e,description:n,onConfirm:r,onCancel:i,confirmLabel:a,cancelLabel:o,isLoading:s=!1,variant:c=`default`,className:l}){let{t:u}=K(),d=a??u(`agent.yes`),f=o??u(`agent.no`);return t(CU,{question:e,description:n,variant:c,isLoading:s,className:l,options:[{id:`confirm`,label:d,icon:t(rg,{className:`size-4`})},{id:`cancel`,label:f,icon:t(hg,{className:`size-4`})}],onSelect:e=>{e===`confirm`?r():i()}})}const TU=z(`flex-shrink-0 border-t border-border/70 bg-background/95 backdrop-blur`,`fixed bottom-0 end-0 start-0 z-20 lg:sticky lg:start-auto lg:end-auto`,`pb-safe-area`);function EU({className:e,...n}){return t(`div`,{className:z(TU,e),...n})}function DU(e){return t(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:t(CU,{...e,hideBorder:!0,compact:!0,className:`my-0`,cardClassName:`bg-background/80 shadow-lg shadow-black/5`})})}function OU(e){let t=e.replace(/^workstream[:_-]?/i,``).replace(/^sys:/i,``).replace(/[-_:]?[0-9a-f]{8}-[0-9a-f-]{12,}$/i,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[:_-]+/g,` `).trim();return t?t.split(/\s+/).map(e=>{let t=e.toLowerCase();return t===`qa`?`QA`:t===`ui`?`UI`:t===`api`?`API`:t===`url`?`URL`:t.charAt(0).toUpperCase()+t.slice(1)}).join(` `):e}function kU(e){return/[0-9a-f]{8}-[0-9a-f-]{12,}/i.test(e)}function AU(e,t){let n=t?OU(t):``,r=OU(e);if(!n)return r;if(kU(e))return n;let i=n.toLowerCase().replace(/\s+/g,``);return r.toLowerCase().replace(/\s+/g,``).startsWith(i)?n:r}function jU(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function MU(e){if(typeof e!=`string`)return!1;let t=e.trim().toLowerCase();return!!(t&&t!==`main`&&t!==`all`)}function NU(e){let t=e.trim();if(!t||!/^[{[]/.test(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function PU(e,t){return MU(t)&&NU(e)}function FU(e){return!PU(jU(e),e.workstream_id)||e.type!==J.ANSWER&&e.type!==J.COMPLETE?!1:e.details?.event_class===`user_content`||e.details?.streamed===!0}function IU(e){switch(e){case`running`:return`bg-info`;case`canceling`:return`bg-attention`;case`completed`:return`bg-success`;case`canceled`:case`failed`:case`timeout`:return`bg-destructive`}}function LU(e){let t=e.details,n=t?.status;if(n===`running`||n===`canceling`||n===`completed`||n===`canceled`||n===`failed`||n===`timeout`)return n;if(t?.workstream_event===`completed`)return`completed`}function RU(e){let t=e.details;if(t?.workstream_event!==`launched`)return null;let n=typeof t.workstream_id==`string`?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return!n||n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function zU(e){let t=e.details;if(t?.event_class!==`activity`||t.workstream_event!==void 0||e.type===J.ERROR)return null;let n=typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,r=typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0;if(!n&&!r)return null;let i=typeof t.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return MU(i)?{workstreamId:i,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:n,childWorkflowRunId:r}:null}function BU(e){let t=e.indexOf(`?`);return t===-1?null:new URLSearchParams(e.slice(t+1)).get(`agentChatDebug`)}function VU(){if(typeof window>`u`)return!1;let e=new URLSearchParams(window.location.search).get(`agentChatDebug`),t=BU(window.location.hash),n=e??t;if(n!==null)return n===`1`||n===`true`;try{let e=window.localStorage.getItem(`agentChatDebug`);return e===`1`||e===`true`}catch{return!1}}function HU(e,t){VU()&&console.debug(`[agent-chat] ${e}`,t??{})}function UU(e,t){let n=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime(),r=e.findIndex(e=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())>n);r===-1?e.push(t):e.splice(r,0,t)}const WU=[J.COMPLETE,J.IDLE,J.REQUEST_INPUT,J.TERMINATED];function GU(e){return e.type===J.UPDATE&&e.details?.event_class===`artifact_updated`}function KU(e){if(!e.length)return!0;let t=e=>e.details?._optimistic&&e.details?._deliveryStatus===`failed`&&WU.includes(e.type),n=e.filter(e=>!t(e)&&!GU(e)),r=n.filter(e=>YU(e)===`main`);if(r.length===0){let e=n[n.length-1];return!e||!WU.includes(e.type)}let i=r[r.length-1];return!WU.includes(i.type)}function qU(e){if(e.type!==J.IDLE)return!1;let t=e.details?.status_reason,n=e.details?.display_role;return t===`user_stopped`||n===`user_stopped`||String(e.message??``).trim().toLowerCase().startsWith(`stopped.`)}function JU(e){return typeof e==`number`?e:new Date(e).getTime()}function YU(e){return e.workstream_id?e.workstream_id:`main`}function XU(e){let t=e.details;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function ZU(e){if(YU(e)===`main`||RU(e)||zU(e))return!0;let t=XU(e),n=typeof t.child_workflow_id==`string`||typeof t.child_workflow_run_id==`string`,r=typeof t.tool==`string`||typeof t.tool_run_id==`string`;return t.event_class===`activity`&&(e.type===J.ERROR||e.type===J.WARNING)&&!n&&!r}function QU(e,t){return t===`all`?e.filter(ZU):e.filter(e=>(RU(e)??zU(e))?.workstreamId!==t&&YU(e)===t)}async function $U(e,t){return e.agents.getArtifactUrl(t,`conversation.json`).then(e=>e.url)}function eW(e,t){if(!t)return!0;let n=e.workstreamId||`main`;return t===`all`?n===`main`:t===n}function tW(e){if(typeof e==`string`)return e.replace(/\r\n/g,`
1006
- `).trim()||void 0}function nW(e){return tW(e.message)}function rW(e,t){let n=tW(e.text);if(!n)return!1;let r=e.workstreamId||`main`;return t.some(t=>{if(JU(t.timestamp)<e.startTimestamp||YU(t)!==r)return!1;let i=typeof t.details?.streaming_id==`string`?t.details.streaming_id:void 0;return e.streamingId&&i?i===e.streamingId?t.details?.display_role===`thinking`?nW(t)===n:!(aW(t)||t.details?.tool_status):!1:e.activityId&&t.details?.activity_id===e.activityId?t.details?.display_role===`thinking`?nW(t)===n:!(aW(t)||t.details?.tool_status):t.type!==J.THOUGHT&&t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE?!1:nW(t)===n})}function iW(e,t){if(YU(e)!==YU(t))return!1;let n=nW(e),r=nW(t);if(!n||n!==r)return!1;let i=JU(e.timestamp);return JU(t.timestamp)-i>1e4?!1:!((e.type!==J.ANSWER||t.type!==J.COMPLETE&&t.type!==J.IDLE)&&(e.type!==J.THOUGHT||t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE||!e.details?.streamed&&!t.details?.streamed)&&(e.type!==t.type||!e.details?.streamed&&!t.details?.streamed||t.type!==J.THOUGHT&&t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE))}function aW(e){return e.type===J.THOUGHT&&!!e.details?.tool}function oW(e){let t=e.details;return e.type===J.THOUGHT&&(t?.display_role===`tool_preamble`||t?.tool===`think`)}function sW(e){if(oW(e))return!1;if(aW(e))return!0;if(e.type!==J.THOUGHT)return!1;let t=e.details;return!!(Array.isArray(t?.tools)&&t.tools.length>0)}function cW(e){return e.details?.tool_run_id}function lW(e){return e.details?.tool_iteration}function uW(e){return e.details?.tool_status}function dW(e){let t=e.details?.activity_group_id;if(typeof t==`string`&&t.trim()!==``)return t}function fW(e,t,n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=[];for(let t of e){let e=dW(t);if(t.type===J.REQUEST_INPUT||t.type===J.BATCH_PROGRESS)o.push(t);else if(oW(t))o.push(t);else if(e)r.has(e)||r.set(e,{messages:[],firstTimestamp:JU(t.timestamp)}),r.get(e)?.messages.push(t);else if(sW(t)){let e=lW(t),n=cW(t);e===void 0?n?(a.has(n)||a.set(n,{messages:[],firstTimestamp:JU(t.timestamp)}),a.get(n)?.messages.push(t)):o.push(t):(i.has(e)||i.set(e,{messages:[],firstTimestamp:JU(t.timestamp)}),i.get(e)?.messages.push(t))}else o.push(t)}let s=[];r.forEach((e,t)=>{s.push({kind:`activity_group`,activityGroupId:t,messages:e.messages,timestamp:e.firstTimestamp})}),i.forEach((e,t)=>{s.push({kind:`iteration_group`,iteration:t,messages:e.messages,timestamp:e.firstTimestamp})}),a.forEach((e,t)=>{s.push({kind:`tool_run`,toolRunId:t,messages:e.messages,timestamp:e.firstTimestamp})});for(let e of o)s.push({kind:`message`,message:e,timestamp:JU(e.timestamp)});t.forEach((t,r)=>{t.text&&(rW(t,e)||eW(t,n)&&s.push({kind:`streaming`,streamingId:r,data:t,timestamp:t.startTimestamp}))}),s.sort((e,t)=>{let n=e.kind===`streaming`&&!e.data.isComplete,r=t.kind===`streaming`&&!t.data.isComplete;return n&&!r?1:r&&!n?-1:e.timestamp-t.timestamp});let c=[],l=[],u=()=>{l.length>0&&(l.length===1&&!oW(l[0])?c.push({type:`single`,message:l[0]}):c.push({type:`tool_group`,messages:l,firstTimestamp:JU(l[0].timestamp)}),l=[])};for(let e of s)if(e.kind===`streaming`)u(),c.push({type:`streaming`,streamingId:e.streamingId,text:e.data.text,workstreamId:e.data.workstreamId,startTimestamp:e.data.startTimestamp,isComplete:e.data.isComplete});else if(e.kind===`activity_group`){u();let t=[...e.messages].sort((e,t)=>JU(e.timestamp)-JU(t.timestamp)),n=t.reduce((e,t)=>uW(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.activityGroupId,toolStatus:n})}else if(e.kind===`iteration_group`){u();let t=[...e.messages].sort((e,t)=>JU(e.timestamp)-JU(t.timestamp)),n=t.reduce((e,t)=>uW(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolStatus:n})}else if(e.kind===`tool_run`){u();let t=[...e.messages].sort((e,t)=>JU(e.timestamp)-JU(t.timestamp)),n=t.reduce((e,t)=>uW(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.toolRunId,toolStatus:n})}else sW(e.message)?l.push(e.message):(u(),c.push({type:`single`,message:e.message}));return u(),c}function pW(e,t){return t??e}function mW(e){let t=[],n=null,r=()=>{n&&=(t.push({type:`tool_group`,messages:n.messages,firstTimestamp:n.firstTimestamp,toolRunId:n.toolRunId,toolStatus:n.toolStatus,preambleText:n.preambleText,preambleMessage:n.preambleMessage}),null)};for(let i of e)i.type===`tool_group`?n?(n.messages=[...n.messages,...i.messages],n.toolStatus=pW(n.toolStatus,i.toolStatus),!n.toolRunId&&i.toolRunId&&(n.toolRunId=i.toolRunId),!n.preambleMessage&&i.preambleMessage&&(n.preambleMessage=i.preambleMessage,n.preambleText=i.preambleText)):n={messages:[...i.messages],firstTimestamp:i.firstTimestamp,toolRunId:i.toolRunId,toolStatus:i.toolStatus,preambleText:i.preambleText,preambleMessage:i.preambleMessage}:(r(),t.push(i));return r(),t}function hW(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function gW(e){let t=_W(e.details?.tool_approval);if(!t)return hW(e);let n=vW(t.tool_title)??vW(t.tool_name),r=bW(vW(t.target));if(n&&r)return`Approve ${n}: ${r}?`;let i=vW(t.action_summary);return i?`Approve ${yW(i)}?`:hW(e)}function _W(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function vW(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function yW(e){return e.replace(/:\s*name(?::|\s+)/i,`: `)}function bW(e){if(!e)return;let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1).trim();if(!r)return e;switch(n){case`document_id`:return`document ${r}`;case`object_id`:return`object ${r}`;case`collection_id`:return`collection ${r}`;case`process_id`:return`process ${r}`;case`process_definition_id`:return`process definition ${r}`;case`interaction_id`:return`interaction ${r}`;case`prompt_id`:return`prompt ${r}`;case`dashboard_id`:return`dashboard ${r}`;case`database_id`:return`database ${r}`;case`table_id`:return`table ${r}`;default:return r}}function xW(e){let t=e.details;return e.type===J.REQUEST_INPUT&&!!t?.ux}function SW(e){let t=e.details;return[t?.request_id,t?.requestId,t?.activity_id,t?.activityId,t?.tool_run_id,t?.toolRunId,e.timestamp,hW(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function CW(e){let t=e.details,n=t?.request_id??t?.tool_use_id;return typeof n==`string`&&n?n:void 0}function wW(e){return CW(e)??SW(e)}function TW(e,t){return`vertesia:answered-request-input:${e}:${t}`}function EW(e,t){if(typeof window<`u`)try{window.sessionStorage.setItem(TW(e,t),`1`)}catch{}}function DW(e,t){if(typeof window<`u`)try{window.sessionStorage.removeItem(TW(e,t))}catch{}}function OW(e,t){if(t.type!==J.REQUEST_INPUT)return!1;let n=CW(t);if(!n||typeof window>`u`)return!1;try{return window.sessionStorage.getItem(TW(e,n))===`1`}catch{return!1}}function kW(e){if(e.type!==J.QUESTION)return;let t=_W(e.details),n=_W(t?.metadata),r=(_W(t?.request_input_response)??_W(n?.request_input_response))?.request_id;return typeof r==`string`&&r?r:void 0}function AW(e){let t=e.details;return[t?.ack,t?._messageId,t?._deliveryStatus,e.timestamp,YU(e),hW(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function jW(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;return e.forEach((e,t)=>{let r=kW(e);r&&n.set(r,t)}),e.forEach((r,i)=>{if(r.type!==J.REQUEST_INPUT)return;let a=CW(r),o=a?n.get(a):void 0;if(o!==void 0&&o>i){t.add(SW(r));return}let s=YU(r);for(let n=i+1;n<e.length;n+=1){let i=e[n];if(YU(i)===s){if(i.type===J.REQUEST_INPUT)break;if(i.type===J.QUESTION){kW(i)||t.add(SW(r));break}}}}),t}function MW(e,t){let n=CW(e);return n?{...t,request_input_response:{request_id:n}}:t}function NW(e,t,n,r){if(!e)return;let i=MW(t,r);i?e(n,i):e(n)}function PW(e){let t=_W(e?.request_input_response)?.request_id;return typeof t==`string`&&t?t:void 0}const FW=`request:`;function IW(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=_W(n.details),r=_W(e?.approval_request)?.approval_key,i=e?.approval_decision;if(i===`auto_approved`){let n=e?.request_id;typeof n==`string`&&n&&t.add(`${FW}${n}`);continue}typeof r==`string`&&(i===`denied`||i===`denied_with_feedback`||i===`timeout`||i===`reviewer_denied`||i===`cancelled_after_denial`)&&t.add(r)}return t}function LW(e){let t=_W(_W(e.details)?.tool_approval)?.approval_key;return typeof t==`string`?t:void 0}function RW(e){return e.type===J.REQUEST_INPUT&&LW(e)!==void 0}const zW=/* @__PURE__ */ new Set([`allow_once`,`allow_for_run`,`deny`]);function BW(e,t){let n=LW(e);if(n&&zW.has(t))return{tool_approval_response:{decision:t,approval_key:n}}}function VW(e){if(e.type!==J.QUESTION)return!1;let t=hW(e).trim().toLowerCase();return t===`allow_once`||t===`allow_for_run`||t===`deny`}function HW(e){if(e.type!==J.QUESTION)return!1;let t=_W(e.details),n=_W(t?.metadata),r=(_W(t?.tool_approval_response)??_W(n?.tool_approval_response))?.decision;return r===`deny_with_feedback`||typeof r==`string`&&zW.has(r)}function UW(e){return VW(e)||HW(e)}function WW(e,t){if(e.type!==J.REQUEST_INPUT)return!1;let n=CW(e);if(n&&t.has(`${FW}${n}`))return!0;let r=LW(e);return r?t.has(r):!1}function GW(e){let t=/* @__PURE__ */ new Set;return e.forEach((n,r)=>{if(!RW(n))return;let i=YU(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if(YU(r)===i){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){UW(r)&&t.add(SW(n));break}}}}),t}function KW(e,t,n){return RW(e)&&(t.has(SW(e))||WW(e,n))}function qW(e,t){let n=/* @__PURE__ */ new Set;return e.forEach((r,i)=>{if(!RW(r)||t&&!WW(r,t))return;let a=YU(r);for(let t=i+1;t<e.length;t+=1){let r=e[t];if(YU(r)===a){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){VW(r)&&n.add(AW(r));break}}}}),n}function JW(e,t){return e.type===J.QUESTION&&t.has(AW(e))}function YW(e,t){return e.type===J.REQUEST_INPUT&&t.has(SW(e))}function XW(e,t=`main`,n){let r=jW(e),i=IW(e);for(let a=e.length-1;a>=0;--a){let o=e[a];if(xW(o)&&YU(o)===t&&!n?.has(wW(o))&&!YW(o,r)&&!WW(o,i))return o}}Q();function ZW({mcpConnect:e,onMcpConnected:r,onDecline:i,disabled:a}){let{client:s}=q(),{t:c}=K();return n(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[t(KO,{appId:e.app_install_id,collectionId:e.collection_id,collectionName:e.name,variant:`default`,onAuthChange:()=>{s.remoteMcpConnections.getCollectionStatus(e.app_install_id,e.collection_id).then(t=>{t.authenticated&&r?.(e)}).catch(()=>{})},readOnly:a}),n(o,{variant:`ghost`,size:`sm`,onClick:i,disabled:a,children:[t(xx,{className:`size-4`}),t(`span`,{children:c(`mcpOAuth.decline`)})]})]})}function QW(e){return e.message?mt($W,{...e,message:e.message,key:`${e.message.workflow_run_id}:${wW(e.message)}`}):null}function $W({message:e,onSendMessage:r,onMcpConnected:i,isLoading:a=!1,disabled:s=!1,className:c}){let{t:l}=K(),[u,d]=G(!1),f=bt(),p=l(u?`agent.showQuestions`:`agent.hideQuestions`),m=e.details.ux,h=m.options??[],g=m.mcp_connect,_=m.free_response,v=s||a||!r,y=gW(e),b=(t,n)=>{v||NW(r,e,t,n)},x=t(Ke,{description:p,asChild:!0,children:t(o,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,"aria-label":p,"aria-expanded":!u,"aria-controls":f,onClick:()=>d(e=>!e),children:t(u?Ih:Dh,{className:`size-4`,"aria-hidden":`true`})})});return t(EU,{className:c,"data-agent-request-input-overlay":!0,children:g?n(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:[n(`div`,{className:`flex items-start gap-2`,children:[t(`div`,{className:`min-w-0 flex-1 text-sm leading-6 text-foreground/85`,children:y}),x]}),t(`div`,{id:f,hidden:u,children:t(ZW,{mcpConnect:g,onMcpConnected:t=>i?.(t,MW(e)),onDecline:()=>b(l(`agent.mcpDeclinedMessage`,{name:g.name})),disabled:v})})]}):t(DU,{question:y,options:h,variant:m.variant,multiSelect:m.multiSelect,allowFreeResponse:h.length===0||!!_,placeholder:_?.placeholder,submitLabel:_?.submit_label,onSelect:t=>b(t,BW(e,t)),onMultiSelect:e=>b(e.join(`, `)),onSubmit:e=>b(e,_?.metadata),isLoading:v,headerAction:x,responseControlsId:f,responseControlsHidden:u})})}Q();const eG={accurate:[`up`],helpful:[`up`],fast:[`up`],well_explained:[`up`],wrong_result:[`down`],incomplete:[`down`],misunderstood_request:[`down`],too_slow:[`down`],tool_failure:[`down`],unsafe_action:[`down`],other:[`up`,`down`]},tG=Object.keys(eG);function nG(e){return tG.filter(t=>eG[t].includes(e))}function rG(e){return`${e.workstream_id||`main`}:${e.timestamp}`}function iG(e){return e.type===J.ANSWER&&e.details?.source!==`streaming_summary`}function aG(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`fb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function oG(e){return e===`recorded`||e===`replaced`}function sG({agentRunId:e,messageId:t,messageSeq:n}){return`${e}|${t??``}|${n??``}`}function cG(e,t){return sG({agentRunId:e,messageId:t.message_id,messageSeq:t.message_seq})}const lG=pt(null);function uG(e){let t=e?.user_id??e?.sub;return t?`user:${t}`:void 0}function dG(e,t,n){let r=/* @__PURE__ */ new Map;if(!n)return/* @__PURE__ */ new Map;for(let i of t??[]){if(i.user_id!==n||i.replaced_at)continue;let t=cG(e,i),a=r.get(t);(!a||a.rated_at<i.rated_at)&&r.set(t,i)}return new Map(Array.from(r,([e,t])=>[e,t.rating]))}function fG({agentRunId:e,children:n}){let{client:r,user:i}=q(),a=uG(i),[o,s]=G(),[c,l]=G(()=>/* @__PURE__ */ new Map),u=W(r);u.current=r,H(()=>{let t=!1;return u.current.agents.retrieve(e).then(n=>{t||s({agentRunId:e,ratings:dG(e,n.feedback,a)})}).catch(()=>{t||s({agentRunId:e,ratings:/* @__PURE__ */ new Map})}),()=>{t=!0}},[e,a]);let d=U(()=>({agentRunId:e,ratingFor:t=>{let n=sG(t);return c.get(n)??(o?.agentRunId===e?o.ratings.get(n):void 0)},remember:(e,t)=>{l(n=>new Map(n).set(sG(e),t))}}),[e,o,c]);return t(lG.Provider,{value:d,children:n})}function pG({agentRunId:e,messageId:r,messageSeq:i,variant:a=`full`,tone:s=`default`,className:c,onRecorded:l}){let{t:u}=K(),{client:d}=q(),f=it(),p=yt(lG),[m,h]=G(),g=m??(p?.agentRunId===e?p.ratingFor({agentRunId:e,messageId:r,messageSeq:i}):void 0),[_,v]=G(),[y,b]=G(!1),[x,S]=G(!1),[C,w]=G(!1),[T,E]=G(),[D,O]=G(``),k=r!==void 0||i!==void 0?`message`:`run`,A=`${e}|${r??``}|${i??``}`,[j,M]=G(A),ee=W(A);j!==A&&(M(A),ee.current=A,h(void 0),v(void 0),S(!1),w(!1),E(void 0),O(``));let N=async(t,n)=>{let a={feedback_id:aG(),rating:t,...n&&T!==void 0?{reason_code:T}:{},...n&&D.trim().length>0?{comment:D.trim()}:{},...r===void 0?{}:{message_id:r},...i===void 0?{}:{message_seq:i}},o=A;try{let n=await d.agents.recordFeedback(e,a);return o===ee.current?oG(n.status)?(l?.(a,n.status),h(t),p?.remember({agentRunId:e,messageId:r,messageSeq:i},t),n.status):(b(n.status===`disabled`),f({status:`info`,title:u(`agent.feedback.notRecorded`),description:u(`agent.feedback.status.${n.status}`),duration:4e3}),n.status):void 0}catch(e){if(o!==ee.current)return;f({status:`error`,title:u(`agent.feedback.failed`),description:e instanceof Error?e.message:String(e),duration:4e3});return}},P=async e=>{if(!_){v(e);try{await N(e,!1)}finally{v(void 0)}}},F=()=>{g&&S(!0)},te=async()=>{if(g){w(!0);try{let e=await N(g,!0);e&&oG(e)&&(S(!1),f({status:`success`,title:u(`agent.feedback.thanks`),duration:2e3}))}finally{w(!1)}}};if(y)return null;let ne=a===`compact`,L=u(k===`message`?`agent.feedback.rateMessageUp`:`agent.feedback.rateRunUp`),R=u(k===`message`?`agent.feedback.rateMessageDown`:`agent.feedback.rateRunDown`),re=(e,n,r)=>t(Ke,{description:n,asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:ne?`icon`:`xs`,"aria-label":n,"aria-pressed":g===e,disabled:_!==void 0,onClick:()=>void P(e),className:z(`transition-colors duration-200 rounded-md`,ne&&`size-8 rounded-lg`,g===e&&(e===`up`?`text-success`:`text-destructive`)),children:t(r,{className:`size-4`})})});return n(`div`,{className:z(`flex items-center gap-0.5`,s===`inline`&&!g&&`opacity-40 transition-opacity duration-200 group-hover:opacity-100 focus-within:opacity-100`,c),children:[re(`up`,L,Hb),re(`down`,R,zb),g&&!x&&t(o,{type:`button`,variant:`ghost`,size:`xs`,onClick:F,className:`ms-1 text-xs text-muted hover:text-foreground`,children:u(`agent.feedback.tellUsMore`)}),n(ce,{isOpen:x,onClose:()=>S(!1),size:`md`,disableCloseOnClickOutside:!0,children:[t(de,{children:u(`agent.feedback.detailTitle`)}),t(le,{children:n(`div`,{className:`flex flex-col gap-4`,children:[t(`p`,{className:`text-sm text-muted`,children:u(`agent.feedback.detailHelp`)}),t(I,{label:u(`agent.feedback.reasonLabel`),children:t(Te,{options:g?nG(g):[],value:T,onChange:E,optionLabel:e=>u(`agent.feedback.reason.${e}`),placeholder:u(`agent.feedback.reasonPlaceholder`),"aria-label":u(`agent.feedback.reasonLabel`),isClearable:!0})}),t(I,{label:u(`agent.feedback.commentLabel`),helpText:u(`agent.feedback.commentHelp`),children:t(Ge,{value:D,onChange:e=>O(e.target.value),maxLength:fn,minLines:3,maxLines:8,placeholder:u(`agent.feedback.commentPlaceholder`)})})]})}),n(ue,{children:[t(o,{variant:`ghost`,onClick:()=>S(!1),disabled:C,children:u(`agent.feedback.skip`)}),t(o,{onClick:()=>void te(),isLoading:C,disabled:C||T===void 0&&D.trim().length===0,children:u(`agent.feedback.submit`)})]})]})]})}function mG({className:e,inline:r=!1,color:i=`blue`}){let a={blue:`from-info to-info`,purple:`from-done to-done`,teal:`from-info to-info`,green:`from-success to-success`,amber:`from-attention to-attention`}[i];return n(`div`,{className:z(`flex items-center gap-1.5`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.2s_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.4s_infinite]`})]})}function hG({className:e,size:r=`md`,color:i=`blue`}){let a={sm:`w-3 h-3`,md:`w-5 h-5`,lg:`w-7 h-7`},o={blue:`bg-info`,purple:`bg-done`,teal:`bg-info`,green:`bg-success`,amber:`bg-attention`};return n(`span`,{className:z(`relative flex`,e),children:[t(`span`,{className:z(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,o[i])}),t(`span`,{className:z(`animate-pulse absolute inline-flex h-[80%] w-[80%] rounded-full opacity-80`,o[i]),style:{left:`10%`,top:`10%`,animationDuration:`2s`}}),t(`span`,{className:z(`relative inline-flex rounded-full`,o[i],a[r])})]})}function gG({className:e,color:n=`blue`}){let[r,i]=G(`.`);return H(()=>{let e=setInterval(()=>{i(e=>e===`.`?`..`:e===`..`?`...`:`.`)},500);return()=>clearInterval(e)},[]),t(`span`,{className:z({blue:`text-info`,purple:`text-done`,teal:`text-info`,green:`text-success`,amber:`text-attention`}[n],`font-bold`,e),children:r})}function _G({message:e,className:r,color:i=`blue`}){let a={blue:{dot:`bg-info`,text:`text-info`},purple:{dot:`bg-done`,text:`text-done`},teal:{dot:`bg-info`,text:`text-info`},green:{dot:`bg-success`,text:`text-success`},amber:{dot:`bg-attention`,text:`text-attention`}};return n(`div`,{className:z(`flex items-center gap-2 py-1`,r),children:[n(`div`,{className:`flex gap-1`,children:[t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.2s`}}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.4s`}})]}),t(`div`,{className:`${a[i].text} font-medium text-xs`,children:e})]})}function vG({className:e,color:r=`blue`,width:i=`md`,message:a}){let[o,s]=G(15),[c,l]=G(`increasing`),[u,d]=G(.4),f=W(null),p=W(!0);return H(()=>{let e=f.current;if(!e)return;let t=new IntersectionObserver(([e])=>{p.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]),H(()=>{let e,t=Date.now(),n=()=>{if(!p.current){e=requestAnimationFrame(n);return}let r=Date.now(),i=r-t;t=r,s(e=>{let t=i/16*u,n=c===`increasing`?e+t:e-t;return n>=85?(l(`decreasing`),d(.3+Math.random()*.2),85):n<=15?(l(`increasing`),d(.3+Math.random()*.2),15):(Math.random()>.99&&d(e=>Math.max(.2,Math.min(.5,e+(Math.random()*.1-.05)))),n)}),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{cancelAnimationFrame(e)}},[c,u]),n(`div`,{ref:f,className:z(`flex flex-col gap-1`,e),children:[a&&t(`div`,{className:`text-xs font-medium ${{blue:`text-info`,purple:`text-done`,teal:`text-info`,green:`text-success`,amber:`text-attention`}[r]} mb-1`,children:a}),t(`div`,{className:z(`h-1.5 rounded-full overflow-hidden shadow-inner`,{blue:`bg-info`,purple:`bg-done`,teal:`bg-info`,green:`bg-success`,amber:`bg-attention`}[r],{sm:`w-24`,md:`w-32`,lg:`w-48`,xl:`w-64`,full:`w-full`}[i]),children:t(`div`,{className:z(`h-full rounded-full`,{blue:`bg-gradient-to-r from-info to-info`,purple:`bg-gradient-to-r from-done to-done`,teal:`bg-gradient-to-r from-info to-info`,green:`bg-gradient-to-r from-success to-success`,amber:`bg-gradient-to-r from-attention to-attention`}[r]),style:{width:`${o}%`,transition:`width 150ms cubic-bezier(0.4, 0.0, 0.2, 1)`}})})]})}function yG({className:e,color:n=`blue`,size:r=`md`}){let[i,a]=G(Array(7).fill(50)),o=W(null),s=W(!0);H(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(([e])=>{s.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]);let c={sm:{width:`w-16`,height:`h-4`,barWidth:`w-0.5`,gap:`gap-[2px]`},md:{width:`w-20`,height:`h-5`,barWidth:`w-1`,gap:`gap-[3px]`},lg:{width:`w-24`,height:`h-6`,barWidth:`w-1.5`,gap:`gap-1`}},l={blue:`bg-gradient-to-b from-info to-info`,purple:`bg-gradient-to-b from-done to-done`,teal:`bg-gradient-to-b from-info to-info`,green:`bg-gradient-to-b from-success to-success`,amber:`bg-gradient-to-b from-attention to-attention`};return H(()=>{let e,t=[1.2,1,1.5,.8,1.3,.9,1.1],n=[0,.5,1,1.5,2,2.5,3],r=0,i=()=>{if(!s.current){e=requestAnimationFrame(i);return}r+=.02;let o=Array(7).fill(0).map((e,i)=>10+(Math.sin(r*t[i]+n[i])+1)*40);a(o),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{cancelAnimationFrame(e)}},[]),t(`div`,{ref:o,className:z(`flex items-end justify-center`,c[r].width,c[r].height,c[r].gap,e),children:i.map((e,i)=>t(`div`,{className:z(c[r].barWidth,`rounded-full transform-gpu`,l[n]),style:{height:`${e}%`,transition:`height 100ms cubic-bezier(0.4, 0.0, 0.2, 1)`,opacity:.9}},`bar-${i}`))})}Q();const bG=[`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/80`,`prose-p:my-2 prose-p:leading-6 prose-li:my-0.5 prose-pre:my-3 prose-headings:tracking-normal`,`prose-headings:text-foreground prose-strong:text-foreground prose-code:text-foreground`,`prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`[&_p]:text-foreground/80 [&_li]:text-foreground/80 [&_li::marker]:text-muted`].join(` `);function xG({children:e,artifactRunId:r,components:i,disableCollapse:a,className:o,"data-testid":s}){let{t:c}=K(),l=e.trim(),[u,d]=G(!1),f=l?l.split(/\r?\n/).length:0,p=l.length>520||f>6,m=p&&!a&&!u;return n(`div`,{className:z(`min-w-0`,o),children:[t(`div`,{"data-testid":s,className:z(bG,m&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Ft,{artifactRunId:r,components:i,children:e})}),p&&!a?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":u,className:z(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>d(e=>!e),children:[c(u?`agent.showLess`:`agent.showMore`),t(Dh,{className:z(`size-4 transition-transform`,u&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}Q();const SG=/* @__PURE__ */ new Set([`heading`,`paragraph`,`list`,`list_item`,`blockquote`,`code_block`,`table`,`separator`]);function CG(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function wG(e,t){let n=e?.[t];return typeof n==`string`&&n.length>0?n:void 0}function TG(e){let t=CG(e),n=wG(t,`kind`);if(n===`store_document`){let e=wG(t,`document_id`);if(!e)return;let r=wG(t,`name`);return{kind:n,document_id:e,...r?{name:r}:{}}}if(n===`agent_artifact`){let e=wG(t,`run_id`),r=wG(t,`path`);return e&&r?{kind:n,run_id:e,path:r}:void 0}}function EG(e){let t=CG(e),n=CG(t?.anchor),r=wG(t,`operation_id`),i=wG(t,`action`),a=wG(n,`block_id`),o=wG(n,`block_type`),s=wG(n,`exact_text`),c=TG(t?.resource);if(!r||i!==`comment`&&i!==`edit`||!a||!o||!SG.has(o)||!s||!c)return;let l=wG(t,`base_version`),u=wG(t,`comment`),d=CG(t?.user_change),f=wG(d,`before`),p=wG(d,`after`);if(i===`comment`&&!u||i===`edit`&&(!f||!p))return;let m=wG(t,`updated_document_id`);return{operation_id:r,resource:c,...l?{base_version:l}:{},action:i,anchor:{block_id:a,block_type:o,exact_text:s},...u?{comment:u}:{},...f&&p?{user_change:{before:f,after:p}}:{},...t?.applied===!0?{applied:!0}:{},...m?{updated_document_id:m}:{}}}function DG(e){return e.length>12?`${e.slice(0,4)}…${e.slice(-4)}`:e}function OG(e){return e.kind===`store_document`?e.name||DG(e.document_id):e.path}const kG=[`[&_h1]:text-base [&_h2]:text-base [&_h3]:text-base [&_h4]:text-base [&_h5]:text-base [&_h6]:text-base`,`[&_h1]:leading-snug [&_h2]:leading-snug [&_h3]:leading-snug`,`[&_:first-child]:mt-0 [&_:last-child]:mb-0`].join(` `);function AG({children:e,className:n}){return t(`pre`,{className:z(`m-0 max-h-48 overflow-auto whitespace-pre-wrap font-mono text-xs leading-5 text-foreground/80`,n),children:e})}function jG({before:e,after:n}){let r=U(()=>Wt(e,n),[e,n]);return t(AG,{children:r.map((e,n)=>e.type===`removed`?t(`del`,{className:`rounded-xs bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`rounded-xs bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})}function MG({action:r}){let{t:i}=K(),a=r.action===`comment`,o=r.applied===!0,s=r.anchor.block_type.replaceAll(`_`,` `),c=a?Hv:xy,l=r.resource.kind===`agent_artifact`?r.resource.run_id:void 0;return n(`div`,{className:`min-w-0 space-y-2 text-start`,"data-document-edit-action":r.action,children:[n(`div`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-muted`,children:[t(c,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t(`span`,{className:`shrink-0 font-medium text-foreground`,children:i(a?`agent.documentEditCardComment`:o?`agent.documentEditCardApplied`:`agent.documentEditCardDirectEdit`)}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`shrink-0 capitalize`,children:s}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`truncate`,children:OG(r.resource)})]}),a?n(e,{children:[r.comment?t(xG,{artifactRunId:l,disableCollapse:!0,className:kG,children:r.comment}):null,t(xG,{artifactRunId:l,disableCollapse:!0,className:z(`border-s-2 border-mixer-muted/30 ps-3 text-foreground/70`,kG),children:r.anchor.exact_text})]}):t(jG,{before:r.user_change?.before??r.anchor.exact_text,after:r.user_change?.after??``})]})}const NG=/* @__PURE__ */ `Brewing some code magic...(Doing the robot dance...(Cooking up something good...(Working my gears...(Parsing the possibilities...(Crunching the numbers...(Connecting the digital dots...(Processing at maximum capacity...(Searching through my circuits...(Running advanced algorithms...(Computing optimal solutions...(Loading brilliance.exe...(Scanning the knowledge base...(Optimizing response protocols...(Having a quick brainstorm...(Thinking cap firmly on...(Pondering the digital universe...(Consulting my silicon wisdom...(Untangling the logic knots...(Assembling clever responses...(Mixing thoughtful ingredients...(Polishing the perfect answer...(Taking a momentary mind sprint...(Connecting virtual synapses...(Baking fresh ideas...(Stirring the thought pot...(Simmering solutions slowly...(Whipping up a smart response...(Adding a dash of intelligence...(Preparing a gourmet answer...(Growing brilliant ideas...(Cultivating the perfect response...(Gathering digital nectar...(Planting seeds of solutions...(Exploring the data landscape...(Mapping the solution path...(Navigating through possibilities...(Charting the course to answers...(Embarking on a thought expedition...(Sketching out concepts...(Painting with digital brushstrokes...(Composing my response symphony...(Crafting precision answers...(Weaving threads of information...(Just a moment of processing...(Taking a quick thinking break...(Almost there, final touches...(Putting the pieces together...(Making progress, hold tight...`.split(`(`);function PG(e,t){if(e.startsWith(t))return e.slice(t.length).split(/[/?#]/,1)[0]||void 0}function FG(e={}){let{StoreLinkComponent:n,CollectionLinkComponent:r,addStickyParams:i}=e;return function({node:e,ref:a,...o}){let s=o.href||``,c=s.startsWith(`/`)&&!s.startsWith(`//`),l=c&&i?i(s):s,u=c?PG(s,`/store/objects/`):void 0;if(u&&n)return t(n,{href:l,documentId:u,className:o.className,children:o.children});let d=c?PG(s,`/store/collections/`):void 0;return d&&r?t(r,{href:l,collectionId:d,className:o.className,children:o.children}):c?t(nr,{href:l,className:o.className,topLevelNav:!0,children:o.children}):t(`a`,{...o,target:`_blank`,rel:`noopener noreferrer`})}}Q();const IG=pt(null);function LG(){return yt(IG)||{openImage:e=>window.open(e,`_blank`),closeImage:()=>{}}}function RG({children:e}){let[r,i]=G(null),a=V((e,t)=>{i({src:e,alt:t})},[]),s=V(()=>{i(null)},[]),{t:c}=K();return n(IG.Provider,{value:{openImage:a,closeImage:s},children:[e,r&&t(`div`,{role:`button`,tabIndex:-1,"aria-label":c(`agent.close`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:s,onKeyDown:Ye(s),children:n(`div`,{className:`relative max-w-[90vw] max-h-[90vh]`,children:[t(`img`,{src:r.src,alt:r.alt||c(`agent.enlargedView`),className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-2xl`}),t(o,{variant:`unstyled`,className:`absolute top-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:s,title:c(`agent.close`),children:t(xx,{className:`size-6`})}),t(`a`,{href:r.src,target:`_blank`,rel:`noopener noreferrer`,className:`absolute bottom-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:e=>e.stopPropagation(),title:c(`agent.openInNewTab`),children:t(Zg,{className:`size-5`})})]})})]})}Q();const zG=/* @__PURE__ */ new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),BG=/* @__PURE__ */ new Set([`css`,`csv`,`html`,`js`,`json`,`jsx`,`log`,`md`,`mjs`,`sql`,`ts`,`tsx`,`txt`,`xml`,`yaml`,`yml`]);function VG(e){let t=e?.split(/[?#]/)[0]??``;return t.includes(`.`)?(t.split(`.`).pop()??``).toLowerCase():``}function HG(e){return e.contentType?.toLowerCase().startsWith(`image/`)?!0:zG.has(VG(e.artifactPath||e.href||e.name))}function UG(e){let t=e.contentType?.toLowerCase()??``;return t.startsWith(`text/`)||t===`application/json`||t.includes(`xml`)?!0:BG.has(VG(e.artifactPath||e.href||e.name))}function WG(e){if(e.artifactPath)return e.artifactPath;if(e.href?.startsWith(`artifact:`))return e.href.slice(9)}function GG(e){let t=e.split(`/store/objects/`)[1];return t?t.split(/[?#]/)[0]:e.replace(/^store:/,``).replace(/^document:(?:\/\/)?/,``).split(/[?#]/)[0]}function KG(e){return e.split(`/store/collections/`)[1]||e.replace(/^collection:/,``)}function qG(e){return!!(e?.includes(`/store/objects/`)||e?.startsWith(`store:`)||e?.startsWith(`document:`))}function JG(e){return!!(e?.includes(`/store/collections/`)||e?.startsWith(`collection:`))}function YG({item:n,children:r,onOpenArtifact:i,StoreLinkComponent:a,CollectionLinkComponent:o}){let s=n.href;if(!s)return t(e,{children:r});let c=WG(n);if(c&&/\.md$/i.test(c)&&i)return t(`button`,{type:`button`,className:`max-w-full text-start`,onClick:()=>i(c),children:r});if(qG(s)){let e=GG(s);return a?t(a,{href:s,documentId:e,children:r}):t(`a`,{href:s.startsWith(`store:`)||s.startsWith(`document:`)?`/store/objects/${e}`:s,children:r})}if(JG(s)){let e=KG(s);return o?t(o,{href:s,collectionId:e,children:r}):t(`a`,{href:s.startsWith(`collection:`)?`/store/collections/${e}`:s,children:r})}return/^https?:\/\//.test(s)||s.startsWith(`/`)?t(`a`,{href:s,target:s.startsWith(`/`)?void 0:`_blank`,rel:`noopener noreferrer`,children:r}):t(e,{children:r})}function XG({item:e,artifactRunId:r,variant:i,onRemove:a,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l}){let{t:u}=K(),d=yt(cn),f=_C(),{openImage:p}=LG(),m=WG(e),h=HG(e),g=h&&!UG(e),[_,v]=G(e.previewUrl);H(()=>{v(e.previewUrl)},[e.previewUrl]),H(()=>{if(!g||e.previewUrl||!r||!m||!d?.client)return;let t=!1,n=yC(r,m,`inline`);return(async()=>{let e=f?await f.getOrFetch(n,async()=>(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url):(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url;t||v(e)})().catch(()=>{t||v(void 0)}),()=>{t=!0}},[m,r,e.previewUrl,d?.client,g,f]);let y={attention:`bg-attention/15 text-attention`,destructive:`bg-destructive/15 text-destructive`,info:`bg-info/15 text-info`,muted:`bg-muted text-muted`,success:`bg-success/15 text-success`}[e.statusTone??`muted`],b=!!(a&&e.removable!==!1),x=t=>{t.stopPropagation(),t.preventDefault(),a?.(e.id)},S=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`absolute -end-1.5 -top-1.5 inline-flex size-5 items-center justify-center rounded-full`,`border border-border bg-background text-muted shadow-sm transition-colors hover:text-foreground`),children:t(xx,{className:`size-3`,"aria-hidden":`true`})}):null,C=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`-me-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted`,`transition-colors hover:bg-mixer-muted/30 hover:text-foreground`),children:t(xx,{className:`size-3.5`,"aria-hidden":`true`})}):null,w=g&&_?t(o,{type:`button`,variant:`unstyled`,size:`none`,onClick:t=>{t.stopPropagation(),t.preventDefault(),p(_,e.name)},"aria-label":e.name,title:u(`agent.enlargedView`),className:z(`group shrink-0 overflow-hidden rounded border border-border/60 p-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i===`composer`?`size-6`:`size-24`),children:t(`img`,{src:_,alt:e.name,className:`h-full w-full object-cover transition-transform group-hover:scale-[1.05]`})}):t(h?Z_:h_,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),T=n(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,children:[w,t(`span`,{className:z(`truncate`,i===`composer`?`max-w-[14rem]`:`max-w-[16rem]`),children:e.name}),e.statusLabel?t(`span`,{className:z(`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium`,y),children:e.statusLabel}):null]});if(i===`composer`)return n(`span`,{title:e.name,className:z(`inline-flex min-h-8 max-w-full items-center gap-1 rounded-xl border border-border/60`,`bg-mixer-muted/15 px-2.5 py-1 text-sm text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:[t(YG,{item:e,StoreLinkComponent:c,CollectionLinkComponent:l,children:T}),C]});let E=t(`span`,{title:e.name,className:z(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/60 bg-mixer-muted/15`,`px-2.5 py-1.5 text-xs text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:T});return n(`span`,{className:`relative inline-flex max-w-full`,children:[t(YG,{item:e,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l,children:E}),S]})}function ZG({items:e,artifactRunId:r,className:i,align:a=`start`,variant:s=`message`,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let{t:f}=K(),[p,m]=G(!1),h=bt(),g=s===`composer`&&e.length>3,_=g&&!p?e.slice(0,3):e,v=e.length-3;return H(()=>{e.length<=3&&m(!1)},[e.length]),e.length===0?null:n(`div`,{id:h,className:z(`flex flex-wrap gap-2`,a===`end`&&`justify-end`,i),children:[_.map(e=>t(XG,{item:e,artifactRunId:r,variant:s,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d},e.id)),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-controls":h,"aria-expanded":p,onClick:()=>m(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!p&&n(`span`,{children:[`+`,v]}),f(p?`agent.showLess`:`agent.showMore`),t(Dh,{className:z(`size-3.5 transition-transform`,p&&`rotate-180`),"aria-hidden":`true`})]})]})}const QG=/^\s*(?:\*\*)?(attachments|uploaded artifacts):(?:\*\*)?\s*$/i,$G=/\s/,eK=[`image -`,`text extracted to `];function tK(e){let t=e;if((t.startsWith(`-`)||t.startsWith(`*`))&&(t=t.slice(1).trimStart()),!t.startsWith(`[`)||!t.endsWith(`)`))return null;let n=t.indexOf(`]`);if(n<2||t[n+1]!==`(`)return null;let r=t.slice(1,n),i=t.slice(n+2,-1);for(let e=i.lastIndexOf(`(`);e>0;e=i.lastIndexOf(`(`,e-1)){let t=e;for(;t>0&&$G.test(i[t-1]);)t--;if(t===e||t<2||i[t-1]!==`)`)continue;let n=i.slice(e+1);if(eK.some(e=>n.startsWith(e)))return{name:r,href:i.slice(0,t-1),note:n}}return i?{name:r,href:i}:null}function nK(e){let t=e.split(/\r?\n/),n=[],r=[],i=!1;for(let e of t){let t=e.trim();if(QG.test(t)){i=!0;continue}if(!i){n.push(e);continue}if(!t)continue;let a=tK(t);if(!a){i=!1,n.push(e);continue}let{name:o,href:s,note:c}=a,l=s.startsWith(`artifact:`)?s.slice(9):void 0;r.push({id:`${s}-${r.length}`,name:o,href:s,artifactPath:l,contentType:c?.toLowerCase().includes(`image`)?`image/*`:void 0})}return{body:n.join(`
1005
+ ${j||``}`,children:n(`div`,{className:`flex items-start gap-3`,children:[e.icon&&t(`span`,{className:`flex-shrink-0 mt-0.5 text-muted`,children:e.icon}),n(`div`,{className:`flex-1 overflow-hidden`,children:[t(`div`,{className:`font-medium text-sm text-foreground break-words text-center`,children:e.label}),e.description&&t(`div`,{className:`mt-1 text-sm text-muted break-words whitespace-pre-wrap`,children:e.description})]})]})},e.id))})}),u&&t(`div`,{className:`px-4 pb-3 pt-1 ${M||``}`,children:n(`div`,{className:`flex gap-2`,children:[t(`input`,{ref:R,type:`text`,value:te,onChange:e=>I(e.target.value),onKeyDown:fe,placeholder:se,disabled:m,className:`flex-1 px-3 py-2 text-sm border border-border rounded-md bg-card text-card-foreground focus:ring-2 focus:ring-info focus:border-transparent ${ee||``}`}),t(o,{size:`sm`,onClick:de,disabled:m||!te.trim(),className:N,children:m?`...`:F})]})})]})]})})}function wU({question:e,description:n,onConfirm:r,onCancel:i,confirmLabel:a,cancelLabel:o,isLoading:s=!1,variant:c=`default`,className:l}){let{t:u}=K(),d=a??u(`agent.yes`),f=o??u(`agent.no`);return t(CU,{question:e,description:n,variant:c,isLoading:s,className:l,options:[{id:`confirm`,label:d,icon:t(rg,{className:`size-4`})},{id:`cancel`,label:f,icon:t(hg,{className:`size-4`})}],onSelect:e=>{e===`confirm`?r():i()}})}const TU=z(`flex-shrink-0 border-t border-border/70 bg-background/95 backdrop-blur`,`fixed bottom-0 end-0 start-0 z-20 lg:sticky lg:start-auto lg:end-auto`,`pb-safe-area`);function EU({className:e,...n}){return t(`div`,{className:z(TU,e),...n})}function DU(e){return t(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:t(CU,{...e,hideBorder:!0,compact:!0,className:`my-0`,cardClassName:`bg-background/80 shadow-lg shadow-black/5`})})}function OU(e){let t=e.replace(/^workstream[:_-]?/i,``).replace(/^sys:/i,``).replace(/[-_:]?[0-9a-f]{8}-[0-9a-f-]{12,}$/i,``).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[:_-]+/g,` `).trim();return t?t.split(/\s+/).map(e=>{let t=e.toLowerCase();return t===`qa`?`QA`:t===`ui`?`UI`:t===`api`?`API`:t===`url`?`URL`:t.charAt(0).toUpperCase()+t.slice(1)}).join(` `):e}function kU(e){return/[0-9a-f]{8}-[0-9a-f-]{12,}/i.test(e)}function AU(e,t){let n=t?OU(t):``,r=OU(e);if(!n)return r;if(kU(e))return n;let i=n.toLowerCase().replace(/\s+/g,``);return r.toLowerCase().replace(/\s+/g,``).startsWith(i)?n:r}function jU(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function MU(e){if(typeof e!=`string`)return!1;let t=e.trim().toLowerCase();return!!(t&&t!==`main`&&t!==`all`)}function NU(e){let t=e.trim();if(!t||!/^[{[]/.test(t))return!1;try{return JSON.parse(t),!0}catch{return!1}}function PU(e,t){return MU(t)&&NU(e)}function FU(e){return!PU(jU(e),e.workstream_id)||e.type!==J.ANSWER&&e.type!==J.COMPLETE?!1:e.details?.event_class===`user_content`||e.details?.streamed===!0}function IU(e){switch(e){case`running`:return`bg-info`;case`canceling`:return`bg-attention`;case`completed`:return`bg-success`;case`canceled`:case`failed`:case`timeout`:return`bg-destructive`}}function LU(e){let t=e.details,n=t?.status;if(n===`running`||n===`canceling`||n===`completed`||n===`canceled`||n===`failed`||n===`timeout`)return n;if(t?.workstream_event===`completed`)return`completed`}function RU(e){let t=e.details;if(t?.workstream_event!==`launched`)return null;let n=typeof t.workstream_id==`string`?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return!n||n===`main`||n===`all`?null:{workstreamId:n,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,childWorkflowRunId:typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0}}function zU(e){let t=e.details;if(t?.event_class!==`activity`||t.workstream_event!==void 0||e.type===J.ERROR)return null;let n=typeof t.child_workflow_id==`string`?t.child_workflow_id:void 0,r=typeof t.child_workflow_run_id==`string`?t.child_workflow_run_id:void 0;if(!n&&!r)return null;let i=typeof t.workstream_id==`string`&&t.workstream_id.trim()?t.workstream_id:typeof e.workstream_id==`string`?e.workstream_id:``;return MU(i)?{workstreamId:i,launchId:typeof t.launch_id==`string`?t.launch_id:void 0,kind:typeof t.kind==`string`?t.kind:void 0,interaction:typeof t.interaction==`string`?t.interaction:void 0,childWorkflowId:n,childWorkflowRunId:r}:null}function BU(e){let t=e.indexOf(`?`);return t===-1?null:new URLSearchParams(e.slice(t+1)).get(`agentChatDebug`)}function VU(){if(typeof window>`u`)return!1;let e=new URLSearchParams(window.location.search).get(`agentChatDebug`),t=BU(window.location.hash),n=e??t;if(n!==null)return n===`1`||n===`true`;try{let e=window.localStorage.getItem(`agentChatDebug`);return e===`1`||e===`true`}catch{return!1}}function HU(e,t){VU()&&console.debug(`[agent-chat] ${e}`,t??{})}function UU(e,t){let n=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime(),r=e.findIndex(e=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())>n);r===-1?e.push(t):e.splice(r,0,t)}const WU=[J.COMPLETE,J.IDLE,J.REQUEST_INPUT,J.TERMINATED];function GU(e){return e.type===J.UPDATE&&e.details?.event_class===`artifact_updated`}function KU(e){if(!e.length)return!0;let t=e=>e.details?._optimistic&&e.details?._deliveryStatus===`failed`&&WU.includes(e.type),n=e.filter(e=>!t(e)&&!GU(e)),r=n.filter(e=>YU(e)===`main`);if(r.length===0){let e=n[n.length-1];return!e||!WU.includes(e.type)}let i=r[r.length-1];return!WU.includes(i.type)}function qU(e){if(e.type!==J.IDLE)return!1;let t=e.details?.status_reason,n=e.details?.display_role;return t===`user_stopped`||n===`user_stopped`||String(e.message??``).trim().toLowerCase().startsWith(`stopped.`)}function JU(e){return typeof e==`number`?e:new Date(e).getTime()}function YU(e){return e.workstream_id?e.workstream_id:`main`}function XU(e){let t=e.details;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function ZU(e){if(YU(e)===`main`||RU(e)||zU(e))return!0;let t=XU(e),n=typeof t.child_workflow_id==`string`||typeof t.child_workflow_run_id==`string`,r=typeof t.tool==`string`||typeof t.tool_run_id==`string`;return t.event_class===`activity`&&(e.type===J.ERROR||e.type===J.WARNING)&&!n&&!r}function QU(e,t){return t===`all`?e.filter(ZU):e.filter(e=>(RU(e)??zU(e))?.workstreamId!==t&&YU(e)===t)}async function $U(e,t){return e.agents.getArtifactUrl(t,`conversation.json`).then(e=>e.url)}function eW(e,t){if(!t)return!0;let n=e.workstreamId||`main`;return t===`all`?n===`main`:t===n}function tW(e){if(typeof e==`string`)return e.replace(/\r\n/g,`
1006
+ `).trim()||void 0}function nW(e){return tW(e.message)}function rW(e,t){let n=tW(e.text);if(!n)return!1;let r=e.workstreamId||`main`;return t.some(t=>{if(JU(t.timestamp)<e.startTimestamp||YU(t)!==r)return!1;let i=typeof t.details?.streaming_id==`string`?t.details.streaming_id:void 0;return e.streamingId&&i?i===e.streamingId?t.details?.display_role===`thinking`?nW(t)===n:!(aW(t)||t.details?.tool_status):!1:e.activityId&&t.details?.activity_id===e.activityId?t.details?.display_role===`thinking`?nW(t)===n:!(aW(t)||t.details?.tool_status):t.type!==J.THOUGHT&&t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE?!1:nW(t)===n})}function iW(e,t){if(YU(e)!==YU(t))return!1;let n=nW(e),r=nW(t);if(!n||n!==r)return!1;let i=JU(e.timestamp);return JU(t.timestamp)-i>1e4?!1:!((e.type!==J.ANSWER||t.type!==J.COMPLETE&&t.type!==J.IDLE)&&(e.type!==J.THOUGHT||t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE||!e.details?.streamed&&!t.details?.streamed)&&(e.type!==t.type||!e.details?.streamed&&!t.details?.streamed||t.type!==J.THOUGHT&&t.type!==J.ANSWER&&t.type!==J.COMPLETE&&t.type!==J.IDLE))}function aW(e){return e.type===J.THOUGHT&&!!e.details?.tool}function oW(e){let t=e.details;return e.type===J.THOUGHT&&(t?.display_role===`tool_preamble`||t?.tool===`think`)}function sW(e){if(oW(e))return!1;if(aW(e))return!0;if(e.type!==J.THOUGHT)return!1;let t=e.details;return!!(Array.isArray(t?.tools)&&t.tools.length>0)}function cW(e){return e.details?.tool_run_id}function lW(e){return e.details?.tool_iteration}function uW(e){return e.details?.tool_status}function dW(e){let t=e.details?.activity_group_id;if(typeof t==`string`&&t.trim()!==``)return t}function fW(e,t,n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=[];for(let t of e){let e=dW(t);if(t.type===J.REQUEST_INPUT||t.type===J.BATCH_PROGRESS)o.push(t);else if(oW(t))o.push(t);else if(e)r.has(e)||r.set(e,{messages:[],firstTimestamp:JU(t.timestamp)}),r.get(e)?.messages.push(t);else if(sW(t)){let e=lW(t),n=cW(t);e===void 0?n?(a.has(n)||a.set(n,{messages:[],firstTimestamp:JU(t.timestamp)}),a.get(n)?.messages.push(t)):o.push(t):(i.has(e)||i.set(e,{messages:[],firstTimestamp:JU(t.timestamp)}),i.get(e)?.messages.push(t))}else o.push(t)}let s=[];r.forEach((e,t)=>{s.push({kind:`activity_group`,activityGroupId:t,messages:e.messages,timestamp:e.firstTimestamp})}),i.forEach((e,t)=>{s.push({kind:`iteration_group`,iteration:t,messages:e.messages,timestamp:e.firstTimestamp})}),a.forEach((e,t)=>{s.push({kind:`tool_run`,toolRunId:t,messages:e.messages,timestamp:e.firstTimestamp})});for(let e of o)s.push({kind:`message`,message:e,timestamp:JU(e.timestamp)});t.forEach((t,r)=>{t.text&&(rW(t,e)||eW(t,n)&&s.push({kind:`streaming`,streamingId:r,data:t,timestamp:t.startTimestamp}))}),s.sort((e,t)=>{let n=e.kind===`streaming`&&!e.data.isComplete,r=t.kind===`streaming`&&!t.data.isComplete;return n&&!r?1:r&&!n?-1:e.timestamp-t.timestamp});let c=[],l=[],u=()=>{l.length>0&&(l.length===1&&!oW(l[0])?c.push({type:`single`,message:l[0]}):c.push({type:`tool_group`,messages:l,firstTimestamp:JU(l[0].timestamp)}),l=[])};for(let e of s)if(e.kind===`streaming`)u(),c.push({type:`streaming`,streamingId:e.streamingId,text:e.data.text,workstreamId:e.data.workstreamId,startTimestamp:e.data.startTimestamp,isComplete:e.data.isComplete});else if(e.kind===`activity_group`){u();let t=[...e.messages].sort((e,t)=>JU(e.timestamp)-JU(t.timestamp)),n=t.reduce((e,t)=>uW(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.activityGroupId,toolStatus:n})}else if(e.kind===`iteration_group`){u();let t=[...e.messages].sort((e,t)=>JU(e.timestamp)-JU(t.timestamp)),n=t.reduce((e,t)=>uW(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolStatus:n})}else if(e.kind===`tool_run`){u();let t=[...e.messages].sort((e,t)=>JU(e.timestamp)-JU(t.timestamp)),n=t.reduce((e,t)=>uW(t)||e,void 0);c.push({type:`tool_group`,messages:t,firstTimestamp:e.timestamp,toolRunId:e.toolRunId,toolStatus:n})}else sW(e.message)?l.push(e.message):(u(),c.push({type:`single`,message:e.message}));return u(),c}function pW(e,t){return t??e}function mW(e){let t=[],n=null,r=()=>{n&&=(t.push({type:`tool_group`,messages:n.messages,firstTimestamp:n.firstTimestamp,toolRunId:n.toolRunId,toolStatus:n.toolStatus,preambleText:n.preambleText,preambleMessage:n.preambleMessage}),null)};for(let i of e)i.type===`tool_group`?n?(n.messages=[...n.messages,...i.messages],n.toolStatus=pW(n.toolStatus,i.toolStatus),!n.toolRunId&&i.toolRunId&&(n.toolRunId=i.toolRunId),!n.preambleMessage&&i.preambleMessage&&(n.preambleMessage=i.preambleMessage,n.preambleText=i.preambleText)):n={messages:[...i.messages],firstTimestamp:i.firstTimestamp,toolRunId:i.toolRunId,toolStatus:i.toolStatus,preambleText:i.preambleText,preambleMessage:i.preambleMessage}:(r(),t.push(i));return r(),t}function hW(e){return e.message?typeof e.message==`object`?JSON.stringify(e.message,null,2):String(e.message).trim():``}function gW(e){let t=_W(e.details?.tool_approval);if(!t)return hW(e);let n=vW(t.tool_title)??vW(t.tool_name),r=bW(vW(t.target));if(n&&r)return`Approve ${n}: ${r}?`;let i=vW(t.action_summary);return i?`Approve ${yW(i)}?`:hW(e)}function _W(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function vW(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function yW(e){return e.replace(/:\s*name(?::|\s+)/i,`: `)}function bW(e){if(!e)return;let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1).trim();if(!r)return e;switch(n){case`document_id`:return`document ${r}`;case`object_id`:return`object ${r}`;case`collection_id`:return`collection ${r}`;case`process_id`:return`process ${r}`;case`process_definition_id`:return`process definition ${r}`;case`interaction_id`:return`interaction ${r}`;case`prompt_id`:return`prompt ${r}`;case`dashboard_id`:return`dashboard ${r}`;case`database_id`:return`database ${r}`;case`table_id`:return`table ${r}`;default:return r}}function xW(e){let t=e.details;return e.type===J.REQUEST_INPUT&&!!t?.ux}function SW(e){let t=e.details;return[t?.request_id,t?.requestId,t?.activity_id,t?.activityId,t?.tool_run_id,t?.toolRunId,e.timestamp,hW(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function CW(e){let t=e.details,n=t?.request_id??t?.tool_use_id;return typeof n==`string`&&n?n:void 0}function wW(e){return CW(e)??SW(e)}function TW(e,t){return`vertesia:answered-request-input:${e}:${t}`}function EW(e,t){if(typeof window<`u`)try{window.sessionStorage.setItem(TW(e,t),`1`)}catch{}}function DW(e,t){if(typeof window<`u`)try{window.sessionStorage.removeItem(TW(e,t))}catch{}}function OW(e,t){if(t.type!==J.REQUEST_INPUT)return!1;let n=CW(t);if(!n||typeof window>`u`)return!1;try{return window.sessionStorage.getItem(TW(e,n))===`1`}catch{return!1}}function kW(e){if(e.type!==J.QUESTION)return;let t=_W(e.details),n=_W(t?.metadata),r=(_W(t?.request_input_response)??_W(n?.request_input_response))?.request_id;return typeof r==`string`&&r?r:void 0}function AW(e){let t=e.details;return[t?.ack,t?._messageId,t?._deliveryStatus,e.timestamp,YU(e),hW(e)].filter(e=>typeof e==`string`||typeof e==`number`).map(String).join(`|`)}function jW(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;return e.forEach((e,t)=>{let r=kW(e);r&&n.set(r,t)}),e.forEach((r,i)=>{if(r.type!==J.REQUEST_INPUT)return;let a=CW(r),o=a?n.get(a):void 0;if(o!==void 0&&o>i){t.add(SW(r));return}let s=YU(r);for(let n=i+1;n<e.length;n+=1){let i=e[n];if(YU(i)===s){if(i.type===J.REQUEST_INPUT)break;if(i.type===J.QUESTION){kW(i)||t.add(SW(r));break}}}}),t}function MW(e,t){let n=CW(e);return n?{...t,request_input_response:{request_id:n}}:t}function NW(e,t,n,r){if(!e)return;let i=MW(t,r);i?e(n,i):e(n)}function PW(e){let t=_W(e?.request_input_response)?.request_id;return typeof t==`string`&&t?t:void 0}const FW=`request:`;function IW(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=_W(n.details),r=_W(e?.approval_request)?.approval_key,i=e?.approval_decision;if(i===`auto_approved`){let n=e?.request_id;typeof n==`string`&&n&&t.add(`${FW}${n}`);continue}typeof r==`string`&&(i===`denied`||i===`denied_with_feedback`||i===`timeout`||i===`reviewer_denied`||i===`cancelled_after_denial`)&&t.add(r)}return t}function LW(e){let t=_W(_W(e.details)?.tool_approval)?.approval_key;return typeof t==`string`?t:void 0}function RW(e){return e.type===J.REQUEST_INPUT&&LW(e)!==void 0}const zW=/* @__PURE__ */ new Set([`allow_once`,`allow_for_run`,`deny`]);function BW(e,t){let n=LW(e);if(n&&zW.has(t))return{tool_approval_response:{decision:t,approval_key:n}}}function VW(e){if(e.type!==J.QUESTION)return!1;let t=hW(e).trim().toLowerCase();return t===`allow_once`||t===`allow_for_run`||t===`deny`}function HW(e){if(e.type!==J.QUESTION)return!1;let t=_W(e.details),n=_W(t?.metadata),r=(_W(t?.tool_approval_response)??_W(n?.tool_approval_response))?.decision;return r===`deny_with_feedback`||typeof r==`string`&&zW.has(r)}function UW(e){return VW(e)||HW(e)}function WW(e,t){if(e.type!==J.REQUEST_INPUT)return!1;let n=CW(e);if(n&&t.has(`${FW}${n}`))return!0;let r=LW(e);return r?t.has(r):!1}function GW(e){let t=/* @__PURE__ */ new Set;return e.forEach((n,r)=>{if(!RW(n))return;let i=YU(n);for(let a=r+1;a<e.length;a+=1){let r=e[a];if(YU(r)===i){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){UW(r)&&t.add(SW(n));break}}}}),t}function KW(e,t,n){return RW(e)&&(t.has(SW(e))||WW(e,n))}function qW(e,t){let n=/* @__PURE__ */ new Set;return e.forEach((r,i)=>{if(!RW(r)||t&&!WW(r,t))return;let a=YU(r);for(let t=i+1;t<e.length;t+=1){let r=e[t];if(YU(r)===a){if(r.type===J.REQUEST_INPUT)break;if(r.type===J.QUESTION){VW(r)&&n.add(AW(r));break}}}}),n}function JW(e,t){return e.type===J.QUESTION&&t.has(AW(e))}function YW(e,t){return e.type===J.REQUEST_INPUT&&t.has(SW(e))}function XW(e,t=`main`,n){let r=jW(e),i=IW(e);for(let a=e.length-1;a>=0;--a){let o=e[a];if(xW(o)&&YU(o)===t&&!n?.has(wW(o))&&!YW(o,r)&&!WW(o,i))return o}}Q();function ZW({mcpConnect:e,onMcpConnected:r,onDecline:i,disabled:a}){let{client:s}=q(),{t:c}=K();return n(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[t(KO,{appId:e.app_install_id,collectionId:e.collection_id,collectionName:e.name,variant:`default`,onAuthChange:()=>{s.remoteMcpConnections.getCollectionStatus(e.app_install_id,e.collection_id).then(t=>{t.authenticated&&r?.(e)}).catch(()=>{})},readOnly:a}),n(o,{variant:`ghost`,size:`sm`,onClick:i,disabled:a,children:[t(xx,{className:`size-4`}),t(`span`,{children:c(`mcpOAuth.decline`)})]})]})}function QW(e){return e.message?mt($W,{...e,message:e.message,key:`${e.message.workflow_run_id}:${wW(e.message)}`}):null}function $W({message:e,onSendMessage:r,onMcpConnected:i,isLoading:a=!1,disabled:s=!1,className:c}){let{t:l}=K(),[u,d]=G(!1),f=bt(),p=l(u?`agent.showQuestions`:`agent.hideQuestions`),m=e.details.ux,h=m.options??[],g=m.mcp_connect,_=m.free_response,v=s||a||!r,y=gW(e),b=(t,n)=>{v||NW(r,e,t,n)},x=t(Ke,{description:p,asChild:!0,children:t(o,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,"aria-label":p,"aria-expanded":!u,"aria-controls":f,onClick:()=>d(e=>!e),children:t(u?Ih:Dh,{className:`size-4`,"aria-hidden":`true`})})});return t(EU,{className:c,"data-agent-request-input-overlay":!0,children:g?n(`div`,{className:`mx-auto w-full max-w-3xl px-3 py-3`,children:[n(`div`,{className:`flex items-start gap-2`,children:[t(`div`,{className:`min-w-0 flex-1 text-sm leading-6 text-foreground/85`,children:y}),x]}),t(`div`,{id:f,hidden:u,children:t(ZW,{mcpConnect:g,onMcpConnected:t=>i?.(t,MW(e)),onDecline:()=>b(l(`agent.mcpDeclinedMessage`,{name:g.name})),disabled:v})})]}):t(DU,{question:y,options:h,variant:m.variant,multiSelect:m.multiSelect,allowFreeResponse:h.length===0||!!_,placeholder:_?.placeholder,submitLabel:_?.submit_label,onSelect:t=>b(t,BW(e,t)),onMultiSelect:e=>b(e.join(`, `)),onSubmit:e=>b(e,_?.metadata),isLoading:v,headerAction:x,responseControlsId:f,responseControlsHidden:u})})}Q();const eG={accurate:[`up`],helpful:[`up`],fast:[`up`],well_explained:[`up`],wrong_result:[`down`],incomplete:[`down`],misunderstood_request:[`down`],too_slow:[`down`],tool_failure:[`down`],unsafe_action:[`down`],other:[`up`,`down`]},tG=Object.keys(eG);function nG(e){return tG.filter(t=>eG[t].includes(e))}function rG(e){return`${e.workstream_id||`main`}:${e.timestamp}`}function iG(e){return e.type===J.ANSWER&&e.details?.source!==`streaming_summary`}function aG(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`fb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function oG(e){return e===`recorded`||e===`replaced`}function sG({agentRunId:e,messageId:t,messageSeq:n}){return`${e}|${t??``}|${n??``}`}function cG(e,t){return sG({agentRunId:e,messageId:t.message_id,messageSeq:t.message_seq})}const lG=pt(null);function uG(e){let t=e?.user_id??e?.sub;return t?`user:${t}`:void 0}function dG(e,t,n){let r=/* @__PURE__ */ new Map;if(!n)return/* @__PURE__ */ new Map;for(let i of t??[]){if(i.user_id!==n||i.replaced_at)continue;let t=cG(e,i),a=r.get(t);(!a||a.rated_at<i.rated_at)&&r.set(t,i)}return new Map(Array.from(r,([e,t])=>[e,t.rating]))}function fG({agentRunId:e,children:n}){let{client:r,user:i}=q(),a=uG(i),[o,s]=G(),[c,l]=G(()=>/* @__PURE__ */ new Map),u=W(r);u.current=r,H(()=>{let t=!1;return u.current.agents.retrieve(e).then(n=>{t||s({agentRunId:e,ratings:dG(e,n.feedback,a)})}).catch(()=>{t||s({agentRunId:e,ratings:/* @__PURE__ */ new Map})}),()=>{t=!0}},[e,a]);let d=U(()=>({agentRunId:e,ratingFor:t=>{let n=sG(t);return c.get(n)??(o?.agentRunId===e?o.ratings.get(n):void 0)},remember:(e,t)=>{l(n=>new Map(n).set(sG(e),t))}}),[e,o,c]);return t(lG.Provider,{value:d,children:n})}function pG({agentRunId:e,messageId:r,messageSeq:i,variant:a=`full`,tone:s=`default`,className:c,onRecorded:l}){let{t:u}=K(),{client:d}=q(),f=it(),p=yt(lG),[m,h]=G(),g=m??(p?.agentRunId===e?p.ratingFor({agentRunId:e,messageId:r,messageSeq:i}):void 0),[_,v]=G(),[y,b]=G(!1),[x,S]=G(!1),[C,w]=G(!1),[T,E]=G(),[D,O]=G(``),k=r!==void 0||i!==void 0?`message`:`run`,A=`${e}|${r??``}|${i??``}`,[j,M]=G(A),ee=W(A);j!==A&&(M(A),ee.current=A,h(void 0),v(void 0),S(!1),w(!1),E(void 0),O(``));let N=async(t,n)=>{let a={feedback_id:aG(),rating:t,...n&&T!==void 0?{reason_code:T}:{},...n&&D.trim().length>0?{comment:D.trim()}:{},...r===void 0?{}:{message_id:r},...i===void 0?{}:{message_seq:i}},o=A;try{let n=await d.agents.recordFeedback(e,a);return o===ee.current?oG(n.status)?(l?.(a,n.status),h(t),p?.remember({agentRunId:e,messageId:r,messageSeq:i},t),n.status):(b(n.status===`disabled`),f({status:`info`,title:u(`agent.feedback.notRecorded`),description:u(`agent.feedback.status.${n.status}`),duration:4e3}),n.status):void 0}catch(e){if(o!==ee.current)return;f({status:`error`,title:u(`agent.feedback.failed`),description:e instanceof Error?e.message:String(e),duration:4e3});return}},P=async e=>{if(!_){v(e);try{await N(e,!1)}finally{v(void 0)}}},F=()=>{g&&S(!0)},te=async()=>{if(g){w(!0);try{let e=await N(g,!0);e&&oG(e)&&(S(!1),f({status:`success`,title:u(`agent.feedback.thanks`),duration:2e3}))}finally{w(!1)}}};if(y)return null;let ne=a===`compact`,L=u(k===`message`?`agent.feedback.rateMessageUp`:`agent.feedback.rateRunUp`),R=u(k===`message`?`agent.feedback.rateMessageDown`:`agent.feedback.rateRunDown`),re=(e,n,r)=>t(Ke,{description:n,asChild:!0,children:t(o,{type:`button`,variant:`ghost`,size:ne?`icon`:`xs`,"aria-label":n,"aria-pressed":g===e,disabled:_!==void 0,onClick:()=>void P(e),className:z(`transition-colors duration-200 rounded-md`,ne&&`size-8 rounded-lg`,g===e&&(e===`up`?`text-success`:`text-destructive`)),children:t(r,{className:`size-4`})})});return n(`div`,{className:z(`flex items-center gap-0.5`,s===`inline`&&!g&&`opacity-40 transition-opacity duration-200 group-hover:opacity-100 focus-within:opacity-100`,c),children:[re(`up`,L,Hb),re(`down`,R,zb),g&&!x&&t(o,{type:`button`,variant:`ghost`,size:`xs`,onClick:F,className:`ms-1 text-xs text-muted hover:text-foreground`,children:u(`agent.feedback.tellUsMore`)}),n(ce,{isOpen:x,onClose:()=>S(!1),size:`md`,disableCloseOnClickOutside:!0,children:[t(de,{children:u(`agent.feedback.detailTitle`)}),t(le,{children:n(`div`,{className:`flex flex-col gap-4`,children:[t(`p`,{className:`text-sm text-muted`,children:u(`agent.feedback.detailHelp`)}),t(I,{label:u(`agent.feedback.reasonLabel`),children:t(Te,{options:g?nG(g):[],value:T,onChange:E,optionLabel:e=>u(`agent.feedback.reason.${e}`),placeholder:u(`agent.feedback.reasonPlaceholder`),"aria-label":u(`agent.feedback.reasonLabel`),isClearable:!0})}),t(I,{label:u(`agent.feedback.commentLabel`),helpText:u(`agent.feedback.commentHelp`),children:t(Ge,{value:D,onChange:e=>O(e.target.value),maxLength:fn,minLines:3,maxLines:8,placeholder:u(`agent.feedback.commentPlaceholder`)})})]})}),n(ue,{children:[t(o,{variant:`ghost`,onClick:()=>S(!1),disabled:C,children:u(`agent.feedback.skip`)}),t(o,{onClick:()=>void te(),isLoading:C,disabled:C||T===void 0&&D.trim().length===0,children:u(`agent.feedback.submit`)})]})]})]})}function mG({className:e,inline:r=!1,color:i=`blue`}){let a={blue:`from-info to-info`,purple:`from-done to-done`,teal:`from-info to-info`,green:`from-success to-success`,amber:`from-attention to-attention`}[i];return n(`div`,{className:z(`flex items-center gap-1.5`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.2s_infinite]`}),t(`div`,{className:`w-2 h-2 bg-gradient-to-r ${a} rounded-full animate-[bounce_1.2s_ease-in-out_0.4s_infinite]`})]})}function hG({className:e,size:r=`md`,color:i=`blue`}){let a={sm:`w-3 h-3`,md:`w-5 h-5`,lg:`w-7 h-7`},o={blue:`bg-info`,purple:`bg-done`,teal:`bg-info`,green:`bg-success`,amber:`bg-attention`};return n(`span`,{className:z(`relative flex`,e),children:[t(`span`,{className:z(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,o[i])}),t(`span`,{className:z(`animate-pulse absolute inline-flex h-[80%] w-[80%] rounded-full opacity-80`,o[i]),style:{left:`10%`,top:`10%`,animationDuration:`2s`}}),t(`span`,{className:z(`relative inline-flex rounded-full`,o[i],a[r])})]})}function gG({className:e,color:n=`blue`}){let[r,i]=G(`.`);return H(()=>{let e=setInterval(()=>{i(e=>e===`.`?`..`:e===`..`?`...`:`.`)},500);return()=>clearInterval(e)},[]),t(`span`,{className:z({blue:`text-info`,purple:`text-done`,teal:`text-info`,green:`text-success`,amber:`text-attention`}[n],`font-bold`,e),children:r})}function _G({message:e,className:r,color:i=`blue`}){let a={blue:{dot:`bg-info`,text:`text-info`},purple:{dot:`bg-done`,text:`text-done`},teal:{dot:`bg-info`,text:`text-info`},green:{dot:`bg-success`,text:`text-success`},amber:{dot:`bg-attention`,text:`text-attention`}};return n(`div`,{className:z(`flex items-center gap-2 py-1`,r),children:[n(`div`,{className:`flex gap-1`,children:[t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.2s`}}),t(`div`,{className:`w-1.5 h-1.5 ${a[i].dot} rounded-full animate-bounce`,style:{animationDelay:`0.4s`}})]}),t(`div`,{className:`${a[i].text} font-medium text-xs`,children:e})]})}function vG({className:e,color:r=`blue`,width:i=`md`,message:a}){let[o,s]=G(15),[c,l]=G(`increasing`),[u,d]=G(.4),f=W(null),p=W(!0);return H(()=>{let e=f.current;if(!e)return;let t=new IntersectionObserver(([e])=>{p.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]),H(()=>{let e,t=Date.now(),n=()=>{if(!p.current){e=requestAnimationFrame(n);return}let r=Date.now(),i=r-t;t=r,s(e=>{let t=i/16*u,n=c===`increasing`?e+t:e-t;return n>=85?(l(`decreasing`),d(.3+Math.random()*.2),85):n<=15?(l(`increasing`),d(.3+Math.random()*.2),15):(Math.random()>.99&&d(e=>Math.max(.2,Math.min(.5,e+(Math.random()*.1-.05)))),n)}),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{cancelAnimationFrame(e)}},[c,u]),n(`div`,{ref:f,className:z(`flex flex-col gap-1`,e),children:[a&&t(`div`,{className:`text-xs font-medium ${{blue:`text-info`,purple:`text-done`,teal:`text-info`,green:`text-success`,amber:`text-attention`}[r]} mb-1`,children:a}),t(`div`,{className:z(`h-1.5 rounded-full overflow-hidden shadow-inner`,{blue:`bg-info`,purple:`bg-done`,teal:`bg-info`,green:`bg-success`,amber:`bg-attention`}[r],{sm:`w-24`,md:`w-32`,lg:`w-48`,xl:`w-64`,full:`w-full`}[i]),children:t(`div`,{className:z(`h-full rounded-full`,{blue:`bg-gradient-to-r from-info to-info`,purple:`bg-gradient-to-r from-done to-done`,teal:`bg-gradient-to-r from-info to-info`,green:`bg-gradient-to-r from-success to-success`,amber:`bg-gradient-to-r from-attention to-attention`}[r]),style:{width:`${o}%`,transition:`width 150ms cubic-bezier(0.4, 0.0, 0.2, 1)`}})})]})}function yG({className:e,color:n=`blue`,size:r=`md`}){let[i,a]=G(Array(7).fill(50)),o=W(null),s=W(!0);H(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(([e])=>{s.current=e.isIntersecting},{threshold:0});return t.observe(e),()=>t.disconnect()},[]);let c={sm:{width:`w-16`,height:`h-4`,barWidth:`w-0.5`,gap:`gap-[2px]`},md:{width:`w-20`,height:`h-5`,barWidth:`w-1`,gap:`gap-[3px]`},lg:{width:`w-24`,height:`h-6`,barWidth:`w-1.5`,gap:`gap-1`}},l={blue:`bg-gradient-to-b from-info to-info`,purple:`bg-gradient-to-b from-done to-done`,teal:`bg-gradient-to-b from-info to-info`,green:`bg-gradient-to-b from-success to-success`,amber:`bg-gradient-to-b from-attention to-attention`};return H(()=>{let e,t=[1.2,1,1.5,.8,1.3,.9,1.1],n=[0,.5,1,1.5,2,2.5,3],r=0,i=()=>{if(!s.current){e=requestAnimationFrame(i);return}r+=.02;let o=Array(7).fill(0).map((e,i)=>10+(Math.sin(r*t[i]+n[i])+1)*40);a(o),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{cancelAnimationFrame(e)}},[]),t(`div`,{ref:o,className:z(`flex items-end justify-center`,c[r].width,c[r].height,c[r].gap,e),children:i.map((e,i)=>t(`div`,{className:z(c[r].barWidth,`rounded-full transform-gpu`,l[n]),style:{height:`${e}%`,transition:`height 100ms cubic-bezier(0.4, 0.0, 0.2, 1)`,opacity:.9}},`bar-${i}`))})}const bG=[`agent-markdown vprose prose max-w-none break-words text-sm leading-6 text-foreground/80`,`prose-p:my-2 prose-p:leading-6 prose-li:my-0.5 prose-pre:my-3 prose-headings:tracking-normal`,`prose-headings:text-foreground prose-strong:text-foreground prose-code:text-foreground`,`prose-a:text-foreground prose-a:underline prose-a:decoration-muted prose-a:underline-offset-4`,`prose-p:text-foreground/80 prose-li:text-foreground/80 prose-li:marker:text-muted`].join(` `);Q();function xG({children:e,artifactRunId:r,components:i,disableCollapse:a,className:o,"data-testid":s}){let{t:c}=K(),l=e.trim(),[u,d]=G(!1),f=l?l.split(/\r?\n/).length:0,p=l.length>520||f>6,m=p&&!a&&!u;return n(`div`,{className:z(`min-w-0`,o),children:[t(`div`,{"data-testid":s,className:z(bG,m&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Ft,{artifactRunId:r,components:i,children:e})}),p&&!a?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":u,className:z(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>d(e=>!e),children:[c(u?`agent.showLess`:`agent.showMore`),t(Dh,{className:z(`size-4 transition-transform`,u&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}Q();const SG=/* @__PURE__ */ new Set([`heading`,`paragraph`,`list`,`list_item`,`blockquote`,`code_block`,`table`,`separator`]);function CG(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function wG(e,t){let n=e?.[t];return typeof n==`string`&&n.length>0?n:void 0}function TG(e){let t=CG(e),n=wG(t,`kind`);if(n===`store_document`){let e=wG(t,`document_id`);if(!e)return;let r=wG(t,`name`);return{kind:n,document_id:e,...r?{name:r}:{}}}if(n===`agent_artifact`){let e=wG(t,`run_id`),r=wG(t,`path`);return e&&r?{kind:n,run_id:e,path:r}:void 0}}function EG(e){let t=CG(e),n=CG(t?.anchor),r=wG(t,`operation_id`),i=wG(t,`action`),a=wG(n,`block_id`),o=wG(n,`block_type`),s=wG(n,`exact_text`),c=TG(t?.resource);if(!r||i!==`comment`&&i!==`edit`||!a||!o||!SG.has(o)||!s||!c)return;let l=wG(t,`base_version`),u=wG(t,`comment`),d=CG(t?.user_change),f=wG(d,`before`),p=wG(d,`after`);if(i===`comment`&&!u||i===`edit`&&(!f||!p))return;let m=wG(t,`updated_document_id`);return{operation_id:r,resource:c,...l?{base_version:l}:{},action:i,anchor:{block_id:a,block_type:o,exact_text:s},...u?{comment:u}:{},...f&&p?{user_change:{before:f,after:p}}:{},...t?.applied===!0?{applied:!0}:{},...m?{updated_document_id:m}:{}}}function DG(e){return e.length>12?`${e.slice(0,4)}…${e.slice(-4)}`:e}function OG(e){return e.kind===`store_document`?e.name||DG(e.document_id):e.path}const kG=[`[&_h1]:text-base [&_h2]:text-base [&_h3]:text-base [&_h4]:text-base [&_h5]:text-base [&_h6]:text-base`,`[&_h1]:leading-snug [&_h2]:leading-snug [&_h3]:leading-snug`,`[&_:first-child]:mt-0 [&_:last-child]:mb-0`].join(` `);function AG({children:e,className:n}){return t(`pre`,{className:z(`m-0 max-h-48 overflow-auto whitespace-pre-wrap font-mono text-xs leading-5 text-foreground/80`,n),children:e})}function jG({before:e,after:n}){let r=U(()=>Wt(e,n),[e,n]);return t(AG,{children:r.map((e,n)=>e.type===`removed`?t(`del`,{className:`rounded-xs bg-mixer-destructive/15 text-destructive line-through decoration-destructive/50`,children:e.text},n):e.type===`added`?t(`ins`,{className:`rounded-xs bg-mixer-success/15 text-success no-underline`,children:e.text},n):t(`span`,{children:e.text},n))})}function MG({action:r}){let{t:i}=K(),a=r.action===`comment`,o=r.applied===!0,s=r.anchor.block_type.replaceAll(`_`,` `),c=a?Hv:xy,l=r.resource.kind===`agent_artifact`?r.resource.run_id:void 0;return n(`div`,{className:`min-w-0 space-y-2 text-start`,"data-document-edit-action":r.action,children:[n(`div`,{className:`flex min-w-0 items-center gap-1.5 text-sm text-muted`,children:[t(c,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t(`span`,{className:`shrink-0 font-medium text-foreground`,children:i(a?`agent.documentEditCardComment`:o?`agent.documentEditCardApplied`:`agent.documentEditCardDirectEdit`)}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`shrink-0 capitalize`,children:s}),t(`span`,{"aria-hidden":`true`,children:`·`}),t(`span`,{className:`truncate`,children:OG(r.resource)})]}),a?n(e,{children:[r.comment?t(xG,{artifactRunId:l,disableCollapse:!0,className:kG,children:r.comment}):null,t(xG,{artifactRunId:l,disableCollapse:!0,className:z(`border-s-2 border-mixer-muted/30 ps-3 text-foreground/70`,kG),children:r.anchor.exact_text})]}):t(jG,{before:r.user_change?.before??r.anchor.exact_text,after:r.user_change?.after??``})]})}const NG=/* @__PURE__ */ `Brewing some code magic...(Doing the robot dance...(Cooking up something good...(Working my gears...(Parsing the possibilities...(Crunching the numbers...(Connecting the digital dots...(Processing at maximum capacity...(Searching through my circuits...(Running advanced algorithms...(Computing optimal solutions...(Loading brilliance.exe...(Scanning the knowledge base...(Optimizing response protocols...(Having a quick brainstorm...(Thinking cap firmly on...(Pondering the digital universe...(Consulting my silicon wisdom...(Untangling the logic knots...(Assembling clever responses...(Mixing thoughtful ingredients...(Polishing the perfect answer...(Taking a momentary mind sprint...(Connecting virtual synapses...(Baking fresh ideas...(Stirring the thought pot...(Simmering solutions slowly...(Whipping up a smart response...(Adding a dash of intelligence...(Preparing a gourmet answer...(Growing brilliant ideas...(Cultivating the perfect response...(Gathering digital nectar...(Planting seeds of solutions...(Exploring the data landscape...(Mapping the solution path...(Navigating through possibilities...(Charting the course to answers...(Embarking on a thought expedition...(Sketching out concepts...(Painting with digital brushstrokes...(Composing my response symphony...(Crafting precision answers...(Weaving threads of information...(Just a moment of processing...(Taking a quick thinking break...(Almost there, final touches...(Putting the pieces together...(Making progress, hold tight...`.split(`(`);function PG(e,t){if(e.startsWith(t))return e.slice(t.length).split(/[/?#]/,1)[0]||void 0}function FG(e={}){let{StoreLinkComponent:n,CollectionLinkComponent:r,addStickyParams:i}=e;return function({node:e,ref:a,...o}){let s=o.href||``,c=s.startsWith(`/`)&&!s.startsWith(`//`),l=c&&i?i(s):s,u=c?PG(s,`/store/objects/`):void 0;if(u&&n)return t(n,{href:l,documentId:u,className:o.className,children:o.children});let d=c?PG(s,`/store/collections/`):void 0;return d&&r?t(r,{href:l,collectionId:d,className:o.className,children:o.children}):c?t(nr,{href:l,className:o.className,topLevelNav:!0,children:o.children}):t(`a`,{...o,target:`_blank`,rel:`noopener noreferrer`})}}Q();const IG=pt(null);function LG(){return yt(IG)||{openImage:e=>window.open(e,`_blank`),closeImage:()=>{}}}function RG({children:e}){let[r,i]=G(null),a=V((e,t)=>{i({src:e,alt:t})},[]),s=V(()=>{i(null)},[]),{t:c}=K();return n(IG.Provider,{value:{openImage:a,closeImage:s},children:[e,r&&t(`div`,{role:`button`,tabIndex:-1,"aria-label":c(`agent.close`),className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:s,onKeyDown:Ye(s),children:n(`div`,{className:`relative max-w-[90vw] max-h-[90vh]`,children:[t(`img`,{src:r.src,alt:r.alt||c(`agent.enlargedView`),className:`max-w-full max-h-[90vh] object-contain rounded-lg shadow-2xl`}),t(o,{variant:`unstyled`,className:`absolute top-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:s,title:c(`agent.close`),children:t(xx,{className:`size-6`})}),t(`a`,{href:r.src,target:`_blank`,rel:`noopener noreferrer`,className:`absolute bottom-2 end-2 text-white bg-black/50 rounded-full p-2 hover:bg-black/70 transition-colors`,onClick:e=>e.stopPropagation(),title:c(`agent.openInNewTab`),children:t(Zg,{className:`size-5`})})]})})]})}Q();const zG=/* @__PURE__ */ new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),BG=/* @__PURE__ */ new Set([`css`,`csv`,`html`,`js`,`json`,`jsx`,`log`,`md`,`mjs`,`sql`,`ts`,`tsx`,`txt`,`xml`,`yaml`,`yml`]);function VG(e){let t=e?.split(/[?#]/)[0]??``;return t.includes(`.`)?(t.split(`.`).pop()??``).toLowerCase():``}function HG(e){return e.contentType?.toLowerCase().startsWith(`image/`)?!0:zG.has(VG(e.artifactPath||e.href||e.name))}function UG(e){let t=e.contentType?.toLowerCase()??``;return t.startsWith(`text/`)||t===`application/json`||t.includes(`xml`)?!0:BG.has(VG(e.artifactPath||e.href||e.name))}function WG(e){if(e.artifactPath)return e.artifactPath;if(e.href?.startsWith(`artifact:`))return e.href.slice(9)}function GG(e){let t=e.split(`/store/objects/`)[1];return t?t.split(/[?#]/)[0]:e.replace(/^store:/,``).replace(/^document:(?:\/\/)?/,``).split(/[?#]/)[0]}function KG(e){return e.split(`/store/collections/`)[1]||e.replace(/^collection:/,``)}function qG(e){return!!(e?.includes(`/store/objects/`)||e?.startsWith(`store:`)||e?.startsWith(`document:`))}function JG(e){return!!(e?.includes(`/store/collections/`)||e?.startsWith(`collection:`))}function YG({item:n,children:r,onOpenArtifact:i,StoreLinkComponent:a,CollectionLinkComponent:o}){let s=n.href;if(!s)return t(e,{children:r});let c=WG(n);if(c&&/\.md$/i.test(c)&&i)return t(`button`,{type:`button`,className:`max-w-full text-start`,onClick:()=>i(c),children:r});if(qG(s)){let e=GG(s);return a?t(a,{href:s,documentId:e,children:r}):t(`a`,{href:s.startsWith(`store:`)||s.startsWith(`document:`)?`/store/objects/${e}`:s,children:r})}if(JG(s)){let e=KG(s);return o?t(o,{href:s,collectionId:e,children:r}):t(`a`,{href:s.startsWith(`collection:`)?`/store/collections/${e}`:s,children:r})}return/^https?:\/\//.test(s)||s.startsWith(`/`)?t(`a`,{href:s,target:s.startsWith(`/`)?void 0:`_blank`,rel:`noopener noreferrer`,children:r}):t(e,{children:r})}function XG({item:e,artifactRunId:r,variant:i,onRemove:a,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l}){let{t:u}=K(),d=yt(cn),f=_C(),{openImage:p}=LG(),m=WG(e),h=HG(e),g=h&&!UG(e),[_,v]=G(e.previewUrl);H(()=>{v(e.previewUrl)},[e.previewUrl]),H(()=>{if(!g||e.previewUrl||!r||!m||!d?.client)return;let t=!1,n=yC(r,m,`inline`);return(async()=>{let e=f?await f.getOrFetch(n,async()=>(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url):(await d.client.files.getArtifactDownloadUrl(r,m,`inline`)).url;t||v(e)})().catch(()=>{t||v(void 0)}),()=>{t=!0}},[m,r,e.previewUrl,d?.client,g,f]);let y={attention:`bg-attention/15 text-attention`,destructive:`bg-destructive/15 text-destructive`,info:`bg-info/15 text-info`,muted:`bg-muted text-muted`,success:`bg-success/15 text-success`}[e.statusTone??`muted`],b=!!(a&&e.removable!==!1),x=t=>{t.stopPropagation(),t.preventDefault(),a?.(e.id)},S=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`absolute -end-1.5 -top-1.5 inline-flex size-5 items-center justify-center rounded-full`,`border border-border bg-background text-muted shadow-sm transition-colors hover:text-foreground`),children:t(xx,{className:`size-3`,"aria-hidden":`true`})}):null,C=b?t(o,{variant:`unstyled`,size:`none`,"aria-label":u(`agent.removeFile`,{name:e.name}),onClick:x,className:z(`-me-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted`,`transition-colors hover:bg-mixer-muted/30 hover:text-foreground`),children:t(xx,{className:`size-3.5`,"aria-hidden":`true`})}):null,w=g&&_?t(o,{type:`button`,variant:`unstyled`,size:`none`,onClick:t=>{t.stopPropagation(),t.preventDefault(),p(_,e.name)},"aria-label":e.name,title:u(`agent.enlargedView`),className:z(`group shrink-0 overflow-hidden rounded border border-border/60 p-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,i===`composer`?`size-6`:`size-24`),children:t(`img`,{src:_,alt:e.name,className:`h-full w-full object-cover transition-transform group-hover:scale-[1.05]`})}):t(h?Z_:h_,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),T=n(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5`,children:[w,t(`span`,{className:z(`truncate`,i===`composer`?`max-w-[14rem]`:`max-w-[16rem]`),children:e.name}),e.statusLabel?t(`span`,{className:z(`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium`,y),children:e.statusLabel}):null]});if(i===`composer`)return n(`span`,{title:e.name,className:z(`inline-flex min-h-8 max-w-full items-center gap-1 rounded-xl border border-border/60`,`bg-mixer-muted/15 px-2.5 py-1 text-sm text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:[t(YG,{item:e,StoreLinkComponent:c,CollectionLinkComponent:l,children:T}),C]});let E=t(`span`,{title:e.name,className:z(`inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/60 bg-mixer-muted/15`,`px-2.5 py-1.5 text-xs text-foreground/80 transition-colors`,e.href&&`hover:bg-mixer-muted/25`),children:T});return n(`span`,{className:`relative inline-flex max-w-full`,children:[t(YG,{item:e,onOpenArtifact:s,StoreLinkComponent:c,CollectionLinkComponent:l,children:E}),S]})}function ZG({items:e,artifactRunId:r,className:i,align:a=`start`,variant:s=`message`,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d}){let{t:f}=K(),[p,m]=G(!1),h=bt(),g=s===`composer`&&e.length>3,_=g&&!p?e.slice(0,3):e,v=e.length-3;return H(()=>{e.length<=3&&m(!1)},[e.length]),e.length===0?null:n(`div`,{id:h,className:z(`flex flex-wrap gap-2`,a===`end`&&`justify-end`,i),children:[_.map(e=>t(XG,{item:e,artifactRunId:r,variant:s,onRemove:c,onOpenArtifact:l,StoreLinkComponent:u,CollectionLinkComponent:d},e.id)),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,"aria-controls":h,"aria-expanded":p,onClick:()=>m(e=>!e),className:`h-8 shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,children:[!p&&n(`span`,{children:[`+`,v]}),f(p?`agent.showLess`:`agent.showMore`),t(Dh,{className:z(`size-3.5 transition-transform`,p&&`rotate-180`),"aria-hidden":`true`})]})]})}const QG=/^\s*(?:\*\*)?(attachments|uploaded artifacts):(?:\*\*)?\s*$/i,$G=/\s/,eK=[`image -`,`text extracted to `];function tK(e){let t=e;if((t.startsWith(`-`)||t.startsWith(`*`))&&(t=t.slice(1).trimStart()),!t.startsWith(`[`)||!t.endsWith(`)`))return null;let n=t.indexOf(`]`);if(n<2||t[n+1]!==`(`)return null;let r=t.slice(1,n),i=t.slice(n+2,-1);for(let e=i.lastIndexOf(`(`);e>0;e=i.lastIndexOf(`(`,e-1)){let t=e;for(;t>0&&$G.test(i[t-1]);)t--;if(t===e||t<2||i[t-1]!==`)`)continue;let n=i.slice(e+1);if(eK.some(e=>n.startsWith(e)))return{name:r,href:i.slice(0,t-1),note:n}}return i?{name:r,href:i}:null}function nK(e){let t=e.split(/\r?\n/),n=[],r=[],i=!1;for(let e of t){let t=e.trim();if(QG.test(t)){i=!0;continue}if(!i){n.push(e);continue}if(!t)continue;let a=tK(t);if(!a){i=!1,n.push(e);continue}let{name:o,href:s,note:c}=a,l=s.startsWith(`artifact:`)?s.slice(9):void 0;r.push({id:`${s}-${r.length}`,name:o,href:s,artifactPath:l,contentType:c?.toLowerCase().includes(`image`)?`image/*`:void 0})}return{body:n.join(`
1007
1007
  `).trim(),attachments:r}}function rK(e){let t=/* @__PURE__ */ new Set;for(let n of e)if(!(n.type!==J.QUESTION||n.details?._optimistic||typeof n.message!=`string`))for(let e of nK(n.message).attachments)e.href&&t.add(e.href),e.artifactPath&&t.add(e.artifactPath);return t}Q();function iK({message:e,batchData:r,isRunning:i=!1,className:a,headerClassName:s,senderClassName:c,progressBarClassName:l,itemListClassName:u,itemClassName:d,summaryClassName:f}){let[p,m]=G(!1),h=it(),{t:g}=K(),{tool_name:_,total:v,completed:y,succeeded:b,failed:x,items:S,started_at:C,completed_at:w}=r,T=v>0?y/v*100:0,E=x>0,D=y===v&&!i,O=i||!D?`running`:x===v?`error`:x>0?`warning`:`completed`,k=()=>i||!D?t(hG,{size:`sm`,color:`blue`}):O===`completed`?t(rg,{className:`size-4 text-success`}):O===`error`||O===`warning`?t(eg,{className:`size-4 text-destructive`}):t(rv,{className:`size-4 text-done`}),A=()=>O===`completed`?`border-s-success`:O===`error`?`border-s-destructive`:O===`warning`?`border-s-attention`:`border-s-info`,j=()=>E?`bg-attention`:D?`bg-success`:`bg-primary`,M=()=>{let e=JSON.stringify(r,null,2);navigator.clipboard.writeText(e).then(()=>{h({status:`success`,title:g(`agent.copiedBatchDetails`),duration:2e3})})},ee=((w?w-C:Date.now()-C)/1e3).toFixed(1);return n(`div`,{className:z(`border-s-4 shadow-md overflow-hidden bg-card text-card-foreground mb-5`,A(),a),children:[n(`div`,{role:`button`,tabIndex:0,"aria-expanded":p,className:z(`flex items-center justify-between px-4 py-2 border-b border-border/80 bg-info cursor-pointer`,s),onClick:()=>m(!p),onKeyDown:Ye(()=>m(!p)),children:[n(`div`,{className:`flex items-center gap-2`,children:[k(),t(`span`,{className:z(`text-xs font-medium text-muted`,c),children:g(`agent.batch`)}),t(`span`,{className:`text-xs text-info font-medium`,children:_}),n(`span`,{className:`text-xs text-muted`,children:[y,`/`,v]}),p?t(Dh,{className:`size-3 text-muted`}):t(Nh,{className:`size-3 text-muted cn-rtl-flip`})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-xs text-muted`,children:[ee,`s`]}),t(`span`,{className:`text-xs text-muted`,children:xO(C).format(`HH:mm:ss`)}),t(o,{variant:`ghost`,size:`xs`,onClick:e=>{e.stopPropagation(),M()},className:`text-muted`,title:g(`agent.copyBatchDetails`),children:t(Ig,{className:`size-3`})})]})]}),t(`div`,{className:z(`px-4 py-2 bg-muted/40`,l),children:n(`div`,{className:`flex items-center gap-3`,children:[t(`div`,{className:`flex-1 h-2 bg-muted rounded-full overflow-hidden`,children:t(`div`,{className:`h-full ${j()} transition-all duration-300 ease-out`,style:{width:`${T}%`}})}),n(`div`,{className:`flex items-center gap-2 text-xs`,children:[b>0&&n(`span`,{className:`text-success flex items-center gap-1`,children:[t(rg,{className:`size-3`}),b]}),x>0&&n(`span`,{className:`text-destructive flex items-center gap-1`,children:[t(eg,{className:`size-3`}),x]}),i&&y<v&&n(`span`,{className:`text-info flex items-center gap-1`,children:[t(wv,{className:`size-3 animate-spin`}),v-y]})]})]})}),p&&S.length>0&&t(`div`,{className:z(`max-h-64 overflow-y-auto`,u),children:S.map(e=>n(`div`,{className:z(`flex items-center gap-2 px-4 py-1.5 text-xs border-b border-border last:border-b-0 hover:bg-muted`,d),children:[n(`div`,{className:`w-4 flex-shrink-0`,children:[e.status===`success`&&t(rg,{className:`size-3 text-success`}),e.status===`error`&&t(eg,{className:`size-3 text-destructive`}),e.status===`running`&&t(wv,{className:`size-3 text-info animate-spin`}),e.status===`pending`&&t(`div`,{className:`size-3 rounded-full border border-border`})]}),t(`span`,{className:`font-mono text-muted w-24 truncate flex-shrink-0`,title:e.id,children:e.id}),t(`span`,{className:`text-muted truncate flex-1`,title:e.message,children:e.message||(e.status===`pending`?g(`agent.waiting`):``)}),e.duration_ms!==void 0&&n(`span`,{className:`text-muted flex-shrink-0`,children:[(e.duration_ms/1e3).toFixed(1),`s`]})]},e.id))}),!p&&e.message&&t(`div`,{className:z(`px-4 py-2 text-xs text-muted`,f),children:e.message})]})}const aK=vt(iK,(e,t)=>e.isRunning===t.isRunning&&e.batchData.completed===t.batchData.completed&&e.batchData.succeeded===t.batchData.succeeded&&e.batchData.failed===t.batchData.failed);Q();const oK={sending:{icon:Dg,className:`text-muted/70`},received:{icon:wh,className:`text-info`},consumed:{icon:xh,className:`text-success`},failed:{icon:eg,className:`text-destructive`}};function sK(e){return e===`sending`||e===`received`||e===`consumed`||e===`failed`}function cK(e){if(e.type!==J.QUESTION&&!qU(e))return;let t=e.details?._deliveryStatus;if(sK(t))return t;if(e.details?.ack)return`consumed`}function lK(e,t){switch(t){case`sending`:return e(`agent.messageSending`);case`received`:return e(`agent.messageReceived`);case`consumed`:return e(`agent.messageConsumed`);case`failed`:return e(`agent.messageFailed`)}return t}function uK({message:e,className:n}){let{t:r}=K(),i=cK(e);if(!i)return null;let a=oK[i],o=a.icon,s=lK(r,i);return t(Ke,{description:s,asChild:!0,children:t(`span`,{"aria-label":s,className:z(`inline-flex h-5 w-5 items-center justify-center`,a.className,n),role:`img`,children:t(o,{className:`size-3.5`,"aria-hidden":`true`})})})}function dK(e){return e.content?.name||e.name}function fK({client:e,toast:t}){let n=Qt.getFixedT(null,Zt),[r,i]=G(!1),a=V(async(r,a)=>{if(r){i(!0);try{pK((await e.files.getDownloadUrlWithOptions({file:r,name:a})).url,a)}catch(e){t({status:`error`,title:n(`store.downloadFailed`),description:e instanceof Error?e.message:n(`store.failedToGetDownloadUrl`),duration:5e3})}finally{i(!1)}}},[e,t,n]),o=V((e,t)=>{e&&pK(e,t)},[]),s=V(async(t,n)=>{let r=await(`store`in e?e.store:e).rendering.render(t);if(r.download_url)pK(r.download_url,n);else if(r.file_uri)pK((await e.files.getDownloadUrlWithOptions({file:r.file_uri,name:n})).url,n);else throw Error(`No download URL or file URI in response`)},[e]);return{downloadFromContentSource:a,downloadFromUrl:o,renderDocument:V(async(e,r)=>{i(!0);try{let i=`${r.title||`document`}.${r.format}`;await s({object_id:e,format:r.format,title:r.title,pandoc_options:r.pandocOptions,use_default_template:r.useDefaultTemplate,template_path:r.templateObjectId?`store:${r.templateObjectId}`:void 0},i),t({status:`success`,title:n(`store.documentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportDocument`),duration:5e3})}finally{i(!1)}},[s,t,n]),renderContent:V(async(e,r)=>{i(!0);try{let i=`${r.title||`export`}.${r.format}`;await s({content:e,format:r.format,title:r.title,artifact_run_id:r.artifactRunId,pandoc_options:r.pandocOptions},i),t({status:`success`,title:n(`store.contentExported`),description:n(`store.successfullyExportedTo`,{format:r.format.toUpperCase()}),duration:2e3})}catch(e){t({status:`error`,title:n(`store.exportFailed`),description:e instanceof Error?e.message:n(`store.failedToExportContent`),duration:5e3})}finally{i(!1)}},[s,t,n]),isDownloading:r}}function pK(e,t){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.blob()}).then(n=>{let r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t||mK(e),i.style.display=`none`,document.body.appendChild(i),i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(r)},100)}).catch(()=>{let n=document.createElement(`a`);n.href=e,n.download=t||mK(e),n.target=`_blank`,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)})}function mK(e){try{let t=new URL(e).pathname.split(`/`);return t[t.length-1]||`download`}catch{return`download`}}function hK(e){return e!==void 0&&e>=`0`&&e<=`9`}function gK(e){return e===` `||e===` `}function _K(e){return e!==void 0&&e!==` `&&e!==` `&&e!==`
1008
1008
  `&&e!==`\r`}function vK(e,t){if(t>0&&hK(e[t-1]))return;let n=t;for(;hK(e[n]);)n++;if(n===t||e[n]!==`.`)return;n++;let r=n;for(;gK(e[n]);)n++;return n>r&&_K(e[n])?n:void 0}function yK(e,t){for(let n=t;n<e.length;n++)if(vK(e,n)!==void 0)return n;return-1}function bK(e){let t=yK(e,0);if(t===-1)return e;let n=e.slice(0,t),r=t;for(;r!==-1;){let t=yK(e,vK(e,r)??r+1);if(t===-1){n+=e.slice(r),n+=`
1009
1009
 
@@ -1051,258 +1051,243 @@ $&`)),t.includes(` - `)&&(t=t.replace(/(^|\S)\s+-\s+/g,`$1
1051
1051
  `)}`);for(let n of e.sections)t.push(`${n.label}\n${aY(n.value)}`);return t.filter(Boolean).join(`
1052
1052
 
1053
1053
  `)}async function TY(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.insetInlineStart=`-9999px`,t.style.top=`0`,document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function EY({item:e}){let r=e.kind===`command`&&e.command?CY(e):void 0,i=!r&&e.sections.length===0?e.text:void 0,a=!!(r||i||e.sections.length),o=wY(e),[s,c]=G(`idle`),l=W(void 0);return H(()=>()=>{l.current!==void 0&&window.clearTimeout(l.current)},[]),n(`div`,{className:`relative mt-2 rounded-lg border border-border/70 bg-mixer-muted/10 p-3 shadow-sm`,children:[a?t(`div`,{className:`absolute end-2 top-2`,children:t(`button`,{type:`button`,className:z(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted opacity-70 transition`,`hover:bg-mixer-muted/20 hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,s===`copied`&&`text-success opacity-100`,s===`failed`&&`text-destructive opacity-100`),onClick:()=>{TY(o).then(e=>{c(e?`copied`:`failed`),l.current!==void 0&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>c(`idle`),2e3)})},"aria-label":`Copy tool details`,title:`Copy tool details`,children:t(s===`copied`?rg:Ig,{className:`size-4`})})}):null,n(`div`,{className:z(a&&`pe-7`),children:[t(bY,{item:e,hasDetailContent:a}),r?t(`pre`,{className:`mb-3 whitespace-pre-wrap break-words font-mono text-sm leading-6 text-foreground/85`,children:r}):null,i?t(`div`,{className:`mb-3 break-words text-sm leading-6 text-foreground/75`,children:i}):null,e.sections.length>0?t(`div`,{className:`space-y-3`,children:e.sections.map(e=>t(xY,{section:e},e.key))}):null]}),s===`failed`&&a?t(`div`,{className:`mt-3 text-xs text-destructive`,children:`Copy failed`}):null]})}function DY({item:e}){let{t:r}=K(),a=!!e.decisionText,s=!a&&(e.status===`error`||e.status===`warning`),c=yY(e).length>0,l=!!(e.command||e.text||e.sections.length||c),u=e.resources.length>0,[d,f]=G(!1),p=a?void 0:e.status,m=r(d?`agent.hideDetails`:`agent.showDetails`),h=u?e.resources.map(e=>e.label).join(`, `):e.title,g=t(`span`,{className:z(`flex size-5 items-center justify-center pt-0.5`,s?`text-attention`:`text-muted`),children:t(vY,{kind:e.kind,status:p})}),_=t(Dh,{className:z(`size-4 shrink-0 text-muted opacity-50 transition-transform`,!d&&`-rotate-90`),"aria-hidden":`true`});return n(`div`,{className:`min-w-0`,children:[u?n(`div`,{className:`grid w-full grid-cols-[1.5rem_1fr_auto] items-center gap-2 text-start`,children:[g,t(PK,{resources:e.resources,workflowRunId:e.workflowRunId}),l?t(Ke,{description:m,asChild:!0,children:t(o,{variant:`ghost`,size:`xs`,className:`size-6 p-0 text-muted`,onClick:()=>f(e=>!e),"aria-expanded":d,"aria-label":`${m}: ${h}`,children:_})}):null]}):n(`button`,{type:`button`,className:z(`grid w-full grid-cols-[1.5rem_1fr_auto] gap-2 text-start outline-none transition-colors`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,l?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>l&&f(e=>!e),"aria-expanded":l?d:void 0,disabled:!l,children:[g,n(`span`,{className:`min-w-0 text-sm text-muted`,children:[t(`span`,{className:`break-words`,children:e.title}),e.decisionText?t(i,{variant:`destructive`,className:`ms-2 rounded-full shadow-sm shadow-destructive/10`,children:e.decisionText}):null]}),l?_:null]}),l&&d?t(`div`,{className:`mt-1`,children:t(EY,{item:e})}):null]})}function OY({item:e,artifactRunId:r,disableCollapse:i}){let{t:a}=K(),o=e.text??e.title,s=o.trim(),[c,l]=G(!1),u=s?s.split(/\r?\n/).length:0,d=s.length>520||u>6,f=a(c?`agent.showLess`:`agent.showMore`);return n(`div`,{className:`min-w-0 py-1`,children:[t(`div`,{"data-testid":`summary-thought-prose`,className:z(bG,d&&!i&&!c&&`[display:-webkit-box] overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:6]`),style:{overflowWrap:`anywhere`},children:t(Ft,{artifactRunId:r,components:oJ,children:o})}),d&&!i?t(`div`,{className:`mt-1.5 flex justify-end`,children:n(`button`,{type:`button`,"aria-expanded":c,className:z(`inline-flex items-center gap-1 text-sm font-medium text-muted transition-colors`,`[text-decoration:none] hover:text-foreground hover:[text-decoration:none]`,`focus-visible:text-foreground focus-visible:[text-decoration:none]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),onClick:()=>l(e=>!e),children:[f,t(Dh,{className:z(`size-4 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})}):null]})}function kY({items:e,artifactRunId:n,disablePreambleCollapse:r}){return t(`div`,{className:`mt-3`,children:t(`div`,{className:`space-y-3`,children:e.map(e=>e.isPreamble||e.kind===`think`?t(OY,{item:e,artifactRunId:n,disableCollapse:r},e.key):t(DY,{item:e},e.key))})})}function AY({text:e,artifactRunId:n,workstreamId:r}){return t(`div`,{className:`mx-auto w-full max-w-3xl px-1`,"data-workstream-id":r,children:t(`div`,{className:bG,style:{overflowWrap:`anywhere`},children:t(Ft,{artifactRunId:n,components:oJ,children:e})})})}function jY({message:e,startTimestamp:r,endTimestamp:i,className:a}){let{t:o}=K(),s=Gq(Wq(r??e.timestamp,i??e.timestamp));return n(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,a),"data-testid":`summary-stopped-message`,children:[n(`div`,{className:`flex items-center justify-end gap-2 text-sm font-medium text-muted`,children:[t(`span`,{children:o(`agent.youStoppedAfter`,{duration:s})}),t(uK,{message:e,className:`h-4 w-4`})]}),t(`div`,{className:`mt-5 border-b border-border/70`})]})}function MY({label:r,timestamp:i,durationSeconds:a,showElapsed:o,details:s,emptyDetailsLabel:c,defaultExpanded:l=!1,disablePreambleCollapse:u=!1,className:d,artifactRunId:f,onSendMessage:p,answeredToolApprovalRequestInputKeys:m,resolvedToolApprovalKeys:h}){let[g,_]=G(l),v=_J(i,o&&a===void 0),y=a??v,b=o&&i!==void 0,x=U(()=>_Y(s??[]),[s]),S=U(()=>(s??[]).filter(e=>xW(e)&&!KW(e,m??/* @__PURE__ */ new Set,h??/* @__PURE__ */ new Set)),[m,s,h]),C=x.length>0||S.length>0||!!c;return t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1`,d),children:n(`div`,{className:`border-b border-border/70 pb-3 text-sm text-muted`,children:[n(`button`,{type:`button`,className:z(`inline-flex max-w-full items-center gap-2 text-start outline-none`,`focus-visible:text-foreground focus-visible:underline focus-visible:underline-offset-4`,C?`cursor-pointer hover:text-foreground`:`cursor-default`),onClick:()=>C&&_(e=>!e),"aria-expanded":C?g:void 0,disabled:!C,children:[t(`span`,{className:`min-w-0 truncate font-medium`,children:r}),b?n(`span`,{className:`shrink-0 text-muted/75`,children:[`for `,Gq(y)]}):null,C?t(g?Dh:Nh,{className:`size-4 shrink-0 opacity-50`}):null]}),C&&g?x.length>0||S.length>0?n(e,{children:[x.length>0?t(kY,{items:x,artifactRunId:f,disablePreambleCollapse:u}):null,S.length>0?t(`div`,{className:`mt-3 space-y-3`,children:S.map(e=>{let n=e.details.ux,r=yU(n.options)&&n.options.length>0;return t(CU,{question:gW(e),options:r?n.options:void 0,variant:n.variant,multiSelect:n.multiSelect,onSelect:t=>NW(p,e,t,BW(e,t)),onMultiSelect:t=>NW(p,e,t.join(`, `)),allowFreeResponse:!r||!!n.free_response,placeholder:n.free_response?.placeholder,submitLabel:n.free_response?.submit_label,onSubmit:t=>NW(p,e,t,n.free_response?.metadata),hideBorder:!0,compact:!0,className:`my-0`,cardClassName:`bg-background/60 shadow-none`},nY(e,`work-request-input`))})}):null]}):n(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-muted`,children:[t(Ib,{className:`size-4 opacity-70`,"aria-hidden":`true`}),t(`span`,{children:c})]}):null]})})}function NY({children:e,status:r}){let i=r===`error`?`bg-destructive`:r===`warning`?`bg-attention`:r===`completed`?`bg-success`:`bg-muted`;return n(`div`,{className:`relative ps-7`,children:[t(`div`,{className:`absolute start-2 top-0 bottom-0 w-px bg-border`}),t(`div`,{className:z(`absolute start-[5px] top-4 size-2.5 rounded-full ring-4 ring-background`,i)}),e]})}var PY=class extends ut{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return console.error(`Message render error:`,e),{hasError:!0,error:e}}componentDidUpdate(e){this.state.hasError&&e.children!==this.props.children&&this.setState({hasError:!1,error:void 0})}render(){return this.state.hasError?n(`div`,{className:`border-s-4 border-s-destructive bg-destructive/10 px-4 py-2 my-2 rounded-e`,children:[t(`p`,{className:`text-sm text-destructive font-medium`,children:Qt.getFixedT(null,Zt)(`agent.failedToRenderMessage`)}),t(`p`,{className:`text-xs text-muted mt-1 truncate`,children:this.state.error?.message||`Unknown error`})]}):this.props.children}};function FY(e,t){let n=[...e.filter(e=>!FJ(e)&&!t?.includes(e.type))].sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),r=[];for(let e of n){let t=r[r.length-1];t&&iW(t,e)||t&&LY(t,e)||r.push(e)}return r}function IY({messages:r,workstreamSourceMessages:i,bottomRef:a,viewMode:s=`stacked`,isCompleted:c=!1,streamingMessages:l=/* @__PURE__ */ new Map,onSendMessage:u,onOpenArtifact:d,messageItemClassNames:f,messageStyleOverrides:p,toolCallGroupClassNames:m,hideToolCallsInViewMode:h,streamingMessageClassNames:g,batchProgressPanelClassNames:_,artifactRunId:v,agentRunId:y,hideWorkstreamTabs:b,workingIndicatorClassName:x,messageListClassName:S,StoreLinkComponent:C,CollectionLinkComponent:w,prependFriendlyMessage:T,initialRequestData:E,initialRequestSchema:D,initialRequestTitle:O,initialRequestTemplate:k,showInitialRequest:A,hiddenMessageTypes:j,disableAutoScroll:M=!1,renderRequestInputControls:ee=!0,activeWorkstream:N,onActiveWorkstreamChange:P}){v||console.warn(`[AllMessagesMixed] artifactRunId prop is missing!`);let{t:F}=K(),te=W(null),[I,ne]=G(`all`),L=N??I,R=V(e=>{N===void 0&&ne(e),P?.(e)},[N,P]),re=W(0),ie=W(null),ae=W(!1),oe=W(!1),se=l.size>0,ce=s===`sliding`;H(()=>{let e=te.current;if(!e)return;let t=()=>{if(oe.current)return;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e,i=n-t-r;ae.current=i>80};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]);let le=U(()=>{let e=0;return l.forEach(t=>{e+=t.text?.length||0}),Math.floor(e/200)},[l]),ue=V(()=>{a.current&&(oe.current=!0,a.current.scrollIntoView({behavior:se?`instant`:`smooth`}),re.current=Date.now(),requestAnimationFrame(()=>{oe.current=!1})),ie.current=null},[a,se]);H(()=>{if(r.length,l.size,M||ae.current)return;let e=Date.now()-re.current;if(e>=100)ue();else if(ie.current===null){let t=100-e;ie.current=window.setTimeout(ue,t)}return()=>{ie.current!==null&&(clearTimeout(ie.current),ie.current=null)}},[r.length,l.size,le,ue,M]);let de=ct.useMemo(()=>FY(r,j),[r,j]),fe=ct.useMemo(()=>i?FY(i,j):de,[i,j,de]),pe=ct.useMemo(()=>{let e=zq(fe);return fe.forEach(t=>{let n=RU(t)??zU(t);n&&e.set(n.workstreamId,AU(n.workstreamId,n.interaction))}),e},[fe]),me=ct.useMemo(()=>{if(L!==`all`)return pe.get(L)??OU(L)},[L,pe]),he=V(()=>{let e=te.current;e&&(oe.current=!0,typeof e.scrollTo==`function`?e.scrollTo({top:0,behavior:`smooth`}):e.scrollTop=0,requestAnimationFrame(()=>{oe.current=!1}))},[]),ge=W(L);H(()=>{ge.current!==L&&(ge.current=L,requestAnimationFrame(he))},[L,he]);let _e=V(e=>{R(e)},[R]),ve=V(()=>{R(`all`)},[R]);H(()=>{L!==`all`&&!pe.has(L)&&R(`all`)},[L,pe,R]);let ye=ct.useMemo(()=>{let e=/* @__PURE__ */ new Map;e.set(`all`,fe.length);let t=Bq(fe,`main`);return e.set(`main`,t.length),fe.forEach(t=>{let n=YU(t);n!==`main`&&e.set(n,(e.get(n)||0)+1)}),e},[fe]),be=ct.useMemo(()=>nJ(QU(de,L)),[de,L]),xe=ct.useMemo(()=>jW(be),[be]),Se=ct.useMemo(()=>IW(be),[be]),Ce=ct.useMemo(()=>GW(be),[be]),we=ct.useMemo(()=>qW(be),[be]),Te=ct.useMemo(()=>{if(ee)return;let e=XW(be);return e?SW(e):void 0},[be,ee]),Ee=ct.useCallback(e=>e.type===J.REQUEST_INPUT&&(Te===SW(e)||KW(e,Ce,Se)),[Ce,Te,Se]),De=ct.useCallback(e=>JW(e,we),[we]),Oe=ct.useMemo(()=>be.filter(e=>!De(e)),[be,De]),ke=W(Date.now()),Ae=(!!T?.trim()||SJ(E)||k!==void 0)&&(A??!0),je=U(()=>be.some(e=>e.type===J.QUESTION),[be]),Me=L===`all`&&Ae&&!je,Ne=U(()=>be.reduce((e,t)=>Math.max(e,Hq(t.timestamp)),-1/0),[be]),Pe=U(()=>be.reduce((e,t)=>GK(t)?e:Math.max(e,Hq(t.timestamp)),-1/0),[be]),Fe=U(()=>be.some(e=>RW(e)&&!KW(e,Ce,Se)),[Ce,be,Se]),Ie=U(()=>$q(be,we),[be,we]),Le=U(()=>Fe||Ie||Qq(Oe)?!1:c||!KU(Oe),[Oe,Ie,Fe,c]),Re=U(()=>{if(fe.length===0)return fe;let e=r[r.length-1];if(!e)return[];let t=fe.indexOf(e);if(t>=0)return t>=fe.length-1?fe:fe.slice(0,t+1);let n=Hq(e.timestamp);return fe.filter(e=>Hq(e.timestamp)<=n)},[fe,r]),ze=U(()=>c||zK(Re),[c,Re]),Be=U(()=>RK(Re),[Re]),{completeStreaming:Ve,incompleteStreaming:He}=ct.useMemo(()=>{let e=/* @__PURE__ */ new Map,t=[];return l.forEach((n,r)=>{eW(n,L)&&(n.startTimestamp<=Pe?e.set(r,n):n.text&&t.push({id:r,data:n}))}),{completeStreaming:e,incompleteStreaming:t}},[l,L,Pe]),Ue=ct.useMemo(()=>QJ(cq(be,Ve),Se),[be,Ve,Se]),We=ct.useMemo(()=>Ue.filter(e=>!Ee(e)&&!De(e)),[Ue,Ee,De]),Ge=U(()=>{if(He.some(({data:e})=>e.text.trim().length>0))return 1/0;let e=He.reduce((e,{data:t})=>Math.max(e,t.startTimestamp),-1/0);return Math.max(Ne,e)},[He,Ne]),Ke=ct.useMemo(()=>oq(We,Le,Ge),[We,Le,Ge]),qe=ct.useMemo(()=>BK(Ke,e=>e.type===`message`&&e.message.type===J.QUESTION,Be,ze),[Ke,Be,ze]),Je=ct.useMemo(()=>mW(fW(be,Ve,L)),[be,Ve,L]),Ye=ct.useMemo(()=>BK(Je,e=>e.type===`single`&&e.message.type===J.QUESTION,Be,ze),[Je,Be,ze]),Xe=U(()=>!Le||Qq(Oe),[Oe,Le]),Ze=U(()=>{if(!Xe||He.length>0)return!1;let e=Ke[Ke.length-1],t=Oe[Oe.length-1],n=t!==void 0&&(t.details?.display_role===`thinking`||sW(t)&&t.details?.tool_status===`completed`);return e?.type===`work`&&e.isActive&&n},[Oe,He.length,Xe,Ke]),Qe=uq(Ke,Xe,He.length>0),$e=dq(Ke)?F(`agent.preparing`):F(`agent.working`),et=be.length===0&&Ae&&Xe&&He.length===0,tt=U(()=>lq(Ke,We,ke.current),[Ke,We]),nt=W(tt),rt=W(!1),it=U(()=>{if(!Qe)return tt;let e=Hq(tt),t=Hq(nt.current);return!rt.current||e<t?tt:nt.current},[tt,Qe]);H(()=>{nt.current=it,rt.current=Qe},[it,Qe]);let at=U(()=>{let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Map;fe.forEach(e=>{let n=YU(e);t.has(n)||t.set(n,[]),t.get(n)?.push(e)});for(let[n,r]of t.entries())if(r.length>0){let t=r.some(e=>{if([J.COMPLETE,J.IDLE,J.REQUEST_INPUT,J.TERMINATED].includes(e.type))return!0;if(e.type===J.UPDATE&&e.details){let t=e.details;return t.workstream_event===`completed`||t.status===`completed`||t.status===`canceled`}return!1});e.set(n,t)}return e},[fe]);return n(`div`,{ref:te,tabIndex:0,className:`flex-1 min-h-0 h-full w-full max-w-full overflow-y-auto overflow-x-hidden px-1.5 sm:px-2.5 lg:px-3 flex flex-col relative focus:outline-none`,"data-testid":`all-messages-mixed`,"data-message-count":r.length,"data-streaming-count":l.size,"data-view-mode":s,children:[t(`style`,{children:`
1054
- /* Better vertical rhythm for markdown */
1055
- .vprose > * + * {
1056
- margin-top: 0.625rem;
1057
- }
1058
- .vprose > h1 + *,
1059
- .vprose > h2 + *,
1060
- .vprose > h3 + * {
1061
- margin-top: 0.375rem;
1062
- }
1063
- /* Tables should read like part of the conversation, not a separate app grid. */
1064
- .vprose table {
1065
- margin-top: 0.875rem;
1066
- margin-bottom: 0.875rem;
1067
- border-collapse: collapse;
1068
- width: 100%;
1069
- background: transparent;
1070
- }
1071
- .vprose th,
1072
- .vprose td {
1073
- padding: 0.5rem 0.625rem;
1074
- border: 0;
1075
- border-bottom: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
1076
- background: transparent;
1077
- text-align: left;
1078
- }
1079
- .vprose thead th {
1080
- background: transparent;
1081
- font-weight: 600;
1082
- color: var(--muted);
1083
- font-size: 0.75rem;
1084
- text-transform: none;
1085
- letter-spacing: 0;
1086
- }
1087
- .vprose tbody tr:hover {
1088
- background: transparent;
1089
- }
1090
- /* Dark mode table styles */
1091
- .dark .vprose th,
1092
- .dark .vprose td {
1093
- border-color: color-mix(in oklch, var(--border) 70%, transparent);
1094
- }
1095
- .dark .vprose thead th {
1096
- background: transparent;
1097
- color: var(--muted);
1098
- }
1099
- .dark .vprose tbody tr:hover {
1100
- background: transparent;
1101
- }
1102
- /* Horizontal rules as section dividers */
1103
- .vprose hr {
1104
- margin-top: 1rem;
1105
- margin-bottom: 1rem;
1106
- border-color: var(--border);
1107
- }
1108
- /* Better blockquote styling */
1109
- .vprose blockquote {
1110
- margin-top: 0.875rem;
1111
- margin-bottom: 0.875rem;
1112
- padding-left: 1rem;
1113
- border-left-width: 3px;
1114
- border-left-color: var(--border);
1115
- color: var(--muted);
1116
- }
1117
- /* Code blocks */
1118
- .vprose pre {
1119
- margin-top: 0.75rem;
1120
- margin-bottom: 0.75rem;
1121
- padding: 0.75rem;
1122
- border-radius: 0.5rem;
1123
- overflow-x: auto;
1124
- background-color: var(--muted-background);
1125
- color: var(--foreground);
1126
- }
1127
- .vprose pre code {
1128
- color: inherit;
1129
- }
1130
- .dark .vprose pre {
1131
- color: var(--foreground);
1132
- }
1054
+ /* Better vertical rhythm for markdown */
1055
+ .vprose > * + *:not(:where(.not-prose, .not-prose *)) {
1056
+ margin-top: 0.625rem;
1057
+ }
1058
+ .vprose > h1 + *:not(:where(.not-prose, .not-prose *)),
1059
+ .vprose > h2 + *:not(:where(.not-prose, .not-prose *)),
1060
+ .vprose > h3 + *:not(:where(.not-prose, .not-prose *)) {
1061
+ margin-top: 0.375rem;
1062
+ }
1063
+ /* Tables should read like part of the conversation, not a separate app grid. */
1064
+ .vprose table:not(:where(.not-prose, .not-prose *)) {
1065
+ margin-top: 0.875rem;
1066
+ margin-bottom: 0.875rem;
1067
+ border-collapse: collapse;
1068
+ width: 100%;
1069
+ background: transparent;
1070
+ }
1071
+ .vprose th:not(:where(.not-prose, .not-prose *)),
1072
+ .vprose td:not(:where(.not-prose, .not-prose *)) {
1073
+ padding: 0.5rem 0.625rem;
1074
+ border: 0;
1075
+ border-bottom: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
1076
+ background: transparent;
1077
+ text-align: left;
1078
+ }
1079
+ .vprose thead th:not(:where(.not-prose, .not-prose *)) {
1080
+ background: transparent;
1081
+ font-weight: 600;
1082
+ color: var(--muted);
1083
+ font-size: 0.75rem;
1084
+ text-transform: none;
1085
+ letter-spacing: 0;
1086
+ }
1087
+ .vprose tbody tr:hover:not(:where(.not-prose, .not-prose *)) {
1088
+ background: transparent;
1089
+ }
1090
+ /* Horizontal rules as section dividers */
1091
+ .vprose hr:not(:where(.not-prose, .not-prose *)) {
1092
+ margin-top: 1rem;
1093
+ margin-bottom: 1rem;
1094
+ border-color: var(--border);
1095
+ }
1096
+ /* Better blockquote styling */
1097
+ .vprose blockquote:not(:where(.not-prose, .not-prose *)) {
1098
+ margin-top: 0.875rem;
1099
+ margin-bottom: 0.875rem;
1100
+ padding-left: 1rem;
1101
+ border-left-width: 3px;
1102
+ border-left-color: var(--border);
1103
+ color: var(--muted);
1104
+ }
1105
+ /* Code blocks */
1106
+ .vprose pre:not(:where(.not-prose, .not-prose *)) {
1107
+ margin-top: 0.75rem;
1108
+ margin-bottom: 0.75rem;
1109
+ padding: 0.75rem;
1110
+ border-radius: 0.5rem;
1111
+ overflow-x: auto;
1112
+ background-color: var(--muted-background);
1113
+ color: var(--foreground);
1114
+ }
1115
+ .vprose pre code:not(:where(.not-prose, .not-prose *)) {
1116
+ color: inherit;
1117
+ }
1133
1118
 
1134
- /* Summary chat markdown: keep structure, but match the app's quieter conversation surface. */
1135
- .agent-markdown {
1136
- color: color-mix(in oklch, var(--foreground) 78%, transparent);
1137
- font-size: 0.875rem;
1138
- line-height: 1.625;
1139
- overflow-x: auto;
1140
- }
1141
- .agent-markdown > * + * {
1142
- margin-top: 0.65rem;
1143
- }
1144
- .agent-markdown p {
1145
- margin-top: 0.5rem;
1146
- margin-bottom: 0.5rem;
1147
- }
1148
- .agent-markdown h1,
1149
- .agent-markdown h2,
1150
- .agent-markdown h3,
1151
- .agent-markdown h4 {
1152
- margin-top: 1.2rem;
1153
- margin-bottom: 0.45rem;
1154
- color: var(--foreground);
1155
- font-weight: 650;
1156
- letter-spacing: 0;
1157
- line-height: 1.3;
1158
- }
1159
- .agent-markdown h1 {
1160
- font-size: 1.2rem;
1161
- }
1162
- .agent-markdown h2 {
1163
- font-size: 1.05rem;
1164
- }
1165
- .agent-markdown h3,
1166
- .agent-markdown h4 {
1167
- font-size: 0.95rem;
1168
- }
1169
- .agent-markdown h1:first-child,
1170
- .agent-markdown h2:first-child,
1171
- .agent-markdown h3:first-child,
1172
- .agent-markdown h4:first-child {
1173
- margin-top: 0;
1174
- }
1175
- .agent-markdown hr {
1176
- margin: 1.15rem 0;
1177
- border: 0;
1178
- border-top: 1px solid var(--border);
1179
- opacity: 0.65;
1180
- }
1181
- .agent-markdown ul,
1182
- .agent-markdown ol {
1183
- margin-top: 0.55rem;
1184
- margin-bottom: 0.55rem;
1185
- padding-left: 1.25rem;
1186
- }
1187
- .agent-markdown li {
1188
- margin-top: 0.2rem;
1189
- margin-bottom: 0.2rem;
1190
- padding-left: 0.1rem;
1191
- color: inherit;
1192
- }
1193
- .agent-markdown li::marker {
1194
- color: var(--muted);
1195
- }
1196
- .agent-markdown strong {
1197
- color: var(--foreground);
1198
- font-weight: 600;
1199
- }
1200
- .agent-markdown em {
1201
- color: color-mix(in oklch, var(--foreground) 72%, transparent);
1202
- }
1203
- .agent-markdown a {
1204
- color: var(--foreground);
1205
- text-decoration-color: var(--muted);
1206
- text-underline-offset: 3px;
1207
- }
1208
- .agent-markdown blockquote {
1209
- margin-top: 0.85rem;
1210
- margin-bottom: 0.85rem;
1211
- padding-left: 0.875rem;
1212
- border-left: 2px solid var(--border);
1213
- color: var(--muted);
1214
- font-style: normal;
1215
- }
1216
- .agent-markdown :not(pre) > code {
1217
- border: 1px solid var(--border);
1218
- border-radius: 0.375rem;
1219
- background: var(--muted);
1220
- color: var(--foreground);
1221
- padding: 0.1rem 0.35rem;
1222
- font-size: 0.8125em;
1223
- font-weight: 500;
1224
- }
1225
- .agent-markdown pre {
1226
- margin-top: 0.85rem;
1227
- margin-bottom: 0.85rem;
1228
- max-height: 32rem;
1229
- overflow: auto;
1230
- border: 1px solid var(--border);
1231
- border-radius: 0.75rem;
1232
- background: var(--muted);
1233
- color: var(--foreground);
1234
- padding: 0.875rem;
1235
- font-size: 0.8125rem;
1236
- line-height: 1.55;
1237
- }
1238
- .agent-markdown pre code {
1239
- border: 0;
1240
- background: transparent;
1241
- color: inherit;
1242
- padding: 0;
1243
- font-size: inherit;
1244
- }
1245
- .agent-markdown table {
1246
- display: table;
1247
- width: 100%;
1248
- max-width: 100%;
1249
- margin: 0.9rem 0 1rem;
1250
- border: 0;
1251
- border-collapse: collapse;
1252
- border-spacing: 0;
1253
- font-size: 0.8125rem;
1254
- table-layout: fixed;
1255
- background: transparent;
1256
- }
1257
- .agent-markdown thead {
1258
- background: transparent;
1259
- }
1260
- .agent-markdown th,
1261
- .agent-markdown td {
1262
- border: 0;
1263
- border-bottom: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
1264
- background: transparent;
1265
- padding: 0.55rem 0.75rem;
1266
- text-align: left;
1267
- vertical-align: top;
1268
- overflow-wrap: anywhere;
1269
- word-break: normal;
1270
- white-space: normal;
1271
- }
1272
- .agent-markdown th {
1273
- color: var(--muted);
1274
- font-size: 0.75rem;
1275
- font-weight: 600;
1276
- letter-spacing: 0;
1277
- text-transform: none;
1278
- white-space: nowrap;
1279
- }
1280
- .agent-markdown td {
1281
- color: inherit;
1282
- }
1283
- .agent-markdown th + th,
1284
- .agent-markdown td + td {
1285
- padding-inline-start: 1.75rem;
1286
- }
1287
- .agent-markdown th:first-child,
1288
- .agent-markdown td:first-child {
1289
- min-width: 0;
1290
- width: auto;
1291
- white-space: normal;
1292
- }
1293
- .agent-markdown col {
1294
- width: var(--agent-markdown-table-column-width);
1295
- }
1296
- .agent-markdown tr:last-child td {
1297
- border-bottom: 0;
1298
- }
1299
- .agent-markdown tbody tr:nth-child(even) {
1300
- background: transparent;
1301
- }
1302
- .agent-markdown tbody tr:hover {
1303
- background: transparent;
1304
- }
1305
- `}),s===`stacked`&&t(`div`,{className:z(`sticky top-0 z-10`,b&&`hidden`),children:t(Rq,{workstreams:pe,activeWorkstream:L,onSelectWorkstream:_e,count:ye,completionStatus:at})}),ce&&L!==`all`&&me&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,title:F(`agent.backToMainAgent`),"aria-label":F(`agent.backToMainAgent`),onClick:ve,children:t(Jm,{className:`size-4`,"aria-hidden":`true`})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:me})]})}),be.length===0&&He.length===0&&!Ae&&!(ce&&Qe)?L===`all`&&Xe?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(AJ,{label:F(`agent.preparing`),timestamp:ke.current,className:x})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:F(L===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:z(`flex-1 flex flex-col justify-start w-full max-w-full`,ce?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,S),children:[Me&&t(kJ,{data:E,schema:D,title:O,template:k,prependFriendlyMessage:T,timestamp:be[0]?.timestamp??Date.now(),isSummaryView:ce,messageItemClassNames:f,messageStyleOverrides:p,StoreLinkComponent:C,CollectionLinkComponent:w},`initial-request`),et&&t(AJ,{label:$e,timestamp:it,className:x}),s===`stacked`?n(e,{children:[Ye.map((e,n)=>{let r=n===Ye.length-1;if(e.type===`resource_summary`)return t(IK,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!WU.includes(n.type)&&!i;return h?.includes(s)?null:t(NY,{status:e.toolStatus,children:t(PY,{children:t(jq,{...m,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,m?.rootClassName),headerClassName:z(`px-3 py-2`,m?.headerClassName),itemHeaderClassName:z(`hover:bg-mixer-muted/20`,m?.itemHeaderClassName)})})},rY(e))}if(e.type===`streaming`)return t(NY,{children:t(HK,{...g,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},rY(e));{let i=e.message;if(Ee(i)||De(i))return null;if(qU(i))return t(NY,{children:t(jY,{message:i,startTimestamp:iY(Ye,n)??i.timestamp,endTimestamp:i.timestamp})},nY(i,`stopped`));let a=!c&&r&&!WU.includes(i.type);return Vq(i)?t(PY,{children:t(aK,{message:i,batchData:i.details,isRunning:!i.details.completed_at,..._})},`batch-${i.details.batch_id}-${i.timestamp}`):t(NY,{status:`message`,children:t(PY,{children:t(kK,{...f,message:i,showPulsatingCircle:a,onSendMessage:u,onOpenArtifact:d,requestInputAnswered:YW(i,xe),cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,f?.cardClassName),headerClassName:z(`px-3 py-2`,f?.headerClassName),contentClassName:z(`bg-transparent`,f?.contentClassName),messageStyleOverrides:p,StoreLinkComponent:C,CollectionLinkComponent:w,feedbackAgentRunId:y})})},nY(i))}}),He.map(({id:e,data:n})=>t(NY,{children:t(HK,{...g,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},`streaming-incomplete-${e}`)),Xe&&He.length===0&&!et&&t(NY,{children:n(`div`,{className:z(`flex items-center gap-2 py-2 text-sm text-muted`,x),children:[t(hG,{size:`sm`,color:`blue`}),t(`span`,{children:F(`agent.working`)})]})})]}):n(e,{children:[qe.map(e=>{if(e.type===`resource_summary`)return t(IK,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`work`){if(h?.includes(s))return null;let n=Xq(e.messages);return t(MY,{label:Zq(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:Wq(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:x,onSendMessage:u,answeredToolApprovalRequestInputKeys:Ce,resolvedToolApprovalKeys:Se},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(jY,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},nY(e.message,`stopped-summary`));let n=e.message;return Ee(n)||De(n)?null:Vq(n)?t(PY,{children:t(aK,{message:n,batchData:n.details,isRunning:!n.details.completed_at,..._})},nY(n,`batch`)):t(PY,{children:t(bJ,{message:n,onSendMessage:u,onOpenArtifact:d,onSelectWorkstream:_e,requestInputAnswered:YW(n,xe),StoreLinkComponent:C,CollectionLinkComponent:w,feedbackAgentRunId:y})},nY(n,`summary`))}),He.map(({id:e,data:n})=>t(AY,{text:n.text,workstreamId:n.workstreamId,artifactRunId:v},`streaming-incomplete-${e}`)),Ze&&t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1 text-sm text-muted`,x),"data-testid":`post-tool-thinking-indicator`,children:F(`agent.thinking`)}),Qe&&!et&&t(MY,{label:$e,status:`running`,timestamp:it,showElapsed:!0,className:x})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const LY=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},RY=ct.memo(IY);Q();function zY(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):/* @__PURE__ */ new Map}function BY(e,t){return e?.find(e=>e.cursor===t)}function VY(e,t){if(t===0||e===`live`)return`live`;let n=UC(e,t);return n>=t-1?`live`:n+1}function HY(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function UY(e){return HY(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function WY(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function GY({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=K(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=G(()=>HC(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=G(!!s),[S,C]=G(0),w=W(null),T=U(()=>KC(m,v,!0),[v,m]),E=T.displayedMessages,D=U(()=>zY(BY(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=V(e=>{let t=HC(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);H(()=>{let e=HC(v,m.length);e!==v&&O(e)},[v,m.length,O]),H(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=VY(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!KU(E),A=U(()=>XW(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=V(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??(/* @__PURE__ */ new Date()).toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;WY(`${UY(j)||`agent-chat`}-${UY(n)}.json`,t)},[e,m.length,j]),ee=V(()=>{O(VY(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:z(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(Ag,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?hy:Dy,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(QC,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(RY,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(QW,{message:A,onSendMessage:ee,isLoading:!1})]})}function KY({className:e,inline:r=!1}){return n(`div`,{className:z(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function qY(){let{client:e}=q(),[t,n]=G([]),[r,i]=G(!0),[a,o]=G(!1),s=W(0),c=V(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>Fn(e)).filter(e=>e.type===`mcp`),o=i.filter(e=>e.auth!==`none`&&e.auth!==`api_key`&&n.includes(e.id)),s=i.filter(e=>e.auth===`none`||e.auth===`api_key`),c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,u=[];for(let e of o)if(e.oauth_provider){let t=c.get(e.oauth_provider)??[];t.push(e),c.set(e.oauth_provider,t)}else if(e.oauth_app){let t=l.get(e.oauth_app)??[];t.push(e),l.set(e.oauth_app,t)}else u.push(e);for(let[e,n]of c){let i=n[0].id;for(let o of n)a.push({key:`${t.id}:provider:${e}:${o.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:o.name,representativeId:i,memberIds:[o.id],memberNames:[o.name],authType:`oauth`,oauthGrantType:r[e]?.grant_type})}for(let[e,n]of l){let r=n[0].id;for(let i of n)a.push({key:`${t.id}:oauthapp:${e}:${i.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:i.name,representativeId:r,memberIds:[i.id],memberNames:[i.name],authType:`oauth`})}for(let e of u)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`oauth`});for(let e of s)a.push({key:`${t.id}:${e.auth}:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:e.auth===`none`?`none`:`api_key`})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=/* @__PURE__ */ new Map,l=await Promise.all(a.map(async t=>{if(t.authType===`none`)return t;try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return H(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function JY(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function YY(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function XY(e){return e.authType===`none`||e.authStatus?.authenticated===!0}function ZY(e,t){return e.filter(e=>XY(e)&&!JY(e,t)).length}function QY(e,t){return e.filter(e=>XY(e)&&!JY(e,t)).map(e=>e.label)}Q();function $Y({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=K(),p=()=>{s(),u?.()};return n(GT,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(KT,{children:f(`mcpConnections.title`)}),n(qT,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(UO,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!JY(e,c),i=XY(e),a=e.authType===`oauth`&&e.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?fv:hv,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(MT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[a&&o&&!e.authStatus?t(LT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:f(`mcpConnections.checkingStatus`),children:t(UO,{className:`size-3`})}):a?t(KO,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}):t(VT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:e.authType===`none`?f(`mcpConnections.noAuthentication`):e.authType===`api_key`?f(`mcpConnections.apiKey`):f(`mcpConnections.managedByApp`)}),l&&t(BO,{size:`sm`,value:r,onChange:t=>l(YY(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}Q();function eX({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=K(),{groups:u,loading:d,statusLoading:f,reload:p}=qY(),[m,h]=G(!1);if(!d&&u.length===0)return null;let g=ZY(u,r),_=QY(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(LT,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(VT,{variant:`success`,children:g})]})]}),t($Y,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function tX({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=K(),{groups:s,loading:c,statusLoading:l,reload:u}=qY();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(UO,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!JY(i,e),c=XY(i),u=i.authType===`oauth`&&i.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?fv:hv,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(MT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),u&&l&&!i.authStatus?t(LT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:o(`mcpConnections.checkingStatus`),children:t(UO,{className:`size-3`})}):u?t(KO,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}):t(VT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:i.authType===`none`?o(`mcpConnections.noAuthentication`):i.authType===`api_key`?o(`mcpConnections.apiKey`):o(`mcpConnections.managedByApp`)}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(BO,{size:`sm`,value:s,onChange:t=>r(YY(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function nX({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=K(),{groups:c,loading:l,statusLoading:u,reload:d}=qY(),[f,p]=G(!1);if(!l&&c.length===0)return null;let m=ZY(c,r);return n(e,{children:[t(yO,{align:`left`,trigger:t(LT,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(bO,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(VT,{variant:`success`,children:m})]})}),t($Y,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function rX(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details,r=n?.status_reason;if(r===un)return;if(r===dn)return{...typeof n?.budget_limit_usd==`number`&&{limitUsd:n.budget_limit_usd},...typeof n?.budget_reported_usd==`number`&&{reportedUsd:n.budget_reported_usd},...typeof n?.budget_estimated_usd==`number`&&{estimatedUsd:n.budget_estimated_usd},requestId:`${e[t].workflow_run_id}:${e[t].timestamp}`,usedUnits:typeof n?.budget_used_units==`number`?n.budget_used_units:void 0,limitTokens:typeof n?.budget_limit_tokens==`number`?n.budget_limit_tokens:void 0}}}function iX(e){let t=Math.round((e.limitTokens??0)/2/1e4)*1e4;return Math.max(1e5,t)}function aX(e){let t=e.replace(/[\s,_]/g,``);if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:void 0}function oX(e,t=`main`){let n=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0;for(let r=e.length-1;r>=0;r--){let i=e[r];if((i.workstream_id||`main`)!==t)continue;let a=i.details;if(!a||!n(a.budget_limit_tokens)||!n(a.budget_used_units))continue;if(a.budget_limit_tokens<=0)return;let o={limitTokens:a.budget_limit_tokens,remainingTokens:Math.max(0,a.budget_limit_tokens-a.budget_used_units),incomplete:a.accounting_status===`incomplete`};if(a.budget_mode!==`dollar`)return o;if(n(a.budget_limit_usd)&&n(a.budget_reported_usd)&&n(a.budget_estimated_usd))return{...o,limitUsd:a.budget_limit_usd,remainingUsd:Math.max(0,a.budget_limit_usd-a.budget_reported_usd-a.budget_estimated_usd)}}}Q();const sX=`stop`;function cX({client:e,agentRunId:n,pause:r,onStop:i,disabled:a=!1,onBudgetRequest:o,renderBudgetRequest:s}){let{t:c}=K(),l=it(),[u,d]=G(!1),[f,p]=G(),m=W(!1),h=W(!1),g=W(!1),_=r.limitUsd!==void 0&&(r.reportedUsd??0)+(r.estimatedUsd??0)>=r.limitUsd,v=Math.max(1,Math.ceil((r.limitUsd??0)/2)),y=_?v:iX(r),b=!!(o||s);H(()=>(g.current=!a,()=>{g.current=!1}),[a]);let x=V(async(t,r=`tokens`)=>{if(a||!g.current||m.current)return!1;if(!Number.isFinite(t)||t<=0||(r===`tokens`?!Number.isSafeInteger(t):!Number.isSafeInteger(Math.round(t*1e9))))return p(RangeError(c(r===`usd`?`agent.budgetPause.usdHelp`:`agent.budgetPause.invalidAmount`))),!1;m.current=!0,p(void 0),d(!0);try{return await e.agents.allocateBudget(n,r===`usd`?{additional_usd:t}:{additional_tokens:t}),!0}catch(e){return m.current=!1,d(!1),p(e),b||(console.error(`Failed to add token budget`,e),l({status:`error`,title:c(`agent.budgetPause.allocateFailed`),description:e instanceof Error?e.message:c(`agent.unknownError`),duration:4e3})),!1}},[n,e,a,b,c,l]),S=U(()=>({agentRunId:n,pause:r,suggestedTokens:iX(r),...r.limitUsd!==void 0&&{suggestedUsd:v,allocateUsd:e=>x(e,`usd`)},allocateBudget:x,stop:a?void 0:i,disabled:a,isSubmitting:u,error:f}),[n,r,v,x,a,i,u,f]);if(H(()=>{!o||a||h.current||(h.current=!0,Promise.resolve().then(()=>{if(g.current)return o(S)}).catch(e=>{g.current&&p(e)}))},[a,o,S]),b)return s?.(S)??null;let C=e=>{let t=_&&/^\d+(?:\.\d{1,9})?$/.test(e.trim())?Number(e):aX(e);if(t===void 0){l({status:`warning`,title:c(_?`agent.budgetPause.usdHelp`:`agent.budgetPause.invalidAmount`),duration:4e3});return}x(t,_?`usd`:`tokens`)},w=r.usedUnits===void 0?void 0:Math.round(r.usedUnits).toLocaleString(),T=r.limitTokens===void 0?void 0:Math.round(r.limitTokens).toLocaleString(),E=_?c(`agent.budgetPause.usdUsage`,{reported:(r.reportedUsd??0).toFixed(4),estimated:(r.estimatedUsd??0).toFixed(4),limit:r.limitUsd}):w&&T?c(`agent.budgetPause.descriptionWithUsage`,{used:w,limit:T}):c(`agent.budgetPause.description`),D=[{id:`allocate`,label:_?c(`agent.budgetPause.usdAdd`,{amount:y}):c(`agent.budgetPause.addOption`,{amount:y.toLocaleString()}),description:c(_?`agent.budgetPause.usdHelp`:`agent.budgetPause.amountHelp`)},...i?[{id:sX,label:c(`agent.budgetPause.stop`)}]:[]];return t(EU,{"data-agent-budget-pause-overlay":!0,children:t(DU,{question:`**${c(_?`agent.budgetPause.usdTitle`:`agent.budgetPause.title`)}**\n\n${E}`,options:D,onSelect:e=>{e===sX?i?.():x(y,_?`usd`:`tokens`)},allowFreeResponse:!0,placeholder:c(_?`agent.budgetPause.usdPlaceholder`:`agent.budgetPause.customAmountPlaceholder`),submitLabel:c(`agent.budgetPause.customAmountSubmit`),onSubmit:C,icon:t(Jb,{className:`size-4`}),isLoading:a||u})})}const lX=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,uX=/(^|\/)process\/(history|state)(\/|$)/,dX=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function fX(e){if(lX.test(e)||uX.test(e))return!0;let t=e.split(`/`).pop()??e;return dX.some(e=>e.test(t))}function pX(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function mX(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function hX(e,t,n=0,r=!1){let[i,a]=G([]),[o,s]=G(!1),[c,l]=G(null),[u,d]=G(0),f=W(0),p=V(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>mX(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);H(()=>{p()},[p,n,u]);let m=U(()=>r?i:i.filter(e=>!fX(e)),[i,r]),h=U(()=>pX(m),[m]),g=i.length-m.length,_=V(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}function gX(){return _X||=import(`react-pdf`).then(e=>{let{pdfjs:t}=e;return t.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${t.version}/build/pdf.worker.min.mjs`,e}),_X}var _X,vX,yX,bX=Y((()=>{vX=_t(()=>gX().then(({Document:e})=>({default:e}))),yX=_t(()=>gX().then(({Page:e})=>({default:e})))}));function xX({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(wv,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted`})})}function SX({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=G(!0),[f,p]=G(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(xX,{className:`py-4`,size:`md`}),t(ft,{fallback:null,children:t(vX,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(yX,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(xX,{className:`py-4`,size:`sm`})})})})]})}function CX({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=G(0),[s,c]=G(!0),[l,u]=G(null),[d,f]=G(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||!e||s,error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(AX.Provider,{value:h,children:e?t(ft,{fallback:t(xX,{className:`py-4`,size:`md`}),children:t(vX,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(xX,{className:`py-4`,size:`md`}),children:r((e,n)=>t(yX,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(xX,{className:`py-4`,size:`sm`})},e))})}):t(xX,{className:`py-4`,size:`md`})})}function wX(){return yt(AX)}function TX({pageNumber:e,width:n,className:r}){let i=wX(),a=i?.pageDimensions?.aspectRatio??jX,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(xX,{size:`md`})}):t(`div`,{className:r,children:t(yX,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(xX,{className:`py-4`,size:`sm`})})})}function EX({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=jX,rootMargin:s=`200px 0px`}){let c=W(null),[l,u]=G(!1);H(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200,f=l?t(yX,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(xX,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted text-xs`,children:e})});return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:f,onSelect:i})})}function DX(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function OX({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=G(null),[_,v]=G({start:0,end:Math.min(15,a)}),[y,b]=G(null),x=W(null),S=V(e=>{g(e)},[]),C=V(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(jX),d?.(jX)}},[d,m]),w=y??jX,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(H(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),H(()=>{let e=u?.current||DX(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(xX,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(ft,{fallback:t(xX,{className:`py-4`,size:`md`}),children:t(vX,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(xX,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(EX,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(xX,{className:`py-4`,size:`md`})})})})}function kX({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=G(0),[f,p]=G(!0),[m,h]=G(null);return H(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(xX,{className:`py-8`,size:`lg`}),t(ft,{fallback:null,children:t(vX,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(yX,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(xX,{className:`py-8`,size:`md`})})})})]})}var AX,jX,MX=Y((()=>{Q(),bX(),AX=pt(null),jX=210/297}));function NX({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:l,className:u,compact:d=!1,headerExtra:f}){let{t:m}=K(),h=W(null),g=W(null),[_,v]=G(void 0),[y,b]=G(RX),[x,S]=G(IX),[C,w]=G(null),T=W(null),E=_?Math.round(_*y/100):void 0,D=V(()=>{let e=LX.findIndex(e=>e>=y);e===-1&&(e=LX.length-1);let t=Math.min(e+1,LX.length-1);b(LX[t])},[y]),O=V(()=>{let e=LX.findIndex(e=>e>=y);e===-1&&(e=LX.length-1);let t=Math.max(e-1,0);b(LX[t])},[y]),k=V(()=>{b(RX)},[]),A=V(e=>e+(d?28:48),[d]),j=V((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);H(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=W(!1),ee=W(null),N=W(y);H(()=>{N.current!==y&&(N.current=y,ee.current={targetPage:s},M.current=!0)},[y,s]),H(()=>{let e=g.current,t=ee.current;if(t&&e&&C){ee.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let P=W(!1);H(()=>{let e=g.current;if(e&&C&&!P.current){if(s>1){P.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else P.current=!0}},[C,s]);let F=W(s);return H(()=>{let e=g.current;if(e&&C&&F.current!==s){F.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),H(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(F.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:ot(`flex flex-col items-stretch`,d?`gap-y-1`:`gap-y-2`,u),children:[n(`div`,{className:ot(`relative flex items-center justify-center px-2`,d?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},title:m(`pdf.previousPage`),children:t(Zh,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(FX,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<LX[LX.length-1],canZoomOut:y>LX[0]}),f&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),f]})]}),t(`div`,{className:`absolute end-2`,children:t(PX,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:ot(`flex flex-col items-center flex-1 overflow-y-auto px-2`,d?`gap-1`:`gap-2`),children:t(OX,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:l,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:ot(`hover:bg-muted rounded-md w-full`,d?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:ot(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(p,{className:ot(`text-muted font-semibold`,d?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:ot(`flex items-center justify-center`,d?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},title:m(`pdf.nextPage`),children:t(zh,{className:`size-4`})})})]})}function PX({currentPage:e,totalPages:r,onChange:i}){let{t:a}=K(),o=W(null),[s,c]=G(String(e));H(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function FX({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=K();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,title:l(`pdf.zoomOut`),children:t(ey,{})}),n(`span`,{className:`text-xs text-muted min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,title:l(`pdf.zoomIn`),children:t(Ay,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,title:l(`pdf.fitToWidth`),className:e===RX?`text-muted/40`:void 0,children:t(Iv,{})})]})}var IX,LX,RX,zX=Y((()=>{Q(),MX(),IX=210/297,LX=[50,75,100,125,150,200,300],RX=100}));function BX({object:e,url:r,source:i,className:a}){let{t:s}=K(),{client:c}=q(),[l,u]=G(1),[d,f]=G(r||``),[p,m]=G(!r),[h,g]=G(0),[_,v]=G(!1);H(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),H(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(Me,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),title:s(`pdf.closeFullscreen`),children:t(xx,{className:`size-4`})})}),t(NX,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(NX,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(o,{title:s(`pdf.fullscreen`),tooltipPlacement:`bottom`,variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),children:t(Nv,{className:`size-4`})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}var VX=Y((()=>{Q(),zX()})),HX=/* @__PURE__ */ yr({UniversalDocumentViewer:()=>pZ});function UX(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function WX(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function GX(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function KX(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function qX(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function JX(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function YX(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function XX(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function ZX(e){return[`tsx`,`jsx`].includes(e.extension)}function QX(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function $X({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function eZ({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(x_,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function tZ(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function nZ(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function rZ(e){return e.split(`/`).pop()||e}function iZ(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function aZ(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function oZ(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function sZ(e){return Array.isArray(e)?e.length:0}function cZ(e){try{let t=iZ(JSON.parse(e));if(!t)return;let n=iZ(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:aZ(n.width),height:aZ(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:aZ(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:iZ(t.timings_ms),error:t.error}}catch{return}}async function lZ(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function uZ({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${rZ(i)}`:n}function dZ({metadata:e}){if(!e)return null;let r=aZ(e.timings_ms?.total_before_cleanup),a=sZ(e.console_errors)+sZ(e.page_errors)+sZ(e.failed_requests)+sZ(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),oZ(r)&&n(`div`,{children:[`Total `,oZ(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function fZ({context:e}){let{client:r}=q(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=G({isLoading:!1}),d=V(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,rZ(e),t)).url,[a,r]);return H(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=nZ(e,`.png`),r=nZ(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=cZ(await lZ(await d(r,`inline`),rZ(r))),o=uZ({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(Z_,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(wv,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(dZ,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t($X,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(dZ,{metadata:l.metadata}),t($X,{content:c,extension:e.extension})]})]})]})}function pZ({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!1,onDownload:p}){let{client:m}=q(),h=U(()=>UX(e),[e]),g=U(()=>WX(h),[h]),[_,v]=G(e.url),[y,b]=G(e.content),[x,S]=G(null),[C,w]=G(!1),[T,E]=G(null),[D,O]=G(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=V(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=V(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${UX(e)}: ${n.statusText}`);return n.text()},[j]),ee=l||M,N={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},P=a.find(e=>e.canRender(N)),F=!P&&(KX(N)||JX(N)||YX(N)||XX(N)),te=!P&&(GX(N)||qX(N)),I={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},ne=!P&&!N.url?s.find(e=>e.target===`pdf`&&e.canConvert(I)):void 0,L=!P&&!N.url&&(QX(N)||!!ne)&&(!!ne||!!u);H(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(F||te||L){w(!0);try{if(L){let e=ne?await ne.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(F){let e=await ee(n);t||b(e);return}if(te){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,ee,L,F,te,D,j,ne,e,k]);let R={...N,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},re;return re=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(wv,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(eg,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:R.reload,children:`Retry`})]}):P?tZ(P,R):(GX(R)||x?.contentType===`application/pdf`)&&R.url?t(BX,{url:R.url,className:`h-full`}):qX(R)&&R.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:R.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):KX(R)?t(`div`,{className:`vprose prose prose-sm max-w-none px-5 py-4`,children:t(Ft,{artifactRunId:e.artifact?.runId,components:d,children:R.content||``})}):JX(R)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:R.content||``}):YX(R)?t(`div`,{className:`px-4 py-2`,children:t(Bt,{xml:R.content||``,collapsible:!0})}):ZX(R)?t(fZ,{context:R}):XX(R)?t($X,{content:R.content,extension:g}):QX(R)&&!ne&&!u?t(eZ,{message:`This file needs a PDF rendition before it can be previewed.`}):t(eZ,{message:`Preview is not available for this file type.`}),n(`div`,{className:z(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),R.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:R.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:z(`min-h-0 flex-1 overflow-auto`,i),children:re})]})}var mZ=Y((()=>{Q(),VX()}));Q();const hZ=ct.lazy(async()=>({default:(await Promise.resolve().then(()=>(mZ(),HX))).UniversalDocumentViewer})),gZ=/* @__PURE__ */ new Set([`md`,`markdown`,`mdx`,`txt`]);function _Z(e){let t=e.split(`.`).pop()?.toLowerCase();return t!==void 0&&gZ.has(t)}function vZ(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function yZ({node:e,depth:r,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let{t:u}=K(),[d,f]=G(!1),p=l||d;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>f(e=>!e),"aria-expanded":p,children:[p?t(Dh,{className:`size-3.5 shrink-0 text-muted`}):t(Nh,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(p?D_:A_,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:vZ(e.name)})]}),p&&e.children.map(e=>t(yZ,{node:e,depth:r+1,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let m=c===e.path;return n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(x_,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),t(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 shrink-0 p-0`,onClick:()=>s(e.path),disabled:m,"aria-label":u(`agent.download`),title:u(`agent.download`),children:m?t(wv,{className:`size-3.5 animate-spin text-info`}):t(Gg,{className:`size-3.5`})})]})}function bZ(e){return e.reduce((e,t)=>t.isDirectory?e+bZ(t.children):e+1,0)}function xZ(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=xZ(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function SZ(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function CZ(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function wZ({runId:e,path:r,onBack:i,onDownload:a,refreshKey:s,refreshDetails:c,onSendMessage:l}){let{t:u}=K(),[d,f]=G(`components`),[p,m]=G(`idle`);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-2 py-1`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToArtifacts`),title:u(`agent.backToArtifacts`),children:t(Jm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[t(`span`,{className:`truncate text-sm font-medium`,title:r,children:r.split(`/`).pop()}),p===`saving`?t(Ke,{description:u(`agent.savingWorkingCopy`),asChild:!0,children:t(wv,{className:`size-3.5 shrink-0 animate-spin text-muted`,"aria-label":u(`agent.savingWorkingCopy`)})}):p===`saved`?t(Ke,{description:u(`agent.savedToWorkingCopy`),asChild:!0,children:t(wh,{className:`size-3.5 shrink-0 text-success`,"aria-label":u(`agent.savedToWorkingCopy`)})}):null]}),n(`div`,{className:`flex items-center gap-0.5`,children:[t(o,{variant:d===`components`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`components`),"aria-label":u(`agent.blockMode`),"aria-pressed":d===`components`,title:u(`agent.blockMode`),children:t(Gy,{className:`size-4`})}),t(o,{variant:d===`document`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`document`),"aria-label":u(`agent.editMode`),"aria-pressed":d===`document`,title:u(`agent.editMode`),children:t(vy,{className:`size-4`})})]}),t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>a(r),"aria-label":u(`agent.download`),title:u(`agent.download`),children:t(Gg,{className:`size-4`})})]}),t(Et,{runId:e,path:r,viewMode:d,refreshKey:s,refreshDetails:c,readOnly:!l,onAction:e=>{if(!l)return;let t=e.anchor.block_type.replaceAll(`_`,` `);l(e.comment?.trim()||u(`agent.editedSelectionMessage`,{blockType:t}),{editing_action:e})},onSaveStatusChange:m,onSendMessage:l?e=>l(e):void 0,className:z(`relative min-h-0 flex-1`,d===`document`?`overflow-hidden`:`overflow-y-auto px-6 py-5`)})]})}function TZ({icon:e,children:r,action:i}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function EZ({runId:r,refreshKey:i=0,refreshDetails:a,selectedPath:s,onSelectedPathChange:c,onSendMessage:l}){let{t:u}=K(),{client:d}=q(),[f,m]=G(!1),{tree:h,flatFiles:g,totalCount:_,systemHiddenCount:v,isLoading:y,error:b,refresh:x}=hX(d,r,i,f),[S,C]=G(null),[w,T]=G(null),[E,D]=G(``),[O,k]=G(null),A=s===void 0?O:s,j=V(e=>{s===void 0&&k(e),c?.(e)},[c,s]),M=E.trim(),N=U(()=>xZ(h,M),[h,M]),P=U(()=>bZ(N),[N]),F=bt(),te=V(async e=>{if(r){C(e);try{let{url:t}=await d.files.getArtifactDownloadUrl(r,e,`attachment`);SZ(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{C(null)}}},[d,r]),I=V(e=>{if(_Z(e)){j(e);return}T(e)},[j]),ne=r&&w?{title:w.split(`/`).pop()||w,fileName:w.split(`/`).pop()||w,contentType:CZ(w),artifact:{runId:r,path:w}}:null;return r?y&&_===0?t(TZ,{icon:t(wv,{className:`mb-2 size-6 animate-spin`}),children:u(`agent.loadingArtifacts`)}):b?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(ee,{title:`Fail to load Artifacts`,className:`w-full`,action:x,actionLabel:n(e,{children:[t(zy,{className:`size-3.5 me-1.5`}),u(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:b}),` `,t(`br`,{})]})}):_===0?t(TZ,{icon:t(oy,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:x,children:[t(zy,{className:`size-3.5 me-1.5`}),u(`agent.refresh`)]}),children:u(`agent.noArtifactsYet`)}):A?t(wZ,{runId:r,path:A,refreshKey:i,refreshDetails:a,onBack:()=>j(null),onDownload:e=>void te(e),onSendMessage:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[M?`${P} of ${g.length} file${g.length===1?``:`s`}`:`${g.length} file${g.length===1?``:`s`}`,!f&&v>0?` · ${v} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Fe,{size:`sm`,value:f,onChange:m,children:t(`span`,{className:`text-xs text-muted`,children:u(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:x,disabled:y,className:`h-6 w-6 p-0`,children:t(zy,{className:`size-3.5 ${y?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:F,className:`sr-only`,children:u(`form.filter`)}),t(R,{id:F,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:E,onChange:D,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:N.length>0?t(`div`,{className:`min-w-0`,children:N.map(e=>t(yZ,{node:e,depth:0,runId:r,onOpen:I,onDownload:te,downloadingPath:S,forceExpanded:!!M},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(!f&&v>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),ne&&n(ce,{isOpen:!!w,onClose:()=>T(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(de,{show:!1,children:ne.fileName}),t(le,{className:`h-full max-h-none p-0`,children:t(ct.Suspense,{fallback:t(p,{className:`h-full`,children:t(wv,{className:`size-6 animate-spin text-muted`})}),children:t(hZ,{source:ne,className:`h-full`,showHeader:!0,onDownload:()=>w&&void te(w)})})})]})]}):t(TZ,{icon:t(oy,{className:`mb-2 size-8`}),children:`No run selected`})}const DZ=ct.memo(EZ);Q();function OZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kZ(e){if(!OZ(e))return;let t=e.browseruse??e.browser_use;if(!OZ(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&(n.url||n.title||n.screenshot||n.raw_screenshot))return n}function AZ(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=kZ(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function jZ(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function MZ(e){return e?e.replace(/_/g,` `):`browser`}function NZ({state:e,runId:r,className:a,compact:o}){let{t:s}=K(),{client:c}=q(),l=_C(),{openImage:u}=LG(),[d,f]=G(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=U(()=>p&&jZ(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return H(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=jZ(p);try{let n=yC(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:z(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(ry,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,MZ(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Zg,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(Z_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:z(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(ry,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:MZ(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(Z_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Zg,{className:`size-3`})})]})]})}Q();function PZ({documentId:e,title:r,onBack:i,onUpdateDocumentTitle:a,refreshKey:s,runId:c}){let{client:l}=q(),{t:u}=K(),[d,f]=G(null),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(null),y=V(async e=>{m(!0),g(null);try{let[t,n]=await Promise.all([l.store.objects.getObjectText(e),l.store.objects.retrieve(e)]);f(t.text??null);let r=n.name;v(r),r&&a?.(e,r)}catch(e){let t=e instanceof Error?e.message:u(`agent.failedToLoadDocument`);g(t),f(null)}finally{m(!1)}},[l,a,u]);return H(()=>{y(e)},[e,s,y]),n(`div`,{className:`h-full overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between gap-1 px-2 py-1 border-b border-border/60 shrink-0`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToDocuments`),title:u(`agent.backToDocuments`),children:t(Jm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[t(h_,{className:`size-4 text-muted shrink-0`}),t(`span`,{className:`truncate text-sm font-medium`,title:_||r,children:_||r||u(`agent.document`)})]}),n(nr,{href:`/store/objects/${e}#overview`,topLevelNav:!0,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(Ke,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Zg,{className:`size-4`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:p?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(wv,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:u(`agent.loadingDocument`)})]}):h?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:h}):d?t(`div`,{className:`vprose prose prose-sm max-w-none`,children:t(Ft,{artifactRunId:c,children:d})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(h_,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:u(`agent.noContentAvailable`)})]})})]})}const FZ=ct.memo(PZ);Q();function IZ({documents:r,activeDocumentId:i,onSelectDocument:a,onUpdateDocumentTitle:s,refreshKey:c,runId:l}){let{t:u}=K(),[d,f]=G(``),p=bt(),m=d.trim().toLocaleLowerCase(),h=U(()=>m?r.filter(e=>e.title.toLocaleLowerCase().includes(m)):r,[r,m]),g=V(()=>a(null),[a]),_=i?r.find(e=>e.id===i):void 0;return i?t(FZ,{documentId:i,title:_?.title,onBack:g,onUpdateDocumentTitle:s,refreshKey:c,runId:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[t(`span`,{className:`text-xs text-muted`,children:m?u(`agent.documentsFiltered`,{visible:h.length,total:r.length}):u(`agent.documentCount`,{count:r.length})}),r.length>5&&n(e,{children:[t(`label`,{htmlFor:p,className:`sr-only`,children:u(`form.filter`)}),t(R,{id:p,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:d,onChange:f,clearable:!0})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:h.length>0?t(`div`,{className:`min-w-0`,children:h.map(e=>n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,onClick:()=>a(e.id),title:e.title,children:[t(h_,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.title})]}),n(nr,{href:`/store/objects/${e.id}#overview`,topLevelNav:!0,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(Ke,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Zg,{className:`size-3.5`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]},e.id))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(`agent.noMatchingDocuments`)})})]})}const LZ=ct.memo(IZ);Q();function RZ({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:l=()=>{}}){let{t:u}=K();if(!i)return null;let d=e.plan||[],f=d.length,m=d.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=f>0?Math.round(m/f*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return d.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(wg,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:u(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:u(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:u(`agent.tasksCompleted`,{completed:m,total:f})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":u(`agent.olderPlan`),title:u(`agent.olderPlan`),children:t(Ah,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():u(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.max(0,c-1)),disabled:c<=0,"aria-label":u(`agent.newerPlan`),title:u(`agent.newerPlan`),children:t(Nh,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":m,"aria-label":u(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:d.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let d=vg,f=`text-muted`;c===`in_progress`?(d=Dg,f=`text-info`):c===`completed`&&(d=rg,f=`text-success`);let p=u(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:z(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(d,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(d.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:u(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=vg,a=`text-muted`,o=u(`agent.pending`);return r===`in_progress`?(i=Dg,a=`text-info`,o=u(`agent.inProgress`)):r===`completed`&&(i=rg,a=`text-success`,o=u(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:z(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const zZ=ct.memo(RZ);Q();function BZ({icon:e,children:r}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function VZ({files:e}){let{t:r}=K(),a=U(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case vn.UPLOADING:case vn.PROCESSING:return t(wv,{className:`size-4 animate-spin text-info`});case vn.READY:return t(rg,{className:`size-4 text-success`});case vn.ERROR:return t(hg,{className:`size-4 text-destructive`});default:return t(h_,{className:`size-4 text-muted`})}},s=e=>{switch(e){case vn.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case vn.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case vn.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case vn.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(BZ,{icon:t(h_,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var HZ=class extends ct.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:z(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function UZ({workstreams:e,messages:r,runId:a}){let{t:s}=K(),{client:c}=q(),l=it(),u=U(()=>AZ(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=V(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=V(async e=>{try{let t=await $U(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(BZ,{icon:t(lv,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?OU(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(HZ,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:z(`mt-2 size-2 shrink-0 rounded-full`,IU(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:OU(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(HZ,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(NZ,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(xg,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(Ag,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}function WZ({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onUpdateDocumentTitle:m,docRefreshKey:h=0,runId:g,processingFiles:_,showArtifacts:v=!1,artifactRefreshKey:y=0,artifactRefreshDetails:b,selectedArtifactPath:x,onSelectedArtifactPathChange:S,onSendMessage:C,payloadContent:w,conversationContent:T,onClose:E,defaultTab:D,activeTab:O,onTabChange:k}){let{t:A}=K(),[j,M]=G(D||`plan`),ee=O??j,N=e=>{M(e),k?.(e)},P=!u&&c.length>0,F=d.length>0,te=_?_.size>0:!1,I=V((e,n)=>t(HZ,{title:A(`agent.panelRenderError`,{name:e}),description:A(`agent.panelRenderErrorDescription`),children:n}),[A]),ne={name:`conversation`,label:`Conversation`,content:T?I(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:T})):null,is_allowed:!!T},L=[...T?[ne]:[],{name:`plan`,label:A(`agent.plan`),content:I(A(`agent.plan`),e?t(zZ,{plan:e,workstreamStatus:r||/* @__PURE__ */ new Map,isOpen:!0,onClose:E,plans:i,activePlanIndex:a,onChangePlan:s}):t(BZ,{icon:t(lv,{className:`mb-2 size-8`}),children:A(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:P?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):A(`agent.workstreams`),content:I(A(`agent.workstreams`),t(UZ,{workstreams:c,messages:l,runId:g})),is_allowed:!u},{name:`documents`,label:F?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):A(`agent.documents`),content:I(A(`agent.documents`),d.length>0&&p?t(LZ,{documents:d,activeDocumentId:f??null,onSelectDocument:p,onUpdateDocumentTitle:m,refreshKey:h,runId:g}):t(BZ,{icon:t(h_,{className:`mb-2 size-8`}),children:A(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:te?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):A(`agent.uploads`),content:I(A(`agent.uploads`),t(VZ,{files:_})),is_allowed:!0},{name:`artifacts`,label:A(`agent.artifacts`),content:I(A(`agent.artifacts`),t(DZ,{runId:g,refreshKey:y,refreshDetails:b,selectedPath:x,onSelectedPathChange:S,onSendMessage:C})),is_allowed:v},{name:`payload`,label:A(`agent.payload`),content:w?I(A(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:w})):null,is_allowed:!!w}],R=L.filter(e=>e.is_allowed===void 0||e.is_allowed===!0);return n(Ve,{tabs:L,current:ee,onTabChange:N,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(me,{tabs:R,current:ee,onTabChange:N,className:`min-w-0 flex-1`}),!T&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:E,title:`Close Right Panel`,children:t(xx,{className:`size-4`})})]}),t(Ue,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const GZ=ct.memo(WZ);function KZ(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i){if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}}return t}function qZ(e,t){let[n,r]=G([]),[i,a]=G(0),[o,s]=G(/* @__PURE__ */ new Map),[c,l]=G(t),[u,d]=G(!1),f=W(-1),p=W(/* @__PURE__ */ new Set);H(()=>{e.length===0&&(r([]),a(0),s(/* @__PURE__ */ new Map),d(!1),f.current=-1,p.current.clear())},[e.length]);let m=V(e=>{let n=e[e.length-1];n&&(n.type===J.TERMINATED?l(!1):l(t?!0:n.type===J.REQUEST_INPUT))},[t]);return H(()=>{if(e.length===0)return;let t=f.current+1;if(t>=e.length){m(e);return}let n=!1,i=[],o=[];for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let r=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!p.current.has(r)){p.current.add(r),n=!0,i.push({plan:e,timestamp:r});let t=/* @__PURE__ */ new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),o.push({timestamp:r,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}f.current=e.length-1,n&&i.length>0&&(r(e=>[...[...i].reverse(),...e]),a(0),d(!0),o.length>0&&s(e=>{let t=new Map(e);for(let e of o)t.set(e.timestamp,e.statusMap);return t})),m(e)},[e,m]),H(()=>{if(n.length===1&&!u&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{d(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[n.length,u]),{plans:n,activePlanIndex:i,setActivePlanIndex:a,workstreamStatusMap:o,showInput:c,showSlidingPanel:u,setShowSlidingPanel:d}}function JZ(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function YZ(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function XZ(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function ZZ(e){if(e&&typeof e==`object`&&`status`in e)return typeof e.status==`number`?e.status:void 0}function QZ(e){return e?.streaming_id_scope===`workflow_run`}function $Z(e){return[J.COMPLETE,J.IDLE,J.TERMINATED,J.REQUEST_INPUT].includes(e.type)}function eQ(e){if(e.type===J.STREAMING_CHUNK)return!1;if(e.type===J.UPDATE&&typeof e.details?.event_class==`string`)return!0;if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||$Z(e)||Mn(e).length>0}function tQ(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function nQ(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===J.QUESTION||qU(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?JZ(t,`consumed`):t;if(n){let i=e.filter(e=>e.type!==t.type&&!qU(e)||!e.details?._optimistic||YZ(e)!==n);return UU(i,r),i}if(t.type===J.QUESTION){let n=e.filter(e=>e.type===J.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return UU(r,t),r}}}let n=[...e];return UU(n,t),n}function rQ(e){let t=e.details,n=XZ(t,`streaming_id`),r=XZ(t,`activity_id`);return n&&QZ(t)?n:r??n}function iQ(e){let t=e.details,n=XZ(t,`streaming_id`),r=XZ(t,`activity_id`),i=[];return n&&QZ(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function aQ(e,t,n){let[r,i]=G([]),[a,o]=G(!1),[s,c]=G(`loading`),[l,u]=G(null),[d,f]=G(null),p=W(n);p.current=n;let[m,h]=G(/* @__PURE__ */ new Map),[g,_]=G(0),v=V(()=>_(e=>e+1),[]),y=W(null),b=W(0),[x,S]=G(/* @__PURE__ */ new Map),C=W(/* @__PURE__ */ new Map),w=W(null),[T,E]=G(!1),D=W(null),O=V(()=>{let e=w.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),w.current=null)},[]),k=V(()=>{C.current.size>0&&(S(new Map(C.current)),E(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>E(!1),50)),w.current=null},[]);return H(()=>{o(!KU(r))},[r]),H(()=>{HU(`stream state`,{agentRunId:t,messageCount:r.length,streamingCount:x.size,initialHistoryStatus:s,isCompleted:a,lastDeliveredTs:b.current,first:tQ(r[0]),last:tQ(r[r.length-1])})},[t,s,a,r,x.size]),H(()=>{let n=y.current!==t;y.current=t,n&&(i([]),c(`loading`),u(null),f(null),S(/* @__PURE__ */ new Map),h(/* @__PURE__ */ new Map),b.current=0);let r=new AbortController,a=n?void 0:b.current||void 0;return HU(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:g}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(HU(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),u(e.status?.toUpperCase()??null),f(e.first_workflow_run_id??null))}).catch(e=>{if(!r.signal.aborted){let n=ZZ(e);n===404?HU(`agent run internals not available yet`,{agentRunId:t,status:n}):qn.logger.warn(`Failed to check agent run status; continuing with the message stream`,{vertesia:{agent_run_id:t,status:n,error:e}})}}),e.agents.streamMessages(t,e=>{if(r.signal.aborted)return;let n=!!(e.timestamp&&e.timestamp<=b.current);if(n||p.current?.(e),HU(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>b.current&&(b.current=e.timestamp),e.type===J.STREAMING_CHUNK){let t=e.details,n=rQ(e);if(!n)return;let r=C.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);C.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),w.current===null&&(document.hidden?w.current={mode:`timeout`,id:window.setTimeout(k,16)}:w.current={mode:`raf`,id:requestAnimationFrame(k)});return}if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){n||h(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===J.THOUGHT||e.type===J.ANSWER){let t=iQ(e);if(t.length>0){for(let e of t)C.current.delete(e);S(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===J.COMPLETE||e.type===J.IDLE)&&C.current.size>0&&k(),eQ(e)&&i(t=>nQ(t,e))},a,r.signal,{closeOnIdle:!1,onHistoryLoaded:e=>{if(r.signal.aborted)return;let n=e.filter(eQ),o,s=-1/0;for(let t of e)if(t.timestamp&&t.timestamp>b.current&&(b.current=t.timestamp),t.type===J.SYSTEM){let e=t.details;if(e?.system_type===`file_processing`&&e.files){let n=t.timestamp??-1/0;(!o||n>=s)&&(o=e,s=n)}}o&&h(new Map(o.files.map(e=>[e.id,e]))),HU(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:tQ(e[0]),last:tQ(e[e.length-1])}),c(e.length>0?`has_messages`:`empty`),n.length>0&&i(e=>n.reduce((e,t)=>nQ(e,t),e))},onHistoryError:e=>{r.signal.aborted||(HU(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),c(`error`))}}).then(()=>{if(!r.signal.aborted)return HU(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(HU(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),u(e.status?.toUpperCase()??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{r.signal.aborted||(HU(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{HU(`stream cleanup`,{agentRunId:t,streamNonce:g}),r.abort(),O(),C.current.clear(),D.current&&=(clearTimeout(D.current),null)}},[t,g,e.agents,k,O]),H(()=>{let e=()=>{!document.hidden&&C.current.size>0&&(O(),k())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[k,O]),{messages:r,streamingMessages:x,isCompleted:a,initialHistoryStatus:s,debugChunkFlash:T,addOptimisticMessage:V(e=>{i(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:V((e,t)=>{i(n=>n.map(n=>n.details?._optimistic&&YZ(n)===e?JZ(n,t):n))},[]),removeOptimisticMessages:V(e=>{i(t=>t.filter(t=>!e(t)))},[]),reconnect:v,agentRunStatus:l,workflowRunId:d,serverFileUpdates:m}}function oQ(e){if(typeof e==`string`&&e.trim().length>0)return e}function sQ(e,t){let n=oQ(e.revision_root_id)||oQ(e.revision_root)||oQ(e.root_document_id)||oQ(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=oQ(r.root);if(e)return e}return t}function cQ(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function lQ(e){let[t,n]=G([]),[r,i]=G(null),[a,o]=G(!1),[s,c]=G(0),l=W(-1);return H(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),H(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=oQ(e.document_id),r=oQ(e.updated_document_id)||t,a=e.title;if(r){let s=sQ(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>cQ(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:V(()=>{o(!1)},[]),selectDocument:V(e=>{i(e)},[]),openDocInPanel:V(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:V((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function uQ(e){return e.type.startsWith(`image/`)}function dQ(e){if(uQ(e)&&typeof URL<`u`&&URL.createObjectURL)return URL.createObjectURL(e)}function fQ(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function pQ(e,t,n,r,i){let a=Qt.getFixedT(null,Zt),[o,s]=G(/* @__PURE__ */ new Map),[c,l]=G(/* @__PURE__ */ new Set),u=W(/* @__PURE__ */ new Set),d=W(/* @__PURE__ */ new Map),f=W(t),p=W(o);p.current=o;let m=W(n);m.current=n;let h=V(e=>{let t=d.current.get(e);t&&(fQ(t),d.current.delete(e))},[]);H(()=>{if(f.current!==t){f.current=t,d.current.forEach(fQ),d.current.clear(),s(/* @__PURE__ */ new Map);let e=/* @__PURE__ */ new Set;u.current=e,l(e)}},[t]),H(()=>()=>{d.current.forEach(fQ),d.current.clear()},[]);let g=U(()=>{let e=/* @__PURE__ */ new Map;if(o.forEach((t,n)=>{c.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(t.consumed_at){e.delete(n);return}if(!c.has(n)){let r=o.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),i&&i.size>0)for(let[t,n]of e)(n.reference&&i.has(n.reference)||n.artifact_path&&i.has(n.artifact_path))&&e.delete(t);return e},[o,c,n,i]);return{processingFiles:g,hasProcessingFiles:U(()=>Array.from(g.values()).some(e=>e.status===vn.UPLOADING||e.status===vn.PROCESSING),[g]),handleFileUpload:V(async n=>{for(let i of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,o=`files/${i.name}`,c=dQ(i);c&&d.current.set(n,c);let l={id:n,name:i.name,content_type:i.type||`application/octet-stream`,size:i.size,status:vn.UPLOADING,started_at:Date.now(),preview_url:c};s(e=>new Map(e).set(n,l));try{if(await e.agents.uploadArtifact(t,o,i),s(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=vn.PROCESSING,r.artifact_path=o,r.reference=`artifact:${o}`),t}),u.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:i.name,content_type:i.type||`application/octet-stream`,reference:`artifact:${o}`,artifact_path:o})}catch(e){if(u.current.has(n))continue;s(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=vn.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:a(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,a]),removeProcessingFile:V(async n=>{l(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),u.current=t,t}),s(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),h(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:a(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,h,a,r]),clearProcessingFiles:V(()=>{d.current.forEach(fQ),d.current.clear(),l(e=>{let t=new Set(e);for(let e of m.current.keys())t.add(e);for(let e of p.current.keys())t.add(e);return u.current=t,t}),s(/* @__PURE__ */ new Map)},[])}}Q();function mQ({activeWorkstreams:r,onSelectWorkstream:i,className:a}){let{t:s}=K(),[c,l]=G(!1),[u,d]=G(!1),f=bt(),p=U(()=>r.filter(e=>e.status===`running`||e.status===`canceling`),[r]),m=c?p:p.slice(0,3),h=Math.max(0,p.length-m.length),g=p.length>3;return H(()=>{g||l(!1)},[g]),p.length===0?null:t(`div`,{className:z(`mx-auto mb-2 w-full max-w-3xl px-1`,a),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2 px-1 font-medium`,children:[t(eh,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:s(`agent.activeWorkstreams`,{count:p.length})})]}),n(o,{variant:`ghost`,size:`icon`,onClick:()=>d(!u),title:s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`),children:[t(u?Ih:Dh,{className:`size-4`}),s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`)]})]}),u?null:n(e,{children:[t(`div`,{id:f,className:`flex flex-col gap-0.5`,children:m.map(r=>{let a=AU(r.workstream_id,r.interaction),s=n(e,{children:[t(`span`,{className:z(`size-1.5 shrink-0 rounded-full`,IU(r.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:a}),r.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:OU(r.phase)})]});return i?n(o,{type:`button`,variant:`ghost`,className:`h-auto min-w-0 justify-start gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,onClick:()=>{l(!1),i(r.workstream_id)},children:[s,t(Nh,{className:`ms-auto size-3.5 shrink-0 rtl:rotate-180`,"aria-hidden":`true`})]},r.launch_id||r.workstream_id):t(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,children:s},r.launch_id||r.workstream_id)})}),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-fit shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,"aria-expanded":c,"aria-controls":f,onClick:()=>l(e=>!e),children:[!c&&n(`span`,{children:[`+`,h]}),s(c?`agent.showLess`:`agent.showMore`),t(Dh,{className:z(`size-3.5 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})]})]})})}const hQ=new ar({strict:!1,validateFormats:!1});function gQ(e){if(e!==kn.virtual_lb&&e!==kn.virtual_mediator&&e!==kn.test)return e}var _Q=class{_listeners=/* @__PURE__ */ new Set;snapshot;constructor(e){this.snapshot=new vQ(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},vQ=class e{vertesia;_interactive=!0;_debug_mode=!1;_evaluate;_final_verification=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_budget_tokens;_budget_usd;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_inference_profile;_availableInferenceProfiles;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._inference_profile=this._inference_profile,t._availableInferenceProfiles=this._availableInferenceProfiles,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._evaluate=this._evaluate,t._final_verification=this._final_verification,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._budget_tokens=this._budget_tokens,t._budget_usd=this._budget_usd,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get evaluate(){return this._evaluate}set evaluate(e){e!==this._evaluate&&(this._evaluate=e,this.onStateChanged())}get final_verification(){return this._final_verification}set final_verification(e){e!==this._final_verification&&(this._final_verification=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get budget_tokens(){return this._budget_tokens}set budget_tokens(e){e!==this._budget_tokens&&(this._budget_tokens=e,this.onStateChanged())}get budget_usd(){return this._budget_usd}setBudgetUsd(e,t){let n=e!==void 0&&Number.isFinite(e)&&e>0&&e<=(2**53-1)/1e9;this._budget_usd=n?e:void 0,n&&(this._budget_tokens??=t??1e6),this.onStateChanged()}get budget(){return this._budget_usd===void 0?this._budget_tokens!=null&&this._budget_tokens>0?{limit_tokens:this._budget_tokens}:void 0:{mode:`dollar`,limit_usd:this._budget_usd,limit_tokens:this._budget_tokens}}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?mn.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._inference_profile=e.config?.inference_profile===void 0?e.config?.environment||e.config?.model?null:void 0:e.config.inference_profile,this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._budget_usd=e.budget?.mode===`dollar`?e.budget.limit_usd:void 0;let o=e.budget?.limit_tokens;this._budget_tokens=o!==void 0&&o>0?o:void 0,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?Nn(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e).catch(()=>{this.environment=void 0})}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=e?gQ(e.provider):void 0,n=this.interaction?.runtime?.model;this._model=n&&t&&In(n,t)?n:e?.default_model&&t&&In(e.default_model,t)?e.default_model:``}this.onStateChanged()}}get inference_profile(){return this._inference_profile}setInferenceProfile(e){this._inference_profile=e,this.onStateChanged()}setAvailableInferenceProfiles(e){this._availableInferenceProfiles=e,this.onStateChanged()}get inferenceProfileError(){if(this._inference_profile){if(!this._availableInferenceProfiles)return`Wait for inference profiles to load, or choose another configuration.`;if(!this._availableInferenceProfiles.includes(this._inference_profile))return`This inference profile is unavailable. Choose the default, Ad hoc, or another profile.`}}get inferenceConfig(){return this._inference_profile===null?{inference_profile:null,environment:this.environment?.id,model:this.model||void 0,model_options:this.model_options}:this._inference_profile?{inference_profile:this._inference_profile}:{}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setEvaluate(e){this.evaluate=e}setFinalVerification(e){this.final_verification=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setBudgetTokens(e){this.budget_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setDraftData(e){this._data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._evaluate=void 0,this._final_verification=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._budget_tokens=void 0,this._budget_usd=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._inference_profile=void 0,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema)&&(this._inputValidator={validate:hQ.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema});let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const yQ=pt(void 0);function bQ({children:e}){let{client:n}=q(),[r]=G(()=>new _Q(n)),i=Ct(r.subscribe,r.getSnapshot);return t(yQ.Provider,{value:i,children:e})}function xQ(){let e=yt(yQ);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}Q();function SQ(){let{router:e}=ir();return t=>{let n=t.startsWith(`/`)?e.getTopRouter().navigator.addStickyParams(t):t;return window.open(n,`_blank`,`noopener,noreferrer`),n}}function CQ({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=K(),O=SQ(),k=r===`compact`,A=u===`sliding`?`stacked`:`sliding`,j=D(`agent.verbose`),M=D(`agent.summary`),ee=A===`stacked`?j:M,N=n(`div`,{className:z(k?`flex flex-row items-center gap-1 lg:flex-col`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(wg,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),k?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(A),className:`size-8 rounded-lg`,title:ee,"aria-label":ee,children:t(A===`stacked`?Gy:Hv,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(Gy,{className:`size-3.5`}),j]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(Hv,{className:`size-3.5`}),M]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,title:D(`agent.rewind.label`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(hh,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),c&&t(o,{type:`button`,size:k?`icon`:`xs`,variant:`ghost`,onClick:()=>O(`/store/agent-runner/${c}`),title:D(`agent.openInNewTab`),className:z(`transition-all duration-200 rounded-md`,k&&`size-8 rounded-lg`),children:t(Zg,{className:`size-4`})}),b&&t(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:`ghost`,onClick:b,title:D(`agent.startNewConversation`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:t(zv,{className:z(`size-4`,r===`full`&&`me-1.5`)})}),t(wQ,{compact:k,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(xx,{className:`size-4`})})]});return r===`compact`?t(bQ,{children:t(`div`,{className:z(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:N})}):t(bQ,{children:n(`div`,{className:z(`flex flex-wrap items-center justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(eh,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:z(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-done shadow-md`:`bg-muted`)})]})]}),N]})})}function wQ({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=K(),_=it(),{client:v}=q(),y=xQ();return t(T,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(Jg,{className:`size-4`})}),children:n(ae,{label:`Actions`,children:[n(oe,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(Ig,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(oe,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(Ig,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(oe,{onClick:p,children:[t(ev,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(oe,{onClick:()=>{l?l():$U(v,r).then(e=>window.open(e,`_blank`))},children:[t(Ag,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(oe,{onClick:f,children:[t(Ag,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(oe,{onClick:u,children:[t(Ag,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(oe,{onClick:c,children:[t(xx,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(oe,{onClick:async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},children:[t(H_,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(oe,{onClick:async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},variant:`destructive`,children:[t(xx,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function TQ(e){return typeof e==`object`&&!!e&&`value`in e}function EQ(e){return TQ(e)?e.value:e}function DQ(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:EQ(e));if(e.multiple)return e.value.map(EQ);let t=e.value[0];return t===void 0?void 0:EQ(t)}function OQ(e,t,n){e.query[t]=n}function kQ(e){let t=new Set(e);return e=>t.has(e)}const AQ=[`sys`,`app`,`tmp`],jQ=/^[0-9a-fA-F]{24}$/;function MQ(e){let t=e.indexOf(`:`),n=t>0?e.slice(0,t):void 0;return n&&AQ.includes(n)?{type:n,label:e.slice(t+1)}:{label:e}}function NQ(e,...t){let n=[e?.name,...t].filter(e=>!!e),r=n.find(e=>!jQ.test(e));if(r)return r;let i=n[0];return i?`Deleted interaction (~${i.slice(-8)})`:void 0}function PQ(e){return!!e&&e.version===0&&e.status===bn.unknown}function FQ({interaction:e,className:n}){let r=`success`;switch(e.status){case bn.published:r=`success`;break;case bn.archived:r=`destructive`;break;case bn.code:r=`info`}let a=[e.version?`v${e.version}`:``,e.status&&e.status!==bn.unknown?e.status:``].filter(Boolean).join(` `);return a?t(i,{variant:r,className:n,children:a}):null}function IQ({interaction:r,fallbacks:a=[],fallbackNode:o=null}){let s=NQ(r,...a);if(!s)return t(e,{children:o});let{type:c,label:l}=MQ(s),u=!!r&&!PQ(r);return n(e,{children:[l,(c||u)&&n(`div`,{className:`flex items-center mt-1.5 shrink-0 gap-2`,children:[c&&t(i,{variant:`secondary`,children:c}),u&&r&&t(FQ,{interaction:r})]})]})}function LQ(e,t){return NQ(e,t)??t}function RQ({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),{type:o,label:s}=MQ(LQ(a,r));return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:s}),o&&t(i,{variant:`secondary`,className:`text-xs w-fit`,children:o}),a&&t(FQ,{interaction:a,className:`text-xs w-fit`})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>LQ(e.find(e=>e._id===t),t).toLowerCase().includes(n.toLowerCase())}}function zQ(e){return`${e._id} (${e.count})`}function BQ(e){return`${e.name} (${e.count})`}function VQ({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:zQ(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function HQ({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return VQ({buckets:e,name:t,placeholder:n,type:r,multiple:i})}Q();const UQ={},WQ={},GQ={};function KQ(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function qQ(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw KQ(n)||delete e[t],n}),e[t]=r),r}function JQ(e){let{client:t}=q();return Ze(()=>qQ(UQ,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function YQ(e){let{client:t}=q();return Ze(()=>qQ(WQ,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function XQ(e){let{client:t}=q();return Ze(()=>qQ(GQ,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function ZQ(){return t(`div`,{className:`size-8`})}function QQ({size:e,color:n,className:r}){return t(Pe,{size:e,color:n,className:`p-1.5 ${r||``}`,children:t(h,{className:`size-full`})})}function $Q({showTitle:e=!1,size:i=`md`}){let{t:a}=K();return t(d$,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function e$({showTitle:e=!1,size:r=`md`}){let{t:i}=K();return t(d$,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(ox,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function t$({accountId:r,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),s=n(e,{children:[t(`div`,{children:o(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,r]})]});return t(d$,{title:o(`user.serviceAccount`),description:s,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(QQ,{size:a,color:`bg-attention text-attention`}),i&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[o(`user.serviceAccount`),` : ~`,r.slice(-6)]})]})})}function n$({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.agentOnBehalfOf`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]});return t(d$,{title:`Email Agent`,description:c,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(QQ,{size:o,color:`bg-attention text-attention`,className:`border-2 border-background`}),t(r,{name:i,size:o,className:`border-2 border-background`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[`Agent (`,i,`)`]})]})})}function r$({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=K(),d=a===`user`&&o,f=a===`apikey`&&o,p=JQ(o||``),m=XQ(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`,y=l?u(`user.schedule`,{title:v}):v,b=n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-foreground text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]});return t(d$,{title:y,description:b,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(QQ,{size:c,color:`bg-info text-info`,className:`border-2 border-background`}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-background`}),g&&t(r,{name:`API`,color:`bg-secondary text-secondary`,size:c,className:`border-2 border-background`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function i$({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(s$,{title:e,message:qe(n),color:`bg-destructive text-destructive`,showTitle:r,size:i})}function a$({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=K();return t(s$,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function o$({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=K();if(!e)return t(s$,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case Tn.User:return t(l$,{userId:a[1],showTitle:n,size:r});case Tn.Group:return t(c$,{userId:a[1],showTitle:n,size:r});case`system`:return t($Q,{showTitle:n,size:r});case Tn.ServiceAccount:return t(t$,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case Tn.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(r$,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case Tn.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(r$,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(n$,{email:a[1],showTitle:n,size:r});case Tn.ApiKey:return t(u$,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(e$,{showTitle:n,size:r});break;default:return t(i$,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function s$({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(d$,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function c$({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=K(),{data:o,error:s}=YQ(e);if(s)return KQ(s)?t(a$,{showTitle:r,size:i,color:`bg-info text-info`}):t(i$,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(ZQ,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(d$,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(lx,{className:`size-6 text-info`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function l$({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=JQ(e);if(c)return KQ(c)?t(a$,{showTitle:i,size:a,color:`bg-info text-info`}):t(i$,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(ZQ,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(d$,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-info`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function u$({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=XQ(e);if(c)return KQ(c)?t(a$,{showTitle:i,size:a,color:`bg-done text-done`}):t(i$,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(ZQ,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-done text-done`,size:a}),d=n(ze,{className:`bg-card text-card-foreground table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]});return t(d$,{title:l,description:d,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function d$({title:e,description:r,children:i}){return n(ge,{hover:!0,children:[t(ve,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(_e,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-base font-semibold`,children:e}),r]})})]})}function f$({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(o$,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function p$({buckets:e,name:t,placeholder:n}){return f$({buckets:e,name:t,placeholder:n})}Q();const m$=kQ([`id`,`run_kind`,`interaction`,`status`,`initiated_by`,`start`,`end`,`evaluation`,`feedback`]);function h$(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(HQ({buckets:e.kinds||[],name:`run_kind`,placeholder:`Kind`})),t.push(RQ({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(HQ({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push(p$({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push(HQ({buckets:e.evaluation||[],name:`evaluation`,placeholder:`Evaluation`})),t.push(HQ({buckets:e.feedback||[],name:`feedback`,placeholder:`Feedback`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function g$(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!m$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search()}}function _$({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=s??u,p=c??d,m=W(!1),h=W(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=h$(e),_=l??g,v=U(()=>g$(r),[r]);return H(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(te,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} runs`:`Loading runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(zy,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}var v$=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const y$=pt({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function b$({children:e}){let{store:n,project:r}=q(),[i,a]=G(),[o,s]=G(!1),c=W(!1),l=W(r?.id),u=V(async()=>{if(r&&!c.current){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new v$(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=V(async()=>(c.current=!1,u()),[u]);return H(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t(y$.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function x$(){let e=yt(y$);return H(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}const S$=kQ([`name`,`types`]);function C$(e){let{registry:t}=x$(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function w$(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!S$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search()}}function T$({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=C$(e),u=w$(r),d=i!==void 0&&a!==void 0;return t(te,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function E$({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=/* @__PURE__ */ new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}const D$=[`id`,`name`,`types`,`status`],O$=[`tags`,`created_at`,`updated_at`],k$=kQ(D$),A$=new Set(O$);function j$(e){return A$.has(e)}function M$(e){return Array.isArray(e)?e:[]}function N$(e){let{registry:t}=x$(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=E$({buckets:M$(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=HQ({buckets:M$(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:M$(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function P$(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0){if(t.value.length===1){let e=EQ(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:EQ(t.value[0]),lte:EQ(t.value[1])})}}else r=DQ(t);k$(n)?OQ(e,n,r):j$(n)&&r!==void 0&&(e.query.match={...e.query.match,[n]:r})}}),e.search()}}function F$({facets:e,search:r}){let[i,a]=G([]),o=N$(e),s=P$(r),c=tt();return t(te,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:c,children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function I$({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=q(),[o,s]=G([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};H(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(Te,{filterBy:`name`,className:i,isClearable:!0,optionLabel:BQ,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}const L$=kQ([`name`,`prompt`,`model`,`tags`]);function R$(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function z$(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!L$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search(!0)}}function B$({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=R$(e),u=z$(r),d=i!==void 0&&a!==void 0;return t(te,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function V$(e){let t=[];return t.push(HQ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function H$({facets:e,filters:r,setFilters:i}){let a=V$(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function U$(e){let t=[];return t.push(HQ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push(p$({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(HQ({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(HQ({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function W$({facets:e,filters:r,setFilters:i}){let a=U$(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const G$=kQ([`name`,`role`,`tags`]);function K$(e,t){let n=e[t];return Array.isArray(n)?n:[]}function q$(e){let t=K$(e,`role`),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.length>0){let e={name:`role`,placeholder:`Role`,type:`select`,options:t.map(e=>({label:e._id,value:e._id,count:e.count}))};n.push(e)}let r={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:K$(e,`tags`).map(e=>({label:e._id,value:e._id}))};return n.push(r),n}function J$(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!G$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search()}}function Y$({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=q$(e),u=J$(r),d=i!==void 0&&a!==void 0;return t(te,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function X$({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r),a=i?.name||r;return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:a}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}Q();const Z$=kQ([`run_ids`,`interaction`,`environment`,`tags`,`model`,`status`,`finish_reason`,`start`,`end`,`workflow_run_ids`,`workflow_ids`]);function Q$(e){return e.filter(e=>e._id!==null)}function $$(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=RQ({buckets:Q$(e.interactions),name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=X$({buckets:Q$(e.environments),name:`environment`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=HQ({buckets:Q$(e.models),name:`model`});t.push(n)}if(e.statuses){let n=HQ({buckets:Q$(e.statuses),name:`status`});t.push(n)}if(e.finish_reason){let n=HQ({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function e1(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!Z$(t.name))return;let n=t.name,r=DQ(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),OQ(e,n,r)}}),e.search()}}function t1({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=$$(e),p=e1(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(te,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(zy,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}function n1({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(Te,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:zQ,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function r1({search:e,name:n,placeholder:r,className:i}){let[a,o]=G([]);return H(()=>{e.setFilterValue(n,a)},[n,e,a]),t(re,{className:i,value:a,onChange:o,placeholder:r})}function i1(e){return`${e.name} (${e.count})`}function a1({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=G([]),{registry:s}=x$(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};H(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(Te,{filterBy:`name`,className:i,isClearable:!0,optionLabel:i1,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function o1(e){let t=[];return t.push(HQ({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function s1({facets:e,filters:r,setFilters:i}){let a=o1(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const c1=kQ([`search_term`,`status`,`initiated_by`,`start`,`end`,`has_reported_errors`]);function l1(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`search_term`,type:`text`,options:[]}),e.status){let n=HQ({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push({...n,name:`status`})}if(e.initiated_by){let n=p$({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push({...n,name:`initiated_by`})}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function u1(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!c1(t.name))return;let n=t.name,r=DQ(t);if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&OQ(e,n,t===`true`)}else typeof r==`string`&&OQ(e,n,r)}}),e.search()}}function d1({facets:e,search:r}){let[i,a]=G([]),o=l1(e),s=u1(r);return t(te,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function f1(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function p1({facets:e,filters:r,setFilters:i}){let a=f1(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}var m1=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const h1=pt(void 0);function g1(){let e=yt(h1);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function _1(){return yt(h1)}function v1({value:e,collectionId:n,children:r}){let[i,a]=G();return H(()=>{let t=new m1(e,n,{},a);a(t)},[n,e]),i&&t(h1.Provider,{value:i,children:r})}Q();const y1=pt(void 0);function b1({onFilter:e,children:n}){return t(y1.Provider,{value:e,children:n})}function x1(){return yt(y1)}const S1=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function C1({field:r,value:i,label:a,copyContent:s}){let c=x1(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(S,{content:s,className:S1}),l&&i!==void 0&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${a}`,className:S1,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(N_,{className:`size-3`})})]})}const w1=`text/csv`,T1=`image/`,E1=`application/pdf`,D1=`video/`,O1=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],k1=e=>e===w1||w1.includes(e),A1=e=>e.startsWith(T1)||T1.includes(e),j1=e=>e===E1||E1.includes(e),M1=e=>e.startsWith(D1)||D1.includes(e),N1=e=>O1.includes(e);function P1(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
1119
+ /* Summary chat markdown: keep structure, but match the app's quieter conversation surface. */
1120
+ .agent-markdown:not(:where(.not-prose, .not-prose *)) {
1121
+ color: color-mix(in oklch, var(--foreground) 78%, transparent);
1122
+ font-size: 0.875rem;
1123
+ line-height: 1.625;
1124
+ overflow-x: auto;
1125
+ }
1126
+ .agent-markdown > * + *:not(:where(.not-prose, .not-prose *)) {
1127
+ margin-top: 0.65rem;
1128
+ }
1129
+ .agent-markdown p:not(:where(.not-prose, .not-prose *)) {
1130
+ margin-top: 0.5rem;
1131
+ margin-bottom: 0.5rem;
1132
+ }
1133
+ .agent-markdown h1:not(:where(.not-prose, .not-prose *)),
1134
+ .agent-markdown h2:not(:where(.not-prose, .not-prose *)),
1135
+ .agent-markdown h3:not(:where(.not-prose, .not-prose *)),
1136
+ .agent-markdown h4:not(:where(.not-prose, .not-prose *)) {
1137
+ margin-top: 1.2rem;
1138
+ margin-bottom: 0.45rem;
1139
+ color: var(--foreground);
1140
+ font-weight: 650;
1141
+ letter-spacing: 0;
1142
+ line-height: 1.3;
1143
+ }
1144
+ .agent-markdown h1:not(:where(.not-prose, .not-prose *)) {
1145
+ font-size: 1.2rem;
1146
+ }
1147
+ .agent-markdown h2:not(:where(.not-prose, .not-prose *)) {
1148
+ font-size: 1.05rem;
1149
+ }
1150
+ .agent-markdown h3:not(:where(.not-prose, .not-prose *)),
1151
+ .agent-markdown h4:not(:where(.not-prose, .not-prose *)) {
1152
+ font-size: 0.95rem;
1153
+ }
1154
+ .agent-markdown h1:first-child:not(:where(.not-prose, .not-prose *)),
1155
+ .agent-markdown h2:first-child:not(:where(.not-prose, .not-prose *)),
1156
+ .agent-markdown h3:first-child:not(:where(.not-prose, .not-prose *)),
1157
+ .agent-markdown h4:first-child:not(:where(.not-prose, .not-prose *)) {
1158
+ margin-top: 0;
1159
+ }
1160
+ .agent-markdown hr:not(:where(.not-prose, .not-prose *)) {
1161
+ margin: 1.15rem 0;
1162
+ border: 0;
1163
+ border-top: 1px solid var(--border);
1164
+ opacity: 0.65;
1165
+ }
1166
+ .agent-markdown ul:not(:where(.not-prose, .not-prose *)),
1167
+ .agent-markdown ol:not(:where(.not-prose, .not-prose *)) {
1168
+ margin-top: 0.55rem;
1169
+ margin-bottom: 0.55rem;
1170
+ padding-left: 1.25rem;
1171
+ }
1172
+ .agent-markdown li:not(:where(.not-prose, .not-prose *)) {
1173
+ margin-top: 0.2rem;
1174
+ margin-bottom: 0.2rem;
1175
+ padding-left: 0.1rem;
1176
+ color: inherit;
1177
+ }
1178
+ .agent-markdown li:not(:where(.not-prose, .not-prose *))::marker {
1179
+ color: var(--muted);
1180
+ }
1181
+ .agent-markdown strong:not(:where(.not-prose, .not-prose *)) {
1182
+ color: var(--foreground);
1183
+ font-weight: 600;
1184
+ }
1185
+ .agent-markdown em:not(:where(.not-prose, .not-prose *)) {
1186
+ color: color-mix(in oklch, var(--foreground) 72%, transparent);
1187
+ }
1188
+ .agent-markdown a:not(:where(.not-prose, .not-prose *)) {
1189
+ color: var(--foreground);
1190
+ text-decoration-color: var(--muted);
1191
+ text-underline-offset: 3px;
1192
+ }
1193
+ .agent-markdown blockquote:not(:where(.not-prose, .not-prose *)) {
1194
+ margin-top: 0.85rem;
1195
+ margin-bottom: 0.85rem;
1196
+ padding-left: 0.875rem;
1197
+ border-left: 2px solid var(--border);
1198
+ color: var(--muted);
1199
+ font-style: normal;
1200
+ }
1201
+ .agent-markdown :not(pre) > code:not(:where(.not-prose, .not-prose *)) {
1202
+ border: 1px solid var(--border);
1203
+ border-radius: 0.375rem;
1204
+ background: var(--muted-background);
1205
+ color: var(--foreground);
1206
+ padding: 0.1rem 0.35rem;
1207
+ font-size: 0.8125em;
1208
+ font-weight: 500;
1209
+ }
1210
+ .agent-markdown pre:not(:where(.not-prose, .not-prose *)) {
1211
+ margin-top: 0.85rem;
1212
+ margin-bottom: 0.85rem;
1213
+ max-height: 32rem;
1214
+ overflow: auto;
1215
+ border: 1px solid var(--border);
1216
+ border-radius: 0.75rem;
1217
+ background: var(--muted-background);
1218
+ color: var(--foreground);
1219
+ padding: 0.875rem;
1220
+ font-size: 0.8125rem;
1221
+ line-height: 1.55;
1222
+ }
1223
+ .agent-markdown pre code:not(:where(.not-prose, .not-prose *)) {
1224
+ border: 0;
1225
+ background: transparent;
1226
+ color: inherit;
1227
+ padding: 0;
1228
+ font-size: inherit;
1229
+ }
1230
+ .agent-markdown table:not(:where(.not-prose, .not-prose *)) {
1231
+ display: table;
1232
+ width: 100%;
1233
+ max-width: 100%;
1234
+ margin: 0.9rem 0 1rem;
1235
+ border: 0;
1236
+ border-collapse: collapse;
1237
+ border-spacing: 0;
1238
+ font-size: 0.8125rem;
1239
+ table-layout: fixed;
1240
+ background: transparent;
1241
+ }
1242
+ .agent-markdown thead:not(:where(.not-prose, .not-prose *)) {
1243
+ background: transparent;
1244
+ }
1245
+ .agent-markdown th:not(:where(.not-prose, .not-prose *)),
1246
+ .agent-markdown td:not(:where(.not-prose, .not-prose *)) {
1247
+ border: 0;
1248
+ border-bottom: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
1249
+ background: transparent;
1250
+ padding: 0.55rem 0.75rem;
1251
+ text-align: left;
1252
+ vertical-align: top;
1253
+ overflow-wrap: anywhere;
1254
+ word-break: normal;
1255
+ white-space: normal;
1256
+ }
1257
+ .agent-markdown th:not(:where(.not-prose, .not-prose *)) {
1258
+ color: var(--muted);
1259
+ font-size: 0.75rem;
1260
+ font-weight: 600;
1261
+ letter-spacing: 0;
1262
+ text-transform: none;
1263
+ white-space: nowrap;
1264
+ }
1265
+ .agent-markdown td:not(:where(.not-prose, .not-prose *)) {
1266
+ color: inherit;
1267
+ }
1268
+ .agent-markdown th + th:not(:where(.not-prose, .not-prose *)),
1269
+ .agent-markdown td + td:not(:where(.not-prose, .not-prose *)) {
1270
+ padding-inline-start: 1.75rem;
1271
+ }
1272
+ .agent-markdown th:first-child:not(:where(.not-prose, .not-prose *)),
1273
+ .agent-markdown td:first-child:not(:where(.not-prose, .not-prose *)) {
1274
+ min-width: 0;
1275
+ width: auto;
1276
+ white-space: normal;
1277
+ }
1278
+ .agent-markdown col:not(:where(.not-prose, .not-prose *)) {
1279
+ width: var(--agent-markdown-table-column-width);
1280
+ }
1281
+ .agent-markdown tr:last-child td:not(:where(.not-prose, .not-prose *)) {
1282
+ border-bottom: 0;
1283
+ }
1284
+ .agent-markdown tbody tr:nth-child(even):not(:where(.not-prose, .not-prose *)) {
1285
+ background: transparent;
1286
+ }
1287
+ .agent-markdown tbody tr:hover:not(:where(.not-prose, .not-prose *)) {
1288
+ background: transparent;
1289
+ }
1290
+ `}),s===`stacked`&&t(`div`,{className:z(`sticky top-0 z-10`,b&&`hidden`),children:t(Rq,{workstreams:pe,activeWorkstream:L,onSelectWorkstream:_e,count:ye,completionStatus:at})}),ce&&L!==`all`&&me&&t(`div`,{className:`sticky top-0 z-20 -mx-2 bg-background/95 px-2 pb-2 pt-1 backdrop-blur sm:-mx-4 sm:px-4`,children:n(`div`,{className:`mx-auto flex w-full max-w-3xl items-center gap-2 border-b border-border/70 pb-3`,children:[t(o,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted hover:text-foreground`,title:F(`agent.backToMainAgent`),"aria-label":F(`agent.backToMainAgent`),onClick:ve,children:t(Jm,{className:`size-4`,"aria-hidden":`true`})}),t(`div`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:me})]})}),be.length===0&&He.length===0&&!Ae&&!(ce&&Qe)?L===`all`&&Xe?t(`div`,{className:`flex-1 px-2 py-6 sm:px-4`,children:t(AJ,{label:F(`agent.preparing`),timestamp:ke.current,className:x})}):t(`div`,{className:`flex items-center justify-center h-full text-center py-8`,children:t(`div`,{className:`flex items-center px-3 py-2 text-sm text-muted`,children:F(L===`all`?`agent.waitingForAgentResponse`:`agent.noMessagesInWorkstream`)})}):n(`div`,{className:z(`flex-1 flex flex-col justify-start w-full max-w-full`,ce?`gap-6 px-2 py-6 sm:px-4`:`gap-3 pb-4`,S),children:[Me&&t(kJ,{data:E,schema:D,title:O,template:k,prependFriendlyMessage:T,timestamp:be[0]?.timestamp??Date.now(),isSummaryView:ce,messageItemClassNames:f,messageStyleOverrides:p,StoreLinkComponent:C,CollectionLinkComponent:w},`initial-request`),et&&t(AJ,{label:$e,timestamp:it,className:x}),s===`stacked`?n(e,{children:[Ye.map((e,n)=>{let r=n===Ye.length-1;if(e.type===`resource_summary`)return t(IK,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`tool_group`){let n=e.messages[e.messages.length-1],i=e.toolStatus===`completed`||e.toolStatus===`error`||e.toolStatus===`warning`,a=!c&&r&&!WU.includes(n.type)&&!i;return h?.includes(s)?null:t(NY,{status:e.toolStatus,children:t(PY,{children:t(jq,{...m,messages:e.messages,showPulsatingCircle:a,toolRunId:e.toolRunId,toolStatus:e.toolStatus,preambleText:e.preambleText,preambleMessage:e.preambleMessage,rootClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,m?.rootClassName),headerClassName:z(`px-3 py-2`,m?.headerClassName),itemHeaderClassName:z(`hover:bg-mixer-muted/20`,m?.itemHeaderClassName)})})},rY(e))}if(e.type===`streaming`)return t(NY,{children:t(HK,{...g,text:e.text,workstreamId:e.workstreamId,isComplete:e.isComplete,timestamp:e.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},rY(e));{let i=e.message;if(Ee(i)||De(i))return null;if(qU(i))return t(NY,{children:t(jY,{message:i,startTimestamp:iY(Ye,n)??i.timestamp,endTimestamp:i.timestamp})},nY(i,`stopped`));let a=!c&&r&&!WU.includes(i.type);return Vq(i)?t(PY,{children:t(aK,{message:i,batchData:i.details,isRunning:!i.details.completed_at,..._})},`batch-${i.details.batch_id}-${i.timestamp}`):t(NY,{status:`message`,children:t(PY,{children:t(kK,{...f,message:i,showPulsatingCircle:a,onSendMessage:u,onOpenArtifact:d,requestInputAnswered:YW(i,xe),cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,f?.cardClassName),headerClassName:z(`px-3 py-2`,f?.headerClassName),contentClassName:z(`bg-transparent`,f?.contentClassName),messageStyleOverrides:p,StoreLinkComponent:C,CollectionLinkComponent:w,feedbackAgentRunId:y})})},nY(i))}}),He.map(({id:e,data:n})=>t(NY,{children:t(HK,{...g,text:n.text,workstreamId:n.workstreamId,isComplete:n.isComplete,timestamp:n.startTimestamp,artifactRunId:v,cardClassName:z(`rounded-lg border border-border bg-background/60 shadow-none`,g?.cardClassName)})},`streaming-incomplete-${e}`)),Xe&&He.length===0&&!et&&t(NY,{children:n(`div`,{className:z(`flex items-center gap-2 py-2 text-sm text-muted`,x),children:[t(hG,{size:`sm`,color:`blue`}),t(`span`,{children:F(`agent.working`)})]})})]}):n(e,{children:[qe.map(e=>{if(e.type===`resource_summary`)return t(IK,{resources:e.resources,workflowRunId:v,className:`my-2`},e.key);if(e.type===`work`){if(h?.includes(s))return null;let n=Xq(e.messages);return t(MY,{label:Zq(e.isActive),status:e.status,timestamp:e.startTimestamp,durationSeconds:e.isActive?void 0:Wq(e.startTimestamp,e.endTimestamp),showElapsed:!0,details:n?void 0:e.messages,defaultExpanded:e.isActive&&!n,disablePreambleCollapse:e.isActive,className:x,onSendMessage:u,answeredToolApprovalRequestInputKeys:Ce,resolvedToolApprovalKeys:Se},`work-${e.id}-${e.isActive?`active`:`done`}-${e.status}`)}if(e.type===`stopped`)return t(jY,{message:e.message,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp},nY(e.message,`stopped-summary`));let n=e.message;return Ee(n)||De(n)?null:Vq(n)?t(PY,{children:t(aK,{message:n,batchData:n.details,isRunning:!n.details.completed_at,..._})},nY(n,`batch`)):t(PY,{children:t(bJ,{message:n,onSendMessage:u,onOpenArtifact:d,onSelectWorkstream:_e,requestInputAnswered:YW(n,xe),StoreLinkComponent:C,CollectionLinkComponent:w,feedbackAgentRunId:y})},nY(n,`summary`))}),He.map(({id:e,data:n})=>t(AY,{text:n.text,workstreamId:n.workstreamId,artifactRunId:v},`streaming-incomplete-${e}`)),Ze&&t(`div`,{className:z(`mx-auto w-full max-w-3xl px-1 text-sm text-muted`,x),"data-testid":`post-tool-thinking-indicator`,children:F(`agent.thinking`)}),Qe&&!et&&t(MY,{label:$e,status:`running`,timestamp:it,showElapsed:!0,className:x})]}),t(`div`,{ref:a,className:`h-2`})]})]})}const LY=(e,t)=>{if(e.type!==t.type||e.message!==t.message)return!1;let n=e.details,r=t.details;if(n?.tool_status!==`completed`||r?.tool_status!==`completed`)return!1;let i=typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime();return(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())-i<2e3},RY=ct.memo(IY);Q();function zY(e){return e?new Map(e.streamingMessages.map((e,t)=>[e.id??e.activityId??`stream-${t}`,e])):/* @__PURE__ */ new Map}function BY(e,t){return e?.find(e=>e.cursor===t)}function VY(e,t){if(t===0||e===`live`)return`live`;let n=UC(e,t);return n>=t-1?`live`:n+1}function HY(e){let t=0,n=e.length;for(;t<n&&e[t]===`-`;)t++;for(;n>t&&e[n-1]===`-`;)n--;return e.slice(t,n)}function UY(e){return HY(e.trim().replace(/[^a-z0-9-_]+/gi,`-`)).slice(0,80)}function WY(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function GY({fixture:e,cursor:r,initialCursor:i,onCursorChange:a,autoStepMs:s,repeat:c=1,viewMode:l,className:u,title:d,showHeader:f=!0}){let{t:p}=K(),m=e.messages,h=i??(m.length>0?0:`live`),[g,_]=G(()=>HC(h,m.length)),v=r??g,y=l??`sliding`,[b,x]=G(!!s),[S,C]=G(0),w=W(null),T=U(()=>KC(m,v,!0),[v,m]),E=T.displayedMessages,D=U(()=>zY(BY(e.streamingFrames,T.cursor)),[e.streamingFrames,T.cursor]),O=V(e=>{let t=HC(e,m.length);r===void 0&&_(t),a?.(t)},[r,m.length,a]);H(()=>{let e=HC(v,m.length);e!==v&&O(e)},[v,m.length,O]),H(()=>{if(!s||s<=0||!b)return;let e=window.setInterval(()=>{let e=VY(v,m.length);if(e===`live`&&v===`live`){C(e=>{let t=e+1;return c>0&&t>=c?(x(!1),t):(O(m.length>0?0:`live`),t)});return}O(e)},s);return()=>window.clearInterval(e)},[s,v,b,m.length,c,O]);let k=E.length>0&&!KU(E),A=U(()=>XW(E),[E]),j=d??e.metadata?.title??p(`agent.rewind.fixtureTitle`),M=V(()=>{let t={...e,metadata:{...e.metadata,title:j,exported_at:e.metadata?.exported_at??(/* @__PURE__ */ new Date()).toISOString(),message_count:m.length}},n=e.metadata?.agent_run_id??`fixture`;WY(`${UY(j)||`agent-chat`}-${UY(n)}.json`,t)},[e,m.length,j]),ee=V(()=>{O(VY(T.cursor,m.length))},[m.length,T.cursor,O]);return n(`div`,{className:z(`flex h-full min-h-0 w-full flex-col bg-background text-foreground`,u),"data-agent-test-playback-enabled":!0,"data-agent-playback-cursor":T.cursor,"data-agent-live-message-count":m.length,"data-agent-rendered-message-count":T.renderedMessageCount,"data-agent-replay-playing":b||void 0,"data-agent-replay-loop":S,children:[f&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,children:j}),t(`div`,{className:`text-xs text-muted`,children:p(`agent.rewind.fixtureMeta`,{messageCount:m.length,loops:S})})]}),n(`div`,{className:`flex items-center gap-2`,children:[n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:M,children:[t(Ag,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(`agent.rewind.exportFixture`)})]}),s&&s>0&&n(o,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>x(e=>!e),children:[t(b?hy:Dy,{className:`size-4`}),t(`span`,{className:`ms-1.5`,children:p(b?`agent.rewind.pause`:`agent.rewind.resume`)})]})]})]}),t(`div`,{className:`flex flex-shrink-0 justify-end px-2 py-1.5`,children:t(QC,{cursor:T.cursor,messages:m,onChangeCursor:O})}),t(RY,{messages:E,isCompleted:k,streamingMessages:D,bottomRef:w,artifactRunId:e.metadata?.agent_run_id??`agent-chat-fixture`,viewMode:y,renderRequestInputControls:!A}),A&&t(QW,{message:A,onSendMessage:ee,isLoading:!1})]})}function KY({className:e,inline:r=!1}){return n(`div`,{className:z(`flex items-center gap-1`,r?`inline-flex`:``,e),children:[t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.3s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}}),t(`div`,{className:`w-2 h-2 bg-primary rounded-full animate-[jumping_1s_0.6s_infinite_ease-in-out] hover:bg-primary`,style:{transform:`translateY(0)`,animationRange:`0px -8px`}})]})}function qY(){let{client:e}=q(),[t,n]=G([]),[r,i]=G(!0),[a,o]=G(!1),s=W(0),c=V(async()=>{let t=s.current+1;s.current=t,i(!0),o(!1);try{let r=await e.apps.getInstalledApps(`tools`),a=[];for(let e of r){let t=e,n=t.oauth_collection_ids??[],r=t.manifest.oauth_providers??{};if(!t.manifest.tool_collections)continue;let i=t.manifest.tool_collections.map(e=>Fn(e)).filter(e=>e.type===`mcp`),o=i.filter(e=>e.auth!==`none`&&e.auth!==`api_key`&&n.includes(e.id)),s=i.filter(e=>e.auth===`none`||e.auth===`api_key`),c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,u=[];for(let e of o)if(e.oauth_provider){let t=c.get(e.oauth_provider)??[];t.push(e),c.set(e.oauth_provider,t)}else if(e.oauth_app){let t=l.get(e.oauth_app)??[];t.push(e),l.set(e.oauth_app,t)}else u.push(e);for(let[e,n]of c){let i=n[0].id;for(let o of n)a.push({key:`${t.id}:provider:${e}:${o.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:o.name,representativeId:i,memberIds:[o.id],memberNames:[o.name],authType:`oauth`,oauthGrantType:r[e]?.grant_type})}for(let[e,n]of l){let r=n[0].id;for(let i of n)a.push({key:`${t.id}:oauthapp:${e}:${i.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:i.name,representativeId:r,memberIds:[i.id],memberNames:[i.name],authType:`oauth`})}for(let e of u)a.push({key:`${t.id}:individual:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:`oauth`});for(let e of s)a.push({key:`${t.id}:${e.auth}:${e.id}`,appId:t.id,appName:t.manifest.title||t.manifest.name,label:e.name,representativeId:e.id,memberIds:[e.id],memberNames:[e.name],authType:e.auth===`none`?`none`:`api_key`})}if(s.current!==t||(n(a),i(!1),a.length===0))return;o(!0);let c=/* @__PURE__ */ new Map,l=await Promise.all(a.map(async t=>{if(t.authType===`none`)return t;try{let n=c.get(t.appId);n||(n=e.remoteMcpConnections.getStatus(t.appId),c.set(t.appId,n));let r=(await n).find(e=>e.collection_id===t.representativeId);return{...t,authStatus:r}}catch{return t}}));if(s.current!==t)return;n(l)}catch(e){s.current===t&&(console.error(`Failed to load MCP tool collections:`,e),n([]))}finally{s.current===t&&(i(!1),o(!1))}},[e]);return H(()=>{c()},[c]),{groups:t,loading:r,statusLoading:a,reload:c}}function JY(e,t){return t?.length?e.memberIds.every(e=>t.includes(e)):!1}function YY(e,t,n){let r=new Set(t??[]);if(n)for(let t of e.memberIds)r.delete(t);else for(let t of e.memberIds)r.add(t);return Array.from(r)}function XY(e){return e.authType===`none`||e.authStatus?.authenticated===!0}function ZY(e,t){return e.filter(e=>XY(e)&&!JY(e,t)).length}function QY(e,t){return e.filter(e=>XY(e)&&!JY(e,t)).map(e=>e.label)}Q();function $Y({isOpen:e,onClose:r,groups:i,loading:a,statusLoading:o=!1,reload:s,disabledCollections:c,onChange:l,onConnectionChange:u,readOnly:d=!1}){let{t:f}=K(),p=()=>{s(),u?.()};return n(GT,{isOpen:e,onClose:r,size:`md`,className:`max-w-[92vw] sm:max-w-[620px] lg:max-w-[620px]`,children:[t(KT,{children:f(`mcpConnections.title`)}),n(qT,{children:[t(`p`,{className:`mb-4 text-sm text-muted`,children:f(`mcpConnections.subtitle`)}),a?t(`div`,{className:`flex items-center justify-center py-8`,children:t(UO,{className:`size-5`})}):i.length===0?t(`div`,{className:`py-8 text-center text-sm text-muted`,children:f(`mcpConnections.empty`)}):t(`div`,{className:`space-y-1`,children:i.map(e=>{let r=!JY(e,c),i=XY(e),a=e.authType===`oauth`&&e.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t(i?fv:hv,{className:`size-4 shrink-0 ${i?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(MT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:e.appName}),e.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:e.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`truncate ${r?`text-foreground`:`text-muted line-through`}`,children:e.label})})]}),n(`div`,{className:`flex shrink-0 items-center gap-3`,children:[a&&o&&!e.authStatus?t(LT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:f(`mcpConnections.checkingStatus`),children:t(UO,{className:`size-3`})}):a?t(KO,{appId:e.appId,collectionId:e.representativeId,collectionName:e.label,authenticated:e.authStatus?.authenticated,onAuthChange:p,variant:`compact`,showDisconnect:!0,readOnly:d}):t(VT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:e.authType===`none`?f(`mcpConnections.noAuthentication`):e.authType===`api_key`?f(`mcpConnections.apiKey`):f(`mcpConnections.managedByApp`)}),l&&t(BO,{size:`sm`,value:r,onChange:t=>l(YY(e,c,t)),disabled:d,"aria-label":f(r?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:e.label})})]})]},e.key)})})]})]})}Q();function eX({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1,variant:s=`outline`,size:c=`sm`}){let{t:l}=K(),{groups:u,loading:d,statusLoading:f,reload:p}=qY(),[m,h]=G(!1);if(!d&&u.length===0)return null;let g=ZY(u,r),_=QY(u,r),v=_.slice(0,2),y=_.length-v.length,b=v.length>0?`${v.join(`, `)}${y>0?` +${y}`:``}`:void 0;return n(e,{children:[n(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b&&t(`span`,{className:`max-w-48 truncate text-muted`,title:_.join(`, `),children:b}),n(LT,{variant:s,size:c,className:`shrink-0`,onClick:()=>h(!0),disabled:d,"aria-label":l(`mcpConnections.manage`),children:[t(`span`,{children:l(`mcpConnections.label`)}),g>0&&t(VT,{variant:`success`,children:g})]})]}),t($Y,{isOpen:m,onClose:()=>h(!1),groups:u,loading:d,reload:p,statusLoading:f,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function tX({disabledCollections:e,onChange:r,onConnectionChange:i,readOnly:a=!1}){let{t:o}=K(),{groups:s,loading:c,statusLoading:l,reload:u}=qY();if(!c&&s.length===0)return null;let d=()=>{u(),i?.()};return c&&s.length===0?n(`div`,{className:`flex items-center gap-2 border-y border-border/70 py-2 text-sm text-muted`,children:[t(UO,{className:`size-4`}),t(`span`,{children:o(`mcpConnections.label`)})]}):t(`div`,{className:`space-y-1`,children:s.map(i=>{let s=!JY(i,e),c=XY(i),u=i.authType===`oauth`&&i.oauthGrantType!==`client_credentials`;return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 text-sm`,children:[n(`div`,{className:`flex min-w-36 flex-1 items-center gap-2`,children:[t(c?fv:hv,{className:`size-4 shrink-0 ${c?`text-success`:`text-muted`}`,"aria-hidden":`true`}),t(MT,{description:n(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`font-medium`,children:i.appName}),i.memberNames.length>1&&t(`div`,{className:`text-xs text-muted`,children:i.memberNames.join(` · `)})]}),placement:`top`,asChild:!0,children:t(`span`,{className:`block truncate ${s?`text-foreground`:`text-muted line-through`}`,children:i.label})})]}),u&&l&&!i.authStatus?t(LT,{variant:`outline`,size:`sm`,disabled:!0,className:`h-6 w-32 justify-center px-2 text-xs`,title:o(`mcpConnections.checkingStatus`),children:t(UO,{className:`size-3`})}):u?t(KO,{appId:i.appId,collectionId:i.representativeId,collectionName:i.label,authenticated:i.authStatus?.authenticated,onAuthChange:d,variant:`compact`,showDisconnect:!0,readOnly:a}):t(VT,{variant:`outline`,className:`h-6 w-32 justify-center px-2 text-xs`,children:i.authType===`none`?o(`mcpConnections.noAuthentication`):i.authType===`api_key`?o(`mcpConnections.apiKey`):o(`mcpConnections.managedByApp`)}),r&&n(`div`,{className:`flex min-w-24 items-center justify-end gap-2 text-xs`,children:[t(`span`,{className:s?`text-muted`:`text-attention`,children:o(s?`mcpConnections.enabled`:`mcpConnections.disabled`)}),t(BO,{size:`sm`,value:s,onChange:t=>r(YY(i,e,t)),disabled:a,"aria-label":o(s?`mcpConnections.deactivateAria`:`mcpConnections.activateAria`,{name:i.label})})]})]},i.key)})})}function nX({disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o=!1}){let{t:s}=K(),{groups:c,loading:l,statusLoading:u,reload:d}=qY(),[f,p]=G(!1);if(!l&&c.length===0)return null;let m=ZY(c,r);return n(e,{children:[t(yO,{align:`left`,trigger:t(LT,{variant:`ghost`,size:`icon`,className:`size-8 rounded-md text-muted hover:bg-muted`,title:s(`mcpConnections.settings`),disabled:l,children:t(`span`,{className:`flex size-5 items-center justify-center rounded-[3px] border border-muted text-sm font-semibold leading-none`,"aria-hidden":`true`,children:`/`})}),children:n(bO,{onClick:()=>p(!0),isDisabled:l,children:[t(`span`,{children:s(`mcpConnections.title`)}),m>0&&t(VT,{variant:`success`,children:m})]})}),t($Y,{isOpen:f,onClose:()=>p(!1),groups:c,loading:l,reload:d,statusLoading:u,disabledCollections:r,onChange:i,onConnectionChange:a,readOnly:o})]})}function rX(e){for(let t=e.length-1;t>=0;t--){let n=e[t].details,r=n?.status_reason;if(r===un)return;if(r===dn)return{...typeof n?.budget_limit_usd==`number`&&{limitUsd:n.budget_limit_usd},...typeof n?.budget_reported_usd==`number`&&{reportedUsd:n.budget_reported_usd},...typeof n?.budget_estimated_usd==`number`&&{estimatedUsd:n.budget_estimated_usd},requestId:`${e[t].workflow_run_id}:${e[t].timestamp}`,usedUnits:typeof n?.budget_used_units==`number`?n.budget_used_units:void 0,limitTokens:typeof n?.budget_limit_tokens==`number`?n.budget_limit_tokens:void 0}}}function iX(e){let t=Math.round((e.limitTokens??0)/2/1e4)*1e4;return Math.max(1e5,t)}function aX(e){let t=e.replace(/[\s,_]/g,``);if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:void 0}function oX(e,t=`main`){let n=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0;for(let r=e.length-1;r>=0;r--){let i=e[r];if((i.workstream_id||`main`)!==t)continue;let a=i.details;if(!a||!n(a.budget_limit_tokens)||!n(a.budget_used_units))continue;if(a.budget_limit_tokens<=0)return;let o={limitTokens:a.budget_limit_tokens,remainingTokens:Math.max(0,a.budget_limit_tokens-a.budget_used_units),incomplete:a.accounting_status===`incomplete`};if(a.budget_mode!==`dollar`)return o;if(n(a.budget_limit_usd)&&n(a.budget_reported_usd)&&n(a.budget_estimated_usd))return{...o,limitUsd:a.budget_limit_usd,remainingUsd:Math.max(0,a.budget_limit_usd-a.budget_reported_usd-a.budget_estimated_usd)}}}Q();const sX=`stop`;function cX({client:e,agentRunId:n,pause:r,onStop:i,disabled:a=!1,onBudgetRequest:o,renderBudgetRequest:s}){let{t:c}=K(),l=it(),[u,d]=G(!1),[f,p]=G(),m=W(!1),h=W(!1),g=W(!1),_=r.limitUsd!==void 0&&(r.reportedUsd??0)+(r.estimatedUsd??0)>=r.limitUsd,v=Math.max(1,Math.ceil((r.limitUsd??0)/2)),y=_?v:iX(r),b=!!(o||s);H(()=>(g.current=!a,()=>{g.current=!1}),[a]);let x=V(async(t,r=`tokens`)=>{if(a||!g.current||m.current)return!1;if(!Number.isFinite(t)||t<=0||(r===`tokens`?!Number.isSafeInteger(t):!Number.isSafeInteger(Math.round(t*1e9))))return p(RangeError(c(r===`usd`?`agent.budgetPause.usdHelp`:`agent.budgetPause.invalidAmount`))),!1;m.current=!0,p(void 0),d(!0);try{return await e.agents.allocateBudget(n,r===`usd`?{additional_usd:t}:{additional_tokens:t}),!0}catch(e){return m.current=!1,d(!1),p(e),b||(console.error(`Failed to add token budget`,e),l({status:`error`,title:c(`agent.budgetPause.allocateFailed`),description:e instanceof Error?e.message:c(`agent.unknownError`),duration:4e3})),!1}},[n,e,a,b,c,l]),S=U(()=>({agentRunId:n,pause:r,suggestedTokens:iX(r),...r.limitUsd!==void 0&&{suggestedUsd:v,allocateUsd:e=>x(e,`usd`)},allocateBudget:x,stop:a?void 0:i,disabled:a,isSubmitting:u,error:f}),[n,r,v,x,a,i,u,f]);if(H(()=>{!o||a||h.current||(h.current=!0,Promise.resolve().then(()=>{if(g.current)return o(S)}).catch(e=>{g.current&&p(e)}))},[a,o,S]),b)return s?.(S)??null;let C=e=>{let t=_&&/^\d+(?:\.\d{1,9})?$/.test(e.trim())?Number(e):aX(e);if(t===void 0){l({status:`warning`,title:c(_?`agent.budgetPause.usdHelp`:`agent.budgetPause.invalidAmount`),duration:4e3});return}x(t,_?`usd`:`tokens`)},w=r.usedUnits===void 0?void 0:Math.round(r.usedUnits).toLocaleString(),T=r.limitTokens===void 0?void 0:Math.round(r.limitTokens).toLocaleString(),E=_?c(`agent.budgetPause.usdUsage`,{reported:(r.reportedUsd??0).toFixed(4),estimated:(r.estimatedUsd??0).toFixed(4),limit:r.limitUsd}):w&&T?c(`agent.budgetPause.descriptionWithUsage`,{used:w,limit:T}):c(`agent.budgetPause.description`),D=[{id:`allocate`,label:_?c(`agent.budgetPause.usdAdd`,{amount:y}):c(`agent.budgetPause.addOption`,{amount:y.toLocaleString()}),description:c(_?`agent.budgetPause.usdHelp`:`agent.budgetPause.amountHelp`)},...i?[{id:sX,label:c(`agent.budgetPause.stop`)}]:[]];return t(EU,{"data-agent-budget-pause-overlay":!0,children:t(DU,{question:`**${c(_?`agent.budgetPause.usdTitle`:`agent.budgetPause.title`)}**\n\n${E}`,options:D,onSelect:e=>{e===sX?i?.():x(y,_?`usd`:`tokens`)},allowFreeResponse:!0,placeholder:c(_?`agent.budgetPause.usdPlaceholder`:`agent.budgetPause.customAmountPlaceholder`),submitLabel:c(`agent.budgetPause.customAmountSubmit`),onSubmit:C,icon:t(Jb,{className:`size-4`}),isLoading:a||u})})}const lX=/(^|\/)(tool-inputs|tool-results|archive)(\/|$)/,uX=/(^|\/)process\/(history|state)(\/|$)/,dX=[/conversation\.json$/,/^conversation-checkpoint-\d+\.json$/,/^tools\.json$/,/^tool-input-refs\.json$/,/^toolu[_-]/i];function fX(e){if(lX.test(e)||uX.test(e))return!0;let t=e.split(`/`).pop()??e;return dX.some(e=>e.test(t))}function pX(e){let t={name:``,path:``,isDirectory:!0,children:[]};for(let n of e){let e=n.split(`/`),r=t,i=``;for(let t=0;t<e.length;t++){let n=e[t];i=i?`${i}/${n}`:n;let a=t===e.length-1,o=r.children.find(e=>e.name===n);o||(o={name:n,path:i,isDirectory:!a,children:[]},r.children.push(o)),r=o}}let n=e=>{e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1),e.children.forEach(n)};return n(t),t.children}function mX(e,t){let n=`agents/${t}/`,r=e.indexOf(n);return r===-1?e.split(`/`).pop()??e:e.slice(r+n.length)}function hX(e,t,n=0,r=!1){let[i,a]=G([]),[o,s]=G(!1),[c,l]=G(null),[u,d]=G(0),f=W(0),p=V(async()=>{if(!t)return;let n=++f.current;s(!0),l(null);try{let r=await e.files.listArtifacts(t);if(n!==f.current)return;let i=r.map(e=>mX(e,t)).filter(e=>!!e);a(i)}catch(e){if(n!==f.current)return;l(e instanceof Error?e.message:`Failed to list artifacts`),a([])}finally{n===f.current&&s(!1)}},[e,t]);H(()=>{p()},[p,n,u]);let m=U(()=>r?i:i.filter(e=>!fX(e)),[i,r]),h=U(()=>pX(m),[m]),g=i.length-m.length,_=V(()=>{d(e=>e+1)},[]);return{tree:h,flatFiles:m,totalCount:i.length,systemHiddenCount:g,isLoading:o,error:c,refresh:_}}function gX(){return _X||=import(`react-pdf`).then(e=>{let{pdfjs:t}=e;return t.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${t.version}/build/pdf.worker.min.mjs`,e}),_X}var _X,vX,yX,bX=Y((()=>{vX=_t(()=>gX().then(({Document:e})=>({default:e}))),yX=_t(()=>gX().then(({Page:e})=>({default:e})))}));function xX({className:e,size:n=`md`}){return t(`div`,{className:`flex items-center justify-center ${e||``}`,children:t(wv,{className:`${{sm:`w-4 h-4`,md:`w-6 h-6`,lg:`w-8 h-8`}[n]} animate-spin text-muted`})})}function SX({pdfUrl:e,pageNumber:r,width:i,className:a,renderTextLayer:o=!1,renderAnnotationLayer:s=!1,onLoadSuccess:c,onError:l}){let[u,d]=G(!0),[f,p]=G(null);return f?t(`div`,{className:`flex items-center justify-center text-destructive text-sm ${a||``}`,children:`Failed to load PDF`}):n(`div`,{className:a,children:[u&&t(xX,{className:`py-4`,size:`md`}),t(ft,{fallback:null,children:t(vX,{file:e,onLoadSuccess:({numPages:e})=>{d(!1),c?.(e)},onLoadError:e=>{d(!1),p(e),l?.(e)},loading:null,children:t(yX,{pageNumber:r,width:i,renderTextLayer:o,renderAnnotationLayer:s,loading:t(xX,{className:`py-4`,size:`sm`})})})})]})}function CX({pdfUrl:e,urlLoading:n=!1,children:r,onLoadSuccess:i}){let[a,o]=G(0),[s,c]=G(!0),[l,u]=G(null),[d,f]=G(null),p=async e=>{o(e.numPages),i?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1});f({width:t.width,height:t.height,aspectRatio:t.width/t.height})}catch(e){console.error(`Failed to get page dimensions:`,e)}c(!1)},m=e=>{c(!1),u(e)},h={pdfUrl:e,numPages:a,loading:n||!e||s,error:l,pageDimensions:d};return l?t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`}):t(AX.Provider,{value:h,children:e?t(ft,{fallback:t(xX,{className:`py-4`,size:`md`}),children:t(vX,{file:e,onLoadSuccess:p,onLoadError:m,loading:t(xX,{className:`py-4`,size:`md`}),children:r((e,n)=>t(yX,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(xX,{className:`py-4`,size:`sm`})},e))})}):t(xX,{className:`py-4`,size:`md`})})}function wX(){return yt(AX)}function TX({pageNumber:e,width:n,className:r}){let i=wX(),a=i?.pageDimensions?.aspectRatio??jX,o=n?Math.round(n/a):200;return i?.loading?t(`div`,{className:`flex items-center justify-center bg-muted ${r||``}`,style:{height:o,width:n||`100%`},children:t(xX,{size:`md`})}):t(`div`,{className:r,children:t(yX,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(xX,{className:`py-4`,size:`sm`})})})}function EX({pageNumber:e,width:n,isSelected:r,onSelect:i,renderThumbnail:a,aspectRatio:o=jX,rootMargin:s=`200px 0px`}){let c=W(null),[l,u]=G(!1);H(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0]?.isIntersecting&&u(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>t.disconnect()},[s]);let d=n?Math.round(n/o):200,f=l?t(yX,{pageNumber:e,width:n,renderTextLayer:!1,renderAnnotationLayer:!1,loading:t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d},children:t(xX,{size:`sm`})})}):t(`div`,{className:`flex items-center justify-center bg-muted`,style:{height:d,width:n||`100%`},children:t(`span`,{className:`text-muted text-xs`,children:e})});return t(`div`,{ref:c,children:a({pageNumber:e,isSelected:r,pageElement:f,onSelect:i})})}function DX(e){if(!e)return null;let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function OX({pdfUrl:r,urlLoading:i=!1,pageCount:a,currentPage:o,thumbnailWidth:s,onPageSelect:c,renderThumbnail:l,scrollContainerRef:u,onAspectRatioChange:d,onItemHeightChange:f,calculateItemHeight:p,onPageCountChange:m}){let[h,g]=G(null),[_,v]=G({start:0,end:Math.min(15,a)}),[y,b]=G(null),x=W(null),S=V(e=>{g(e)},[]),C=V(async e=>{m?.(e.numPages);try{let t=(await e.getPage(1)).getViewport({scale:1}),n=t.width/t.height;b(n),d?.(n)}catch(e){console.error(`Failed to get page dimensions:`,e),b(jX),d?.(jX)}},[d,m]),w=y??jX,T=s?Math.round(s/w):200,E=p?p(T):T+16+24+8;if(H(()=>{E>0&&y!==null&&f?.(E)},[E,y,f]),H(()=>{let e=u?.current||DX(x.current);if(!e)return;let t=()=>{let t=e.scrollTop,n=e.clientHeight,r=Math.floor(t/E),i=Math.ceil((t+n)/E),o=Math.max(0,r-5),s=Math.min(a,i+5);v(e=>e.start!==o||e.end!==s?{start:o,end:s}:e)};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[E,a,u]),h)return t(`div`,{className:`flex items-center justify-center text-destructive text-sm py-4`,children:`Failed to load PDF`});if(i||!r)return t(xX,{className:`py-4`,size:`md`});let D=_.start*E,O=(a-_.end)*E,k=y!==null;return t(`div`,{ref:x,children:t(ft,{fallback:t(xX,{className:`py-4`,size:`md`}),children:t(vX,{file:r,onLoadSuccess:C,onLoadError:S,loading:t(xX,{className:`py-4`,size:`md`}),children:k?n(e,{children:[D>0&&t(`div`,{style:{height:D}}),Array.from({length:_.end-_.start},(e,n)=>{let r=_.start+n+1;return t(`div`,{"data-page-index":r-1,style:{height:E,overflow:`hidden`},children:t(EX,{pageNumber:r,width:s,isSelected:r===o,onSelect:()=>c(r),renderThumbnail:l,aspectRatio:w})},r)}),O>0&&t(`div`,{style:{height:O}})]}):t(xX,{className:`py-4`,size:`md`})})})})}function kX({pdfUrl:e,pageNumber:r,width:i,height:a,className:o,renderTextLayer:s=!1,renderAnnotationLayer:c=!1,onPageChange:l}){let[u,d]=G(0),[f,p]=G(!0),[m,h]=G(null);return H(()=>{u>0&&l?.(r,u)},[r,u,l]),m?t(`div`,{className:`flex items-center justify-center text-destructive ${o||``}`,children:n(`span`,{children:[`Failed to load PDF: `,m.message]})}):n(`div`,{className:o,children:[f&&t(xX,{className:`py-8`,size:`lg`}),t(ft,{fallback:null,children:t(vX,{file:e,onLoadSuccess:({numPages:e})=>{d(e),p(!1)},onLoadError:e=>{p(!1),h(e)},loading:null,children:t(yX,{pageNumber:Math.min(r,u||1),width:i,height:a,renderTextLayer:s,renderAnnotationLayer:c,loading:t(xX,{className:`py-8`,size:`md`})})})})]})}var AX,jX,MX=Y((()=>{Q(),bX(),AX=pt(null),jX=210/297}));function NX({pdfUrl:r,pdfUrlLoading:i=!1,pageCount:a,currentPage:s,onChange:c,onPageCountChange:l,className:u,compact:d=!1,headerExtra:f}){let{t:m}=K(),h=W(null),g=W(null),[_,v]=G(void 0),[y,b]=G(RX),[x,S]=G(IX),[C,w]=G(null),T=W(null),E=_?Math.round(_*y/100):void 0,D=V(()=>{let e=LX.findIndex(e=>e>=y);e===-1&&(e=LX.length-1);let t=Math.min(e+1,LX.length-1);b(LX[t])},[y]),O=V(()=>{let e=LX.findIndex(e=>e>=y);e===-1&&(e=LX.length-1);let t=Math.max(e-1,0);b(LX[t])},[y]),k=V(()=>{b(RX)},[]),A=V(e=>e+(d?28:48),[d]),j=V((e,t)=>{let n=e?Math.round(e/t):200;return A(n)},[A]);H(()=>{let e=g.current;if(!e)return;let t=null,n=()=>e.clientWidth-16-16-4,r=()=>{let t=n();if(t<=0)return;let r=T.current;if(r&&r>0){let n=e.scrollTop,i=Math.round(n/r),a=j(t,x),o=i*a;v(t),requestAnimationFrame(()=>{e.scrollTo({top:o,behavior:`instant`})}),T.current=a}else v(t),T.current=j(t,x)},i=n();i>0&&(v(i),T.current=j(i,x));let a=new ResizeObserver(()=>{t&&clearTimeout(t),t=setTimeout(r,150)});return a.observe(e),()=>{t&&clearTimeout(t),a.disconnect()}},[x,j]);let M=W(!1),ee=W(null),N=W(y);H(()=>{N.current!==y&&(N.current=y,ee.current={targetPage:s},M.current=!0)},[y,s]),H(()=>{let e=g.current,t=ee.current;if(t&&e&&C){ee.current=null;let n=(t.targetPage-1)*C;requestAnimationFrame(()=>{e.scrollTo({top:n,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})})}},[C]);let P=W(!1);H(()=>{let e=g.current;if(e&&C&&!P.current){if(s>1){P.current=!0,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}else P.current=!0}},[C,s]);let F=W(s);return H(()=>{let e=g.current;if(e&&C&&F.current!==s){F.current=s,M.current=!0;let t=(s-1)*C;e.scrollTo({top:t,behavior:`instant`}),requestAnimationFrame(()=>{M.current=!1})}},[s,C]),H(()=>{let e=g.current;if(!e||!C)return;let t=null,n=()=>{M.current||(t&&clearTimeout(t),t=setTimeout(()=>{let t=e.scrollTop,n=Math.round(t/C)+1,r=Math.max(1,Math.min(n,a));r!==s&&(F.current=r,c(r))},50))};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{t&&clearTimeout(t),e.removeEventListener(`scroll`,n)}},[C,a,s,c]),n(`div`,{ref:h,className:ot(`flex flex-col items-stretch`,d?`gap-y-1`:`gap-y-2`,u),children:[n(`div`,{className:ot(`relative flex items-center justify-center px-2`,d?`h-6`:`h-9`),children:[t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s>1&&c(s-1)},title:m(`pdf.previousPage`),children:t(Zh,{className:`size-4`})}),n(`div`,{className:`absolute start-2 flex items-center gap-x-1`,children:[t(FX,{zoom:y,onZoomIn:D,onZoomOut:O,onFitToView:k,canZoomIn:y<LX[LX.length-1],canZoomOut:y>LX[0]}),f&&n(e,{children:[t(`div`,{className:`w-px h-4 bg-border mx-1`}),f]})]}),t(`div`,{className:`absolute end-2`,children:t(PX,{currentPage:s,totalPages:a,onChange:c})})]}),t(`div`,{ref:g,className:ot(`flex flex-col items-center flex-1 overflow-y-auto px-2`,d?`gap-1`:`gap-2`),children:t(OX,{pdfUrl:r,urlLoading:i,pageCount:a,currentPage:s,thumbnailWidth:E,onPageSelect:c,onPageCountChange:l,scrollContainerRef:g,onAspectRatioChange:S,onItemHeightChange:w,calculateItemHeight:A,renderThumbnail:({pageNumber:e,isSelected:r,pageElement:i,onSelect:a})=>n(`div`,{className:ot(`hover:bg-muted rounded-md w-full`,d?`p-1`:`p-2`),children:[t(o,{variant:`unstyled`,size:`none`,"aria-pressed":r,"aria-label":`Page ${e}`,className:ot(`relative border-[2px] cursor-pointer overflow-hidden`,r?`border-primary`:`border-border`),onClick:a,children:i}),t(p,{className:ot(`text-muted font-semibold`,d?`text-xs pt-0.5`:`text-sm pt-1`),children:e})]},e)})}),t(`div`,{className:ot(`flex items-center justify-center`,d?`h-6`:`h-9`),children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>{s<a&&c(s+1)},title:m(`pdf.nextPage`),children:t(zh,{className:`size-4`})})})]})}function PX({currentPage:e,totalPages:r,onChange:i}){let{t:a}=K(),o=W(null),[s,c]=G(String(e));H(()=>{c(String(e))},[e]);let l=()=>{let t=parseInt(s,10);!Number.isNaN(t)&&t>=1&&t<=r?i(t):c(String(e))};return n(`div`,{className:`flex items-center gap-1 text-xs text-muted`,children:[t(`span`,{children:a(`pdf.page`)}),t(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:t=>{t.key===`Enter`?(l(),o.current?.blur()):t.key===`Escape`&&(c(String(e)),o.current?.blur())},onBlur:()=>{l()},className:`w-8 h-5 text-center text-xs px-1 py-0 bg-background border border-border rounded focus:outline-none focus:border-primary`}),n(`span`,{children:[`/ `,r]})]})}function FX({zoom:e,onZoomIn:r,onZoomOut:i,onFitToView:a,canZoomIn:s,canZoomOut:c}){let{t:l}=K();return n(`div`,{className:`flex items-center gap-x-0.5`,children:[t(o,{variant:`ghost`,size:`xs`,onClick:i,isDisabled:!c,title:l(`pdf.zoomOut`),children:t(ey,{})}),n(`span`,{className:`text-xs text-muted min-w-[32px] text-center`,children:[e,`%`]}),t(o,{variant:`ghost`,size:`xs`,onClick:r,isDisabled:!s,title:l(`pdf.zoomIn`),children:t(Ay,{})}),t(o,{variant:`ghost`,size:`xs`,onClick:a,title:l(`pdf.fitToWidth`),className:e===RX?`text-muted/40`:void 0,children:t(Iv,{})})]})}var IX,LX,RX,zX=Y((()=>{Q(),MX(),IX=210/297,LX=[50,75,100,125,150,200,300],RX=100}));function BX({object:e,url:r,source:i,className:a}){let{t:s}=K(),{client:c}=q(),[l,u]=G(1),[d,f]=G(r||``),[p,m]=G(!r),[h,g]=G(0),[_,v]=G(!1);H(()=>{if(r){f(r),m(!1);return}let t=i||e?.content?.source;if(!t){m(!1);return}m(!0),c.files.getDownloadUrl(t).then(e=>{f(e.url)}).catch(e=>{console.error(`Failed to get PDF URL:`,e)}).finally(()=>{m(!1)})},[r,i,e?.content?.source,c]),H(()=>{let t=e?.metadata,n=t?.pages||t?.page_count||0;n>0&&g(n)},[e?.metadata]);let y=e=>{g(e)};return p?t(`div`,{className:`flex items-center justify-center h-full`,children:t(Me,{size:`lg`})}):d?_?n(`div`,{className:`fixed inset-0 bg-background z-50 flex flex-col overflow-hidden`,children:[t(`div`,{className:`flex h-9 items-center justify-end shrink-0 bg-sidebar px-2 border-b border-sidebar-border`,children:t(o,{variant:`ghost`,size:`xs`,onClick:()=>v(!1),title:s(`pdf.closeFullscreen`),children:t(xx,{className:`size-4`})})}),t(NX,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:`flex-1 min-h-0`})]}):t(`div`,{className:`relative h-full flex flex-col`,children:t(NX,{pdfUrl:d,pdfUrlLoading:p,pageCount:h||100,currentPage:l,onChange:u,onPageCountChange:y,className:a,compact:!0,headerExtra:t(o,{title:s(`pdf.fullscreen`),tooltipPlacement:`bottom`,variant:`unstyled`,className:`p-1 rounded cursor-pointer transition-colors text-muted hover:text-foreground hover:bg-muted`,onClick:()=>v(!0),children:t(Nv,{className:`size-4`})})})}):t(`div`,{className:`flex items-center justify-center h-full text-muted`,children:s(`pdf.noPdfAvailable`)})}var VX=Y((()=>{Q(),zX()})),HX=/* @__PURE__ */ yr({UniversalDocumentViewer:()=>pZ});function UX(e){return e.fileName||e.title||e.artifact?.path.split(`/`).pop()||e.sourcePath?.split(`/`).pop()||`Document`}function WX(e){let t=e.split(`?`)[0]||e;return t.includes(`.`)&&t.split(`.`).pop()?.toLowerCase()||``}function GX(e){return e.contentType===`application/pdf`||e.extension===`pdf`}function KX(e){return[`md`,`markdown`].includes(e.extension)||[`text/markdown`,`text/x-markdown`].includes(e.contentType||``)}function qX(e){return e.contentType?.startsWith(`image/`)||[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`].includes(e.extension)}function JX(e){return e.contentType===`text/html`||[`html`,`htm`].includes(e.extension)}function YX(e){return[`application/xml`,`text/xml`].includes(e.contentType||``)||e.extension===`xml`}function XX(e){return e.contentType?.startsWith(`text/`)||[`css`,`csv`,`json`,`txt`,`tsx`,`ts`,`jsx`,`js`,`xml`,`yaml`,`yml`].includes(e.extension)}function ZX(e){return[`tsx`,`jsx`].includes(e.extension)}function QX(e){return[`doc`,`docx`,`ppt`,`pptx`].includes(e.extension)||[`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-powerpoint`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`].includes(e.contentType||``)}function $X({content:e,extension:n}){return t(`pre`,{className:`h-full overflow-auto rounded-md bg-muted/10 p-3 text-xs leading-5`,children:t(`code`,{className:n?`language-${n}`:void 0,children:e||``})})}function eZ({message:e}){return n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-muted`,children:[t(x_,{className:`size-8`}),t(`span`,{className:`text-sm`,children:e})]})}function tZ(e,n){if(e.Component){let r=e.Component;return t(r,{context:n})}return e.render?.(n)??null}function nZ(e,t){return e.includes(`.`)?e.replace(/\.[^/.]+$/,t):`${e}${t}`}function rZ(e){return e.split(`/`).pop()||e}function iZ(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function aZ(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function oZ(e){if(e!==void 0)return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function sZ(e){return Array.isArray(e)?e.length:0}function cZ(e){try{let t=iZ(JSON.parse(e));if(!t)return;let n=iZ(t.viewport);return{ok:typeof t.ok==`boolean`?t.ok:void 0,source_artifact:typeof t.source_artifact==`string`?t.source_artifact:void 0,screenshot_artifact:typeof t.screenshot_artifact==`string`?t.screenshot_artifact:void 0,rendered_at:typeof t.rendered_at==`string`?t.rendered_at:void 0,viewport:n?{width:aZ(n.width),height:aZ(n.height)}:void 0,dependencies_reused:typeof t.dependencies_reused==`boolean`?t.dependencies_reused:void 0,status:aZ(t.status),title:typeof t.title==`string`?t.title:void 0,console_errors:Array.isArray(t.console_errors)?t.console_errors:void 0,page_errors:Array.isArray(t.page_errors)?t.page_errors:void 0,failed_requests:Array.isArray(t.failed_requests)?t.failed_requests:void 0,bad_responses:Array.isArray(t.bad_responses)?t.bad_responses:void 0,timings_ms:iZ(t.timings_ms),error:t.error}}catch{return}}async function lZ(e,t){let n=await fetch(e);if(!n.ok)throw Error(`Failed to load ${t}: ${n.statusText}`);return n.text()}function uZ({metadata:e,sourcePath:t,fallbackPath:n,artifactMode:r}){let i=e?.screenshot_artifact?.replace(/^\/+/,``);if(!i)return n;if(r)return i;let a=e?.source_artifact?.replace(/^\/+/,``),o=t.replace(/^\/+/,``);if(a&&o.endsWith(a)){let e=o.slice(0,-a.length).replace(/\/+$/,``);return e?`${e}/${i}`:i}let s=o.includes(`/`)?o.slice(0,o.lastIndexOf(`/`)+1):``;return s?`${s}${rZ(i)}`:n}function dZ({metadata:e}){if(!e)return null;let r=aZ(e.timings_ms?.total_before_cleanup),a=sZ(e.console_errors)+sZ(e.page_errors)+sZ(e.failed_requests)+sZ(e.bad_responses);return n(`div`,{className:`grid gap-2 border-b p-3 text-xs`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.ok!==void 0&&t(i,{variant:e.ok?`success`:`destructive`,children:e.ok?`render ok`:`render failed`}),e.dependencies_reused!==void 0&&n(i,{variant:e.dependencies_reused?`info`:`secondary`,children:[`deps `,e.dependencies_reused?`reused`:`installed`]}),e.status&&n(i,{variant:`secondary`,children:[`HTTP `,e.status]}),a>0&&n(i,{variant:`attention`,children:[a,` browser issue(s)`]})]}),n(`div`,{className:`grid gap-1 text-muted sm:grid-cols-2`,children:[e.viewport?.width&&e.viewport.height&&n(`div`,{children:[`Viewport `,e.viewport.width,` x `,e.viewport.height]}),oZ(r)&&n(`div`,{children:[`Total `,oZ(r)]}),e.rendered_at&&n(`div`,{children:[`Rendered `,new Date(e.rendered_at).toLocaleString()]}),e.title&&n(`div`,{className:`truncate`,children:[`Title `,e.title]})]}),typeof e.error==`string`&&t(`div`,{className:`text-destructive`,children:e.error})]})}function fZ({context:e}){let{client:r}=q(),a=e.source.artifact,o=a?.path||e.source.sourcePath,s=!!a,c=e.content||``,[l,u]=G({isLoading:!1}),d=V(async(e,t)=>a?(await r.files.getArtifactDownloadUrl(a.runId,e,t)).url:(await r.files.getDownloadUrl(e,rZ(e),t)).url,[a,r]);return H(()=>{if(!o){u({isLoading:!1,previewError:`No source path is available for this TSX artifact.`});return}let e=o,t=!1,n=nZ(e,`.png`),r=nZ(e,`.render.json`);async function i(){u({isLoading:!0});let i,a,o=n;try{i=cZ(await lZ(await d(r,`inline`),rZ(r))),o=uZ({metadata:i,sourcePath:e,fallbackPath:n,artifactMode:s})}catch(e){a=e instanceof Error?e.message:`Render metadata is not available`}let c,l;try{c=await d(o,`inline`)}catch(e){l=e instanceof Error?e.message:`Sandbox render image is not available`}t||u({isLoading:!1,imageUrl:c,metadata:i,metadataError:a,previewError:l})}return i(),()=>{t=!0}},[s,d,o]),n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 border-b px-3 py-2 text-sm`,children:[t(Z_,{className:`size-4 text-info`}),t(`span`,{className:`font-medium`,children:`Sandbox render`}),l.isLoading?t(i,{variant:`secondary`,children:`loading`}):l.imageUrl?t(i,{variant:`success`,children:`PNG preview`}):t(i,{variant:`attention`,children:`source only`}),l.metadata?.rendered_at&&t(`span`,{className:`text-xs text-muted`,children:new Date(l.metadata.rendered_at).toLocaleString()})]}),l.isLoading?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(wv,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading sandbox render...`})]}):l.imageUrl?n(`div`,{className:`grid min-h-0 flex-1 xl:grid-cols-[minmax(0,1fr)_minmax(24rem,0.7fr)]`,children:[t(`div`,{className:`flex min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:l.imageUrl,alt:`${e.fileName} sandbox render`,className:`max-h-full max-w-full rounded-md object-contain`})}),n(`div`,{className:`min-h-0 overflow-auto border-t xl:border-s xl:border-t-0`,children:[t(dZ,{metadata:l.metadata}),t(`div`,{className:`p-3`,children:t($X,{content:c,extension:e.extension})})]})]}):n(`div`,{className:`grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]`,children:[n(`div`,{className:`border-b px-3 py-2 text-xs text-muted`,children:[`No sandbox-rendered PNG was found for this TSX artifact. Showing the source without executing it in Studio.`,l.previewError&&n(`span`,{className:`ms-1`,children:[`Preview lookup: `,l.previewError]}),!l.previewError&&l.metadataError&&n(`span`,{className:`ms-1`,children:[`Metadata lookup: `,l.metadataError]})]}),n(`div`,{className:`min-h-0 overflow-auto p-3`,children:[t(dZ,{metadata:l.metadata}),t($X,{content:c,extension:e.extension})]})]})]})}function pZ({source:e,className:r,bodyClassName:i,renderers:a=[],converters:s=[],resolveUrl:c,loadText:l,createRendition:u,markdownComponents:d,showHeader:f=!1,onDownload:p}){let{client:m}=q(),h=U(()=>UX(e),[e]),g=U(()=>WX(h),[h]),[_,v]=G(e.url),[y,b]=G(e.content),[x,S]=G(null),[C,w]=G(!1),[T,E]=G(null),[D,O]=G(0),k=[e.id,e.title,e.fileName,e.contentType,e.url,e.sourcePath,e.content,e.artifact?.runId,e.artifact?.path].join(`\0`),A=V(async(e,t)=>e.url?e.url:e.artifact?(await m.files.getArtifactDownloadUrl(e.artifact.runId,e.artifact.path,t)).url:e.sourcePath?(await m.files.getDownloadUrl(e.sourcePath,e.fileName,t)).url:``,[m]),j=c||A,M=V(async e=>{if(e.content!==void 0)return e.content;let t=await j(e,`inline`);if(!t)return``;let n=await fetch(t);if(!n.ok)throw Error(`Failed to load ${UX(e)}: ${n.statusText}`);return n.text()},[j]),ee=l||M,N={source:e,fileName:h,extension:g,contentType:e.contentType||x?.contentType,url:x?.url||_,content:x?.content||y,isLoading:C,error:T,reload:()=>O(e=>e+1)},P=a.find(e=>e.canRender(N)),F=!P&&(KX(N)||JX(N)||YX(N)||XX(N)),te=!P&&(GX(N)||qX(N)),I={source:e,fileName:h,extension:g,contentType:e.contentType,target:`pdf`},ne=!P&&!N.url?s.find(e=>e.target===`pdf`&&e.canConvert(I)):void 0,L=!P&&!N.url&&(QX(N)||!!ne)&&(!!ne||!!u);H(()=>{let t=!1,n=e;E(null),v(n.url),b(n.content),S(null);async function r(){if(F||te||L){w(!0);try{if(L){let e=ne?await ne.convert({source:n,fileName:h,extension:g,contentType:n.contentType,target:`pdf`}):await u?.(n,`pdf`);t||S(e??null);return}if(F){let e=await ee(n);t||b(e);return}if(te){let e=await j(n,`inline`);t||v(e)}}catch(e){t||E(e instanceof Error?e.message:`Failed to load document`)}finally{t||w(!1)}}}return r(),()=>{t=!0}},[u,g,h,ee,L,F,te,D,j,ne,e,k]);let R={...N,url:x?.url||_,content:x?.content||y,contentType:x?.contentType||e.contentType,isLoading:C,error:T},re;return re=C?n(`div`,{className:`flex h-full min-h-64 items-center justify-center gap-2 text-muted`,children:[t(wv,{className:`size-5 animate-spin`}),t(`span`,{className:`text-sm`,children:`Loading preview...`})]}):T?n(`div`,{className:`flex h-full min-h-64 flex-col items-center justify-center gap-2 text-destructive`,children:[t(eg,{className:`size-7`}),t(`span`,{className:`max-w-xl text-center text-sm`,children:T}),t(o,{variant:`outline`,size:`sm`,onClick:R.reload,children:`Retry`})]}):P?tZ(P,R):(GX(R)||x?.contentType===`application/pdf`)&&R.url?t(BX,{url:R.url,className:`h-full`}):qX(R)&&R.url?t(`div`,{className:`flex h-full min-h-0 items-center justify-center overflow-auto bg-muted/10 p-3`,children:t(`img`,{src:R.url,alt:h,className:`max-h-full max-w-full rounded-md object-contain`})}):KX(R)?t(`div`,{className:`vprose prose prose-sm max-w-none px-5 py-4`,children:t(Ft,{artifactRunId:e.artifact?.runId,components:d,children:R.content||``})}):JX(R)?t(`iframe`,{title:h,className:`h-full min-h-96 w-full bg-white`,sandbox:``,srcDoc:R.content||``}):YX(R)?t(`div`,{className:`px-4 py-2`,children:t(Bt,{xml:R.content||``,collapsible:!0})}):ZX(R)?t(fZ,{context:R}):XX(R)?t($X,{content:R.content,extension:g}):QX(R)&&!ne&&!u?t(eZ,{message:`This file needs a PDF rendition before it can be previewed.`}):t(eZ,{message:`Preview is not available for this file type.`}),n(`div`,{className:z(`flex h-full min-h-0 flex-col overflow-hidden`,r),children:[f&&n(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b py-2 ps-3 pe-16`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`truncate text-sm font-medium`,title:h,children:h}),R.contentType&&t(`div`,{className:`truncate text-xs text-muted`,children:R.contentType})]}),p&&t(o,{variant:`outline`,size:`sm`,onClick:()=>p(e),children:`Download`})]}),t(`div`,{className:z(`min-h-0 flex-1 overflow-auto`,i),children:re})]})}var mZ=Y((()=>{Q(),VX()}));Q();const hZ=ct.lazy(async()=>({default:(await Promise.resolve().then(()=>(mZ(),HX))).UniversalDocumentViewer})),gZ=/* @__PURE__ */ new Set([`md`,`markdown`,`mdx`,`txt`]);function _Z(e){let t=e.split(`.`).pop()?.toLowerCase();return t!==void 0&&gZ.has(t)}function vZ(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function yZ({node:e,depth:r,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l=!1}){let{t:u}=K(),[d,f]=G(!1),p=l||d;if(e.isDirectory)return n(`div`,{className:`min-w-0`,children:[n(o,{variant:`unstyled`,className:`flex w-full max-w-full items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>f(e=>!e),"aria-expanded":p,children:[p?t(Dh,{className:`size-3.5 shrink-0 text-muted`}):t(Nh,{className:`size-3.5 shrink-0 text-muted cn-rtl-flip`}),t(p?D_:A_,{className:`size-4 shrink-0 text-info`}),t(`span`,{className:`min-w-0 truncate font-medium`,title:e.path,children:vZ(e.name)})]}),p&&e.children.map(e=>t(yZ,{node:e,depth:r+1,runId:i,onOpen:a,onDownload:s,downloadingPath:c,forceExpanded:l},`${i}:${e.path}`))]});let m=c===e.path;return n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,style:{paddingInlineStart:`${r*14+4}px`},onClick:()=>a(e.path),title:e.path,children:[t(`span`,{className:`size-3.5 shrink-0`}),t(x_,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.name})]}),t(o,{variant:`ghost`,size:`sm`,className:`h-7 w-7 shrink-0 p-0`,onClick:()=>s(e.path),disabled:m,"aria-label":u(`agent.download`),title:u(`agent.download`),children:m?t(wv,{className:`size-3.5 animate-spin text-info`}):t(Gg,{className:`size-3.5`})})]})}function bZ(e){return e.reduce((e,t)=>t.isDirectory?e+bZ(t.children):e+1,0)}function xZ(e,t){let n=t.trim().toLocaleLowerCase();return n?e.flatMap(e=>{let t=`${e.name} ${e.path}`.toLocaleLowerCase().includes(n);if(!e.isDirectory)return t?[e]:[];let r=xZ(e.children,n);return t?[{...e}]:r.length>0?[{...e,children:r}]:[]}):e}function SZ(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function CZ(e){switch(e.split(`.`).pop()?.toLowerCase()){case`css`:return`text/css`;case`gif`:return`image/gif`;case`htm`:case`html`:return`text/html`;case`jpeg`:case`jpg`:return`image/jpeg`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`pdf`:return`application/pdf`;case`png`:return`image/png`;case`svg`:return`image/svg+xml`;case`ts`:case`tsx`:return`text/typescript`;case`txt`:return`text/plain`;case`webp`:return`image/webp`;default:return}}function wZ({runId:e,path:r,onBack:i,onDownload:a,refreshKey:s,refreshDetails:c,onSendMessage:l}){let{t:u}=K(),[d,f]=G(`components`),[p,m]=G(`idle`);return n(`div`,{className:`flex h-full min-h-0 flex-col`,children:[n(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-2 py-1`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToArtifacts`),title:u(`agent.backToArtifacts`),children:t(Jm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[t(`span`,{className:`truncate text-sm font-medium`,title:r,children:r.split(`/`).pop()}),p===`saving`?t(Ke,{description:u(`agent.savingWorkingCopy`),asChild:!0,children:t(wv,{className:`size-3.5 shrink-0 animate-spin text-muted`,"aria-label":u(`agent.savingWorkingCopy`)})}):p===`saved`?t(Ke,{description:u(`agent.savedToWorkingCopy`),asChild:!0,children:t(wh,{className:`size-3.5 shrink-0 text-success`,"aria-label":u(`agent.savedToWorkingCopy`)})}):null]}),n(`div`,{className:`flex items-center gap-0.5`,children:[t(o,{variant:d===`components`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`components`),"aria-label":u(`agent.blockMode`),"aria-pressed":d===`components`,title:u(`agent.blockMode`),children:t(Gy,{className:`size-4`})}),t(o,{variant:d===`document`?`primary`:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>f(`document`),"aria-label":u(`agent.editMode`),"aria-pressed":d===`document`,title:u(`agent.editMode`),children:t(vy,{className:`size-4`})})]}),t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:()=>a(r),"aria-label":u(`agent.download`),title:u(`agent.download`),children:t(Gg,{className:`size-4`})})]}),t(Et,{runId:e,path:r,viewMode:d,refreshKey:s,refreshDetails:c,readOnly:!l,onAction:e=>{if(!l)return;let t=e.anchor.block_type.replaceAll(`_`,` `);l(e.comment?.trim()||u(`agent.editedSelectionMessage`,{blockType:t}),{editing_action:e})},onSaveStatusChange:m,onSendMessage:l?e=>l(e):void 0,className:z(`relative min-h-0 flex-1`,d===`document`?`overflow-hidden`:`overflow-y-auto px-6 py-5`)})]})}function TZ({icon:e,children:r,action:i}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r}),i]})}function EZ({runId:r,refreshKey:i=0,refreshDetails:a,selectedPath:s,onSelectedPathChange:c,onSendMessage:l}){let{t:u}=K(),{client:d}=q(),[f,m]=G(!1),{tree:h,flatFiles:g,totalCount:_,systemHiddenCount:v,isLoading:y,error:b,refresh:x}=hX(d,r,i,f),[S,C]=G(null),[w,T]=G(null),[E,D]=G(``),[O,k]=G(null),A=s===void 0?O:s,j=V(e=>{s===void 0&&k(e),c?.(e)},[c,s]),M=E.trim(),N=U(()=>xZ(h,M),[h,M]),P=U(()=>bZ(N),[N]),F=bt(),te=V(async e=>{if(r){C(e);try{let{url:t}=await d.files.getArtifactDownloadUrl(r,e,`attachment`);SZ(t,e.split(`/`).pop()||`artifact`)}catch(e){console.error(`Failed to get artifact download URL:`,e)}finally{C(null)}}},[d,r]),I=V(e=>{if(_Z(e)){j(e);return}T(e)},[j]),ne=r&&w?{title:w.split(`/`).pop()||w,fileName:w.split(`/`).pop()||w,contentType:CZ(w),artifact:{runId:r,path:w}}:null;return r?y&&_===0?t(TZ,{icon:t(wv,{className:`mb-2 size-6 animate-spin`}),children:u(`agent.loadingArtifacts`)}):b?t(`div`,{className:`flex flex-col items-center justify-center p-4 text-muted w-full`,children:n(ee,{title:`Fail to load Artifacts`,className:`w-full`,action:x,actionLabel:n(e,{children:[t(zy,{className:`size-3.5 me-1.5`}),u(`agent.retry`)]}),children:[t(`span`,{className:`break-all text-muted`,children:b}),` `,t(`br`,{})]})}):_===0?t(TZ,{icon:t(oy,{className:`mb-2 size-8`}),action:n(o,{variant:`ghost`,size:`sm`,className:`mt-2`,onClick:x,children:[t(zy,{className:`size-3.5 me-1.5`}),u(`agent.refresh`)]}),children:u(`agent.noArtifactsYet`)}):A?t(wZ,{runId:r,path:A,refreshKey:i,refreshDetails:a,onBack:()=>j(null),onDownload:e=>void te(e),onSendMessage:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted`,children:[n(`span`,{children:[M?`${P} of ${g.length} file${g.length===1?``:`s`}`:`${g.length} file${g.length===1?``:`s`}`,!f&&v>0?` · ${v} hidden`:``]}),n(`div`,{className:`flex items-center gap-1`,children:[t(Fe,{size:`sm`,value:f,onChange:m,children:t(`span`,{className:`text-xs text-muted`,children:u(`agent.showSystemArtifacts`)})}),t(o,{variant:`ghost`,size:`sm`,onClick:x,disabled:y,className:`h-6 w-6 p-0`,children:t(zy,{className:`size-3.5 ${y?`animate-spin`:``}`})})]})]}),t(`label`,{htmlFor:F,className:`sr-only`,children:u(`form.filter`)}),t(R,{id:F,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:E,onChange:D,clearable:!0})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:N.length>0?t(`div`,{className:`min-w-0`,children:N.map(e=>t(yZ,{node:e,depth:0,runId:r,onOpen:I,onDownload:te,downloadingPath:S,forceExpanded:!!M},`${r}:${e.path}`))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(!f&&v>0?`agent.onlySystemArtifacts`:`agent.noContentAvailable`)})}),ne&&n(ce,{isOpen:!!w,onClose:()=>T(null),size:`xl`,className:`h-[90vh] p-0`,description:`Artifact preview`,children:[t(de,{show:!1,children:ne.fileName}),t(le,{className:`h-full max-h-none p-0`,children:t(ct.Suspense,{fallback:t(p,{className:`h-full`,children:t(wv,{className:`size-6 animate-spin text-muted`})}),children:t(hZ,{source:ne,className:`h-full`,showHeader:!0,onDownload:()=>w&&void te(w)})})})]})]}):t(TZ,{icon:t(oy,{className:`mb-2 size-8`}),children:`No run selected`})}const DZ=ct.memo(EZ);Q();function OZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kZ(e){if(!OZ(e))return;let t=e.browseruse??e.browser_use;if(!OZ(t))return;let n={widget:typeof t.widget==`string`?t.widget:void 0,browser_workflow_id:typeof t.browser_workflow_id==`string`?t.browser_workflow_id:void 0,workstream_id:typeof t.workstream_id==`string`?t.workstream_id:void 0,phase:typeof t.phase==`string`?t.phase:void 0,url:typeof t.url==`string`?t.url:void 0,title:typeof t.title==`string`?t.title:void 0,screenshot:typeof t.screenshot==`string`?t.screenshot:void 0,raw_screenshot:typeof t.raw_screenshot==`string`?t.raw_screenshot:void 0,prefer_raw_screenshot:typeof t.prefer_raw_screenshot==`boolean`?t.prefer_raw_screenshot:void 0,updated_at:typeof t.updated_at==`number`?t.updated_at:void 0};if(!(n.widget&&n.widget!==`browseruse`)&&(n.url||n.title||n.screenshot||n.raw_screenshot))return n}function AZ(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=kZ(n.details);if(!e)continue;let r=e.workstream_id||n.workstream_id||`main`,i=e.updated_at??(typeof n.timestamp==`number`?n.timestamp:new Date(n.timestamp).getTime()),a=t.get(r);(!a||i>=a.timestamp)&&t.set(r,{state:{...e,workstream_id:r},timestamp:i})}return new Map(Array.from(t.entries()).map(([e,t])=>[e,t.state]))}function jZ(e){return e.replace(/^artifact:\/\//,``).replace(/^artifact:/,``).replace(/^\/+/,``)}function MZ(e){return e?e.replace(/_/g,` `):`browser`}function NZ({state:e,runId:r,className:a,compact:o}){let{t:s}=K(),{client:c}=q(),l=_C(),{openImage:u}=LG(),[d,f]=G(),p=e.prefer_raw_screenshot===!1?e.screenshot||e.raw_screenshot:e.raw_screenshot||e.screenshot,m=e.title||e.url||s(`agent.browserUse`),h=U(()=>p&&jZ(p).split(`/`).pop()||s(`agent.browserScreenshot`),[p,s]);return H(()=>{if(!p){f(void 0);return}if(p.startsWith(`http://`)||p.startsWith(`https://`)){f(p);return}if(!r){f(void 0);return}let e=!1;return(async()=>{let t=jZ(p);try{let n=yC(r,t,`inline`),i=l?await l.getOrFetch(n,async()=>(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url):(await c.files.getArtifactDownloadUrl(r,t,`inline`)).url;e||f(i)}catch(n){console.error(`Failed to resolve browser screenshot ${t}`,n),e||f(void 0)}})(),()=>{e=!0}},[c,r,p,l]),o?n(`div`,{className:z(`overflow-hidden rounded-md border border-border/70 bg-transparent`,a),children:[n(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[t(ry,{className:`size-3.5 shrink-0 text-info`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserPreview`)}),e.phase&&n(`span`,{className:`truncate text-[11px] capitalize text-muted`,children:[`· `,MZ(e.phase)]})]}),t(`div`,{className:`truncate text-[11px] text-muted`,title:m,children:m})]}),e.url&&t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Zg,{className:`size-3`})})]}),p&&(d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-32 w-full object-contain`})}):n(`div`,{className:`flex min-h-16 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-4 text-xs text-muted`,children:[t(Z_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}))]}):n(`div`,{className:z(`overflow-hidden rounded-md border border-muted bg-mixer-muted/10`,a),children:[n(`div`,{className:`flex items-start justify-between gap-2 border-b border-muted px-2.5 py-2`,children:[n(`div`,{className:`flex min-w-0 items-start gap-2`,children:[t(ry,{className:`mt-0.5 size-4 shrink-0 text-info`}),n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-xs font-medium text-foreground`,children:s(`agent.browserUse`)}),t(`div`,{className:`truncate text-xs text-muted`,title:m,children:m})]})]}),t(i,{variant:`info`,className:`shrink-0 capitalize`,children:MZ(e.phase)})]}),d?t(`button`,{type:`button`,className:`block w-full bg-mixer-muted/20 text-start`,onClick:()=>u(d,h),title:s(`agent.clickToEnlarge`),children:t(`img`,{src:d,alt:h,className:`block max-h-56 w-full object-contain`})}):n(`div`,{className:`flex min-h-28 items-center justify-center gap-2 bg-mixer-muted/20 px-3 py-6 text-xs text-muted`,children:[t(Z_,{className:`size-4`}),t(`span`,{children:s(`agent.browserScreenshotPending`)})]}),e.url&&n(`div`,{className:`flex items-center gap-2 border-t border-muted px-2.5 py-1.5`,children:[t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 truncate text-xs text-info hover:underline`,title:e.url,children:e.url}),t(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:s(`agent.openInNewTab`),className:z(`inline-flex h-6 shrink-0 items-center justify-center rounded-md px-1.5`,`text-muted hover:bg-muted hover:text-foreground`),children:t(Zg,{className:`size-3`})})]})]})}Q();function PZ({documentId:e,title:r,onBack:i,onUpdateDocumentTitle:a,refreshKey:s,runId:c}){let{client:l}=q(),{t:u}=K(),[d,f]=G(null),[p,m]=G(!1),[h,g]=G(null),[_,v]=G(null),y=V(async e=>{m(!0),g(null);try{let[t,n]=await Promise.all([l.store.objects.getObjectText(e),l.store.objects.retrieve(e)]);f(t.text??null);let r=n.name;v(r),r&&a?.(e,r)}catch(e){let t=e instanceof Error?e.message:u(`agent.failedToLoadDocument`);g(t),f(null)}finally{m(!1)}},[l,a,u]);return H(()=>{y(e)},[e,s,y]),n(`div`,{className:`h-full overflow-hidden flex flex-col`,children:[n(`div`,{className:`flex items-center justify-between gap-1 px-2 py-1 border-b border-border/60 shrink-0`,children:[t(o,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 rounded-md p-0`,onClick:i,"aria-label":u(`agent.backToDocuments`),title:u(`agent.backToDocuments`),children:t(Jm,{className:`size-4 cn-rtl-flip`})}),n(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[t(h_,{className:`size-4 text-muted shrink-0`}),t(`span`,{className:`truncate text-sm font-medium`,title:_||r,children:_||r||u(`agent.document`)})]}),n(nr,{href:`/store/objects/${e}#overview`,topLevelNav:!0,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(Ke,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Zg,{className:`size-4`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-4 py-4`,children:p?n(`div`,{className:`flex items-center justify-center py-12`,children:[t(wv,{className:`size-5 animate-spin text-muted`}),t(`span`,{className:`ms-2 text-sm text-muted`,children:u(`agent.loadingDocument`)})]}):h?t(`div`,{className:`p-4 rounded-md bg-destructive/10 text-destructive text-sm`,children:h}):d?t(`div`,{className:`vprose prose prose-sm max-w-none`,children:t(Ft,{artifactRunId:c,children:d})}):n(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted`,children:[t(h_,{className:`size-8 mb-2`}),t(`span`,{className:`text-sm`,children:u(`agent.noContentAvailable`)})]})})]})}const FZ=ct.memo(PZ);Q();function IZ({documents:r,activeDocumentId:i,onSelectDocument:a,onUpdateDocumentTitle:s,refreshKey:c,runId:l}){let{t:u}=K(),[d,f]=G(``),p=bt(),m=d.trim().toLocaleLowerCase(),h=U(()=>m?r.filter(e=>e.title.toLocaleLowerCase().includes(m)):r,[r,m]),g=V(()=>a(null),[a]),_=i?r.find(e=>e.id===i):void 0;return i?t(FZ,{documentId:i,title:_?.title,onBack:g,onUpdateDocumentTitle:s,refreshKey:c,runId:l}):n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[t(`span`,{className:`text-xs text-muted`,children:m?u(`agent.documentsFiltered`,{visible:h.length,total:r.length}):u(`agent.documentCount`,{count:r.length})}),r.length>5&&n(e,{children:[t(`label`,{htmlFor:p,className:`sr-only`,children:u(`form.filter`)}),t(R,{id:p,type:`text`,role:`searchbox`,autoComplete:`off`,placeholder:u(`store.searchPlaceholder`),value:d,onChange:f,clearable:!0})]})]}),t(`div`,{className:`flex-1 overflow-y-auto px-3 py-2`,children:h.length>0?t(`div`,{className:`min-w-0`,children:h.map(e=>n(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n(o,{variant:`unstyled`,className:`flex min-w-0 flex-1 items-center justify-start gap-1.5 rounded px-1 py-1 text-start text-sm hover:bg-muted/30`,onClick:()=>a(e.id),title:e.title,children:[t(h_,{className:`size-4 shrink-0 text-muted`}),t(`span`,{className:`min-w-0 truncate`,children:e.title})]}),n(nr,{href:`/store/objects/${e.id}#overview`,topLevelNav:!0,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-muted/20 hover:text-foreground`,children:[t(Ke,{description:u(`agent.openDocument`),placement:`top`,size:`xs`,asChild:!0,children:t(Zg,{className:`size-3.5`,"aria-hidden":`true`})}),t(`span`,{className:`sr-only`,children:u(`agent.openDocument`)})]})]},e.id))}):t(`div`,{className:`px-1 py-6 text-sm text-muted`,children:u(`agent.noMatchingDocuments`)})})]})}const LZ=ct.memo(IZ);Q();function RZ({plan:e,workstreamStatus:r,isOpen:i,onClose:a,plans:s=[],activePlanIndex:c=0,onChangePlan:l=()=>{}}){let{t:u}=K();if(!i)return null;let d=e.plan||[],f=d.length,m=d.reduce((e,t)=>t?.id&&(r.get(t.id.toString())===`completed`||t.status===`completed`)?e+1:e,0),h=f>0?Math.round(m/f*100):0,g=s.length>0?s.length-c:1,_=s[c]?.timestamp;return d.length===0?t(`div`,{className:`h-full overflow-hidden`,children:n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[t(wg,{className:`mb-2 size-8`}),t(`span`,{className:`text-sm`,children:u(`agent.noPlanAvailable`)})]})}):t(`div`,{className:`h-full overflow-hidden`,children:n(`div`,{className:`flex h-full flex-col gap-4 overflow-y-auto px-2 py-3`,children:[n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-medium text-foreground`,children:u(`agent.taskProgress`)}),t(`div`,{className:`text-xs text-muted`,children:u(`agent.tasksCompleted`,{completed:m,total:f})})]}),s.length>1&&n(`div`,{className:`flex shrink-0 items-center gap-1 text-xs text-muted`,children:[t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.min(s.length-1,c+1)),disabled:c>=s.length-1,"aria-label":u(`agent.olderPlan`),title:u(`agent.olderPlan`),children:t(Ah,{className:`size-4`,"aria-hidden":`true`})}),n(`div`,{className:`min-w-20 text-center`,children:[n(`div`,{className:`font-medium text-foreground`,children:[g,`/`,s.length]}),t(`div`,{className:`truncate`,children:_?new Date(_).toLocaleTimeString():u(`agent.unknownTime`)})]}),t(o,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>l(Math.max(0,c-1)),disabled:c<=0,"aria-label":u(`agent.newerPlan`),title:u(`agent.newerPlan`),children:t(Nh,{className:`size-4`,"aria-hidden":`true`})})]})]}),t(`div`,{className:`h-2 overflow-hidden rounded-full bg-mixer-muted/20`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":f,"aria-valuenow":m,"aria-label":u(`agent.taskProgress`),children:t(`div`,{className:`h-full rounded-full bg-success transition-all duration-300`,style:{width:`${h}%`}})})]}),t(`ol`,{className:`divide-y divide-border/60`,children:d.map((e,i)=>{let a=e.id?e.id.toString():`task-${i}`,o=e.goal||`Task ${i+1}`,s=e.id?`task-${e.id.toString()}`:`task-${o}-${e.status||`pending`}`,c=e.status||`pending`,l=r.get(a);l!==void 0&&(c=l);let d=vg,f=`text-muted`;c===`in_progress`?(d=Dg,f=`text-info`):c===`completed`&&(d=rg,f=`text-success`);let p=u(c===`completed`?`agent.completed`:c===`in_progress`?`agent.inProgress`:`agent.pending`);return n(`li`,{className:`grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 px-1 py-3`,children:[t(`span`,{className:`mt-0.5 min-w-5 text-center text-xs font-medium tabular-nums text-muted/80`,children:a}),t(`span`,{className:`min-w-0 text-sm leading-5 text-foreground/85`,children:o}),n(`span`,{className:z(`flex items-center gap-1.5 text-xs font-medium`,f),children:[t(d,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),t(`span`,{children:p})]})]},s)})}),(()=>{let e=new Set(d.filter(e=>e?.id).map(e=>e.id.toString())),i=Array.from(r.entries()).filter(([t])=>t!==`main`&&!e.has(t));return i.length>0?n(`div`,{className:`mt-1 px-1 py-2`,children:[t(`div`,{className:`mb-2 text-xs font-medium text-muted`,children:u(`agent.workstreams`)}),t(`div`,{className:`divide-y divide-border/60`,children:i.map(([e,r])=>{let i=vg,a=`text-muted`,o=u(`agent.pending`);return r===`in_progress`?(i=Dg,a=`text-info`,o=u(`agent.inProgress`)):r===`completed`&&(i=rg,a=`text-success`,o=u(`agent.completed`)),n(`div`,{className:`flex items-center gap-2 py-2`,children:[t(i,{className:z(`size-3.5 shrink-0`,a)}),t(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:e}),t(`span`,{className:`text-xs font-medium text-muted`,children:o})]},e)})})]}):null})()]})})}const zZ=ct.memo(RZ);Q();function BZ({icon:e,children:r}){return n(p,{className:`h-full min-h-[240px] flex-col text-center text-muted`,children:[e,t(`span`,{className:`text-sm`,children:r})]})}function VZ({files:e}){let{t:r}=K(),a=U(()=>e?Array.from(e.values()):[],[e]),o=e=>{switch(e){case vn.UPLOADING:case vn.PROCESSING:return t(wv,{className:`size-4 animate-spin text-info`});case vn.READY:return t(rg,{className:`size-4 text-success`});case vn.ERROR:return t(hg,{className:`size-4 text-destructive`});default:return t(h_,{className:`size-4 text-muted`})}},s=e=>{switch(e){case vn.UPLOADING:return t(i,{variant:`info`,children:r(`agent.uploading`)});case vn.PROCESSING:return t(i,{variant:`info`,children:r(`agent.processing`)});case vn.READY:return t(i,{variant:`success`,children:r(`agent.ready`)});case vn.ERROR:return t(i,{variant:`destructive`,children:r(`agent.error`)});default:return null}};return t(`div`,{className:`h-full min-h-0`,children:a.length===0?t(BZ,{icon:t(h_,{className:`mb-2 size-8`}),children:r(`agent.noFilesUploadedYet`)}):t(`div`,{className:`space-y-2 p-2`,children:a.map(e=>n(`div`,{className:`flex items-start gap-2 p-2 border border-muted rounded-md`,children:[t(`div`,{className:`mt-0.5`,children:o(e.status)}),n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-sm font-medium truncate`,children:e.name}),s(e.status)]}),e.error&&t(`div`,{className:`text-xs text-destructive mt-1`,children:e.error})]})]},e.id))})})}var HZ=class extends ct.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`Agent right panel section failed to render`,{error:e,componentStack:t.componentStack})}render(){return this.state.hasError?n(`div`,{className:z(`rounded-md border border-destructive bg-mixer-destructive/10 text-destructive`,this.props.compact?`p-2 text-xs`:`m-3 p-3 text-sm`),children:[t(`div`,{className:`font-medium`,children:this.props.title}),t(`div`,{className:`mt-1 text-xs text-muted`,children:this.props.description}),this.state.message&&t(`div`,{className:`mt-1 break-all text-[11px] text-muted`,children:this.state.message})]}):this.props.children}};function UZ({workstreams:e,messages:r,runId:a}){let{t:s}=K(),{client:c}=q(),l=it(),u=U(()=>AZ(r),[r]),d=s(`agent.panelRenderErrorDescription`),f=V(e=>{navigator.clipboard.writeText(e),l({status:`success`,title:s(`agent.runIdCopied`),duration:2e3})},[s,l]),p=V(async e=>{try{let t=await $U(c,e);t&&window.open(t,`_blank`)}catch{l({status:`error`,title:s(`agent.failedToDownload`)})}},[c,s,l]);return e.length===0?t(BZ,{icon:t(lv,{className:`mb-2 size-8`}),children:s(`agent.noActiveParallelTasks`)}):n(`div`,{className:`h-full min-h-0 overflow-y-auto px-2 py-2`,children:[t(`div`,{className:`px-1 pb-2 text-xs text-muted`,children:s(`agent.parallelWorkDescription`)}),t(`div`,{className:`divide-y divide-border/60`,children:e.map(e=>{let r=e.status===`running`||e.status===`canceling`,c=Math.round(e.elapsed_ms/1e3),l=Math.max(0,Math.round(e.remaining_ms/1e3)),m=e.deadline_ms>0?Math.min(100,Math.round(e.elapsed_ms/e.deadline_ms*100)):0,h=u.get(e.workstream_id),g=e.deadline_ms>0,_=e.child_workflow_run_id,v=[e.phase?OU(e.phase):void 0,c>0?s(`agent.elapsed`,{seconds:c}):void 0,g&&l>0?s(`agent.remaining`,{seconds:l}):void 0].filter(Boolean),y=(()=>{switch(e.status){case`running`:return t(i,{variant:`info`,children:s(`agent.running`)});case`canceling`:return t(i,{variant:`attention`,children:s(`agent.canceling`)});case`completed`:return t(i,{variant:`done`,children:s(`agent.completed`)});case`failed`:return t(i,{variant:`destructive`,children:s(`agent.failed`)});case`timeout`:return t(i,{variant:`destructive`,children:s(`agent.timeout`)});case`canceled`:return t(i,{variant:`destructive`,children:s(`agent.canceled`)})}})();return t(HZ,{title:s(`agent.workstreamRenderError`),description:d,compact:!0,children:t(`div`,{className:`py-3`,children:n(`div`,{className:`flex items-start gap-2`,children:[t(`span`,{className:z(`mt-2 size-2 shrink-0 rounded-full`,IU(e.status)),"aria-hidden":`true`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[t(`span`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,title:e.workstream_id,children:OU(e.workstream_id)}),y]}),v.length>0&&t(`div`,{className:`mt-0.5 truncate text-xs text-muted`,children:v.join(` · `)}),r&&g&&t(`div`,{className:`mt-2 h-1 rounded-full bg-muted`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":m,"aria-valuetext":s(`agent.workstreamProgress`,{percent:m}),children:t(`div`,{className:`h-full rounded-full bg-info transition-all duration-500`,style:{width:`${m}%`}})}),h&&t(HZ,{title:s(`agent.browserWidgetRenderError`),description:d,compact:!0,children:t(NZ,{state:h,runId:a,compact:!0,className:`mt-2`})}),_&&n(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>f(_),children:[t(xg,{className:`size-3 me-1`}),s(`agent.copyRunId`)]}),n(o,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted hover:text-foreground`,onClick:()=>p(_),children:[t(Ag,{className:`size-3 me-1`}),s(`agent.download`)]})]})]})]})})},e.launch_id)})})]})}function WZ({plan:e,workstreamStatus:r,plans:i=[],activePlanIndex:a=0,onChangePlan:s,activeWorkstreams:c=[],messages:l=[],hideWorkstreams:u=!1,openDocuments:d=[],activeDocumentId:f,onSelectDocument:p,onUpdateDocumentTitle:m,docRefreshKey:h=0,runId:g,processingFiles:_,showArtifacts:v=!1,artifactRefreshKey:y=0,artifactRefreshDetails:b,selectedArtifactPath:x,onSelectedArtifactPathChange:S,onSendMessage:C,payloadContent:w,conversationContent:T,onClose:E,defaultTab:D,activeTab:O,onTabChange:k}){let{t:A}=K(),[j,M]=G(D||`plan`),ee=O??j,N=e=>{M(e),k?.(e)},P=!u&&c.length>0,F=d.length>0,te=_?_.size>0:!1,I=V((e,n)=>t(HZ,{title:A(`agent.panelRenderError`,{name:e}),description:A(`agent.panelRenderErrorDescription`),children:n}),[A]),ne={name:`conversation`,label:`Conversation`,content:T?I(`Conversation`,t(`div`,{className:`flex flex-col h-full min-h-0`,children:T})):null,is_allowed:!!T},L=[...T?[ne]:[],{name:`plan`,label:A(`agent.plan`),content:I(A(`agent.plan`),e?t(zZ,{plan:e,workstreamStatus:r||/* @__PURE__ */ new Map,isOpen:!0,onClose:E,plans:i,activePlanIndex:a,onChangePlan:s}):t(BZ,{icon:t(lv,{className:`mb-2 size-8`}),children:A(`agent.noPlanAvailable`)})),is_allowed:!0},{name:`workstreams`,label:P?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.workstreams`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:c.length})]}):A(`agent.workstreams`),content:I(A(`agent.workstreams`),t(UZ,{workstreams:c,messages:l,runId:g})),is_allowed:!u},{name:`documents`,label:F?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.documents`),` `,t(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full bg-info px-1.5 py-0.5 text-[10px] text-info`,children:d.length})]}):A(`agent.documents`),content:I(A(`agent.documents`),d.length>0&&p?t(LZ,{documents:d,activeDocumentId:f??null,onSelectDocument:p,onUpdateDocumentTitle:m,refreshKey:h,runId:g}):t(BZ,{icon:t(h_,{className:`mb-2 size-8`}),children:A(`agent.noDocumentsOpen`)})),is_allowed:!0},{name:`uploads`,label:te?n(`span`,{className:`inline-flex min-w-0 items-center gap-1 whitespace-nowrap`,children:[A(`agent.uploads`),` `,t(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-info`})]}):A(`agent.uploads`),content:I(A(`agent.uploads`),t(VZ,{files:_})),is_allowed:!0},{name:`artifacts`,label:A(`agent.artifacts`),content:I(A(`agent.artifacts`),t(DZ,{runId:g,refreshKey:y,refreshDetails:b,selectedPath:x,onSelectedPathChange:S,onSendMessage:C})),is_allowed:v},{name:`payload`,label:A(`agent.payload`),content:w?I(A(`agent.payload`),t(`div`,{className:`overflow-y-auto`,children:w})):null,is_allowed:!!w}],R=L.filter(e=>e.is_allowed===void 0||e.is_allowed===!0);return n(Ve,{tabs:L,current:ee,onTabChange:N,fullHeight:!0,className:`px-0`,children:[n(`div`,{className:`flex items-end justify-between shrink-0 px-1 py-1 gap-1`,children:[t(me,{tabs:R,current:ee,onTabChange:N,className:`min-w-0 flex-1`}),!T&&t(o,{variant:`ghost`,size:`sm`,className:`shrink-0 ms-1`,onClick:E,title:`Close Right Panel`,children:t(xx,{className:`size-4`})})]}),t(Ue,{className:`flex-1 min-h-0 pt-0 pb-0`})]})}const GZ=ct.memo(WZ);function KZ(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`file`)continue;let i=r.getAsFile();if(i){if(r.type.startsWith(`image/`)&&(!i.name||i.name===`image.png`)){let e=r.type.split(`/`)[1]||`png`;t.push(new File([i],`pasted-image-${Date.now()}.${e}`,{type:i.type}))}else t.push(i)}}return t}function qZ(e,t){let[n,r]=G([]),[i,a]=G(0),[o,s]=G(/* @__PURE__ */ new Map),[c,l]=G(t),[u,d]=G(!1),f=W(-1),p=W(/* @__PURE__ */ new Set);H(()=>{e.length===0&&(r([]),a(0),s(/* @__PURE__ */ new Map),d(!1),f.current=-1,p.current.clear())},[e.length]);let m=V(e=>{let n=e[e.length-1];n&&(n.type===J.TERMINATED?l(!1):l(t?!0:n.type===J.REQUEST_INPUT))},[t]);return H(()=>{if(e.length===0)return;let t=f.current+1;if(t>=e.length){m(e);return}let n=!1,i=[],o=[];for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.PLAN)try{let e=null;if(t.details&&typeof t.details==`object`&&t.details.plan&&Array.isArray(t.details.plan)&&(e={plan:t.details.plan}),e){let r=typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime();if(!p.current.has(r)){p.current.add(r),n=!0,i.push({plan:e,timestamp:r});let t=/* @__PURE__ */ new Map;t.set(`main`,`in_progress`),Array.isArray(e.plan)&&e.plan.forEach(e=>{if(e&&typeof e==`object`&&e.id){let n=e.id.toString();t.set(n,e.status||`pending`)}}),o.push({timestamp:r,statusMap:t})}}}catch(e){console.error(`Failed to parse plan from message:`,e)}}f.current=e.length-1,n&&i.length>0&&(r(e=>[...[...i].reverse(),...e]),a(0),d(!0),o.length>0&&s(e=>{let t=new Map(e);for(let e of o)t.set(e.timestamp,e.statusMap);return t})),m(e)},[e,m]),H(()=>{if(n.length===1&&!u&&!sessionStorage.getItem(`plan-panel-shown`)){let e=setTimeout(()=>{d(!0),sessionStorage.setItem(`plan-panel-shown`,`true`)},500);return()=>clearTimeout(e)}},[n.length,u]),{plans:n,activePlanIndex:i,setActivePlanIndex:a,workstreamStatusMap:o,showInput:c,showSlidingPanel:u,setShowSlidingPanel:d}}function JZ(e,t){return{...e,details:{...e.details??{},_deliveryStatus:t}}}function YZ(e){let t=e.details,n=t?._messageId;if(typeof n==`string`&&n)return n;let r=t?.ack;return typeof r==`string`&&r?r:void 0}function XZ(e,t){let n=e?.[t];return typeof n==`string`&&n?n:void 0}function ZZ(e){if(e&&typeof e==`object`&&`status`in e)return typeof e.status==`number`?e.status:void 0}function QZ(e){return e?.streaming_id_scope===`workflow_run`}function $Z(e){return[J.COMPLETE,J.IDLE,J.TERMINATED,J.REQUEST_INPUT].includes(e.type)}function eQ(e){if(e.type===J.STREAMING_CHUNK)return!1;if(e.type===J.UPDATE&&typeof e.details?.event_class==`string`)return!0;if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files)return!1}return!!e.message||$Z(e)||Mn(e).length>0}function tQ(e){if(e)return{type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,text:typeof e.message==`string`?e.message.slice(0,80):e.message?`[non-string]`:``,display_role:e.details?.display_role,source:e.details?.source}}function nQ(e,t){if(e.find(e=>e.timestamp===t.timestamp))return e;if(!t.details?._optimistic&&(t.type===J.QUESTION||qU(t))){let n=typeof t.details?.ack==`string`?t.details.ack:void 0,r=n?JZ(t,`consumed`):t;if(n){let i=e.filter(e=>e.type!==t.type&&!qU(e)||!e.details?._optimistic||YZ(e)!==n);return UU(i,r),i}if(t.type===J.QUESTION){let n=e.filter(e=>e.type===J.QUESTION&&e.details?._optimistic&&e.message===t.message&&(e.workstream_id??`main`)===(t.workstream_id??`main`));if(n.length===1){let r=e.filter(e=>e!==n[0]);return UU(r,t),r}}}let n=[...e];return UU(n,t),n}function rQ(e){let t=e.details,n=XZ(t,`streaming_id`),r=XZ(t,`activity_id`);return n&&QZ(t)?n:r??n}function iQ(e){let t=e.details,n=XZ(t,`streaming_id`),r=XZ(t,`activity_id`),i=[];return n&&QZ(t)&&i.push(n),r&&i.push(r),[...new Set(i)]}function aQ(e,t,n){let[r,i]=G([]),[a,o]=G(!1),[s,c]=G(`loading`),[l,u]=G(null),[d,f]=G(null),p=W(n);p.current=n;let[m,h]=G(/* @__PURE__ */ new Map),[g,_]=G(0),v=V(()=>_(e=>e+1),[]),y=W(null),b=W(0),[x,S]=G(/* @__PURE__ */ new Map),C=W(/* @__PURE__ */ new Map),w=W(null),[T,E]=G(!1),D=W(null),O=V(()=>{let e=w.current;e&&(e.mode===`raf`?cancelAnimationFrame(e.id):clearTimeout(e.id),w.current=null)},[]),k=V(()=>{C.current.size>0&&(S(new Map(C.current)),E(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>E(!1),50)),w.current=null},[]);return H(()=>{o(!KU(r))},[r]),H(()=>{HU(`stream state`,{agentRunId:t,messageCount:r.length,streamingCount:x.size,initialHistoryStatus:s,isCompleted:a,lastDeliveredTs:b.current,first:tQ(r[0]),last:tQ(r[r.length-1])})},[t,s,a,r,x.size]),H(()=>{let n=y.current!==t;y.current=t,n&&(i([]),c(`loading`),u(null),f(null),S(/* @__PURE__ */ new Map),h(/* @__PURE__ */ new Map),b.current=0);let r=new AbortController,a=n?void 0:b.current||void 0;return HU(`stream start`,{agentRunId:t,isNewConversation:n,since:a,streamNonce:g}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(HU(`internals loaded`,{agentRunId:t,status:e.status,first_workflow_run_id:e.first_workflow_run_id}),u(e.status?.toUpperCase()??null),f(e.first_workflow_run_id??null))}).catch(e=>{if(!r.signal.aborted){let n=ZZ(e);n===404?HU(`agent run internals not available yet`,{agentRunId:t,status:n}):qn.logger.warn(`Failed to check agent run status; continuing with the message stream`,{vertesia:{agent_run_id:t,status:n,error:e}})}}),e.agents.streamMessages(t,e=>{if(r.signal.aborted)return;let n=!!(e.timestamp&&e.timestamp<=b.current);if(n||p.current?.(e),HU(`stream message`,{agentRunId:t,type:e.type,timestamp:e.timestamp,workstream_id:e.workstream_id,hasMessage:!!e.message,display_role:e.details?.display_role,source:e.details?.source}),e.timestamp&&e.timestamp>b.current&&(b.current=e.timestamp),e.type===J.STREAMING_CHUNK){let t=e.details,n=rQ(e);if(!n)return;let r=C.current.get(n)||{text:``,workstreamId:e.workstream_id,startTimestamp:Date.now(),activityId:t?.activity_id,streamingId:t?.streaming_id},i=r.text+(e.message||``);C.current.set(n,{text:i,workstreamId:e.workstream_id,isComplete:t.is_final,startTimestamp:r.startTimestamp,activityId:t?.activity_id,streamingId:t?.streaming_id}),w.current===null&&(document.hidden?w.current={mode:`timeout`,id:window.setTimeout(k,16)}:w.current={mode:`raf`,id:requestAnimationFrame(k)});return}if(e.type===J.SYSTEM){let t=e.details;if(t?.system_type===`file_processing`&&t.files){n||h(new Map(t.files.map(e=>[e.id,e])));return}}if(e.type===J.THOUGHT||e.type===J.ANSWER){let t=iQ(e);if(t.length>0){for(let e of t)C.current.delete(e);S(e=>{let n=new Map(e),r=!1;for(let e of t)r=n.delete(e)||r;return r?n:e})}}(e.type===J.COMPLETE||e.type===J.IDLE)&&C.current.size>0&&k(),eQ(e)&&i(t=>nQ(t,e))},a,r.signal,{closeOnIdle:!1,onHistoryLoaded:e=>{if(r.signal.aborted)return;let n=e.filter(eQ),o,s=-1/0;for(let t of e)if(t.timestamp&&t.timestamp>b.current&&(b.current=t.timestamp),t.type===J.SYSTEM){let e=t.details;if(e?.system_type===`file_processing`&&e.files){let n=t.timestamp??-1/0;(!o||n>=s)&&(o=e,s=n)}}o&&h(new Map(o.files.map(e=>[e.id,e]))),HU(`history loaded`,{agentRunId:t,count:e.length,timelineCount:n.length,since:a,first:tQ(e[0]),last:tQ(e[e.length-1])}),c(e.length>0?`has_messages`:`empty`),n.length>0&&i(e=>n.reduce((e,t)=>nQ(e,t),e))},onHistoryError:e=>{r.signal.aborted||(HU(`history error`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),c(`error`))}}).then(()=>{if(!r.signal.aborted)return HU(`stream resolved`,{agentRunId:t}),e.agents.getInternals(t).then(e=>{r.signal.aborted||(HU(`internals refreshed after stream end`,{agentRunId:t,status:e.status}),u(e.status?.toUpperCase()??null))}).catch(e=>{r.signal.aborted||console.error(`Failed to refresh agent run status on stream end:`,e)})}).catch(e=>{r.signal.aborted||(HU(`stream failed`,{agentRunId:t,error:e instanceof Error?e.message:String(e)}),console.error(`Failed to stream agent messages:`,e))}),()=>{HU(`stream cleanup`,{agentRunId:t,streamNonce:g}),r.abort(),O(),C.current.clear(),D.current&&=(clearTimeout(D.current),null)}},[t,g,e.agents,k,O]),H(()=>{let e=()=>{!document.hidden&&C.current.size>0&&(O(),k())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[k,O]),{messages:r,streamingMessages:x,isCompleted:a,initialHistoryStatus:s,debugChunkFlash:T,addOptimisticMessage:V(e=>{i(t=>{let n=[...t,e];return n.sort((e,t)=>(typeof e.timestamp==`number`?e.timestamp:new Date(e.timestamp).getTime())-(typeof t.timestamp==`number`?t.timestamp:new Date(t.timestamp).getTime())),n})},[]),updateOptimisticMessageStatus:V((e,t)=>{i(n=>n.map(n=>n.details?._optimistic&&YZ(n)===e?JZ(n,t):n))},[]),removeOptimisticMessages:V(e=>{i(t=>t.filter(t=>!e(t)))},[]),reconnect:v,agentRunStatus:l,workflowRunId:d,serverFileUpdates:m}}function oQ(e){if(typeof e==`string`&&e.trim().length>0)return e}function sQ(e,t){let n=oQ(e.revision_root_id)||oQ(e.revision_root)||oQ(e.root_document_id)||oQ(e.root_id);if(n)return n;let r=e.revision_info;if(r&&typeof r==`object`){let e=oQ(r.root);if(e)return e}return t}function cQ(e,t){return e.revisionRootId&&t.revisionRootId?e.revisionRootId===t.revisionRootId:t.revisionRootId?e.id===t.revisionRootId:e.revisionRootId?e.revisionRootId===t.id:e.id===t.id}function lQ(e){let[t,n]=G([]),[r,i]=G(null),[a,o]=G(!1),[s,c]=G(0),l=W(-1);return H(()=>{e.length===0&&(n([]),i(null),o(!1),c(0),l.current=-1)},[e.length]),H(()=>{let t=l.current+1;if(!(t>=e.length)){for(let r=t;r<e.length;r++){let t=e[r];if(t.type===J.UPDATE&&t.details){let e=t.details;if(e.event_class===`document_created`||e.event_class===`document_updated`){let t=oQ(e.document_id),r=oQ(e.updated_document_id)||t,a=e.title;if(r){let s=sQ(e,t||r),l={id:r,title:a||`Document`,revisionRootId:s};n(e=>{let t=e.findIndex(e=>cQ(e,l));if(t<0)return[...e,l];let n=e[t];if(n.id===l.id&&n.title===l.title&&n.revisionRootId===l.revisionRootId)return e;let r=[...e];return r[t]=l,r}),i(l.id),o(!0),e.event_class===`document_updated`&&c(e=>e+1)}}}}l.current=e.length-1}},[e]),{openDocuments:t,activeDocumentId:r,isDocPanelOpen:a,docRefreshKey:s,closeDocPanel:V(()=>{o(!1)},[]),selectDocument:V(e=>{i(e)},[]),openDocInPanel:V(e=>{n(t=>t.some(t=>t.id===e)?t:[...t,{id:e,title:`Document`,revisionRootId:e}]),i(e),o(!0)},[]),updateDocumentTitle:V((e,t)=>{n(n=>n.map(n=>n.id===e?{...n,title:t}:n))},[])}}function uQ(e){return e.type.startsWith(`image/`)}function dQ(e){if(uQ(e)&&typeof URL<`u`&&URL.createObjectURL)return URL.createObjectURL(e)}function fQ(e){typeof URL<`u`&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function pQ(e,t,n,r,i){let a=Qt.getFixedT(null,Zt),[o,s]=G(/* @__PURE__ */ new Map),[c,l]=G(/* @__PURE__ */ new Set),u=W(/* @__PURE__ */ new Set),d=W(/* @__PURE__ */ new Map),f=W(t),p=W(o);p.current=o;let m=W(n);m.current=n;let h=V(e=>{let t=d.current.get(e);t&&(fQ(t),d.current.delete(e))},[]);H(()=>{if(f.current!==t){f.current=t,d.current.forEach(fQ),d.current.clear(),s(/* @__PURE__ */ new Map);let e=/* @__PURE__ */ new Set;u.current=e,l(e)}},[t]),H(()=>()=>{d.current.forEach(fQ),d.current.clear()},[]);let g=U(()=>{let e=/* @__PURE__ */ new Map;if(o.forEach((t,n)=>{c.has(n)||e.set(n,t)}),n.forEach((t,n)=>{if(t.consumed_at){e.delete(n);return}if(!c.has(n)){let r=o.get(n);e.set(n,{...t,artifact_path:t.artifact_path??r?.artifact_path,reference:t.reference??r?.reference,...r?.preview_url?{preview_url:r.preview_url}:{}})}}),i&&i.size>0)for(let[t,n]of e)(n.reference&&i.has(n.reference)||n.artifact_path&&i.has(n.artifact_path))&&e.delete(t);return e},[o,c,n,i]);return{processingFiles:g,hasProcessingFiles:U(()=>Array.from(g.values()).some(e=>e.status===vn.UPLOADING||e.status===vn.PROCESSING),[g]),handleFileUpload:V(async n=>{for(let i of n){let n=`file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,o=`files/${i.name}`,c=dQ(i);c&&d.current.set(n,c);let l={id:n,name:i.name,content_type:i.type||`application/octet-stream`,size:i.size,status:vn.UPLOADING,started_at:Date.now(),preview_url:c};s(e=>new Map(e).set(n,l));try{if(await e.agents.uploadArtifact(t,o,i),s(e=>{let t=new Map(e),r=t.get(n);return r&&(r.status=vn.PROCESSING,r.artifact_path=o,r.reference=`artifact:${o}`),t}),u.current.has(n))continue;await e.agents.sendSignal(t,`FileUploaded`,{id:n,name:i.name,content_type:i.type||`application/octet-stream`,reference:`artifact:${o}`,artifact_path:o})}catch(e){if(u.current.has(n))continue;s(t=>{let r=new Map(t),i=r.get(n);return i&&(i.status=vn.ERROR,i.error=e instanceof Error?e.message:`Upload failed`,i.completed_at=Date.now()),r}),r({status:`error`,title:a(`agent.uploadFailed`),description:e instanceof Error?e.message:`Failed to upload file`,duration:3e3})}}},[e,t,r,a]),removeProcessingFile:V(async n=>{l(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),u.current=t,t}),s(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t}),h(n);try{await e.agents.sendSignal(t,`FileRemoved`,{id:n})}catch(e){r({status:`error`,title:a(`agent.removeFileFailed`),description:e instanceof Error?e.message:`Failed to remove file`,duration:3e3})}},[t,e,h,a,r]),clearProcessingFiles:V(()=>{d.current.forEach(fQ),d.current.clear(),l(e=>{let t=new Set(e);for(let e of m.current.keys())t.add(e);for(let e of p.current.keys())t.add(e);return u.current=t,t}),s(/* @__PURE__ */ new Map)},[])}}Q();function mQ({activeWorkstreams:r,onSelectWorkstream:i,className:a}){let{t:s}=K(),[c,l]=G(!1),[u,d]=G(!1),f=bt(),p=U(()=>r.filter(e=>e.status===`running`||e.status===`canceling`),[r]),m=c?p:p.slice(0,3),h=Math.max(0,p.length-m.length),g=p.length>3;return H(()=>{g||l(!1)},[g]),p.length===0?null:t(`div`,{className:z(`mx-auto mb-2 w-full max-w-3xl px-1`,a),"data-agent-active-workstreams":!0,children:n(`output`,{className:`flex flex-col gap-1.5 rounded-2xl border border-border/70 bg-background/95 p-2 text-xs text-muted shadow-lg shadow-black/5`,"aria-live":`polite`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`div`,{className:`flex min-w-0 items-center gap-2 px-1 font-medium`,children:[t(eh,{className:`size-3.5 shrink-0 text-muted`,"aria-hidden":`true`}),t(`span`,{className:`truncate`,children:s(`agent.activeWorkstreams`,{count:p.length})})]}),n(o,{variant:`ghost`,size:`icon`,onClick:()=>d(!u),title:s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`),children:[t(u?Ih:Dh,{className:`size-4`}),s(u?`agent.showActiveWorkstreams`:`agent.hideActiveWorkstreams`)]})]}),u?null:n(e,{children:[t(`div`,{id:f,className:`flex flex-col gap-0.5`,children:m.map(r=>{let a=AU(r.workstream_id,r.interaction),s=n(e,{children:[t(`span`,{className:z(`size-1.5 shrink-0 rounded-full`,IU(r.status)),"aria-hidden":`true`}),t(`span`,{className:`truncate font-medium`,children:a}),r.phase&&t(`span`,{className:`truncate text-xs text-muted/75`,children:OU(r.phase)})]});return i?n(o,{type:`button`,variant:`ghost`,className:`h-auto min-w-0 justify-start gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,onClick:()=>{l(!1),i(r.workstream_id)},children:[s,t(Nh,{className:`ms-auto size-3.5 shrink-0 rtl:rotate-180`,"aria-hidden":`true`})]},r.launch_id||r.workstream_id):t(`div`,{className:`flex min-w-0 items-center gap-2 rounded-lg px-1 py-1 text-sm text-foreground/80`,title:a,children:s},r.launch_id||r.workstream_id)})}),g&&n(o,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 w-fit shrink-0 gap-1 rounded-xl px-2.5 text-xs text-muted`,"aria-expanded":c,"aria-controls":f,onClick:()=>l(e=>!e),children:[!c&&n(`span`,{children:[`+`,h]}),s(c?`agent.showLess`:`agent.showMore`),t(Dh,{className:z(`size-3.5 transition-transform`,c&&`rotate-180`),"aria-hidden":`true`})]})]})]})})}const hQ=new ar({strict:!1,validateFormats:!1});function gQ(e){if(e!==kn.virtual_lb&&e!==kn.virtual_mediator&&e!==kn.test)return e}var _Q=class{_listeners=/* @__PURE__ */ new Set;snapshot;constructor(e){this.snapshot=new vQ(e,this)}subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)});getSnapshot=()=>this.snapshot;notify(){this._listeners.forEach(e=>{e()})}},vQ=class e{vertesia;_interactive=!0;_debug_mode=!1;_evaluate;_final_verification=!1;_non_blocking_subagents=!0;_checkpoint_tokens;_budget_tokens;_budget_usd;_visibility;_user_channels;_collection;_disabled_mcp_collections;_start=!1;_preserveRunValues=!1;_interaction;_environment;_inference_profile;_availableInferenceProfiles;_model=``;_model_options;_tool_names=[];_data;_mode=`start`;_scheduledWorkflowConfig;_interactionParamsSchema;_schemaVersion=0;_inputValidator;_store;constructor(e,t){this.vertesia=e,this._store=t}onStateChanged(){let e=this.clone();this._store.snapshot=e,this._store.notify()}clone(){let t=new e(this.vertesia,this._store);return t._interactionParamsSchema=this._interactionParamsSchema,t._schemaVersion=this._schemaVersion,t._interaction=this._interaction,t._data=this._data,t._environment=this._environment,t._inference_profile=this._inference_profile,t._availableInferenceProfiles=this._availableInferenceProfiles,t._model=this._model,t._model_options=this._model_options?{...this._model_options}:void 0,t._tool_names=[...this._tool_names],t._interactive=this._interactive,t._debug_mode=this._debug_mode,t._evaluate=this._evaluate,t._final_verification=this._final_verification,t._non_blocking_subagents=this._non_blocking_subagents,t._checkpoint_tokens=this._checkpoint_tokens,t._budget_tokens=this._budget_tokens,t._budget_usd=this._budget_usd,t._visibility=this._visibility,t._user_channels=this._user_channels?[...this._user_channels]:void 0,t._inputValidator=this._inputValidator,t._start=this._start,t._collection=this._collection,t._disabled_mcp_collections=this._disabled_mcp_collections?[...this._disabled_mcp_collections]:void 0,t._preserveRunValues=this._preserveRunValues,t._mode=this._mode,t._scheduledWorkflowConfig=this._scheduledWorkflowConfig,t}set mode(e){e!==this._mode&&(this._mode=e,e===`schedule`&&!this._scheduledWorkflowConfig&&(this._scheduledWorkflowConfig={name:``,description:``,cron_expression:`0 9 * * *`,timezone:`UTC`}),this.onStateChanged())}get mode(){return this._mode}set scheduledWorkflowConfig(e){this._scheduledWorkflowConfig=e,this.onStateChanged()}get scheduledWorkflowConfig(){return this._scheduledWorkflowConfig}updateScheduledWorkflowConfig(e){this._scheduledWorkflowConfig={...this._scheduledWorkflowConfig,...e},this.onStateChanged()}get interactive(){return this._interactive}set interactive(e){e!==this._interactive&&(this._interactive=e,this.onStateChanged())}get debug_mode(){return this._debug_mode}set debug_mode(e){e!==this._debug_mode&&(this._debug_mode=e,this.onStateChanged())}get evaluate(){return this._evaluate}set evaluate(e){e!==this._evaluate&&(this._evaluate=e,this.onStateChanged())}get final_verification(){return this._final_verification}set final_verification(e){e!==this._final_verification&&(this._final_verification=e,this.onStateChanged())}get non_blocking_subagents(){return this._non_blocking_subagents}set non_blocking_subagents(e){e!==this._non_blocking_subagents&&(this._non_blocking_subagents=e,this.onStateChanged())}get checkpoint_tokens(){return this._checkpoint_tokens}set checkpoint_tokens(e){e!==this._checkpoint_tokens&&(this._checkpoint_tokens=e,this.onStateChanged())}get budget_tokens(){return this._budget_tokens}set budget_tokens(e){e!==this._budget_tokens&&(this._budget_tokens=e,this.onStateChanged())}get budget_usd(){return this._budget_usd}setBudgetUsd(e,t){let n=e!==void 0&&Number.isFinite(e)&&e>0&&e<=(2**53-1)/1e9;this._budget_usd=n?e:void 0,n&&(this._budget_tokens??=t??1e6),this.onStateChanged()}get budget(){return this._budget_usd===void 0?this._budget_tokens!=null&&this._budget_tokens>0?{limit_tokens:this._budget_tokens}:void 0:{mode:`dollar`,limit_usd:this._budget_usd,limit_tokens:this._budget_tokens}}get visibility(){return this._visibility}set visibility(e){e!==this._visibility&&(this._visibility=e,this.onStateChanged())}get user_channels(){return this._user_channels}set user_channels(e){this._user_channels=e,this.onStateChanged()}get collection(){return this._collection}set collection(e){e!==this._collection&&(this._collection=e,this.onStateChanged())}get disabled_mcp_collections(){return this._disabled_mcp_collections}set disabled_mcp_collections(e){this._disabled_mcp_collections=e&&e.length>0?e:void 0,this.onStateChanged()}get search_scope(){return this._collection?mn.Collection:void 0}async restoreConversation(e){let t=e.interaction;e.version&&(/^[a-fA-F0-9]{24}$/.test(t)||(t=`${t}@${e.version}`));let n=await this.vertesia.interactions.catalog.resolve(t),r=n.runtime?.environment||e.config?.environment,i=e.config?.model,a=await(r?this.vertesia.environments.retrieve(r).catch(()=>void 0):Promise.resolve(void 0));this._data=e.data,this.interaction=n,e.interactionParamsSchema!=null&&(this.interactionParamsSchema=e.interactionParamsSchema),this._inference_profile=e.config?.inference_profile===void 0?e.config?.environment||e.config?.model?null:void 0:e.config.inference_profile,this._tool_names=e.tool_names||[],this._interactive=e.interactive,this._debug_mode=e.debug_mode??!1,this._non_blocking_subagents=e.non_blocking_subagents??!0,this._checkpoint_tokens=e.checkpoint_tokens,this._budget_usd=e.budget?.mode===`dollar`?e.budget.limit_usd:void 0;let o=e.budget?.limit_tokens;this._budget_tokens=o!==void 0&&o>0?o:void 0,this._user_channels=e.user_channels,this._disabled_mcp_collections=e.disabled_mcp_collections,this._model_options=e.config?.model_options,this.collection=e.collection_id??void 0,this._model_options=e.config?.model_options,this.environment=a,i&&(this._model=i),this.onStateChanged()}get interaction(){return this._interaction}set interaction(e){if(e?.id!==this._interaction?.id){if(this._interaction=e,this.interactionParamsSchema=e?Nn(e.prompts):void 0,this._inputValidator=void 0,e&&!this._preserveRunValues&&(this._model_options=e.model_options,e.runtime?.environment)){let t=e.runtime.environment;this.vertesia.environments.retrieve(t).then(e=>this.environment=e).catch(()=>{this.environment=void 0})}this.onStateChanged()}}get environment(){return this._environment}set environment(e){if(e?.id!==this._environment?.id){if(this._environment=e,!this._preserveRunValues){let t=e?gQ(e.provider):void 0,n=this.interaction?.runtime?.model;this._model=n&&t&&In(n,t)?n:e?.default_model&&t&&In(e.default_model,t)?e.default_model:``}this.onStateChanged()}}get inference_profile(){return this._inference_profile}setInferenceProfile(e){this._inference_profile=e,this.onStateChanged()}setAvailableInferenceProfiles(e){this._availableInferenceProfiles=e,this.onStateChanged()}get inferenceProfileError(){if(this._inference_profile){if(!this._availableInferenceProfiles)return`Wait for inference profiles to load, or choose another configuration.`;if(!this._availableInferenceProfiles.includes(this._inference_profile))return`This inference profile is unavailable. Choose the default, Ad hoc, or another profile.`}}get inferenceConfig(){return this._inference_profile===null?{inference_profile:null,environment:this.environment?.id,model:this.model||void 0,model_options:this.model_options}:this._inference_profile?{inference_profile:this._inference_profile}:{}}get model(){return this._model}set model(e){e!==this._model&&(this._model=e||``,this.onStateChanged())}get model_options(){return this._model_options}set model_options(e){JSON.stringify(e)!==JSON.stringify(this._model_options)&&(this._model_options=e,this.onStateChanged())}get tool_names(){return this._tool_names}set tool_names(e){this._tool_names=e,this.onStateChanged()}get data(){return this._data}set data(e){this._data=e,this.onStateChanged()}set run(e){console.log(`run`,e),this.onStateChanged()}set start(e){this._start!==e&&(this._start=e,this.onStateChanged())}markStarted(){this.start=!0}setMode(e){this.mode=e}setInteraction(e){this.interaction=e}setEnvironment(e){this.environment=e}setModel(e){this.model=e}setModelOptions(e){this.model_options=e}setToolNames(e){this.tool_names=e}setCollection(e){this.collection=e}setDisabledMcpCollections(e){this.disabled_mcp_collections=e}setInteractive(e){this.interactive=e}setDebugMode(e){this.debug_mode=e}setEvaluate(e){this.evaluate=e}setFinalVerification(e){this.final_verification=e}setUserChannels(e){this.user_channels=e}setCheckpointTokens(e){this.checkpoint_tokens=e}setBudgetTokens(e){this.budget_tokens=e}setVisibility(e){this.visibility=e}setData(e){this.data=e}setDraftData(e){this._data=e}setPreserveRunValues(e){this.preserveRunValues=e}get start(){return this._start}get preserveRunValues(){return this._preserveRunValues}set preserveRunValues(e){this._preserveRunValues=e}get schemaVersion(){return this._schemaVersion}get interactionParamsSchema(){return this._interactionParamsSchema}set interactionParamsSchema(e){this._interactionParamsSchema!==e&&(this._interactionParamsSchema=e,this._schemaVersion+=1,e&&(this._data=this.initializeBooleanDefaults(this._data||{},e)),this.onStateChanged())}initializeBooleanDefaults(e,t){if(!t.properties)return e;let n={...e};for(let[e,r]of Object.entries(t.properties)){let t=r;t.type===`boolean`&&n[e]===void 0?n[e]=!1:t.type===`object`&&t.properties&&(n[e]=this.initializeBooleanDefaults(n[e]||{},t))}return n}reset(){if(this._start=!1,this._interactive=!0,this._debug_mode=!1,this._evaluate=void 0,this._final_verification=!1,this._non_blocking_subagents=!0,this._checkpoint_tokens=void 0,this._budget_tokens=void 0,this._budget_usd=void 0,this._visibility=void 0,this._user_channels=void 0,this._collection=void 0,this._disabled_mcp_collections=void 0,this._preserveRunValues=!1,this._inference_profile=void 0,this._model=``,this._model_options=void 0,this._environment=void 0,this._tool_names=[],this._interaction=void 0,this._data=void 0,this._interactionParamsSchema=null,this._inputValidator=void 0,this.model=void 0,this.environment=void 0,this.onStateChanged(),location.hash){let e=window.location.origin+window.location.pathname+window.location.search;history.replaceState(null,``,e),location.hash=``}}validateInput(){if(!this._interactionParamsSchema)return{isValid:!0};(!this._inputValidator||this._inputValidator.schema!==this._interactionParamsSchema)&&(this._inputValidator={validate:hQ.compile(this._interactionParamsSchema),schema:this._interactionParamsSchema});let e=this._data||{};return this._inputValidator.validate(e)?{isValid:!0}:{isValid:!1,errorMessage:this._inputValidator.validate.errors?this._inputValidator.validate.errors.map(e=>`${e.instancePath}: ${e.message}`).join(`, `):`Invalid payload data`}}};const yQ=pt(void 0);function bQ({children:e}){let{client:n}=q(),[r]=G(()=>new _Q(n)),i=Ct(r.subscribe,r.getSnapshot);return t(yQ.Provider,{value:i,children:e})}function xQ(){let e=yt(yQ);if(!e)throw Error(`usePayloadBuilder must be used within a PayloadProvider`);return e}Q();function SQ(){let{router:e}=ir();return t=>{let n=t.startsWith(`/`)?e.getTopRouter().navigator.addStickyParams(t):t;return window.open(n,`_blank`,`noopener,noreferrer`),n}}function CQ({title:e,variant:r=`full`,isTerminal:i=!1,onClose:a,isModal:s,agentRunId:c,workflowRunId:l,viewMode:u,onViewModeChange:d,showPlanPanel:f,showPlanButton:p=!0,onTogglePlanPanel:m,showPlaybackButton:h=!1,isPlaybackEnabled:g=!1,onTogglePlayback:_,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C=!0,onClone:w,isReceivingChunks:T=!1,className:E}){let{t:D}=K(),O=SQ(),k=r===`compact`,A=u===`sliding`?`stacked`:`sliding`,j=D(`agent.verbose`),M=D(`agent.summary`),ee=A===`stacked`?j:M,N=n(`div`,{className:z(k?`flex flex-row items-center gap-1 lg:flex-col`:`flex justify-end items-center gap-2 ms-auto`),children:[p&&t(`div`,{className:`relative`,children:n(o,{size:r===`compact`?`icon`:`sm`,variant:f?`primary`:`ghost`,onClick:m,className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),title:D(`agent.toggleRightSidebar`),children:[t(wg,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)}):t(`span`,{className:`sr-only`,children:D(f?`agent.hideSidebar`:`agent.showSidebar`)})]})}),k?t(o,{variant:`ghost`,size:`icon`,onClick:()=>d(A),className:`size-8 rounded-lg`,title:ee,"aria-label":ee,children:t(A===`stacked`?Gy:Hv,{className:`size-4`})}):n(`div`,{className:`flex items-center gap-1 bg-muted rounded p-0.5 mt-2 lg:mt-0`,children:[n(o,{variant:u===`stacked`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`stacked`),"aria-pressed":u===`stacked`,className:`gap-1.5`,children:[t(Gy,{className:`size-3.5`}),j]}),n(o,{variant:u===`sliding`?`outline`:`ghost`,size:`xs`,onClick:()=>d(`sliding`),"aria-pressed":u===`sliding`,className:`gap-1.5`,children:[t(Hv,{className:`size-3.5`}),M]})]}),h&&_&&n(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:g?`primary`:`ghost`,onClick:_,"aria-pressed":g,title:D(`agent.rewind.label`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:[t(hh,{className:z(`size-4`,r===`full`&&`me-1.5`)}),r===`full`?t(`span`,{className:`font-medium text-xs`,children:D(`agent.rewind.label`)}):t(`span`,{className:`sr-only`,children:D(`agent.rewind.label`)})]}),c&&t(o,{type:`button`,size:k?`icon`:`xs`,variant:`ghost`,onClick:()=>O(`/store/agent-runner/${c}`),title:D(`agent.openInNewTab`),className:z(`transition-all duration-200 rounded-md`,k&&`size-8 rounded-lg`),children:t(Zg,{className:`size-4`})}),b&&t(o,{type:`button`,size:r===`compact`?`icon`:`sm`,variant:`ghost`,onClick:b,title:D(`agent.startNewConversation`),className:z(`transition-all duration-200 rounded-md`,r===`compact`&&`size-8 rounded-lg`),children:t(zv,{className:z(`size-4`,r===`full`&&`me-1.5`)})}),t(wQ,{compact:k,agentRunId:c,workflowRunId:l,isModal:s,isTerminal:i,onClose:a,onDownload:v,onExportFixture:y,resetWorkflow:b,onExportPdf:x,onShowDetails:S,allowWorkflowControl:C,onClone:w}),a&&!s&&t(o,{size:`xs`,variant:`ghost`,onClick:a,"aria-label":D(`agent.close`),children:t(xx,{className:`size-4`})})]});return r===`compact`?t(bQ,{children:t(`div`,{className:z(`inline-flex items-center rounded-xl border border-border/70 bg-background/90 p-1 shadow-lg shadow-black/10 backdrop-blur`,E),children:N})}):t(bQ,{children:n(`div`,{className:z(`flex flex-wrap items-center justify-between py-1.5 px-2 border-b shadow-sm flex-shrink-0`,E),children:[n(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`div`,{className:`flex items-center gap-1`,children:[t(eh,{className:`size-5 text-muted`}),t(`span`,{className:`font-medium`,children:e})]}),n(`span`,{className:`text-xs text-muted ms-1 flex items-center gap-1.5`,children:[`(Agent Run ID: `,c,`)`,t(`span`,{className:z(`w-2 h-2 rounded-full transition-colors duration-200`,T?`bg-done shadow-md`:`bg-muted`)})]})]}),N]})})}function wQ({compact:e=!1,agentRunId:r,workflowRunId:i,isModal:a,isTerminal:s,onClose:c,onDownload:l,onExportFixture:u,resetWorkflow:d,onExportPdf:f,onShowDetails:p,allowWorkflowControl:m=!0,onClone:h}){let{t:g}=K(),_=it(),{client:v}=q(),y=xQ();return t(T,{align:`right`,trigger:t(o,{size:e?`icon`:`xs`,variant:`ghost`,title:g(`agent.moreActions`),className:e?`size-8 rounded-lg`:void 0,children:t(Jg,{className:`size-4`})}),children:n(ae,{label:`Actions`,children:[n(oe,{onClick:()=>{navigator.clipboard.writeText(r),_({status:`success`,title:g(`agent.agentRunIdCopied`),duration:2e3})},children:[t(Ig,{className:`size-3.5 text-muted`}),` `,g(`agent.copyAgentRunId`)]}),n(oe,{onClick:()=>{navigator.clipboard.writeText(i),_({status:`success`,title:g(`agent.workflowRunIdCopied`),duration:2e3})},children:[t(Ig,{className:`size-3.5 text-muted`}),` `,g(`agent.copyWorkflowRunId`)]}),p&&n(oe,{onClick:p,children:[t(ev,{className:`size-3.5 text-muted`}),` `,g(`agent.details`)]}),n(oe,{onClick:()=>{l?l():$U(v,r).then(e=>window.open(e,`_blank`))},children:[t(Ag,{className:`size-3.5 text-muted`}),` `,g(`agent.downloadConversation`)]}),f&&n(oe,{onClick:f,children:[t(Ag,{className:`size-3.5 text-muted`}),` `,g(`agent.exportAsPdf`)]}),u&&n(oe,{onClick:u,children:[t(Ag,{className:`size-3.5 text-muted`}),` `,g(`agent.rewind.exportFixture`)]}),c&&a&&n(oe,{onClick:c,children:[t(xx,{className:`size-3.5 text-muted`}),` `,g(`agent.close`)]}),h&&n(oe,{onClick:async()=>{try{let e=await v.agents.fork(r);_({status:`success`,title:g(`agent.conversationCloned`),duration:2e3}),h?.(e)}catch{_({status:`error`,title:g(`agent.failedToCloneConversation`),duration:2e3})}},children:[t(H_,{className:`size-3.5 text-muted`}),` `,g(`agent.cloneConversation`)]}),m&&!s&&n(oe,{onClick:async()=>{try{return await v.agents.terminate(r,`cancel`),_({status:`success`,title:g(`agent.workflowCancelled`),duration:2e3}),y.reset(),d?.(),!0}catch{return _({status:`error`,title:g(`agent.failedToCancelWorkflow`),duration:2e3}),!1}},variant:`destructive`,children:[t(xx,{className:`size-3.5`}),` `,g(`agent.cancelWorkflow`)]})]})})}function TQ(e){return typeof e==`object`&&!!e&&`value`in e}function EQ(e){return TQ(e)?e.value:e}function DQ(e){if(e.type===`stringList`)return e.value.map(e=>typeof e==`string`?e:EQ(e));if(e.multiple)return e.value.map(EQ);let t=e.value[0];return t===void 0?void 0:EQ(t)}function OQ(e,t,n){e.query[t]=n}function kQ(e){let t=new Set(e);return e=>t.has(e)}const AQ=[`sys`,`app`,`tmp`],jQ=/^[0-9a-fA-F]{24}$/;function MQ(e){let t=e.indexOf(`:`),n=t>0?e.slice(0,t):void 0;return n&&AQ.includes(n)?{type:n,label:e.slice(t+1)}:{label:e}}function NQ(e,...t){let n=[e?.name,...t].filter(e=>!!e),r=n.find(e=>!jQ.test(e));if(r)return r;let i=n[0];return i?`Deleted interaction (~${i.slice(-8)})`:void 0}function PQ(e){return!!e&&e.version===0&&e.status===bn.unknown}function FQ({interaction:e,className:n}){let r=`success`;switch(e.status){case bn.published:r=`success`;break;case bn.archived:r=`destructive`;break;case bn.code:r=`info`}let a=[e.version?`v${e.version}`:``,e.status&&e.status!==bn.unknown?e.status:``].filter(Boolean).join(` `);return a?t(i,{variant:r,className:n,children:a}):null}function IQ({interaction:r,fallbacks:a=[],fallbackNode:o=null}){let s=NQ(r,...a);if(!s)return t(e,{children:o});let{type:c,label:l}=MQ(s),u=!!r&&!PQ(r);return n(e,{children:[l,(c||u)&&n(`div`,{className:`flex items-center mt-1.5 shrink-0 gap-2`,children:[c&&t(i,{variant:`secondary`,children:c}),u&&r&&t(FQ,{interaction:r})]})]})}function LQ(e,t){return NQ(e,t)??t}function RQ({buckets:e,name:r,placeholder:a}){let o=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:r,placeholder:a||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:o,type:`select`,labelRenderer:r=>{let a=e.find(e=>e._id===r),{type:o,label:s}=MQ(LQ(a,r));return n(`div`,{className:`w-full flex items-center justify-between`,children:[n(`div`,{className:`flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1`,children:[t(`span`,{className:`text-sm truncate`,children:s}),o&&t(i,{variant:`secondary`,className:`text-xs w-fit`,children:o}),a&&t(FQ,{interaction:a,className:`text-xs w-fit`})]}),(a?.count??0)>0&&n(`span`,{className:`ms-2 text-xs shrink-0`,children:[`(`,a?.count,`)`]})]})},filterBy:(t,n)=>LQ(e.find(e=>e._id===t),t).toLowerCase().includes(n.toLowerCase())}}function zQ(e){return`${e._id} (${e.count})`}function BQ(e){return`${e.name} (${e.count})`}function VQ({buckets:e,name:t,placeholder:n,type:r=`select`,multiple:i=!1}){return{name:t,options:e.map(e=>({label:zQ(e),value:e._id})),type:r,multiple:i,placeholder:`${n??`${t.charAt(0).toUpperCase()+t.slice(1)}`}`,allowCreate:!1}}function HQ({buckets:e,name:t,placeholder:n,type:r,multiple:i}){return VQ({buckets:e,name:t,placeholder:n,type:r,multiple:i})}Q();const UQ={},WQ={},GQ={};function KQ(e){return typeof e==`object`&&!!e&&`status`in e&&e.status===404}function qQ(e,t,n){let r=e[t];return r||(r=n().catch(n=>{throw KQ(n)||delete e[t],n}),e[t]=r),r}function JQ(e){let{client:t}=q();return Ze(()=>qQ(UQ,e,()=>t.users.retrieve(e)),{deps:[e],condition:()=>!!e})}function YQ(e){let{client:t}=q();return Ze(()=>qQ(WQ,e,()=>t.iam.groups.retrieve(e)),{deps:[e],condition:()=>!!e})}function XQ(e){let{client:t}=q();return Ze(()=>qQ(GQ,e,()=>t.apikeys.retrieve(e)),{deps:[e],condition:()=>!!e})}function ZQ(){return t(`div`,{className:`size-8`})}function QQ({size:e,color:n,className:r}){return t(Pe,{size:e,color:n,className:`p-1.5 ${r||``}`,children:t(h,{className:`size-full`})})}function $Q({showTitle:e=!1,size:i=`md`}){let{t:a}=K();return t(d$,{title:a(`user.systemUser`),description:a(`user.systemUserDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(r,{size:i}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:a(`user.systemUser`)})]})})}function e$({showTitle:e=!1,size:r=`md`}){let{t:i}=K();return t(d$,{title:i(`user.allProjectMembers`),description:i(`user.allProjectMembersDescription`),children:n(`div`,{className:`flex gap-2 items-center`,children:[t(ox,{className:`size-4`,size:r}),e&&t(`div`,{className:`text-sm font-semibold ps-2`,children:i(`user.allProjectMembers`)})]})})}function t$({accountId:r,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),s=n(e,{children:[t(`div`,{children:o(`user.serviceAccountDescription`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,r]})]});return t(d$,{title:o(`user.serviceAccount`),description:s,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(QQ,{size:a,color:`bg-attention text-attention`}),i&&n(`div`,{className:`text-sm font-semibold ps-2 truncate`,children:[o(`user.serviceAccount`),` : ~`,r.slice(-6)]})]})})}function n$({email:i,showTitle:a=!1,size:o=`md`}){let{t:s}=K(),c=n(e,{children:[t(`div`,{children:s(`user.agentOnBehalfOf`)}),n(`div`,{className:`text-muted text-sm`,children:[t(`span`,{className:`font-semibold`,children:`Email:`}),` `,i]})]});return t(d$,{title:`Email Agent`,description:c,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(QQ,{size:o,color:`bg-attention text-attention`,className:`border-2 border-background`}),t(r,{name:i,size:o,className:`border-2 border-background`})]}),a&&n(`div`,{className:`text-sm font-semibold truncate`,children:[`Agent (`,i,`)`]})]})})}function r$({agentId:i,onBehalfOfType:a,onBehalfOfId:o,showTitle:s=!1,size:c=`md`,isScheduleAgent:l=!1}){let{t:u}=K(),d=a===`user`&&o,f=a===`apikey`&&o,p=JQ(o||``),m=XQ(o||``),h=d?p.data:void 0,g=f?m.data:void 0,_=i.slice(-6),v=h?u(`user.agentOnBehalfOf`):g?u(`user.agentOnBehalfOfApiKey`):`${u(`user.serviceAccount`)}~${_}`,y=l?u(`user.schedule`,{title:v}):v,b=n(`div`,{className:`space-y-2`,children:[h&&n(`div`,{className:`flex items-center gap-2`,children:[t(r,{src:h.picture,name:h.name,size:`sm`}),n(`div`,{children:[t(`div`,{className:`font-medium`,children:h.name||h.email}),h.email&&h.name&&t(`div`,{className:`text-xs text-muted`,children:h.email})]})]}),g&&n(`div`,{children:[t(`div`,{className:`font-medium`,children:g.name}),n(`div`,{className:`text-xs text-muted`,children:[`Key ID: `,g.id]})]}),!h&&!g&&n(e,{children:[t(`div`,{children:u(`user.serviceAccountDescription`)}),n(`div`,{className:`text-foreground text-sm`,children:[t(`span`,{className:`font-semibold`,children:`ID:`}),` `,i]})]})]});return t(d$,{title:y,description:b,children:n(`div`,{className:`flex items-center gap-2`,children:[n(`div`,{className:`flex items-center -space-x-2`,children:[t(QQ,{size:c,color:`bg-info text-info`,className:`border-2 border-background`}),h&&t(r,{src:h.picture,name:h.name,size:c,className:`border-2 border-background`}),g&&t(r,{name:`API`,color:`bg-secondary text-secondary`,size:c,className:`border-2 border-background`})]}),s&&t(`div`,{className:`text-sm font-semibold truncate`,children:h?`Agent (${h.name||h.email})`:g?`Agent (${g.name})`:v})]})})}function i$({title:e=`Error`,error:n,showTitle:r=!1,size:i=`md`}){return t(s$,{title:e,message:qe(n),color:`bg-destructive text-destructive`,showTitle:r,size:i})}function a$({showTitle:e=!1,size:n=`md`,color:r}){let{t:i}=K();return t(s$,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),color:r,showTitle:e,size:n})}function o$({userRef:e,showTitle:n=!1,size:r=`md`}){let{t:i}=K();if(!e)return t(s$,{title:i(`user.unknownUser`),message:i(`user.unknownUserDescription`),showTitle:n,size:r});let a=e.split(`:`),o=a[0];switch(o){case Tn.User:return t(l$,{userId:a[1],showTitle:n,size:r});case Tn.Group:return t(c$,{userId:a[1],showTitle:n,size:r});case`system`:return t($Q,{showTitle:n,size:r});case Tn.ServiceAccount:return t(t$,{accountId:a.slice(1).join(`:`),showTitle:n,size:r});case Tn.Agent:{let e,i,o;return a[1]===`agent`?(e=a.slice(2,5).join(`:`),i=a[5],o=a[6]):(e=a.slice(1,4).join(`:`),i=a[4],o=a[5]),t(r$,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r})}case Tn.Schedule:{let e=a[2]===`agent`?a.slice(3,6).join(`:`):`unknown-agent`,i=a[6],o=a[7];return t(r$,{agentId:e,onBehalfOfType:i,onBehalfOfId:o,showTitle:n,size:r,isScheduleAgent:!0})}case`email`:return t(n$,{email:a[1],showTitle:n,size:r});case Tn.ApiKey:return t(u$,{keyId:a[1],size:r,showTitle:n});case`project`:if(a[1]===`*`)return t(e$,{showTitle:n,size:r});break;default:return t(i$,{title:i(`user.unknownUser`),error:`Invalid user ref type: ${o}`,showTitle:n,size:r})}}function s$({title:e,message:i,color:a,size:o=`md`,showTitle:s=!1}){return t(d$,{title:e,description:i,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{color:a,size:o}),s&&t(`div`,{className:`text-sm font-semibold ps-1`,children:e})]})})}function c$({userId:e,showTitle:r=!1,size:i=`md`}){let{t:a}=K(),{data:o,error:s}=YQ(e);if(s)return KQ(s)?t(a$,{showTitle:r,size:i,color:`bg-info text-info`}):t(i$,{title:a(`user.failedToFetchGroup`),error:s,showTitle:r,size:i});if(!o)return t(ZQ,{});let c=n(`div`,{className:`space-y-1`,children:[o.description&&t(`div`,{className:`text-sm`,children:o.description}),t(`div`,{className:`text-xs text-muted`,children:a(`user.groupId`,{id:o.id})}),o.tags&&o.tags.length>0&&t(`div`,{className:`flex flex-wrap gap-1`,children:o.tags.map(e=>t(`span`,{className:`px-1.5 py-0.5 bg-muted rounded text-xs`,children:e},e))})]});return t(d$,{title:o.name||a(`user.unnamedGroup`),description:c,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(lx,{className:`size-6 text-info`,size:i}),r&&t(`div`,{className:`text-sm font-semibold ps-2`,children:o.name||a(`user.unnamedGroup`)})]})})}function l$({userId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=JQ(e);if(c)return KQ(c)?t(a$,{showTitle:i,size:a,color:`bg-info text-info`}):t(i$,{title:o(`user.failedToFetchUser`),error:c,showTitle:i,size:a});if(!s)return t(ZQ,{});let l=t(`div`,{className:`truncate`,title:s.email,children:s.email});return t(d$,{title:s.name||s.email||s.username||o(`user.unknown`),description:l,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[t(r,{src:s.picture,name:s.name,color:`bg-info`,size:a}),i&&t(`div`,{className:`text-sm font-semibold ps-2`,children:s.name||s.email||s.username||o(`user.unknown`)})]})})}function u$({keyId:e,showTitle:i=!1,size:a=`md`}){let{t:o}=K(),{data:s,error:c}=XQ(e);if(c)return KQ(c)?t(a$,{showTitle:i,size:a,color:`bg-done text-done`}):t(i$,{title:o(`user.failedToFetchApiKey`),error:c,showTitle:i,size:a});if(!s)return t(ZQ,{});let l=o(`user.privateKey`),u=t(r,{name:`PK`,color:`bg-done text-done`,size:a}),d=n(ze,{className:`bg-card text-card-foreground table-fixed w-full`,children:[n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.key`)}),t(`td`,{className:`truncate max-w-0`,children:s?.name})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.account`)}),t(`td`,{className:`truncate max-w-0`,children:s?.account})]}),n(`tr`,{children:[t(`td`,{className:`font-semibold w-20`,children:o(`user.project`)}),t(`td`,{className:`truncate max-w-0`,children:s?.project.name})]})]});return t(d$,{title:l,description:d,children:n(`div`,{className:`flex flex-row items-center gap-2`,children:[u,i&&t(`div`,{className:`text-sm font-semibold`,children:s?.name||s?.account||s?.project.name||o(`user.unknown`)})]})})}function d$({title:e,description:r,children:i}){return n(ge,{hover:!0,children:[t(ve,{className:`cursor-pointer flex items-center inline-block`,children:t(`div`,{children:i})}),t(_e,{align:`center`,sideOffset:8,side:`right`,children:n(`div`,{className:`flex flex-col gap-1 rounded-md shadow-md p-2`,children:[t(`div`,{className:`text-base font-semibold`,children:e}),r]})})]})}function f$({buckets:e,name:r,placeholder:i}){let a=e.map(e=>({value:e._id,label:`(${e.count})`}));return{name:r,placeholder:i||`${r.charAt(0).toUpperCase()+r.slice(1)}`,options:a,labelRenderer:r=>{if(r===`Unknown User`||!r)return`Unknown User (${e.find(e=>e._id===r)?.count||0})`;let i=e.find(e=>e._id===r);return n(`div`,{className:`flex items-center w-full gap-2`,children:[t(`div`,{className:`flex-1 min-w-0 flex items-center truncate`,children:t(o$,{userRef:r,showTitle:!0,size:`sm`})}),n(`span`,{className:`text-muted flex-shrink-0`,children:[`(`,i?.count||0,`)`]})]})}}}function p$({buckets:e,name:t,placeholder:n}){return f$({buckets:e,name:t,placeholder:n})}Q();const m$=kQ([`id`,`run_kind`,`interaction`,`status`,`initiated_by`,`start`,`end`,`evaluation`,`feedback`]);function h$(e){let t=[];return t.push({name:`id`,placeholder:`Agent Run ID`,type:`text`,multiple:!1}),t.push(HQ({buckets:e.kinds||[],name:`run_kind`,placeholder:`Kind`})),t.push(RQ({buckets:e.interactions||[],name:`interaction`,placeholder:`Interaction`})),t.push(HQ({buckets:e.statuses||[],name:`status`,placeholder:`Status`})),t.push(p$({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`})),t.push(HQ({buckets:e.evaluation||[],name:`evaluation`,placeholder:`Evaluation`})),t.push(HQ({buckets:e.feedback||[],name:`feedback`,placeholder:`Feedback`})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function g$(e){return t=>{e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!m$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search()}}function _$({facets:e,search:r,selectionCount:i,actions:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=s??u,p=c??d,m=W(!1),h=W(typeof window<`u`&&!!new URLSearchParams(window.location.search).get(`filters`)),g=h$(e),_=l??g,v=U(()=>g$(r),[r]);return H(()=>{if(!m.current){m.current=!0;return}if(h.current){h.current=!1;return}v(f)},[f,v]),t(te,{filterGroups:_,filters:f,setFilters:p,children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!i&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} runs`:`Loading runs...`})}),a&&a.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:a.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(zy,{className:`size-5`})})]})]}),f.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}var v$=class{types;map={};constructor(e){this.types=e,e.sort((e,t)=>e.name.localeCompare(t.name));for(let t of e)this.map[t.id]=t}getType(e){return this.map[e]}getTypeLayout(e){let t=this.map[e];return t?t.table_layout:void 0}getTypeName(e){let t=this.map[e];return t?t.name:void 0}};const y$=pt({registry:void 0,isLoading:!1,load:()=>Promise.resolve(),reload:()=>Promise.resolve()});function b$({children:e}){let{store:n,project:r}=q(),[i,a]=G(),[o,s]=G(!1),c=W(!1),l=W(r?.id),u=V(async()=>{if(r&&!c.current){c.current=!0,s(!0);try{let e=await n.types.catalog.list({layout:!0});a(new v$(e))}catch(e){console.error(`Failed to fetch types`,e)}finally{s(!1),c.current=!1}}},[n,r]),d=V(async()=>(c.current=!1,u()),[u]);return H(()=>{l.current!==r?.id&&(l.current=r?.id,a(void 0),c.current=!1)}),t(y$.Provider,{value:{registry:i,isLoading:o,load:u,reload:d},children:e})}function x$(){let e=yt(y$);return H(()=>{!e.registry&&!e.isLoading&&e.load()},[e.registry,e.isLoading,e.load]),e}const S$=kQ([`name`,`types`]);function C$(e){let{registry:t}=x$(),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t){let e=t.types.map(e=>({label:e.name,value:e.id})),r={name:`types`,placeholder:`Type`,type:`select`,multiple:!0,options:e,filterBy:(t,n)=>e.find(e=>e.value===t)?.label?.toLowerCase().includes(n.toLowerCase())??!1};n.push(r)}return n}function w$(e){return t=>{if(t.length===0){e.clearFilters(!0);return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!S$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search()}}function T$({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=C$(e),u=w$(r),d=i!==void 0&&a!==void 0;return t(te,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function E$({buckets:e,typeRegistry:r,type:i=`select`,multiple:a=!1}){let o=/* @__PURE__ */ new Map;return r||console.warn(`Type names cannot be resolved`),e.forEach(e=>{let t,n=e._id;e._id==null?(n=`Document`,t=`Document`):(t=r?.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),o.set(n,{name:t,count:e.count})}),{name:`types`,placeholder:`Types`,type:i,multiple:a,options:e.map(e=>{let t=e._id,n=t||`Document`,r=o.get(n);return{value:t,label:r?`${r.name} (${r.count})`:`Unknown (${e.count})`}}),labelRenderer:e=>{let r=o.get(e);return r?n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:r.name}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,r.count,`)`]})]}):(console.warn(`Type data not found for ${e}`),e)},filterBy:(e,t)=>{let n=o.get(e);return n?n.name.toLowerCase().includes(t.toLowerCase()):(console.warn(`Type name not found for ${e}`),!1)}}}const D$=[`id`,`name`,`types`,`status`],O$=[`tags`,`created_at`,`updated_at`],k$=kQ(D$),A$=new Set(O$);function j$(e){return A$.has(e)}function M$(e){return Array.isArray(e)?e:[]}function N$(e){let{registry:t}=x$(),n=[];if(n.push({placeholder:`ID`,name:`id`,type:`text`,options:[]}),n.push({placeholder:`Name`,name:`name`,type:`text`,options:[]}),e.type){let r=E$({buckets:M$(e.type),typeRegistry:t,type:`select`,multiple:!0});n.push(r)}if(e.status){let t=HQ({buckets:M$(e.status),name:`status`,placeholder:`Status`,type:`select`,multiple:!0});n.push(t)}return e.tags&&n.push({name:`tags`,placeholder:`Tags`,type:`stringList`,options:M$(e.tags).map(e=>({label:e._id,value:e._id}))}),n.push({name:`created_at`,placeholder:`Created Date`,type:`date`,multiple:!0,options:[]}),n.push({name:`updated_at`,placeholder:`Updated Date`,type:`date`,multiple:!0,options:[]}),n}function P$(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){let n=t.name,r;if(t.type===`date`&&t.multiple){if(Array.isArray(t.value)&&t.value.length>0){if(t.value.length===1){let e=EQ(t.value[0]);r={gte:e,lte:e}}else t.value.length===2&&(r={gte:EQ(t.value[0]),lte:EQ(t.value[1])})}}else r=DQ(t);k$(n)?OQ(e,n,r):j$(n)&&r!==void 0&&(e.query.match={...e.query.match,[n]:r})}}),e.search()}}function F$({facets:e,search:r}){let[i,a]=G([]),o=N$(e),s=P$(r),c=tt();return t(te,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},inModal:c,children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function I$({search:e,buckets:n,placeholder:r=`All Environments`,className:i}){let{client:a}=q(),[o,s]=G([]),c=e.getFilterValue(`environment`),l=t=>{e.setFilterValue(`environment`,t?._id)};H(()=>{if(a){let e=n.map(async e=>{let t;return await a.environments.retrieve(e._id).then(e=>{t=e.name}).catch(()=>{t=`${e._id} (deleted)`}),t||=e._id,{...e,name:t}});Promise.all(e).then(e=>{e.sort((e,t)=>e.name.localeCompare(t.name)),s(e)})}},[n,a]);let u=o?.find(e=>e._id===c);return t(Te,{filterBy:`name`,className:i,isClearable:!0,optionLabel:BQ,options:o,value:u,onChange:l,by:`_id`,placeholder:r})}const L$=kQ([`name`,`prompt`,`model`,`tags`]);function R$(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.push({name:`prompt`,placeholder:`Prompt Name`,type:`text`,multiple:!1}),t.push({name:`model`,placeholder:`Model`,type:`text`,multiple:!1}),t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),t}function z$(e){return t=>{if(t.length===0){e.clearFilters(!0,!0);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!L$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search(!0)}}function B$({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=R$(e),u=z$(r),d=i!==void 0&&a!==void 0;return t(te,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function V$(e){let t=[];return t.push(HQ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!1})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function H$({facets:e,filters:r,setFilters:i}){let a=V$(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function U$(e){let t=[];return t.push(HQ({buckets:e.statuses||[],name:`status`,placeholder:`Status`,multiple:!0})),t.push(p$({buckets:e.started_by||[],name:`started_by`,placeholder:`Started By`})),t.push(HQ({buckets:e.run_type||[],name:`run_type`,placeholder:`Mode`,multiple:!0})),t.push(HQ({buckets:e.processes||[],name:`process`,placeholder:`Process`,multiple:!0})),t.push({name:`start`,placeholder:`Started After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Started Before`,type:`date`,multiple:!1}),t}function W$({facets:e,filters:r,setFilters:i}){let a=U$(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const G$=kQ([`name`,`role`,`tags`]);function K$(e,t){let n=e[t];return Array.isArray(n)?n:[]}function q$(e){let t=K$(e,`role`),n=[];if(n.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t.length>0){let e={name:`role`,placeholder:`Role`,type:`select`,options:t.map(e=>({label:e._id,value:e._id,count:e.count}))};n.push(e)}let r={name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0,options:K$(e,`tags`).map(e=>({label:e._id,value:e._id}))};return n.push(r),n}function J$(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!G$(t.name))return;let n=t.name;OQ(e,n,DQ(t))}}),e.search()}}function Y$({facets:e,search:r,filters:i,setFilters:a,filterGroups:o}){let[s,c]=G([]),l=q$(e),u=J$(r),d=i!==void 0&&a!==void 0;return t(te,{filterGroups:o??l,filters:d?i:s,setFilters:e=>{if(d){a(e);return}let t=typeof e==`function`?e(s):e;c(t),u(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function X$({buckets:e,name:r}){let i=e.map(e=>({label:`(${e.count})`,value:e._id}));return{name:`environment`,placeholder:r.charAt(0).toUpperCase()+r.slice(1),options:i,type:`select`,labelRenderer:r=>{let i=e.find(e=>e._id===r),a=i?.name||r;return n(`div`,{className:`w-full flex items-center`,children:[t(`span`,{className:`text-sm truncate`,children:a}),n(`span`,{className:`ms-2 text-xs`,children:[`(`,i?.count||0,`)`]})]})},filterBy:(t,n)=>(e.find(e=>e._id===t)?.name||t).toLowerCase().includes(n.toLowerCase())}}Q();const Z$=kQ([`run_ids`,`interaction`,`environment`,`tags`,`model`,`status`,`finish_reason`,`start`,`end`,`workflow_run_ids`,`workflow_ids`]);function Q$(e){return e.filter(e=>e._id!==null)}function $$(e){let t=[];if(t.push({name:`run_ids`,placeholder:`Run ID`,type:`text`,multiple:!1}),e.interactions){let n=RQ({buckets:Q$(e.interactions),name:`interaction`,placeholder:`Interactions`});t.push(n)}if(e.environments){let n=X$({buckets:Q$(e.environments),name:`environment`});t.push(n)}if(t.push({name:`tags`,placeholder:`Tags`,type:`stringList`,multiple:!0}),e.models){let n=HQ({buckets:Q$(e.models),name:`model`});t.push(n)}if(e.statuses){let n=HQ({buckets:Q$(e.statuses),name:`status`});t.push(n)}if(e.finish_reason){let n=HQ({buckets:e.finish_reason.map(e=>({...e,_id:e._id===null?`none`:e._id})),name:`finish_reason`,placeholder:`Finish Reason`});t.push(n)}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`workflow_run_ids`,placeholder:`Workflow Run ID`,type:`text`,multiple:!1}),t.push({name:`workflow_ids`,placeholder:`Workflow ID`,type:`text`,multiple:!1}),t}function e1(e){return t=>{if(t.length===0){e.clearFilters(!0,!1);return}e.clearFilters(!1,!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!Z$(t.name))return;let n=t.name,r=DQ(t);(n===`run_ids`||n===`workflow_run_ids`||n===`workflow_ids`)&&!Array.isArray(r)&&(r=[r]),OQ(e,n,r)}}),e.search()}}function t1({facets:e,search:r,actions:i,selectionCount:a,filters:s,setFilters:c,filterGroups:l}){let[u,d]=G([]),f=$$(e),p=e1(r),m=s!==void 0&&c!==void 0,h=m?s:u;return t(te,{filterGroups:l??f,filters:h,setFilters:e=>{if(m){c(e);return}let t=typeof e==`function`?e(u):e;d(t),p(t)},children:n(`div`,{className:`gap-2 items-center w-full`,children:[n(`div`,{className:`flex justify-between mb-1`,children:[t(P,{}),n(`div`,{className:`flex justify-end`,children:[!a&&t(`div`,{className:`flex items-center justify-between px-2 py-1`,children:t(`div`,{className:`text-sm text-muted`,children:r.initialized?`${r.totalCount} calls`:`Loading calls...`})}),i&&i.length>0?t(`div`,{className:`flex items-center gap-2 mb-1 me-2`,children:i.map((e,n)=>t(`div`,{children:e},`action-${n}`))}):null,t(o,{onClick:()=>{r.search()},variant:`outline`,title:`Refresh`,children:t(zy,{className:`size-5`})})]})]}),h.length>0&&n(`div`,{className:`flex items-center gap-2 mb-1`,children:[t(N,{}),t(F,{})]})]})})}function n1({search:e,buckets:n,name:r,placeholder:i,className:a}){let o=e.getFilterValue(r),s=t=>{e.setFilterValue(r,t?._id)},c=n?.find(e=>JSON.stringify(e._id)===JSON.stringify(o));return t(Te,{filterBy:`_id`,className:a,isClearable:!0,optionLabel:zQ,options:n,value:c,onChange:s,by:`_id`,placeholder:i})}function r1({search:e,name:n,placeholder:r,className:i}){let[a,o]=G([]);return H(()=>{e.setFilterValue(n,a)},[n,e,a]),t(re,{className:i,value:a,onChange:o,placeholder:r})}function i1(e){return`${e.name} (${e.count})`}function a1({search:e,buckets:n,placeholder:r=`Filter by Type`,className:i}){let[a,o]=G([]),{registry:s}=x$(),c=e.getFilterValue(`type`),l=t=>{e.setFilterValue(`type`,t?._id)};H(()=>{if(s){let e=n.map(e=>{let t;return e._id==null?(e._id=`Document`,t=`Document`):(t=s.getTypeName(e._id),t||=(console.warn(`Content Object Type not found`,e._id),e._id)),{...e,name:t}});e.sort((e,t)=>e.name.localeCompare(t.name)),o(e)}},[n,s]);let u=a?.find(e=>e._id===c);return t(Te,{filterBy:`name`,className:i,isClearable:!0,optionLabel:i1,options:a,value:u,onChange:l,by:`_id`,placeholder:r})}function o1(e){let t=[];return t.push(HQ({buckets:e.tags||[],name:`tags`,placeholder:`Tags`,multiple:!0})),t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function s1({facets:e,filters:r,setFilters:i}){let a=o1(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}const c1=kQ([`search_term`,`status`,`initiated_by`,`start`,`end`,`has_reported_errors`]);function l1(e){let t=[];if(t.push({placeholder:`Workflow Name or Workflow Run ID`,name:`search_term`,type:`text`,options:[]}),e.status){let n=HQ({buckets:e.status||[],name:`status`,placeholder:`Status`});t.push({...n,name:`status`})}if(e.initiated_by){let n=p$({buckets:e.initiated_by||[],name:`initiated_by`,placeholder:`Initiated By`});t.push({...n,name:`initiated_by`})}return t.push({name:`start`,placeholder:`Date After`,type:`date`,multiple:!1}),t.push({name:`end`,placeholder:`Date Before`,type:`date`,multiple:!1}),t.push({name:`has_reported_errors`,placeholder:`Has Reported Errors`,type:`select`,multiple:!1,options:[{label:`Yes`,value:`true`},{label:`No`,value:`false`}]}),t}function u1(e){return t=>{if(t.length===0){e.clearFilters();return}e.clearFilters(!1),t.forEach(t=>{if(t.value&&t.value.length>0){if(!c1(t.name))return;let n=t.name,r=DQ(t);if(n===`has_reported_errors`){let t=Array.isArray(r)?r[0]:r;(t===`true`||t===`false`)&&OQ(e,n,t===`true`)}else typeof r==`string`&&OQ(e,n,r)}}),e.search()}}function d1({facets:e,search:r}){let[i,a]=G([]),o=l1(e),s=u1(r);return t(te,{filterGroups:o,filters:i,setFilters:e=>{let t=typeof e==`function`?e(i):e;a(t),s(t)},children:n(`div`,{className:`flex gap-2 items-center`,children:[t(P,{}),t(N,{}),t(F,{})]})})}function f1(e){let t=[];return t.push({name:`name`,placeholder:`Name`,type:`text`,multiple:!1}),t}function p1({facets:e,filters:r,setFilters:i}){let a=f1(e);return t(te,{filterGroups:a,filters:r,setFilters:i,children:n(`div`,{className:`flex items-center gap-2`,children:[t(P,{}),t(N,{}),t(F,{})]})})}var m1=class e{object;objects;setState;collectionId;singleSelection=!1;constructor(e,t,n,r){this.object=e,this.objects=n,this.setState=r,this.singleSelection=Object.keys(this.objects).length===0,this.collectionId=t}isSingleSelection(){return this.singleSelection}hasSelection(){return this.object!==void 0||this.size()!==0}size(){return Object.keys(this.objects).length}getObjectIds(){return Object.keys(this.objects)}getObjectId(){return this.object?.id}clone(){return new e(this.object,this.collectionId,this.objects,this.setState)}add(e){this.objects[e.id]=e,this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}remove(e){delete this.objects[e],this.singleSelection=Object.keys(this.objects).length===0,this.setState(this.clone())}addAll(e){for(let t of e)this.objects[t.id]=t;this.setState(this.clone())}isSelected(e){return this.objects[e]!==void 0}removeAll(){this.objects={},this.singleSelection=!0,this.setState(this.clone())}};const h1=pt(void 0);function g1(){let e=yt(h1);if(!e)throw Error(`useObjectSelection must be used within a ObjectSelectionProvider`);return e}function _1(){return yt(h1)}function v1({value:e,collectionId:n,children:r}){let[i,a]=G();return H(()=>{let t=new m1(e,n,{},a);a(t)},[n,e]),i&&t(h1.Provider,{value:i,children:r})}Q();const y1=pt(void 0);function b1({onFilter:e,children:n}){return t(y1.Provider,{value:e,children:n})}function x1(){return yt(y1)}const S1=`h-6 w-6 p-0 opacity-0 group-hover/field:opacity-100 text-muted hover:text-foreground transition-opacity shrink-0`;function C1({field:r,value:i,label:a,copyContent:s}){let c=x1(),l=Array.isArray(i)?i.length>0:i!==void 0&&i!==``;return n(e,{children:[s!==void 0&&s!==``&&t(S,{content:s,className:S1}),l&&i!==void 0&&t(o,{variant:`ghost`,size:`sm`,title:`Filter by ${a}`,className:S1,onClick:e=>{e.stopPropagation(),c?.(r,i)},children:t(N_,{className:`size-3`})})]})}const w1=`text/csv`,T1=`image/`,E1=`application/pdf`,D1=`video/`,O1=[`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/msword`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.ms-powerpoint`],k1=e=>e===w1||w1.includes(e),A1=e=>e.startsWith(T1)||T1.includes(e),j1=e=>e===E1||E1.includes(e),M1=e=>e.startsWith(D1)||D1.includes(e),N1=e=>O1.includes(e);function P1(e,t){if(typeof window>`u`||typeof document>`u`)return!1;let n=document.createElement(`iframe`);n.style.position=`fixed`,n.style.right=`0`,n.style.bottom=`0`,n.style.width=`0`,n.style.height=`0`,n.style.border=`0`,n.style.visibility=`hidden`,document.body.appendChild(n);let r=n.contentWindow;if(!r)return n.parentNode?.removeChild(n),!1;let i=r.document;i.open(),i.write(`<!doctype html><html><head><title></title></head><body></body></html>`),i.close(),i.title=t,document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(e=>{i.head.appendChild(e.cloneNode(!0))});let a=i.createElement(`style`);return a.textContent=`
1306
1291
  @media print {
1307
1292
  body {
1308
1293
  margin: 24px;