solace-agent-mesh 1.4.3__py3-none-any.whl → 1.4.5__py3-none-any.whl

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.

Potentially problematic release.


This version of solace-agent-mesh might be problematic. Click here for more details.

Files changed (72) hide show
  1. solace_agent_mesh/agent/adk/setup.py +545 -470
  2. solace_agent_mesh/agent/sac/app.py +36 -15
  3. solace_agent_mesh/agent/sac/component.py +7 -3
  4. solace_agent_mesh/agent/tools/builtin_artifact_tools.py +17 -0
  5. solace_agent_mesh/agent/tools/builtin_data_analysis_tools.py +4 -0
  6. solace_agent_mesh/agent/tools/tool_definition.py +8 -0
  7. solace_agent_mesh/agent/tools/web_tools.py +5 -0
  8. solace_agent_mesh/assets/docs/404.html +3 -3
  9. solace_agent_mesh/assets/docs/assets/images/sam-enterprise-credentials-b269f095349473118b2b33bdfcc40122.png +0 -0
  10. solace_agent_mesh/assets/docs/assets/js/ae0e903d.7c73bc4f.js +1 -0
  11. solace_agent_mesh/assets/docs/assets/js/{f284c35a.cad4dbf2.js → f284c35a.2b2f5048.js} +1 -1
  12. solace_agent_mesh/assets/docs/assets/js/{main.66eec320.js → main.2b4fe82a.js} +2 -2
  13. solace_agent_mesh/assets/docs/assets/js/{runtime~main.355446b2.js → runtime~main.c0805958.js} +1 -1
  14. solace_agent_mesh/assets/docs/docs/documentation/Enterprise/installation/index.html +27 -11
  15. solace_agent_mesh/assets/docs/docs/documentation/Enterprise/single-sign-on/index.html +3 -3
  16. solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +3 -3
  17. solace_agent_mesh/assets/docs/docs/documentation/Migrations/A2A Upgrade To 0.3.0/a2a-technical-migration-map/index.html +3 -3
  18. solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +3 -3
  19. solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +3 -3
  20. solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +3 -3
  21. solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +3 -3
  22. solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +3 -3
  23. solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +3 -3
  24. solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +3 -3
  25. solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +3 -3
  26. solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +3 -3
  27. solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +3 -3
  28. solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +3 -3
  29. solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +3 -3
  30. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +3 -3
  31. solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +3 -3
  32. solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +3 -3
  33. solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +3 -3
  34. solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +3 -3
  35. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +3 -3
  36. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +3 -3
  37. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +3 -3
  38. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +3 -3
  39. solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +3 -3
  40. solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +3 -3
  41. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +3 -3
  42. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +3 -3
  43. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +3 -3
  44. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +3 -3
  45. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +3 -3
  46. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +3 -3
  47. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +3 -3
  48. solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-python-tools/index.html +3 -3
  49. solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +3 -3
  50. solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +3 -3
  51. solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +3 -3
  52. solace_agent_mesh/assets/docs/img/sam-enterprise-credentials.png +0 -0
  53. solace_agent_mesh/assets/docs/lunr-index-1758644347760.json +1 -0
  54. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  55. solace_agent_mesh/assets/docs/search-doc-1758644347760.json +1 -0
  56. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  57. solace_agent_mesh/cli/__init__.py +1 -1
  58. solace_agent_mesh/cli/commands/eval_cmd.py +3 -3
  59. solace_agent_mesh/client/webui/frontend/static/assets/main-B67MsY-v.js +339 -0
  60. solace_agent_mesh/client/webui/frontend/static/index.html +1 -1
  61. solace_agent_mesh/common/utils/type_utils.py +28 -0
  62. solace_agent_mesh/gateway/http_sse/main.py +19 -0
  63. {solace_agent_mesh-1.4.3.dist-info → solace_agent_mesh-1.4.5.dist-info}/METADATA +3 -3
  64. {solace_agent_mesh-1.4.3.dist-info → solace_agent_mesh-1.4.5.dist-info}/RECORD +68 -65
  65. solace_agent_mesh/assets/docs/assets/js/ae0e903d.abca774a.js +0 -1
  66. solace_agent_mesh/assets/docs/lunr-index-1758138634356.json +0 -1
  67. solace_agent_mesh/assets/docs/search-doc-1758138634356.json +0 -1
  68. solace_agent_mesh/client/webui/frontend/static/assets/main-Cv2k8j3R.js +0 -339
  69. /solace_agent_mesh/assets/docs/assets/js/{main.66eec320.js.LICENSE.txt → main.2b4fe82a.js.LICENSE.txt} +0 -0
  70. {solace_agent_mesh-1.4.3.dist-info → solace_agent_mesh-1.4.5.dist-info}/WHEEL +0 -0
  71. {solace_agent_mesh-1.4.3.dist-info → solace_agent_mesh-1.4.5.dist-info}/entry_points.txt +0 -0
  72. {solace_agent_mesh-1.4.3.dist-info → solace_agent_mesh-1.4.5.dist-info}/licenses/LICENSE +0 -0
@@ -1,339 +0,0 @@
1
- var Tp=Object.defineProperty;var Ap=(e,t,n)=>t in e?Tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ca=(e,t,n)=>Ap(e,typeof t!="symbol"?t+"":t,n);import{c as Np}from"./client-B9p_nFNA.js";import{r as u,j as a,c as Fl,a as Ur,R as pi,b as kp,N as po,X as Ro,E as _p,d as Bt,C as zl,e as mi,f as Ip,A as $l,L as hi,g as gi,P as Bl,B as jp,S as Mp,F as ua,h as Rp,i as Pp,k as sr,l as Lp,m as Dp,n as Op,o as Ul,D as xi,p as Hl,q as Fp,T as zp,M as Wl,I as vi,s as Gl,t as $p,u as Bp,v as Up,w as Vl,x as Hp,y as Yl,z as Wp,G as Gp,H as da,J as Vp,K as Kl,O as ql,Q as Yp,U as Ze,V as Je,W as Xl,Y as Kp,Z as qp,_ as fa,$ as pa,a0 as cs,a1 as Xp,a2 as Zp,a3 as Jp,a4 as Qp,a5 as em,a6 as tm,a7 as nm,a8 as rm,a9 as om,aa as sm,ab as im,ac as Zl,ad as Jl,ae as am,af as ma,ag as ha,ah as lm,ai as ga,aj as cm,ak as um,al as dm}from"./vendor-CS5YMf8a.js";function xa(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ql(...e){return t=>{let n=!1;const r=e.map(o=>{const s=xa(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():xa(e[o],null)}}}}function $e(...e){return u.useCallback(Ql(...e),e)}function Pn(e){const t=fm(e),n=u.forwardRef((r,o)=>{const{children:s,...i}=r,l=u.Children.toArray(s),c=l.find(mm);if(c){const d=c.props.children,f=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return a.jsx(t,{...i,ref:o,children:u.isValidElement(d)?u.cloneElement(d,void 0,f):null})}return a.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var ec=Pn("Slot");function fm(e){const t=u.forwardRef((n,r)=>{const{children:o,...s}=n;if(u.isValidElement(o)){const i=gm(o),l=hm(s,o.props);return o.type!==u.Fragment&&(l.ref=r?Ql(r,i):i),u.cloneElement(o,l)}return u.Children.count(o)>1?u.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tc=Symbol("radix.slottable");function pm(e){const t=({children:n})=>a.jsx(a.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=tc,t}function mm(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tc}function hm(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...l)=>{const c=s(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function gm(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const va=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,wa=Fl,Tn=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return wa(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(d=>{const f=n==null?void 0:n[d],p=s==null?void 0:s[d];if(f===null)return null;const m=va(f)||va(p);return o[d][m]}),l=n&&Object.entries(n).reduce((d,f)=>{let[p,m]=f;return m===void 0||(d[p]=m),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:p,className:m,...g}=f;return Object.entries(g).every(x=>{let[h,v]=x;return Array.isArray(v)?v.includes({...s,...l}[h]):{...s,...l}[h]===v})?[...d,p,m]:d},[]);return wa(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},wi=()=>localStorage.getItem("access_token"),xm=()=>localStorage.getItem("refresh_token"),vm=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},wm=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},bm=async()=>{const e=xm();if(!e)return null;const t=await fetch("/api/v1/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(t.ok){const n=await t.json();return vm(n.access_token,n.refresh_token),n.access_token}return wm(),window.location.href="/api/v1/auth/login",null},ze=async(e,t={})=>{const n=wi();if(!n)return fetch(e,t);const r=await fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${n}`}});if(r.status===401){const o=await bm();if(o)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${o}`}})}return r},bi="-",ym=e=>{const t=Cm(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(bi);return l[0]===""&&l.length!==1&&l.shift(),nc(l,t)||Sm(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},nc=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?nc(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const s=e.join(bi);return(i=t.validators.find(({validator:l})=>l(s)))==null?void 0:i.classGroupId},ba=/^\[(.+)\]$/,Sm=e=>{if(ba.test(e)){const t=ba.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Cm=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const o in n)Os(n[o],r,o,t);return r},Os=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const s=o===""?t:ya(t,o);s.classGroupId=n;return}if(typeof o=="function"){if(Em(o)){Os(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([s,i])=>{Os(i,ya(t,s),n,r)})})},ya=(e,t)=>{let n=e;return t.split(bi).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Em=e=>e.isThemeGetter,Tm=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=r.get(s))!==void 0)return o(s,i),i},set(s,i){n.has(s)?n.set(s,i):o(s,i)}}},Fs="!",zs=":",Am=zs.length,Nm=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,l=0,c=0,d;for(let x=0;x<o.length;x++){let h=o[x];if(i===0&&l===0){if(h===zs){s.push(o.slice(c,x)),c=x+Am;continue}if(h==="/"){d=x;continue}}h==="["?i++:h==="]"?i--:h==="("?l++:h===")"&&l--}const f=s.length===0?o:o.substring(c),p=km(f),m=p!==f,g=d&&d>c?d-c:void 0;return{modifiers:s,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:g}};if(t){const o=t+zs,s=r;r=i=>i.startsWith(o)?s(i.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},km=e=>e.endsWith(Fs)?e.substring(0,e.length-1):e.startsWith(Fs)?e.substring(1):e,_m=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const o=[];let s=[];return r.forEach(i=>{i[0]==="["||t[i]?(o.push(...s.sort(),i),s=[]):s.push(i)}),o.push(...s.sort()),o}},Im=e=>({cache:Tm(e.cacheSize),parseClassName:Nm(e),sortModifiers:_m(e),...ym(e)}),jm=/\s+/,Mm=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],l=e.trim().split(jm);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:p,modifiers:m,hasImportantModifier:g,baseClassName:x,maybePostfixModifierPosition:h}=n(f);if(p){c=f+(c.length>0?" "+c:c);continue}let v=!!h,b=r(v?x.substring(0,h):x);if(!b){if(!v){c=f+(c.length>0?" "+c:c);continue}if(b=r(x),!b){c=f+(c.length>0?" "+c:c);continue}v=!1}const w=s(m).join(":"),y=g?w+Fs:w,E=y+b;if(i.includes(E))continue;i.push(E);const A=o(b,v);for(let I=0;I<A.length;++I){const k=A[I];i.push(y+k)}c=f+(c.length>0?" "+c:c)}return c};function Rm(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=rc(t))&&(r&&(r+=" "),r+=n);return r}const rc=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=rc(e[r]))&&(n&&(n+=" "),n+=t);return n};function Pm(e,...t){let n,r,o,s=i;function i(c){const d=t.reduce((f,p)=>p(f),e());return n=Im(d),r=n.cache.get,o=n.cache.set,s=l,l(c)}function l(c){const d=r(c);if(d)return d;const f=Mm(c,n);return o(c,f),f}return function(){return s(Rm.apply(null,arguments))}}const Ye=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},oc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,sc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Lm=/^\d+\/\d+$/,Dm=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Om=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Fm=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,zm=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$m=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Wn=e=>Lm.test(e),Te=e=>!!e&&!Number.isNaN(Number(e)),gn=e=>!!e&&Number.isInteger(Number(e)),us=e=>e.endsWith("%")&&Te(e.slice(0,-1)),an=e=>Dm.test(e),Bm=()=>!0,Um=e=>Om.test(e)&&!Fm.test(e),ic=()=>!1,Hm=e=>zm.test(e),Wm=e=>$m.test(e),Gm=e=>!re(e)&&!oe(e),Vm=e=>pr(e,cc,ic),re=e=>oc.test(e),In=e=>pr(e,uc,Um),ds=e=>pr(e,Zm,Te),Sa=e=>pr(e,ac,ic),Ym=e=>pr(e,lc,Wm),Zr=e=>pr(e,dc,Hm),oe=e=>sc.test(e),yr=e=>mr(e,uc),Km=e=>mr(e,Jm),Ca=e=>mr(e,ac),qm=e=>mr(e,cc),Xm=e=>mr(e,lc),Jr=e=>mr(e,dc,!0),pr=(e,t,n)=>{const r=oc.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},mr=(e,t,n=!1)=>{const r=sc.exec(e);return r?r[1]?t(r[1]):n:!1},ac=e=>e==="position"||e==="percentage",lc=e=>e==="image"||e==="url",cc=e=>e==="length"||e==="size"||e==="bg-size",uc=e=>e==="length",Zm=e=>e==="number",Jm=e=>e==="family-name",dc=e=>e==="shadow",Qm=()=>{const e=Ye("color"),t=Ye("font"),n=Ye("text"),r=Ye("font-weight"),o=Ye("tracking"),s=Ye("leading"),i=Ye("breakpoint"),l=Ye("container"),c=Ye("spacing"),d=Ye("radius"),f=Ye("shadow"),p=Ye("inset-shadow"),m=Ye("text-shadow"),g=Ye("drop-shadow"),x=Ye("blur"),h=Ye("perspective"),v=Ye("aspect"),b=Ye("ease"),w=Ye("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...E(),oe,re],I=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],T=()=>[oe,re,c],Y=()=>[Wn,"full","auto",...T()],X=()=>[gn,"none","subgrid",oe,re],W=()=>["auto",{span:["full",gn,oe,re]},gn,oe,re],q=()=>[gn,"auto",oe,re],ee=()=>["auto","min","max","fr",oe,re],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Z=()=>["start","end","center","stretch","center-safe","end-safe"],N=()=>["auto",...T()],j=()=>[Wn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],C=()=>[e,oe,re],M=()=>[...E(),Ca,Sa,{position:[oe,re]}],D=()=>["no-repeat",{repeat:["","x","y","space","round"]}],P=()=>["auto","cover","contain",qm,Vm,{size:[oe,re]}],te=()=>[us,yr,In],O=()=>["","none","full",d,oe,re],B=()=>["",Te,yr,In],L=()=>["solid","dashed","dotted","double"],H=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],_=()=>[Te,us,Ca,Sa],G=()=>["","none",x,oe,re],J=()=>["none",Te,oe,re],Q=()=>["none",Te,oe,re],ae=()=>[Te,oe,re],se=()=>[Wn,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[an],breakpoint:[an],color:[Bm],container:[an],"drop-shadow":[an],ease:["in","out","in-out"],font:[Gm],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[an],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[an],shadow:[an],spacing:["px",Te],text:[an],"text-shadow":[an],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Wn,re,oe,v]}],container:["container"],columns:[{columns:[Te,re,oe,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Y()}],"inset-x":[{"inset-x":Y()}],"inset-y":[{"inset-y":Y()}],start:[{start:Y()}],end:[{end:Y()}],top:[{top:Y()}],right:[{right:Y()}],bottom:[{bottom:Y()}],left:[{left:Y()}],visibility:["visible","invisible","collapse"],z:[{z:[gn,"auto",oe,re]}],basis:[{basis:[Wn,"full","auto",l,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Te,Wn,"auto","initial","none",re]}],grow:[{grow:["",Te,oe,re]}],shrink:[{shrink:["",Te,oe,re]}],order:[{order:[gn,"first","last","none",oe,re]}],"grid-cols":[{"grid-cols":X()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":X()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ee()}],"auto-rows":[{"auto-rows":ee()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...Z(),"normal"]}],"justify-self":[{"justify-self":["auto",...Z()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...Z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Z(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...Z(),"baseline"]}],"place-self":[{"place-self":["auto",...Z()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:N()}],mx:[{mx:N()}],my:[{my:N()}],ms:[{ms:N()}],me:[{me:N()}],mt:[{mt:N()}],mr:[{mr:N()}],mb:[{mb:N()}],ml:[{ml:N()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:j()}],w:[{w:[l,"screen",...j()]}],"min-w":[{"min-w":[l,"screen","none",...j()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...j()]}],h:[{h:["screen","lh",...j()]}],"min-h":[{"min-h":["screen","lh","none",...j()]}],"max-h":[{"max-h":["screen","lh",...j()]}],"font-size":[{text:["base",n,yr,In]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,oe,ds]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",us,re]}],"font-family":[{font:[Km,re,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,oe,re]}],"line-clamp":[{"line-clamp":[Te,"none",oe,ds]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",oe,re]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",oe,re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:C()}],"text-color":[{text:C()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...L(),"wavy"]}],"text-decoration-thickness":[{decoration:[Te,"from-font","auto",oe,In]}],"text-decoration-color":[{decoration:C()}],"underline-offset":[{"underline-offset":[Te,"auto",oe,re]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",oe,re]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",oe,re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:D()}],"bg-size":[{bg:P()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},gn,oe,re],radial:["",oe,re],conic:[gn,oe,re]},Xm,Ym]}],"bg-color":[{bg:C()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:C()}],"gradient-via":[{via:C()}],"gradient-to":[{to:C()}],rounded:[{rounded:O()}],"rounded-s":[{"rounded-s":O()}],"rounded-e":[{"rounded-e":O()}],"rounded-t":[{"rounded-t":O()}],"rounded-r":[{"rounded-r":O()}],"rounded-b":[{"rounded-b":O()}],"rounded-l":[{"rounded-l":O()}],"rounded-ss":[{"rounded-ss":O()}],"rounded-se":[{"rounded-se":O()}],"rounded-ee":[{"rounded-ee":O()}],"rounded-es":[{"rounded-es":O()}],"rounded-tl":[{"rounded-tl":O()}],"rounded-tr":[{"rounded-tr":O()}],"rounded-br":[{"rounded-br":O()}],"rounded-bl":[{"rounded-bl":O()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":B()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...L(),"hidden","none"]}],"divide-style":[{divide:[...L(),"hidden","none"]}],"border-color":[{border:C()}],"border-color-x":[{"border-x":C()}],"border-color-y":[{"border-y":C()}],"border-color-s":[{"border-s":C()}],"border-color-e":[{"border-e":C()}],"border-color-t":[{"border-t":C()}],"border-color-r":[{"border-r":C()}],"border-color-b":[{"border-b":C()}],"border-color-l":[{"border-l":C()}],"divide-color":[{divide:C()}],"outline-style":[{outline:[...L(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Te,oe,re]}],"outline-w":[{outline:["",Te,yr,In]}],"outline-color":[{outline:C()}],shadow:[{shadow:["","none",f,Jr,Zr]}],"shadow-color":[{shadow:C()}],"inset-shadow":[{"inset-shadow":["none",p,Jr,Zr]}],"inset-shadow-color":[{"inset-shadow":C()}],"ring-w":[{ring:B()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:C()}],"ring-offset-w":[{"ring-offset":[Te,In]}],"ring-offset-color":[{"ring-offset":C()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":C()}],"text-shadow":[{"text-shadow":["none",m,Jr,Zr]}],"text-shadow-color":[{"text-shadow":C()}],opacity:[{opacity:[Te,oe,re]}],"mix-blend":[{"mix-blend":[...H(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":H()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Te]}],"mask-image-linear-from-pos":[{"mask-linear-from":_()}],"mask-image-linear-to-pos":[{"mask-linear-to":_()}],"mask-image-linear-from-color":[{"mask-linear-from":C()}],"mask-image-linear-to-color":[{"mask-linear-to":C()}],"mask-image-t-from-pos":[{"mask-t-from":_()}],"mask-image-t-to-pos":[{"mask-t-to":_()}],"mask-image-t-from-color":[{"mask-t-from":C()}],"mask-image-t-to-color":[{"mask-t-to":C()}],"mask-image-r-from-pos":[{"mask-r-from":_()}],"mask-image-r-to-pos":[{"mask-r-to":_()}],"mask-image-r-from-color":[{"mask-r-from":C()}],"mask-image-r-to-color":[{"mask-r-to":C()}],"mask-image-b-from-pos":[{"mask-b-from":_()}],"mask-image-b-to-pos":[{"mask-b-to":_()}],"mask-image-b-from-color":[{"mask-b-from":C()}],"mask-image-b-to-color":[{"mask-b-to":C()}],"mask-image-l-from-pos":[{"mask-l-from":_()}],"mask-image-l-to-pos":[{"mask-l-to":_()}],"mask-image-l-from-color":[{"mask-l-from":C()}],"mask-image-l-to-color":[{"mask-l-to":C()}],"mask-image-x-from-pos":[{"mask-x-from":_()}],"mask-image-x-to-pos":[{"mask-x-to":_()}],"mask-image-x-from-color":[{"mask-x-from":C()}],"mask-image-x-to-color":[{"mask-x-to":C()}],"mask-image-y-from-pos":[{"mask-y-from":_()}],"mask-image-y-to-pos":[{"mask-y-to":_()}],"mask-image-y-from-color":[{"mask-y-from":C()}],"mask-image-y-to-color":[{"mask-y-to":C()}],"mask-image-radial":[{"mask-radial":[oe,re]}],"mask-image-radial-from-pos":[{"mask-radial-from":_()}],"mask-image-radial-to-pos":[{"mask-radial-to":_()}],"mask-image-radial-from-color":[{"mask-radial-from":C()}],"mask-image-radial-to-color":[{"mask-radial-to":C()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[Te]}],"mask-image-conic-from-pos":[{"mask-conic-from":_()}],"mask-image-conic-to-pos":[{"mask-conic-to":_()}],"mask-image-conic-from-color":[{"mask-conic-from":C()}],"mask-image-conic-to-color":[{"mask-conic-to":C()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:D()}],"mask-size":[{mask:P()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",oe,re]}],filter:[{filter:["","none",oe,re]}],blur:[{blur:G()}],brightness:[{brightness:[Te,oe,re]}],contrast:[{contrast:[Te,oe,re]}],"drop-shadow":[{"drop-shadow":["","none",g,Jr,Zr]}],"drop-shadow-color":[{"drop-shadow":C()}],grayscale:[{grayscale:["",Te,oe,re]}],"hue-rotate":[{"hue-rotate":[Te,oe,re]}],invert:[{invert:["",Te,oe,re]}],saturate:[{saturate:[Te,oe,re]}],sepia:[{sepia:["",Te,oe,re]}],"backdrop-filter":[{"backdrop-filter":["","none",oe,re]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[Te,oe,re]}],"backdrop-contrast":[{"backdrop-contrast":[Te,oe,re]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Te,oe,re]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Te,oe,re]}],"backdrop-invert":[{"backdrop-invert":["",Te,oe,re]}],"backdrop-opacity":[{"backdrop-opacity":[Te,oe,re]}],"backdrop-saturate":[{"backdrop-saturate":[Te,oe,re]}],"backdrop-sepia":[{"backdrop-sepia":["",Te,oe,re]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",oe,re]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Te,"initial",oe,re]}],ease:[{ease:["linear","initial",b,oe,re]}],delay:[{delay:[Te,oe,re]}],animate:[{animate:["none",w,oe,re]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,oe,re]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:J()}],"rotate-x":[{"rotate-x":J()}],"rotate-y":[{"rotate-y":J()}],"rotate-z":[{"rotate-z":J()}],scale:[{scale:Q()}],"scale-x":[{"scale-x":Q()}],"scale-y":[{"scale-y":Q()}],"scale-z":[{"scale-z":Q()}],"scale-3d":["scale-3d"],skew:[{skew:ae()}],"skew-x":[{"skew-x":ae()}],"skew-y":[{"skew-y":ae()}],transform:[{transform:[oe,re,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:se()}],"translate-x":[{"translate-x":se()}],"translate-y":[{"translate-y":se()}],"translate-z":[{"translate-z":se()}],"translate-none":["translate-none"],accent:[{accent:C()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:C()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",oe,re]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",oe,re]}],fill:[{fill:["none",...C()]}],"stroke-w":[{stroke:[Te,yr,In,ds]}],stroke:[{stroke:["none",...C()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},eh=Pm(Qm);function Ee(...e){return eh(Fl(e))}const th=e=>{try{const t=new URL(e);if(t.protocol!=="artifact:")return null;const n=t.pathname.split("/").filter(s=>s),r=n[n.length-1],o=t.searchParams.get("version");return{filename:r,version:o}}catch(t){return console.error("Invalid artifact URI:",t),null}},fc=(e,t)=>{try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t||"download",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch(n){console.error("Error downloading blob:",n)}},nh=async e=>{try{let t,n=e.name;if(e.content){const r=atob(e.content),o=new Array(r.length);for(let i=0;i<r.length;i++)o[i]=r.charCodeAt(i);const s=new Uint8Array(o);t=new Blob([s],{type:e.mime_type||"application/octet-stream"})}else if(e.uri){const r=th(e.uri);if(!r)throw new Error(`Invalid or unhandled URI format: ${e.uri}`);n=r.filename;const o=r.version||"latest",s=`/api/v1/artifacts/${encodeURIComponent(n)}/versions/${o}`,i=await ze(s,{credentials:"include"});if(!i.ok)throw new Error(`Failed to download file: ${i.statusText}`);t=await i.blob()}else throw new Error("File has no content or URI to download.");fc(t,n)}catch(t){console.error("Error creating download link:",t)}},pc=(e,t=2)=>{if(e===0)return"0 Bytes";if(e<0||!Number.isFinite(e))return"Invalid size";const n=1024,r=t<0?0:t,o=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],s=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,s)).toFixed(r))+" "+o[s]},Ea=e=>{if(!e)return"N/A";try{const t=new Date(e);if(isNaN(t.getTime()))return"N/A";const r=Math.floor((new Date().getTime()-t.getTime())/1e3),o=Math.floor(r/60),s=Math.floor(o/60),i=Math.floor(s/24);return r<60?`${r}s ago`:o<60?`${o}m ago`:s<24?`${s}h ago`:i===1?"Yesterday":i<7?`${i}d ago`:t.toLocaleDateString()}catch(t){return console.error("Error formatting date:",t),"Invalid date"}},rh=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}},Ta=(e="")=>`
2
- whitespace-normal
3
- break-words
4
- leading-[24px]
5
-
6
- /* Typography */
7
- [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mb-4 [&_h1]:mt-6 [&_h1]:text-foreground
8
- [&_h2]:text-xl [&_h2]:font-bold [&_h2]:mb-3 [&_h2]:mt-5 [&_h2]:text-foreground
9
- [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-foreground
10
- [&_h4]:text-base [&_h4]:font-semibold [&_h4]:mb-2 [&_h4]:mt-3 [&_h4]:text-foreground
11
- [&_h5]:text-sm [&_h5]:font-semibold [&_h5]:mb-1 [&_h5]:mt-2 [&_h5]:text-foreground
12
- [&_h6]:text-xs [&_h6]:font-semibold [&_h6]:mb-1 [&_h6]:mt-2 [&_h6]:text-foreground
13
-
14
- /* Paragraphs */
15
- [&_p]:mb-2 [&_p]:leading-[24px] [&_p]:text-foreground
16
-
17
- /* Text formatting */
18
- [&_strong]:font-semibold [&_strong]:text-foreground
19
- [&_em]:italic
20
- [&_del]:line-through [&_del]:text-foreground
21
-
22
- /* Links */
23
- [&_a]:text-[var(--color-primary-wMain)] [&_a]:underline [&_a]:decoration-[var(--color-primary-wMain)] dark:[&_a]:text-[var(--color-primary-w20)] dark:[&_a]:decoration-[var(--color-primary-w20)]
24
- [&_a:hover]:text-[var(--color-primary-w100)] [&_a:hover]:decoration-[var(--color-primary-w100)] dark:[&_a:hover]:text-[var(--color-primary-w10)] dark:[&_a:hover]:decoration-[var(--color-primary-w10)]
25
-
26
- /* Lists */
27
- [&_ul]:mb-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1
28
- [&_ol]:mb-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1
29
- [&_li]:text-foreground [&_li]:leading-[24px]
30
- [&_ul_ul]:mt-1 [&_ul_ul]:mb-1
31
- [&_ol_ol]:mt-1 [&_ol_ol]:mb-1
32
-
33
- /* Code */
34
- [&_code]:bg-transparent [&_code]:py-0.5 [&_code]:rounded
35
- [&_code]:text-sm [&_code]:font-mono [&_code]:font-semibold [&_code]:text-foreground [&_code]:break-words
36
- [&_pre]:bg-transparent [&_pre]:p-4 [&_pre]:rounded-lg [&_pre]:overflow-x-auto [&_pre]:max-w-full
37
- [&_pre]:mb-4 [&_pre]:border [&_pre]:border-border [&_pre]:whitespace-pre-wrap
38
- [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-sm [&_pre_code]:break-words
39
-
40
- /* Blockquotes */
41
- [&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4
42
- [&_blockquote]:py-2 [&_blockquote]:mb-4 [&_blockquote]:italic
43
- [&_blockquote]:text-foreground [&_blockquote]:bg-transparent
44
-
45
- /* Tables */
46
- [&_table]:w-full [&_table]:mb-4 [&_table]:border-collapse [&_table]:table-fixed [&_table]:max-w-full
47
- [&_th]:border [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:break-words
48
- [&_th]:bg-transparent [&_th]:font-semibold [&_th]:text-left
49
- [&_td]:border [&_td]:border-border [&_td]:px-3 [&_td]:py-2 [&_td]:break-words
50
- [&_tr:nth-child(even)]:bg-transparent
51
-
52
- /* Horizontal rules */
53
- [&_hr]:border-0 [&_hr]:border-t [&_hr]:border-border [&_hr]:my-6
54
-
55
- /* Images */
56
- [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded [&_img]:my-2 [&_img]:object-contain
57
-
58
- ${e}
59
- `.trim().replace(/\s+/g," "),oh=(e="")=>`
60
- /* Buttons - "important" overrides for flow controls */
61
- [&>button]:bg-[var(--color-background-w10)]
62
- [&>button]:dark:!bg-[var(--color-background-w100)]
63
- [&>button]:hover:bg-[var(--color-background-w20)]
64
- [&>button]:dark:hover:!bg-[var(--color-primary-w60)]
65
- [&>button]:text-[var(--color-primary-text-wMain)]
66
- [&>button]:dark:text-[var(--color-primary-text-w10)]
67
- [&>button]:!border
68
- [&>button]:!border-[var(--color-secondary-w40)]
69
- [&>button]:dark:!border-[var(--color-secondary-w70)]
70
-
71
- ${e}
72
- `.trim().replace(/\s+/g," ");function ve(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function sh(e,t){const n=u.createContext(t),r=s=>{const{children:i,...l}=s,c=u.useMemo(()=>l,Object.values(l));return a.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=u.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function An(e,t=[]){let n=[];function r(s,i){const l=u.createContext(i),c=n.length;n=[...n,i];const d=p=>{var b;const{scope:m,children:g,...x}=p,h=((b=m==null?void 0:m[e])==null?void 0:b[c])||l,v=u.useMemo(()=>x,Object.values(x));return a.jsx(h.Provider,{value:v,children:g})};d.displayName=s+"Provider";function f(p,m){var h;const g=((h=m==null?void 0:m[e])==null?void 0:h[c])||l,x=u.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[d,f]}const o=()=>{const s=n.map(i=>u.createContext(i));return function(l){const c=(l==null?void 0:l[e])||s;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[r,ih(o,...t)]}function ih(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((l,{useScope:c,scopeName:d})=>{const p=c(s)[`__scope${d}`];return{...l,...p}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var ah=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ne=ah.reduce((e,t)=>{const n=Pn(`Primitive.${t}`),r=u.forwardRef((o,s)=>{const{asChild:i,...l}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(c,{...l,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function lh(e,t){e&&Ur.flushSync(()=>e.dispatchEvent(t))}function yn(e){const t=u.useRef(e);return u.useEffect(()=>{t.current=e}),u.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ch(e,t=globalThis==null?void 0:globalThis.document){const n=yn(e);u.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var uh="DismissableLayer",$s="dismissableLayer.update",dh="dismissableLayer.pointerDownOutside",fh="dismissableLayer.focusOutside",Aa,mc=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Hr=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:l,...c}=e,d=u.useContext(mc),[f,p]=u.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=u.useState({}),x=$e(t,k=>p(k)),h=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=h.indexOf(v),w=f?h.indexOf(f):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,E=w>=b,A=hh(k=>{const T=k.target,Y=[...d.branches].some(X=>X.contains(T));!E||Y||(o==null||o(k),i==null||i(k),k.defaultPrevented||l==null||l())},m),I=gh(k=>{const T=k.target;[...d.branches].some(X=>X.contains(T))||(s==null||s(k),i==null||i(k),k.defaultPrevented||l==null||l())},m);return ch(k=>{w===d.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},m),u.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Aa=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Na(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Aa)}},[f,m,n,d]),u.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Na())},[f,d]),u.useEffect(()=>{const k=()=>g({});return document.addEventListener($s,k),()=>document.removeEventListener($s,k)},[]),a.jsx(Ne.div,{...c,ref:x,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:ve(e.onFocusCapture,I.onFocusCapture),onBlurCapture:ve(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:ve(e.onPointerDownCapture,A.onPointerDownCapture)})});Hr.displayName=uh;var ph="DismissableLayerBranch",mh=u.forwardRef((e,t)=>{const n=u.useContext(mc),r=u.useRef(null),o=$e(t,r);return u.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),a.jsx(Ne.div,{...e,ref:o})});mh.displayName=ph;function hh(e,t=globalThis==null?void 0:globalThis.document){const n=yn(e),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){hc(dh,n,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function gh(e,t=globalThis==null?void 0:globalThis.document){const n=yn(e),r=u.useRef(!1);return u.useEffect(()=>{const o=s=>{s.target&&!r.current&&hc(fh,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Na(){const e=new CustomEvent($s);document.dispatchEvent(e)}function hc(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?lh(o,s):o.dispatchEvent(s)}var rt=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},xh=pi[" useId ".trim().toString()]||(()=>{}),vh=0;function Jt(e){const[t,n]=u.useState(xh());return rt(()=>{n(r=>r??String(vh++))},[e]),t?`radix-${t}`:""}const wh=["top","right","bottom","left"],Sn=Math.min,gt=Math.max,wo=Math.round,Qr=Math.floor,Qt=e=>({x:e,y:e}),bh={left:"right",right:"left",bottom:"top",top:"bottom"},yh={start:"end",end:"start"};function Bs(e,t,n){return gt(e,Sn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function hr(e){return e.split("-")[1]}function yi(e){return e==="x"?"y":"x"}function Si(e){return e==="y"?"height":"width"}const Sh=new Set(["top","bottom"]);function Xt(e){return Sh.has(fn(e))?"y":"x"}function Ci(e){return yi(Xt(e))}function Ch(e,t,n){n===void 0&&(n=!1);const r=hr(e),o=Ci(e),s=Si(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=bo(i)),[i,bo(i)]}function Eh(e){const t=bo(e);return[Us(e),t,Us(t)]}function Us(e){return e.replace(/start|end/g,t=>yh[t])}const ka=["left","right"],_a=["right","left"],Th=["top","bottom"],Ah=["bottom","top"];function Nh(e,t,n){switch(e){case"top":case"bottom":return n?t?_a:ka:t?ka:_a;case"left":case"right":return t?Th:Ah;default:return[]}}function kh(e,t,n,r){const o=hr(e);let s=Nh(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Us)))),s}function bo(e){return e.replace(/left|right|bottom|top/g,t=>bh[t])}function _h(e){return{top:0,right:0,bottom:0,left:0,...e}}function gc(e){return typeof e!="number"?_h(e):{top:e,right:e,bottom:e,left:e}}function yo(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ia(e,t,n){let{reference:r,floating:o}=e;const s=Xt(t),i=Ci(t),l=Si(i),c=fn(t),d=s==="y",f=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let g;switch(c){case"top":g={x:f,y:r.y-o.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:p};break;case"left":g={x:r.x-o.width,y:p};break;default:g={x:r.x,y:r.y}}switch(hr(t)){case"start":g[i]-=m*(n&&d?-1:1);break;case"end":g[i]+=m*(n&&d?-1:1);break}return g}const Ih=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,l=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:p}=Ia(d,r,c),m=r,g={},x=0;for(let h=0;h<l.length;h++){const{name:v,fn:b}=l[h],{x:w,y,data:E,reset:A}=await b({x:f,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});f=w??f,p=y??p,g={...g,[v]:{...g[v],...E}},A&&x<=50&&(x++,typeof A=="object"&&(A.placement&&(m=A.placement),A.rects&&(d=A.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):A.rects),{x:f,y:p}=Ia(d,m,c)),h=-1)}return{x:f,y:p,placement:m,strategy:o,middlewareData:g}};async function Rr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:m=!1,padding:g=0}=dn(t,e),x=gc(g),v=l[m?p==="floating"?"reference":"floating":p],b=yo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},A=yo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:y,strategy:c}):w);return{top:(b.top-A.top+x.top)/E.y,bottom:(A.bottom-b.bottom+x.bottom)/E.y,left:(b.left-A.left+x.left)/E.x,right:(A.right-b.right+x.right)/E.x}}const jh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=dn(e,t)||{};if(d==null)return{};const p=gc(f),m={x:n,y:r},g=Ci(o),x=Si(g),h=await i.getDimensions(d),v=g==="y",b=v?"top":"left",w=v?"bottom":"right",y=v?"clientHeight":"clientWidth",E=s.reference[x]+s.reference[g]-m[g]-s.floating[x],A=m[g]-s.reference[g],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let k=I?I[y]:0;(!k||!await(i.isElement==null?void 0:i.isElement(I)))&&(k=l.floating[y]||s.floating[x]);const T=E/2-A/2,Y=k/2-h[x]/2-1,X=Sn(p[b],Y),W=Sn(p[w],Y),q=X,ee=k-h[x]-W,F=k/2-h[x]/2+T,Z=Bs(q,F,ee),N=!c.arrow&&hr(o)!=null&&F!==Z&&s.reference[x]/2-(F<q?X:W)-h[x]/2<0,j=N?F<q?F-q:F-ee:0;return{[g]:m[g]+j,data:{[g]:Z,centerOffset:F-Z-j,...N&&{alignmentOffset:j}},reset:N}}}),Mh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:h=!0,...v}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=fn(o),w=Xt(l),y=fn(l)===l,E=await(c.isRTL==null?void 0:c.isRTL(d.floating)),A=m||(y||!h?[bo(l)]:Eh(l)),I=x!=="none";!m&&I&&A.push(...kh(l,h,x,E));const k=[l,...A],T=await Rr(t,v),Y=[];let X=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&Y.push(T[b]),p){const F=Ch(o,i,E);Y.push(T[F[0]],T[F[1]])}if(X=[...X,{placement:o,overflows:Y}],!Y.every(F=>F<=0)){var W,q;const F=(((W=s.flip)==null?void 0:W.index)||0)+1,Z=k[F];if(Z&&(!(p==="alignment"?w!==Xt(Z):!1)||X.every(C=>Xt(C.placement)===w?C.overflows[0]>0:!0)))return{data:{index:F,overflows:X},reset:{placement:Z}};let N=(q=X.filter(j=>j.overflows[0]<=0).sort((j,C)=>j.overflows[1]-C.overflows[1])[0])==null?void 0:q.placement;if(!N)switch(g){case"bestFit":{var ee;const j=(ee=X.filter(C=>{if(I){const M=Xt(C.placement);return M===w||M==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(M=>M>0).reduce((M,D)=>M+D,0)]).sort((C,M)=>C[1]-M[1])[0])==null?void 0:ee[0];j&&(N=j);break}case"initialPlacement":N=l;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function ja(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ma(e){return wh.some(t=>e[t]>=0)}const Rh=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dn(e,t);switch(r){case"referenceHidden":{const s=await Rr(t,{...o,elementContext:"reference"}),i=ja(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Ma(i)}}}case"escaped":{const s=await Rr(t,{...o,altBoundary:!0}),i=ja(s,n.floating);return{data:{escapedOffsets:i,escaped:Ma(i)}}}default:return{}}}}},xc=new Set(["left","top"]);async function Ph(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),l=hr(n),c=Xt(n)==="y",d=xc.has(i)?-1:1,f=s&&c?-1:1,p=dn(t,e);let{mainAxis:m,crossAxis:g,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof x=="number"&&(g=l==="end"?x*-1:x),c?{x:g*f,y:m*d}:{x:m*d,y:g*f}}const Lh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:l}=t,c=await Ph(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},Dh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:v=>{let{x:b,y:w}=v;return{x:b,y:w}}},...c}=dn(e,t),d={x:n,y:r},f=await Rr(t,c),p=Xt(fn(o)),m=yi(p);let g=d[m],x=d[p];if(s){const v=m==="y"?"top":"left",b=m==="y"?"bottom":"right",w=g+f[v],y=g-f[b];g=Bs(w,g,y)}if(i){const v=p==="y"?"top":"left",b=p==="y"?"bottom":"right",w=x+f[v],y=x-f[b];x=Bs(w,x,y)}const h=l.fn({...t,[m]:g,[p]:x});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[p]:i}}}}}},Oh=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=dn(e,t),f={x:n,y:r},p=Xt(o),m=yi(p);let g=f[m],x=f[p];const h=dn(l,t),v=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const y=m==="y"?"height":"width",E=s.reference[m]-s.floating[y]+v.mainAxis,A=s.reference[m]+s.reference[y]-v.mainAxis;g<E?g=E:g>A&&(g=A)}if(d){var b,w;const y=m==="y"?"width":"height",E=xc.has(fn(o)),A=s.reference[p]-s.floating[y]+(E&&((b=i.offset)==null?void 0:b[p])||0)+(E?0:v.crossAxis),I=s.reference[p]+s.reference[y]+(E?0:((w=i.offset)==null?void 0:w[p])||0)-(E?v.crossAxis:0);x<A?x=A:x>I&&(x=I)}return{[m]:g,[p]:x}}}},Fh=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:l}=t,{apply:c=()=>{},...d}=dn(e,t),f=await Rr(t,d),p=fn(o),m=hr(o),g=Xt(o)==="y",{width:x,height:h}=s.floating;let v,b;p==="top"||p==="bottom"?(v=p,b=m===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=p,v=m==="end"?"top":"bottom");const w=h-f.top-f.bottom,y=x-f.left-f.right,E=Sn(h-f[v],w),A=Sn(x-f[b],y),I=!t.middlewareData.shift;let k=E,T=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),I&&!m){const X=gt(f.left,0),W=gt(f.right,0),q=gt(f.top,0),ee=gt(f.bottom,0);g?T=x-2*(X!==0||W!==0?X+W:gt(f.left,f.right)):k=h-2*(q!==0||ee!==0?q+ee:gt(f.top,f.bottom))}await c({...t,availableWidth:T,availableHeight:k});const Y=await i.getDimensions(l.floating);return x!==Y.width||h!==Y.height?{reset:{rects:!0}}:{}}}};function Po(){return typeof window<"u"}function gr(e){return vc(e)?(e.nodeName||"").toLowerCase():"#document"}function vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function nn(e){var t;return(t=(vc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vc(e){return Po()?e instanceof Node||e instanceof vt(e).Node:!1}function Ht(e){return Po()?e instanceof Element||e instanceof vt(e).Element:!1}function tn(e){return Po()?e instanceof HTMLElement||e instanceof vt(e).HTMLElement:!1}function Ra(e){return!Po()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof vt(e).ShadowRoot}const zh=new Set(["inline","contents"]);function Wr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Wt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!zh.has(o)}const $h=new Set(["table","td","th"]);function Bh(e){return $h.has(gr(e))}const Uh=[":popover-open",":modal"];function Lo(e){return Uh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Hh=["transform","translate","scale","rotate","perspective"],Wh=["transform","translate","scale","rotate","perspective","filter"],Gh=["paint","layout","strict","content"];function Ei(e){const t=Ti(),n=Ht(e)?Wt(e):e;return Hh.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Wh.some(r=>(n.willChange||"").includes(r))||Gh.some(r=>(n.contain||"").includes(r))}function Vh(e){let t=Cn(e);for(;tn(t)&&!ir(t);){if(Ei(t))return t;if(Lo(t))return null;t=Cn(t)}return null}function Ti(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Yh=new Set(["html","body","#document"]);function ir(e){return Yh.has(gr(e))}function Wt(e){return vt(e).getComputedStyle(e)}function Do(e){return Ht(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Cn(e){if(gr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ra(e)&&e.host||nn(e);return Ra(t)?t.host:t}function wc(e){const t=Cn(e);return ir(t)?e.ownerDocument?e.ownerDocument.body:e.body:tn(t)&&Wr(t)?t:wc(t)}function Pr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=vt(o);if(s){const l=Hs(i);return t.concat(i,i.visualViewport||[],Wr(o)?o:[],l&&n?Pr(l):[])}return t.concat(o,Pr(o,[],n))}function Hs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bc(e){const t=Wt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=tn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=wo(n)!==s||wo(r)!==i;return l&&(n=s,r=i),{width:n,height:r,$:l}}function Ai(e){return Ht(e)?e:e.contextElement}function tr(e){const t=Ai(e);if(!tn(t))return Qt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=bc(t);let i=(s?wo(n.width):n.width)/r,l=(s?wo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Kh=Qt(0);function yc(e){const t=vt(e);return!Ti()||!t.visualViewport?Kh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function qh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==vt(e)?!1:t}function Ln(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ai(e);let i=Qt(1);t&&(r?Ht(r)&&(i=tr(r)):i=tr(e));const l=qh(s,n,r)?yc(s):Qt(0);let c=(o.left+l.x)/i.x,d=(o.top+l.y)/i.y,f=o.width/i.x,p=o.height/i.y;if(s){const m=vt(s),g=r&&Ht(r)?vt(r):r;let x=m,h=Hs(x);for(;h&&r&&g!==x;){const v=tr(h),b=h.getBoundingClientRect(),w=Wt(h),y=b.left+(h.clientLeft+parseFloat(w.paddingLeft))*v.x,E=b.top+(h.clientTop+parseFloat(w.paddingTop))*v.y;c*=v.x,d*=v.y,f*=v.x,p*=v.y,c+=y,d+=E,x=vt(h),h=Hs(x)}}return yo({width:f,height:p,x:c,y:d})}function Oo(e,t){const n=Do(e).scrollLeft;return t?t.left+n:Ln(nn(e)).left+n}function Sc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Oo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Xh(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=nn(r),l=t?Lo(t.floating):!1;if(r===i||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=Qt(1);const f=Qt(0),p=tn(r);if((p||!p&&!s)&&((gr(r)!=="body"||Wr(i))&&(c=Do(r)),tn(r))){const g=Ln(r);d=tr(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const m=i&&!p&&!s?Sc(i,c):Qt(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+m.x,y:n.y*d.y-c.scrollTop*d.y+f.y+m.y}}function Zh(e){return Array.from(e.getClientRects())}function Jh(e){const t=nn(e),n=Do(e),r=e.ownerDocument.body,o=gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Oo(e);const l=-n.scrollTop;return Wt(r).direction==="rtl"&&(i+=gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:l}}const Pa=25;function Qh(e,t){const n=vt(e),r=nn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,l=0,c=0;if(o){s=o.width,i=o.height;const f=Ti();(!f||f&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const d=Oo(r);if(d<=0){const f=r.ownerDocument,p=f.body,m=getComputedStyle(p),g=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-g);x<=Pa&&(s-=x)}else d<=Pa&&(s+=d);return{width:s,height:i,x:l,y:c}}const eg=new Set(["absolute","fixed"]);function tg(e,t){const n=Ln(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=tn(e)?tr(e):Qt(1),i=e.clientWidth*s.x,l=e.clientHeight*s.y,c=o*s.x,d=r*s.y;return{width:i,height:l,x:c,y:d}}function La(e,t,n){let r;if(t==="viewport")r=Qh(e,n);else if(t==="document")r=Jh(nn(e));else if(Ht(t))r=tg(t,n);else{const o=yc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return yo(r)}function Cc(e,t){const n=Cn(e);return n===t||!Ht(n)||ir(n)?!1:Wt(n).position==="fixed"||Cc(n,t)}function ng(e,t){const n=t.get(e);if(n)return n;let r=Pr(e,[],!1).filter(l=>Ht(l)&&gr(l)!=="body"),o=null;const s=Wt(e).position==="fixed";let i=s?Cn(e):e;for(;Ht(i)&&!ir(i);){const l=Wt(i),c=Ei(i);!c&&l.position==="fixed"&&(o=null),(s?!c&&!o:!c&&l.position==="static"&&!!o&&eg.has(o.position)||Wr(i)&&!c&&Cc(e,i))?r=r.filter(f=>f!==i):o=l,i=Cn(i)}return t.set(e,r),r}function rg(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Lo(t)?[]:ng(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((d,f)=>{const p=La(t,f,o);return d.top=gt(p.top,d.top),d.right=Sn(p.right,d.right),d.bottom=Sn(p.bottom,d.bottom),d.left=gt(p.left,d.left),d},La(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function og(e){const{width:t,height:n}=bc(e);return{width:t,height:n}}function sg(e,t,n){const r=tn(t),o=nn(t),s=n==="fixed",i=Ln(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=Qt(0);function d(){c.x=Oo(o)}if(r||!r&&!s)if((gr(t)!=="body"||Wr(o))&&(l=Do(t)),r){const g=Ln(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&d();s&&!r&&o&&d();const f=o&&!r&&!s?Sc(o,l):Qt(0),p=i.left+l.scrollLeft-c.x-f.x,m=i.top+l.scrollTop-c.y-f.y;return{x:p,y:m,width:i.width,height:i.height}}function fs(e){return Wt(e).position==="static"}function Da(e,t){if(!tn(e)||Wt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return nn(e)===n&&(n=n.ownerDocument.body),n}function Ec(e,t){const n=vt(e);if(Lo(e))return n;if(!tn(e)){let o=Cn(e);for(;o&&!ir(o);){if(Ht(o)&&!fs(o))return o;o=Cn(o)}return n}let r=Da(e,t);for(;r&&Bh(r)&&fs(r);)r=Da(r,t);return r&&ir(r)&&fs(r)&&!Ei(r)?n:r||Vh(e)||n}const ig=async function(e){const t=this.getOffsetParent||Ec,n=this.getDimensions,r=await n(e.floating);return{reference:sg(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ag(e){return Wt(e).direction==="rtl"}const lg={convertOffsetParentRelativeRectToViewportRelativeRect:Xh,getDocumentElement:nn,getClippingRect:rg,getOffsetParent:Ec,getElementRects:ig,getClientRects:Zh,getDimensions:og,getScale:tr,isElement:Ht,isRTL:ag};function Tc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cg(e,t){let n=null,r;const o=nn(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=e.getBoundingClientRect(),{left:f,top:p,width:m,height:g}=d;if(l||t(),!m||!g)return;const x=Qr(p),h=Qr(o.clientWidth-(f+m)),v=Qr(o.clientHeight-(p+g)),b=Qr(f),y={rootMargin:-x+"px "+-h+"px "+-v+"px "+-b+"px",threshold:gt(0,Sn(1,c))||1};let E=!0;function A(I){const k=I[0].intersectionRatio;if(k!==c){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Tc(d,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(A,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(A,y)}n.observe(e)}return i(!0),s}function ug(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=Ai(e),f=o||s?[...d?Pr(d):[],...Pr(t)]:[];f.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const p=d&&l?cg(d,n):null;let m=-1,g=null;i&&(g=new ResizeObserver(b=>{let[w]=b;w&&w.target===d&&g&&(g.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=g)==null||y.observe(t)})),n()}),d&&!c&&g.observe(d),g.observe(t));let x,h=c?Ln(e):null;c&&v();function v(){const b=Ln(e);h&&!Tc(h,b)&&n(),h=b,x=requestAnimationFrame(v)}return n(),()=>{var b;f.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(b=g)==null||b.disconnect(),g=null,c&&cancelAnimationFrame(x)}}const dg=Lh,fg=Dh,pg=Mh,mg=Fh,hg=Rh,Oa=jh,gg=Oh,xg=(e,t,n)=>{const r=new Map,o={platform:lg,...n},s={...o.platform,_c:r};return Ih(e,t,{...o,platform:s})};var vg=typeof document<"u",wg=function(){},mo=vg?u.useLayoutEffect:wg;function So(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,o;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(!So(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!So(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ac(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Fa(e,t){const n=Ac(e);return Math.round(t*n)/n}function ps(e){const t=u.useRef(e);return mo(()=>{t.current=e}),t}function bg(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,p]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,g]=u.useState(r);So(m,r)||g(r);const[x,h]=u.useState(null),[v,b]=u.useState(null),w=u.useCallback(C=>{C!==I.current&&(I.current=C,h(C))},[]),y=u.useCallback(C=>{C!==k.current&&(k.current=C,b(C))},[]),E=s||x,A=i||v,I=u.useRef(null),k=u.useRef(null),T=u.useRef(f),Y=c!=null,X=ps(c),W=ps(o),q=ps(d),ee=u.useCallback(()=>{if(!I.current||!k.current)return;const C={placement:t,strategy:n,middleware:m};W.current&&(C.platform=W.current),xg(I.current,k.current,C).then(M=>{const D={...M,isPositioned:q.current!==!1};F.current&&!So(T.current,D)&&(T.current=D,Ur.flushSync(()=>{p(D)}))})},[m,t,n,W,q]);mo(()=>{d===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,p(C=>({...C,isPositioned:!1})))},[d]);const F=u.useRef(!1);mo(()=>(F.current=!0,()=>{F.current=!1}),[]),mo(()=>{if(E&&(I.current=E),A&&(k.current=A),E&&A){if(X.current)return X.current(E,A,ee);ee()}},[E,A,ee,X,Y]);const Z=u.useMemo(()=>({reference:I,floating:k,setReference:w,setFloating:y}),[w,y]),N=u.useMemo(()=>({reference:E,floating:A}),[E,A]),j=u.useMemo(()=>{const C={position:n,left:0,top:0};if(!N.floating)return C;const M=Fa(N.floating,f.x),D=Fa(N.floating,f.y);return l?{...C,transform:"translate("+M+"px, "+D+"px)",...Ac(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:D}},[n,l,N.floating,f.x,f.y]);return u.useMemo(()=>({...f,update:ee,refs:Z,elements:N,floatingStyles:j}),[f,ee,Z,N,j])}const yg=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Oa({element:r.current,padding:o}).fn(n):{}:r?Oa({element:r,padding:o}).fn(n):{}}}},Sg=(e,t)=>({...dg(e),options:[e,t]}),Cg=(e,t)=>({...fg(e),options:[e,t]}),Eg=(e,t)=>({...gg(e),options:[e,t]}),Tg=(e,t)=>({...pg(e),options:[e,t]}),Ag=(e,t)=>({...mg(e),options:[e,t]}),Ng=(e,t)=>({...hg(e),options:[e,t]}),kg=(e,t)=>({...yg(e),options:[e,t]});var _g="Arrow",Nc=u.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return a.jsx(Ne.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:a.jsx("polygon",{points:"0,0 30,0 15,10"})})});Nc.displayName=_g;var Ig=Nc;function jg(e){const[t,n]=u.useState(void 0);return rt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,l;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;i=d.inlineSize,l=d.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ni="Popper",[kc,xr]=An(Ni),[Mg,_c]=kc(Ni),Ic=e=>{const{__scopePopper:t,children:n}=e,[r,o]=u.useState(null);return a.jsx(Mg,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ic.displayName=Ni;var jc="PopperAnchor",Mc=u.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=_c(jc,n),i=u.useRef(null),l=$e(t,i),c=u.useRef(null);return u.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||i.current,d!==c.current&&s.onAnchorChange(c.current)}),r?null:a.jsx(Ne.div,{...o,ref:l})});Mc.displayName=jc;var ki="PopperContent",[Rg,Pg]=kc(ki),Rc=u.forwardRef((e,t)=>{var _,G,J,Q,ae,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:g="optimized",onPlaced:x,...h}=e,v=_c(ki,n),[b,w]=u.useState(null),y=$e(t,ue=>w(ue)),[E,A]=u.useState(null),I=jg(E),k=(I==null?void 0:I.width)??0,T=(I==null?void 0:I.height)??0,Y=r+(s!=="center"?"-"+s:""),X=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},W=Array.isArray(d)?d:[d],q=W.length>0,ee={padding:X,boundary:W.filter(Dg),altBoundary:q},{refs:F,floatingStyles:Z,placement:N,isPositioned:j,middlewareData:C}=bg({strategy:"fixed",placement:Y,whileElementsMounted:(...ue)=>ug(...ue,{animationFrame:g==="always"}),elements:{reference:v.anchor},middleware:[Sg({mainAxis:o+T,alignmentAxis:i}),c&&Cg({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Eg():void 0,...ee}),c&&Tg({...ee}),Ag({...ee,apply:({elements:ue,rects:he,availableWidth:ke,availableHeight:Pe})=>{const{width:De,height:Me}=he.reference,Be=ue.floating.style;Be.setProperty("--radix-popper-available-width",`${ke}px`),Be.setProperty("--radix-popper-available-height",`${Pe}px`),Be.setProperty("--radix-popper-anchor-width",`${De}px`),Be.setProperty("--radix-popper-anchor-height",`${Me}px`)}}),E&&kg({element:E,padding:l}),Og({arrowWidth:k,arrowHeight:T}),m&&Ng({strategy:"referenceHidden",...ee})]}),[M,D]=Dc(N),P=yn(x);rt(()=>{j&&(P==null||P())},[j,P]);const te=(_=C.arrow)==null?void 0:_.x,O=(G=C.arrow)==null?void 0:G.y,B=((J=C.arrow)==null?void 0:J.centerOffset)!==0,[L,H]=u.useState();return rt(()=>{b&&H(window.getComputedStyle(b).zIndex)},[b]),a.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:j?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(Q=C.transformOrigin)==null?void 0:Q.x,(ae=C.transformOrigin)==null?void 0:ae.y].join(" "),...((se=C.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:a.jsx(Rg,{scope:n,placedSide:M,onArrowChange:A,arrowX:te,arrowY:O,shouldHideArrow:B,children:a.jsx(Ne.div,{"data-side":M,"data-align":D,...h,ref:y,style:{...h.style,animation:j?void 0:"none"}})})})});Rc.displayName=ki;var Pc="PopperArrow",Lg={top:"bottom",right:"left",bottom:"top",left:"right"},Lc=u.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Pg(Pc,r),i=Lg[s.placedSide];return a.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:a.jsx(Ig,{...o,ref:n,style:{...o.style,display:"block"}})})});Lc.displayName=Pc;function Dg(e){return e!==null}var Og=e=>({name:"transformOrigin",options:e,fn(t){var v,b,w;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[d,f]=Dc(n),p={start:"0%",center:"50%",end:"100%"}[f],m=(((b=o.arrow)==null?void 0:b.x)??0)+l/2,g=(((w=o.arrow)==null?void 0:w.y)??0)+c/2;let x="",h="";return d==="bottom"?(x=i?p:`${m}px`,h=`${-c}px`):d==="top"?(x=i?p:`${m}px`,h=`${r.floating.height+c}px`):d==="right"?(x=`${-c}px`,h=i?p:`${g}px`):d==="left"&&(x=`${r.floating.width+c}px`,h=i?p:`${g}px`),{data:{x,y:h}}}});function Dc(e){const[t,n="center"]=e.split("-");return[t,n]}var _i=Ic,Fo=Mc,Ii=Rc,ji=Lc,Fg="Portal",Gr=u.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,s]=u.useState(!1);rt(()=>s(!0),[]);const i=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?kp.createPortal(a.jsx(Ne.div,{...r,ref:t}),i):null});Gr.displayName=Fg;function zg(e,t){return u.useReducer((n,r)=>t[n][r]??n,e)}var mn=e=>{const{present:t,children:n}=e,r=$g(t),o=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),s=$e(r.ref,Bg(o));return typeof n=="function"||r.isPresent?u.cloneElement(o,{ref:s}):null};mn.displayName="Presence";function $g(e){const[t,n]=u.useState(),r=u.useRef(null),o=u.useRef(e),s=u.useRef("none"),i=e?"mounted":"unmounted",[l,c]=zg(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=eo(r.current);s.current=l==="mounted"?d:"none"},[l]),rt(()=>{const d=r.current,f=o.current;if(f!==e){const m=s.current,g=eo(d);e?c("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(f&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),rt(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,p=g=>{const h=eo(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&h&&(c("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=g=>{g.target===t&&(s.current=eo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function eo(e){return(e==null?void 0:e.animationName)||"none"}function Bg(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ug=pi[" useInsertionEffect ".trim().toString()]||rt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Hg({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const f=u.useRef(e!==void 0);u.useEffect(()=>{const p=f.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,r])}const d=u.useCallback(f=>{var p;if(l){const m=Wg(f)?f(e):f;m!==e&&((p=i.current)==null||p.call(i,m))}else s(f)},[l,e,s,i]);return[c,d]}function Hg({defaultProp:e,onChange:t}){const[n,r]=u.useState(e),o=u.useRef(n),s=u.useRef(t);return Ug(()=>{s.current=t},[t]),u.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Wg(e){return typeof e=="function"}var Oc=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"}),Gg="VisuallyHidden",Fc=u.forwardRef((e,t)=>a.jsx(Ne.span,{...e,ref:t,style:{...Oc,...e.style}}));Fc.displayName=Gg;var Vg=Fc,[zo]=An("Tooltip",[xr]),$o=xr(),zc="TooltipProvider",Yg=700,Ws="tooltip.open",[Kg,Mi]=zo(zc),$c=e=>{const{__scopeTooltip:t,delayDuration:n=Yg,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=u.useRef(!0),l=u.useRef(!1),c=u.useRef(0);return u.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),a.jsx(Kg,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:u.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:u.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:s})};$c.displayName=zc;var Lr="Tooltip",[qg,Vr]=zo(Lr),Bc=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:l}=e,c=Mi(Lr,e.__scopeTooltip),d=$o(t),[f,p]=u.useState(null),m=Jt(),g=u.useRef(0),x=i??c.disableHoverableContent,h=l??c.delayDuration,v=u.useRef(!1),[b,w]=Dn({prop:r,defaultProp:o??!1,onChange:k=>{k?(c.onOpen(),document.dispatchEvent(new CustomEvent(Ws))):c.onClose(),s==null||s(k)},caller:Lr}),y=u.useMemo(()=>b?v.current?"delayed-open":"instant-open":"closed",[b]),E=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,v.current=!1,w(!0)},[w]),A=u.useCallback(()=>{window.clearTimeout(g.current),g.current=0,w(!1)},[w]),I=u.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{v.current=!0,w(!0),g.current=0},h)},[h,w]);return u.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),a.jsx(_i,{...d,children:a.jsx(qg,{scope:t,contentId:m,open:b,stateAttribute:y,trigger:f,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?I():E()},[c.isOpenDelayedRef,I,E]),onTriggerLeave:u.useCallback(()=>{x?A():(window.clearTimeout(g.current),g.current=0)},[A,x]),onOpen:E,onClose:A,disableHoverableContent:x,children:n})})};Bc.displayName=Lr;var Gs="TooltipTrigger",Uc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Vr(Gs,n),s=Mi(Gs,n),i=$o(n),l=u.useRef(null),c=$e(t,l,o.onTriggerChange),d=u.useRef(!1),f=u.useRef(!1),p=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),a.jsx(Fo,{asChild:!0,...i,children:a.jsx(Ne.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:ve(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:ve(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:ve(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ve(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:ve(e.onBlur,o.onClose),onClick:ve(e.onClick,o.onClose)})})});Uc.displayName=Gs;var Ri="TooltipPortal",[Xg,Zg]=zo(Ri,{forceMount:void 0}),Hc=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=Vr(Ri,t);return a.jsx(Xg,{scope:t,forceMount:n,children:a.jsx(mn,{present:n||s.open,children:a.jsx(Gr,{asChild:!0,container:o,children:r})})})};Hc.displayName=Ri;var ar="TooltipContent",Wc=u.forwardRef((e,t)=>{const n=Zg(ar,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Vr(ar,e.__scopeTooltip);return a.jsx(mn,{present:r||i.open,children:i.disableHoverableContent?a.jsx(Gc,{side:o,...s,ref:t}):a.jsx(Jg,{side:o,...s,ref:t})})}),Jg=u.forwardRef((e,t)=>{const n=Vr(ar,e.__scopeTooltip),r=Mi(ar,e.__scopeTooltip),o=u.useRef(null),s=$e(t,o),[i,l]=u.useState(null),{trigger:c,onClose:d}=n,f=o.current,{onPointerInTransitChange:p}=r,m=u.useCallback(()=>{l(null),p(!1)},[p]),g=u.useCallback((x,h)=>{const v=x.currentTarget,b={x:x.clientX,y:x.clientY},w=nx(b,v.getBoundingClientRect()),y=rx(b,w),E=ox(h.getBoundingClientRect()),A=ix([...y,...E]);l(A),p(!0)},[p]);return u.useEffect(()=>()=>m(),[m]),u.useEffect(()=>{if(c&&f){const x=v=>g(v,f),h=v=>g(v,c);return c.addEventListener("pointerleave",x),f.addEventListener("pointerleave",h),()=>{c.removeEventListener("pointerleave",x),f.removeEventListener("pointerleave",h)}}},[c,f,g,m]),u.useEffect(()=>{if(i){const x=h=>{const v=h.target,b={x:h.clientX,y:h.clientY},w=(c==null?void 0:c.contains(v))||(f==null?void 0:f.contains(v)),y=!sx(b,i);w?m():y&&(m(),d())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,f,i,d,m]),a.jsx(Gc,{...e,ref:s})}),[Qg,ex]=zo(Lr,{isInside:!1}),tx=pm("TooltipContent"),Gc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...l}=e,c=Vr(ar,n),d=$o(n),{onClose:f}=c;return u.useEffect(()=>(document.addEventListener(Ws,f),()=>document.removeEventListener(Ws,f)),[f]),u.useEffect(()=>{if(c.trigger){const p=m=>{const g=m.target;g!=null&&g.contains(c.trigger)&&f()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,f]),a.jsx(Hr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:a.jsxs(Ii,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.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:[a.jsx(tx,{children:r}),a.jsx(Qg,{scope:n,isInside:!0,children:a.jsx(Vg,{id:c.contentId,role:"tooltip",children:o||r})})]})})});Wc.displayName=ar;var Vc="TooltipArrow",Yc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=$o(n);return ex(Vc,n).isInside?null:a.jsx(ji,{...o,...r,ref:t})});Yc.displayName=Vc;function nx(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function rx(e,t,n=5){const 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});break}return r}function ox(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function sx(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const l=t[s],c=t[i],d=l.x,f=l.y,p=c.x,m=c.y;f>r!=m>r&&n<(p-d)*(r-f)/(m-f)+d&&(o=!o)}return o}function ix(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),ax(t)}function ax(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}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)}var lx=$c,cx=Bc,ux=Uc,dx=Hc,fx=Wc,px=Yc;function mx({delayDuration:e=0,...t}){return a.jsx(lx,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Pi({...e}){return a.jsx(mx,{delayDuration:500,children:a.jsx(cx,{"data-slot":"tooltip",...e})})}function Li({...e}){return a.jsx(ux,{"data-slot":"tooltip-trigger",...e})}function Di({className:e,sideOffset:t=0,children:n,...r}){return a.jsx(dx,{children:a.jsxs(fx,{"data-slot":"tooltip-content",sideOffset:t,className:Ee("bg-primary text-primary-foreground 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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,a.jsx(px,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Kc="text-[var(--color-primary-wMain)] hover:text-[var(--color-primary-text-w60)] dark:text-[var(--color-primary-w20)] dark:hover:text-[var(--color-primary-text-w10)]",ms=Kc+" hover:bg-[var(--color-primary-w10)] dark:hover:bg-[var(--color-primary-w60)]",hx=Tn("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm font-semibold transition-all disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-transparent dark:disabled:hover:bg-transparent",{variants:{variant:{default:"text-[var(--color-primary-text-w10)] bg-[var(--color-primary-wMain)] hover:bg-[var(--color-primary-w100)] dark:hover:bg-[var(--color-primary-w60)]",destructive:"text-[var(--color-primary-text-w10)] bg-[var(--color-error-wMain)] hover:bg-[var(--color-error-w70)]",outline:ms+" border border-1 border-[var(--color-primary-wMain)]",secondary:ms,ghost:ms,link:Kc+" underline-offset-4 hover:underline"},size:{default:"h-9 px-5 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function be({className:e,variant:t,size:n,asChild:r=!1,tooltip:o="",testid:s="",...i}){const l=r?ec:"button",c=o?{...i,"aria-label":o}:i,d=a.jsx(l,{"data-slot":"button","data-testid":s||o||i.title,className:Ee(hx({variant:t,size:n,className:e})),...c});return o?a.jsxs(Pi,{children:[a.jsx(Li,{asChild:!0,children:d}),a.jsx(Di,{children:o})]}):d}const qc=({onClick:e,text:t="View Agent Workflow"})=>a.jsx(be,{variant:"ghost",size:"sm",onClick:e,tooltip:t,children:a.jsx(po,{className:"h-4 w-4"})}),Xc=u.forwardRef(({className:e,...t},n)=>a.jsx("textarea",{className:Ee("flex min-h-[80px] w-full rounded-md border px-3 py-2 placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Xc.displayName="Textarea";var hs="focusScope.autoFocusOnMount",gs="focusScope.autoFocusOnUnmount",za={bubbles:!1,cancelable:!0},gx="FocusScope",Bo=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[l,c]=u.useState(null),d=yn(o),f=yn(s),p=u.useRef(null),m=$e(t,h=>c(h)),g=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let h=function(y){if(g.paused||!l)return;const E=y.target;l.contains(E)?p.current=E:xn(p.current,{select:!0})},v=function(y){if(g.paused||!l)return;const E=y.relatedTarget;E!==null&&(l.contains(E)||xn(p.current,{select:!0}))},b=function(y){if(document.activeElement===document.body)for(const A of y)A.removedNodes.length>0&&xn(l)};document.addEventListener("focusin",h),document.addEventListener("focusout",v);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",v),w.disconnect()}}},[r,l,g.paused]),u.useEffect(()=>{if(l){Ba.add(g);const h=document.activeElement;if(!l.contains(h)){const b=new CustomEvent(hs,za);l.addEventListener(hs,d),l.dispatchEvent(b),b.defaultPrevented||(xx(Sx(Zc(l)),{select:!0}),document.activeElement===h&&xn(l))}return()=>{l.removeEventListener(hs,d),setTimeout(()=>{const b=new CustomEvent(gs,za);l.addEventListener(gs,f),l.dispatchEvent(b),b.defaultPrevented||xn(h??document.body,{select:!0}),l.removeEventListener(gs,f),Ba.remove(g)},0)}}},[l,d,f,g]);const x=u.useCallback(h=>{if(!n&&!r||g.paused)return;const v=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,b=document.activeElement;if(v&&b){const w=h.currentTarget,[y,E]=vx(w);y&&E?!h.shiftKey&&b===E?(h.preventDefault(),n&&xn(y,{select:!0})):h.shiftKey&&b===y&&(h.preventDefault(),n&&xn(E,{select:!0})):b===w&&h.preventDefault()}},[n,r,g.paused]);return a.jsx(Ne.div,{tabIndex:-1,...i,ref:m,onKeyDown:x})});Bo.displayName=gx;function xx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(xn(r,{select:t}),document.activeElement!==n)return}function vx(e){const t=Zc(e),n=$a(t,e),r=$a(t.reverse(),e);return[n,r]}function Zc(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function $a(e,t){for(const n of e)if(!wx(n,{upTo:t}))return n}function wx(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function bx(e){return e instanceof HTMLInputElement&&"select"in e}function xn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bx(e)&&t&&e.select()}}var Ba=yx();function yx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ua(e,t),e.unshift(t)},remove(t){var n;e=Ua(e,t),(n=e[0])==null||n.resume()}}}function Ua(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Sx(e){return e.filter(t=>t.tagName!=="A")}var xs=0;function Oi(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ha()),document.body.insertAdjacentElement("beforeend",e[1]??Ha()),xs++,()=>{xs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),xs--}},[])}function Ha(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var qt=function(){return qt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},qt.apply(this,arguments)};function Jc(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Cx(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var ho="right-scroll-bar-position",go="width-before-scroll-bar",Ex="with-scroll-bars-hidden",Tx="--removed-body-scroll-bar-size";function vs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ax(e,t){var n=u.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Nx=typeof window<"u"?u.useLayoutEffect:u.useEffect,Wa=new WeakMap;function kx(e,t){var n=Ax(null,function(r){return e.forEach(function(o){return vs(o,r)})});return Nx(function(){var r=Wa.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(l){s.has(l)||vs(l,null)}),s.forEach(function(l){o.has(l)||vs(l,i)})}Wa.set(n,e)},[e]),n}function _x(e){return e}function Ix(e,t){t===void 0&&(t=_x);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(s),i=n}var c=function(){var f=i;i=[],f.forEach(s)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(f){i.push(f),d()},filter:function(f){return i=i.filter(f),n}}}};return o}function jx(e){e===void 0&&(e={});var t=Ix(null);return t.options=qt({async:!0,ssr:!1},e),t}var Qc=function(e){var t=e.sideCar,n=Jc(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return u.createElement(r,qt({},n))};Qc.isSideCarExport=!0;function Mx(e,t){return e.useMedium(t),Qc}var eu=jx(),ws=function(){},Uo=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:ws,onWheelCapture:ws,onTouchMoveCapture:ws}),o=r[0],s=r[1],i=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,f=e.enabled,p=e.shards,m=e.sideCar,g=e.noRelative,x=e.noIsolation,h=e.inert,v=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,y=e.gapMode,E=Jc(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=m,I=kx([n,t]),k=qt(qt({},E),o);return u.createElement(u.Fragment,null,f&&u.createElement(A,{sideCar:eu,removeScrollBar:d,shards:p,noRelative:g,noIsolation:x,inert:h,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:y}),i?u.cloneElement(u.Children.only(l),qt(qt({},k),{ref:I})):u.createElement(w,qt({},k,{className:c,ref:I}),l))});Uo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Uo.classNames={fullWidth:go,zeroRight:ho};var Rx=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Px(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Rx();return t&&e.setAttribute("nonce",t),e}function Lx(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Dx(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ox=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Px())&&(Lx(t,n),Dx(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Fx=function(){var e=Ox();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},tu=function(){var e=Fx(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},zx={left:0,top:0,right:0,gap:0},bs=function(e){return parseInt(e||"",10)||0},$x=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[bs(n),bs(r),bs(o)]},Bx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return zx;var t=$x(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Ux=tu(),nr="data-scroll-locked",Hx=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
73
- .`.concat(Ex,` {
74
- overflow: hidden `).concat(r,`;
75
- padding-right: `).concat(l,"px ").concat(r,`;
76
- }
77
- body[`).concat(nr,`] {
78
- overflow: hidden `).concat(r,`;
79
- overscroll-behavior: contain;
80
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
81
- padding-left: `.concat(o,`px;
82
- padding-top: `).concat(s,`px;
83
- padding-right: `).concat(i,`px;
84
- margin-left:0;
85
- margin-top:0;
86
- margin-right: `).concat(l,"px ").concat(r,`;
87
- `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
88
- }
89
-
90
- .`).concat(ho,` {
91
- right: `).concat(l,"px ").concat(r,`;
92
- }
93
-
94
- .`).concat(go,` {
95
- margin-right: `).concat(l,"px ").concat(r,`;
96
- }
97
-
98
- .`).concat(ho," .").concat(ho,` {
99
- right: 0 `).concat(r,`;
100
- }
101
-
102
- .`).concat(go," .").concat(go,` {
103
- margin-right: 0 `).concat(r,`;
104
- }
105
-
106
- body[`).concat(nr,`] {
107
- `).concat(Tx,": ").concat(l,`px;
108
- }
109
- `)},Ga=function(){var e=parseInt(document.body.getAttribute(nr)||"0",10);return isFinite(e)?e:0},Wx=function(){u.useEffect(function(){return document.body.setAttribute(nr,(Ga()+1).toString()),function(){var e=Ga()-1;e<=0?document.body.removeAttribute(nr):document.body.setAttribute(nr,e.toString())}},[])},Gx=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Wx();var s=u.useMemo(function(){return Bx(o)},[o]);return u.createElement(Ux,{styles:Hx(s,!t,o,n?"":"!important")})},Vs=!1;if(typeof window<"u")try{var to=Object.defineProperty({},"passive",{get:function(){return Vs=!0,!0}});window.addEventListener("test",to,to),window.removeEventListener("test",to,to)}catch{Vs=!1}var Gn=Vs?{passive:!1}:!1,Vx=function(e){return e.tagName==="TEXTAREA"},nu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Vx(e)&&n[t]==="visible")},Yx=function(e){return nu(e,"overflowY")},Kx=function(e){return nu(e,"overflowX")},Va=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ru(e,r);if(o){var s=ou(e,r),i=s[1],l=s[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qx=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Xx=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ru=function(e,t){return e==="v"?Yx(t):Kx(t)},ou=function(e,t){return e==="v"?qx(t):Xx(t)},Zx=function(e,t){return e==="h"&&t==="rtl"?-1:1},Jx=function(e,t,n,r,o){var s=Zx(e,window.getComputedStyle(t).direction),i=s*r,l=n.target,c=t.contains(l),d=!1,f=i>0,p=0,m=0;do{if(!l)break;var g=ou(e,l),x=g[0],h=g[1],v=g[2],b=h-v-s*x;(x||b)&&ru(e,l)&&(p+=b,m+=x);var w=l.parentNode;l=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(f&&Math.abs(p)<1||!f&&Math.abs(m)<1)&&(d=!0),d},no=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ya=function(e){return[e.deltaX,e.deltaY]},Ka=function(e){return e&&"current"in e?e.current:e},Qx=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ev=function(e){return`
110
- .block-interactivity-`.concat(e,` {pointer-events: none;}
111
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
112
- `)},tv=0,Vn=[];function nv(e){var t=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(tv++)[0],s=u.useState(tu)[0],i=u.useRef(e);u.useEffect(function(){i.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=Cx([e.lockRef.current],(e.shards||[]).map(Ka),!0).filter(Boolean);return h.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=u.useCallback(function(h,v){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var b=no(h),w=n.current,y="deltaX"in h?h.deltaX:w[0]-b[0],E="deltaY"in h?h.deltaY:w[1]-b[1],A,I=h.target,k=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in h&&k==="h"&&I.type==="range")return!1;var T=Va(k,I);if(!T)return!0;if(T?A=k:(A=k==="v"?"h":"v",T=Va(k,I)),!T)return!1;if(!r.current&&"changedTouches"in h&&(y||E)&&(r.current=A),!A)return!0;var Y=r.current||A;return Jx(Y,v,h,Y==="h"?y:E)},[]),c=u.useCallback(function(h){var v=h;if(!(!Vn.length||Vn[Vn.length-1]!==s)){var b="deltaY"in v?Ya(v):no(v),w=t.current.filter(function(A){return A.name===v.type&&(A.target===v.target||v.target===A.shadowParent)&&Qx(A.delta,b)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var y=(i.current.shards||[]).map(Ka).filter(Boolean).filter(function(A){return A.contains(v.target)}),E=y.length>0?l(v,y[0]):!i.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),d=u.useCallback(function(h,v,b,w){var y={name:h,delta:v,target:b,should:w,shadowParent:rv(b)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),f=u.useCallback(function(h){n.current=no(h),r.current=void 0},[]),p=u.useCallback(function(h){d(h.type,Ya(h),h.target,l(h,e.lockRef.current))},[]),m=u.useCallback(function(h){d(h.type,no(h),h.target,l(h,e.lockRef.current))},[]);u.useEffect(function(){return Vn.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Gn),document.addEventListener("touchmove",c,Gn),document.addEventListener("touchstart",f,Gn),function(){Vn=Vn.filter(function(h){return h!==s}),document.removeEventListener("wheel",c,Gn),document.removeEventListener("touchmove",c,Gn),document.removeEventListener("touchstart",f,Gn)}},[]);var g=e.removeScrollBar,x=e.inert;return u.createElement(u.Fragment,null,x?u.createElement(s,{styles:ev(o)}):null,g?u.createElement(Gx,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function rv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ov=Mx(eu,nv);var Ho=u.forwardRef(function(e,t){return u.createElement(Uo,qt({},e,{ref:t,sideCar:ov}))});Ho.classNames=Uo.classNames;var sv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Yn=new WeakMap,ro=new WeakMap,oo={},ys=0,su=function(e){return e&&(e.host||su(e.parentNode))},iv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=su(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},av=function(e,t,n,r){var o=iv(t,Array.isArray(e)?e:[e]);oo[n]||(oo[n]=new WeakMap);var s=oo[n],i=[],l=new Set,c=new Set(o),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};o.forEach(d);var f=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))f(m);else try{var g=m.getAttribute(r),x=g!==null&&g!=="false",h=(Yn.get(m)||0)+1,v=(s.get(m)||0)+1;Yn.set(m,h),s.set(m,v),i.push(m),h===1&&x&&ro.set(m,!0),v===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return f(t),l.clear(),ys++,function(){i.forEach(function(p){var m=Yn.get(p)-1,g=s.get(p)-1;Yn.set(p,m),s.set(p,g),m||(ro.has(p)||p.removeAttribute(r),ro.delete(p)),g||p.removeAttribute(n)}),ys--,ys||(Yn=new WeakMap,Yn=new WeakMap,ro=new WeakMap,oo={})}},Fi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=sv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),av(r,o,n,"aria-hidden")):function(){return null}},Wo="Dialog",[iu]=An(Wo),[lv,Gt]=iu(Wo),au=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,l=u.useRef(null),c=u.useRef(null),[d,f]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Wo});return a.jsx(lv,{scope:t,triggerRef:l,contentRef:c,contentId:Jt(),titleId:Jt(),descriptionId:Jt(),open:d,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(p=>!p),[f]),modal:i,children:n})};au.displayName=Wo;var lu="DialogTrigger",cv=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Gt(lu,n),s=$e(t,o.triggerRef);return a.jsx(Ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Bi(o.open),...r,ref:s,onClick:ve(e.onClick,o.onOpenToggle)})});cv.displayName=lu;var zi="DialogPortal",[uv,cu]=iu(zi,{forceMount:void 0}),uu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Gt(zi,t);return a.jsx(uv,{scope:t,forceMount:n,children:u.Children.map(r,i=>a.jsx(mn,{present:n||s.open,children:a.jsx(Gr,{asChild:!0,container:o,children:i})}))})};uu.displayName=zi;var Co="DialogOverlay",du=u.forwardRef((e,t)=>{const n=cu(Co,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Gt(Co,e.__scopeDialog);return s.modal?a.jsx(mn,{present:r||s.open,children:a.jsx(fv,{...o,ref:t})}):null});du.displayName=Co;var dv=Pn("DialogOverlay.RemoveScroll"),fv=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Gt(Co,n);return a.jsx(Ho,{as:dv,allowPinchZoom:!0,shards:[o.contentRef],children:a.jsx(Ne.div,{"data-state":Bi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),On="DialogContent",fu=u.forwardRef((e,t)=>{const n=cu(On,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Gt(On,e.__scopeDialog);return a.jsx(mn,{present:r||s.open,children:s.modal?a.jsx(pv,{...o,ref:t}):a.jsx(mv,{...o,ref:t})})});fu.displayName=On;var pv=u.forwardRef((e,t)=>{const n=Gt(On,e.__scopeDialog),r=u.useRef(null),o=$e(t,n.contentRef,r);return u.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),a.jsx(pu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ve(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ve(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&s.preventDefault()}),onFocusOutside:ve(e.onFocusOutside,s=>s.preventDefault())})}),mv=u.forwardRef((e,t)=>{const n=Gt(On,e.__scopeDialog),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(pu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),pu=u.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,l=Gt(On,n),c=u.useRef(null),d=$e(t,c);return Oi(),a.jsxs(a.Fragment,{children:[a.jsx(Bo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(Hr,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Bi(l.open),...i,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),a.jsxs(a.Fragment,{children:[a.jsx(hv,{titleId:l.titleId}),a.jsx(xv,{contentRef:c,descriptionId:l.descriptionId})]})]})}),$i="DialogTitle",mu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Gt($i,n);return a.jsx(Ne.h2,{id:o.titleId,...r,ref:t})});mu.displayName=$i;var hu="DialogDescription",gu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Gt(hu,n);return a.jsx(Ne.p,{id:o.descriptionId,...r,ref:t})});gu.displayName=hu;var xu="DialogClose",vu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Gt(xu,n);return a.jsx(Ne.button,{type:"button",...r,ref:t,onClick:ve(e.onClick,()=>o.onOpenChange(!1))})});vu.displayName=xu;function Bi(e){return e?"open":"closed"}var wu="DialogTitleWarning",[o1,bu]=sh(wu,{contentName:On,titleName:$i,docsSlug:"dialog"}),hv=({titleId:e})=>{const t=bu(wu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
113
-
114
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
115
-
116
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},gv="DialogDescriptionWarning",xv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${bu(gv).contentName}}.`;return u.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},vv=au,wv=uu,bv=du,yv=fu,Sv=mu,Cv=gu,Ev=vu;function Go({...e}){return a.jsx(vv,{"data-slot":"dialog",...e})}function Tv({...e}){return a.jsx(wv,{"data-slot":"dialog-portal",...e})}function Av({className:e,...t}){return a.jsx(bv,{"data-slot":"dialog-overlay",className:Ee("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Vo({className:e,children:t,showCloseButton:n=!0,...r}){return a.jsxs(Tv,{"data-slot":"dialog-portal",children:[a.jsx(Av,{}),a.jsxs(yv,{"data-slot":"dialog-content",className:Ee("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-md border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,n&&a.jsxs(Ev,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[a.jsx(Ro,{}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Yo({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-header",className:Ee("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Nv({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-footer",className:Ee("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Ko({className:e,...t}){return a.jsx(Sv,{"data-slot":"dialog-title",className:Ee("text-lg leading-none font-semibold",e),...t})}function qo({className:e,...t}){return a.jsx(Cv,{"data-slot":"dialog-description",className:Ee("py-4 text-sm",e),...t})}const Xo=u.createContext(null);Xo.displayName="PanelGroupContext";const Ue={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},Ui=10,Mn=u.useLayoutEffect,qa=pi.useId,kv=typeof qa=="function"?qa:()=>null;let _v=0;function Hi(e=null){const t=kv(),n=u.useRef(e||t||null);return n.current===null&&(n.current=""+_v++),e??n.current}function yu({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:s,id:i,maxSize:l,minSize:c,onCollapse:d,onExpand:f,onResize:p,order:m,style:g,tagName:x="div",...h}){const v=u.useContext(Xo);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:w,getPanelSize:y,getPanelStyle:E,groupId:A,isPanelCollapsed:I,reevaluatePanelConstraints:k,registerPanel:T,resizePanel:Y,unregisterPanel:X}=v,W=Hi(i),q=u.useRef({callbacks:{onCollapse:d,onExpand:f,onResize:p},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:l,minSize:c},id:W,idIsFromProps:i!==void 0,order:m});u.useRef({didLogMissingDefaultSizeWarning:!1}),Mn(()=>{const{callbacks:F,constraints:Z}=q.current,N={...Z};q.current.id=W,q.current.idIsFromProps=i!==void 0,q.current.order=m,F.onCollapse=d,F.onExpand=f,F.onResize=p,Z.collapsedSize=n,Z.collapsible=r,Z.defaultSize=o,Z.maxSize=l,Z.minSize=c,(N.collapsedSize!==Z.collapsedSize||N.collapsible!==Z.collapsible||N.maxSize!==Z.maxSize||N.minSize!==Z.minSize)&&k(q.current,N)}),Mn(()=>{const F=q.current;return T(F),()=>{X(F)}},[m,W,T,X]),u.useImperativeHandle(s,()=>({collapse:()=>{b(q.current)},expand:F=>{w(q.current,F)},getId(){return W},getSize(){return y(q.current)},isCollapsed(){return I(q.current)},isExpanded(){return!I(q.current)},resize:F=>{Y(q.current,F)}}),[b,w,y,I,W,Y]);const ee=E(q.current,o);return u.createElement(x,{...h,children:e,className:t,id:W,style:{...ee,...g},[Ue.groupId]:A,[Ue.panel]:"",[Ue.panelCollapsible]:r||void 0,[Ue.panelId]:W,[Ue.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const Su=u.forwardRef((e,t)=>u.createElement(yu,{...e,forwardedRef:t}));yu.displayName="Panel";Su.displayName="forwardRef(Panel)";let Ys=null,xo=-1,vn=null;function Iv(e,t,n){const r=(t&Nu)!==0,o=(t&ku)!==0,s=(t&_u)!==0,i=(t&Iu)!==0;if(t){if(r)return s?"se-resize":i?"ne-resize":"e-resize";if(o)return s?"sw-resize":i?"nw-resize":"w-resize";if(s)return"s-resize";if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function jv(){vn!==null&&(document.head.removeChild(vn),Ys=null,vn=null,xo=-1)}function Ss(e,t,n){var r,o;const s=Iv(e,t);if(Ys!==s){if(Ys=s,vn===null&&(vn=document.createElement("style"),document.head.appendChild(vn)),xo>=0){var i;(i=vn.sheet)===null||i===void 0||i.removeRule(xo)}xo=(r=(o=vn.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function Cu(e){return e.type==="keydown"}function Eu(e){return e.type.startsWith("pointer")}function Tu(e){return e.type.startsWith("mouse")}function Zo(e){if(Eu(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Tu(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Mv(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Rv(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Pv(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Ja(e),b:Ja(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ce(r,"Stacking order can only be calculated for elements with a common ancestor");const o={a:Za(Xa(n.a)),b:Za(Xa(n.b))};if(o.a===o.b){const s=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=s.length;for(;l--;){const c=s[l];if(c===i.a)return 1;if(c===i.b)return-1}}return Math.sign(o.a-o.b)}const Lv=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Dv(e){var t;const n=getComputedStyle((t=Au(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Ov(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Dv(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Lv.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Xa(e){let t=e.length;for(;t--;){const n=e[t];if(Ce(n,"Missing node"),Ov(n))return n}return null}function Za(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ja(e){const t=[];for(;e;)t.push(e),e=Au(e);return t}function Au(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Nu=1,ku=2,_u=4,Iu=8,Fv=Mv()==="coarse";let Ut=[],rr=!1,wn=new Map,Jo=new Map;const Dr=new Set;function zv(e,t,n,r,o){var s;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},c=(s=wn.get(i))!==null&&s!==void 0?s:0;return wn.set(i,c+1),Dr.add(l),Eo(),function(){var f;Jo.delete(e),Dr.delete(l);const p=(f=wn.get(i))!==null&&f!==void 0?f:1;if(wn.set(i,p-1),Eo(),p===1&&wn.delete(i),Ut.includes(l)){const m=Ut.indexOf(l);m>=0&&Ut.splice(m,1),Qo(),o("up",!0,null)}}}function $v(e){const{target:t}=e,{x:n,y:r}=Zo(e);rr=!0,Wi({target:t,x:n,y:r}),Eo(),Ut.length>0&&(To("down",e),Qo(),e.preventDefault(),ju(t)||e.stopImmediatePropagation())}function Cs(e){const{x:t,y:n}=Zo(e);if(rr&&e.type!=="pointerleave"&&e.buttons===0&&(rr=!1,To("up",e)),!rr){const{target:r}=e;Wi({target:r,x:t,y:n})}To("move",e),Qo(),Ut.length>0&&e.preventDefault()}function Es(e){const{target:t}=e,{x:n,y:r}=Zo(e);Jo.clear(),rr=!1,Ut.length>0&&(e.preventDefault(),ju(t)||e.stopImmediatePropagation()),To("up",e),Wi({target:t,x:n,y:r}),Qo(),Eo()}function ju(e){let t=e;for(;t;){if(t.hasAttribute(Ue.resizeHandle))return!0;t=t.parentElement}return!1}function Wi({target:e,x:t,y:n}){Ut.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Dr.forEach(o=>{const{element:s,hitAreaMargins:i}=o,l=s.getBoundingClientRect(),{bottom:c,left:d,right:f,top:p}=l,m=Fv?i.coarse:i.fine;if(t>=d-m&&t<=f+m&&n>=p-m&&n<=c+m){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Pv(r,s)>0){let x=r,h=!1;for(;x&&!x.contains(s);){if(Rv(x.getBoundingClientRect(),l)){h=!0;break}x=x.parentElement}if(h)return}Ut.push(o)}})}function Ts(e,t){Jo.set(e,t)}function Qo(){let e=!1,t=!1;Ut.forEach(r=>{const{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;Jo.forEach(r=>{n|=r}),e&&t?Ss("intersection",n):e?Ss("horizontal",n):t?Ss("vertical",n):jv()}let As;function Eo(){var e;(e=As)===null||e===void 0||e.abort(),As=new AbortController;const t={capture:!0,signal:As.signal};Dr.size&&(rr?(Ut.length>0&&wn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("contextmenu",Es,t),o.addEventListener("pointerleave",Cs,t),o.addEventListener("pointermove",Cs,t))}),wn.forEach((n,r)=>{const{body:o}=r;o.addEventListener("pointerup",Es,t),o.addEventListener("pointercancel",Es,t)})):wn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("pointerdown",$v,t),o.addEventListener("pointermove",Cs,t))}))}function To(e,t){Dr.forEach(n=>{const{setResizeHandlerState:r}=n,o=Ut.includes(n);r(e,o,t)})}function Bv(){const[e,t]=u.useState(0);return u.useCallback(()=>t(n=>n+1),[])}function Ce(e,t){if(!e)throw console.error(t),Error(t)}function Fn(e,t,n=Ui){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function cn(e,t,n=Ui){return Fn(e,t,n)===0}function ht(e,t,n){return Fn(e,t,n)===0}function Uv(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const o=e[r],s=t[r];if(!ht(o,s,n))return!1}return!0}function Jn({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ce(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:s,maxSize:i=100,minSize:l=0}=r;if(Fn(n,l)<0)if(s){const c=(o+l)/2;Fn(n,c)<0?n=o:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(Ui)),n}function _r({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:s}){if(ht(e,0))return t;const i=[...t],[l,c]=r;Ce(l!=null,"Invalid first pivot index"),Ce(c!=null,"Invalid second pivot index");let d=0;if(s==="keyboard"){{const p=e<0?c:l,m=n[p];Ce(m,`Panel constraints not found for index ${p}`);const{collapsedSize:g=0,collapsible:x,minSize:h=0}=m;if(x){const v=t[p];if(Ce(v!=null,`Previous layout not found for panel index ${p}`),ht(v,g)){const b=h-v;Fn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?l:c,m=n[p];Ce(m,`No panel constraints found for index ${p}`);const{collapsedSize:g=0,collapsible:x,minSize:h=0}=m;if(x){const v=t[p];if(Ce(v!=null,`Previous layout not found for panel index ${p}`),ht(v,h)){const b=v-g;Fn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let m=e<0?c:l,g=0;for(;;){const h=t[m];Ce(h!=null,`Previous layout not found for panel index ${m}`);const b=Jn({panelConstraints:n,panelIndex:m,size:100})-h;if(g+=b,m+=p,m<0||m>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-x:x}{let m=e<0?l:c;for(;m>=0&&m<n.length;){const g=Math.abs(e)-Math.abs(d),x=t[m];Ce(x!=null,`Previous layout not found for panel index ${m}`);const h=x-g,v=Jn({panelConstraints:n,panelIndex:m,size:h});if(!ht(x,v)&&(d+=x-v,i[m]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Uv(o,i))return o;{const p=e<0?c:l,m=t[p];Ce(m!=null,`Previous layout not found for panel index ${p}`);const g=m+d,x=Jn({panelConstraints:n,panelIndex:p,size:g});if(i[p]=x,!ht(x,g)){let h=g-x,b=e<0?c:l;for(;b>=0&&b<n.length;){const w=i[b];Ce(w!=null,`Previous layout not found for panel index ${b}`);const y=w+h,E=Jn({panelConstraints:n,panelIndex:b,size:y});if(ht(w,E)||(h-=E-w,i[b]=E),ht(h,0))break;e>0?b--:b++}}}const f=i.reduce((p,m)=>m+p,0);return ht(f,100)?i:o}function Hv({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,s=0,i=0;const l=n[0];Ce(l!=null,"No pivot index found"),t.forEach((p,m)=>{const{constraints:g}=p,{maxSize:x=100,minSize:h=0}=g;m===l?(r=h,o=x):(s+=h,i+=x)});const c=Math.min(o,100-s),d=Math.max(r,100-i),f=e[l];return{valueMax:c,valueMin:d,valueNow:f}}function Or(e,t=document){return Array.from(t.querySelectorAll(`[${Ue.resizeHandleId}][data-panel-group-id="${e}"]`))}function Mu(e,t,n=document){const o=Or(e,n).findIndex(s=>s.getAttribute(Ue.resizeHandleId)===t);return o??null}function Ru(e,t,n){const r=Mu(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Wv(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Pu(e,t=document){if(Wv(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function es(e,t=document){const n=t.querySelector(`[${Ue.resizeHandleId}="${e}"]`);return n||null}function Gv(e,t,n,r=document){var o,s,i,l;const c=es(t,r),d=Or(e,r),f=c?d.indexOf(c):-1,p=(o=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,m=(i=(l=n[f+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[p,m]}function Vv({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:s,setLayout:i}){u.useRef({didWarnAboutMissingResizeHandle:!1}),Mn(()=>{if(!s)return;const l=Or(n,s);for(let c=0;c<o.length-1;c++){const{valueMax:d,valueMin:f,valueNow:p}=Hv({layout:r,panelsArray:o,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const g=o[c];Ce(g,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",g.id),m.setAttribute("aria-valuemax",""+Math.round(d)),m.setAttribute("aria-valuemin",""+Math.round(f)),m.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{l.forEach((c,d)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,o,s]),u.useEffect(()=>{if(!s)return;const l=t.current;Ce(l,"Eager values not found");const{panelDataArray:c}=l,d=Pu(n,s);Ce(d!=null,`No group found for id "${n}"`);const f=Or(n,s);Ce(f,`No resize handles found for group id "${n}"`);const p=f.map(m=>{const g=m.getAttribute(Ue.resizeHandleId);Ce(g,"Resize handle element has no handle id attribute");const[x,h]=Gv(n,g,c,s);if(x==null||h==null)return()=>{};const v=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const w=c.findIndex(y=>y.id===x);if(w>=0){const y=c[w];Ce(y,`No panel data found for index ${w}`);const E=r[w],{collapsedSize:A=0,collapsible:I,minSize:k=0}=y.constraints;if(E!=null&&I){const T=_r({delta:ht(E,A)?k-A:A-E,initialLayout:r,panelConstraints:c.map(Y=>Y.constraints),pivotIndices:Ru(n,g,s),prevLayout:r,trigger:"keyboard"});r!==T&&i(T)}}break}}};return m.addEventListener("keydown",v),()=>{m.removeEventListener("keydown",v)}});return()=>{p.forEach(m=>m())}},[s,e,t,n,r,o,i])}function Qa(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Lu(e,t){const n=e==="horizontal",{x:r,y:o}=Zo(t);return n?r:o}function Yv(e,t,n,r,o){const s=n==="horizontal",i=es(t,o);Ce(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(Ue.groupId);Ce(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const d=Lu(n,e),f=Pu(l,o);Ce(f,`No group element found for id "${l}"`);const p=f.getBoundingClientRect(),m=s?p.width:p.height;return(d-c)/m*100}function Kv(e,t,n,r,o,s){if(Cu(e)){const i=n==="horizontal";let l=0;e.shiftKey?l=100:o!=null?l=o:l=10;let c=0;switch(e.key){case"ArrowDown":c=i?0:l;break;case"ArrowLeft":c=i?-l:0;break;case"ArrowRight":c=i?l:0;break;case"ArrowUp":c=i?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:Yv(e,t,n,r,s)}function qv({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,o=100;for(let s=0;s<e.length;s++){const i=n[s];Ce(i,`Panel constraints not found for index ${s}`);const{defaultSize:l}=i;l!=null&&(r++,t[s]=l,o-=l)}for(let s=0;s<e.length;s++){const i=n[s];Ce(i,`Panel constraints not found for index ${s}`);const{defaultSize:l}=i;if(l!=null)continue;const c=e.length-r,d=o/c;r++,t[s]=d,o-=d}return t}function Kn(e,t,n){t.forEach((r,o)=>{const s=e[o];Ce(s,`Panel data not found for index ${o}`);const{callbacks:i,constraints:l,id:c}=s,{collapsedSize:d=0,collapsible:f}=l,p=n[c];if(p==null||r!==p){n[c]=r;const{onCollapse:m,onExpand:g,onResize:x}=i;x&&x(r,p),f&&(m||g)&&(g&&(p==null||cn(p,d))&&!cn(r,d)&&g(),m&&(p==null||!cn(p,d))&&cn(r,d)&&m())}})}function so(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Xv({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:s=3}){const i=n[o];let l;return i==null?l=e!=null?e.toFixed(s):"1":r.length===1?l="1":l=i.toFixed(s),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Zv(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function el(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Du(e){return`react-resizable-panels:${e}`}function Ou(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:o,order:s}=t;return o?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function Fu(e,t){try{const n=Du(e),r=t.getItem(n);if(r){const o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Jv(e,t,n){var r,o;const s=(r=Fu(e,n))!==null&&r!==void 0?r:{},i=Ou(t);return(o=s[i])!==null&&o!==void 0?o:null}function Qv(e,t,n,r,o){var s;const i=Du(e),l=Ou(t),c=(s=Fu(e,o))!==null&&s!==void 0?s:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(c))}catch(d){console.error(d)}}function tl({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,i)=>s+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!ht(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const i=n[s];Ce(i!=null,`No layout data found for index ${s}`);const l=100/r*i;n[s]=l}let o=0;for(let s=0;s<t.length;s++){const i=n[s];Ce(i!=null,`No layout data found for index ${s}`);const l=Jn({panelConstraints:t,panelIndex:s,size:i});i!=l&&(o+=i-l,n[s]=l)}if(!ht(o,0))for(let s=0;s<t.length;s++){const i=n[s];Ce(i!=null,`No layout data found for index ${s}`);const l=i+o,c=Jn({panelConstraints:t,panelIndex:s,size:l});if(i!==c&&(o-=c-i,n[s]=c,ht(o,0)))break}return n}const ew=100,Ir={getItem:e=>(el(Ir),Ir.getItem(e)),setItem:(e,t)=>{el(Ir),Ir.setItem(e,t)}},nl={};function zu({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:s=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Ir,style:d,tagName:f="div",...p}){const m=Hi(s),g=u.useRef(null),[x,h]=u.useState(null),[v,b]=u.useState([]),w=Bv(),y=u.useRef({}),E=u.useRef(new Map),A=u.useRef(0),I=u.useRef({autoSaveId:e,direction:r,dragState:x,id:m,keyboardResizeBy:l,onLayout:i,storage:c}),k=u.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});u.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),u.useImperativeHandle(o,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:O}=k.current;return O},setLayout:O=>{const{onLayout:B}=I.current,{layout:L,panelDataArray:H}=k.current,_=tl({layout:O,panelConstraints:H.map(G=>G.constraints)});Qa(L,_)||(b(_),k.current.layout=_,B&&B(_),Kn(H,_,y.current))}}),[]),Mn(()=>{I.current.autoSaveId=e,I.current.direction=r,I.current.dragState=x,I.current.id=m,I.current.onLayout=i,I.current.storage=c}),Vv({committedValuesRef:I,eagerValuesRef:k,groupId:m,layout:v,panelDataArray:k.current.panelDataArray,setLayout:b,panelGroupElement:g.current}),u.useEffect(()=>{const{panelDataArray:O}=k.current;if(e){if(v.length===0||v.length!==O.length)return;let B=nl[e];B==null&&(B=Zv(Qv,ew),nl[e]=B);const L=[...O],H=new Map(E.current);B(e,L,H,v,c)}},[e,v,c]),u.useEffect(()=>{});const T=u.useCallback(O=>{const{onLayout:B}=I.current,{layout:L,panelDataArray:H}=k.current;if(O.constraints.collapsible){const _=H.map(ae=>ae.constraints),{collapsedSize:G=0,panelSize:J,pivotIndices:Q}=jn(H,O,L);if(Ce(J!=null,`Panel size not found for panel "${O.id}"`),!cn(J,G)){E.current.set(O.id,J);const se=Xn(H,O)===H.length-1?J-G:G-J,ue=_r({delta:se,initialLayout:L,panelConstraints:_,pivotIndices:Q,prevLayout:L,trigger:"imperative-api"});so(L,ue)||(b(ue),k.current.layout=ue,B&&B(ue),Kn(H,ue,y.current))}}},[]),Y=u.useCallback((O,B)=>{const{onLayout:L}=I.current,{layout:H,panelDataArray:_}=k.current;if(O.constraints.collapsible){const G=_.map(he=>he.constraints),{collapsedSize:J=0,panelSize:Q=0,minSize:ae=0,pivotIndices:se}=jn(_,O,H),ue=B??ae;if(cn(Q,J)){const he=E.current.get(O.id),ke=he!=null&&he>=ue?he:ue,De=Xn(_,O)===_.length-1?Q-ke:ke-Q,Me=_r({delta:De,initialLayout:H,panelConstraints:G,pivotIndices:se,prevLayout:H,trigger:"imperative-api"});so(H,Me)||(b(Me),k.current.layout=Me,L&&L(Me),Kn(_,Me,y.current))}}},[]),X=u.useCallback(O=>{const{layout:B,panelDataArray:L}=k.current,{panelSize:H}=jn(L,O,B);return Ce(H!=null,`Panel size not found for panel "${O.id}"`),H},[]),W=u.useCallback((O,B)=>{const{panelDataArray:L}=k.current,H=Xn(L,O);return Xv({defaultSize:B,dragState:x,layout:v,panelData:L,panelIndex:H})},[x,v]),q=u.useCallback(O=>{const{layout:B,panelDataArray:L}=k.current,{collapsedSize:H=0,collapsible:_,panelSize:G}=jn(L,O,B);return Ce(G!=null,`Panel size not found for panel "${O.id}"`),_===!0&&cn(G,H)},[]),ee=u.useCallback(O=>{const{layout:B,panelDataArray:L}=k.current,{collapsedSize:H=0,collapsible:_,panelSize:G}=jn(L,O,B);return Ce(G!=null,`Panel size not found for panel "${O.id}"`),!_||Fn(G,H)>0},[]),F=u.useCallback(O=>{const{panelDataArray:B}=k.current;B.push(O),B.sort((L,H)=>{const _=L.order,G=H.order;return _==null&&G==null?0:_==null?-1:G==null?1:_-G}),k.current.panelDataArrayChanged=!0,w()},[w]);Mn(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:O,onLayout:B,storage:L}=I.current,{layout:H,panelDataArray:_}=k.current;let G=null;if(O){const Q=Jv(O,_,L);Q&&(E.current=new Map(Object.entries(Q.expandToSizes)),G=Q.layout)}G==null&&(G=qv({panelDataArray:_}));const J=tl({layout:G,panelConstraints:_.map(Q=>Q.constraints)});Qa(H,J)||(b(J),k.current.layout=J,B&&B(J),Kn(_,J,y.current))}}),Mn(()=>{const O=k.current;return()=>{O.layout=[]}},[]);const Z=u.useCallback(O=>{let B=!1;const L=g.current;return L&&window.getComputedStyle(L,null).getPropertyValue("direction")==="rtl"&&(B=!0),function(_){_.preventDefault();const G=g.current;if(!G)return()=>null;const{direction:J,dragState:Q,id:ae,keyboardResizeBy:se,onLayout:ue}=I.current,{layout:he,panelDataArray:ke}=k.current,{initialLayout:Pe}=Q??{},De=Ru(ae,O,G);let Me=Kv(_,O,J,Q,se,G);const Be=J==="horizontal";Be&&B&&(Me=-Me);const wt=ke.map(et=>et.constraints),We=_r({delta:Me,initialLayout:Pe??he,panelConstraints:wt,pivotIndices:De,prevLayout:he,trigger:Cu(_)?"keyboard":"mouse-or-touch"}),bt=!so(he,We);(Eu(_)||Tu(_))&&A.current!=Me&&(A.current=Me,!bt&&Me!==0?Be?Ts(O,Me<0?Nu:ku):Ts(O,Me<0?_u:Iu):Ts(O,0)),bt&&(b(We),k.current.layout=We,ue&&ue(We),Kn(ke,We,y.current))}},[]),N=u.useCallback((O,B)=>{const{onLayout:L}=I.current,{layout:H,panelDataArray:_}=k.current,G=_.map(he=>he.constraints),{panelSize:J,pivotIndices:Q}=jn(_,O,H);Ce(J!=null,`Panel size not found for panel "${O.id}"`);const se=Xn(_,O)===_.length-1?J-B:B-J,ue=_r({delta:se,initialLayout:H,panelConstraints:G,pivotIndices:Q,prevLayout:H,trigger:"imperative-api"});so(H,ue)||(b(ue),k.current.layout=ue,L&&L(ue),Kn(_,ue,y.current))},[]),j=u.useCallback((O,B)=>{const{layout:L,panelDataArray:H}=k.current,{collapsedSize:_=0,collapsible:G}=B,{collapsedSize:J=0,collapsible:Q,maxSize:ae=100,minSize:se=0}=O.constraints,{panelSize:ue}=jn(H,O,L);ue!=null&&(G&&Q&&cn(ue,_)?cn(_,J)||N(O,J):ue<se?N(O,se):ue>ae&&N(O,ae))},[N]),C=u.useCallback((O,B)=>{const{direction:L}=I.current,{layout:H}=k.current;if(!g.current)return;const _=es(O,g.current);Ce(_,`Drag handle element not found for id "${O}"`);const G=Lu(L,B);h({dragHandleId:O,dragHandleRect:_.getBoundingClientRect(),initialCursorPosition:G,initialLayout:H})},[]),M=u.useCallback(()=>{h(null)},[]),D=u.useCallback(O=>{const{panelDataArray:B}=k.current,L=Xn(B,O);L>=0&&(B.splice(L,1),delete y.current[O.id],k.current.panelDataArrayChanged=!0,w())},[w]),P=u.useMemo(()=>({collapsePanel:T,direction:r,dragState:x,expandPanel:Y,getPanelSize:X,getPanelStyle:W,groupId:m,isPanelCollapsed:q,isPanelExpanded:ee,reevaluatePanelConstraints:j,registerPanel:F,registerResizeHandle:Z,resizePanel:N,startDragging:C,stopDragging:M,unregisterPanel:D,panelGroupElement:g.current}),[T,x,r,Y,X,W,m,q,ee,j,F,Z,N,C,M,D]),te={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return u.createElement(Xo.Provider,{value:P},u.createElement(f,{...p,children:t,className:n,id:s,ref:g,style:{...te,...d},[Ue.group]:"",[Ue.groupDirection]:r,[Ue.groupId]:m}))}const $u=u.forwardRef((e,t)=>u.createElement(zu,{...e,forwardedRef:t}));zu.displayName="PanelGroup";$u.displayName="forwardRef(PanelGroup)";function Xn(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function jn(e,t,n){const r=Xn(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:s}}function tw({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){u.useEffect(()=>{if(e||n==null||r==null)return;const o=es(t,r);if(o==null)return;const s=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const l=o.getAttribute(Ue.groupId);Ce(l,`No group element found for id "${l}"`);const c=Or(l,r),d=Mu(l,t,r);Ce(d!==null,`No resize element found for id "${t}"`);const f=i.shiftKey?d>0?d-1:c.length-1:d+1<c.length?d+1:0;c[f].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[r,e,t,n])}function Bu({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:s,onClick:i,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:f,style:p={},tabIndex:m=0,tagName:g="div",...x}){var h,v;const b=u.useRef(null),w=u.useRef({onClick:i,onDragging:l,onPointerDown:d,onPointerUp:f});u.useEffect(()=>{w.current.onClick=i,w.current.onDragging=l,w.current.onPointerDown=d,w.current.onPointerUp=f});const y=u.useContext(Xo);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:A,registerResizeHandle:I,startDragging:k,stopDragging:T,panelGroupElement:Y}=y,X=Hi(o),[W,q]=u.useState("inactive"),[ee,F]=u.useState(!1),[Z,N]=u.useState(null),j=u.useRef({state:W});Mn(()=>{j.current.state=W}),u.useEffect(()=>{if(n)N(null);else{const P=I(X);N(()=>P)}},[n,X,I]);const C=(h=r==null?void 0:r.coarse)!==null&&h!==void 0?h:15,M=(v=r==null?void 0:r.fine)!==null&&v!==void 0?v:5;u.useEffect(()=>{if(n||Z==null)return;const P=b.current;Ce(P,"Element ref not attached");let te=!1;return zv(X,P,E,{coarse:C,fine:M},(B,L,H)=>{if(!L){q("inactive");return}switch(B){case"down":{q("drag"),te=!1,Ce(H,'Expected event to be defined for "down" action'),k(X,H);const{onDragging:_,onPointerDown:G}=w.current;_==null||_(!0),G==null||G();break}case"move":{const{state:_}=j.current;te=!0,_!=="drag"&&q("hover"),Ce(H,'Expected event to be defined for "move" action'),Z(H);break}case"up":{q("hover"),T();const{onClick:_,onDragging:G,onPointerUp:J}=w.current;G==null||G(!1),J==null||J(),te||_==null||_();break}}})},[C,E,n,M,I,X,Z,k,T]),tw({disabled:n,handleId:X,resizeHandler:Z,panelGroupElement:Y});const D={touchAction:"none",userSelect:"none"};return u.createElement(g,{...x,children:e,className:t,id:o,onBlur:()=>{F(!1),s==null||s()},onFocus:()=>{F(!0),c==null||c()},ref:b,role:"separator",style:{...D,...p},tabIndex:m,[Ue.groupDirection]:E,[Ue.groupId]:A,[Ue.resizeHandle]:"",[Ue.resizeHandleActive]:W==="drag"?"pointer":ee?"keyboard":void 0,[Ue.resizeHandleEnabled]:!n,[Ue.resizeHandleId]:X,[Ue.resizeHandleState]:W})}Bu.displayName="PanelResizeHandle";function nw({className:e,...t}){return a.jsx($u,{"data-slot":"resizable-panel-group",className:Ee("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function rl({...e}){return a.jsx(Su,{"data-slot":"resizable-panel",...e})}function rw({withHandle:e,className:t,...n}){return a.jsx(Bu,{"data-slot":"resizable-handle",className:Ee("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&a.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:a.jsx(_p,{className:"size-2.5"})})})}function ow({ref:e,anchorRef:t,onClickOutside:n,enabled:r=!0}){u.useEffect(()=>{if(!r)return;const o=s=>{const i=s.target,l=e.current&&!e.current.contains(i),c=t!=null&&t.current?!t.current.contains(i):!0;l&&c&&n()};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[e,t,n,r])}function sw({onEscape:e,enabled:t=!0}){u.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[e,t])}const iw={x:0,y:0},Nt=16,aw=["top-start","bottom-end","top-end"];function lw({anchorRef:e,placement:t="top-start",offset:n=iw,fallbackPlacements:r=aw}){const o=u.useCallback((c,d,f)=>{let p=0,m=0;switch(f){case"top":p=c.top-d.height-n.y,m=c.left+(c.width-d.width)/2+n.x;break;case"top-start":p=c.top-d.height-n.y,m=c.left+n.x;break;case"top-end":p=c.top-d.height-n.y,m=c.right-d.width-n.x;break;case"bottom":p=c.bottom+n.y,m=c.left+(c.width-d.width)/2+n.x;break;case"bottom-start":p=c.bottom+n.y,m=c.left+n.x;break;case"bottom-end":p=c.bottom+n.y,m=c.right-d.width-n.x;break;case"left":p=c.top+(c.height-d.height)/2+n.y,m=c.left-d.width-n.x;break;case"left-start":p=c.top+n.y,m=c.left-d.width-n.x;break;case"left-end":p=c.bottom-d.height-n.y,m=c.left-d.width-n.x;break;case"right":p=c.top+(c.height-d.height)/2+n.y,m=c.right+n.x;break;case"right-start":p=c.top+n.y,m=c.right+n.x;break;case"right-end":p=c.bottom-d.height-n.y,m=c.right+n.x;break}return console.log(`Calculated position for ${f}:`,{top:p,left:m}),{top:p,left:m,placement:f}},[n.x,n.y]),s=u.useCallback((c,d)=>{const f={width:window.innerWidth,height:window.innerHeight};return c.left<Nt||c.top<Nt||c.left+d.width>f.width-Nt||c.top+d.height>f.height-Nt},[]),i=u.useCallback(c=>{if(!e.current){const x={width:window.innerWidth,height:window.innerHeight};return{top:x.height/2-100,left:x.width/2-100,placement:t}}const d=e.current.getBoundingClientRect(),f=c.getBoundingClientRect(),p=o(d,f,t);if(!s(p,f))return p;for(const x of r){const h=o(d,f,x);if(!s(h,f))return h}const m={width:window.innerWidth,height:window.innerHeight},g={...p};return g.left<Nt?g.left=Nt:g.left+f.width>m.width-Nt&&(g.left=m.width-f.width-Nt),g.top<Nt?g.top=Nt:g.top+f.height>m.height-Nt&&(g.top=m.height-f.height-Nt),g},[e,t,r,o,s]);return{getPositionStyle:u.useCallback(c=>{const d=i(c);return{position:"fixed",top:d.top,left:d.left,zIndex:1e3}},[i]),getOptimalPosition:i}}function cw({defaultWidth:e,minWidth:t,maxWidth:n,position:r="left",onWidthChange:o}){const[s,i]=u.useState(e),[l,c]=u.useState(!1),d=u.useRef(0),f=u.useRef(e),p=u.useCallback(b=>{b.preventDefault(),c(!0),d.current=b.clientX,f.current=s},[s]),m=u.useCallback(b=>{if(!l)return;const w=b.clientX-d.current,y=r==="right"?-w:w,E=Math.min(Math.max(f.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),g=u.useCallback(()=>{c(!1)},[]),x=u.useCallback(b=>{b.preventDefault(),c(!0),d.current=b.touches[0].clientX,f.current=s},[s]),h=u.useCallback(b=>{if(!l)return;const w=b.touches[0].clientX-d.current,y=r==="right"?-w:w,E=Math.min(Math.max(f.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),v=u.useCallback(()=>{c(!1)},[]);return u.useEffect(()=>{if(l)return document.addEventListener("mousemove",m),document.addEventListener("mouseup",g),document.addEventListener("touchmove",h),document.addEventListener("touchend",v),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",g),document.removeEventListener("touchmove",h),document.removeEventListener("touchend",v),document.body.style.userSelect="",document.body.style.cursor=""}},[l,m,g,h,v]),{width:s,isResizing:l,handleMouseDown:p,handleTouchStart:x,setWidth:i}}const uw=u.forwardRef(({children:e,defaultWidth:t=300,minWidth:n=200,maxWidth:r=800,position:o="left",resizable:s=!0,className:i,onWidthChange:l,...c},d)=>{const{width:f,isResizing:p,handleMouseDown:m,handleTouchStart:g}=cw({defaultWidth:t,minWidth:n,maxWidth:r,position:o,onWidthChange:l}),x={width:`${f}px`},h=o==="left"?"right-0":"left-0";return a.jsxs("div",{ref:d,className:Ee("relative h-full flex-shrink-0 cursor-pointer",o==="left"?"border-r":"border-l",i),style:x,...c,children:[a.jsx("div",{className:Ee("h-full overflow-x-hidden overflow-y-auto"),children:e}),s&&a.jsx("div",{className:Ee("group absolute top-0 bottom-0 w-2",h,"cursor-col-resize","hover:bg-[var(--color-primary-wMain)]","transition-all duration-200",p&&"bg-[var(--color-primary-wMain)]"),onMouseDown:m,onTouchStart:g,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} panel`,tabIndex:0,onKeyDown:b=>{if(b.key==="ArrowLeft"||b.key==="ArrowRight"){b.preventDefault();const w=b.key==="ArrowRight"?10:-10,y=o==="right"?-w:w,E=Math.min(Math.max(f+y,n),r);l==null||l(E)}},children:a.jsx("div",{className:Ee("absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 transform","bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]","group-hover:bg-[var(--color-primary-wMain)]","transition-colors duration-200",p&&"bg-[var(--color-primary-wMain)]")})})]})});uw.displayName="SidePanel";const Uu=u.createContext(null),Hu=u.createContext(void 0),Wu=u.createContext(null),Gu=u.createContext(null),Vu=u.createContext(void 0),Yu=u.createContext(null);function rn(){const e=u.useContext(Wu);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}const dw="https://solace.com/a2a/extensions/display-name",fw="https://solace.com/a2a/extensions/peer-agent-topology",pw="https://solace.com/a2a/extensions/sam/tools",mw=e=>{var o,s,i,l;let t,n,r;if((o=e.capabilities)!=null&&o.extensions){const c=e.capabilities.extensions.find(p=>p.uri===dw);(s=c==null?void 0:c.params)!=null&&s.display_name&&(t=c.params.display_name);const d=e.capabilities.extensions.find(p=>p.uri===fw);(i=d==null?void 0:d.params)!=null&&i.peer_agent_names&&(n=d.params.peer_agent_names);const f=e.capabilities.extensions.find(p=>p.uri===pw);(l=f==null?void 0:f.params)!=null&&l.tools&&(r=f.params.tools)}return{...e,display_name:t,peer_agents:n||[],tools:r||[],displayName:t,peerAgents:n||[]}},hw=()=>{const{configServerUrl:e}=rn(),[t,n]=u.useState([]),[r,o]=u.useState({}),[s,i]=u.useState(!0),[l,c]=u.useState(null),d=u.useCallback(async()=>{i(!0),c(null);try{const f=`${e}/api/v1`,p=await ze(`${f}/agentCards`,{credentials:"include"});if(!p.ok){const h=await p.json().catch(()=>({message:`Failed to fetch agents: ${p.statusText}`}));throw new Error(h.message||`Failed to fetch agents: ${p.statusText}`)}const g=(await p.json()).map(mw);n(g);const x={};g.forEach(h=>{h.name&&(x[h.name]=h.displayName||h.name)}),o(x)}catch(f){console.error("Error fetching agents:",f),c(f instanceof Error?f.message:"Could not load agent information."),n([])}finally{i(!1)}},[e]);return u.useEffect(()=>{d()},[d]),u.useMemo(()=>({agents:t,agentNameMap:r,isLoading:s,error:l,refetch:d}),[t,r,s,l,d])},gw=e=>{const{configServerUrl:t}=rn(),[n,r]=u.useState([]),[o,s]=u.useState(!0),[i,l]=u.useState(null),c=`${t}/api/v1`,d=u.useCallback(async()=>{if(!e){r([]),s(!1);return}s(!0),l(null);try{const f=await ze(`${c}/artifacts/${e}`,{credentials:"include"});if(!f.ok){const m=await f.json().catch(()=>({message:`Failed to fetch artifacts. ${f.statusText}`}));throw new Error(m.message||`Failed to fetch artifacts. ${f.statusText}`)}const p=await f.json();r(p)}catch(f){const p=f instanceof Error?f.message:"Failed to fetch artifacts.";l(p),r([])}finally{s(!1)}},[c,e]);return u.useEffect(()=>{d()},[d]),{artifacts:n,isLoading:o,error:i,refetch:d}},xw=()=>{const e=u.useContext(Uu);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},He=()=>{const e=u.useContext(Hu);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e};function vw(){const{messages:e}=He(),t=rn(),n=u.useCallback(r=>{if((t==null?void 0:t.persistenceEnabled)===!1&&!(e.length<=1))return r.preventDefault(),"Are you sure you want to leave? Your chat history will be lost."},[e.length,t==null?void 0:t.persistenceEnabled]);u.useEffect(()=>(window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}),[n])}function Ku(){const e=u.useContext(Gu);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function ww(e,t){const[n,r]=u.useState(e);return u.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const bw=async(e,t,n)=>{const r=await ze(`${e}/api/v1/artifacts/${t}/${encodeURIComponent(n.filename)}`,{credentials:"include"});if(!r.ok)throw new Error(`Failed to download artifact: ${n.filename}. Status: ${r.status}`);const o=await r.blob();fc(o,n.filename)},qu=()=>{const{configServerUrl:e}=rn(),{addNotification:t,sessionId:n}=He();return{onDownload:async o=>{if(!n){t("Cannot download artifact: No active session.","error");return}try{await bw(e,n,o),t(`Downloaded artifact: ${o.filename}.`)}catch{t(`Failed to download artifact: ${o.filename}.`,"error")}}}},yw=({onFilesDropped:e,fileFilter:t,disabled:n=!1})=>{const[r,o]=u.useState(!1),s=u.useRef(0),i=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),s.current=(s.current||0)+1,f.dataTransfer.types.includes("Files")&&o(!0))},[n,s]),l=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),f.dataTransfer.types.includes("Files")&&(f.dataTransfer.dropEffect="copy"))},[n]),c=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),s.current=(s.current||0)-1,s.current===0&&o(!1))},[n,s]),d=u.useCallback(f=>{if(n||(f.preventDefault(),f.stopPropagation(),o(!1),s.current=0,!f.dataTransfer.files||f.dataTransfer.files.length===0))return;const p=Array.from(f.dataTransfer.files),m=t?p.filter(t):p;m.length!==0&&e(m)},[n,s,t,e]);return{isDragging:r,handleDragEnter:i,handleDragOver:l,handleDragLeave:c,handleDrop:d}},Gi=()=>{const e=u.useContext(Vu);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function Xu(){const e=u.useContext(Yu);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}u.createContext(null);function Zu(e){const t=e+"CollectionProvider",[n,r]=An(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:v,children:b}=h,w=Bt.useRef(null),y=Bt.useRef(new Map).current;return a.jsx(o,{scope:v,itemMap:y,collectionRef:w,children:b})};i.displayName=t;const l=e+"CollectionSlot",c=Pn(l),d=Bt.forwardRef((h,v)=>{const{scope:b,children:w}=h,y=s(l,b),E=$e(v,y.collectionRef);return a.jsx(c,{ref:E,children:w})});d.displayName=l;const f=e+"CollectionItemSlot",p="data-radix-collection-item",m=Pn(f),g=Bt.forwardRef((h,v)=>{const{scope:b,children:w,...y}=h,E=Bt.useRef(null),A=$e(v,E),I=s(f,b);return Bt.useEffect(()=>(I.itemMap.set(E,{ref:E,...y}),()=>void I.itemMap.delete(E))),a.jsx(m,{[p]:"",ref:A,children:w})});g.displayName=f;function x(h){const v=s(e+"CollectionConsumer",h);return Bt.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((I,k)=>y.indexOf(I.ref.current)-y.indexOf(k.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:d,ItemSlot:g},x,r]}var Sw=u.createContext(void 0);function Vi(e){const t=u.useContext(Sw);return e||t||"ltr"}const Yi=u.forwardRef(({actions:e,className:t,...n},r)=>{const o=(i,l)=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l.onClick())},s=(i,l)=>{var d,f,p,m,g;const c=(d=i.currentTarget.parentElement)==null?void 0:d.querySelectorAll('[role="menuitem"]');if(c)switch(i.key){case"ArrowDown":{i.preventDefault();const x=(l+1)%c.length;(f=c[x])==null||f.focus();break}case"ArrowUp":{i.preventDefault();const x=(l-1+c.length)%c.length;(p=c[x])==null||p.focus();break}case"Home":i.preventDefault(),(m=c[0])==null||m.focus();break;case"End":i.preventDefault(),(g=c[c.length-1])==null||g.focus();break;case"Escape":i.preventDefault(),i.currentTarget.blur();break}};return a.jsx("div",{ref:r,role:"menu",className:Ee("min-w-[8rem] overflow-hidden",t),...n,children:e.map((i,l)=>a.jsxs(u.Fragment,{children:[i.divider&&l>0&&a.jsx("div",{className:"my-1 h-px bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]"}),a.jsxs("div",{role:"menuitem",tabIndex:0,className:Ee("relative my-1.5 flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm transition-colors select-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)]"),onClick:i.onClick,onKeyDown:c=>{o(c,i),s(c,l)},children:[i.icon&&i.iconPosition!=="right"&&a.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon}),a.jsx("span",{className:"flex-1",children:i.label}),i.icon&&i.iconPosition==="right"&&a.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon})]})]},i.id))})});Yi.displayName="Menu";var ts="Popover",[Ju]=An(ts,[xr]),Yr=xr(),[Cw,Nn]=Ju(ts),Qu=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,l=Yr(t),c=u.useRef(null),[d,f]=u.useState(!1),[p,m]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ts});return a.jsx(_i,{...l,children:a.jsx(Cw,{scope:t,contentId:Jt(),triggerRef:c,open:p,onOpenChange:m,onOpenToggle:u.useCallback(()=>m(g=>!g),[m]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>f(!0),[]),onCustomAnchorRemove:u.useCallback(()=>f(!1),[]),modal:i,children:n})})};Qu.displayName=ts;var ed="PopoverAnchor",Ew=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Nn(ed,n),s=Yr(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return u.useEffect(()=>(i(),()=>l()),[i,l]),a.jsx(Fo,{...s,...r,ref:t})});Ew.displayName=ed;var td="PopoverTrigger",nd=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Nn(td,n),s=Yr(n),i=$e(t,o.triggerRef),l=a.jsx(Ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ad(o.open),...r,ref:i,onClick:ve(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:a.jsx(Fo,{asChild:!0,...s,children:l})});nd.displayName=td;var Ki="PopoverPortal",[Tw,Aw]=Ju(Ki,{forceMount:void 0}),rd=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=Nn(Ki,t);return a.jsx(Tw,{scope:t,forceMount:n,children:a.jsx(mn,{present:n||s.open,children:a.jsx(Gr,{asChild:!0,container:o,children:r})})})};rd.displayName=Ki;var lr="PopoverContent",od=u.forwardRef((e,t)=>{const n=Aw(lr,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=Nn(lr,e.__scopePopover);return a.jsx(mn,{present:r||s.open,children:s.modal?a.jsx(kw,{...o,ref:t}):a.jsx(_w,{...o,ref:t})})});od.displayName=lr;var Nw=Pn("PopoverContent.RemoveScroll"),kw=u.forwardRef((e,t)=>{const n=Nn(lr,e.__scopePopover),r=u.useRef(null),o=$e(t,r),s=u.useRef(!1);return u.useEffect(()=>{const i=r.current;if(i)return Fi(i)},[]),a.jsx(Ho,{as:Nw,allowPinchZoom:!0,children:a.jsx(sd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ve(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:ve(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:ve(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),_w=u.forwardRef((e,t)=>{const n=Nn(lr,e.__scopePopover),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(sd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),sd=u.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:f,...p}=e,m=Nn(lr,n),g=Yr(n);return Oi(),a.jsx(Bo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(Hr,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),children:a.jsx(Ii,{"data-state":ad(m.open),role:"dialog",id:m.contentId,...g,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),id="PopoverClose",Iw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Nn(id,n);return a.jsx(Ne.button,{type:"button",...r,ref:t,onClick:ve(e.onClick,()=>o.onOpenChange(!1))})});Iw.displayName=id;var jw="PopoverArrow",Mw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Yr(n);return a.jsx(ji,{...o,...r,ref:t})});Mw.displayName=jw;function ad(e){return e?"open":"closed"}var Rw=Qu,Pw=nd,Lw=rd,Dw=od;function ld({...e}){return a.jsx(Rw,{"data-slot":"popover",...e})}function cd({...e}){return a.jsx(Pw,{"data-slot":"popover-trigger",...e})}function ud({className:e,align:t="center",sideOffset:n=4,...r}){return a.jsx(Lw,{children:a.jsx(Dw,{"data-slot":"popover-content",align:t,sideOffset:n,className:Ee("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-[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 bg-background z-50 w-auto origin-(--radix-popover-content-transform-origin) rounded-sm border px-0 py-1 shadow-sm outline-hidden",e),...r})})}function Ow({isOpen:e,onClose:t,anchorRef:n,children:r,placement:o="bottom-start",offset:s,className:i,closeOnClickOutside:l=!0,closeOnEscape:c=!0,portal:d=!0,animationDuration:f=150,fallbackPlacements:p}){const m=u.useRef(null),[g,x]=u.useState({}),[h,v]=u.useState(!1);ow({ref:m,anchorRef:n,onClickOutside:t,enabled:e&&l}),sw({onEscape:t,enabled:e&&c});const{getPositionStyle:b}=lw({anchorRef:n,placement:o,offset:s,fallbackPlacements:p});if(u.useEffect(()=>{e&&m.current?(v(!1),requestAnimationFrame(()=>{if(m.current){const y=b(m.current);x(y),v(!0)}})):v(!1)},[e,b]),!e)return null;const w=a.jsx("div",{ref:m,role:"dialog","aria-modal":"false",className:Ee("bg-background min-w-[8rem] overflow-hidden border shadow-md",i),style:{...g,opacity:e&&h?1:0,transform:`scale(${e&&h?1:.95})`,transition:`opacity ${f}ms ease-in-out, transform ${f}ms ease-in-out`,pointerEvents:e&&h?"auto":"none",visibility:h?"visible":"hidden"},children:r});return d?Ur.createPortal(w,document.body):w}function ol(e,[t,n]){return Math.min(n,Math.max(t,e))}function Fw(e){const t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var zw=[" ","Enter","ArrowUp","ArrowDown"],$w=[" ","Enter"],zn="Select",[ns,rs,Bw]=Zu(zn),[vr]=An(zn,[Bw,xr]),os=xr(),[Uw,kn]=vr(zn),[Hw,Ww]=vr(zn),dd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:l,onValueChange:c,dir:d,name:f,autoComplete:p,disabled:m,required:g,form:x}=e,h=os(t),[v,b]=u.useState(null),[w,y]=u.useState(null),[E,A]=u.useState(!1),I=Vi(d),[k,T]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:zn}),[Y,X]=Dn({prop:i,defaultProp:l,onChange:c,caller:zn}),W=u.useRef(null),q=v?x||!!v.closest("form"):!0,[ee,F]=u.useState(new Set),Z=Array.from(ee).map(N=>N.props.value).join(";");return a.jsx(_i,{...h,children:a.jsxs(Uw,{required:g,scope:t,trigger:v,onTriggerChange:b,valueNode:w,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:A,contentId:Jt(),value:Y,onValueChange:X,open:k,onOpenChange:T,dir:I,triggerPointerDownPosRef:W,disabled:m,children:[a.jsx(ns.Provider,{scope:t,children:a.jsx(Hw,{scope:e.__scopeSelect,onNativeOptionAdd:u.useCallback(N=>{F(j=>new Set(j).add(N))},[]),onNativeOptionRemove:u.useCallback(N=>{F(j=>{const C=new Set(j);return C.delete(N),C})},[]),children:n})}),q?a.jsxs(Rd,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:p,value:Y,onChange:N=>X(N.target.value),disabled:m,form:x,children:[Y===void 0?a.jsx("option",{value:""}):null,Array.from(ee)]},Z):null]})})};dd.displayName=zn;var fd="SelectTrigger",pd=u.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=os(n),i=kn(fd,n),l=i.disabled||r,c=$e(t,i.onTriggerChange),d=rs(n),f=u.useRef("touch"),[p,m,g]=Ld(h=>{const v=d().filter(y=>!y.disabled),b=v.find(y=>y.value===i.value),w=Dd(v,h,b);w!==void 0&&i.onValueChange(w.value)}),x=h=>{l||(i.onOpenChange(!0),g()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return a.jsx(Fo,{asChild:!0,...s,children:a.jsx(Ne.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Pd(i.value)?"":void 0,...o,ref:c,onClick:ve(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&x(h)}),onPointerDown:ve(o.onPointerDown,h=>{f.current=h.pointerType;const v=h.target;v.hasPointerCapture(h.pointerId)&&v.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(x(h),h.preventDefault())}),onKeyDown:ve(o.onKeyDown,h=>{const v=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(v&&h.key===" ")&&zw.includes(h.key)&&(x(),h.preventDefault())})})})});pd.displayName=fd;var md="SelectValue",hd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...l}=e,c=kn(md,n),{onValueNodeHasChildrenChange:d}=c,f=s!==void 0,p=$e(t,c.onValueNodeChange);return rt(()=>{d(f)},[d,f]),a.jsx(Ne.span,{...l,ref:p,style:{pointerEvents:"none"},children:Pd(c.value)?a.jsx(a.Fragment,{children:i}):s})});hd.displayName=md;var Gw="SelectIcon",gd=u.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return a.jsx(Ne.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});gd.displayName=Gw;var Vw="SelectPortal",xd=e=>a.jsx(Gr,{asChild:!0,...e});xd.displayName=Vw;var $n="SelectContent",vd=u.forwardRef((e,t)=>{const n=kn($n,e.__scopeSelect),[r,o]=u.useState();if(rt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(a.jsx(wd,{scope:e.__scopeSelect,children:a.jsx(ns.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),s):null}return a.jsx(bd,{...e,ref:t})});vd.displayName=$n;var zt=10,[wd,_n]=vr($n),Yw="SelectContentImpl",Kw=Pn("SelectContent.RemoveScroll"),bd=u.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:x,hideWhenDetached:h,avoidCollisions:v,...b}=e,w=kn($n,n),[y,E]=u.useState(null),[A,I]=u.useState(null),k=$e(t,_=>E(_)),[T,Y]=u.useState(null),[X,W]=u.useState(null),q=rs(n),[ee,F]=u.useState(!1),Z=u.useRef(!1);u.useEffect(()=>{if(y)return Fi(y)},[y]),Oi();const N=u.useCallback(_=>{const[G,...J]=q().map(se=>se.ref.current),[Q]=J.slice(-1),ae=document.activeElement;for(const se of _)if(se===ae||(se==null||se.scrollIntoView({block:"nearest"}),se===G&&A&&(A.scrollTop=0),se===Q&&A&&(A.scrollTop=A.scrollHeight),se==null||se.focus(),document.activeElement!==ae))return},[q,A]),j=u.useCallback(()=>N([T,y]),[N,T,y]);u.useEffect(()=>{ee&&j()},[ee,j]);const{onOpenChange:C,triggerPointerDownPosRef:M}=w;u.useEffect(()=>{if(y){let _={x:0,y:0};const G=Q=>{var ae,se;_={x:Math.abs(Math.round(Q.pageX)-(((ae=M.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((se=M.current)==null?void 0:se.y)??0))}},J=Q=>{_.x<=10&&_.y<=10?Q.preventDefault():y.contains(Q.target)||C(!1),document.removeEventListener("pointermove",G),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",G),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",J,{capture:!0})}}},[y,C,M]),u.useEffect(()=>{const _=()=>C(!1);return window.addEventListener("blur",_),window.addEventListener("resize",_),()=>{window.removeEventListener("blur",_),window.removeEventListener("resize",_)}},[C]);const[D,P]=Ld(_=>{const G=q().filter(ae=>!ae.disabled),J=G.find(ae=>ae.ref.current===document.activeElement),Q=Dd(G,_,J);Q&&setTimeout(()=>Q.ref.current.focus())}),te=u.useCallback((_,G,J)=>{const Q=!Z.current&&!J;(w.value!==void 0&&w.value===G||Q)&&(Y(_),Q&&(Z.current=!0))},[w.value]),O=u.useCallback(()=>y==null?void 0:y.focus(),[y]),B=u.useCallback((_,G,J)=>{const Q=!Z.current&&!J;(w.value!==void 0&&w.value===G||Q)&&W(_)},[w.value]),L=r==="popper"?Ks:yd,H=L===Ks?{side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:x,hideWhenDetached:h,avoidCollisions:v}:{};return a.jsx(wd,{scope:n,content:y,viewport:A,onViewportChange:I,itemRefCallback:te,selectedItem:T,onItemLeave:O,itemTextRefCallback:B,focusSelectedItem:j,selectedItemText:X,position:r,isPositioned:ee,searchRef:D,children:a.jsx(Ho,{as:Kw,allowPinchZoom:!0,children:a.jsx(Bo,{asChild:!0,trapped:w.open,onMountAutoFocus:_=>{_.preventDefault()},onUnmountAutoFocus:ve(o,_=>{var G;(G=w.trigger)==null||G.focus({preventScroll:!0}),_.preventDefault()}),children:a.jsx(Hr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:_=>_.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:a.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:_=>_.preventDefault(),...b,...H,onPlaced:()=>F(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:ve(b.onKeyDown,_=>{const G=_.ctrlKey||_.altKey||_.metaKey;if(_.key==="Tab"&&_.preventDefault(),!G&&_.key.length===1&&P(_.key),["ArrowUp","ArrowDown","Home","End"].includes(_.key)){let Q=q().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(_.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(_.key)){const ae=_.target,se=Q.indexOf(ae);Q=Q.slice(se+1)}setTimeout(()=>N(Q)),_.preventDefault()}})})})})})})});bd.displayName=Yw;var qw="SelectItemAlignedPosition",yd=u.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=kn($n,n),i=_n($n,n),[l,c]=u.useState(null),[d,f]=u.useState(null),p=$e(t,k=>f(k)),m=rs(n),g=u.useRef(!1),x=u.useRef(!0),{viewport:h,selectedItem:v,selectedItemText:b,focusSelectedItem:w}=i,y=u.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&h&&v&&b){const k=s.trigger.getBoundingClientRect(),T=d.getBoundingClientRect(),Y=s.valueNode.getBoundingClientRect(),X=b.getBoundingClientRect();if(s.dir!=="rtl"){const ae=X.left-T.left,se=Y.left-ae,ue=k.left-se,he=k.width+ue,ke=Math.max(he,T.width),Pe=window.innerWidth-zt,De=ol(se,[zt,Math.max(zt,Pe-ke)]);l.style.minWidth=he+"px",l.style.left=De+"px"}else{const ae=T.right-X.right,se=window.innerWidth-Y.right-ae,ue=window.innerWidth-k.right-se,he=k.width+ue,ke=Math.max(he,T.width),Pe=window.innerWidth-zt,De=ol(se,[zt,Math.max(zt,Pe-ke)]);l.style.minWidth=he+"px",l.style.right=De+"px"}const W=m(),q=window.innerHeight-zt*2,ee=h.scrollHeight,F=window.getComputedStyle(d),Z=parseInt(F.borderTopWidth,10),N=parseInt(F.paddingTop,10),j=parseInt(F.borderBottomWidth,10),C=parseInt(F.paddingBottom,10),M=Z+N+ee+C+j,D=Math.min(v.offsetHeight*5,M),P=window.getComputedStyle(h),te=parseInt(P.paddingTop,10),O=parseInt(P.paddingBottom,10),B=k.top+k.height/2-zt,L=q-B,H=v.offsetHeight/2,_=v.offsetTop+H,G=Z+N+_,J=M-G;if(G<=B){const ae=W.length>0&&v===W[W.length-1].ref.current;l.style.bottom="0px";const se=d.clientHeight-h.offsetTop-h.offsetHeight,ue=Math.max(L,H+(ae?O:0)+se+j),he=G+ue;l.style.height=he+"px"}else{const ae=W.length>0&&v===W[0].ref.current;l.style.top="0px";const ue=Math.max(B,Z+h.offsetTop+(ae?te:0)+H)+J;l.style.height=ue+"px",h.scrollTop=G-B+h.offsetTop}l.style.margin=`${zt}px 0`,l.style.minHeight=D+"px",l.style.maxHeight=q+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[m,s.trigger,s.valueNode,l,d,h,v,b,s.dir,r]);rt(()=>y(),[y]);const[E,A]=u.useState();rt(()=>{d&&A(window.getComputedStyle(d).zIndex)},[d]);const I=u.useCallback(k=>{k&&x.current===!0&&(y(),w==null||w(),x.current=!1)},[y,w]);return a.jsx(Zw,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:I,children:a.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:a.jsx(Ne.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});yd.displayName=qw;var Xw="SelectPopperPosition",Ks=u.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=zt,...s}=e,i=os(n);return a.jsx(Ii,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ks.displayName=Xw;var[Zw,qi]=vr($n,{}),qs="SelectViewport",Sd=u.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=_n(qs,n),i=qi(qs,n),l=$e(t,s.onViewportChange),c=u.useRef(0);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),a.jsx(ns.Slot,{scope:n,children:a.jsx(Ne.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ve(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const g=Math.abs(c.current-f.scrollTop);if(g>0){const x=window.innerHeight-zt*2,h=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),b=Math.max(h,v);if(b<x){const w=b+g,y=Math.min(x,w),E=w-y;p.style.height=y+"px",p.style.bottom==="0px"&&(f.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});Sd.displayName=qs;var Cd="SelectGroup",[Jw,Qw]=vr(Cd),e0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Jt();return a.jsx(Jw,{scope:n,id:o,children:a.jsx(Ne.div,{role:"group","aria-labelledby":o,...r,ref:t})})});e0.displayName=Cd;var Ed="SelectLabel",t0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Qw(Ed,n);return a.jsx(Ne.div,{id:o.id,...r,ref:t})});t0.displayName=Ed;var Ao="SelectItem",[n0,Td]=vr(Ao),Ad=u.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,l=kn(Ao,n),c=_n(Ao,n),d=l.value===r,[f,p]=u.useState(s??""),[m,g]=u.useState(!1),x=$e(t,w=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,w,r,o)}),h=Jt(),v=u.useRef("touch"),b=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return a.jsx(n0,{scope:n,value:r,disabled:o,textId:h,isSelected:d,onItemTextChange:u.useCallback(w=>{p(y=>y||((w==null?void 0:w.textContent)??"").trim())},[]),children:a.jsx(ns.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:a.jsx(Ne.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:ve(i.onFocus,()=>g(!0)),onBlur:ve(i.onBlur,()=>g(!1)),onClick:ve(i.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:ve(i.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:ve(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:ve(i.onPointerMove,w=>{var y;v.current=w.pointerType,o?(y=c.onItemLeave)==null||y.call(c):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ve(i.onPointerLeave,w=>{var y;w.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:ve(i.onKeyDown,w=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&w.key===" "||($w.includes(w.key)&&b(),w.key===" "&&w.preventDefault())})})})})});Ad.displayName=Ao;var jr="SelectItemText",Nd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=kn(jr,n),l=_n(jr,n),c=Td(jr,n),d=Ww(jr,n),[f,p]=u.useState(null),m=$e(t,b=>p(b),c.onItemTextChange,b=>{var w;return(w=l.itemTextRefCallback)==null?void 0:w.call(l,b,c.value,c.disabled)}),g=f==null?void 0:f.textContent,x=u.useMemo(()=>a.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:h,onNativeOptionRemove:v}=d;return rt(()=>(h(x),()=>v(x)),[h,v,x]),a.jsxs(a.Fragment,{children:[a.jsx(Ne.span,{id:c.textId,...s,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ur.createPortal(s.children,i.valueNode):null]})});Nd.displayName=jr;var kd="SelectItemIndicator",_d=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Td(kd,n).isSelected?a.jsx(Ne.span,{"aria-hidden":!0,...r,ref:t}):null});_d.displayName=kd;var Xs="SelectScrollUpButton",Id=u.forwardRef((e,t)=>{const n=_n(Xs,e.__scopeSelect),r=qi(Xs,e.__scopeSelect),[o,s]=u.useState(!1),i=$e(t,r.onScrollButtonChange);return rt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollTop>0;s(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Md,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});Id.displayName=Xs;var Zs="SelectScrollDownButton",jd=u.forwardRef((e,t)=>{const n=_n(Zs,e.__scopeSelect),r=qi(Zs,e.__scopeSelect),[o,s]=u.useState(!1),i=$e(t,r.onScrollButtonChange);return rt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<d;s(f)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Md,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});jd.displayName=Zs;var Md=u.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=_n("SelectScrollButton",n),i=u.useRef(null),l=rs(n),c=u.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),rt(()=>{var f;const d=l().find(p=>p.ref.current===document.activeElement);(f=d==null?void 0:d.ref.current)==null||f.scrollIntoView({block:"nearest"})},[l]),a.jsx(Ne.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ve(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ve(o.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ve(o.onPointerLeave,()=>{c()})})}),r0="SelectSeparator",o0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return a.jsx(Ne.div,{"aria-hidden":!0,...r,ref:t})});o0.displayName=r0;var Js="SelectArrow",s0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=os(n),s=kn(Js,n),i=_n(Js,n);return s.open&&i.position==="popper"?a.jsx(ji,{...o,...r,ref:t}):null});s0.displayName=Js;var i0="SelectBubbleInput",Rd=u.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=u.useRef(null),s=$e(r,o),i=Fw(t);return u.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const p=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(p)}},[i,t]),a.jsx(Ne.select,{...n,style:{...Oc,...n.style},ref:s,defaultValue:t})});Rd.displayName=i0;function Pd(e){return e===""||e===void 0}function Ld(e){const t=yn(e),n=u.useRef(""),r=u.useRef(0),o=u.useCallback(i=>{const l=n.current+i;t(l),(function c(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),s=u.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return u.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Dd(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=a0(e,Math.max(s,0));o.length===1&&(i=i.filter(d=>d!==n));const c=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function a0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var l0=dd,c0=pd,u0=hd,d0=gd,f0=xd,p0=vd,m0=Sd,h0=Ad,g0=Nd,x0=_d,v0=Id,w0=jd;function Od({...e}){return a.jsx(l0,{"data-slot":"select",...e})}function Fd({...e}){return a.jsx(u0,{"data-slot":"select-value",...e})}function zd({className:e,size:t="default",children:n,...r}){return a.jsxs(c0,{"data-slot":"select-trigger","data-size":t,className:Ee("flex w-fit items-center justify-between gap-2 border px-3 py-2 text-sm whitespace-nowrap shadow-xs disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,a.jsx(d0,{asChild:!0,children:a.jsx(zl,{className:"size-4 opacity-50"})})]})}function $d({className:e,children:t,position:n="popper",...r}){return a.jsx(f0,{children:a.jsxs(p0,{"data-slot":"select-content",className:Ee("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-[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 bg-background relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[a.jsx(b0,{}),a.jsx(m0,{className:Ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),a.jsx(y0,{})]})})}function Bd({className:e,children:t,...n}){return a.jsxs(h0,{"data-slot":"select-item",className:Ee("[&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 py-1.5 pr-8 pl-2 text-sm select-none hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[a.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:a.jsx(x0,{children:a.jsx(mi,{className:"size-4"})})}),a.jsx(g0,{children:t})]})}function b0({className:e,...t}){return a.jsx(v0,{"data-slot":"select-scroll-up-button",className:Ee("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Ip,{className:"size-4"})})}function y0({className:e,...t}){return a.jsx(w0,{"data-slot":"select-scroll-down-button",className:Ee("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(zl,{className:"size-4"})})}var Ns="rovingFocusGroup.onEntryFocus",S0={bubbles:!1,cancelable:!0},Kr="RovingFocusGroup",[Qs,Ud,C0]=Zu(Kr),[E0,Hd]=An(Kr,[C0]),[T0,A0]=E0(Kr),Wd=u.forwardRef((e,t)=>a.jsx(Qs.Provider,{scope:e.__scopeRovingFocusGroup,children:a.jsx(Qs.Slot,{scope:e.__scopeRovingFocusGroup,children:a.jsx(N0,{...e,ref:t})})}));Wd.displayName=Kr;var N0=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,m=u.useRef(null),g=$e(t,m),x=Vi(s),[h,v]=Dn({prop:i,defaultProp:l??null,onChange:c,caller:Kr}),[b,w]=u.useState(!1),y=yn(d),E=Ud(n),A=u.useRef(!1),[I,k]=u.useState(0);return u.useEffect(()=>{const T=m.current;if(T)return T.addEventListener(Ns,y),()=>T.removeEventListener(Ns,y)},[y]),a.jsx(T0,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:h,onItemFocus:u.useCallback(T=>v(T),[v]),onItemShiftTab:u.useCallback(()=>w(!0),[]),onFocusableItemAdd:u.useCallback(()=>k(T=>T+1),[]),onFocusableItemRemove:u.useCallback(()=>k(T=>T-1),[]),children:a.jsx(Ne.div,{tabIndex:b||I===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:ve(e.onMouseDown,()=>{A.current=!0}),onFocus:ve(e.onFocus,T=>{const Y=!A.current;if(T.target===T.currentTarget&&Y&&!b){const X=new CustomEvent(Ns,S0);if(T.currentTarget.dispatchEvent(X),!X.defaultPrevented){const W=E().filter(N=>N.focusable),q=W.find(N=>N.active),ee=W.find(N=>N.id===h),Z=[q,ee,...W].filter(Boolean).map(N=>N.ref.current);Yd(Z,f)}}A.current=!1}),onBlur:ve(e.onBlur,()=>w(!1))})})}),Gd="RovingFocusGroupItem",Vd=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...l}=e,c=Jt(),d=s||c,f=A0(Gd,n),p=f.currentTabStopId===d,m=Ud(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:h}=f;return u.useEffect(()=>{if(r)return g(),()=>x()},[r,g,x]),a.jsx(Qs.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:a.jsx(Ne.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:ve(e.onMouseDown,v=>{r?f.onItemFocus(d):v.preventDefault()}),onFocus:ve(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:ve(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=I0(v,f.orientation,f.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let y=m().filter(E=>E.focusable).map(E=>E.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const E=y.indexOf(v.currentTarget);y=f.loop?j0(y,E+1):y.slice(E+1)}setTimeout(()=>Yd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:h!=null}):i})})});Vd.displayName=Gd;var k0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function I0(e,t,n){const r=_0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return k0[r]}function Yd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function j0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var M0=Wd,R0=Vd,ss="Tabs",[P0]=An(ss,[Hd]),Kd=Hd(),[L0,Xi]=P0(ss),qd=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:l,activationMode:c="automatic",...d}=e,f=Vi(l),[p,m]=Dn({prop:r,onChange:o,defaultProp:s??"",caller:ss});return a.jsx(L0,{scope:n,baseId:Jt(),value:p,onValueChange:m,orientation:i,dir:f,activationMode:c,children:a.jsx(Ne.div,{dir:f,"data-orientation":i,...d,ref:t})})});qd.displayName=ss;var Xd="TabsList",Zd=u.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=Xi(Xd,n),i=Kd(n);return a.jsx(M0,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:a.jsx(Ne.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});Zd.displayName=Xd;var Jd="TabsTrigger",Qd=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=Xi(Jd,n),l=Kd(n),c=nf(i.baseId,r),d=rf(i.baseId,r),f=r===i.value;return a.jsx(R0,{asChild:!0,...l,focusable:!o,active:f,children:a.jsx(Ne.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:t,onMouseDown:ve(e.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?i.onValueChange(r):p.preventDefault()}),onKeyDown:ve(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&i.onValueChange(r)}),onFocus:ve(e.onFocus,()=>{const p=i.activationMode!=="manual";!f&&!o&&p&&i.onValueChange(r)})})})});Qd.displayName=Jd;var ef="TabsContent",tf=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,l=Xi(ef,n),c=nf(l.baseId,r),d=rf(l.baseId,r),f=r===l.value,p=u.useRef(f);return u.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),a.jsx(mn,{present:o||f,children:({present:m})=>a.jsx(Ne.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&s})})});tf.displayName=ef;function nf(e,t){return`${e}-trigger-${t}`}function rf(e,t){return`${e}-content-${t}`}var D0=qd,O0=Zd,F0=Qd,z0=tf;function $0({className:e,...t}){return a.jsx(D0,{"data-slot":"tabs",className:Ee("flex flex-col gap-2",e),...t})}function B0({className:e,...t}){return a.jsx(O0,{"data-slot":"tabs-list",className:Ee("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function sl({className:e,...t}){return a.jsx(F0,{"data-slot":"tabs-trigger","data-testid":t.value,"aria-label":t.value,title:t.title,className:Ee("data-[state=active]:bg-background dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow,background-color] hover:bg-[var(--color-brand-w10)] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-[var(--color-brand-wMain)] data-[state=active]:shadow-sm dark:hover:bg-[var(--color-brand-wMain30)] dark:data-[state=active]:text-[var(--color-brand-wMain)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function il({className:e,...t}){return a.jsx(z0,{"data-slot":"tabs-content",className:Ee("flex-1 outline-none",e),...t})}const of=u.forwardRef(({className:e,...t},n)=>a.jsx(Xc,{autoComplete:"off",ref:n,name:"message","data-testid":"chat-input",className:Ee("flex w-full items-center rounded-md px-4 py-3 placeholder:text-[var(--color-secondary-wMain)] disabled:cursor-not-allowed disabled:opacity-50",e),...t}));of.displayName="ChatInput";const U0=Tn("flex gap-2 max-w-[90%] items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),sf=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:Ee(U0({variant:t,layout:n,className:e}),"group relative"),ref:s,...o,children:u.Children.map(r,i=>u.isValidElement(i)&&typeof i.type!="string"?u.cloneElement(i,{variant:t,layout:n}):i)}));sf.displayName="ChatBubble";const H0=Tn("p-4",{variants:{variant:{received:"rounded-r-lg rounded-tl-lg",sent:"rounded-l-lg rounded-tr-lg justify-end bg-[var(--message-background)]"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),af=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:Ee(H0({variant:t,layout:n,className:e}),"relative max-w-full break-words whitespace-pre-wrap"),ref:s,...o,children:a.jsx(a.Fragment,{children:r})}));af.displayName="ChatBubbleMessage";const W0=u.forwardRef(({variant:e,className:t,children:n,...r},o)=>a.jsx("div",{ref:o,className:Ee("absolute top-1/2 flex -translate-y-1/2 opacity-0 transition-opacity duration-200 group-hover:opacity-100",e==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",t),...r,children:n}));W0.displayName="ChatBubbleActionWrapper";const lf={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},cf=Bt.forwardRef(({className:e="",children:t,...n},r)=>{const{scrollRef:o,isAtBottom:s,disableAutoScroll:i,scrollToBottom:l,userHasScrolled:c}=tb({smooth:!0,content:t});return u.useImperativeHandle(r,()=>({scrollToBottom:l})),a.jsxs("div",{className:`fade-both-mask relative h-full min-h-0 w-full flex-1 py-3 ${e}`,children:[a.jsx("div",{className:"flex h-full w-full flex-col overflow-y-auto p-4",ref:o,onWheel:i,onTouchMove:i,...n,style:{scrollBehavior:"smooth"},children:a.jsx("div",{className:"flex flex-col gap-6",style:lf,children:t})}),!s&&c&&a.jsx(be,{onClick:()=>{l()},size:"icon",variant:"outline",className:"bg-background absolute bottom-2 left-1/2 z-20 inline-flex -translate-x-1/2 transform rounded-full shadow-md","aria-label":"Scroll to bottom",children:a.jsx($l,{className:"h-4 w-4"})})]})});cf.displayName="ChatMessageList";const G0=Tn("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),V0=Tn("animate-spin",{variants:{size:{small:"size-4",medium:"size-8",large:"size-12"},variant:{primary:"text-[var(--color-brand-wMain)]",secondary:"text-[var(--color-primary-wMain)]",muted:"text-[var(--color-secondary-text-wMain)] dark:text-[var(--color-secondary-text-w50)]",foreground:"text-foreground"}},defaultVariants:{size:"medium",variant:"primary"}});function Y0({size:e,show:t,children:n,className:r,variant:o}){return a.jsxs("span",{className:G0({show:t}),children:[a.jsx(hi,{className:Ee(V0({size:e,variant:o}),r)}),n]})}function K0({className:e=""}){return a.jsx(Y0,{size:"small",variant:"primary",className:e})}const io={error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-wMain)]"},q0=Tn("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent [a&]:hover:bg-primary/90",secondary:"border-transparent [a&]:hover:bg-secondary/90",destructive:"border-transparent [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"},type:{error:io.error,warning:io.warning,info:io.info,success:io.success}},defaultVariants:{variant:"default"}});function uf({className:e,variant:t,type:n,asChild:r=!1,...o}){const s=r?ec:"span";return a.jsx(s,{"data-slot":"badge",className:Ee(q0({variant:t,type:n}),e),...o})}const X0=Tn("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function Z0({className:e,variant:t,...n}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:Ee(X0({variant:t}),e),...n})}function J0({className:e,...t}){return a.jsx("div",{"data-slot":"alert-title",className:Ee("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function Q0({message:e,type:t}){return a.jsx("div",{className:"transform transition-all duration-200 ease-in-out",children:a.jsx(Z0,{className:"border-border bg-accent max-w-80 rounded-sm shadow-md",children:a.jsxs(J0,{className:"flex items-center text-sm",children:[t==="error"&&a.jsx(gi,{className:"mr-2 text-[var(--color-error-wMain)]"}),a.jsx("div",{className:"truncate",children:e})]})})})}function eb(){const{notifications:e}=He();return e.length===0?null:a.jsx("div",{className:"pointer-events-none fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 transform flex-col-reverse gap-2",children:e.map(t=>a.jsx("div",{className:"pointer-events-auto",children:a.jsx(Q0,{id:t.id,message:t.message,type:t.type,duration:t.type==="error"?5e3:3e3})},t.id))})}function tb(e={}){const{offset:t=20,smooth:n=!1,content:r,autoScrollOnNewContent:o=!1}=e,s=u.useRef(null),i=u.useRef(0),l=u.useRef(!1),[c,d]=u.useState({isAtBottom:!0,autoScrollEnabled:!0}),f=u.useCallback(x=>{const{scrollTop:h,scrollHeight:v,clientHeight:b}=x;return Math.abs(v-h-b)<=t},[t]),p=u.useCallback(x=>{if(!s.current)return;const h=s.current.scrollHeight-s.current.clientHeight;x?s.current.scrollTop=h:s.current.scrollTo({top:h,behavior:n?"smooth":"auto"}),d({isAtBottom:!0,autoScrollEnabled:!0}),l.current=!1},[n]),m=u.useCallback(()=>{if(!s.current)return;const x=f(s.current);d(h=>({isAtBottom:x,autoScrollEnabled:x?!0:h.autoScrollEnabled}))},[f]);u.useEffect(()=>{const x=s.current;if(x)return x.addEventListener("scroll",m,{passive:!0}),()=>x.removeEventListener("scroll",m)},[m]),u.useEffect(()=>{const x=s.current;if(!x)return;const h=x.scrollHeight;h!==i.current&&((c.autoScrollEnabled||o)&&requestAnimationFrame(()=>{p(i.current===0)}),i.current=h)},[r,c.autoScrollEnabled,p,o]),u.useEffect(()=>{const x=s.current;if(!x)return;const h=new ResizeObserver(()=>{c.autoScrollEnabled&&p(!0)});return h.observe(x),()=>h.disconnect()},[c.autoScrollEnabled,p]);const g=u.useCallback(()=>{(s.current?f(s.current):!1)||(l.current=!0,d(h=>({...h,autoScrollEnabled:!1})))},[f]);return{scrollRef:s,isAtBottom:c.isAtBottom,autoScrollEnabled:c.autoScrollEnabled,scrollToBottom:()=>p(),disableAutoScroll:g,userHasScrolled:l.current}}const nb=({fileName:e,onRemove:t})=>a.jsxs(uf,{className:"bg-muted max-w-50 gap-1.5 rounded-full pr-1",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs md:text-sm",title:e,children:e}),t&&a.jsx(be,{variant:"ghost",size:"icon",onClick:t,className:"h-2 min-h-0 w-2 min-w-0 p-2",title:"Remove file",children:a.jsx(Ro,{})})]}),rb=({agents:e=[],scrollToBottom:t})=>{const{isResponding:n,isCancelling:r,userInput:o,selectedAgentName:s,setSelectedAgentName:i,setUserInput:l,handleSubmit:c,handleCancel:d}=He(),f=u.useRef(null),[p,m]=u.useState([]),g=u.useRef(null),x=u.useRef(n),[h,v]=u.useState(o),b=ww(h,300);u.useEffect(()=>{l(b)},[b,l]),u.useEffect(()=>{v(o)},[o]),u.useEffect(()=>{x.current&&!n&&setTimeout(()=>{var F;(F=g.current)==null||F.focus()},100),x.current=n},[n]);const w=()=>{var F;n||(F=f.current)==null||F.click()},y=F=>{const Z=F.target.files;if(Z){const N=Array.from(Z).filter(j=>!p.some(C=>C.name===j.name&&C.size===j.size&&C.lastModified===j.lastModified));N.length>0&&m(j=>[...j,...N])}F.target&&(F.target.value=""),setTimeout(()=>{var N;(N=g.current)==null||N.focus()},100)},E=F=>{if(n)return;const Z=F.clipboardData;if(!Z||!Z.files||Z.files.length===0)return;Z.files.length>0&&F.preventDefault();const N=Array.from(Z.files).filter(j=>!p.some(C=>C.name===j.name&&C.size===j.size&&C.lastModified===j.lastModified));N.length>0&&m(j=>[...j,...N])},A=F=>{m(Z=>Z.filter((N,j)=>j!==F))},I=u.useMemo(()=>!n&&((h==null?void 0:h.trim())||p.length!==0),[n,h,p]),k=async F=>{F.preventDefault(),I&&(await c(F,p,h.trim()),m([]),v(""),t==null||t())},T=F=>{if(n)return;const Z=F.filter(N=>!p.some(j=>j.name===N.name&&j.size===N.size&&j.lastModified===N.lastModified));Z.length>0&&m(N=>[...N,...Z])},{isDragging:Y,handleDragEnter:X,handleDragOver:W,handleDragLeave:q,handleDrop:ee}=yw({onFilesDropped:T,disabled:n});return a.jsxs("div",{className:`rounded-lg border p-4 shadow-sm ${Y?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:X,onDragOver:W,onDragLeave:q,onDrop:ee,children:[a.jsx("input",{type:"file",ref:f,className:"hidden",multiple:!0,onChange:y,accept:"*/*",disabled:n}),p.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:p.map((F,Z)=>a.jsx(nb,{fileName:F.name,onRemove:()=>A(Z)},`${F.name}-${F.lastModified}-${Z}`))}),a.jsx(of,{ref:g,value:h,onChange:F=>v(F.target.value),placeholder:"How can I help you today?",className:"field-sizing-content max-h-50 min-h-0 resize-none rounded-2xl border-none p-3 text-base/normal shadow-none transition-[height] duration-500 ease-in-out focus-visible:outline-none",rows:1,onPaste:E,onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&I&&k(F)}}),a.jsxs("div",{className:"m-2 flex items-center gap-2",children:[a.jsx(be,{variant:"ghost",onClick:w,disabled:n,tooltip:"Attach file",children:a.jsx(Bl,{className:"size-4"})}),a.jsx("div",{children:"Agent: "}),a.jsxs(Od,{value:s,onValueChange:i,disabled:n||e.length===0,children:[a.jsx(zd,{className:"w-[250px]",children:a.jsx(Fd,{defaultValue:s})}),a.jsx($d,{children:e.map(F=>a.jsx(Bd,{value:F.name,children:F.displayName||F.name},F.name))})]}),n&&!r?a.jsxs(be,{className:"ml-auto gap-1.5",onClick:d,variant:"outline",disabled:r,tooltip:"Cancel",children:[a.jsx(jp,{className:"size-4"}),"Stop"]}):a.jsx(be,{variant:"ghost",className:"ml-auto gap-1.5",onClick:k,disabled:!I,tooltip:"Send message",children:a.jsx(Mp,{className:"size-4"})})]})]})};function ob(e,t){return t&&t.toLowerCase().startsWith("text/")?!0:e?e.toLowerCase().endsWith(".txt")||e.toLowerCase().endsWith(".text"):!1}function sb(e,t){if(t){const n=t.toLowerCase();if(n==="text/html"||n==="application/xhtml+xml")return!0}return e?e.toLowerCase().endsWith(".html")||e.toLowerCase().endsWith(".htm"):!1}function ib(e,t){if(t){const n=t.toLowerCase();if(n==="text/x-mermaid"||n==="application/x-mermaid")return!0}return e?e.toLowerCase().endsWith(".mermaid")||e.toLowerCase().endsWith(".mmd"):!1}function ab(e,t){if(t){const n=t.toLowerCase();if(n==="text/csv"||n==="application/csv")return!0}return e?e.toLowerCase().endsWith(".csv"):!1}function lb(e,t){if(t&&t.toLowerCase().startsWith("image/"))return!0;if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".png")||n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".gif")||n.endsWith(".bmp")||n.endsWith(".webp")||n.endsWith(".svg")}function cb(e,t){if(t){const n=t.toLowerCase();if(n==="application/json"||n==="text/json")return!0}return e?e.toLowerCase().endsWith(".json"):!1}function ub(e,t){if(t){const r=t.toLowerCase();if(r==="application/yaml"||r==="text/yaml"||r==="application/x-yaml"||r==="text/x-yaml")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".yaml")||n.endsWith(".yml")}function db(e,t){if(t){const r=t.toLowerCase();if(r==="text/markdown"||r==="application/markdown"||r==="text/x-markdown")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function fb(e,t){if(t&&t.toLowerCase().startsWith("audio/"))return!0;if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".mp3")||n.endsWith(".wav")||n.endsWith(".ogg")||n.endsWith(".aac")||n.endsWith(".flac")||n.endsWith(".m4a")}function qr(e,t){return sb(e,t)?"html":ib(e,t)?"mermaid":lb(e,t)?"image":db(e,t)?"markdown":fb(e,t)?"audio":cb(e,t)?"json":ub(e,t)?"yaml":ab(e,t)?"csv":ob(e,t)?"text":null}function df(e){try{const t=Uint8Array.from(atob(e),n=>n.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!1}).decode(t)}catch(t){console.warn("TextDecoder failed (potentially non-UTF8 data), falling back to simple atob:",t);try{return atob(e)}catch(n){return console.error("Failed to decode base64 content with atob fallback:",n),e}}}const ff=["csv","html","json","mermaid","image","markdown","audio","text","yaml"],pb=["image","audio"],mb=e=>{if(!e||!e.content)return"";const t=qr(e.name,e.mime_type);if(!t||!ff.includes(t))return"";if(pb.includes(t))return e.content;try{return df(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},pf=5*1024*1024,hb=pc(pf);function gb(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=qr(e.filename,e.mime_type);return!t||!ff.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>pf?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${hb}.`}:{canPreview:!0}}const mf=(e,t="h-4 w-4")=>{if(!e)return a.jsx(ua,{className:t});switch(qr(e.filename,e.mime_type)){case"image":case"mermaid":return a.jsx(Op,{className:t});case"audio":return a.jsx(Dp,{className:t});case"html":return a.jsx(Lp,{className:t});case"text":return a.jsx(sr,{className:t});case"csv":return a.jsx(Pp,{className:t});case"json":return a.jsx(Rp,{className:t});default:return a.jsx(ua,{className:t})}},hf=({fileAttachment:e,isEmbedded:t=!1})=>a.jsx(gf,{filename:e.name,mimeType:e.mime_type,onDownload:()=>nh(e),className:"ml-4",isEmbedded:t}),gf=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:o=!1})=>{const{artifacts:s,setPreviewArtifact:i,openSidePanelTab:l}=He(),c=u.useMemo(()=>s.find(f=>f.filename===e),[s,e]),d=u.useMemo(()=>mf(c||{filename:e,mime_type:t||""}),[c,e,t]);return a.jsxs("div",{className:`flex h-11 max-w-xs flex-shrink items-center gap-2 rounded-lg bg-[var(--accent-background)] px-2 py-1 ${n||""}`,children:[d,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-9",title:e,children:a.jsx("strong",{children:a.jsx("code",{children:e})})}),c&&!o&&a.jsx(be,{variant:"ghost",onClick:f=>{f.stopPropagation(),l("files"),i(c)},tooltip:"Preview",children:a.jsx(Ul,{className:"h-4 w-4"})}),r&&a.jsx(be,{variant:"ghost",onClick:()=>r(),tooltip:"Download file",children:a.jsx(xi,{className:"h-4 w-4"})})]})},xb=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"audio/mpeg"};base64,${e}`;return a.jsx("div",{className:"flex h-auto max-w-[100vw] items-center justify-center p-4",children:a.jsxs("audio",{controls:!0,className:"w-full",onLoad:()=>n(null),onError:()=>n("Failed to load audio content."),children:[a.jsx("source",{src:r,type:t||"audio/mpeg"}),"Your browser does not support the audio element."]})})},vb=e=>{if(!e)return[];const t=[];let n=[],r="",o=!1;for(let s=0;s<e.length;s++){const i=e[s],l=s<e.length-1?e[s+1]:"";i==='"'?l==='"'?(r+='"',s++):o=!o:i===","&&!o?(n.push(r.trim()),r=""):(i===`
117
- `||i==="\r"&&l===`
118
- `)&&!o?(i==="\r"&&l===`
119
- `&&s++,n.push(r.trim()),r="",n.some(c=>c.trim())?(t.push(n),n=[]):n=[]):r+=i}return(r||n.length>0)&&(n.push(r.trim()),n.some(s=>s.trim())&&t.push(n)),t},wb=({content:e,setRenderError:t})=>{u.useEffect(()=>{t(null)},[e,t]);const n=u.useMemo(()=>{try{return vb(e)}catch(r){return console.error("Error parsing CSV:",r),t("Failed to parse CSV content."),[]}},[e,t]);return n.length?a.jsx("div",{className:"block w-full overflow-x-scroll p-4",children:a.jsx("div",{style:{minWidth:"min(100%, max-content)"},children:a.jsxs("table",{className:"w-full border text-sm",children:[a.jsx("thead",{className:"sticky top-0 z-10 shadow-sm",children:n.length>0&&a.jsx("tr",{children:n[0].map((r,o)=>a.jsx("th",{className:"border-b p-2 text-left font-medium whitespace-nowrap",title:r,children:(r==null?void 0:r.trim())||""},`header-${o}`))})}),a.jsx("tbody",{children:n.slice(1).map((r,o)=>a.jsx("tr",{className:o%2===0?"bg-muted dark:bg-gray-700":"",children:r.map((s,i)=>a.jsx("td",{className:"min-w-0 border-b p-2 align-top break-words",title:s,children:(s==null?void 0:s.trim())||""},`cell-${o}-${i}`))},`row-${o}`))})]})})}):a.jsx("div",{children:"No valid CSV content found or failed to parse."})},bb=({content:e,setRenderError:t})=>{const n=u.useMemo(()=>e.replace(/<script(?:\s[^>]*)?>([\s\S]*?)<\/script>/gi,(s,i)=>{const l=s.match(/<script(\s[^>]*)?>/i);return`<script${l&&l[1]?l[1]:""}>(function() {
120
- try {
121
- ${i}
122
- } catch (e) { console.error('Error in sandboxed script:', e); }
123
- })();<\/script>`}),[e]);return a.jsx("div",{className:"h-full w-full overflow-hidden border dark:bg-gray-400",children:a.jsx("iframe",{srcDoc:n,title:"HTML Preview",sandbox:"allow-scripts allow-same-origin allow-downloads allow-forms allow-popups",allow:"autoplay",className:"h-full w-full border-none",onError:()=>t("Failed to load HTML content."),onLoad:()=>t(null)})})},yb=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"image/png"};base64,${e}`;return a.jsx("div",{className:"flex h-auto w-auto max-w-[100vw] items-center justify-center p-4",children:a.jsx("img",{src:r,onError:()=>n("Failed to load image"),onLoad:()=>n(null),alt:"Preview",className:"h-full w-full object-contain"})})};function xf(){const e=u.useRef(null),t=()=>{if(e.current){const r=document.createRange();r.selectNodeContents(e.current);const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(r))}};return{ref:e,handleKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="a"&&(r.preventDefault(),t())},selectAllContent:t}}const Sb=({content:e})=>{const{ref:t,handleKeyDown:n}=xf();return a.jsx("div",{className:"w-full p-4",children:a.jsx("div",{ref:t,className:"max-w-full overflow-hidden select-text focus-visible:outline-none",tabIndex:0,onKeyDown:n,children:a.jsx(or,{className:"max-w-full break-words",children:e})})})};/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:vf,setPrototypeOf:al,isFrozen:Cb,getPrototypeOf:Eb,getOwnPropertyDescriptor:Tb}=Object;let{freeze:lt,seal:_t,create:wf}=Object,{apply:ei,construct:ti}=typeof Reflect<"u"&&Reflect;lt||(lt=function(t){return t});_t||(_t=function(t){return t});ei||(ei=function(t,n,r){return t.apply(n,r)});ti||(ti=function(t,n){return new t(...n)});const ao=ct(Array.prototype.forEach),Ab=ct(Array.prototype.lastIndexOf),ll=ct(Array.prototype.pop),Sr=ct(Array.prototype.push),Nb=ct(Array.prototype.splice),vo=ct(String.prototype.toLowerCase),ks=ct(String.prototype.toString),cl=ct(String.prototype.match),Cr=ct(String.prototype.replace),kb=ct(String.prototype.indexOf),_b=ct(String.prototype.trim),$t=ct(Object.prototype.hasOwnProperty),st=ct(RegExp.prototype.test),Er=Ib(TypeError);function ct(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return ei(e,t,r)}}function Ib(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ti(e,n)}}function Ae(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:vo;al&&al(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&(Cb(t)||(t[r]=s),o=s)}e[o]=!0}return e}function jb(e){for(let t=0;t<e.length;t++)$t(e,t)||(e[t]=null);return e}function ln(e){const t=wf(null);for(const[n,r]of vf(e))$t(e,n)&&(Array.isArray(r)?t[n]=jb(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=ln(r):t[n]=r);return t}function Tr(e,t){for(;e!==null;){const r=Tb(e,t);if(r){if(r.get)return ct(r.get);if(typeof r.value=="function")return ct(r.value)}e=Eb(e)}function n(){return null}return n}const ul=lt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),_s=lt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Is=lt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Mb=lt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),js=lt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Rb=lt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),dl=lt(["#text"]),fl=lt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Ms=lt(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pl=lt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),lo=lt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Pb=_t(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Lb=_t(/<%[\w\W]*|[\w\W]*%>/gm),Db=_t(/\$\{[\w\W]*/gm),Ob=_t(/^data-[\-\w.\u00B7-\uFFFF]+$/),Fb=_t(/^aria-[\-\w]+$/),bf=_t(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),zb=_t(/^(?:\w+script|data):/i),$b=_t(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),yf=_t(/^html$/i),Bb=_t(/^[a-z][.\w]*(-[.\w]+)+$/i);var ml=Object.freeze({__proto__:null,ARIA_ATTR:Fb,ATTR_WHITESPACE:$b,CUSTOM_ELEMENT:Bb,DATA_ATTR:Ob,DOCTYPE_NAME:yf,ERB_EXPR:Lb,IS_ALLOWED_URI:bf,IS_SCRIPT_OR_DATA:zb,MUSTACHE_EXPR:Pb,TMPLIT_EXPR:Db});const Ar={element:1,text:3,progressingInstruction:7,comment:8,document:9},Ub=function(){return typeof window>"u"?null:window},Hb=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},hl=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Sf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ub();const t=K=>Sf(K);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==Ar.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:d,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:g}=e,x=c.prototype,h=Tr(x,"cloneNode"),v=Tr(x,"remove"),b=Tr(x,"nextSibling"),w=Tr(x,"childNodes"),y=Tr(x,"parentNode");if(typeof i=="function"){const K=n.createElement("template");K.content&&K.content.ownerDocument&&(n=K.content.ownerDocument)}let E,A="";const{implementation:I,createNodeIterator:k,createDocumentFragment:T,getElementsByTagName:Y}=n,{importNode:X}=r;let W=hl();t.isSupported=typeof vf=="function"&&typeof y=="function"&&I&&I.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:q,ERB_EXPR:ee,TMPLIT_EXPR:F,DATA_ATTR:Z,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:j,ATTR_WHITESPACE:C,CUSTOM_ELEMENT:M}=ml;let{IS_ALLOWED_URI:D}=ml,P=null;const te=Ae({},[...ul,..._s,...Is,...js,...dl]);let O=null;const B=Ae({},[...fl,...Ms,...pl,...lo]);let L=Object.seal(wf(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),H=null,_=null,G=!0,J=!0,Q=!1,ae=!0,se=!1,ue=!0,he=!1,ke=!1,Pe=!1,De=!1,Me=!1,Be=!1,wt=!0,We=!1;const bt="user-content-";let et=!0,tt=!1,nt={},le=null;const It=Ae({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let yt=null;const jt=Ae({},["audio","video","img","source","image","track"]);let Mt=null;const St=Ae({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ct="http://www.w3.org/1998/Math/MathML",Et="http://www.w3.org/2000/svg",Xe="http://www.w3.org/1999/xhtml";let dt=Xe,Rt=!1,Pt=null;const on=Ae({},[Ct,Et,Xe],ks);let Le=Ae({},["mi","mo","mn","ms","mtext"]),Ge=Ae({},["annotation-xml"]);const Lt=Ae({},["title","style","font","a","script"]);let mt=null;const Dt=["application/xhtml+xml","text/html"],Ot="text/html";let Oe=null,ft=null;const sn=n.createElement("form"),Vt=function(S){return S instanceof RegExp||S instanceof Function},Tt=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ft&&ft===S)){if((!S||typeof S!="object")&&(S={}),S=ln(S),mt=Dt.indexOf(S.PARSER_MEDIA_TYPE)===-1?Ot:S.PARSER_MEDIA_TYPE,Oe=mt==="application/xhtml+xml"?ks:vo,P=$t(S,"ALLOWED_TAGS")?Ae({},S.ALLOWED_TAGS,Oe):te,O=$t(S,"ALLOWED_ATTR")?Ae({},S.ALLOWED_ATTR,Oe):B,Pt=$t(S,"ALLOWED_NAMESPACES")?Ae({},S.ALLOWED_NAMESPACES,ks):on,Mt=$t(S,"ADD_URI_SAFE_ATTR")?Ae(ln(St),S.ADD_URI_SAFE_ATTR,Oe):St,yt=$t(S,"ADD_DATA_URI_TAGS")?Ae(ln(jt),S.ADD_DATA_URI_TAGS,Oe):jt,le=$t(S,"FORBID_CONTENTS")?Ae({},S.FORBID_CONTENTS,Oe):It,H=$t(S,"FORBID_TAGS")?Ae({},S.FORBID_TAGS,Oe):ln({}),_=$t(S,"FORBID_ATTR")?Ae({},S.FORBID_ATTR,Oe):ln({}),nt=$t(S,"USE_PROFILES")?S.USE_PROFILES:!1,G=S.ALLOW_ARIA_ATTR!==!1,J=S.ALLOW_DATA_ATTR!==!1,Q=S.ALLOW_UNKNOWN_PROTOCOLS||!1,ae=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,se=S.SAFE_FOR_TEMPLATES||!1,ue=S.SAFE_FOR_XML!==!1,he=S.WHOLE_DOCUMENT||!1,De=S.RETURN_DOM||!1,Me=S.RETURN_DOM_FRAGMENT||!1,Be=S.RETURN_TRUSTED_TYPE||!1,Pe=S.FORCE_BODY||!1,wt=S.SANITIZE_DOM!==!1,We=S.SANITIZE_NAMED_PROPS||!1,et=S.KEEP_CONTENT!==!1,tt=S.IN_PLACE||!1,D=S.ALLOWED_URI_REGEXP||bf,dt=S.NAMESPACE||Xe,Le=S.MATHML_TEXT_INTEGRATION_POINTS||Le,Ge=S.HTML_INTEGRATION_POINTS||Ge,L=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&Vt(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(L.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&Vt(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(L.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(L.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),se&&(J=!1),Me&&(De=!0),nt&&(P=Ae({},dl),O=[],nt.html===!0&&(Ae(P,ul),Ae(O,fl)),nt.svg===!0&&(Ae(P,_s),Ae(O,Ms),Ae(O,lo)),nt.svgFilters===!0&&(Ae(P,Is),Ae(O,Ms),Ae(O,lo)),nt.mathMl===!0&&(Ae(P,js),Ae(O,pl),Ae(O,lo))),S.ADD_TAGS&&(P===te&&(P=ln(P)),Ae(P,S.ADD_TAGS,Oe)),S.ADD_ATTR&&(O===B&&(O=ln(O)),Ae(O,S.ADD_ATTR,Oe)),S.ADD_URI_SAFE_ATTR&&Ae(Mt,S.ADD_URI_SAFE_ATTR,Oe),S.FORBID_CONTENTS&&(le===It&&(le=ln(le)),Ae(le,S.FORBID_CONTENTS,Oe)),et&&(P["#text"]=!0),he&&Ae(P,["html","head","body"]),P.table&&(Ae(P,["tbody"]),delete H.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw Er('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Er('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=S.TRUSTED_TYPES_POLICY,A=E.createHTML("")}else E===void 0&&(E=Hb(g,o)),E!==null&&typeof A=="string"&&(A=E.createHTML(""));lt&&lt(S),ft=S}},Ft=Ae({},[..._s,...Is,...Mb]),Yt=Ae({},[...js,...Rb]),Se=function(S){let R=y(S);(!R||!R.tagName)&&(R={namespaceURI:dt,tagName:"template"});const V=vo(S.tagName),me=vo(R.tagName);return Pt[S.namespaceURI]?S.namespaceURI===Et?R.namespaceURI===Xe?V==="svg":R.namespaceURI===Ct?V==="svg"&&(me==="annotation-xml"||Le[me]):!!Ft[V]:S.namespaceURI===Ct?R.namespaceURI===Xe?V==="math":R.namespaceURI===Et?V==="math"&&Ge[me]:!!Yt[V]:S.namespaceURI===Xe?R.namespaceURI===Et&&!Ge[me]||R.namespaceURI===Ct&&!Le[me]?!1:!Yt[V]&&(Lt[V]||!Ft[V]):!!(mt==="application/xhtml+xml"&&Pt[S.namespaceURI]):!1},$=function(S){Sr(t.removed,{element:S});try{y(S).removeChild(S)}catch{v(S)}},U=function(S,R){try{Sr(t.removed,{attribute:R.getAttributeNode(S),from:R})}catch{Sr(t.removed,{attribute:null,from:R})}if(R.removeAttribute(S),S==="is")if(De||Me)try{$(R)}catch{}else try{R.setAttribute(S,"")}catch{}},z=function(S){let R=null,V=null;if(Pe)S="<remove></remove>"+S;else{const fe=cl(S,/^[\r\n\t ]+/);V=fe&&fe[0]}mt==="application/xhtml+xml"&&dt===Xe&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const me=E?E.createHTML(S):S;if(dt===Xe)try{R=new m().parseFromString(me,mt)}catch{}if(!R||!R.documentElement){R=I.createDocument(dt,"template",null);try{R.documentElement.innerHTML=Rt?A:me}catch{}}const Re=R.body||R.documentElement;return S&&V&&Re.insertBefore(n.createTextNode(V),Re.childNodes[0]||null),dt===Xe?Y.call(R,he?"html":"body")[0]:he?R.documentElement:Re},ie=function(S){return k.call(S.ownerDocument||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},de=function(S){return S instanceof p&&(typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||!(S.attributes instanceof f)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function")},pe=function(S){return typeof l=="function"&&S instanceof l};function ge(K,S,R){ao(K,V=>{V.call(t,S,R,ft)})}const xe=function(S){let R=null;if(ge(W.beforeSanitizeElements,S,null),de(S))return $(S),!0;const V=Oe(S.nodeName);if(ge(W.uponSanitizeElement,S,{tagName:V,allowedTags:P}),ue&&S.hasChildNodes()&&!pe(S.firstElementChild)&&st(/<[/\w!]/g,S.innerHTML)&&st(/<[/\w!]/g,S.textContent)||S.nodeType===Ar.progressingInstruction||ue&&S.nodeType===Ar.comment&&st(/<[/\w]/g,S.data))return $(S),!0;if(!P[V]||H[V]){if(!H[V]&&ne(V)&&(L.tagNameCheck instanceof RegExp&&st(L.tagNameCheck,V)||L.tagNameCheck instanceof Function&&L.tagNameCheck(V)))return!1;if(et&&!le[V]){const me=y(S)||S.parentNode,Re=w(S)||S.childNodes;if(Re&&me){const fe=Re.length;for(let ye=fe-1;ye>=0;--ye){const je=h(Re[ye],!0);je.__removalCount=(S.__removalCount||0)+1,me.insertBefore(je,b(S))}}}return $(S),!0}return S instanceof c&&!Se(S)||(V==="noscript"||V==="noembed"||V==="noframes")&&st(/<\/no(script|embed|frames)/i,S.innerHTML)?($(S),!0):(se&&S.nodeType===Ar.text&&(R=S.textContent,ao([q,ee,F],me=>{R=Cr(R,me," ")}),S.textContent!==R&&(Sr(t.removed,{element:S.cloneNode()}),S.textContent=R)),ge(W.afterSanitizeElements,S,null),!1)},Ie=function(S,R,V){if(wt&&(R==="id"||R==="name")&&(V in n||V in sn))return!1;if(!(J&&!_[R]&&st(Z,R))){if(!(G&&st(N,R))){if(!O[R]||_[R]){if(!(ne(S)&&(L.tagNameCheck instanceof RegExp&&st(L.tagNameCheck,S)||L.tagNameCheck instanceof Function&&L.tagNameCheck(S))&&(L.attributeNameCheck instanceof RegExp&&st(L.attributeNameCheck,R)||L.attributeNameCheck instanceof Function&&L.attributeNameCheck(R))||R==="is"&&L.allowCustomizedBuiltInElements&&(L.tagNameCheck instanceof RegExp&&st(L.tagNameCheck,V)||L.tagNameCheck instanceof Function&&L.tagNameCheck(V))))return!1}else if(!Mt[R]){if(!st(D,Cr(V,C,""))){if(!((R==="src"||R==="xlink:href"||R==="href")&&S!=="script"&&kb(V,"data:")===0&&yt[S])){if(!(Q&&!st(j,Cr(V,C,"")))){if(V)return!1}}}}}}return!0},ne=function(S){return S!=="annotation-xml"&&cl(S,M)},we=function(S){ge(W.beforeSanitizeAttributes,S,null);const{attributes:R}=S;if(!R||de(S))return;const V={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:O,forceKeepAttr:void 0};let me=R.length;for(;me--;){const Re=R[me],{name:fe,namespaceURI:ye,value:je}=Re,At=Oe(fe),hn=je;let Fe=fe==="value"?hn:_b(hn);if(V.attrName=At,V.attrValue=Fe,V.keepAttr=!0,V.forceKeepAttr=void 0,ge(W.uponSanitizeAttribute,S,V),Fe=V.attrValue,We&&(At==="id"||At==="name")&&(U(fe,S),Fe=bt+Fe),ue&&st(/((--!?|])>)|<\/(style|title)/i,Fe)){U(fe,S);continue}if(V.forceKeepAttr)continue;if(!V.keepAttr){U(fe,S);continue}if(!ae&&st(/\/>/i,Fe)){U(fe,S);continue}se&&ao([q,ee,F],wr=>{Fe=Cr(Fe,wr," ")});const ls=Oe(S.nodeName);if(!Ie(ls,At,Fe)){U(fe,S);continue}if(E&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!ye)switch(g.getAttributeType(ls,At)){case"TrustedHTML":{Fe=E.createHTML(Fe);break}case"TrustedScriptURL":{Fe=E.createScriptURL(Fe);break}}if(Fe!==hn)try{ye?S.setAttributeNS(ye,fe,Fe):S.setAttribute(fe,Fe),de(S)?$(S):ll(t.removed)}catch{U(fe,S)}}ge(W.afterSanitizeAttributes,S,null)},_e=function K(S){let R=null;const V=ie(S);for(ge(W.beforeSanitizeShadowDOM,S,null);R=V.nextNode();)ge(W.uponSanitizeShadowNode,R,null),xe(R),we(R),R.content instanceof s&&K(R.content);ge(W.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(K){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},R=null,V=null,me=null,Re=null;if(Rt=!K,Rt&&(K="<!-->"),typeof K!="string"&&!pe(K))if(typeof K.toString=="function"){if(K=K.toString(),typeof K!="string")throw Er("dirty is not a string, aborting")}else throw Er("toString is not a function");if(!t.isSupported)return K;if(ke||Tt(S),t.removed=[],typeof K=="string"&&(tt=!1),tt){if(K.nodeName){const je=Oe(K.nodeName);if(!P[je]||H[je])throw Er("root node is forbidden and cannot be sanitized in-place")}}else if(K instanceof l)R=z("<!---->"),V=R.ownerDocument.importNode(K,!0),V.nodeType===Ar.element&&V.nodeName==="BODY"||V.nodeName==="HTML"?R=V:R.appendChild(V);else{if(!De&&!se&&!he&&K.indexOf("<")===-1)return E&&Be?E.createHTML(K):K;if(R=z(K),!R)return De?null:Be?A:""}R&&Pe&&$(R.firstChild);const fe=ie(tt?K:R);for(;me=fe.nextNode();)xe(me),we(me),me.content instanceof s&&_e(me.content);if(tt)return K;if(De){if(Me)for(Re=T.call(R.ownerDocument);R.firstChild;)Re.appendChild(R.firstChild);else Re=R;return(O.shadowroot||O.shadowrootmode)&&(Re=X.call(r,Re,!0)),Re}let ye=he?R.outerHTML:R.innerHTML;return he&&P["!doctype"]&&R.ownerDocument&&R.ownerDocument.doctype&&R.ownerDocument.doctype.name&&st(yf,R.ownerDocument.doctype.name)&&(ye="<!DOCTYPE "+R.ownerDocument.doctype.name+`>
124
- `+ye),se&&ao([q,ee,F],je=>{ye=Cr(ye,je," ")}),E&&Be?E.createHTML(ye):ye},t.setConfig=function(){let K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Tt(K),ke=!0},t.clearConfig=function(){ft=null,ke=!1},t.isValidAttribute=function(K,S,R){ft||Tt({});const V=Oe(K),me=Oe(S);return Ie(V,me,R)},t.addHook=function(K,S){typeof S=="function"&&Sr(W[K],S)},t.removeHook=function(K,S){if(S!==void 0){const R=Ab(W[K],S);return R===-1?void 0:Nb(W[K],R,1)[0]}return ll(W[K])},t.removeHooks=function(K){W[K]=[]},t.removeAllHooks=function(){W=hl()},t}var Cf=Sf();const Wb=({content:e,setRenderError:t})=>{const[n,r]=u.useState(""),o=u.useMemo(()=>Cf.sanitize(e,{USE_PROFILES:{html:!1},ALLOWED_TAGS:["br","em","strong","b","i"],ALLOWED_ATTR:[]}),[e]);return u.useEffect(()=>{r(`<!DOCTYPE html>
125
- <html>
126
- <head>
127
- <meta charset="utf-8">
128
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
129
- <title>Mermaid Preview</title>
130
- <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"><\/script>
131
- <script src="https://cdn.jsdelivr.net/npm/panzoom@9.4.0/dist/panzoom.min.js"><\/script>
132
- <script>
133
- document.addEventListener('DOMContentLoaded', function() {
134
- try {
135
- mermaid.initialize({
136
- startOnLoad: true,
137
- theme: 'default',
138
- fontFamily: 'arial, sans-serif',
139
- logLevel: 'error',
140
- securityLevel: 'strict'
141
- });
142
-
143
- // Initialize panzoom after Mermaid rendering
144
- mermaid.run().then(() => {
145
- const diagramContainer = document.getElementById('diagram-container');
146
- if (diagramContainer) {
147
- const pz = panzoom(diagramContainer, {
148
- maxZoom: 10,
149
- minZoom: 0.1,
150
- smoothScroll: true,
151
- bounds: true,
152
- boundsPadding: 0.1
153
- });
154
- // Add zoom controls (old version had only reset)
155
- const resetButton = document.getElementById('reset');
156
- if (resetButton) {
157
- resetButton.addEventListener('click', () => {
158
- pz.moveTo(0, 0);
159
- pz.zoomAbs(0, 0, 1);
160
- });
161
- }
162
- }
163
- }).catch(err => {
164
- console.error("Mermaid rendering failed inside iframe:", err);
165
- const mermaidDiv = document.querySelector('.mermaid');
166
- if (mermaidDiv) mermaidDiv.innerText = "Error rendering diagram: " + err.message;
167
- });
168
-
169
- window.addEventListener('message', function(event) {
170
- if (event.data && event.data.action === 'getMermaidSvg') {
171
- const svgElement = document.querySelector('.mermaid svg');
172
- if (svgElement) {
173
- if (!svgElement.getAttribute('xmlns')) { // Ensure xmlns for standalone SVG
174
- svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
175
- }
176
- const svgData = new XMLSerializer().serializeToString(svgElement);
177
- window.parent.postMessage({
178
- action: 'downloadSvg',
179
- svgData: svgData,
180
- filename: event.data.filename || 'mermaid-diagram.svg'
181
- }, '*');
182
- } else {
183
- console.error('SVG element not found for download inside iframe.');
184
- }
185
- }
186
- });
187
- } catch (e) {
188
- console.error("Error initializing Mermaid or Panzoom inside iframe:", e);
189
- const mermaidDiv = document.querySelector('.mermaid');
190
- if (mermaidDiv) mermaidDiv.innerText = "Failed to initialize diagram viewer: " + e.message;
191
- }
192
- });
193
- <\/script>
194
- <style>
195
- /* Styles from old code */
196
- html, body {
197
- height: 100%;
198
- margin: 0;
199
- padding: 0;
200
- overflow: hidden;
201
- font-family: Arial, sans-serif; /* Old font */
202
- }
203
- .container {
204
- display: flex;
205
- flex-direction: column;
206
- height: 100vh;
207
- overflow: hidden;
208
- }
209
- .diagram-wrapper {
210
- flex: 1;
211
- overflow: hidden;
212
- position: relative;
213
- display: flex;
214
- justify-content: center;
215
- align-items: center;
216
- background-color: #f9f9f9;
217
- }
218
- #diagram-container {
219
- transform-origin: 0 0;
220
- cursor: grab;
221
- box-shadow: 0 0 10px rgba(0,0,0,0.1);
222
- background-color: white;
223
- padding: 20px;
224
- border-radius: 5px;
225
- /* Ensure diagram container can hold the content */
226
- width: auto; /* Adjust as needed, or let content define it */
227
- height: auto;
228
- max-width: 100%;
229
- max-height: 100%;
230
- }
231
- #diagram-container:active {
232
- cursor: grabbing;
233
- }
234
- .mermaid {
235
- display: flex; /* Helps in centering if SVG is smaller */
236
- justify-content: center;
237
- align-items: center;
238
- /* width: 100%; Ensures mermaid div takes space, SVG might scale within it */
239
- /* height: 100%; */
240
- }
241
- .mermaid svg {
242
- max-width: 100%; /* Ensure SVG scales down if too large */
243
- max-height: 100%;
244
- }
245
- .controls{
246
- position: fixed;
247
- bottom: 20px;
248
- right: 20px;
249
- z-index: 1000;
250
- display: flex;
251
- gap: 5px;
252
- }
253
- .control-btn {
254
- width: 40px;
255
- height: 40px;
256
- border-radius: 50%;
257
- border: none;
258
- background-color: white;
259
- box-shadow: 0 2px 5px rgba(0,0,0,0.2);
260
- cursor: pointer;
261
- font-size: 18px;
262
- display: flex;
263
- align-items: center;
264
- justify-content: center;
265
- }
266
- .control-btn:hover {
267
- background-color: #f0f0f0;
268
- }
269
- .instructions {
270
- position: fixed;
271
- top: 10px;
272
- left: 10px;
273
- background-color: rgba(255,255,255,0.8);
274
- padding: 5px 10px;
275
- border-radius: 4px;
276
- font-size: 12px;
277
- color: #666;
278
- }
279
- </style>
280
- </head>
281
- <body>
282
- <div class="container">
283
- <div class="diagram-wrapper">
284
- <div id="diagram-container">
285
- <div class="mermaid">
286
- ${o}
287
- </div>
288
- </div>
289
- </div>
290
- <div class="instructions">
291
- Drag to pan and scroll to zoom
292
- </div>
293
- <div class="controls">
294
- <button id="reset" class="control-btn" title="Reset View">↺</button>
295
- </div>
296
- </div>
297
- </body>
298
- </html>`)},[o]),a.jsx("div",{className:"bg-background h-full p-4",children:a.jsx("iframe",{srcDoc:n,title:"Mermaid Diagram Preview",sandbox:"allow-scripts allow-same-origin allow-downloads",className:"h-96 w-full resize border-none",onError:()=>t("Failed to load Mermaid content."),onLoad:()=>t(null)})})};/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function Ef(e){return typeof e>"u"||e===null}function Gb(e){return typeof e=="object"&&e!==null}function Vb(e){return Array.isArray(e)?e:Ef(e)?[]:[e]}function Yb(e,t){var n,r,o,s;if(t)for(s=Object.keys(t),n=0,r=s.length;n<r;n+=1)o=s[n],e[o]=t[o];return e}function Kb(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function qb(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Xb=Ef,Zb=Gb,Jb=Vb,Qb=Kb,ey=qb,ty=Yb,Ke={isNothing:Xb,isObject:Zb,toArray:Jb,repeat:Qb,isNegativeZero:ey,extend:ty};function Tf(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
299
-
300
- `+e.mark.snippet),r+" "+n):r}function Fr(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Tf(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Fr.prototype=Object.create(Error.prototype);Fr.prototype.constructor=Fr;Fr.prototype.toString=function(t){return this.name+": "+Tf(this,t)};var at=Fr;function Rs(e,t,n,r,o){var s="",i="",l=Math.floor(o/2)-1;return r-t>l&&(s=" ... ",t=r-l+s.length),n-r>l&&(i=" ...",n=r+l-i.length),{str:s+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+s.length}}function Ps(e,t){return Ke.repeat(" ",t-e.length)+e}function ny(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],s,i=-1;s=n.exec(e.buffer);)o.push(s.index),r.push(s.index+s[0].length),e.position<=s.index&&i<0&&(i=r.length-2);i<0&&(i=r.length-1);var l="",c,d,f=Math.min(e.line+t.linesAfter,o.length).toString().length,p=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)d=Rs(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),p),l=Ke.repeat(" ",t.indent)+Ps((e.line-c+1).toString(),f)+" | "+d.str+`
301
- `+l;for(d=Rs(e.buffer,r[i],o[i],e.position,p),l+=Ke.repeat(" ",t.indent)+Ps((e.line+1).toString(),f)+" | "+d.str+`
302
- `,l+=Ke.repeat("-",t.indent+f+3+d.pos)+`^
303
- `,c=1;c<=t.linesAfter&&!(i+c>=o.length);c++)d=Rs(e.buffer,r[i+c],o[i+c],e.position-(r[i]-r[i+c]),p),l+=Ke.repeat(" ",t.indent)+Ps((e.line+c+1).toString(),f)+" | "+d.str+`
304
- `;return l.replace(/\n$/,"")}var ry=ny,oy=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],sy=["scalar","sequence","mapping"];function iy(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function ay(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(oy.indexOf(n)===-1)throw new at('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=iy(t.styleAliases||null),sy.indexOf(this.kind)===-1)throw new at('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Qe=ay;function gl(e,t){var n=[];return e[t].forEach(function(r){var o=n.length;n.forEach(function(s,i){s.tag===r.tag&&s.kind===r.kind&&s.multi===r.multi&&(o=i)}),n[o]=r}),n}function ly(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function ni(e){return this.extend(e)}ni.prototype.extend=function(t){var n=[],r=[];if(t instanceof Qe)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new at("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(s){if(!(s instanceof Qe))throw new at("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(s.loadKind&&s.loadKind!=="scalar")throw new at("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(s.multi)throw new at("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(s){if(!(s instanceof Qe))throw new at("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(ni.prototype);return o.implicit=(this.implicit||[]).concat(n),o.explicit=(this.explicit||[]).concat(r),o.compiledImplicit=gl(o,"implicit"),o.compiledExplicit=gl(o,"explicit"),o.compiledTypeMap=ly(o.compiledImplicit,o.compiledExplicit),o};var Af=ni,Nf=new Qe("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),kf=new Qe("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),_f=new Qe("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),If=new Af({explicit:[Nf,kf,_f]});function cy(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function uy(){return null}function dy(e){return e===null}var jf=new Qe("tag:yaml.org,2002:null",{kind:"scalar",resolve:cy,construct:uy,predicate:dy,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function fy(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function py(e){return e==="true"||e==="True"||e==="TRUE"}function my(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Mf=new Qe("tag:yaml.org,2002:bool",{kind:"scalar",resolve:fy,construct:py,predicate:my,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function hy(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function gy(e){return 48<=e&&e<=55}function xy(e){return 48<=e&&e<=57}function vy(e){if(e===null)return!1;var t=e.length,n=0,r=!1,o;if(!t)return!1;if(o=e[n],(o==="-"||o==="+")&&(o=e[++n]),o==="0"){if(n+1===t)return!0;if(o=e[++n],o==="b"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(o!=="0"&&o!=="1")return!1;r=!0}return r&&o!=="_"}if(o==="x"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!hy(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}if(o==="o"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!gy(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}}if(o==="_")return!1;for(;n<t;n++)if(o=e[n],o!=="_"){if(!xy(e.charCodeAt(n)))return!1;r=!0}return!(!r||o==="_")}function wy(e){var t=e,n=1,r;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),r=t[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),t=t.slice(1),r=t[0]),t==="0")return 0;if(r==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function by(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Ke.isNegativeZero(e)}var Rf=new Qe("tag:yaml.org,2002:int",{kind:"scalar",resolve:vy,construct:wy,predicate:by,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),yy=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Sy(e){return!(e===null||!yy.test(e)||e[e.length-1]==="_")}function Cy(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var Ey=/^[-+]?[0-9]+e/;function Ty(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Ke.isNegativeZero(e))return"-0.0";return n=e.toString(10),Ey.test(n)?n.replace("e",".e"):n}function Ay(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Ke.isNegativeZero(e))}var Pf=new Qe("tag:yaml.org,2002:float",{kind:"scalar",resolve:Sy,construct:Cy,predicate:Ay,represent:Ty,defaultStyle:"lowercase"}),Lf=If.extend({implicit:[jf,Mf,Rf,Pf]}),Df=Lf,Of=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ff=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Ny(e){return e===null?!1:Of.exec(e)!==null||Ff.exec(e)!==null}function ky(e){var t,n,r,o,s,i,l,c=0,d=null,f,p,m;if(t=Of.exec(e),t===null&&(t=Ff.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,o=+t[3],!t[4])return new Date(Date.UTC(n,r,o));if(s=+t[4],i=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(f=+t[10],p=+(t[11]||0),d=(f*60+p)*6e4,t[9]==="-"&&(d=-d)),m=new Date(Date.UTC(n,r,o,s,i,l,c)),d&&m.setTime(m.getTime()-d),m}function _y(e){return e.toISOString()}var zf=new Qe("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Ny,construct:ky,instanceOf:Date,represent:_y});function Iy(e){return e==="<<"||e===null}var $f=new Qe("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Iy}),Zi=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
305
- \r`;function jy(e){if(e===null)return!1;var t,n,r=0,o=e.length,s=Zi;for(n=0;n<o;n++)if(t=s.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function My(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,s=Zi,i=0,l=[];for(t=0;t<o;t++)t%4===0&&t&&(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)),i=i<<6|s.indexOf(r.charAt(t));return n=o%4*6,n===0?(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)):n===18?(l.push(i>>10&255),l.push(i>>2&255)):n===12&&l.push(i>>4&255),new Uint8Array(l)}function Ry(e){var t="",n=0,r,o,s=e.length,i=Zi;for(r=0;r<s;r++)r%3===0&&r&&(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]),n=(n<<8)+e[r];return o=s%3,o===0?(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]):o===2?(t+=i[n>>10&63],t+=i[n>>4&63],t+=i[n<<2&63],t+=i[64]):o===1&&(t+=i[n>>2&63],t+=i[n<<4&63],t+=i[64],t+=i[64]),t}function Py(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Bf=new Qe("tag:yaml.org,2002:binary",{kind:"scalar",resolve:jy,construct:My,predicate:Py,represent:Ry}),Ly=Object.prototype.hasOwnProperty,Dy=Object.prototype.toString;function Oy(e){if(e===null)return!0;var t=[],n,r,o,s,i,l=e;for(n=0,r=l.length;n<r;n+=1){if(o=l[n],i=!1,Dy.call(o)!=="[object Object]")return!1;for(s in o)if(Ly.call(o,s))if(!i)i=!0;else return!1;if(!i)return!1;if(t.indexOf(s)===-1)t.push(s);else return!1}return!0}function Fy(e){return e!==null?e:[]}var Uf=new Qe("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Oy,construct:Fy}),zy=Object.prototype.toString;function $y(e){if(e===null)return!0;var t,n,r,o,s,i=e;for(s=new Array(i.length),t=0,n=i.length;t<n;t+=1){if(r=i[t],zy.call(r)!=="[object Object]"||(o=Object.keys(r),o.length!==1))return!1;s[t]=[o[0],r[o[0]]]}return!0}function By(e){if(e===null)return[];var t,n,r,o,s,i=e;for(s=new Array(i.length),t=0,n=i.length;t<n;t+=1)r=i[t],o=Object.keys(r),s[t]=[o[0],r[o[0]]];return s}var Hf=new Qe("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:$y,construct:By}),Uy=Object.prototype.hasOwnProperty;function Hy(e){if(e===null)return!0;var t,n=e;for(t in n)if(Uy.call(n,t)&&n[t]!==null)return!1;return!0}function Wy(e){return e!==null?e:{}}var Wf=new Qe("tag:yaml.org,2002:set",{kind:"mapping",resolve:Hy,construct:Wy}),Ji=Df.extend({implicit:[zf,$f],explicit:[Bf,Uf,Hf,Wf]}),En=Object.prototype.hasOwnProperty,No=1,Gf=2,Vf=3,ko=4,Ls=1,Gy=2,xl=3,Vy=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Yy=/[\x85\u2028\u2029]/,Ky=/[,\[\]\{\}]/,Yf=/^(?:!|!!|![a-z\-]+!)$/i,Kf=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function vl(e){return Object.prototype.toString.call(e)}function en(e){return e===10||e===13}function Rn(e){return e===9||e===32}function pt(e){return e===9||e===32||e===10||e===13}function Qn(e){return e===44||e===91||e===93||e===123||e===125}function qy(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function Xy(e){return e===120?2:e===117?4:e===85?8:0}function Zy(e){return 48<=e&&e<=57?e-48:-1}function wl(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
306
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function Jy(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var qf=new Array(256),Xf=new Array(256);for(var qn=0;qn<256;qn++)qf[qn]=wl(qn)?1:0,Xf[qn]=wl(qn);function Qy(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Ji,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Zf(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=ry(n),new at(t,n)}function ce(e,t){throw Zf(e,t)}function _o(e,t){e.onWarning&&e.onWarning.call(null,Zf(e,t))}var bl={YAML:function(t,n,r){var o,s,i;t.version!==null&&ce(t,"duplication of %YAML directive"),r.length!==1&&ce(t,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),o===null&&ce(t,"ill-formed argument of the YAML directive"),s=parseInt(o[1],10),i=parseInt(o[2],10),s!==1&&ce(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&_o(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var o,s;r.length!==2&&ce(t,"TAG directive accepts exactly two arguments"),o=r[0],s=r[1],Yf.test(o)||ce(t,"ill-formed tag handle (first argument) of the TAG directive"),En.call(t.tagMap,o)&&ce(t,'there is a previously declared suffix for "'+o+'" tag handle'),Kf.test(s)||ce(t,"ill-formed tag prefix (second argument) of the TAG directive");try{s=decodeURIComponent(s)}catch{ce(t,"tag prefix is malformed: "+s)}t.tagMap[o]=s}};function bn(e,t,n,r){var o,s,i,l;if(t<n){if(l=e.input.slice(t,n),r)for(o=0,s=l.length;o<s;o+=1)i=l.charCodeAt(o),i===9||32<=i&&i<=1114111||ce(e,"expected valid JSON character");else Vy.test(l)&&ce(e,"the stream contains non-printable characters");e.result+=l}}function yl(e,t,n,r){var o,s,i,l;for(Ke.isObject(n)||ce(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(n),i=0,l=o.length;i<l;i+=1)s=o[i],En.call(t,s)||(t[s]=n[s],r[s]=!0)}function er(e,t,n,r,o,s,i,l,c){var d,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),d=0,f=o.length;d<f;d+=1)Array.isArray(o[d])&&ce(e,"nested arrays are not supported inside keys"),typeof o=="object"&&vl(o[d])==="[object Object]"&&(o[d]="[object Object]");if(typeof o=="object"&&vl(o)==="[object Object]"&&(o="[object Object]"),o=String(o),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(s))for(d=0,f=s.length;d<f;d+=1)yl(e,t,s[d],n);else yl(e,t,s,n);else!e.json&&!En.call(n,o)&&En.call(t,o)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,ce(e,"duplicated mapping key")),o==="__proto__"?Object.defineProperty(t,o,{configurable:!0,enumerable:!0,writable:!0,value:s}):t[o]=s,delete n[o];return t}function Qi(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):ce(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Ve(e,t,n){for(var r=0,o=e.input.charCodeAt(e.position);o!==0;){for(;Rn(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(t&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(en(o))for(Qi(e),o=e.input.charCodeAt(e.position),r++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&_o(e,"deficient indentation"),r}function is(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||pt(n)))}function ea(e,t){t===1?e.result+=" ":t>1&&(e.result+=Ke.repeat(`
307
- `,t-1))}function eS(e,t,n){var r,o,s,i,l,c,d,f,p=e.kind,m=e.result,g;if(g=e.input.charCodeAt(e.position),pt(g)||Qn(g)||g===35||g===38||g===42||g===33||g===124||g===62||g===39||g===34||g===37||g===64||g===96||(g===63||g===45)&&(o=e.input.charCodeAt(e.position+1),pt(o)||n&&Qn(o)))return!1;for(e.kind="scalar",e.result="",s=i=e.position,l=!1;g!==0;){if(g===58){if(o=e.input.charCodeAt(e.position+1),pt(o)||n&&Qn(o))break}else if(g===35){if(r=e.input.charCodeAt(e.position-1),pt(r))break}else{if(e.position===e.lineStart&&is(e)||n&&Qn(g))break;if(en(g))if(c=e.line,d=e.lineStart,f=e.lineIndent,Ve(e,!1,-1),e.lineIndent>=t){l=!0,g=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=d,e.lineIndent=f;break}}l&&(bn(e,s,i,!1),ea(e,e.line-c),s=i=e.position,l=!1),Rn(g)||(i=e.position+1),g=e.input.charCodeAt(++e.position)}return bn(e,s,i,!1),e.result?!0:(e.kind=p,e.result=m,!1)}function tS(e,t){var n,r,o;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=o=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(bn(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,o=e.position;else return!0;else en(n)?(bn(e,r,o,!0),ea(e,Ve(e,!1,t)),r=o=e.position):e.position===e.lineStart&&is(e)?ce(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);ce(e,"unexpected end of the stream within a single quoted scalar")}function nS(e,t){var n,r,o,s,i,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return bn(e,n,e.position,!0),e.position++,!0;if(l===92){if(bn(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),en(l))Ve(e,!1,t);else if(l<256&&qf[l])e.result+=Xf[l],e.position++;else if((i=Xy(l))>0){for(o=i,s=0;o>0;o--)l=e.input.charCodeAt(++e.position),(i=qy(l))>=0?s=(s<<4)+i:ce(e,"expected hexadecimal character");e.result+=Jy(s),e.position++}else ce(e,"unknown escape sequence");n=r=e.position}else en(l)?(bn(e,n,r,!0),ea(e,Ve(e,!1,t)),n=r=e.position):e.position===e.lineStart&&is(e)?ce(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}ce(e,"unexpected end of the stream within a double quoted scalar")}function rS(e,t){var n=!0,r,o,s,i=e.tag,l,c=e.anchor,d,f,p,m,g,x=Object.create(null),h,v,b,w;if(w=e.input.charCodeAt(e.position),w===91)f=93,g=!1,l=[];else if(w===123)f=125,g=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),w=e.input.charCodeAt(++e.position);w!==0;){if(Ve(e,!0,t),w=e.input.charCodeAt(e.position),w===f)return e.position++,e.tag=i,e.anchor=c,e.kind=g?"mapping":"sequence",e.result=l,!0;n?w===44&&ce(e,"expected the node content, but found ','"):ce(e,"missed comma between flow collection entries"),v=h=b=null,p=m=!1,w===63&&(d=e.input.charCodeAt(e.position+1),pt(d)&&(p=m=!0,e.position++,Ve(e,!0,t))),r=e.line,o=e.lineStart,s=e.position,cr(e,t,No,!1,!0),v=e.tag,h=e.result,Ve(e,!0,t),w=e.input.charCodeAt(e.position),(m||e.line===r)&&w===58&&(p=!0,w=e.input.charCodeAt(++e.position),Ve(e,!0,t),cr(e,t,No,!1,!0),b=e.result),g?er(e,l,x,v,h,b,r,o,s):p?l.push(er(e,null,x,v,h,b,r,o,s)):l.push(h),Ve(e,!0,t),w=e.input.charCodeAt(e.position),w===44?(n=!0,w=e.input.charCodeAt(++e.position)):n=!1}ce(e,"unexpected end of the stream within a flow collection")}function oS(e,t){var n,r,o=Ls,s=!1,i=!1,l=t,c=0,d=!1,f,p;if(p=e.input.charCodeAt(e.position),p===124)r=!1;else if(p===62)r=!0;else return!1;for(e.kind="scalar",e.result="";p!==0;)if(p=e.input.charCodeAt(++e.position),p===43||p===45)Ls===o?o=p===43?xl:Gy:ce(e,"repeat of a chomping mode identifier");else if((f=Zy(p))>=0)f===0?ce(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?ce(e,"repeat of an indentation width identifier"):(l=t+f-1,i=!0);else break;if(Rn(p)){do p=e.input.charCodeAt(++e.position);while(Rn(p));if(p===35)do p=e.input.charCodeAt(++e.position);while(!en(p)&&p!==0)}for(;p!==0;){for(Qi(e),e.lineIndent=0,p=e.input.charCodeAt(e.position);(!i||e.lineIndent<l)&&p===32;)e.lineIndent++,p=e.input.charCodeAt(++e.position);if(!i&&e.lineIndent>l&&(l=e.lineIndent),en(p)){c++;continue}if(e.lineIndent<l){o===xl?e.result+=Ke.repeat(`
308
- `,s?1+c:c):o===Ls&&s&&(e.result+=`
309
- `);break}for(r?Rn(p)?(d=!0,e.result+=Ke.repeat(`
310
- `,s?1+c:c)):d?(d=!1,e.result+=Ke.repeat(`
311
- `,c+1)):c===0?s&&(e.result+=" "):e.result+=Ke.repeat(`
312
- `,c):e.result+=Ke.repeat(`
313
- `,s?1+c:c),s=!0,i=!0,c=0,n=e.position;!en(p)&&p!==0;)p=e.input.charCodeAt(++e.position);bn(e,n,e.position,!1)}return!0}function Sl(e,t){var n,r=e.tag,o=e.anchor,s=[],i,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ce(e,"tab characters must not be used in indentation")),!(c!==45||(i=e.input.charCodeAt(e.position+1),!pt(i))));){if(l=!0,e.position++,Ve(e,!0,-1)&&e.lineIndent<=t){s.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,cr(e,t,Vf,!1,!0),s.push(e.result),Ve(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)ce(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=o,e.kind="sequence",e.result=s,!0):!1}function sS(e,t,n){var r,o,s,i,l,c,d=e.tag,f=e.anchor,p={},m=Object.create(null),g=null,x=null,h=null,v=!1,b=!1,w;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=p),w=e.input.charCodeAt(e.position);w!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ce(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),s=e.line,(w===63||w===58)&&pt(r))w===63?(v&&(er(e,p,m,g,x,null,i,l,c),g=x=h=null),b=!0,v=!0,o=!0):v?(v=!1,o=!0):ce(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,w=r;else{if(i=e.line,l=e.lineStart,c=e.position,!cr(e,n,Gf,!1,!0))break;if(e.line===s){for(w=e.input.charCodeAt(e.position);Rn(w);)w=e.input.charCodeAt(++e.position);if(w===58)w=e.input.charCodeAt(++e.position),pt(w)||ce(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(er(e,p,m,g,x,null,i,l,c),g=x=h=null),b=!0,v=!1,o=!1,g=e.tag,x=e.result;else if(b)ce(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(b)ce(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=f,!0}if((e.line===s||e.lineIndent>t)&&(v&&(i=e.line,l=e.lineStart,c=e.position),cr(e,t,ko,!0,o)&&(v?x=e.result:h=e.result),v||(er(e,p,m,g,x,h,i,l,c),g=x=h=null),Ve(e,!0,-1),w=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&w!==0)ce(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&er(e,p,m,g,x,null,i,l,c),b&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=p),b}function iS(e){var t,n=!1,r=!1,o,s,i;if(i=e.input.charCodeAt(e.position),i!==33)return!1;if(e.tag!==null&&ce(e,"duplication of a tag property"),i=e.input.charCodeAt(++e.position),i===60?(n=!0,i=e.input.charCodeAt(++e.position)):i===33?(r=!0,o="!!",i=e.input.charCodeAt(++e.position)):o="!",t=e.position,n){do i=e.input.charCodeAt(++e.position);while(i!==0&&i!==62);e.position<e.length?(s=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):ce(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!pt(i);)i===33&&(r?ce(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(t-1,e.position+1),Yf.test(o)||ce(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);s=e.input.slice(t,e.position),Ky.test(s)&&ce(e,"tag suffix cannot contain flow indicator characters")}s&&!Kf.test(s)&&ce(e,"tag name cannot contain such characters: "+s);try{s=decodeURIComponent(s)}catch{ce(e,"tag name is malformed: "+s)}return n?e.tag=s:En.call(e.tagMap,o)?e.tag=e.tagMap[o]+s:o==="!"?e.tag="!"+s:o==="!!"?e.tag="tag:yaml.org,2002:"+s:ce(e,'undeclared tag handle "'+o+'"'),!0}function aS(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&ce(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!pt(n)&&!Qn(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ce(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function lS(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!pt(r)&&!Qn(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&ce(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),En.call(e.anchorMap,n)||ce(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Ve(e,!0,-1),!0}function cr(e,t,n,r,o){var s,i,l,c=1,d=!1,f=!1,p,m,g,x,h,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,s=i=l=ko===n||Vf===n,r&&Ve(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;iS(e)||aS(e);)Ve(e,!0,-1)?(d=!0,l=s,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||o),(c===1||ko===n)&&(No===n||Gf===n?h=t:h=t+1,v=e.position-e.lineStart,c===1?l&&(Sl(e,v)||sS(e,v,h))||rS(e,h)?f=!0:(i&&oS(e,h)||tS(e,h)||nS(e,h)?f=!0:lS(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&ce(e,"alias node should not have any properties")):eS(e,h,No===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&Sl(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&ce(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),p=0,m=e.implicitTypes.length;p<m;p+=1)if(x=e.implicitTypes[p],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(En.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,g=e.typeMap.multi[e.kind||"fallback"],p=0,m=g.length;p<m;p+=1)if(e.tag.slice(0,g[p].tag.length)===g[p].tag){x=g[p];break}x||ce(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&ce(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):ce(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function cS(e){var t=e.position,n,r,o,s=!1,i;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(i=e.input.charCodeAt(e.position))!==0&&(Ve(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(s=!0,i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!pt(i);)i=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),o=[],r.length<1&&ce(e,"directive name must not be less than one character in length");i!==0;){for(;Rn(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!en(i));break}if(en(i))break;for(n=e.position;i!==0&&!pt(i);)i=e.input.charCodeAt(++e.position);o.push(e.input.slice(n,e.position))}i!==0&&Qi(e),En.call(bl,r)?bl[r](e,r,o):_o(e,'unknown document directive "'+r+'"')}if(Ve(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,Ve(e,!0,-1)):s&&ce(e,"directives end mark is expected"),cr(e,e.lineIndent-1,ko,!1,!0),Ve(e,!0,-1),e.checkLineBreaks&&Yy.test(e.input.slice(t,e.position))&&_o(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&is(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Ve(e,!0,-1));return}if(e.position<e.length-1)ce(e,"end of the stream or a document separator is expected");else return}function Jf(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
314
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new Qy(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,ce(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)cS(n);return n.documents}function uS(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=Jf(e,n);if(typeof t!="function")return r;for(var o=0,s=r.length;o<s;o+=1)t(r[o])}function dS(e,t){var n=Jf(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new at("expected a single document in the stream, but found more")}}var fS=uS,pS=dS,Qf={loadAll:fS,load:pS},ep=Object.prototype.toString,tp=Object.prototype.hasOwnProperty,ta=65279,mS=9,zr=10,hS=13,gS=32,xS=33,vS=34,ri=35,wS=37,bS=38,yS=39,SS=42,np=44,CS=45,Io=58,ES=61,TS=62,AS=63,NS=64,rp=91,op=93,kS=96,sp=123,_S=124,ip=125,ot={};ot[0]="\\0";ot[7]="\\a";ot[8]="\\b";ot[9]="\\t";ot[10]="\\n";ot[11]="\\v";ot[12]="\\f";ot[13]="\\r";ot[27]="\\e";ot[34]='\\"';ot[92]="\\\\";ot[133]="\\N";ot[160]="\\_";ot[8232]="\\L";ot[8233]="\\P";var IS=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],jS=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function MS(e,t){var n,r,o,s,i,l,c;if(t===null)return{};for(n={},r=Object.keys(t),o=0,s=r.length;o<s;o+=1)i=r[o],l=String(t[i]),i.slice(0,2)==="!!"&&(i="tag:yaml.org,2002:"+i.slice(2)),c=e.compiledTypeMap.fallback[i],c&&tp.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function RS(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new at("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Ke.repeat("0",r-t.length)+t}var PS=1,$r=2;function LS(e){this.schema=e.schema||Ji,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Ke.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=MS(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?$r:PS,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Cl(e,t){for(var n=Ke.repeat(" ",t),r=0,o=-1,s="",i,l=e.length;r<l;)o=e.indexOf(`
315
- `,r),o===-1?(i=e.slice(r),r=l):(i=e.slice(r,o+1),r=o+1),i.length&&i!==`
316
- `&&(s+=n),s+=i;return s}function oi(e,t){return`
317
- `+Ke.repeat(" ",e.indent*t)}function DS(e,t){var n,r,o;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(o=e.implicitTypes[n],o.resolve(t))return!0;return!1}function jo(e){return e===gS||e===mS}function Br(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==ta||65536<=e&&e<=1114111}function El(e){return Br(e)&&e!==ta&&e!==hS&&e!==zr}function Tl(e,t,n){var r=El(e),o=r&&!jo(e);return(n?r:r&&e!==np&&e!==rp&&e!==op&&e!==sp&&e!==ip)&&e!==ri&&!(t===Io&&!o)||El(t)&&!jo(t)&&e===ri||t===Io&&o}function OS(e){return Br(e)&&e!==ta&&!jo(e)&&e!==CS&&e!==AS&&e!==Io&&e!==np&&e!==rp&&e!==op&&e!==sp&&e!==ip&&e!==ri&&e!==bS&&e!==SS&&e!==xS&&e!==_S&&e!==ES&&e!==TS&&e!==yS&&e!==vS&&e!==wS&&e!==NS&&e!==kS}function FS(e){return!jo(e)&&e!==Io}function Mr(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function ap(e){var t=/^\n* /;return t.test(e)}var lp=1,si=2,cp=3,up=4,Zn=5;function zS(e,t,n,r,o,s,i,l){var c,d=0,f=null,p=!1,m=!1,g=r!==-1,x=-1,h=OS(Mr(e,0))&&FS(Mr(e,e.length-1));if(t||i)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Mr(e,c),!Br(d))return Zn;h=h&&Tl(d,f,l),f=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Mr(e,c),d===zr)p=!0,g&&(m=m||c-x-1>r&&e[x+1]!==" ",x=c);else if(!Br(d))return Zn;h=h&&Tl(d,f,l),f=d}m=m||g&&c-x-1>r&&e[x+1]!==" "}return!p&&!m?h&&!i&&!o(e)?lp:s===$r?Zn:si:n>9&&ap(e)?Zn:i?s===$r?Zn:si:m?up:cp}function $S(e,t,n,r,o){e.dump=(function(){if(t.length===0)return e.quotingType===$r?'""':"''";if(!e.noCompatMode&&(IS.indexOf(t)!==-1||jS.test(t)))return e.quotingType===$r?'"'+t+'"':"'"+t+"'";var s=e.indent*Math.max(1,n),i=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return DS(e,d)}switch(zS(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,o)){case lp:return t;case si:return"'"+t.replace(/'/g,"''")+"'";case cp:return"|"+Al(t,e.indent)+Nl(Cl(t,s));case up:return">"+Al(t,e.indent)+Nl(Cl(BS(t,i),s));case Zn:return'"'+US(t)+'"';default:throw new at("impossible error: invalid scalar style")}})()}function Al(e,t){var n=ap(e)?String(t):"",r=e[e.length-1]===`
318
- `,o=r&&(e[e.length-2]===`
319
- `||e===`
320
- `),s=o?"+":r?"":"-";return n+s+`
321
- `}function Nl(e){return e[e.length-1]===`
322
- `?e.slice(0,-1):e}function BS(e,t){for(var n=/(\n+)([^\n]*)/g,r=(function(){var d=e.indexOf(`
323
- `);return d=d!==-1?d:e.length,n.lastIndex=d,kl(e.slice(0,d),t)})(),o=e[0]===`
324
- `||e[0]===" ",s,i;i=n.exec(e);){var l=i[1],c=i[2];s=c[0]===" ",r+=l+(!o&&!s&&c!==""?`
325
- `:"")+kl(c,t),o=s}return r}function kl(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,o=0,s,i=0,l=0,c="";r=n.exec(e);)l=r.index,l-o>t&&(s=i>o?i:l,c+=`
326
- `+e.slice(o,s),o=s+1),i=l;return c+=`
327
- `,e.length-o>t&&i>o?c+=e.slice(o,i)+`
328
- `+e.slice(i+1):c+=e.slice(o),c.slice(1)}function US(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Mr(e,o),r=ot[n],!r&&Br(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||RS(n);return t}function HS(e,t,n){var r="",o=e.tag,s,i,l;for(s=0,i=n.length;s<i;s+=1)l=n[s],e.replacer&&(l=e.replacer.call(n,String(s),l)),(pn(e,t,l,!1,!1)||typeof l>"u"&&pn(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function _l(e,t,n,r){var o="",s=e.tag,i,l,c;for(i=0,l=n.length;i<l;i+=1)c=n[i],e.replacer&&(c=e.replacer.call(n,String(i),c)),(pn(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&pn(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=oi(e,t)),e.dump&&zr===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=s,e.dump=o||"[]"}function WS(e,t,n){var r="",o=e.tag,s=Object.keys(n),i,l,c,d,f;for(i=0,l=s.length;i<l;i+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=s[i],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),pn(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),pn(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function GS(e,t,n,r){var o="",s=e.tag,i=Object.keys(n),l,c,d,f,p,m;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new at("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)m="",(!r||o!=="")&&(m+=oi(e,t)),d=i[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),pn(e,t+1,d,!0,!0,!0)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&zr===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,p&&(m+=oi(e,t)),pn(e,t+1,f,!0,p)&&(e.dump&&zr===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=s,e.dump=o||"{}"}function Il(e,t,n){var r,o,s,i,l,c;for(o=n?e.explicitTypes:e.implicitTypes,s=0,i=o.length;s<i;s+=1)if(l=o[s],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,ep.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(tp.call(l.represent,c))r=l.represent[c](t,c);else throw new at("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function pn(e,t,n,r,o,s,i){e.tag=null,e.dump=n,Il(e,n,!1)||Il(e,n,!0);var l=ep.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",p,m;if(f&&(p=e.duplicates.indexOf(n),m=p!==-1),(e.tag!==null&&e.tag!=="?"||m||e.indent!==2&&t>0)&&(o=!1),m&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(f&&m&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(GS(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(WS(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?_l(e,t-1,e.dump,o):_l(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(HS(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&$S(e,e.dump,t,s,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new at("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function VS(e,t){var n=[],r=[],o,s;for(ii(e,n,r),o=0,s=r.length;o<s;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(s)}function ii(e,t,n){var r,o,s;if(e!==null&&typeof e=="object")if(o=t.indexOf(e),o!==-1)n.indexOf(o)===-1&&n.push(o);else if(t.push(e),Array.isArray(e))for(o=0,s=e.length;o<s;o+=1)ii(e[o],t,n);else for(r=Object.keys(e),o=0,s=r.length;o<s;o+=1)ii(e[r[o]],t,n)}function YS(e,t){t=t||{};var n=new LS(t);n.noRefs||VS(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),pn(n,0,r,!0,!0)?n.dump+`
329
- `:""}var KS=YS,qS={dump:KS};function na(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var XS=Qe,ZS=Af,JS=If,QS=Lf,eC=Df,tC=Ji,nC=Qf.load,rC=Qf.loadAll,oC=qS.dump,sC=at,iC={binary:Bf,float:Pf,map:_f,null:jf,pairs:Hf,set:Wf,timestamp:zf,bool:Mf,int:Rf,merge:$f,omap:Uf,seq:kf,str:Nf},aC=na("safeLoad","load"),lC=na("safeLoadAll","loadAll"),cC=na("safeDump","dump"),uC={Type:XS,Schema:ZS,FAILSAFE_SCHEMA:JS,JSON_SCHEMA:QS,CORE_SCHEMA:eC,DEFAULT_SCHEMA:tC,load:nC,loadAll:rC,dump:oC,YAMLException:sC,types:iC,safeLoad:aC,safeLoadAll:lC,safeDump:cC};const dC=({content:e,rendererType:t,setRenderError:n})=>{const[r,o]=u.useState(!1);u.useEffect(()=>{n(null)},[e,n]);const[s,i]=u.useMemo(()=>{try{if(t==="yaml"){const l=uC.load(e);return[e,l]}else if(t==="json"){const l=JSON.parse(e);return[JSON.stringify(l,null,2),l]}throw new Error(`Unsupported renderer type: ${t}`)}catch(l){const c=t==="yaml"?"YAML":"JSON";console.error(`Error parsing ${c} for panel:`,l);const d={[`${c}_Parsing_Error`]:`The provided content is not valid ${c}.`,Details:l.message,Content_Snippet:e.substring(0,500)+(e.length>500?"...":"")};return n(`${c} parsing failed: ${l.message}`),[e,d]}},[e,t,n]);return a.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(be,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Ul,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(Hl,{})," Raw Text"]})})}),a.jsx("div",{className:"flex min-h-0 flex-col",children:a.jsx("div",{className:"flex-1 overflow-auto",children:r?a.jsx(dp,{content:s,setRenderError:n}):a.jsx(fi,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},dp=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=xf();return a.jsx("div",{className:`overflow-auto p-4 ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},fp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(wb,{content:e,setRenderError:r});case"mermaid":return a.jsx(Wb,{content:e,setRenderError:r});case"html":return a.jsx(bb,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(dC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(yb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(Sb,{content:e,setRenderError:r});case"audio":return a.jsx(xb,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(dp,{content:e,setRenderError:r})}},fC={"application/pdf":"pdf","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/x-markdown":"md","application/json":"json","application/yaml":"yaml","text/yaml":"yaml","application/xml":"xml","text/xml":"xml","image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff","audio/mpeg":"mp3","audio/wav":"wav","audio/ogg":"ogg","audio/aac":"aac","audio/flac":"flac","audio/x-m4a":"m4a","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","application/javascript":"js","application/gzip":"gz","application/x-tar":"tar","application/rtf":"rtf"};function pC(e,t){const n=fC[e]||"bin";return`embedded_file_${t+1}.${n}`}function mC(e){if(!e||typeof e!="string")return[];const t=[],n=/data:([a-zA-Z0-9/.-]+);base64,([A-Za-z0-9+/=]+)/g;let r,o=0;for(;(r=n.exec(e))!==null;){const[s,i,l]=r,c=e[r.index-1],d=e[r.index+s.length];if(!(c==='"'&&d==='"'||c==="'"&&d==="'")&&l&&l.length>10){const f=qr(void 0,i);f?t.push({type:f,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:pC(i,o++)})}}return t}function hC(e){if(!e||typeof e!="string")return[];const t=[],n=/<html[\s\S]*?<\/html>/gi;let r;for(;(r=n.exec(e))!==null;)t.push({type:"html",content:r[0].trim(),originalMatch:r[0]});return t}function gC(e){if(!e||typeof e!="string")return[];const t=[],n=/```mermaid\s*\n([\s\S]*?)```/gi;let r;for(;(r=n.exec(e))!==null;){const[o,s]=r;t.push({type:"mermaid",content:s.trim(),originalMatch:o})}return t}function xC(e){return!e||typeof e!="string"?[]:[...mC(e),...hC(e),...gC(e)]}const vC=["image","audio"],wC=({message:e})=>{var d;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(d=e.parts)==null?void 0:d.filter(f=>f.kind==="text"),o=(r==null?void 0:r.map(f=>f.text).join(""))||"";if(e.isUser)return a.jsx("span",{children:o});const s=o.trim();if(!s)return null;if(e.isError)return a.jsxs("div",{className:"flex items-center",children:[a.jsx(gi,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(or,{children:s})]});const i=xC(s);if(i.length===0)return a.jsx(or,{children:s});let l=s;const c=[];return i.forEach((f,p)=>{if(l=l.replace(f.originalMatch,""),f.type==="file"){const m={name:f.filename||"downloaded_file",content:f.content,mime_type:f.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(hf,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!vC.includes(f.type)){const m=df(f.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:a.jsx(fp,{content:m,rendererType:f.type,mime_type:f.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(or,{children:l}),c]})},pp=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),bC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(pp,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(gf,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,yC=e=>e.files&&e.files.length>0?a.jsx(pp,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(hf,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,SC=(e,t,n)=>{var d,f;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(d=e.parts)==null?void 0:d.some(p=>p.kind==="text"&&p.text.trim());if(!s&&!e.artifactNotification)return null;const i=e.isUser?"sent":"received",l=!e.isUser&&e.isComplete&&!!e.taskId&&n,c=()=>{e.taskId&&(o(e.taskId),r("workflow"))};return a.jsx(sf,{variant:i,children:a.jsxs(af,{variant:i,children:[s&&a.jsx(wC,{message:e}),e.artifactNotification&&a.jsxs("div",{className:"my-1 flex items-center rounded-md bg-blue-100 p-2 dark:bg-blue-900/50",children:[a.jsx(sr,{className:"mr-2 text-blue-500 dark:text-blue-400"}),a.jsxs("span",{className:"text-sm",children:["Artifact created: ",a.jsx("strong",{children:e.artifactNotification.name}),e.artifactNotification.version&&` (v${e.artifactNotification.version})`]})]}),l&&a.jsx("div",{className:"mt-3",children:a.jsx(qc,{onClick:c})})]})},(f=e.metadata)==null?void 0:f.messageId)},CC=({message:e,isLastWithTaskId:t})=>{const n=He();return e?a.jsxs(a.Fragment,{children:[SC(e,n,t),bC(e),yC(e)]}):null},EC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=He(),{configServerUrl:r}=rn(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[d,f]=u.useState(""),p=u.useCallback(async()=>{const w=`${r}/api/v1/sessions`;try{const y=await ze(w);if(y.ok){const E=await y.json();i(E.sessions||[])}else console.error(`Failed to fetch sessions: ${y.status} ${y.statusText}`)}catch(y){console.error("An error occurred while fetching sessions:",y)}},[r]);u.useEffect(()=>{p();const w=()=>{p()},y=E=>{const{sessionId:A}=E.detail;i(I=>{const k=I.find(T=>T.id===A);if(k){const T=I.filter(Y=>Y.id!==A);return[k,...T]}return I})};return window.addEventListener("new-chat-session",w),window.addEventListener("session-updated",y),()=>{window.removeEventListener("new-chat-session",w),window.removeEventListener("session-updated",y)}},[p]),u.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const m=async w=>{l!==w&&await e(w)},g=w=>{c(w.id),f(w.name||"")},x=async()=>{l&&(await t(l,d),c(null),p())},h=w=>{n(w)},v=w=>rh(w),b=w=>{if(w.name&&w.name.trim())return w.name;const y=w.id;return y.startsWith("web-session-")?`Chat ${y.replace("web-session-","").substring(0,8)}`:`Session ${y.substring(0,8)}`};return a.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.length>0&&a.jsx("ul",{children:s.map(w=>a.jsx("li",{className:"group my-2 pr-4",children:a.jsxs("div",{className:"flex items-center justify-between rounded px-4 py-2 hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===w.id?a.jsx("input",{ref:o,type:"text",value:d,onChange:y=>f(y.target.value),onKeyDown:y=>y.key==="Enter"&&x(),onBlur:x,className:"flex-grow bg-transparent focus:outline-none"}):a.jsx("button",{onClick:()=>m(w.id),className:"flex-grow text-left",children:a.jsxs("div",{className:"flex max-w-50 flex-col",children:[a.jsx("span",{className:"truncate font-semibold",title:b(w),children:b(w)}),a.jsx("span",{className:"text-muted-foreground text-xs",children:v(w.updatedTime)})]})}),a.jsx("div",{className:"flex items-center opacity-0 transition-opacity group-hover:opacity-100",children:l===w.id?a.jsxs(a.Fragment,{children:[a.jsx(be,{variant:"ghost",onClick:x,children:a.jsx(mi,{size:16})}),a.jsx(be,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Ro,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(be,{variant:"ghost",onClick:()=>g(w),children:a.jsx(Fp,{size:16})}),a.jsx(be,{variant:"ghost",onClick:()=>h(w),children:a.jsx(zp,{size:16})})]})})]})},w.id))}),s.length===0&&a.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[a.jsx(Wl,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]})]})]})},TC=()=>{const{persistenceEnabled:e}=rn(),{sessionName:t}=He();return e===!1?a.jsx("div",{className:"flex h-full flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[a.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[a.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t||"New Chat"}),a.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),a.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Multi-session support coming soon"})]})}):a.jsx(EC,{})},AC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=He(),d=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),a.jsx("div",{className:"truncate text-xs",title:Ea(e.last_modified),children:Ea(e.last_modified)})]}),t&&d.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(Od,{value:l==null?void 0:l.toString(),onValueChange:f=>{c(e.filename,parseInt(f))},children:[a.jsx(zd,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(Fd,{placeholder:"Version"})}),a.jsx($d,{children:d.map(f=>a.jsxs(Bd,{value:f.toString(),children:["Version ",f]},f))})]})})]}),a.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[s&&a.jsx(be,{variant:"ghost",size:"sm",onClick:f=>{f.stopPropagation(),f.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(vi,{})}),o&&a.jsx(be,{variant:"ghost",size:"sm",onClick:async f=>{f.stopPropagation(),f.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(xi,{})}),r&&a.jsx(be,{variant:"ghost",size:"sm",onClick:f=>{f.preventDefault(),f.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(Gl,{})})]})]})},jl=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=He(),{onDownload:o}=qu(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=d=>{if(!d||typeof d=="object"&&Object.keys(d).length===0)return a.jsx("span",{children:"Not available"});const f=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&f(p[0],m+1),p.length>1&&a.jsx("span",{children:", ..."}),"]"]}):typeof p=="object"&&p!==null?a.jsx("div",{className:`ml-${m*2} border-l pl-2`,children:Object.entries(p).map(([g,x],h)=>a.jsxs("div",{className:"text-xs",children:[a.jsxs("span",{className:"font-semibold",children:[g,":"]})," ",f(x,m+1)]},h))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof d=="object"&&d.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",d.type," ",d.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof d=="object"&&d.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",d.columns.join(", ")]}),typeof d=="object"&&d.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),f(d.structure)]}),typeof d=="object"&&d.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",d.error]}),typeof d=="string"&&a.jsx("p",{children:d})]})};return a.jsx("div",{className:`group relative w-full border-b px-4 py-3 transition-all duration-150 ${t?"":"cursor-pointer hover:bg-[var(--accent-background)]"}`,onClick:d=>{d.stopPropagation(),r(e)},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),r(e))},tabIndex:0,role:"button","aria-expanded":s,children:a.jsxs("div",{className:"flex items-start space-x-2",children:[a.jsx("div",{className:"flex-shrink-0 pt-0.5",children:mf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(AC,{artifactInfo:e,isExpanded:s,onDelete:l,onDownload:o,setIsExpanded:i,isPreview:t}),s&&a.jsxs("div",{className:"text-xs",children:[a.jsx("div",{className:"mt-1 text-xs break-words whitespace-pre-wrap italic",children:e.description||"No description."}),a.jsxs("div",{className:"mt-2 space-y-1 pt-2",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Size: "}),pc(e.size)]}),e.uri&&a.jsxs("div",{children:[a.jsx("strong",{children:"URI: "}),a.jsx("span",{className:"break-all",children:e.uri||"None"})]}),e.schema&&a.jsx("div",{children:c(e.schema)})]})]})]})]})})},NC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=He();return!e||!t?null:a.jsx(Go,{open:e,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsxs(Ko,{className:"flex max-w-[400px] flex-row gap-1",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(qo,{className:"flex flex-col gap-2",children:a.jsx("div",{children:"This file will be permanently deleted. "})})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(be,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(be,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},kC={replace:e=>{e instanceof Up.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function or({children:e,className:t}){if(!e)return null;try{const n=$p.parse(e,{gfm:!0}),r=Cf.sanitize(n,{USE_PROFILES:{html:!0}}),o=Bp(r,kC);return a.jsx("div",{className:Ta(t),children:o})}catch{return a.jsx("div",{className:Ta(t),children:e})}}const _C=Tn("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:{error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-w10)]"}},defaultVariants:{variant:"error"}}),IC={error:gi,warning:Hp,info:vi,success:Vl};function ra({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=IC[t||"error"];return a.jsxs("div",{className:Ee(_C({variant:t,className:e})),role:"alert","aria-live":"polite",...s,children:[a.jsx(i,{className:"size-5 shrink-0"}),a.jsx("span",{className:"flex-1",children:n}),r&&o&&a.jsx(be,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Ro,{className:"size-3"})})]})}const jC=({artifact:e,message:t})=>{const{onDownload:n}=qu();return a.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[a.jsx("div",{className:"mb-1 font-semibold",children:"Preview Coming Soon"}),a.jsx("div",{children:t}),a.jsx("div",{className:"mb-4",children:"Download file to view."}),a.jsxs(be,{onClick:()=>n(e),children:[a.jsx(xi,{className:"h-4 w-4"}),"Download"]})]})},Ds=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),MC=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=He(),r=u.useMemo(()=>gb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function f(){try{s(!0),l(null),await t(e.filename)}catch(p){console.error("Error fetching artifact content:",p),l(p instanceof Error?p.message:"Failed to load artifact content")}finally{s(!1)}}r!=null&&r.canPreview&&f()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(ra,{variant:"error",message:"Error rendering preview"}),a.jsx(Ds,{children:"No preview available"})]});if(o)return a.jsx(Ds,{children:a.jsx(hi,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(jC,{artifact:e,message:r.reason??""});const c=qr(e.filename,e.mime_type),d=mb(n);return!c||!d?a.jsx(Ds,{children:"No preview available"}):a.jsx(fp,{content:d,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},Zt={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},RC=e=>{switch(e){case Zt.NameAsc:return"Name (A-Z)";case Zt.NameDesc:return"Name (Z-A)";case Zt.DateAsc:return"Date (oldest first)";case Zt.DateDesc:return"Date (newest first)"}},PC=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(Zt).map(o=>({id:o,label:RC(o),onClick:()=>t(o),icon:e===o?a.jsx(mi,{}):void 0,iconPosition:"right"}));return a.jsxs(ld,{children:[a.jsx(cd,{asChild:!0,children:n}),a.jsx(ud,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},LC=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=He(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(Yl,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(Gl,{}),iconPosition:"left",divider:!0}];return a.jsxs(ld,{children:[a.jsx(cd,{asChild:!0,children:e}),a.jsx(ud,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(Yi,{actions:r})})]})},DC=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=He();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Go,{open:t,onOpenChange:n,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{children:"Delete All?"}),a.jsxs(qo,{children:[e.length===1?"One file":`All ${e.length} files`," will be permanently deleted."]})]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx(be,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(be,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},OC={[Zt.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[Zt.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[Zt.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[Zt.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},FC=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=He(),[o,s]=u.useState(Zt.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(OC[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(be,{variant:"ghost",onClick:()=>r(null),children:a.jsx(Wp,{})}),a.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):i.length>0&&a.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[a.jsx(PC,{currentSortOption:o,onSortChange:s,children:a.jsxs(be,{variant:"ghost",title:"Sort By",children:[a.jsx($l,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(LC,{children:a.jsx(be,{variant:"ghost",tooltip:"More",children:a.jsx(Gp,{className:"h-5 w-5"})})},"more-popover")]}),[n,i.length,o,r]);return a.jsxs("div",{className:"flex h-full flex-col",children:[l,a.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(c=>a.jsx(jl,{artifact:c},c.filename)),i.length===0&&a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&a.jsx(hi,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(sr,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Files"}),a.jsx("div",{className:"mt-2 text-sm",children:"No files available"})]})]})})]}),n&&a.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[a.jsx(jl,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:a.jsx(MC,{artifact:n})})]})]}),a.jsx(NC,{}),a.jsx(DC,{})]})},zC=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=He(),{isReconnecting:c,isTaskMonitorConnecting:d,isTaskMonitorConnected:f,monitoredTasks:p,connectTaskMonitorStream:m}=Gi(),[g,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const y=p[l],E=bE(y.events||[],p,y);x(E)}else x(null)},[l,p]);const h=()=>c||d?{message:"Connecting to task monitor ...",showButton:!1}:f?l?g?null:{message:"No workflow data available for the selected task",showButton:!1}:{message:"No task selected to display",showButton:!1}:{message:"No connection to task monitor",showButton:!0,buttonText:"Reconnect",buttonIcon:Vp,buttonAction:m},v=()=>{const y=!t;n(y),e(y)},b=y=>{y==="files"&&i(null),s(y)},w=y=>{t&&(n(!1),e==null||e(!1)),b(y)};return t?a.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[a.jsx(be,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(da,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(be,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(sr,{className:"size-5"})}),a.jsx(be,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(po,{className:"size-5"})})]}):a.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:a.jsx("div",{className:"m-1 min-h-0 flex-1",children:a.jsxs($0,{value:o,onValueChange:y=>b(y),className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex gap-2 p-2",children:[a.jsx(be,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(da,{className:"size-5"})}),a.jsxs(B0,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(sl,{value:"files",title:"Files",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-l-md border border-r-0 data-[state=active]:z-10 data-[state=active]:border-r-0",children:[a.jsx(sr,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(sl,{value:"workflow",title:"Workflow",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-r-md border border-l-0 data-[state=active]:z-10 data-[state=active]:border-l-0",children:[a.jsx(po,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(il,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(FC,{})})}),a.jsx(il,{value:"workflow",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:(()=>{const y=h();return!y&&g?a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx(UC,{task:g}),a.jsx(wE,{processedSteps:g.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[a.jsx(po,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),a.jsx("div",{className:"mt-2 text-sm",children:y==null?void 0:y.message}),(y==null?void 0:y.showButton)&&a.jsx("div",{className:"mt-4",children:a.jsxs(be,{onClick:y.buttonAction,children:[y.buttonIcon&&(()=>{const E=y.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),y.buttonText]})})]})})})()})})]})]})})})},ai=({statusText:e,onViewWorkflow:t})=>a.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?a.jsx(qc,{onClick:t}):a.jsx(K0,{className:"mr-3 ml-2"}),a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&a.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]}),mp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=He(),{persistenceEnabled:r}=rn();return a.jsx(Go,{open:e,onOpenChange:t,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{className:"flex max-w-[400px] flex-row gap-1",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(qo,{className:"flex flex-col gap-2",children:r===!1?"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?":"This will create a new chat session. Your current chat will be saved in the sessions panel."})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(be,{variant:"outline",onClick:t,children:"Cancel"}),a.jsx(be,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},$C=({onToggle:e})=>{const[t,n]=u.useState(!1);return a.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 pt-[35px] pb-3",children:[a.jsx(be,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(Kl,{className:"size-5"})}),a.jsxs(be,{variant:"ghost",onClick:()=>n(!0),tooltip:"Start New Chat Session",children:[a.jsx(ql,{className:"size-5"}),"New chat"]})]}),a.jsx("div",{className:"mt-1 min-h-0 flex-1",children:a.jsx(TC,{})}),a.jsx(mp,{isOpen:t,onClose:()=>n(!1)})]})},Nr=(e,t)=>a.jsx(uf,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),BC=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(ai,{statusText:e.currentStatusText})});const n=(r=t==null?void 0:t.parts)==null?void 0:r.filter(o=>o.kind==="text").map(o=>o.text).join("");switch(e.status){case"submitted":case"working":return a.jsx("div",{title:n||e.status,children:a.jsx(ai,{statusText:n||e.status})});case"input-required":return Nr("Input Required","info");case"completed":return Nr("Completed","success");case"canceled":return Nr("Canceled","info");case"failed":return Nr("Failed","error");default:return Nr("Unknown","info")}},UC=({task:e})=>{const{messages:t}=He(),n=u.useMemo(()=>{const r=t.find(o=>o.isStatusBubble);return e?BC(e,r):null},[t,e]);return e?a.jsxs("div",{className:"grid grid-cols-[auto_1fr] grid-rows-[32px_32px] gap-x-8 border-b p-4 leading-[32px]",children:[a.jsx("div",{className:"text-muted-foreground",children:"User"}),a.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),a.jsx("div",{className:"text-muted-foreground",children:"Status"}),a.jsx("div",{className:"truncate",children:n})]}):null};class hp{getEdgeAnimationState(t,n,r){const o=r.find(l=>l.id===t);if(!o)return{isAnimated:!1,animationType:"static"};if(!this.isAgentToToolRequest(o))return{isAnimated:!1,animationType:"static"};const s=r.slice(0,n+1);return this.hasMatchingResponse(o,s)?{isAnimated:!1,animationType:"static"}:{isAnimated:!0,animationType:"request"}}isAgentToToolRequest(t){var n,r;switch(t.type){case"AGENT_LLM_CALL":return!0;case"AGENT_TOOL_INVOCATION_START":return!(((n=t.data.toolDecision)==null?void 0:n.isPeerDelegation)||((r=t.data.toolInvocationStart)==null?void 0:r.isPeerInvocation)||t.target&&t.target.startsWith("peer_"));default:return!1}}hasMatchingResponse(t,n){switch(t.type){case"AGENT_LLM_CALL":return this.hasLLMResponse(t,n);case"AGENT_TOOL_INVOCATION_START":return this.hasToolResponse(t,n);default:return!1}}hasLLMResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.source;return n.some(s=>{var f;if(new Date(s.timestamp).getTime()<r)return!1;const l=(s.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||s.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&s.target===o,c=s.source===o&&(s.type==="AGENT_TOOL_INVOCATION_START"||s.type==="TASK_COMPLETED"),d=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((f=s.data.toolResult)==null?void 0:f.isPeerResponse);return l||c||d})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.target,s=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===o&&i.target===s)}isRequestStep(t){return this.isAgentToToolRequest(t)}isResponseStep(t){return["AGENT_TOOL_EXECUTION_RESULT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_LLM_RESPONSE_TO_AGENT"].includes(t.type)}}const un={USER:50,MAIN_FLOW:300,TOOLS:600},HC=50,qe=50,kt=330,Bn=50,Kt=20,ur=10,Ml=qe+20,WC=90;function Un(e,t,n){return e.push(n),t.add(n.id),n}function GC(e,t){return e.push(t),t}function Hn(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function ut(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function Xr(e){const t=ut(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function VC(e,t,n){var r;for(let o=e.length-1;o>=0;o--){const s=e[o],i=n.find(l=>l.id===s.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return s}return null}function YC(e,t){if(!t)return null;const n=ut(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function KC(e,t){if(!t)return null;const n=ut(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function as(e,t){var o;const n=ut(e);if(!n)return null;if(t.functionCallId){const s=YC(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=KC(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=Xr(e);if(r&&t.source){const s=t.source.replace(/[^a-zA-Z0-9_]/g,"_"),i=(o=t.target)==null?void 0:o.replace(/[^a-zA-Z0-9_]/g,"_"),l=r.peerAgent.id;if(l.includes(s)||i&&l.includes(i))return r}return r||null}function gp(e,t){var r,o,s;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(s=(o=e.data)==null?void 0:o.toolInvocationStart)==null?void 0:s.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function xp(e,t,n,r){var o;if(r)for(let s=e.length-1;s>=0;s--){const i=e[s];if(i.functionCallId===r){const l=n.find(c=>c.id===i.id);if(((o=l==null?void 0:l.data)==null?void 0:o.toolName)===t||t==="LLM")return i}}return VC(e,t,n)}function qC(e,t,n){const r=ut(e);if(!r)return null;const o=t.replace(/[^a-zA-Z0-9_]/g,"_"),s=n==null?void 0:n.replace(/[^a-zA-Z0-9_]/g,"_");let i=null;for(const l of r.subflows)if(l.peerAgent.id.includes(o)||s&&l.peerAgent.id.includes(s)){i=l;break}if(!i)return null;if(i.isParallel)return i;if(i.parentSubflowId){const l=r.subflows.find(c=>c.id===i.parentSubflowId);if(l&&l.isParallel)return l;if(l)return vp(r,l)}return null}function vp(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return vp(e,n)}return null}function dr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Hn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l={id:s,type:"orchestratorNode",position:{x:un.MAIN_FLOW,y:i},data:{label:t,visualizerStepId:n.id}};Un(r,e.allCreatedNodeIds,l),e.nodePositions.set(s,l.position);const c={id:s,yPosition:i,height:qe,width:kt},d={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:c};e.agentRegistry.registerAgent(d);const f={id:o,orchestratorAgent:c,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+qe};return e.phases.push(f),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=f.maxY+Bn,f}function li(e,t,n,r,o){var Y,X,W,q,ee;const s=ut(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((Y=n.data.toolResult)==null?void 0:Y.isPeerResponse)===!0,l=n.source||"",c=n.target||"",d=fr(l);!i&&!d&&!o&&e.indentationLevel++;const f=((W=(X=n.delegationInfo)==null?void 0:X[0])==null?void 0:W.subTaskId)||n.owningTaskId,p=Hn(e,`${t}_${f}`),m=Hn(e,`group_${t}_${f}`),g=((ee=(q=n.data)==null?void 0:q.toolInvocationStart)==null?void 0:ee.functionCallId)||n.functionCallId||"";let x,h,v;const b=Array.from(e.parallelFlows.values()).find(F=>F.subflowFunctionCallIds.includes(g)),w=Xr(e),y=qC(e,l,c);o&&b?(x=b.startX+b.currentXOffset,h=b.startY,v=h+Kt,b.currentXOffset+=(kt+ur)*2.2):y?(v=e.nextAvailableGlobalY,x=(y.groupNode.xPosition||un.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,h=v-Kt):(v=e.nextAvailableGlobalY,x=un.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,h=v-Kt);const E={id:p,type:"genericAgentNode",position:{x:50,y:Kt},data:{label:t,visualizerStepId:n.id},parentId:m},A={id:m,type:"group",position:{x,y:h},data:{label:`${t} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${qe+2*Kt}px`}};Un(r,e.allCreatedNodeIds,A),Un(r,e.allCreatedNodeIds,E),e.nodePositions.set(p,E.position),e.nodePositions.set(m,A.position);const I={id:p,xPosition:un.MAIN_FLOW,yPosition:v,height:qe,width:kt},k={id:p,name:t,type:"peer",phaseId:s.id,subflowId:f,context:"subflow",nodeInstance:I};e.agentRegistry.registerAgent(k);const T={id:f,functionCallId:g,isParallel:o,peerAgent:I,groupNode:{id:m,xPosition:x,yPosition:h,height:qe+2*Kt,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+qe,maxContentXRelative:E.position.x+kt,callingPhaseId:s.id,parentSubflowId:w==null?void 0:w.id,inheritedXOffset:y==null?void 0:y.groupNode.xPosition};return s.subflows.push(T),y&&(y.lastSubflow=T),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,T.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+Bn):e.nextAvailableGlobalY=T.groupNode.yPosition+T.groupNode.height+Bn,T}function wp(e,t,n,r,o,s,i=!1){const l=ut(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,d=i?"LLM":`Tool: ${t}`,f=i?"LLM":t,p=s?s.groupNode.id:void 0;let m,g,x,h;if(s){if(m=s.peerAgent.yPosition+s.currentToolYOffset,s.currentToolYOffset+=Ml,x=50+300,s.groupNode.xPosition===void 0||s.groupNode.yPosition===void 0)return null;g=s.groupNode.xPosition+x,h=m-s.groupNode.yPosition}else g=un.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Ml,x=g,h=m;const v=Hn(e,`${f}_${r.id}`),b={id:v,type:n,position:{x,y:h},data:{label:d,visualizerStepId:r.id,toolName:t},parentId:p};Un(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:h});const w={id:v,xPosition:g,yPosition:m,height:qe,width:kt,functionCallId:r.functionCallId};c.push(w);const y=m+qe;if(s){s.maxY=Math.max(s.maxY,y),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+kt);const E=s.maxY-s.groupNode.yPosition+Kt;s.groupNode.height=Math.max(s.groupNode.height,E);const A=s.maxContentXRelative+ur;s.groupNode.width=Math.max(s.groupNode.width||0,A);const I=o.find(k=>k.id===s.groupNode.id);I&&(I.style={...I.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+Bn)}else l.maxY=Math.max(l.maxY,y),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+Bn);return w}function oa(e,t,n,r){e.userNodeCounter++;const o=Hn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:un.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Un(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:qe,width:kt};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+qe;return t.maxY=Math.max(t.maxY,c),l}function xt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const d=o.allCreatedNodeIds.has(e),f=o.allCreatedNodeIds.has(t);if(!d||!f)return;const p=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(g=>g.id===p)){const g=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",x=s.isRequestStep(n),h={id:p,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:x,animationType:x?"request":"static",duration:1}};l&&(h.sourceHandle=l),c&&(h.targetHandle=c),GC(r,h)}}function XC(){const e=new Map;return{agents:e,findAgentByName(t){const n=t.startsWith("peer_")?t.substring(5):t,r=[];for(const[,o]of e)(o.name===n||o.name===t)&&r.push(o);return r.length===0?null:r.reduce((o,s)=>{const i=parseInt(o.id.split("_").pop()||"0");return parseInt(s.id.split("_").pop()||"0")>i?s:o})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function ci(e,t,n){return e==="orchestrator"?t==="output"?n==="bottom"?"orch-bottom-output":"orch-right-output-tools":n==="top"?"orch-top-input":"orch-right-input-tools":t==="output"?n==="bottom"?"peer-bottom-output":"peer-right-output-tools":n==="top"?"peer-top-input":"peer-right-input-tools"}function fr(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const ZC=["USER_REQUEST","AGENT_LLM_CALL","AGENT_LLM_RESPONSE_TO_AGENT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_TOOL_INVOCATION_START","AGENT_TOOL_EXECUTION_RESULT","AGENT_RESPONSE_TEXT","TASK_COMPLETED","TASK_FAILED"];function JC(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=ut(t),d=Xr(t);let f,p=!1;if(d?(f=d.peerAgent,f.id.startsWith(l+"_")&&(p=!0)):c&&(f=c.orchestratorAgent,f.id.startsWith(l+"_")&&(p=!0)),p&&f&&c){t.userNodeCounter++;const m=Hn(t,`User_continue_${t.userNodeCounter}`),g=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:un.USER,y:g},data:{label:"User",visualizerStepId:e.id}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const h={id:m,yPosition:g,height:qe,width:kt};c.userNodes.push(h),t.allUserNodes.push(h);const v=g+qe;f.yPosition=Math.max(f.yPosition,g),c.maxY=Math.max(c.maxY,v,f.yPosition+qe),t.nextAvailableGlobalY=c.maxY+Bn;const b=fr(i)?"orch-left-input":"peer-left-input";xt(h.id,f.id,e,r,t,o,s,"user-right-output",b)}else{const m=dr(t,i,e,n),g=Hn(t,`User_${m.id}`),x={id:g,type:"userNode",position:{x:un.USER,y:m.orchestratorAgent.yPosition-WC},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Un(n,t.allCreatedNodeIds,x),t.nodePositions.set(g,x.position);const h={id:g,yPosition:x.position.y,height:qe,width:kt};m.userNodes.push(h),t.allUserNodes.push(h),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+qe),t.nextAvailableGlobalY=m.maxY+Bn,xt(g,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function QC(e,t,n,r,o,s){const i=ut(t);if(!i)return;const l=as(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,d=wp(t,"LLM","llmNode",e,n,l,!0);d&&xt(c,d.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function eE(e,t,n,r,o,s){var x;if(e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"&&((x=e.data.toolDecision)!=null&&x.isParallel)){const h=`parallel-${e.id}`;e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).length>1&&t.parallelFlows.set(h,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).map(v=>v.functionCallId),completedSubflows:new Set,startX:un.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=ut(t);if(!i)return;const l=as(t,e);let c;const f=xp((l||i).toolInstances,"LLM",n,e.functionCallId);if(f)c=f.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const p=e.target||"UnknownAgent";let m,g;l?(m=l.peerAgent.id,g="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(p.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(m=i.orchestratorAgent.id,g="orch-right-input-tools"),c&&m&&g?xt(c,m,e,r,t,o,s,"llm-bottom-output",g):console.error(`[Timeline] Could not determine target agent node ID or handle for step type ${e.type}: ${e.id}. Target agent name: ${p}. Edge will be missing.`)}function tE(e,t,n,r,o,s){var f;const i=ut(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((f=e.data.toolInvocationStart)==null?void 0:f.isPeerInvocation)||c.startsWith("peer_")){const p=c.startsWith("peer_")?c.substring(5):c,m=t.agentRegistry.findAgentByName(l);if(!m){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const g=m.nodeInstance,x=ci(m.type,"output","bottom"),h=gp(e,t),v=li(t,p,e,n,h);v&&xt(g.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=as(t,e);let m,g;if(p)m=p.peerAgent.id,g="peer-right-output-tools";else{const h=t.agentRegistry.findAgentByName(l);h?(m=h.id,g=ci(h.type,"output","right")):(m=i.orchestratorAgent.id,g="orch-right-output-tools")}const x=wp(t,c,"genericToolNode",e,n,p);x&&xt(m,x.id,e,r,t,o,s,g,`${x.id}-tool-left-input`)}}function nE(e,t,n,r,o,s){var d,f;const i=ut(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((d=e.data.toolResult)!=null&&d.isPeerResponse){const p=(f=e.data.toolResult)==null?void 0:f.functionCallId,m=Array.from(t.parallelFlows.entries()).find(([x,h])=>h.subflowFunctionCallIds.includes(p||""));if(m){const[x,h]=m;if(h.completedSubflows.add(p||""),h.completedSubflows.size<h.subflowFunctionCallIds.length)return;const v=i.subflows.filter(E=>h.subflowFunctionCallIds.includes(E.functionCallId)),b=e.target||"OrchestratorAgent";let w,y;if(fr(b))t.indentationLevel=0,w=dr(t,b,e,n).orchestratorAgent,y="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=li(t,b,e,n,!1);if(!E)return;w=E.peerAgent,y="peer-top-input"}v.forEach(E=>{var A;xt(((A=E.lastSubflow)==null?void 0:A.peerAgent.id)??E.peerAgent.id,w.id,e,r,t,o,s,"peer-bottom-output",y)}),t.parallelFlows.delete(x);return}const g=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!g){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(fr(c)){t.indentationLevel=0;const x=dr(t,c,e,n);xt(g.id,x.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const x=gp(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),h=li(t,c,e,n,x);h&&xt(g.id,h.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=as(t,e),x=xp((m||i).toolInstances,l,n,e.functionCallId);if(x&&(p=x.id),p){let h,v;if(m)h=m.peerAgent.id,v="peer-right-input-tools";else{const b=t.agentRegistry.findAgentByName(c);b?(h=b.id,v=ci(b.type,"input","right")):(h=i.orchestratorAgent.id,v="orch-right-input-tools")}xt(p,h,e,r,t,o,s,l==="LLM"?"llm-bottom-output":`${p}-tool-bottom-output`,v)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function rE(e,t,n,r,o,s){const i=ut(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=oa(t,i,e,n);xt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function oE(e,t,n,r,o,s){const i=ut(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(g=>g.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const g=dr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&xt(x.peerAgent.id,g.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=Xr(t);if(!c){console.warn(`[Timeline] TASK_COMPLETED with isSubTaskStep=true but no active subflow. Step ID: ${e.id}`);return}if(!i){console.error(`[Timeline] No current phase found for TASK_COMPLETED. Step ID: ${e.id}`);return}const d=c.peerAgent,f=n.some(g=>typeof g.data.label=="string"&&fr(g.data.label));let p,m;f?(t.indentationLevel=0,p=dr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=oa(t,i,e,n).id,m="user-top-input"),xt(d.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function sE(e,t,n,r){const o=ut(t);if(!o)return;const s=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const d=Xr(t);if(d&&d.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=d.peerAgent,c="peer-bottom-output";else if(o.orchestratorAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=o.orchestratorAgent,c="orch-bottom-output";else for(const m of o.subflows)if(m.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_"))){l=m.peerAgent,c="peer-bottom-output";break}if(!l){console.error(`[Timeline] Could not find source agent node for TASK_FAILED: ${s}`);return}let f,p;fr(i)?(t.indentationLevel=0,f=dr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(f=oa(t,o,e,n).id,p="user-top-input"),iE(l.id,f,e,r,t,c,p)}function iE(e,t,n,r,o,s,i){var p;if(!e||!t||e===t)return;const l=o.allCreatedNodeIds.has(e),c=o.allCreatedNodeIds.has(t);if(!l||!c)return;const d=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===d)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",g=m.length>30?"Error":m,x={id:d,source:e,target:t,label:g,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:m}};s&&(x.sourceHandle=s),i&&(x.targetHandle=i),r.push(x)}}const aE=e=>{const t=[],n=[];if(!e||e.length===0)return{nodes:t,edges:n};const r=new hp,o={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:HC,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:XC(),indentationLevel:0,indentationStep:50},s=e.filter(c=>ZC.includes(c.type)),i=s.findIndex(c=>c.type==="USER_REQUEST");let l=s;i>0&&(l=[s[i],...s.slice(0,i),...s.slice(i+1)]);for(const c of l)switch(c.type){case"USER_REQUEST":JC(c,o,t,n,r,e);break;case"AGENT_LLM_CALL":QC(c,o,t,n,r,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":eE(c,o,t,n,r,e);break;case"AGENT_TOOL_INVOCATION_START":tE(c,o,t,n,r,e);break;case"AGENT_TOOL_EXECUTION_RESULT":nE(c,o,t,n,r,e);break;case"AGENT_RESPONSE_TEXT":rE(c,o,t,n,r,e);break;case"TASK_COMPLETED":oE(c,o,t,n,r,e);break;case"TASK_FAILED":sE(c,o,t,n);break}return o.phases.forEach(c=>{c.subflows.forEach(d=>{const f=t.find(p=>p.id===d.groupNode.id);if(f&&f.style){const m=d.maxY-d.groupNode.yPosition+Kt;f.style.height=`${Math.max(qe+2*Kt,m)}px`;const g=d.maxContentXRelative+ur,x=kt+2*ur+o.indentationLevel*o.indentationStep;f.style.width=`${Math.max(g,x)}px`}})}),{nodes:t,edges:n}},lE=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:d})=>{const[f,p]=u.useState(!1),[m]=Yp({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),g=()=>{const v={strokeWidth:f?3:2,stroke:"var(--color-muted-foreground)",...l},b=d;return b!=null&&b.isError?{...v,stroke:f?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:f?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:f?"#1d4ed8":"#3b82f6",strokeWidth:f?4:3}:f?{...v,stroke:"var(--edge-hover-color)"}:v},x=()=>p(!0),h=()=>p(!1);return a.jsxs(a.Fragment,{children:[a.jsx("path",{id:`${e}-interaction`,style:{strokeWidth:16,stroke:"transparent",fill:"none",cursor:"pointer"},className:"react-flow__edge-interaction",d:m,onMouseEnter:x,onMouseLeave:h}),a.jsx("path",{id:e,style:{...g(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:m,markerEnd:c,onMouseEnter:x,onMouseLeave:h})]})},cE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-blue-700 bg-white px-5 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-blue-600 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"180px",textAlign:"center"},children:[a.jsx(Ze,{type:"target",position:Je.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Ze,{type:"source",position:Je.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(Ze,{type:"target",position:Je.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(Ze,{type:"source",position:Je.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(Ze,{type:"target",position:Je.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md font-semibold",children:e.label})})]}),uE=({data:e,id:t})=>{const n=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-cyan-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-cyan-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-cyan-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Ze,{type:"target",position:Je.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(Ze,{type:"source",position:Je.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},dE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-teal-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-teal-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-teal-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[a.jsx(Ze,{type:"target",position:Je.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(Ze,{type:"source",position:Je.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},fE=({data:e})=>a.jsxs("div",{className:"cursor-pointer rounded-lg border-indigo-600 bg-gradient-to-r from-indigo-50 to-purple-50 px-5 py-3 text-gray-900 shadow-xl transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-2xl dark:border-indigo-400 dark:bg-gradient-to-r dark:from-indigo-900 dark:to-purple-900 dark:text-gray-100",style:{minWidth:"180px",textAlign:"center",borderWidth:"2px",borderStyle:"solid",boxShadow:"0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:[a.jsx(Ze,{type:"source",position:Je.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(Ze,{type:"target",position:Je.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(Ze,{type:"target",position:Je.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Ze,{type:"source",position:Je.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(Ze,{type:"target",position:Je.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md flex items-center font-bold",children:e.label})})]}),pE=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-purple-500"}};return a.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-purple-600 bg-white px-4 py-3 text-gray-800 shadow-lg transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-700 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[e.isTopNode&&a.jsx(Ze,{type:"source",position:Je.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(Ze,{type:"target",position:Je.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(Ze,{type:"source",position:Je.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),a.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},mE=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,y,E;switch(e.type){case"USER_REQUEST":return a.jsx(Zp,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(Vl,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(Xp,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(cs,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(cs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const A=(y=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:y[0];return(A==null?void 0:A.isPeerDelegation)?a.jsx(fa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(pa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(E=e.data.toolInvocationStart)!=null&&E.isPeerInvocation?a.jsx(fa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(pa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(qp,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(sr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(Kp,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},s=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),i=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),l=`${s}.${i}`,c=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Prompt Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.promptPreview})]}),d=({data:w})=>{const[y,E]=Bt.useState(!1),A=I=>{I.stopPropagation(),E(!y)};return y?a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[a.jsx("strong",{children:"LLM Response Details:"}),a.jsx("button",{onClick:A,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),w.modelName&&a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsxs("div",{className:"mt-1",children:[a.jsx("p",{children:a.jsx("strong",{children:"Response Preview:"})}),a.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:w.responsePreview})]}),w.isFinalResponse!==void 0&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Final Response:"})," ",w.isFinalResponse?"Yes":"No"]})]}):a.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"italic",children:"Internal LLM response"}),a.jsx("button",{onClick:A,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},f=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-blue-50 p-2 font-mono text-xs text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{children:["🔧 ",w.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),a.jsx("ul",{className:"space-y-1 pl-2",children:w.decisions.map(y=>a.jsxs("li",{className:"flex items-center",children:[a.jsx("span",{className:"mr-2",children:"•"}),a.jsx("code",{children:y.toolName})]},y.functionCallId))})]}),p=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Arguments:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:a.jsx(fi,{data:w.toolArguments})})]}),m=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Result:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:typeof w.resultData=="object"?a.jsx(fi,{data:w.resultData}):a.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(w.resultData)})})]}),g=w=>a.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Artifact:"})," ",w.artifactName,w.version!==void 0&&a.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",w.version,")"]})]}),w.mimeType&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",w.mimeType]}),w.description&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Description:"})," ",w.description]})]}),x=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},h=r==="popover"?`
330
- p-3 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors duration-150
331
- ${n?"cursor-pointer":""}
332
- `:`
333
- mb-3 p-3 border rounded-lg shadow-sm
334
- bg-white dark:bg-gray-800 hover:shadow-md transition-shadow duration-150
335
- ${t?"border-blue-500 dark:border-blue-400 ring-2 ring-blue-500 dark:ring-blue-400":"border-gray-200 dark:border-gray-700"}
336
- ${n?"cursor-pointer":""}
337
- `,v=()=>e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||e.type==="AGENT_TOOL_INVOCATION_START"?"Delegated to: ":e.type==="AGENT_TOOL_EXECUTION_RESULT"?"Response from: ":"Peer Interaction with: ",b=e.title;return a.jsxs("div",{className:h,style:x,onClick:n,children:[a.jsxs("div",{className:"mb-1.5 flex items-center",children:[o(),a.jsx("h4",{className:"flex-grow text-sm font-semibold text-gray-700 dark:text-gray-200",title:e.title,children:b}),a.jsx("span",{className:"font-mono text-xs text-gray-500 dark:text-gray-400",children:l})]}),e.delegationInfo&&e.delegationInfo.length>0&&a.jsx("div",{className:"mt-2 mb-1.5 space-y-2 rounded-r-md border-l-4 border-blue-500 bg-blue-50 p-2 text-sm dark:border-blue-400 dark:bg-gray-700/60",children:e.delegationInfo.map(w=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center font-semibold text-blue-700 dark:text-blue-300",children:[a.jsx(Xl,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.jsxs("span",{children:[v(),w.peerAgentName]})]}),w.subTaskId&&a.jsxs("div",{className:"mt-0.5 ml-[24px] text-xs text-blue-600 dark:text-blue-400",children:["Sub-Task:"," ",a.jsxs("span",{className:"font-mono",title:w.subTaskId,children:[w.subTaskId.substring(0,15),"..."]})]})]},w.functionCallId))}),e.data.text&&a.jsx("div",{className:"max-h-20 overflow-y-auto pl-1 text-sm text-gray-800 dark:text-gray-100",children:a.jsx(or,{children:e.data.text})}),e.data.finalMessage&&a.jsx("div",{className:"pl-1 text-sm text-gray-800 dark:text-gray-100",children:a.jsx(or,{children:e.data.finalMessage})}),e.type==="TASK_COMPLETED"&&!e.data.finalMessage&&a.jsx("div",{className:"pl-1 text-sm text-gray-600 italic dark:text-gray-300",children:"Task completed successfully."}),e.data.errorDetails&&a.jsxs("div",{className:"mt-1 rounded-md bg-red-50 p-2 pl-1 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400",children:[a.jsxs("p",{children:[a.jsx("strong",{children:"Error:"})," ",e.data.errorDetails.message]}),e.data.errorDetails.code&&a.jsxs("p",{className:"text-xs",children:["Code: ",e.data.errorDetails.code]})]}),e.data.llmCall&&c(e.data.llmCall),e.data.llmResponseToAgent&&a.jsx(d,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&f(e.data.toolDecision),e.data.toolInvocationStart&&p(e.data.toolInvocationStart),e.data.toolResult&&m(e.data.toolResult),e.data.artifactNotification&&g(e.data.artifactNotification)]})},hE={genericAgentNode:cE,userNode:pE,llmNode:dE,orchestratorNode:fE,genericToolNode:uE},gE={defaultFlowEdge:lE},xE={x:16,y:0},vE=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,o,s]=Qp([]),[i,l,c]=em([]),{fitView:d}=tm(),{highlightedStepId:f,setHighlightedStepId:p}=Gi(),{taskIdInSidePanel:m}=He(),g=u.useRef([]),[x,h]=u.useState(!1),[v,b]=u.useState(null),[w,y]=u.useState(!1),E=u.useRef(null),[A,I]=u.useState(null),k=u.useRef(new hp),T=u.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:aE(e),[e]),Y=u.useMemo(()=>T.edges.length?T.edges.map(j=>{const C=j.data;let M={isAnimated:!1,animationType:"none"};if(C!=null&&C.visualizerStepId){const P=e.length-1;M=k.current.getEdgeAnimationState(C.visualizerStepId,P,e)}let D=j.id===A;return f&&(C==null?void 0:C.visualizerStepId)===f&&(D=!0),{...j,animated:M.isAnimated,data:{...C,isAnimated:M.isAnimated,animationType:M.animationType,isSelected:D}}}):[],[T.edges,e,A,f]),X=u.useCallback(()=>{o(j=>j.map(C=>{var Q,ae,se,ue;if(C.type!=="group")return C;const M=j.filter(he=>he.parentId===C.id);if(M.length===0)return C;let D=0,P=0;M.forEach(he=>{const ke=he.position.x+kt,Pe=he.position.y+qe;D=Math.max(D,ke),P=Math.max(P,Pe)});const te=D+ur,O=P+Kt;let B=0;const L=C.id.split("_");if(L.length>2){const he=L.find(ke=>ke.startsWith("subflow"));if(he){const ke=parseInt(he.replace("subflow",""));isNaN(ke)||(B=ke)}}const H=kt+2*ur+B*50,_=Math.max(te,H),G=parseInt(((ae=(Q=C.style)==null?void 0:Q.width)==null?void 0:ae.toString().replace("px",""))||"0"),J=parseInt(((ue=(se=C.style)==null?void 0:se.height)==null?void 0:ue.toString().replace("px",""))||"0");return G!==_||J!==O?{...C,style:{...C.style,width:`${_}px`,height:`${O}px`}}:C}))},[o]);u.useEffect(()=>{o(T.nodes),l(Y),X()},[T.nodes,Y,o,l,X]);const W=u.useCallback((j,C)=>i.find(M=>M.source===j&&(C?M.sourceHandle===C:!0))||null,[i]),q=u.useCallback((j,C)=>{var D;h(!0);const M=(D=C.data)==null?void 0:D.visualizerStepId;if(M){const P=e.find(te=>te.id===M);P&&(I(C.id),t?p(M):(p(M),b(P),y(!0)))}},[e,t,p]),ee=u.useCallback(j=>{switch(j.type){case"userNode":{const C=j.data;return C!=null&&C.isTopNode?["user-bottom-output"]:C!=null&&C.isBottomNode?["user-top-input"]:["user-right-output"]}case"orchestratorNode":return["orch-right-output-tools","orch-bottom-output"];case"genericAgentNode":return["peer-right-output-tools","peer-bottom-output"];case"llmNode":return["llm-bottom-output"];case"genericToolNode":return[`${j.id}-tool-bottom-output`];default:return[]}},[]),F=u.useCallback(()=>{y(!1),b(null)},[]),Z=u.useCallback((j,C)=>{if(h(!0),C.type==="group"){p(null),I(null),F();return}const M=ee(C);let D=null;for(const P of M)if(D=W(C.id,P),D)break;if(!D&&C.type==="userNode"){const P=C.data;P!=null&&P.isBottomNode&&(D=i.find(te=>te.target===C.id)||null)}D&&q(j,D)},[ee,p,F,W,i,q]),N=u.useCallback(j=>{j!=null&&j.isTrusted&&h(!0)},[]);return u.useEffect(()=>{h(!1)},[m]),u.useEffect(()=>{!n&&d&&r.length>0&&g.current!==e&&x===!1&&(d({duration:200,padding:.1,maxZoom:1.2}),g.current=e)},[r.length,d,e,n,x]),u.useEffect(()=>{if(o(j=>j.map(C=>{var te;const M=((te=C.data)==null?void 0:te.visualizerStepId)&&C.data.visualizerStepId===f,D=T.nodes.find(O=>O.id===C.id),P=(D==null?void 0:D.style)||{};return{...C,style:{...P,boxShadow:M?"0px 4px 12px rgba(0, 0, 0, 0.2)":P.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),f){const j=Y.find(C=>{const M=C.data;return(M==null?void 0:M.visualizerStepId)===f});j&&I(j.id)}else I(null)},[f,o,T.nodes,Y]),!e||e.length===0?a.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:Object.keys(e).length>0?"Processing flow data...":"No steps to display in flow chart."}):T.nodes.length===0&&e.length>0?a.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:"Generating flow chart..."}):a.jsxs("div",{style:{height:"100%",width:"100%"},className:"relative",children:[a.jsxs(nm,{nodes:r,edges:i.map(j=>({...j,markerEnd:{type:im.ArrowClosed,color:"#888"}})),onNodesChange:s,onEdgesChange:c,onEdgeClick:q,onNodeClick:Z,onPaneClick:()=>{p(null),I(null),F()},onMoveStart:N,nodeTypes:hE,edgeTypes:gE,fitViewOptions:{padding:.1},className:"bg-gray-50 dark:bg-gray-900 [&>button]:dark:bg-gray-700",proOptions:{hideAttribution:!0},nodesDraggable:!1,elementsSelectable:!1,nodesConnectable:!1,minZoom:.2,children:[a.jsx(rm,{}),a.jsx(om,{className:oh()}),a.jsx(sm,{position:"top-right",className:"flex items-center space-x-4",children:a.jsx("div",{ref:E})})]}),a.jsx(Ow,{isOpen:w,onClose:F,anchorRef:E,offset:xE,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:v&&a.jsx(mE,{step:v,variant:"popover"})})]})},wE=e=>a.jsx(Jp,{children:a.jsx(vE,{...e})}),bp=e=>{var t,n,r,o;if(e.events&&e.events.length>0){const s=e.events[0];if((o=(r=(n=(t=s.full_payload)==null?void 0:t.params)==null?void 0:n.message)==null?void 0:r.metadata)!=null&&o.parentTaskId)return s.full_payload.params.message.metadata.parentTaskId}},kr=e=>{var t,n,r;return((r=(n=(t=e.full_payload)==null?void 0:t.result)==null?void 0:n.status)==null?void 0:r.timestamp)||e.timestamp},yp=(e,t,n,r)=>{const o=t[e];if(!o)return console.warn(`[collectAllDescendantEvents] Task not found in allMonitoredTasks: ${e}`),[];n.set(e,r);let s=[...o.events||[]];for(const i in t){const l=t[i];if(l.taskId===e)continue;bp(l)===e&&(s=s.concat(yp(l.taskId,t,n,r+1)))}return s},bE=(e,t,n)=>{if(!n)return null;const r={overall:{totalTaskDurationMs:0},agents:{}},o=new Map,s=new Map,i=(N,j)=>(r.agents[N]||(r.agents[N]={agentName:j,instanceId:N,displayName:j,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),r.agents[N]),l=new Map,c=yp(n.taskId,t,l,0);if(c.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const d=c.sort((N,j)=>new Date(kr(N)).getTime()-new Date(kr(j)).getTime()),f=[];let p,m="",g,x,h=[],v=null,b;const w=new Map,y=new Map,E=new Map,A=N=>{if(m.trim()&&g&&x){const j=m.trim();let C=n.taskId;if(h.length>0){const P=h[0].split("-");P.length>2&&P[1]!=="global"&&(C=P.slice(1,P.length-1).join("-"))}else N&&(C=N);const M=l.get(C)??0,D=w.get(C)||E.get(C);f.push({id:`vstep-agenttext-${f.length}-${h[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:x,title:`${g}: Response`,source:g,target:"User",data:{text:j},rawEventIds:[...h],isSubTaskStep:M>0,nestingLevel:M,owningTaskId:C,functionCallId:D}),v=j}m="",g=void 0,x=void 0,h=[],b=void 0};d.forEach((N,j)=>{var _,G,J,Q,ae,se,ue,he,ke,Pe,De,Me,Be,wt,We,bt,et,tt,nt,le,It,yt,jt,Mt,St,Ct,Et,Xe,dt,Rt,Pt,on,Le,Ge,Lt,mt,Dt,Ot,Oe,ft,sn,Vt,Tt,Ft,Yt;const C=kr(N),M=`raw-${N.task_id||"global"}-${j}`,D=N.full_payload,P=N.task_id||n.taskId,te=l.get(P)??0;let O=N.source_entity||"UnknownAgent";(J=(G=(_=D==null?void 0:D.params)==null?void 0:_.message)==null?void 0:G.metadata)!=null&&J.agent_name?O=D.params.message.metadata.agent_name:(ae=(Q=D==null?void 0:D.result)==null?void 0:Q.metadata)!=null&&ae.agent_name?O=D.result.metadata.agent_name:(ke=(he=(ue=(se=D==null?void 0:D.result)==null?void 0:se.status)==null?void 0:ue.message)==null?void 0:he.metadata)!=null&&ke.agent_name?O=D.result.status.message.metadata.agent_name:(Me=(De=(Pe=D==null?void 0:D.result)==null?void 0:Pe.artifact)==null?void 0:De.metadata)!=null&&Me.agent_name&&(O=D.result.artifact.metadata.agent_name);let B;if(te>0?B=w.get(P):B=E.get(P),N.direction==="request"&&te>0){const Se=(Be=D.params)==null?void 0:Be.metadata,$=Se==null?void 0:Se.function_call_id,U=N.task_id;if(U&&$){w.set(U,$);return}}if(N.direction==="request"&&te===0&&N.task_id===n.taskId){A(P),v=null;const Se=D.params;let $="User request";if((wt=Se==null?void 0:Se.message)!=null&&wt.parts){const U=Se.message.parts.filter(z=>z.kind==="text"&&z.text);U.length>0&&($=U[U.length-1].text)}f.push({id:`vstep-userreq-${f.length}-${M}`,type:"USER_REQUEST",timestamp:C,title:"User Input",source:"User",target:N.target_entity||O,data:{text:$},rawEventIds:[M],isSubTaskStep:!1,nestingLevel:0,owningTaskId:P});return}if(N.direction==="status-update"&&(D!=null&&D.result)){const Se=D.result,$=(We=Se.status)==null?void 0:We.message,U=$==null?void 0:$.metadata;let z;const ie=!!(U!=null&&U.forwarded_from_peer);ie?z=U.forwarded_from_peer:(bt=Se.metadata)!=null&&bt.agent_name?z=Se.metadata.agent_name:U!=null&&U.agent_name?z=U.agent_name:z=N.source_entity||"Agent";const de=`${z}:${P}`;if(!ie&&($!=null&&$.parts))for(const pe of $.parts){if(pe.kind==="data"){const ge=pe.data;ge.type==="agent_progress_update"?p=ge.status_text:ge.type==="artifact_creation_progress"&&(p=`Saving artifact: ${ge.filename} (${ge.bytes_saved} bytes)`)}if(pe.kind==="data"){A(P);const xe=pe.data;switch(xe==null?void 0:xe.type){case"agent_progress_update":{f.push({id:`vstep-progress-${f.length}-${M}`,type:"AGENT_RESPONSE_TEXT",timestamp:C,title:`${z}: Progress Update`,source:z,target:"User",data:{text:xe.status_text},rawEventIds:[M],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B});break}case"llm_invocation":{const ne=xe.request;let we="System-initiated LLM call";if(ne!=null&&ne.contents&&Array.isArray(ne.contents)&&ne.contents.length>0){const K=[...ne.contents].reverse().find(S=>S.role==="user");K&&K.parts&&(we=K.parts.map(S=>S.text||"").join(`
338
- `).trim())}const _e={modelName:(ne==null?void 0:ne.model)||"Unknown Model",promptPreview:we||"No text in user prompt."};i(de,z),o.set(de,{timestamp:C,modelName:_e.modelName}),f.push({id:`vstep-llmcall-${f.length}-${M}`,type:"AGENT_LLM_CALL",timestamp:C,title:`${z}: LLM Call`,source:z,target:"LLM",data:{llmCall:_e},rawEventIds:[M],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B});break}case"llm_response":{const ne=o.get(de);if(ne){const S=new Date(C).getTime()-new Date(ne.timestamp).getTime();i(de,z).llmCalls.push({modelName:ne.modelName,durationMs:S,timestamp:ne.timestamp}),o.delete(de)}const we=xe.data,_e=(et=we.content)==null?void 0:et.parts,K=_e==null?void 0:_e.filter(S=>S.function_call);if(K&&K.length>0){A(P),v=null,E.delete(P);const S=K.map(je=>{var At;return{functionCallId:je.function_call.id,toolName:je.function_call.name,toolArguments:je.function_call.args||{},isPeerDelegation:(At=je.function_call.name)==null?void 0:At.startsWith("peer_")}}),R={decisions:S,isParallel:S.length>1},V=[],me=new Set;S.forEach(je=>{if(je.isPeerDelegation){const At=je.toolName.substring(5);for(const hn in t){const Fe=t[hn];if(me.has(Fe.taskId))continue;if(bp(Fe)===P&&Fe.events&&Fe.events.length>0){const wr=Fe.events.find(br=>{var sa,ia,aa,la;return br.direction==="request"&&((la=(aa=(ia=(sa=br.full_payload)==null?void 0:sa.params)==null?void 0:ia.message)==null?void 0:aa.metadata)==null?void 0:la.function_call_id)===je.functionCallId});if(wr&&new Date(kr(wr)).getTime()>=new Date(C).getTime()){const br={functionCallId:je.functionCallId,peerAgentName:At,subTaskId:Fe.taskId};V.push(br),y.set(je.functionCallId,br),Fe.taskId&&(w.set(Fe.taskId,je.functionCallId),me.add(Fe.taskId));break}}}}});const Re={id:`vstep-tooldecision-${f.length}-${M}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:C,title:`LLM: Tool Decision${R.isParallel?" (Parallel)":""}`,source:"LLM",target:z,data:{toolDecision:R},rawEventIds:[M],delegationInfo:V.length>0?V:void 0,isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B};f.push(Re);const fe=R.isParallel?Re.id:void 0,ye=de;i(ye,z),S.forEach(je=>{var hn;const At=je.isPeerDelegation?(hn=y.get(je.functionCallId))==null?void 0:hn.subTaskId:void 0;s.has(je.functionCallId)||s.set(je.functionCallId,{timestamp:C,toolName:je.toolName,isPeer:je.isPeerDelegation,invokingAgentInstanceId:ye,subTaskId:At,parallelBlockId:fe})})}else{const S=(_e==null?void 0:_e.filter(V=>V.text).map(V=>V.text).join(`
339
- `))||"",R={responsePreview:S.substring(0,200)+(S.length>200?"...":""),isFinalResponse:(we==null?void 0:we.partial)===!1};f.push({id:`vstep-llmrespagent-${f.length}-${M}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:C,title:`${z}: LLM Response`,source:"LLM",target:z,data:{llmResponseToAgent:R},rawEventIds:[M],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B})}break}case"tool_invocation_start":{const ne={functionCallId:xe.function_call_id,toolName:xe.tool_name,toolArguments:xe.tool_args,isPeerInvocation:(tt=xe.tool_name)==null?void 0:tt.startsWith("peer_")};f.push({id:`vstep-toolinvokestart-${f.length}-${M}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:C,title:`${z}: Executing tool ${ne.toolName}`,source:z,target:ne.toolName,data:{toolInvocationStart:ne},rawEventIds:[M],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B});break}case"tool_result":{const ne=xe.function_call_id,we=s.get(ne);if(we){const K=new Date(C).getTime()-new Date(we.timestamp).getTime(),S=r.agents[we.invokingAgentInstanceId];if(S){const R={toolName:we.toolName,durationMs:K,isPeer:we.isPeer,timestamp:we.timestamp,peerAgentName:we.isPeer?we.toolName.substring(5):void 0,subTaskId:we.subTaskId,parallelBlockId:we.parallelBlockId};S.toolCalls.push(R)}s.delete(ne)}const _e={toolName:xe.tool_name,functionCallId:ne,resultData:xe.result_data,isPeerResponse:(nt=xe.tool_name)==null?void 0:nt.startsWith("peer_")};f.push({id:`vstep-toolresult-${f.length}-${M}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:C,title:`${z}: Tool Result - ${_e.toolName}`,source:_e.toolName,target:z,data:{toolResult:_e},rawEventIds:[M],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B});break}}}else pe.kind==="text"&&pe.text&&(g&&g!==z&&(A(P),v=null),g||(g=z,x=C,b=ie),m+=pe.text,h.push(M))}return}if(N.direction==="artifact_update"&&((le=D==null?void 0:D.result)!=null&&le.artifact)){A(P);const Se=D.result.artifact,$=((It=Se.metadata)==null?void 0:It.agent_name)||N.source_entity||"Agent";let U;if(Se.parts&&Se.parts.length>0){const ie=Se.parts[0];ie.kind==="file"?U=ie.file.mimeType||void 0:(yt=ie.metadata)!=null&&yt.mime_type&&(U=ie.metadata.mime_type)}const z={artifactName:Se.name||"Unnamed Artifact",version:typeof((jt=Se.metadata)==null?void 0:jt.version)=="number"?Se.metadata.version:void 0,description:Se.description||void 0,mimeType:U};f.push({id:`vstep-artifactnotify-${f.length}-${M}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:C,title:`${$}: Artifact Update - ${z.artifactName}`,source:$,target:"User/System",data:{artifactNotification:z},rawEventIds:[M],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B});return}if(["response","task"].includes(N.direction)&&((St=(Mt=D==null?void 0:D.result)==null?void 0:Mt.status)!=null&&St.state)){m.trim()&&A(P);const Se=D.result,$=Se.status.state,U=((Ct=Se.metadata)==null?void 0:Ct.agent_name)||((dt=(Xe=(Et=Se.status)==null?void 0:Et.message)==null?void 0:Xe.metadata)==null?void 0:dt.agent_name)||N.source_entity||"Agent";if(["completed","failed","canceled"].includes($)&&te==0){const z=$==="completed"?"TASK_COMPLETED":"TASK_FAILED",ie=`${U}: Task ${$.charAt(0).toUpperCase()+$.slice(1)}`;let de={},pe="";if((Rt=Se.status.message)!=null&&Rt.parts){const Ie=Se.status.message.parts.find(ne=>ne.kind==="text");Ie!=null&&Ie.text&&(pe=Ie.text.trim())}const ge=P===n.taskId,xe=pe&&(!ge||pe!==v);if(z==="TASK_COMPLETED")de={finalMessage:xe?pe:void 0};else{const ne={message:xe?pe:`Task ${$}.`},we=D.error;we&&(ne.message=we.message||ne.message,ne.code=we.code,we.data&&(ne.details=we.data)),Se.error&&(ne.message=Se.error.message||ne.message,ne.code=Se.error.code||ne.code,ne.details=Se.error.data||ne.details),de={errorDetails:ne}}f.push({id:`vstep-${$}-${f.length}-${M}`,type:z,timestamp:C,title:ie,source:U,target:"User",data:de,rawEventIds:[M],isSubTaskStep:te>0,nestingLevel:te,owningTaskId:P,functionCallId:B}),ge&&(v=null);return}}const L=N.direction==="status-update"&&((Ge=(Le=(on=(Pt=D==null?void 0:D.result)==null?void 0:Pt.status)==null?void 0:on.message)==null?void 0:Le.parts)==null?void 0:Ge.some(Se=>Se.kind==="text"));let H=N.source_entity;(Ot=(Dt=(mt=(Lt=D==null?void 0:D.result)==null?void 0:Lt.status)==null?void 0:mt.message)==null?void 0:Dt.metadata)!=null&&Ot.forwarded_from_peer?H=D.result.status.message.metadata.forwarded_from_peer:(ft=(Oe=D==null?void 0:D.result)==null?void 0:Oe.metadata)!=null&&ft.agent_name?H=D.result.metadata.agent_name:(Ft=(Tt=(Vt=(sn=D==null?void 0:D.result)==null?void 0:sn.status)==null?void 0:Vt.message)==null?void 0:Tt.metadata)!=null&&Ft.agent_name&&(H=D.result.status.message.metadata.agent_name),m.trim()&&g&&(!L||L&&H!==g)&&(A(P),l.get(((Yt=h[0])==null?void 0:Yt.split("-")[1])||n.taskId)===0&&!b&&(v=null))});const I=d.length>0&&d[d.length-1].task_id||n.taskId;A(I);const k=d[0]?kr(d[0]):n.firstSeen.toISOString();let T,Y="working";const X=f.filter(N=>N.owningTaskId===n.taskId),W=X.length>0?X[X.length-1]:null;if(W&&(W.type==="TASK_COMPLETED"?(Y="completed",T=W.timestamp):W.type==="TASK_FAILED"&&(Y="failed",T=W.timestamp)),Y==="working"&&d.length>0){const N=d[d.length-1];t[N.task_id||n.taskId]}let q;k&&T&&(q=new Date(T).getTime()-new Date(k).getTime()),["completed","failed","canceled","rejected"].includes(Y)&&(p=void 0);const ee={taskId:n.taskId,initialRequestText:n.initialRequestText,status:Y,currentStatusText:p,startTime:k,endTime:T,durationMs:q,steps:f};ee.steps.forEach((N,j)=>{if(N.type==="TASK_COMPLETED"){let C="";for(let M=j-1;M>=0;M--){const D=ee.steps[M];if(D.type!=="AGENT_RESPONSE_TEXT"||D.source!==N.source)break;C=D.data.text+C}N.data.finalMessage&&(C+=N.data.finalMessage),N.data.finalMessage=C.trim()||void 0}}),Object.values(r.agents).forEach(N=>{N.totalLlmTimeMs=N.llmCalls.reduce((P,te)=>P+te.durationMs,0);const j=N.toolCalls.filter(P=>!P.parallelBlockId),C=new Map;N.toolCalls.forEach(P=>{P.parallelBlockId&&(C.has(P.parallelBlockId)||C.set(P.parallelBlockId,[]),C.get(P.parallelBlockId).push(P))});const M=j.reduce((P,te)=>P+te.durationMs,0);let D=0;C.forEach(P=>{if(P.length>0){const te=Math.min(...P.map(B=>new Date(B.timestamp).getTime())),O=Math.max(...P.map(B=>new Date(B.timestamp).getTime()+B.durationMs));D+=O-te}}),N.totalToolTimeMs=M+D});const F=new Map;Object.values(r.agents).forEach(N=>{F.has(N.agentName)||F.set(N.agentName,[]),F.get(N.agentName).push(N)}),F.forEach(N=>{N.length>1&&(N.sort((j,C)=>{const M=D=>{const P=[...D.llmCalls.map(te=>new Date(te.timestamp).getTime()),...D.toolCalls.map(te=>new Date(te.timestamp).getTime())];return P.length>0?Math.min(...P):1/0};return M(j)-M(C)}),N.forEach((j,C)=>{j.displayName=`${j.agentName} (${C+1})`}))});const Z=new Map;return Object.values(r.agents).forEach(N=>{const j=N.instanceId.split(":").slice(1).join(":");j&&Z.set(j,N.displayName)}),Object.values(r.agents).forEach(N=>{N.toolCalls.forEach(j=>{if(j.isPeer&&j.subTaskId){const C=Z.get(j.subTaskId);C&&(j.peerAgentName=C)}})}),q!==void 0&&(r.overall.totalTaskDurationMs=q),ee.performanceReport=r,ee},yE=({items:e,bottomItems:t,activeItem:n,onItemChange:r,onHeaderClick:o})=>{const s=i=>{r(i)};return a.jsxs("aside",{className:"flex h-screen w-[100px] flex-col border-r border-[var(--color-secondary-w70)] bg-[var(--color-primary-w100)]",children:[a.jsx(CE,{onClick:o}),a.jsx(TE,{items:e,bottomItems:t,activeItem:n,onItemClick:s})]})},SE=a.jsxs("svg",{id:"header-icon",xmlns:"http://www.w3.org/2000/svg",version:"1.1",viewBox:"0 0 500 150",width:"100%",height:"100%",children:[a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M14.3,82.5c0-4.4,1-8.2,2.9-11.3,1.9-3.1,4.4-5.7,7.5-7.8,3.1-2,6.5-3.6,10.4-4.6,3.8-1,7.7-1.5,11.5-1.5s7.1.3,10.2.9c3.1.6,5.9,1.5,8.2,2.6,2.4,1.1,4.2,2.4,5.6,3.8,1.4,1.4,2,3,2,4.6,0,2.4,0,4.3-.2,5.7-.1,1.4-.3,2.4-.6,3.1-.3.7-.7,1.1-1.1,1.3-.4.2-.9.2-1.6.2-1.8,0-3.2-.7-4.3-2-1.1-1.3-2.3-2.8-3.7-4.4-1.4-1.6-3.1-3.1-5.3-4.4-2.1-1.3-5.3-2-9.3-2s-4.4.3-6,.9c-1.6.6-2.9,1.5-3.8,2.5-.9,1-1.6,2.2-2,3.4-.4,1.2-.6,2.4-.6,3.5,0,2.5,1,4.4,3.1,5.7,2.1,1.3,4.7,2.3,7.8,3.2,3.1.9,6.5,1.7,10.1,2.5,3.6.8,7,1.9,10.1,3.4,3.1,1.5,5.8,3.5,7.9,6.1,2.1,2.6,3.1,6.1,3.1,10.5s-.8,8-2.5,11.3c-1.7,3.4-4,6.2-7,8.5-3,2.3-6.6,4.1-10.8,5.3-4.2,1.3-8.9,1.9-13.9,1.9s-8.8-.6-12.5-1.9c-3.7-1.3-6.9-2.8-9.6-4.6-2.7-1.8-4.7-3.7-6.2-5.6-1.5-1.9-2.2-3.5-2.2-4.7,0-1.8.5-3.6,1.6-5.3,1-1.8,2.6-2.7,4.7-2.7s2.5.4,3.5,1.2c.9.8,1.8,1.7,2.7,2.8.8,1.1,1.7,2.3,2.6,3.7.9,1.4,2,2.6,3.3,3.7,1.3,1.1,2.9,2,4.7,2.8,1.8.8,4.1,1.2,6.8,1.2,4.1,0,7.5-1,10.3-3.1,2.8-2.1,4.2-4.8,4.2-8s-1-4.9-3.1-6.4c-2-1.4-4.6-2.6-7.7-3.5-3.1-.9-6.4-1.7-10-2.4-3.6-.7-7-1.8-10-3.2-3.1-1.4-5.7-3.4-7.7-6-2-2.6-3.1-6.3-3.1-11"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M124.6,66.8c-4,0-7.3.9-9.9,2.7-2.6,1.8-4.7,4.2-6.4,7.1-1.6,2.9-2.8,6.1-3.5,9.7-.7,3.5-1,6.9-1,10.1,0,4.9.5,9.2,1.6,13,1,3.7,2.5,6.8,4.4,9.3,1.9,2.5,4.1,4.3,6.7,5.6,2.6,1.3,5.3,1.9,8.2,1.9s5.7-.6,8.2-1.9c2.6-1.3,4.8-3.1,6.7-5.6,1.9-2.5,3.3-5.5,4.4-9.3,1-3.7,1.6-8,1.6-13,0-9.5-1.9-16.9-5.8-22-3.9-5.1-8.9-7.7-15.2-7.7M82.2,96.5c0-5.8,1.1-11,3.3-15.9,2.2-4.8,5.2-8.9,9.1-12.4,3.9-3.5,8.4-6.1,13.6-8,5.2-1.9,10.7-2.8,16.6-2.8s11.4.9,16.6,2.8c5.2,1.9,9.7,4.6,13.5,8,3.8,3.5,6.9,7.6,9.1,12.4,2.2,4.8,3.4,10.1,3.4,15.9s-1.1,11.2-3.4,15.9c-2.3,4.8-5.3,8.9-9.1,12.3-3.8,3.5-8.3,6.1-13.5,8-5.2,1.9-10.7,2.8-16.6,2.8s-11.4-.9-16.6-2.8c-5.2-1.9-9.7-4.6-13.6-8-3.9-3.5-6.9-7.6-9.1-12.3-2.2-4.8-3.3-10.1-3.3-15.9"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M172.3,23.3c0-.8.9-1.8,2.7-2.8,1.8-1,4-2,6.5-2.9,2.5-.9,5.1-1.6,7.7-2.3,2.6-.6,4.7-.9,6.3-.9s1.3,0,1.9.2c.6.2,1.2.5,1.8,1.2.6.6,1,1.6,1.4,2.9.4,1.3.5,3.1.5,5.4v94.7c0,2.4.4,4.1,1.2,4.9.8.9,1.6,1.5,2.5,2,.9.4,1.7.8,2.5,1.3.8.4,1.2,1.4,1.2,2.8s-.5,2.5-1.6,3.2c-1,.7-2.4,1-3.9,1h-24.2c-1.6,0-2.9-.3-3.9-1-1-.7-1.6-1.8-1.6-3.2s.4-2.3,1.2-2.7c.8-.5,1.6-.9,2.5-1.3.9-.4,1.7-1.1,2.5-2,.8-.9,1.2-2.5,1.2-4.9V34.5c0-2-.4-3.4-1.3-4.2-.9-.8-1.9-1.4-2.9-1.9-1-.5-2-1-2.9-1.6-.9-.6-1.3-1.8-1.3-3.5"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M254.4,93.3c-3.7,1.2-6.8,2.8-9.4,4.7-2.6,1.9-4.6,4.1-6,6.6-1.4,2.5-2.1,5-2.1,7.6s.3,3.6,1,5.3c.7,1.8,1.6,3.4,2.9,4.7,1.3,1.4,2.7,2.5,4.5,3.3,1.7.8,3.6,1.3,5.7,1.3s5.2-.7,7.2-2c2-1.3,3.6-2.9,4.9-4.7,1.3-1.8,2.2-3.7,2.7-5.7.6-1.9.9-3.6.9-4.9v-18.2c-4.5.1-8.6.8-12.2,2M220.5,69.7c0-1.9.9-3.6,2.6-5.1,1.7-1.5,4-2.8,6.8-3.8,2.8-1,6-1.9,9.5-2.4,3.5-.6,7-.9,10.4-.9,7,0,12.9.8,17.6,2.3,4.7,1.5,8.5,3.6,11.5,6.1,2.9,2.6,5,5.5,6.3,8.7,1.3,3.2,1.9,6.6,1.9,10v34.5c0,1.9.4,3.2,1.3,4.1.8.8,1.7,1.5,2.7,2,.9.5,1.8,1,2.7,1.5.8.5,1.3,1.4,1.3,2.7s-.4,2.5-1.2,3.4c-.8.9-2.7,1.3-5.7,1.3h-13.2c-2.4,0-4.1-.5-5.1-1.6-1-1-1.5-2.8-1.5-5.2v-1.7h-.6c-2.4,3.5-5.9,6-10.4,7.6-4.6,1.6-9.3,2.4-14.4,2.4s-8.5-.6-11.9-1.9c-3.4-1.3-6.3-3-8.6-5.1-2.4-2.1-4.1-4.6-5.3-7.5-1.2-2.8-1.8-5.8-1.8-8.8,0-5.2,1.6-9.7,4.8-13.5,3.2-3.8,7.3-6.8,12.2-9.2,5-2.4,10.5-4.1,16.6-5.2,6.1-1.1,12-1.6,17.9-1.6,0-4.7-1.3-8.6-4-11.5-2.7-3-6.6-4.5-11.7-4.5s-5.7.5-7.5,1.4c-1.9.9-3.6,2-5.1,3.1-1.5,1.2-3.1,2.2-4.7,3.1-1.6.9-3.7,1.4-6.2,1.4s-3.8-.5-5-1.6c-1.3-1.1-1.9-2.6-1.9-4.6"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M301.5,97.6c0-5.9,1-11.3,3.1-16.2,2.1-4.9,4.9-9.2,8.6-12.7,3.6-3.6,7.9-6.3,12.9-8.3,5-2,10.4-3,16.2-3s7.2.4,10.8,1.3c3.5.9,6.6,2.1,9.3,3.5,2.7,1.5,4.9,3.2,6.5,5.2,1.6,2,2.4,4.1,2.4,6.3s-.9,4.1-2.7,5.5c-1.8,1.4-4.2,2-7.2,2s-4.1-.8-5.3-2.4c-1.2-1.6-2.4-3.4-3.5-5.3-1.1-1.9-2.4-3.6-4-5.3-1.6-1.6-3.9-2.4-7.1-2.4s-5.2.8-7.5,2.3c-2.3,1.5-4.2,3.7-5.9,6.5-1.7,2.8-3,6.2-3.8,10-.9,3.9-1.3,8.2-1.3,12.9s.6,7.9,1.8,11.2c1.2,3.3,2.8,6.1,4.8,8.4,2,2.3,4.3,4.1,6.9,5.3,2.6,1.2,5.4,1.8,8.3,1.8s6.9-.6,9.4-1.9c2.5-1.3,4.7-2.6,6.4-4.2,1.8-1.5,3.3-2.9,4.6-4.2,1.3-1.3,2.6-1.9,4-1.9s2,.3,2.7,1c.8.7,1.2,1.6,1.2,2.7,0,1.7-.8,3.6-2.5,5.9-1.7,2.3-4,4.4-6.9,6.4-2.9,2-6.4,3.8-10.4,5.2-4,1.4-8.4,2.1-13.1,2.1s-10.7-.9-15.5-2.7c-4.8-1.8-8.9-4.4-12.3-7.8-3.5-3.3-6.2-7.4-8.2-12-2-4.7-3-9.8-3-15.5"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M423.2,65.9c-3.4,0-6.3.7-8.9,2.2-2.6,1.5-4.9,3.5-6.8,6.1-1.9,2.6-3.3,5.8-4.3,9.4-1,3.7-1.5,7.7-1.5,12.1v.9c3.5-.3,7.1-.9,11-1.7,3.9-.8,7.4-2,10.7-3.5,3.2-1.5,5.9-3.4,8.1-5.7,2.1-2.4,3.2-5.3,3.2-8.7s-.9-5.9-2.7-8c-1.8-2.1-4.7-3.1-8.7-3.1M380,98.4c0-5.7.9-11,2.7-15.9,1.8-5,4.5-9.3,8.2-13,3.7-3.7,8.3-6.6,13.9-8.8,5.6-2.1,12.2-3.2,19.9-3.2s6.8.4,10.4,1.2c3.6.8,6.8,2,9.8,3.8,3,1.7,5.4,4,7.4,6.8,1.9,2.8,2.9,6.1,2.9,10s-1.6,9-4.9,12.2c-3.3,3.2-7.5,5.8-12.6,7.7-5.1,1.9-10.8,3.4-16.9,4.3-6.1.9-12,1.6-17.7,1.9.5,3.1,1.5,5.9,2.9,8.3,1.4,2.4,3.1,4.4,5.2,6,2,1.6,4.2,2.8,6.6,3.6,2.4.8,4.7,1.2,7.1,1.2s5-.3,7.2-.9c2.2-.6,4.2-1.3,6-2.3,1.8-.9,3.5-2,4.9-3.1,1.5-1.1,2.8-2.2,3.9-3.2,1-1,2-1.9,2.8-2.4.8-.6,1.8-.9,3-.9,2.4,0,3.6,1.2,3.6,3.6s-1,4-3,6.4c-2,2.4-4.7,4.6-8,6.7-3.4,2-7.2,3.8-11.5,5.2-4.3,1.4-8.9,2.1-13.7,2.1s-10.9-.9-15.8-2.8c-4.9-1.9-9.1-4.5-12.7-7.8-3.6-3.3-6.4-7.2-8.5-11.8-2-4.6-3.1-9.5-3.1-14.8"}),a.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M464.7,123.7c0-6.5,5.3-11.8,11.8-11.8s11.8,5.3,11.8,11.8-5.3,11.8-11.8,11.8-11.8-5.3-11.8-11.8"})]}),CE=({onClick:e})=>a.jsx("div",{className:"flex h-[80px] min-h-[80px] cursor-pointer items-center justify-center border-b",onClick:e,children:a.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-full",children:SE})}),EE=()=>{const{currentTheme:e,toggleTheme:t}=Xu(),n=`Toggle theme (currently ${e})`;return a.jsxs(Pi,{children:[a.jsx(Li,{asChild:!0,children:a.jsx("button",{type:"button",onClick:t,className:"relative mx-auto flex w-full cursor-pointer flex-col items-center bg-[var(--color-primary-w100)] px-3 py-5 text-xs text-[var(--color-primary-text-w10)] transition-colors hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":n,title:n,children:a.jsx(Zl,{className:"mb-1 h-6 w-6"})})}),a.jsx(Di,{side:"right",children:n})]})},TE=({items:e,bottomItems:t,activeItem:n,onItemClick:r})=>a.jsxs("nav",{className:"flex flex-1 flex-col",role:"navigation","aria-label":"Main navigation",children:[a.jsx("ul",{className:"space-y-1",children:e.map(o=>a.jsxs("li",{children:[a.jsx(Rl,{item:o,isActive:n===o.id,onItemClick:r}),o.showDividerAfter&&a.jsx("div",{className:"mx-4 my-3 border-t border-[var(--color-secondary-w70)]"})]},o.id))}),t&&t.length>0&&a.jsx("div",{className:"flex-1"}),t&&t.length>0&&a.jsx("ul",{className:"space-y-1",children:t.map(o=>a.jsx("li",{className:"my-4",children:o.id==="theme-toggle"?a.jsx(EE,{}):a.jsx(Rl,{item:o,isActive:n===o.id,onItemClick:r},o.id)},o.id))})]}),Rl=({item:e,isActive:t,onItemClick:n})=>{const{id:r,label:o,icon:s,disabled:i}=e,l=()=>{!i&&n&&n(r)},c=d=>{(d.key==="Enter"||d.key===" ")&&l()};return a.jsxs(Pi,{children:[a.jsx(Li,{asChild:!0,children:a.jsxs("button",{type:"button",onClick:n?l:void 0,onKeyDown:n?c:void 0,disabled:i,className:Ee("relative mx-auto flex w-full cursor-pointer flex-col items-center border-l-4 border-[var(--color-primary-w100)] px-3 py-5 text-xs transition-colors","bg-[var(--color-primary-w100)] hover:bg-[var(--color-primary-w90)]","text-[var(--color-primary-text-w10)] hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)]","disabled:cursor-not-allowed disabled:opacity-50",t?"border-l-4 border-[var(--color-brand-wMain)] bg-[var(--color-primary-w90)]":""),"aria-label":o,"aria-current":t?"page":void 0,children:[a.jsx(s,{className:Ee("mb-1 h-6 w-6",t&&"text-[var(--color-brand-wMain)]")}),a.jsx("span",{className:"text-center text-[13px] leading-tight",children:o})]})}),a.jsx(Di,{side:"right",children:o})]})},Pl=[{id:"chat",label:"Chat",icon:Wl},{id:"agentMesh",label:"Agents",icon:Jl}],Ll=[{id:"theme-toggle",label:"Theme",icon:Zl,onClick:()=>{}}],Sp=({title:e,breadcrumbs:t,tabs:n,buttons:r,leadingAction:o})=>a.jsxs("div",{className:"relative flex max-h-[80px] min-h-[80px] w-full items-center border-b px-8",children:[t&&t.length>0&&a.jsx("div",{className:"absolute top-1 left-8 flex h-8 items-center",children:t.map((s,i)=>a.jsxs(Bt.Fragment,{children:[i>0&&a.jsx("span",{className:"mx-1",children:a.jsx(am,{size:16})}),s.onClick?a.jsx(be,{variant:"link",className:"m-0 p-0",onClick:s.onClick,children:s.label}):a.jsx("div",{children:s.label})]},i))}),o&&a.jsx("div",{className:"mr-4 flex items-center pt-[35px]",children:o}),a.jsx("div",{className:"truncate pt-[35px] text-xl text-nowrap",children:e}),n&&n.length>0&&a.jsx("div",{className:"ml-8 flex items-center pt-[35px]",role:"tablist",children:n.map((s,i)=>a.jsxs("button",{role:"tab","aria-selected":s.isActive,onClick:s.onClick,className:`relative cursor-pointer px-4 py-3 font-medium transition-colors duration-200 ${s.isActive?"border-b-2 border-[var(--color-brand-wMain)] font-semibold":""} ${i>0?"ml-6":""}`,children:[s.label,s.isActive&&a.jsx("div",{className:"absolute right-0 bottom-0 left-0 h-0.5"})]},s.id))}),a.jsx("div",{className:"flex-1"}),r&&r.length>0&&a.jsx("div",{className:"flex items-center gap-2",children:r.map((s,i)=>a.jsx(Bt.Fragment,{children:s},i))})]}),it=({label:e,value:t,icon:n,fullWidthValue:r=!1})=>t==null||typeof t=="string"&&!t.trim()?null:a.jsxs("div",{className:`mb-1.5 flex text-sm ${r?"flex-col items-start":"items-center"}`,children:[a.jsxs("div",{className:"flex w-36 flex-shrink-0 items-center text-sm font-semibold text-nowrap",children:[n&&a.jsx("span",{className:"mr-2",children:n}),e,":"]}),a.jsx("div",{className:`text-accent-foreground text-sm ${r?"mt-1 w-full":"truncate"}`,title:typeof t=="string"?t:void 0,children:t})]}),AE=({agent:e,isExpanded:t,onToggleExpand:n})=>{const r=l=>!l||Object.keys(l).length===0?a.jsx("span",{className:"text-sm",children:"N/A"}):a.jsx("ul",{className:"list-inside list-disc pl-1",children:Object.entries(l).map(([c,d])=>a.jsxs("li",{className:"text-sm",children:[a.jsxs("span",{className:"capitalize",children:[c.replace(/_/g," "),":"]})," ",d?"Yes":"No"]},c))}),o=(l,c="None")=>!l||l.length===0?a.jsx("span",{children:c}):l.map(d=>a.jsx("span",{className:"mr-1 mb-1 inline-block rounded-full px-2 py-0.5 text-xs font-medium",children:d},d)),s=l=>!l||l.length===0?a.jsx("span",{children:"No skills listed"}):a.jsx("div",{className:"space-y-1",children:l.map(c=>a.jsxs("div",{className:"rounded p-1.5 text-xs",children:[a.jsx("p",{className:"font-semibold",children:c.name}),a.jsx("p",{children:c.description})]},c.id||c.name))}),i=l=>!l||l.length===0?a.jsx("span",{children:"No tools listed"}):a.jsx("div",{className:"space-y-1",children:l.map(c=>a.jsxs("div",{className:"rounded p-1.5 text-xs",children:[a.jsx("p",{className:"text-foreground font-semibold",children:c.name}),a.jsx("p",{className:"mb-1",children:c.description})]},c.name))});return a.jsx("div",{className:"bg-card h-[400px] w-full flex-shrink-0 cursor-pointer rounded-lg sm:w-[380px]",onClick:n,role:"button",tabIndex:0,"aria-expanded":t,children:a.jsxs("div",{className:`transform-style-preserve-3d relative h-full w-full transition-transform duration-700 ${t?"rotate-y-180":""}`,style:{transformStyle:"preserve-3d"},children:[a.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(0deg)"},children:[a.jsx("div",{className:"flex items-center p-4",children:a.jsxs("div",{className:"flex min-w-0 items-center",children:[a.jsx(Jl,{className:"mr-3 h-8 w-8 flex-shrink-0 text-[var(--color-brand-wMain)]"}),a.jsx("div",{className:"min-w-0",children:a.jsx("h2",{className:"truncate text-xl font-semibold",title:e.name,children:e.displayName||e.name})})]})}),a.jsxs("div",{className:"scrollbar-themed flex-grow space-y-3 overflow-y-auto p-4",children:[a.jsx("div",{className:"mb-2 line-clamp-4 text-base",children:e.description||"No description provided."}),a.jsx(it,{label:"Version",value:e.version,icon:a.jsx(ma,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&a.jsx(it,{label:"Key Capabilities",value:r(e.capabilities),icon:a.jsx(ha,{size:14}),fullWidthValue:!0})]}),a.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for details"})]}),a.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[a.jsx("div",{className:"flex items-center p-3",children:a.jsxs("h3",{className:"text-md truncate font-semibold",title:e.name,children:["Details: ",e.displayName||e.name]})}),a.jsxs("div",{className:"scrollbar-themed flex-grow space-y-1.5 overflow-y-auto p-3 text-xs",children:[a.jsx(it,{label:"Name",value:e.name,icon:a.jsx(vi,{size:14})}),a.jsx(it,{label:"Description",value:e.description,icon:a.jsx(lm,{size:14}),fullWidthValue:!0}),a.jsx(it,{label:"Version",value:e.version,icon:a.jsx(ma,{size:14})}),a.jsx(it,{label:"Endpoint",value:e.url||"N/A",icon:a.jsx(Xl,{size:14})}),a.jsx(it,{label:"Docs",value:e.documentationUrl?a.jsx("a",{href:e.documentationUrl,target:"_blank",rel:"noopener noreferrer",className:"break-all",children:"View Docs"}):"N/A",icon:a.jsx(Bl,{size:14})}),e.provider&&a.jsxs("div",{className:"mt-1.5 border-t pt-1.5",children:[a.jsx("h4",{className:"mb-0.5 text-xs font-semibold",children:"Provider"}),a.jsx(it,{label:"Name",value:e.provider.organization}),a.jsx(it,{label:"URL",value:e.provider.url||"N/A"})]}),a.jsx(it,{label:"Capabilities",value:r(e.capabilities),icon:a.jsx(ha,{size:14}),fullWidthValue:!0}),a.jsx(it,{label:"Input Modes",value:o(e.defaultInputModes),icon:a.jsx(ga,{size:14}),fullWidthValue:!0}),a.jsx(it,{label:"Output Modes",value:o(e.defaultOutputModes),icon:a.jsx(ga,{size:14}),fullWidthValue:!0}),a.jsx(it,{label:"Skills",value:s(e.skills),icon:a.jsx(cm,{size:14}),fullWidthValue:!0}),a.jsx(it,{label:"Tools Info",value:i(e.tools),icon:a.jsx(Hl,{size:14}),fullWidthValue:!0}),a.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:a.jsx(it,{label:"A2A Protocol",value:e.protocolVersion})})]}),a.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for summary"})]})]})})},ui=({agents:e})=>{const[t,n]=u.useState(null),[r,o]=u.useState(""),s=l=>{n(c=>c===l?null:l)},i=e.filter(l=>{var c;return(c=l.displayName||l.name)==null?void 0:c.toLowerCase().includes(r.toLowerCase())});return a.jsx("div",{children:e.length===0?a.jsx("div",{className:"flex h-[calc(100vh-250px)] items-center justify-center",children:"No agents discovered in the current namespace."}):a.jsxs("div",{className:"mx-auto mt-[50px] ml-[50px]",children:[a.jsx("div",{className:"my-4",children:a.jsx("input",{type:"text","data-testid":"agent-search-input",placeholder:"Search...",value:r,onChange:l=>o(l.target.value),className:"bg-background rounded-md border px-3 py-2"})}),i.length===0&&r?a.jsxs("div",{className:"flex h-[calc(100vh-250px)] flex-col items-center justify-center gap-6",children:["No agents match your search.",a.jsx(be,{variant:"outline",title:"Clear Search",onClick:()=>o(""),children:"Clear Search"})]}):a.jsx("div",{className:"max-h-[calc(100vh-250px)] overflow-y-auto",children:a.jsx("div",{className:"flex flex-wrap gap-10",children:i.map(l=>a.jsx(AE,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>s(l.name)},l.name))})})]})})},Cp={LAYOUT:"layout"};class NE{constructor(){ca(this,"_plugins",{});this.registerDefaultPlugins()}get plugins(){return Object.values(this._plugins)}registerPlugin(t){this._plugins[t.id]&&console.warn(`Plugin with ID ${t.id} already exists. Overwriting.`),this._plugins[t.id]=t}getPluginById(t){return this._plugins[t]}getPluginsByType(t){return Object.values(this._plugins).filter(n=>n.type===t)}registerDefaultPlugins(){this.registerPlugin({type:Cp.LAYOUT,id:"cards",label:"Cards",icon:um,priority:100,render:t=>a.jsx(ui,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}const Ep=new NE,kE=({currentLayout:e,onLayoutChange:t,className:n=""})=>{const r=Ep.getPluginsByType(Cp.LAYOUT);return r&&r.length>1?a.jsxs("div",{className:`flex items-center space-x-1 ${n}`,children:[a.jsx("span",{className:"text-sm font-semibold",children:"Layout:"}),a.jsx("div",{className:"flex gap-1 rounded-sm p-1",children:r.map(o=>{const s=o.icon,i=e===o.id;return a.jsxs(be,{variant:"ghost",size:"sm",onClick:()=>t(o.id),title:o.label,className:i?"bg-[var(--color-secondary-w20)] dark:bg-[var(--color-secondary-w80)]":"",children:[s&&a.jsx(s,{size:14}),a.jsx("span",{children:o.label})]},o.id)})})]}):null},Dl={CARDS:"cards"};function _E(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=He(),[o,s]=u.useState("cards");if(t)return a.jsx("div",{className:"space-y-6",children:a.jsx("div",{className:"flex h-96 items-center justify-center",children:a.jsx("div",{children:"Loading agents..."})})});if(n)return a.jsx("div",{className:"space-y-6",children:a.jsx("div",{className:"flex h-96 items-center justify-center",children:a.jsx(ra,{variant:"error",message:`Error loading agents. ${n}`})})});const i=()=>{if(o===Dl.CARDS)return a.jsx(ui,{agents:e});const l=Ep.getPluginById(o);return l?l.render({agents:e}):(console.warn(`Layout ${o} not found, falling back to cards layout`),a.jsx(ui,{agents:e}))};return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(Sp,{title:"Agents",buttons:[a.jsxs(be,{variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[a.jsx(Yl,{className:"size-4"}),"Refresh Agents"]})]}),a.jsxs("div",{className:`relative flex-1 p-4 ${o===Dl.CARDS?"":"bg-[var(--muted)] dark:bg-[var(--color-bg-wMain)]"}`,children:[a.jsx("div",{className:"absolute right-8 z-20 flex items-center space-x-4",children:a.jsx(kE,{currentLayout:o,onLayoutChange:s})}),i()]})]})}const IE=({isOpen:e,onClose:t,onConfirm:n,sessionName:r})=>e?a.jsx(Go,{open:e,onOpenChange:t,children:a.jsxs(Vo,{children:[a.jsxs(Yo,{children:[a.jsx(Ko,{children:"Delete Chat Session?"}),a.jsxs(qo,{children:["This action cannot be undone. This chat session and any associated artifacts will be permanently deleted: ",a.jsx("strong",{children:r})]})]}),a.jsxs(Nv,{children:[a.jsx(be,{variant:"outline",onClick:t,title:"Cancel",children:"Cancel"}),a.jsx(be,{onClick:n,title:"Delete",children:"Delete"})]})]})}):null,co=4,di={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},jE={chatPanelSizes:{...di.chatPanelSizes,min:50},sidePanelSizes:{...di.sidePanelSizes,max:50}};function ME(){var B;const{agents:e,sessionId:t,messages:n,setMessages:r,selectedAgentName:o,setSelectedAgentName:s,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,openSidePanelTab:c,setTaskIdInSidePanel:d,isResponding:f,latestStatusText:p,sessionToDelete:m,closeSessionDeleteModal:g,confirmSessionDelete:x,sessionName:h}=He(),{isTaskMonitorConnected:v,isTaskMonitorConnecting:b,taskMonitorSseError:w,connectTaskMonitorStream:y}=Gi(),[E,A]=u.useState(!0),[I,k]=u.useState(!1),[T,Y]=u.useState(!1),X=u.useRef(null),W=u.useRef(null),q=u.useRef(null),{chatPanelSizes:ee,sidePanelSizes:F}=u.useMemo(()=>E?di:jE,[E]),Z=u.useCallback(L=>{if(k(!0),W.current)if(L)W.current.resize(co);else{const H=q.current||F.default;W.current.resize(H)}setTimeout(()=>k(!1),300)},[F.default]),N=u.useCallback(()=>{l(!0)},[l]),j=u.useCallback(()=>{l(!1)},[l]),C=u.useCallback(L=>{L>co+1&&(q.current=L)},[]),M=u.useCallback(()=>{A(!E)},[E]);u.useEffect(()=>{W.current&&i&&W.current.resize(co);const L=()=>{if(W.current&&i){k(!0);const H=q.current||F.default;W.current.resize(H),l(!1),setTimeout(()=>k(!1),300)}};return window.addEventListener("expand-side-panel",L),()=>{window.removeEventListener("expand-side-panel",L)}},[i,l,F.default]),u.useEffect(()=>{if(!o&&e.length>0){const L=e.find(J=>J.name==="OrchestratorAgent"),H=L?L.name:e[0].name;s(H);const _=e.find(J=>J.name===H),G=_!=null&&_.displayName?`Hi! I'm the ${_==null?void 0:_.displayName} Agent. How can I help?`:`Hi! I'm ${H}. How can I help?`;r(J=>[...J.filter(ae=>!ae.isStatusBubble),{role:"agent",kind:"message",messageId:`welcome-${Date.now()}`,parts:[{kind:"text",text:G}],isUser:!1,isComplete:!0,metadata:{sessionId:t,lastProcessedEventSequence:0}}])}},[e,o,t,r,s]);const D=u.useMemo(()=>{const L=new Map;return n.forEach((H,_)=>{H.taskId&&L.set(H.taskId,_)}),L},[n]),P=u.useMemo(()=>n.find(L=>L.isStatusBubble),[n]),te=u.useMemo(()=>{if(!P||!P.parts)return null;const L=P.parts.find(H=>H.kind==="text");return(L==null?void 0:L.text)||null},[P]),O=u.useMemo(()=>{if(P!=null&&P.taskId)return()=>{d(P.taskId),c("workflow")}},[P==null?void 0:P.taskId,d,c]);return u.useEffect(()=>{const L=()=>{!v&&!b&&w&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),y())};return window.addEventListener("focus",L),()=>{window.removeEventListener("focus",L)}},[v,b,w,y]),a.jsxs("div",{className:"relative flex h-screen w-full flex-col overflow-hidden",children:[a.jsx("div",{className:`absolute top-0 left-0 z-20 h-screen transition-transform duration-300 ${E?"-translate-x-full":"translate-x-0"}`,children:a.jsx($C,{onToggle:M})}),a.jsx("div",{className:`transition-all duration-300 ${E?"ml-0":"ml-100"}`,children:a.jsx(Sp,{title:h||"New Chat",leadingAction:E?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(be,{variant:"ghost",onClick:M,className:"h-10 w-10 p-0",tooltip:"Show Sessions Panel",children:a.jsx(Kl,{className:"size-5"})}),a.jsx("div",{className:"h-6 w-px bg-gray-300 dark:bg-gray-600"}),a.jsx(be,{variant:"ghost",onClick:()=>Y(!0),className:"h-10 w-10 p-0",tooltip:"Start New Chat Session",children:a.jsx(ql,{className:"size-5"})})]}):null})}),a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsx("div",{className:`min-h-0 flex-1 overflow-x-auto transition-all duration-300 ${E?"ml-0":"ml-100"}`,children:a.jsxs(nw,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[a.jsx(rl,{defaultSize:ee.default,minSize:ee.min,maxSize:ee.max,id:"chat-panel",children:a.jsxs("div",{className:"flex h-full w-full flex-col py-6",children:[a.jsx(cf,{className:"text-base",ref:X,children:n.map((L,H)=>{var G;const _=!!(L.taskId&&D.get(L.taskId)===H);return a.jsx(CC,{message:L,isLastWithTaskId:_},`${((G=L.metadata)==null?void 0:G.sessionId)||"session"}-${H}-${L.isUser?"received":"sent"}`)})}),a.jsxs("div",{style:lf,children:[f&&a.jsx(ai,{statusText:(te||p.current)??void 0,onViewWorkflow:O}),a.jsx(rb,{agents:e,scrollToBottom:(B=X.current)==null?void 0:B.scrollToBottom})]})]})}),a.jsx(rw,{}),a.jsx(rl,{ref:W,defaultSize:F.default,minSize:F.min,maxSize:F.max,collapsedSize:co,collapsible:!0,onCollapse:N,onExpand:j,onResize:C,id:"chat-side-panel",className:I?"transition-all duration-300 ease-in-out":"",children:a.jsx("div",{className:"h-full",children:a.jsx(zC,{onCollapsedToggle:Z,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,isSidePanelTransitioning:I})})})]})})}),a.jsx(mp,{isOpen:T,onClose:()=>Y(!1)}),a.jsx(IE,{isOpen:!!m,onClose:g,onConfirm:x,sessionName:(m==null?void 0:m.name)||`Session ${m==null?void 0:m.id.substring(0,8)}`})]})}const RE=e=>({displayName:e?"Solace Dark JER":"Solace Light JER",styles:{container:{backgroundColor:"transparent",fontFamily:"monospace",fontSize:"14px"},property:e?"var(--color-primary-text-w10)":"var(--color-primary-text-wMain)",bracket:"var(--color-secondary-text-w50)",itemCount:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},string:e?"var(--color-success-w70)":"var(--color-success-wMain)",number:"var(--color-accent-n0-wMain)",boolean:e?"var(--color-warning-w70)":"var(--color-warning-wMain)",null:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},iconCollection:"var(--color-secondary-text-w50)",iconCopy:"var(--color-secondary-text-w50)"}}),fi=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=Xu(),o=u.useMemo(()=>RE(r==="dark"),[r]),s=u.useMemo(()=>t===void 0||t<0?!1:t,[t]),i=u.useMemo(()=>e===null||typeof e!="object"?{value:e}:e,[e]),l=`rounded-lg border overflow-auto ${n}`.trim();return e===void 0?a.jsx("div",{className:l,children:a.jsx("span",{className:"italic",children:"No JSON data"})}):a.jsx("div",{className:l,children:a.jsx(dm,{data:i,theme:o,viewOnly:!0,collapse:s,showStringQuotes:!0,showCollectionCount:"when-closed"})})};let uo=null,fo=null;function PE({children:e}){const{fetchCsrfToken:t}=Ku(),[n,r]=u.useState(uo),[o,s]=u.useState(!uo&&!fo),[i,l]=u.useState(fo);return u.useEffect(()=>{if(uo||fo)return;let c=!0;return(async()=>{s(!0),l(null);try{let f=await ze("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"}}),p;if(f.ok)p=await f.json();else{const x=await f.text();if(console.error("Initial config fetch failed:",f.status,x),f.status===403){console.log("Config fetch failed with 403, attempting to get CSRF token first...");const h=await t();if(!h)throw new Error("Failed to obtain CSRF token after config fetch failed.");if(console.log("Retrying config fetch with CSRF token..."),f=await ze("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":h,Accept:"application/json"}}),!f.ok){const v=await f.text();throw console.error("Config fetch retry failed:",f.status,v),new Error(`Failed to fetch config on retry: ${f.status} ${v}`)}p=await f.json()}else throw new Error(`Failed to fetch config: ${f.status} ${x}`)}const m=p.frontend_use_authorization??!1;m&&(console.log("Fetching CSRF token for config-related requests..."),await t());const g={configServerUrl:p.frontend_server_url,configAuthLoginUrl:p.frontend_auth_login_url,configUseAuthorization:m,configWelcomeMessage:p.frontend_welcome_message,configRedirectUrl:p.frontend_redirect_url,configCollectFeedback:p.frontend_collect_feedback,configBotName:p.frontend_bot_name,configFeatureEnablement:p.frontend_feature_enablement??{},frontend_use_authorization:p.frontend_use_authorization,persistenceEnabled:p.persistence_enabled??!0};c&&(uo=g,r(g)),console.log("App config processed and set:",g)}catch(f){if(console.error("Error initializing app:",f),c){const p=f.message||"Failed to load application configuration.";fo=p,l(p)}}finally{c&&s(!1)}})(),()=>{c=!1}},[t]),n?a.jsx(Wu.Provider,{value:n,children:e}):o?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Loading Configuration..."})]})}):i?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-red-100 dark:bg-red-900",children:a.jsxs("div",{className:"rounded border border-red-400 bg-white p-4 text-center dark:bg-gray-800",children:[a.jsx("h1",{className:"text-xl font-bold text-red-700 dark:text-red-300",children:"Configuration Error"}),a.jsx("p",{className:"mt-2 text-red-600 dark:text-red-200",children:i}),a.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:"Please check the backend server and network connection, then refresh the page."})]})}):a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl",children:"Initializing Application..."})]})})}const LE=({children:e})=>{const{configServerUrl:t}=rn(),n=`${t}/api/v1`,[r,o]=u.useState(null),[s,i]=u.useState(!1),[l,c]=u.useState(!1),[d,f]=u.useState(null),[p,m]=u.useState({}),[g,x]=u.useState([]),[h,v]=u.useState(null),[b,w]=u.useState(0),[y,E]=u.useState(!1),A=10,I=u.useRef(null),k=u.useRef(null),T=u.useRef(null);u.useEffect(()=>{k.current=r},[r]);const Y=u.useCallback(C=>{m(M=>{var O,B,L;const D=C.task_id;if(!D)return C.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",C),M;const P=M[D],te=new Date(C.timestamp);if(P){const H=[...P.events,C].sort((_,G)=>new Date(_.timestamp).getTime()-new Date(G.timestamp).getTime());return{...M,[D]:{...P,events:H,lastUpdated:te}}}else{let H="Task started...";if(C.direction==="request"&&((B=(O=C.full_payload)==null?void 0:O.method)!=null&&B.startsWith("message/"))){const G=C.full_payload.params;if((L=G==null?void 0:G.message)!=null&&L.parts){const J=G.message.parts.filter(Q=>Q.kind==="text"&&Q.text);J.length>0&&(H=J[J.length-1].text)}}const _={taskId:D,initialRequestText:H,events:[C],firstSeen:te,lastUpdated:te};return x(G=>[D,...G.filter(J=>J!==D)]),{...M,[D]:_}}})},[]),X=u.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),i(!1),c(!0),f(null),w(0),E(!1),T.current&&(clearTimeout(T.current),T.current=null)},[]),W=u.useCallback(C=>{try{const M=JSON.parse(C.data);Y(M)}catch(M){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",M,"Raw data:",C.data),f("Received unparseable 'a2a_message' event from server.")}},[Y]),q=u.useCallback(C=>{console.error("TaskMonitorContext: SSE connection error:",C),i(!1),c(!1),I.current&&I.current.readyState===EventSource.CLOSED?f("Task Monitor SSE connection closed by server or network issue."):f("Task Monitor SSE connection error occurred."),I.current&&(I.current.close(),I.current=null),T.current&&(clearTimeout(T.current),T.current=null)},[]),ee=u.useCallback(async()=>{if(l||s){console.warn("TaskMonitorContext: Stream is already active or connecting.");return}console.log("TaskMonitorContext: Attempting to connect stream..."),i(!0);try{const C={subscription_targets:[{type:"my_a2a_messages"}]},M=await ze(`${n}/visualization/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C),credentials:"include"});if(!M.ok){const L=await M.json().catch(()=>({detail:"Failed to subscribe"}));if(L.error_type==="authorization_failure"){const H=L.message||"Access denied: insufficient permissions",_=L.suggested_action?` ${L.suggested_action}`:"";throw new Error(`${H}${_}`)}else if(L.error_type==="subscription_failure"){const H=L.message||"Subscription failed",_=L.suggested_action?` ${L.suggested_action}`:"";throw new Error(`${H}${_}`)}else throw new Error(L.detail||L.message||`Subscription failed: ${M.statusText}`)}const D=await M.json();o(D.stream_id);const P=D.sse_endpoint_url.startsWith("/")?`${t||""}${D.sse_endpoint_url}`:D.sse_endpoint_url;I.current&&I.current.close();const te=wi(),O=`${P}${te?`?token=${te}`:""}`,B=new EventSource(O,{withCredentials:!0});I.current=B,B.onopen=X,B.addEventListener("a2a_message",W),B.onerror=q}catch(C){console.error("TaskMonitorContext: Error connecting stream:",C),f(C instanceof Error?C.message:String(C)),i(!1),c(!1),o(null),I.current&&(I.current.close(),I.current=null),T.current&&(clearTimeout(T.current),T.current=null)}},[n,t,l,s,X,W,q]),F=u.useCallback(()=>{if(T.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(b>=A){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),E(!1),f(`Connection lost. Max reconnection attempts (${A}) reached.`);return}const C=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${b+1}/${A} in ${C}ms...`),E(!0),w(M=>M+1),T.current=setTimeout(()=>{ee()},C)},[b,ee]),Z=u.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),T.current&&(clearTimeout(T.current),T.current=null),I.current&&(I.current.close(),I.current=null);const C=k.current;if(C)try{await ze(`${n}/visualization/${C}/unsubscribe`,{method:"DELETE",credentials:"include"})}catch(M){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${C}`,M)}o(null),i(!1),c(!1),f(null),m({}),x([]),v(null),w(0),E(!1)},[n]);u.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),I.current&&(I.current.close(),I.current=null);const C=k.current;if(C)if(navigator.sendBeacon){const M=new FormData;navigator.sendBeacon(`${n}/visualization/${C}/unsubscribe`,M)}else ze(`${n}/visualization/${C}/unsubscribe`,{method:"DELETE",credentials:"include",keepalive:!0}).catch(M=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",M))},[n]),u.useEffect(()=>{!l&&!s&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),ee())},[]),u.useEffect(()=>{!l&&!s&&d&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),F())},[l,s,d,F]),u.useEffect(()=>()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]);const N=u.useCallback(C=>{v(C)},[]),j={isTaskMonitorConnecting:s,isTaskMonitorConnected:l,taskMonitorSseError:d,monitoredTasks:p,monitoredTaskOrder:g,highlightedStepId:h,isReconnecting:y,reconnectionAttempts:b,connectTaskMonitorStream:ee,disconnectTaskMonitorStream:Z,setHighlightedStepId:N};return a.jsx(Vu.Provider,{value:j,children:e})},DE=1*1024*1024,OE=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result.split(",")[1]),r.onerror=o=>n(o)}),FE=({children:e})=>{const{configWelcomeMessage:t,configServerUrl:n,persistenceEnabled:r}=rn(),o=u.useMemo(()=>`${n}/api/v1`,[n]),[s,i]=u.useState(""),[l,c]=u.useState([]),[d,f]=u.useState(""),[p,m]=u.useState(!1),[g,x]=u.useState([]),[h,v]=u.useState(null),b=u.useRef(null),[w,y]=u.useState(""),[E,A]=u.useState(!1),[I,k]=u.useState(null),T=u.useRef(null),Y=u.useRef(!1),X=u.useRef(null),W=u.useRef(0),q=u.useRef(E);u.useEffect(()=>{q.current=E},[E]);const{agents:ee,error:F,isLoading:Z,refetch:N}=hw(),{artifacts:j,isLoading:C,refetch:M}=gw(s),[D,P]=u.useState(!0),[te,O]=u.useState("files"),[B,L]=u.useState(!1),[H,_]=u.useState(null),[G,J]=u.useState(!1),[Q,ae]=u.useState(new Set),[se,ue]=u.useState(!1),[he,ke]=u.useState(null),[Pe,De]=u.useState(null),[Me,Be]=u.useState(null),[wt,We]=u.useState(null),[bt,et]=u.useState(null),[tt,nt]=u.useState(null),le=u.useCallback(($,U)=>{x(z=>{if(z.find(ge=>ge.message===$))return z;const de=Date.now().toString(),pe={id:de,message:$,type:U||"info"};return setTimeout(()=>{x(ge=>ge.filter(xe=>xe.id!==de))},3e3),[...z,pe]})},[]),It=u.useCallback(async $=>{const U=await ze(`${o}/sessions/${$}/messages`);if(!U.ok){const z=await U.json().catch(()=>({detail:"Failed to fetch session history"}));throw new Error(z.detail||`HTTP error ${U.status}`)}return U.json()},[o]),yt=u.useCallback(async $=>{const U=new FormData;U.append("file",$);try{const z=await ze(`${o}/artifacts/${s}/${encodeURIComponent($.name)}`,{method:"POST",body:U,credentials:"include"});if(!z.ok){const de=await z.json().catch(()=>({detail:`Failed to upload ${$.name}`}));throw new Error(de.detail||`HTTP error ${z.status}`)}const ie=await z.json();return le(`Artifact "${$.name}" uploaded successfully.`),await M(),ie.uri||null}catch(z){return le(`Error uploading artifact "${$.name}": ${z instanceof Error?z.message:"Unknown error"}`),null}},[o,s,le,M]),jt=u.useCallback(async $=>{try{const U=await ze(`${o}/artifacts/${s}/${encodeURIComponent($)}`,{method:"DELETE",credentials:"include"});if(!U.ok&&U.status!==204){const z=await U.json().catch(()=>({detail:`Failed to delete ${$}`}));throw new Error(z.detail||`HTTP error ${U.status}`)}le(`File "${$}" deleted successfully.`),M()}catch(U){le(`Error deleting file "${$}": ${U instanceof Error?U.message:"Unknown error"}`)}},[o,s,le,M]),Mt=u.useCallback($=>{_($),L(!0)},[]),St=u.useCallback(()=>{_(null),L(!1)},[]),Ct=u.useCallback(async()=>{H&&await jt(H.filename),St()},[H,jt,St]),Et=u.useCallback(()=>{if(Q.size===0){le("No files selected for deletion.");return}ue(!0)},[Q,le]),Xe=u.useCallback(async()=>{ue(!1);const $=Array.from(Q);let U=0,z=0;for(const ie of $)try{const de=await ze(`${o}/artifacts/${encodeURIComponent(ie)}`,{method:"DELETE",credentials:"include"});if(!de.ok&&de.status!==204)throw new Error(`Failed to delete ${ie}`);U++}catch(de){console.error(de),z++}U>0&&le(`${U} files(s) deleted successfully.`),z>0&&le(`Failed to delete ${z} files(s).`),M(),ae(new Set),J(!1)},[Q,o,le,M]),dt=u.useCallback(async $=>{De(null),Be(null),We(null);try{const U=await ze(`${o}/artifacts/${s}/${encodeURIComponent($)}/versions`,{credentials:"include"});if(!U.ok)throw new Error("Error fetching version list");const z=await U.json();if(!z||z.length===0)throw new Error("No versions available");De(z.sort((ne,we)=>ne-we));const ie=Math.max(...z);Be(ie);const de=await ze(`${o}/artifacts/${s}/${encodeURIComponent($)}/versions/${ie}`,{credentials:"include"});if(!de.ok)throw new Error("Error fetching latest version content");const pe=await de.blob(),ge=await new Promise((ne,we)=>{const _e=new FileReader;_e.onloadend=()=>{var K;return ne(((K=_e.result)==null?void 0:K.toString().split(",")[1])||"")},_e.onerror=we,_e.readAsDataURL(pe)}),xe=j.find(ne=>ne.filename===$),Ie={name:$,mime_type:(xe==null?void 0:xe.mime_type)||"application/octet-stream",content:ge,last_modified:(xe==null?void 0:xe.last_modified)||new Date().toISOString()};return We(Ie),Ie}catch(U){return le(`Error loading preview for ${$}: ${U instanceof Error?U.message:"Unknown error"}`),null}},[o,s,j,le]),Rt=u.useCallback(async($,U)=>{if(!Pe||!Pe.includes(U))return le(`Version ${U} is not available for ${$}.`),null;We(null);try{const z=await ze(`${o}/artifacts/${s}/${encodeURIComponent($)}/versions/${U}`,{credentials:"include"});if(!z.ok)throw new Error(`Error fetching version ${U}`);const ie=await z.blob(),de=await new Promise((xe,Ie)=>{const ne=new FileReader;ne.onloadend=()=>{var we;return xe(((we=ne.result)==null?void 0:we.toString().split(",")[1])||"")},ne.onerror=Ie,ne.readAsDataURL(ie)}),pe=j.find(xe=>xe.filename===$),ge={name:$,mime_type:(pe==null?void 0:pe.mime_type)||"application/octet-stream",content:de,last_modified:(pe==null?void 0:pe.last_modified)||new Date().toISOString()};return Be(U),We(ge),ge}catch(z){return le(`Error loading version ${U}: ${z instanceof Error?z.message:"Unknown error"}`),null}},[o,le,j,Pe,s]),Pt=u.useCallback($=>{le(`Loading preview for attached file: ${$.name}`),We($),De(null),Be(null)},[le]),on=u.useCallback($=>{P(!1),O($),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:$}}))},[]),Le=u.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null),b.current&&(b.current.close(),b.current=null),Y.current=!1},[]),Ge=u.useCallback($=>{var _e;W.current+=1;const U=W.current;let z;try{console.log("TEST-SSE ChatProvider Raw Message:",$.data),z=JSON.parse($.data)}catch(K){console.error("Failed to parse SSE message:",K),le("Received unparseable agent update.","error");return}if("error"in z&&z.error){const S=`Error: ${z.error.message}`;c(R=>{const V=R.filter(me=>!me.isStatusBubble);return V.push({role:"agent",parts:[{kind:"text",text:S}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${crypto.randomUUID()}`,lastProcessedEventSequence:U}}),V}),m(!1),Le(),v(null);return}if(!("result"in z)||!z.result){console.warn("Received SSE message without a result or error field.",z);return}const ie=z.result;let de=!1,pe,ge,xe;switch(ie.kind){case"task":de=!0,pe=void 0,xe=ie.id,ie.artifacts&&ie.artifacts.length>0&&console.log("Final task has artifacts to process:",ie.artifacts);break;case"status-update":de=ie.final,pe=(_e=ie.status)==null?void 0:_e.message,xe=ie.taskId;break;case"artifact-update":ge=ie.artifact,xe=ie.taskId;break;default:console.warn("Received unknown result kind in SSE message:",ie);return}const Ie=[],ne=[];let we=null;if(pe!=null&&pe.parts)for(const K of pe.parts)if(K.kind==="data"){const S=K.data;if(S&&typeof S=="object"&&"type"in S)switch(S.type){case"agent_progress_update":we=String((S==null?void 0:S.status_text)??"Processing...");break;case"artifact_creation_progress":we=`Saving artifact: ${String((S==null?void 0:S.filename)??"unknown file")} (${Number((S==null?void 0:S.bytes_saved)??0)} bytes)`;break;case"tool_invocation_start":break;default:Ie.push(K)}}else if(K.kind==="file"){const R=K.file,V={name:R.name||"untitled_file",mime_type:R.mimeType};"bytes"in R&&R.bytes?V.content=R.bytes:"uri"in R&&R.uri&&(V.uri=R.uri),ne.push(V)}else Ie.push(K);we&&(X.current=we),c(K=>{var Re;const S=[...K];let R=S[S.length-1];R!=null&&R.isStatusBubble&&(S.pop(),R=S[S.length-1]);const V=Ie.find(fe=>fe.kind==="text"),me=Ie.filter(fe=>fe.kind!=="text");if(R&&!R.isUser&&!R.isComplete&&R.taskId===ie.taskId&&(V||ne.length>0)){const fe={...R,parts:[...R.parts],files:R.files?[...R.files]:[],isComplete:de||ne.length>0,metadata:{...R.metadata,lastProcessedEventSequence:U}};if(V){const ye=fe.parts[fe.parts.length-1];(ye==null?void 0:ye.kind)==="text"?fe.parts[fe.parts.length-1]={...ye,text:ye.text+V.text}:fe.parts.push(V)}me.length>0&&fe.parts.push(...me),ne.length>0&&fe.files.push(...ne),S[S.length-1]=fe}else if(Ie.some(ye=>ye.kind==="text"&&ye.text.trim())||ne.length>0||ge){const ye={role:"agent",parts:Ie,files:ne.length>0?ne:void 0,taskId:ie.taskId,isUser:!1,isComplete:de||ne.length>0,metadata:{messageId:((Re=z.id)==null?void 0:Re.toString())||`msg-${crypto.randomUUID()}`,sessionId:ie.contextId,lastProcessedEventSequence:U}};ge&&(ye.artifactNotification={name:ge.name||ge.artifactId}),S.push(ye)}if(!de&&X.current)S.push({role:"agent",parts:[{kind:"text",text:X.current}],taskId:ie.taskId,isUser:!1,isStatusBubble:!0,isComplete:!1,metadata:{messageId:`status-${crypto.randomUUID()}`,lastProcessedEventSequence:U}});else if(de){X.current=null;const fe=S.findLastIndex(ye=>!ye.isUser&&ye.taskId===xe);fe!==-1&&(S[fe]={...S[fe],isComplete:!0,metadata:{...S[fe].metadata,lastProcessedEventSequence:U}})}return S}),de&&(q.current&&(le("Task successfully cancelled."),T.current&&clearTimeout(T.current),A(!1)),m(!1),Le(),v(null),Y.current=!0,M(),setTimeout(()=>{Y.current=!1},100))},[le,Le,M]),Lt=u.useCallback(async()=>{const $="ChatProvider.handleNewSession:";if(console.log(`${$} Starting new session process...`),Le(),p&&h&&w&&!E){console.log(`${$} Cancelling current task ${h}`);try{const z={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:h}};ze(`${o}/tasks/${h}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z),credentials:"include"})}catch(z){console.warn(`${$} Failed to cancel current task:`,z)}}T.current&&(clearTimeout(T.current),T.current=null),A(!1),console.log(`${$} Resetting session state - new session will be created when first message is sent`),i(""),et(null),c(t?[{parts:[{kind:"text",text:t}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}]:[]),f(""),m(!1),v(null),k(null),ke(null),Y.current=!1,X.current=null,W.current=0,console.log(`${$} Refreshing artifacts for new session...`),await M(),le("New session started successfully."),console.log(`${$} New session setup complete - session will be created on first message.`)},[o,p,h,w,E,t,le,M,Le]),mt=u.useCallback(async $=>{const U="ChatProvider.handleSwitchSession:";if(console.log(`${U} Switching to session ${$}...`),Le(),p&&h&&w&&!E){console.log(`${U} Cancelling current task ${h}`);try{const z={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:h}};await ze(`${o}/tasks/${h}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z),credentials:"include"})}catch(z){console.warn(`${U} Failed to cancel current task:`,z)}}T.current&&(clearTimeout(T.current),T.current=null),A(!1);try{const ie=(await It($)).map(pe=>({parts:[{kind:"text",text:pe.message}],isUser:pe.senderType==="user",isComplete:!0,role:pe.senderType==="user"?"user":"agent",metadata:{sessionId:pe.sessionId,messageId:pe.id,lastProcessedEventSequence:0}})),de=await ze(`${o}/sessions/${$}`);if(de.ok){const pe=await de.json();et(pe.name)}i($),c(ie),f(""),m(!1),v(null),k(null),ke(null),Y.current=!1,X.current=null,W.current=0}catch(z){console.error(`${U} Failed to fetch session history:`,z),le("Error switching session. Please try again.","error")}},[Le,p,h,w,E,o,le,It]),Dt=u.useCallback(async($,U,z=!0)=>{if(r)try{const ie=await ze(`${o}/sessions/${$}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:U})});if(!ie.ok){const de=await ie.json().catch(()=>({detail:"Failed to update session name"}));throw new Error(de.detail||`HTTP error ${ie.status}`)}z&&le("Session name updated successfully."),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(ie){le(`Error updating session name: ${ie instanceof Error?ie.message:"Unknown error"}`)}},[o,r,le]),Ot=u.useCallback(async $=>{try{const U=await ze(`${o}/sessions/${$}`,{method:"DELETE"});if(!U.ok){const z=await U.json().catch(()=>({detail:"Failed to delete session"}));throw new Error(z.detail||`HTTP error ${U.status}`)}le("Session deleted successfully."),$===s&&Lt(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(U){le(`Error deleting session: ${U instanceof Error?U.message:"Unknown error"}`)}},[o,le,Lt,s]),Oe=u.useCallback($=>{nt($)},[]),ft=u.useCallback(()=>{nt(null)},[]),sn=u.useCallback(async()=>{tt&&(await Ot(tt.id),nt(null))},[tt,Ot]),Vt=u.useCallback(async()=>{if(!p&&!E||!h){le("No active task to cancel.");return}if(E){le("Cancellation already in progress.");return}le(`Requesting cancellation for task ${h}...`),A(!0);try{const $={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:h}},U=await ze(`${o}/tasks/${h}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(U.status===202)T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{le(`Cancellation for task ${h} timed out. Allowing new input.`),A(!1),m(!1),Le(),v(null),T.current=null,c(z=>z.filter(ie=>!ie.isStatusBubble))},15e3);else{const z=await U.json().catch(()=>({detail:"Unknown cancellation error"}));le(`Failed to request cancellation: ${z.detail||U.statusText}`),A(!1)}}catch($){le(`Error sending cancellation request: ${$ instanceof Error?$.message:"Network error"}`),A(!1)}},[p,E,h,o,le,Le]),Tt=u.useCallback(()=>{},[]),Ft=u.useCallback(()=>{p&&!Y.current&&!q.current&&le("Connection error with agent updates."),Y.current||(m(!1),q.current||(Le(),v(null)),X.current=null),c($=>$.filter(U=>!U.isStatusBubble).map((U,z,ie)=>z===ie.length-1&&!U.isUser?{...U,isComplete:!0}:U))},[le,Le,p]),Yt=u.useCallback(async($,U,z)=>{console.log("handleSubmit: using sessionId",s),$.preventDefault();const ie=(z==null?void 0:z.trim())||d.trim(),de=U||[];if(!ie&&de.length===0||p||E||!w){w||le("Please select an agent first."),E&&le("Cannot send new message while a task is being cancelled.");return}Le(),Y.current=!1,m(!0),v(null),X.current=null,W.current=0;const pe={role:"user",parts:[{kind:"text",text:ie}],isUser:!0,uploadedFiles:de.length>0?de:void 0,metadata:{messageId:`msg-${crypto.randomUUID()}`,sessionId:s,lastProcessedEventSequence:0}};X.current="Thinking",c(ge=>[...ge,pe]),f("");try{const ge=de.map(async me=>{if(me.size<DE)return{kind:"file",file:{bytes:await OE(me),name:me.name,mimeType:me.type}};{const Re=await yt(me);return Re?{kind:"file",file:{uri:Re,name:me.name,mimeType:me.type}}:(le(`Failed to upload large file: ${me.name}`,"error"),null)}}),xe=(await Promise.all(ge)).filter(me=>me!==null),Ie=[];if(ie&&Ie.push({kind:"text",text:ie}),Ie.push(...xe),Ie.length===0)throw new Error("Cannot send an empty message.");console.log(`ChatProvider handleSubmit: Using sessionId for contextId: ${s}`);const ne={role:"user",parts:Ie,messageId:`msg-${crypto.randomUUID()}`,kind:"message",contextId:s,metadata:{agent_name:w}},we={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"message/stream",params:{message:ne}};console.log("ChatProvider handleSubmit: Sending POST to /message:stream");const _e=await ze(`${o}/message:stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)});if(!_e.ok){const me=await _e.json().catch(()=>({detail:"Unknown error"}));throw console.error("ChatProvider handleSubmit: Error from /message:stream",_e.status,me),new Error(me.detail||`HTTP error ${_e.status}`)}const K=await _e.json(),S=K==null?void 0:K.result,R=S==null?void 0:S.id,V=S==null?void 0:S.contextId;if(console.log(`ChatProvider handleSubmit: Extracted responseSessionId: ${V}, current sessionId: ${s}`),console.log("ChatProvider handleSubmit: Full result object:",K),!R)throw console.error("ChatProvider handleSubmit: Backend did not return a valid taskId. Result:",K),new Error("Backend did not return a valid taskId.");if(console.log(`ChatProvider handleSubmit: Checking session update condition - responseSessionId: ${V}, sessionId: ${s}, different: ${V!==s}`),V&&V!==s){console.log(`ChatProvider handleSubmit: Updating sessionId from ${s} to ${V}`);const me=!s||s==="";if(i(V),c(Re=>Re.map(fe=>{var ye,je;return((ye=fe.metadata)==null?void 0:ye.messageId)===((je=pe.metadata)==null?void 0:je.messageId)?{...fe,metadata:{...fe.metadata,sessionId:V}}:fe})),me){const fe=pe.parts.filter(ye=>ye.kind==="text").map(ye=>ye.text).join(" ").trim();if(fe){const ye=fe.length>100?`${fe.substring(0,100)}...`:fe;et(ye),Dt(V,ye,!1)}typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}}console.log(`ChatProvider handleSubmit: Received taskId ${R}. Setting currentTaskId and taskIdInSidePanel.`),v(R),k(R)}catch(ge){console.error("ChatProvider handleSubmit: Catch block error",ge),le(`Error: ${ge instanceof Error?ge.message:"Unknown error"}`),m(!1),c(xe=>xe.filter(Ie=>!Ie.isStatusBubble)),v(null),Y.current=!1,X.current=null}},[s,d,p,E,w,Le,le,o,yt,Dt]);u.useEffect(()=>{if(h&&o){console.log(`ChatProvider Effect: currentTaskId is ${h}. Setting up EventSource.`);const $=wi(),U=`${o}/sse/subscribe/${h}${$?`?token=${$}`:""}`,z=new EventSource(U,{withCredentials:!0});return b.current=z,z.onopen=Tt,z.onerror=Ft,z.addEventListener("status_update",Ge),z.addEventListener("artifact_update",Ge),z.addEventListener("final_response",Ge),z.addEventListener("error",Ge),()=>{console.log(`ChatProvider Effect Cleanup: currentTaskId was ${h}. Closing EventSource.`),z.removeEventListener("status_update",Ge),z.removeEventListener("artifact_update",Ge),z.removeEventListener("final_response",Ge),z.removeEventListener("error",Ge),Le()}}else console.log("ChatProvider Effect: currentTaskId is null or apiPrefix missing. Ensuring EventSource is closed."),Le()},[h,o,Ge,Tt,Ft,Le]);const Se={sessionId:s,setSessionId:i,sessionName:bt,setSessionName:et,messages:l,setMessages:c,userInput:d,setUserInput:f,isResponding:p,currentTaskId:h,isCancelling:E,latestStatusText:X,agents:ee,agentsLoading:Z,agentsError:F,agentsRefetch:N,handleNewSession:Lt,handleSwitchSession:mt,handleSubmit:Yt,handleCancel:Vt,notifications:g,addNotification:le,selectedAgentName:w,setSelectedAgentName:y,artifacts:j,artifactsLoading:C,artifactsRefetch:M,uploadArtifactFile:yt,isSidePanelCollapsed:D,activeSidePanelTab:te,setIsSidePanelCollapsed:P,setActiveSidePanelTab:O,openSidePanelTab:on,taskIdInSidePanel:I,setTaskIdInSidePanel:k,isDeleteModalOpen:B,artifactToDelete:H,openDeleteModal:Mt,closeDeleteModal:St,confirmDelete:Ct,openSessionDeleteModal:Oe,closeSessionDeleteModal:ft,confirmSessionDelete:sn,sessionToDelete:tt,isArtifactEditMode:G,setIsArtifactEditMode:J,selectedArtifactFilenames:Q,setSelectedArtifactFilenames:ae,handleDeleteSelectedArtifacts:Et,confirmBatchDeleteArtifacts:Xe,isBatchDeleteModalOpen:se,setIsBatchDeleteModalOpen:ue,previewedArtifactAvailableVersions:Pe,currentPreviewedVersionNumber:Me,previewFileContent:wt,openArtifactForPreview:dt,navigateArtifactVersion:Rt,openMessageAttachmentForPreview:Pt,previewArtifact:he,setPreviewArtifact:ke,updateSessionName:Dt,deleteSession:Ot};return a.jsx(Hu.Provider,{value:Se,children:e})},zE=({children:e})=>{const{frontend_use_authorization:t,configAuthLoginUrl:n}=rn(),{fetchCsrfToken:r,clearCsrfToken:o}=Ku(),[s,i]=u.useState(!1),[l,c]=u.useState(!0),[d,f]=u.useState(null);u.useEffect(()=>{let g=!0;const x=async()=>{if(!t){g&&(i(!0),c(!1));return}try{const v=await ze("/api/v1/users/me",{credentials:"include",headers:{Accept:"application/json"}});if(v.ok){const b=await v.json();console.log("User is authenticated:",b),g&&(f(b),i(!0)),console.log("Fetching CSRF token for authenticated requests..."),await r()}else v.status===401?(console.log("User is not authenticated"),g&&i(!1)):(console.error("Unexpected response from /users/me:",v.status),g&&i(!1))}catch(v){console.error("Error checking authentication:",v),g&&i(!1)}finally{g&&c(!1)}};x();const h=v=>{v.key==="access_token"&&x()};return window.addEventListener("storage",h),()=>{g=!1,window.removeEventListener("storage",h)}},[t,n,r]);const p=()=>{window.location.href=n},m=()=>{i(!1),f(null),o()};return l?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Checking Authentication..."})]})}):a.jsx(Uu.Provider,{value:{isAuthenticated:s,useAuthorization:t,login:p,logout:m,userInfo:d},children:e})};function $E(e){var r;if(typeof document>"u")return null;const n=`; ${document.cookie}`.split(`; ${e}=`);return n.length===2&&((r=n.pop())==null?void 0:r.split(";").shift())||null}const BE=e=>new Promise(t=>setTimeout(t,e)),UE=async(e=5,t=50)=>{try{const n=await ze("/api/v1/csrf-token",{credentials:"include"});if(!n.ok)throw new Error(`CSRF endpoint returned status ${n.status}`);const r=await n.json();if(r.csrf_token)return console.log("CSRF token found in response body:",r.csrf_token),r.csrf_token;for(let o=0;o<e;o++){const s=$E("csrf_token");if(s)return console.log(`CSRF token found in cookie after ${o} retries:`,s),s;console.log(`CSRF token not found in cookie, attempt ${o+1}/${e}. Waiting ${t}ms...`),await BE(t)}throw new Error("CSRF token not available in response or cookie after retries")}catch(n){return console.error("Error fetching/reading CSRF token:",n),null}};function HE({children:e}){const[t,n]=u.useState(null),r=u.useCallback(async()=>{if(t)return t;const i=await UE();if(i)n(i);else throw new Error("Failed to obtain CSRF token after config fetch failed.");return i},[t]),o=u.useCallback(()=>{n(null)},[]),s={fetchCsrfToken:r,clearCsrfToken:o};return a.jsx(Gu.Provider,{value:s,children:e})}const WE={brand:{wMain:"#00C895",w30:"#B3EFDF",wMain30:"#00C8954d",w10:"#E6FAF4",w60:"#66DEBF",w100:"#00AD93"},primary:{w100:"#01374E",w90:"#014968",wMain:"#015B82",w60:"#679DB4",w40:"#99BDCD",w20:"#CCDEE6",w10:"#E6EFF2",text:{wMain:"#273749",w100:"#000000",w10:"#CCCCCC"}},secondary:{w70:"#536574",w80:"#354E62",w8040:"#354E6240",w100:"#000000",wMain:"#8790A0",w40:"#CFD3D9",w20:"#E7E9EC",w10:"#F3F4F6",text:{wMain:"#647481",w50:"#B1B9C0"}},background:{w100:"#021B2F",wMain:"#03223B",w20:"#F7F8F9",w10:"#FFFFFF"},info:{w100:"#2B71B1",wMain:"#0591D3",w70:"#7CD3F6",w30:"#B4DEF2",w20:"#CDE9F6",w10:"#E6F4FB"},error:{w100:"#C33135",wMain:"#E94C4E",w70:"#ED9B9D",w30:"#F8C9CA",w20:"#FBDBDC",w10:"#FDEDED"},warning:{w100:"#E1681F",wMain:"#FF8E2B",w70:"#F8C785",w30:"#FFDDBF",w20:"#FFE8D5",w10:"#FFF4EA"},success:{w100:"#006B53",wMain:"#009A80",w70:"#6FCCBC",w30:"#B3E1D9",w20:"#CCEBE6",w10:"#E6F5F2"},stateLayer:{w10:"#03223B1a",w20:"#03223B33"},accent:{n0:{w100:"#2F51AD",wMain:"#3C69E1",w30:"#C5D2F6",w10:"#ECF0FC"},n1:{w100:"#1F284C",wMain:"#3A4880",w30:"#C4C8D9",w60:"#8991B3",w20:"#D8DAE6",w10:"#EBEDF2"},n2:{w100:"#165E64",wMain:"#009193",w30:"#B3DEDF",w20:"#CCE9E9",w10:"#E6F4F4"},n3:{w100:"#542D75",wMain:"#7841A8",w30:"#D7C6E5",w10:"#F2ECF6"},n4:{w100:"#951379",wMain:"#CB1AA5",w30:"#F2C4E8"},n5:{w100:"#D03C1B",wMain:"#F66651",w30:"#FCCEC7",w60:"#FAA397"},n6:{w100:"#DE7E00",wMain:"#FCA829",w30:"#FEE5BF"},n7:{w100:"#2DADE1",wMain:"#7CD3F6",w30:"#CBEDFB"},n8:{w100:"#4F5A63",wMain:"#86939E",w30:"#DBDFE2"},n9:{wMain:"#DA162D"}},learning:{wMain:"#033A6F",w90:"#022E59",w100:"#022343",w20:"#CDD8E2",w10:"#E6EBF1"}},GE={light:{background:"background.w10",foreground:"primary.text.wMain",card:"background.w10","card-foreground":"primary.text.wMain",popover:"background.w10","popover-foreground":"primary.text.wMain",primary:"primary.wMain","primary-foreground":"primary.text.w10",secondary:"secondary.w10","secondary-foreground":"secondary.text.wMain",muted:"secondary.w10","muted-foreground":"secondary.text.wMain",accent:"secondary.w40","accent-foreground":"secondary.text.wMain",destructive:"error.wMain",border:"secondary.w40",input:"secondary.w40",ring:"brand.wMain","ring-offset":"brand.wMain","accent-background":"background.w20","message-background":"secondary.w20","chart-1":"brand.w60","chart-2":"primary.wMain","chart-3":"accent.n3.wMain","chart-4":"accent.n6.wMain","chart-5":"accent.n5.wMain",sidebar:"background.w20","sidebar-foreground":"primary.text.wMain","sidebar-primary":"primary.wMain","sidebar-primary-foreground":"primary.text.w10","sidebar-accent":"secondary.w10","sidebar-accent-foreground":"secondary.text.wMain","sidebar-border":"secondary.w40","sidebar-ring":"brand.wMain"},dark:{background:"background.w100",foreground:"primary.text.w10",card:"background.wMain","card-foreground":"primary.text.w10",popover:"background.wMain","popover-foreground":"primary.text.w10",primary:"primary.w60","primary-foreground":"primary.text.wMain",secondary:"secondary.w80","secondary-foreground":"secondary.text.w50",muted:"secondary.w80","muted-foreground":"secondary.text.w50",accent:"secondary.w80","accent-foreground":"secondary.text.w50",destructive:"error.w70",border:"secondary.w70",input:"secondary.w70",ring:"brand.w60","ring-offset":"brand.w60","accent-background":"primary.w90","message-background":"secondary.w70","chart-1":"brand.w100","chart-2":"primary.wMain","chart-3":"accent.n3.w100","chart-4":"accent.n6.w30","chart-5":"accent.n5.w60",sidebar:"background.wMain","sidebar-foreground":"primary.text.w10","sidebar-primary":"primary.w60","sidebar-primary-foreground":"primary.text.wMain","sidebar-accent":"secondary.w80","sidebar-accent-foreground":"secondary.text.w50","sidebar-border":"secondary.w70","sidebar-ring":"brand.w60"}},VE={"error-text-wMain":"error.wMain","error-text-w50":"error.w70","warning-text-wMain":"warning.wMain","warning-text-w50":"warning.w70","success-text-wMain":"success.wMain","success-text-w50":"success.w70","info-text-wMain":"info.wMain","info-text-w50":"info.w70"};function Ol(e,t){const n=t.split(".");let r=e;for(const o of n)if(r&&typeof r=="object"&&o in r)r=r[o];else return console.warn(`Color path not found: ${t}`),"#000000";return typeof r=="string"?r:"#000000"}function YE(e,t){const n={},r=GE[t];for(const[o,s]of Object.entries(r)){const i=Ol(e,s);n[`--${o}`]=i}for(const[o,s]of Object.entries(VE)){const i=Ol(e,s);n[`--color-${o}`]=i}return n}const Mo="sam-theme";function KE(e){var n,r,o,s,i,l,c,d,f,p,m,g,x,h,v,b,w,y,E,A,I,k,T,Y,X,W,q,ee,F,Z,N,j,C,M,D,P,te,O,B,L,H,_,G,J,Q,ae,se,ue,he,ke,Pe,De,Me,Be,wt,We,bt,et,tt,nt,le,It,yt,jt,Mt,St,Ct,Et,Xe,dt,Rt,Pt,on,Le,Ge,Lt,mt,Dt,Ot,Oe,ft,sn,Vt,Tt,Ft,Yt,Se,$,U,z,ie,de,pe,ge,xe,Ie,ne,we,_e,K,S,R,V;const t={};return e.brand.wMain&&(t["--color-brand-wMain"]=e.brand.wMain),e.brand.wMain30&&(t["--color-brand-wMain30"]=e.brand.wMain30),e.brand.w100&&(t["--color-brand-w100"]=e.brand.w100),e.brand.w60&&(t["--color-brand-w60"]=e.brand.w60),e.brand.w30&&(t["--color-brand-w30"]=e.brand.w30),e.brand.w10&&(t["--color-brand-w10"]=e.brand.w10),e.primary.wMain&&(t["--color-primary-wMain"]=e.primary.wMain),e.primary.w100&&(t["--color-primary-w100"]=e.primary.w100),e.primary.w90&&(t["--color-primary-w90"]=e.primary.w90),e.primary.w60&&(t["--color-primary-w60"]=e.primary.w60),e.primary.w40&&(t["--color-primary-w40"]=e.primary.w40),e.primary.w20&&(t["--color-primary-w20"]=e.primary.w20),e.primary.w10&&(t["--color-primary-w10"]=e.primary.w10),e.primary.text.wMain&&(t["--color-primary-text-wMain"]=e.primary.text.wMain),e.primary.text.w100&&(t["--color-primary-text-w100"]=e.primary.text.w100),e.primary.text.w10&&(t["--color-primary-text-w10"]=e.primary.text.w10),e.secondary.wMain&&(t["--color-secondary-wMain"]=e.secondary.wMain),e.secondary.w100&&(t["--color-secondary-w100"]=e.secondary.w100),e.secondary.w80&&(t["--color-secondary-w80"]=e.secondary.w80),e.secondary.w8040&&(t["--color-secondary-w8040"]=e.secondary.w8040),e.secondary.w70&&(t["--color-secondary-w70"]=e.secondary.w70),e.secondary.w40&&(t["--color-secondary-w40"]=e.secondary.w40),e.secondary.w20&&(t["--color-secondary-w20"]=e.secondary.w20),e.secondary.w10&&(t["--color-secondary-w10"]=e.secondary.w10),e.secondary.text.wMain&&(t["--color-secondary-text-wMain"]=e.secondary.text.wMain),e.secondary.text.w50&&(t["--color-secondary-text-w50"]=e.secondary.text.w50),e.background.wMain&&(t["--color-background-wMain"]=e.background.wMain),e.background.w100&&(t["--color-background-w100"]=e.background.w100),e.background.w20&&(t["--color-background-w20"]=e.background.w20),e.background.w10&&(t["--color-background-w10"]=e.background.w10),(n=e.info)!=null&&n.wMain&&(t["--color-info-wMain"]=e.info.wMain),(r=e.info)!=null&&r.w100&&(t["--color-info-w100"]=e.info.w100),(o=e.info)!=null&&o.w70&&(t["--color-info-w70"]=e.info.w70),(s=e.info)!=null&&s.w30&&(t["--color-info-w30"]=e.info.w30),(i=e.info)!=null&&i.w20&&(t["--color-info-w20"]=e.info.w20),(l=e.info)!=null&&l.w10&&(t["--color-info-w10"]=e.info.w10),(c=e.error)!=null&&c.wMain&&(t["--color-error-wMain"]=e.error.wMain),(d=e.error)!=null&&d.w100&&(t["--color-error-w100"]=e.error.w100),(f=e.error)!=null&&f.w70&&(t["--color-error-w70"]=e.error.w70),(p=e.error)!=null&&p.w30&&(t["--color-error-w30"]=e.error.w30),(m=e.error)!=null&&m.w20&&(t["--color-error-w20"]=e.error.w20),(g=e.error)!=null&&g.w10&&(t["--color-error-w10"]=e.error.w10),(x=e.warning)!=null&&x.wMain&&(t["--color-warning-wMain"]=e.warning.wMain),(h=e.warning)!=null&&h.w100&&(t["--color-warning-w100"]=e.warning.w100),(v=e.warning)!=null&&v.w70&&(t["--color-warning-w70"]=e.warning.w70),(b=e.warning)!=null&&b.w30&&(t["--color-warning-w30"]=e.warning.w30),(w=e.warning)!=null&&w.w20&&(t["--color-warning-w20"]=e.warning.w20),(y=e.warning)!=null&&y.w10&&(t["--color-warning-w10"]=e.warning.w10),(E=e.success)!=null&&E.wMain&&(t["--color-success-wMain"]=e.success.wMain),(A=e.success)!=null&&A.w100&&(t["--color-success-w100"]=e.success.w100),(I=e.success)!=null&&I.w70&&(t["--color-success-w70"]=e.success.w70),(k=e.success)!=null&&k.w30&&(t["--color-success-w30"]=e.success.w30),(T=e.success)!=null&&T.w20&&(t["--color-success-w20"]=e.success.w20),(Y=e.success)!=null&&Y.w10&&(t["--color-success-w10"]=e.success.w10),(X=e.stateLayer)!=null&&X.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(W=e.stateLayer)!=null&&W.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(ee=(q=e.accent)==null?void 0:q.n0)!=null&&ee.wMain&&(t["--color-accent-n0-wMain"]=e.accent.n0.wMain),(Z=(F=e.accent)==null?void 0:F.n0)!=null&&Z.w100&&(t["--color-accent-n0-w100"]=e.accent.n0.w100),(j=(N=e.accent)==null?void 0:N.n0)!=null&&j.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(M=(C=e.accent)==null?void 0:C.n0)!=null&&M.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),(P=(D=e.accent)==null?void 0:D.n1)!=null&&P.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(O=(te=e.accent)==null?void 0:te.n1)!=null&&O.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(L=(B=e.accent)==null?void 0:B.n1)!=null&&L.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),(_=(H=e.accent)==null?void 0:H.n1)!=null&&_.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(J=(G=e.accent)==null?void 0:G.n1)!=null&&J.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(ae=(Q=e.accent)==null?void 0:Q.n1)!=null&&ae.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(ue=(se=e.accent)==null?void 0:se.n2)!=null&&ue.wMain&&(t["--color-accent-n2-wMain"]=e.accent.n2.wMain),(ke=(he=e.accent)==null?void 0:he.n2)!=null&&ke.w100&&(t["--color-accent-n2-w100"]=e.accent.n2.w100),(De=(Pe=e.accent)==null?void 0:Pe.n2)!=null&&De.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(Be=(Me=e.accent)==null?void 0:Me.n2)!=null&&Be.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(We=(wt=e.accent)==null?void 0:wt.n2)!=null&&We.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(et=(bt=e.accent)==null?void 0:bt.n3)!=null&&et.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(nt=(tt=e.accent)==null?void 0:tt.n3)!=null&&nt.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(It=(le=e.accent)==null?void 0:le.n3)!=null&&It.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(jt=(yt=e.accent)==null?void 0:yt.n3)!=null&&jt.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(St=(Mt=e.accent)==null?void 0:Mt.n4)!=null&&St.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(Et=(Ct=e.accent)==null?void 0:Ct.n4)!=null&&Et.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(dt=(Xe=e.accent)==null?void 0:Xe.n4)!=null&&dt.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(Pt=(Rt=e.accent)==null?void 0:Rt.n5)!=null&&Pt.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(Le=(on=e.accent)==null?void 0:on.n5)!=null&&Le.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(Lt=(Ge=e.accent)==null?void 0:Ge.n5)!=null&&Lt.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(Dt=(mt=e.accent)==null?void 0:mt.n5)!=null&&Dt.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(Oe=(Ot=e.accent)==null?void 0:Ot.n6)!=null&&Oe.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(sn=(ft=e.accent)==null?void 0:ft.n6)!=null&&sn.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(Tt=(Vt=e.accent)==null?void 0:Vt.n6)!=null&&Tt.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),(Yt=(Ft=e.accent)==null?void 0:Ft.n7)!=null&&Yt.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),($=(Se=e.accent)==null?void 0:Se.n7)!=null&&$.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),(z=(U=e.accent)==null?void 0:U.n7)!=null&&z.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(de=(ie=e.accent)==null?void 0:ie.n8)!=null&&de.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),(ge=(pe=e.accent)==null?void 0:pe.n8)!=null&&ge.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(Ie=(xe=e.accent)==null?void 0:xe.n8)!=null&&Ie.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),(we=(ne=e.accent)==null?void 0:ne.n9)!=null&&we.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(_e=e.learning)!=null&&_e.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(K=e.learning)!=null&&K.w100&&(t["--color-learning-w100"]=e.learning.w100),(S=e.learning)!=null&&S.w90&&(t["--color-learning-w90"]=e.learning.w90),(R=e.learning)!=null&&R.w20&&(t["--color-learning-w20"]=e.learning.w20),(V=e.learning)!=null&&V.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function qE(e,t="light"){const n={};if(e){const o=KE(e);Object.assign(n,o)}const r=YE(e,t);return Object.assign(n,r),n}function XE(){const e=localStorage.getItem(Mo);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ZE(e,t){const n=qE(e,t),r=document.documentElement;for(const[o,s]of Object.entries(n))r.style.setProperty(o,s);requestAnimationFrame(()=>{console.log(`Applying ${t} theme with palette`),r.classList.remove("light","dark"),r.classList.add(t),localStorage.setItem(Mo,t)})}const JE=({children:e})=>{const t=u.useMemo(()=>WE,[]),[n,r]=u.useState(()=>XE()),o=u.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const s=n==="light"?"dark":"light";r(s),localStorage.setItem(Mo,s)}}),[n]);return u.useEffect(()=>{if(!(localStorage.getItem(Mo)!==null)){const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{r(c.matches?"dark":"light")};return i.addEventListener?i.addEventListener("change",l):i.addListener(l),()=>{i.removeEventListener?i.removeEventListener("change",l):i.removeListener(l)}}},[]),u.useEffect(()=>{document.documentElement.classList.remove("light","dark"),ZE(t,n)},[n,t]),a.jsx(Yu.Provider,{value:o,children:e})};function QE(){const[e,t]=u.useState("chat"),{isAuthenticated:n,login:r,useAuthorization:o}=xw();if(vw(),o&&!n)return a.jsx("div",{className:"bg-background flex h-screen items-center justify-center",children:a.jsx(be,{onClick:r,children:"Login"})});const s=c=>{const d=Pl.find(f=>f.id===c)||Ll.find(f=>f.id===c);d!=null&&d.onClick&&c!=="settings"?d.onClick():c!=="settings"&&t(c)},i=()=>{t("chat")},l=()=>{switch(e){case"chat":return a.jsx(ME,{});case"agentMesh":return a.jsx(_E,{})}};return a.jsxs("div",{className:"relative flex h-screen",children:[a.jsx(yE,{items:Pl,bottomItems:Ll,activeItem:e,onItemChange:s,onHeaderClick:i}),a.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:l()}),a.jsx(eb,{})]})}function e1(){return a.jsx(JE,{children:a.jsx(HE,{children:a.jsx(PE,{children:a.jsx(zE,{children:a.jsx(FE,{children:a.jsx(LE,{children:a.jsx(QE,{})})})})})})})}Np.createRoot(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(e1,{})}));