kifaru 1.0.200 → 1.0.201

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.
@@ -38,9 +38,9 @@ import{i as e,n as t,o as n,r,t as i}from"./react-dom.B--7n7g5.js";import{_ as a
38
38
  `},Pn=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Fn=function(){y.useEffect(function(){return document.body.setAttribute(Mn,(Pn()+1).toString()),function(){var e=Pn()-1;e<=0?document.body.removeAttribute(Mn):document.body.setAttribute(Mn,e.toString())}},[])},In=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Fn();var a=y.useMemo(function(){return An(i)},[i]);return y.createElement(jn,{styles:Nn(a,!t,i,n?``:`!important`)})},Ln=!1;if(typeof window<`u`)try{var Rn=Object.defineProperty({},"passive",{get:function(){return Ln=!0,!0}});window.addEventListener(`test`,Rn,Rn),window.removeEventListener(`test`,Rn,Rn)}catch{Ln=!1}var zn=Ln?{passive:!1}:!1,Bn=function(e){return e.tagName===`TEXTAREA`},Vn=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Bn(e)&&n[t]===`visible`)},Hn=function(e){return Vn(e,`overflowY`)},Un=function(e){return Vn(e,`overflowX`)},Wn=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),qn(e,r)){var i=Jn(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Gn=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Kn=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},qn=function(e,t){return e===`v`?Hn(t):Un(t)},Jn=function(e,t){return e===`v`?Gn(t):Kn(t)},Yn=function(e,t){return e===`h`&&t===`rtl`?-1:1},Xn=function(e,t,n,r,i){var a=Yn(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Jn(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&qn(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Zn=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Qn=function(e){return[e.deltaX,e.deltaY]},$n=function(e){return e&&`current`in e?e.current:e},er=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tr=function(e){return`
39
39
  .block-interactivity-${e} {pointer-events: none;}
40
40
  .allow-interactivity-${e} {pointer-events: all;}
41
- `},nr=0,rr=[];function ir(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),i=y.useState(nr++)[0],a=y.useState(En)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=tn([e.lockRef.current],(e.shards||[]).map($n),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=y.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Zn(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Wn(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Wn(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Xn(h,t,e,h===`h`?s:c,!0)},[]),c=y.useCallback(function(e){var n=e;if(rr.length&&rr[rr.length-1]===a){var r=`deltaY`in n?Qn(n):Zn(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&er(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map($n).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=y.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ar(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=y.useCallback(function(e){n.current=Zn(e),r.current=void 0},[]),d=y.useCallback(function(t){l(t.type,Qn(t),t.target,s(t,e.lockRef.current))},[]),f=y.useCallback(function(t){l(t.type,Zn(t),t.target,s(t,e.lockRef.current))},[]);y.useEffect(function(){return rr.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,zn),document.addEventListener(`touchmove`,c,zn),document.addEventListener(`touchstart`,u,zn),function(){rr=rr.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,zn),document.removeEventListener(`touchmove`,c,zn),document.removeEventListener(`touchstart`,u,zn)}},[]);var p=e.removeScrollBar,m=e.inert;return y.createElement(y.Fragment,null,m?y.createElement(a,{styles:tr(i)}):null,p?y.createElement(In,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ar(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var or=gn(_n,ir),sr=y.forwardRef(function(e,t){return y.createElement(yn,$t({},e,{ref:t,sideCar:or}))});sr.classNames=yn.classNames;var cr=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},lr=new WeakMap,ur=new WeakMap,dr={},fr=0,pr=function(e){return e&&(e.host||pr(e.parentNode))},mr=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=pr(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},hr=function(e,t,n,r){var i=mr(t,Array.isArray(e)?e:[e]);dr[n]||(dr[n]=new WeakMap);var a=dr[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(lr.get(e)||0)+1,l=(a.get(e)||0)+1;lr.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ur.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),fr++,function(){o.forEach(function(e){var t=lr.get(e)-1,i=a.get(e)-1;lr.set(e,t),a.set(e,i),t||(ur.has(e)||e.removeAttribute(r),ur.delete(e)),i||e.removeAttribute(n)}),fr--,fr||(lr=new WeakMap,lr=new WeakMap,ur=new WeakMap,dr={})}},gr=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||cr(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),hr(r,i,n,`aria-hidden`)):function(){return null}},_r=Object.defineProperty,vr=(e,t)=>_r(e,`name`,{value:t,configurable:!0}),yr=`Dialog`,[br,xr]=O(yr),[Sr,Cr]=br(yr),wr=vr(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=y.useRef(null),c=y.useRef(null),[l,u]=Te({prop:r,defaultProp:i??!1,onChange:a,caller:yr}),[d,f]=y.useState(0),[p,m]=y.useState(0);return(0,b.jsx)(Sr,{scope:t,triggerRef:s,contentRef:c,contentId:Ue(),titleId:Ue(),descriptionId:Ue(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:y.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Tr=`DialogTrigger`,Er=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Tr,n),a=u(t,i.triggerRef);return(0,b.jsx)(d.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Kr(i.open),...r,ref:a,onClick:P(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),Dr=`DialogPortal`,[Or,kr]=br(Dr,{forceMount:void 0}),Ar=vr(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Cr(Dr,t);return(0,b.jsx)(Or,{scope:t,forceMount:n,children:y.Children.map(r,e=>(0,b.jsx)(Ne,{present:n||a.open,children:(0,b.jsx)(Gt,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),jr=`DialogOverlay`,Mr=y.forwardRef(vr(function(e,t){let n=kr(jr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Cr(jr,e.__scopeDialog);return a.modal?(0,b.jsx)(Ne,{present:r||a.open,children:(0,b.jsx)(Pr,{...i,ref:t})}):null},`DialogOverlay`)),Nr=m(`DialogOverlay.RemoveScroll`),Pr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(jr,n),a=bt(),o=u(t,a);return(0,b.jsx)(sr,{as:Nr,allowPinchZoom:!0,shards:[i.contentRef],children:(0,b.jsx)(d.div,{"data-state":Kr(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Fr=`DialogContent`,Ir=y.forwardRef(vr(function(e,t){let n=kr(Fr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Cr(Fr,e.__scopeDialog);return(0,b.jsx)(Ne,{present:r||a.open,children:a.modal?(0,b.jsx)(Lr,{...i,ref:t}):(0,b.jsx)(Rr,{...i,ref:t})})},`DialogContent`)),Lr=y.forwardRef(vr(function(e,t){let n=Cr(Fr,e.__scopeDialog),r=y.useRef(null),i=u(t,n.contentRef,r);return y.useEffect(()=>{let e=r.current;if(e)return gr(e)},[]),(0,b.jsx)(zr,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:P(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:P(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Rr=y.forwardRef(vr(function(e,t){let n=Cr(Fr,e.__scopeDialog),r=y.useRef(!1),i=y.useRef(!1);return(0,b.jsx)(zr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),zr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Cr(Fr,n);return Zt(),(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(jt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,b.jsx)(yt,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Kr(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Br=`DialogTitle`,Vr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Br,n),{setTitleCount:a}=i;return ge(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,b.jsx)(d.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Hr=`DialogDescription`,Ur=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Hr,n),{setDescriptionCount:a}=i;return ge(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,b.jsx)(d.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Wr=`DialogClose`,Gr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Wr,n);return(0,b.jsx)(d.button,{type:`button`,...r,ref:t,onClick:P(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Kr(e){return e?`open`:`closed`}vr(Kr,`getState`);var qr=Object.defineProperty,Jr=(e,t)=>qr(e,`name`,{value:t,configurable:!0}),Yr=`Avatar`,[Xr,Zr]=O(Yr),Qr=[0,()=>void 0],[$r,ei]=Xr(Yr),ti=y.forwardRef(Jr(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=y.useState(`idle`),[o,s]=ci();return(0,b.jsx)($r,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,b.jsx)(d.span,{...r,ref:t})})},`Avatar`)),ni=`AvatarImage`,ri=y.forwardRef(Jr(function(e,t){let{__scopeAvatar:n,src:r,onLoadingStatusChange:i,...a}=e,o=ei(ni,n);o.setImageCount;let s=oi(r,{referrerPolicy:a.referrerPolicy,crossOrigin:a.crossOrigin,loadingStatus:o.imageLoadingStatus,setLoadingStatus:o.setImageLoadingStatus}),c=dt(e=>{i?.(e)}),l=y.useRef(s);return ge(()=>{let e=l.current;l.current=s,s!==e&&c(s)},[s,c]),s===`loaded`?(0,b.jsx)(d.img,{...a,ref:t,src:r}):null},`AvatarImage`)),ii=`AvatarFallback`,ai=y.forwardRef(Jr(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=ei(ii,n),[o,s]=y.useState(r===void 0);return y.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==`loaded`?(0,b.jsx)(d.span,{...i,ref:t}):null},`AvatarFallback`));function oi(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return ge(()=>{if(!e){n(`error`);return}let t=new window.Image,a=Jr(e=>{let t=e.currentTarget;n(si(t))},`handleLoad`),o=Jr(()=>n(`error`),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n(si(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(`idle`)}},[e,i,r,n]),t}Jr(oi,`useImageLoadingStatus`);function si(e){return e.complete?e.naturalWidth>0?`loaded`:`error`:`loading`}Jr(si,`getImageLoadingStatus`);function ci(){return Qr}Jr(ci,`useImageCount`);function li(e){}Jr(li,`useUpdateImageCount`);var ui=Object.defineProperty,di=(e,t)=>ui(e,`name`,{value:t,configurable:!0});function fi(e){let[t,n]=y.useState(void 0);return ge(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}di(fi,`useSize`);var pi=[`top`,`right`,`bottom`,`left`],mi=Math.min,hi=Math.max,gi=Math.round,_i=Math.floor,vi=e=>({x:e,y:e}),yi={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function bi(e,t,n){return hi(e,mi(t,n))}function xi(e,t){return typeof e==`function`?e(t):e}function Si(e){return e.split(`-`)[0]}function Ci(e){return e.split(`-`)[1]}function wi(e){return e===`x`?`y`:`x`}function Ti(e){return e===`y`?`height`:`width`}function Ei(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Di(e){return wi(Ei(e))}function Oi(e,t,n){n===void 0&&(n=!1);let r=Ci(e),i=Di(e),a=Ti(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Li(o)),[o,Li(o)]}function ki(e){let t=Li(e);return[Ai(e),t,Ai(t)]}function Ai(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ji=[`left`,`right`],Mi=[`right`,`left`],Ni=[`top`,`bottom`],Pi=[`bottom`,`top`];function Fi(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Mi:ji:t?ji:Mi;case`left`:case`right`:return t?Ni:Pi;default:return[]}}function Ii(e,t,n,r){let i=Ci(e),a=Fi(Si(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ai)))),a}function Li(e){let t=Si(e);return yi[t]+e.slice(t.length)}function Ri(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function zi(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ri(e)}function Bi(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Vi(e,t,n){let{reference:r,floating:i}=e,a=Ei(t),o=Di(t),s=Ti(o),c=Si(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Ci(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Hi(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=xi(t,e),p=zi(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Bi(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Bi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Ui=50,Wi=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Hi},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Vi(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Ui&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Vi(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Gi=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=xi(e,t)||{};if(l==null)return{};let d=zi(u),f={x:n,y:r},p=Di(i),m=Ti(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=mi(d[_],T),D=mi(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=bi(E,k,O),j=!c.arrow&&Ci(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Ki=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=xi(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Si(r),_=Ei(o),v=Si(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Li(o)]:ki(o)),x=p!==`none`;!d&&x&&b.push(...Ii(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Oi(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Ei(t)||T.every(e=>Ei(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Ei(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function qi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ji(e){return pi.some(t=>e[t]>=0)}var Yi=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=xi(e,t);switch(i){case`referenceHidden`:{let e=qi(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ji(e)}}}case`escaped`:{let e=qi(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ji(e)}}}default:return{}}}}},Xi=new Set([`left`,`top`]);async function Zi(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Si(n),s=Ci(n),c=Ei(n)===`y`,l=Xi.has(o)?-1:1,u=a&&c?-1:1,d=xi(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Qi=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Zi(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},$i=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=xi(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Ei(i),p=wi(f),m=u[p],h=u[f],g=(e,t)=>bi(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},ea=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=xi(e,t),u={x:n,y:r},d=Ei(i),f=wi(d),p=u[f],m=u[d],h=xi(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Xi.has(Si(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ta=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=xi(e,t),c=await i.detectOverflow(t,s),l=Si(n),u=Ci(n),d=Ei(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=mi(p-c[m],g),y=mi(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*hi(c.left,c.right):S=p-2*hi(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function na(){return typeof window<`u`}function ra(e){return oa(e)?(e.nodeName||``).toLowerCase():`#document`}function ia(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function aa(e){return((oa(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function oa(e){return na()?e instanceof Node||e instanceof ia(e).Node:!1}function sa(e){return na()?e instanceof Element||e instanceof ia(e).Element:!1}function ca(e){return na()?e instanceof HTMLElement||e instanceof ia(e).HTMLElement:!1}function la(e){return!na()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof ia(e).ShadowRoot}function ua(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=xa(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function da(e){return/^(table|td|th)$/.test(ra(e))}function fa(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var pa=/transform|translate|scale|rotate|perspective|filter/,ma=/paint|layout|strict|content/,ha=e=>!!e&&e!==`none`,ga;function _a(e){let t=sa(e)?xa(e):e;return ha(t.transform)||ha(t.translate)||ha(t.scale)||ha(t.rotate)||ha(t.perspective)||!ya()&&(ha(t.backdropFilter)||ha(t.filter))||pa.test(t.willChange||``)||ma.test(t.contain||``)}function va(e){let t=Ca(e);for(;ca(t)&&!ba(t);){if(_a(t))return t;if(fa(t))return null;t=Ca(t)}return null}function ya(){return ga??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ga}function ba(e){return/^(html|body|#document)$/.test(ra(e))}function xa(e){return ia(e).getComputedStyle(e)}function Sa(e){return sa(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ca(e){if(ra(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||la(e)&&e.host||aa(e);return la(t)?t.host:t}function wa(e){let t=Ca(e);return ba(t)?(e.ownerDocument||e).body:ca(t)&&ua(t)?t:wa(t)}function Ta(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=wa(e),i=r===e.ownerDocument?.body,a=ia(r);if(i){let e=Ea(a);return t.concat(a,a.visualViewport||[],ua(r)?r:[],e&&n?Ta(e):[])}return t.concat(r,Ta(r,[],n))}function Ea(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Da(e){let t=xa(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ca(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=gi(n)!==a||gi(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Oa(e){return sa(e)?e:e.contextElement}function ka(e){let t=Oa(e);if(!ca(t))return vi(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Da(t),o=(a?gi(n.width):n.width)/r,s=(a?gi(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Aa=vi(0);function ja(e){let t=ia(e);return!ya()||!t.visualViewport?Aa:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ma(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===ia(e)}function Na(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Oa(e),o=vi(1);t&&(r?sa(r)&&(o=ka(r)):o=ka(e));let s=Ma(a,n,r)?ja(a):vi(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=ia(a),t=sa(r)?ia(r):r,n=e,i=Ea(n);for(;i&&t!==n;){let e=ka(i),t=i.getBoundingClientRect(),r=xa(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=ia(i),i=Ea(n)}}return Bi({width:u,height:d,x:c,y:l})}function Pa(e,t){let n=Sa(e).scrollLeft;return t?t.left+n:Na(aa(e)).left+n}function Fa(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Pa(e,n),y:n.top+t.scrollTop}}function Ia(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=aa(r),s=t?fa(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=vi(1),u=vi(0),d=ca(r);if((d||!a)&&((ra(r)!==`body`||ua(o))&&(c=Sa(r)),d)){let e=Na(r);l=ka(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Fa(o,c):vi(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function La(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ra(e){let t=Sa(e),n=e.ownerDocument.body,r=hi(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=hi(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Pa(e),o=-t.scrollTop;return xa(n).direction===`rtl`&&(a+=hi(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var za=25;function Ba(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=ia(e),a=aa(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ya()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Pa(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=za&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Va(e,t){let n=Na(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ka(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ha(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ba(e,n,t);else if(t===`document`)r=Ra(aa(e));else if(sa(t))r=Va(t,n);else{let n=ja(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Bi(r)}function Ua(e,t){let n=t.get(e);if(n)return n;let r=Ta(e,[],!1).filter(e=>sa(e)&&ra(e)!==`body`),i=null,a=xa(e).position===`fixed`,o=a?Ca(e):e;for(;sa(o)&&!ba(o);){let e=xa(o),t=_a(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ca(o)}return t.set(e,r),r}function Wa(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?fa(t)?[]:Ua(t,this._c):[].concat(n),r],o=Ha(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ha(t,a[e],i);s=hi(n.top,s),c=mi(n.right,c),l=mi(n.bottom,l),u=hi(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ga(e){let{width:t,height:n}=Da(e);return{width:t,height:n}}function Ka(e,t,n){let r=ca(t),i=aa(t),a=n===`fixed`,o=Na(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=vi(0);if((r||!a)&&((ra(t)!==`body`||ua(i))&&(s=Sa(t)),r)){let e=Na(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Pa(i));let l=i&&!r&&!a?Fa(i,s):vi(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function qa(e){return xa(e).position===`static`}function Ja(e,t){if(!ca(e)||xa(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return aa(e)===n&&(n=n.ownerDocument.body),n}function Ya(e,t){let n=ia(e);if(fa(e))return n;if(!ca(e)){let t=Ca(e);for(;t&&!ba(t);){if(sa(t)&&!qa(t))return t;t=Ca(t)}return n}let r=Ja(e,t);for(;r&&da(r)&&qa(r);)r=Ja(r,t);return r&&ba(r)&&qa(r)&&!_a(r)?n:r||va(e)||n}var Xa=async function(e){let t=this.getOffsetParent||Ya,n=this.getDimensions,r=await n(e.floating);return{reference:Ka(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Za(e){return xa(e).direction===`rtl`}var Qa={convertOffsetParentRelativeRectToViewportRelativeRect:Ia,getDocumentElement:aa,getClippingRect:Wa,getOffsetParent:Ya,getElementRects:Xa,getClientRects:La,getDimensions:Ga,getScale:ka,isElement:sa,isRTL:Za};function $a(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function eo(e,t,n){let r=null,i,a=aa(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=_i(d),h=_i(a.clientWidth-(u+f)),g=_i(a.clientHeight-(d+p)),_=_i(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:hi(0,mi(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!$a(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=ia(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function to(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Oa(e),u=i||a?[...l?Ta(l):[],...t?Ta(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?eo(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Na(e):null;c&&g();function g(){let t=Na(e);h&&!$a(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var no=Qi,ro=$i,io=Ki,ao=ta,oo=Yi,so=Gi,co=ea,lo=(e,t,n)=>{let r=new Map,i=n??{},a={...Qa,...i.platform,_c:r};return Wi(e,t,{...i,platform:a})},uo=typeof document<`u`?y.useLayoutEffect:function(){};function fo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!fo(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!fo(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function po(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mo(e,t){let n=po(e);return Math.round(t*n)/n}function ho(e){let t=y.useRef(e);return uo(()=>{t.current=e}),t}function go(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=y.useState(r);fo(f,r)||p(r);let[m,h]=y.useState(null),[g,_]=y.useState(null),v=y.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=y.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=y.useRef(null),w=y.useRef(null),T=y.useRef(u),E=c!=null,D=ho(c),O=ho(i),k=ho(l),A=y.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),lo(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!fo(T.current,t)&&(T.current=t,Ut.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);uo(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=y.useRef(!1);uo(()=>(j.current=!0,()=>{j.current=!1}),[]),uo(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=y.useMemo(()=>({reference:C,floating:w,setReference:v,setFloating:b}),[v,b]),N=y.useMemo(()=>({reference:x,floating:S}),[x,S]),ee=y.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=mo(N.floating,u.x),r=mo(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...po(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:ee}),[u,A,M,N,ee])}var _o=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:so({element:r.current,padding:i}).fn(n):r?so({element:r,padding:i}).fn(n):{}}}},vo=(e,t)=>{let n=no(e);return{name:n.name,fn:n.fn,options:[e,t]}},yo=(e,t)=>{let n=ro(e);return{name:n.name,fn:n.fn,options:[e,t]}},bo=(e,t)=>({fn:co(e).fn,options:[e,t]}),xo=(e,t)=>{let n=io(e);return{name:n.name,fn:n.fn,options:[e,t]}},So=(e,t)=>{let n=ao(e);return{name:n.name,fn:n.fn,options:[e,t]}},Co=(e,t)=>{let n=oo(e);return{name:n.name,fn:n.fn,options:[e,t]}},wo=(e,t)=>{let n=_o(e);return{name:n.name,fn:n.fn,options:[e,t]}},To=Object.defineProperty,Eo=y.forwardRef(((e,t)=>To(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,b.jsx)(d.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,b.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),Do=Object.defineProperty,Oo=(e,t)=>Do(e,`name`,{value:t,configurable:!0}),ko=`Popper`,[Ao,jo]=O(ko),[Mo,No]=Ao(ko),Po=Oo(e=>{let{__scopePopper:t,children:n}=e,[r,i]=y.useState(null),[a,o]=y.useState(void 0);return(0,b.jsx)(Mo,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Fo=`PopperAnchor`,Io=y.forwardRef(Oo(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=No(Fo,n),o=y.useRef(null),s=a.onAnchorChange,c=y.useCallback(e=>{o.current=e,e&&s(e)},[s]),l=u(t,c),f=y.useRef(null);y.useEffect(()=>{if(!r)return;let e=f.current;f.current=r.current,e!==f.current&&s(f.current)});let p=a.placementState&&Ko(a.placementState),m=p?.[0],h=p?.[1];return r?null:(0,b.jsx)(d.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...i,ref:l})},`PopperAnchor`)),Lo=`PopperContent`,[Ro,zo]=Ao(Lo),Bo=y.forwardRef(Oo(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:p=`partial`,hideWhenDetached:m=!1,updatePositionStrategy:h=`optimized`,onPlaced:g,..._}=e,v=No(Lo,n),[x,S]=y.useState(null),C=u(t,S),[w,T]=y.useState(null),E=fi(w),D=E?.width??0,O=E?.height??0,k=r+(a===`center`?``:`-`+a),A=typeof f==`number`?f:{top:0,right:0,bottom:0,left:0,...f},j=Array.isArray(l)?l:[l],M=j.length>0,N={padding:A,boundary:j.filter(Wo),altBoundary:M},{refs:ee,floatingStyles:te,placement:ne,isPositioned:re,middlewareData:ie}=go({strategy:`fixed`,placement:k,whileElementsMounted:Oo((...e)=>to(...e,{animationFrame:h===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[vo({mainAxis:i+O,alignmentAxis:o}),c&&yo({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?bo():void 0,...N}),c&&xo({...N}),So({...N,apply:Oo(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),w&&wo({element:w,padding:s}),Go({arrowWidth:D,arrowHeight:O}),m&&Co({strategy:`referenceHidden`,...N,boundary:M?N.boundary:void 0})]}),ae=v.setPlacementState;ge(()=>(ae(ne),()=>{ae(void 0)}),[ne,ae]);let[oe,se]=Ko(ne),ce=dt(g);ge(()=>{re&&ce?.()},[re,ce]);let le=ie.arrow?.x,ue=ie.arrow?.y,de=ie.arrow?.centerOffset!==0,[P,fe]=y.useState();return ge(()=>{x&&fe(window.getComputedStyle(x).zIndex)},[x]),(0,b.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:re?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:P,"--radix-popper-transform-origin":[ie.transformOrigin?.x,ie.transformOrigin?.y].join(` `),...ie.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,b.jsx)(Ro,{scope:n,placedSide:oe,placedAlign:se,onArrowChange:T,arrowX:le,arrowY:ue,shouldHideArrow:de,children:(0,b.jsx)(d.div,{"data-side":oe,"data-align":se,..._,ref:C,style:{..._.style,animation:re?_.style?.animation:`none`}})})})},`PopperContent`)),Vo=`PopperArrow`,Ho={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Uo=y.forwardRef(Oo(function(e,t){let{__scopePopper:n,...r}=e,i=zo(Vo,n),a=Ho[i.placedSide];return(0,b.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,b.jsx)(Eo,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function Wo(e){return e!==null}Oo(Wo,`isNotNull`);var Go=Oo(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Ko(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Ko(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Oo(Ko,`getSideAndAlignFromPlacement`);var qo=Po,Jo=Io,Yo=Bo,Xo=Uo,Zo=Object.defineProperty,Qo=(e,t)=>Zo(e,`name`,{value:t,configurable:!0}),$o=!1;function es(){let[e,t]=y.useState($o);return y.useEffect(()=>{$o||($o=!0,t(!0))},[]),e}Qo(es,`useIsHydrated`);var ts=y.useSyncExternalStore;function ns(){return()=>{}}Qo(ns,`subscribe`);function rs(){return ts(ns,()=>!0,()=>!1)}Qo(rs,`useIsHydratedModern`);var is=typeof ts==`function`?rs:es,as=Object.defineProperty,os=(e,t)=>as(e,`name`,{value:t,configurable:!0}),ss=`rovingFocusGroup.onEntryFocus`,cs={bubbles:!1,cancelable:!0},ls=`RovingFocusGroup`,[us,ds,fs]=M(ls),[ps,ms]=O(ls,[fs]),[hs,gs]=ps(ls),_s=y.forwardRef(os(function(e,t){return(0,b.jsx)(us.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,b.jsx)(us.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,b.jsx)(vs,{...e,ref:t})})})},`RovingFocusGroup`)),vs=y.forwardRef(os(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:f=!1,...p}=e,m=y.useRef(null),h=u(t,m),g=ct(a),[_,v]=Te({prop:o,defaultProp:s??null,onChange:c,caller:ls}),[x,S]=y.useState(!1),C=dt(l),w=ds(n),T=y.useRef(!1),[E,D]=y.useState(0);return y.useEffect(()=>{let e=m.current;if(e)return e.addEventListener(ss,C),()=>e.removeEventListener(ss,C)},[C]),(0,b.jsx)(hs,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:y.useCallback(e=>v(e),[v]),onItemShiftTab:y.useCallback(()=>S(!0),[]),onFocusableItemAdd:y.useCallback(()=>D(e=>e+1),[]),onFocusableItemRemove:y.useCallback(()=>D(e=>e-1),[]),children:(0,b.jsx)(d.div,{tabIndex:x||E===0?-1:0,"data-orientation":r,...p,ref:h,style:{outline:`none`,...e.style},onMouseDown:P(e.onMouseDown,()=>{T.current=!0}),onFocus:P(e.onFocus,e=>{let t=!T.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(ss,cs);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=w().filter(e=>e.focusable);ws([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),f)}}T.current=!1}),onBlur:P(e.onBlur,()=>S(!1))})})},`RovingFocusGroupImpl`)),ys=`RovingFocusGroupItem`,bs=y.forwardRef(os(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Ue(),l=a||c,u=gs(ys,n),f=u.currentTabStopId===l,p=ds(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=u,_=is();return ge(()=>{if(_&&r)return m(),()=>h()},[_,r,m,h]),y.useEffect(()=>{if(!_&&r)return m(),()=>h()},[_,r,m,h]),(0,b.jsx)(us.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,b.jsx)(d.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:P(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:P(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:P(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Cs(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Ts(n,r+1):n.slice(r+1)}setTimeout(()=>ws(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),xs={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ss(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}os(Ss,`getDirectionAwareKey`);function Cs(e,t,n){let r=Ss(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return xs[r]}os(Cs,`getFocusIntent`);function ws(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}os(ws,`focusFirst`);function Ts(e,t){return e.map((n,r)=>e[(t+r)%e.length])}os(Ts,`wrapArray`);var Es=_s,Ds=bs,Os=Object.defineProperty,ks=(e,t)=>Os(e,`name`,{value:t,configurable:!0}),As=[`Enter`,` `],js=[`ArrowDown`,`PageUp`,`Home`],Ms=[`ArrowUp`,`PageDown`,`End`],Ns=[...js,...Ms],Ps={ltr:[...As,`ArrowRight`],rtl:[...As,`ArrowLeft`]},Fs={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Is=`Menu`,[Ls,Rs,zs]=M(Is),[Bs,Vs]=O(Is,[zs,jo,ms]),Hs=jo(),Us=ms(),[Ws,Gs]=Bs(Is),[Ks,qs]=Bs(Is),Js=ks(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Hs(t),[c,l]=y.useState(null),u=y.useRef(!1),d=dt(a),f=ct(i);return y.useEffect(()=>{let e=ks(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=ks(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),y.useEffect(()=>{if(!n)return;let e=ks(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,b.jsx)(qo,{...s,children:(0,b.jsx)(Ws,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,b.jsx)(Ks,{scope:t,onClose:y.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Ys=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e,i=Hs(n);return(0,b.jsx)(Jo,{...i,...r,ref:t})},`MenuAnchor`)),Xs=`MenuPortal`,[Zs,Qs]=Bs(Xs,{forceMount:void 0}),$s=ks(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Gs(Xs,t);return(0,b.jsx)(Zs,{scope:t,forceMount:n,children:(0,b.jsx)(Ne,{present:n||a.open,children:(0,b.jsx)(Gt,{asChild:!0,container:i,children:r})})})},`MenuPortal`),ec=`MenuContent`,[tc,nc]=Bs(ec),rc=y.forwardRef(ks(function(e,t){let n=Qs(ec,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Gs(ec,e.__scopeMenu),o=qs(ec,e.__scopeMenu);return(0,b.jsx)(Ls.Provider,{scope:e.__scopeMenu,children:(0,b.jsx)(Ne,{present:r||a.open,children:(0,b.jsx)(Ls.Slot,{scope:e.__scopeMenu,children:o.modal?(0,b.jsx)(ic,{...i,ref:t}):(0,b.jsx)(ac,{...i,ref:t})})})})},`MenuContent`)),ic=y.forwardRef(ks(function(e,t){let n=Gs(ec,e.__scopeMenu),r=y.useRef(null),i=u(t,r);return y.useEffect(()=>{let e=r.current;if(e)return gr(e)},[]),(0,b.jsx)(sc,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),ac=y.forwardRef(ks(function(e,t){let n=Gs(ec,e.__scopeMenu);return(0,b.jsx)(sc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),oc=m(`MenuContent.ScrollLock`),sc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=Gs(ec,n),v=qs(ec,n),x=Hs(n),S=Us(n),C=Rs(n),[w,T]=y.useState(null),E=y.useRef(null),D=u(t,E,_.onContentChange),O=y.useRef(0),k=y.useRef(``),A=y.useRef(0),j=y.useRef(null),M=y.useRef(`right`),N=y.useRef(0),ee=h?sr:y.Fragment,te=h?{as:oc,allowPinchZoom:!0}:void 0,ne=ks(e=>{let t=k.current+e,n=C().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=zc(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;ks((function e(t){k.current=t,window.clearTimeout(O.current),t!==``&&(O.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);y.useEffect(()=>()=>window.clearTimeout(O.current),[]),Zt();let re=y.useCallback(e=>M.current===j.current?.side&&Vc(e,j.current?.area),[]);return(0,b.jsx)(tc,{scope:n,searchRef:k,onItemEnter:y.useCallback(e=>{re(e)&&e.preventDefault()},[re]),onItemLeave:y.useCallback(e=>{re(e)||(E.current?.focus(),T(null))},[re]),onTriggerLeave:y.useCallback(e=>{re(e)&&e.preventDefault()},[re]),pointerGraceTimerRef:A,onPointerGraceIntentChange:y.useCallback(e=>{j.current=e},[]),children:(0,b.jsx)(ee,{...te,children:(0,b.jsx)(jt,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,b.jsx)(yt,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,b.jsx)(Es,{asChild:!0,...S,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:w,onCurrentTabStopIdChange:T,onEntryFocus:P(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,b.jsx)(Yo,{role:`menu`,"aria-orientation":`vertical`,"data-state":Pc(_.open),"data-radix-menu-content":``,dir:v.dir,...x,...g,ref:D,style:{outline:`none`,...g.style},onKeyDown:P(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ne(e.key));let i=E.current;if(e.target!==i||!Ns.includes(e.key))return;e.preventDefault();let a=C().filter(e=>!e.disabled).map(e=>e.ref.current);Ms.includes(e.key)&&a.reverse(),Lc(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(O.current),k.current=``)}),onPointerMove:P(e.onPointerMove,Hc(e=>{let t=e.target,n=N.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>N.current?`right`:`left`;M.current=t,N.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),cc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e;return(0,b.jsx)(d.div,{role:`group`,...r,ref:t})},`MenuGroup`)),lc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e;return(0,b.jsx)(d.div,{...r,ref:t})},`MenuLabel`)),uc=`MenuItem`,dc=`menu.itemSelect`,fc=y.forwardRef(ks(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=y.useRef(null),o=qs(uc,e.__scopeMenu),s=nc(uc,e.__scopeMenu),c=u(t,a),l=y.useRef(!1),d=ks(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(dc,{bubbles:!0,cancelable:!0});e.addEventListener(dc,e=>r?.(e),{once:!0}),_(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,b.jsx)(pc,{...i,ref:c,disabled:n,onClick:P(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:P(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:P(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&As.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),pc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=nc(uc,n),s=Us(n),c=y.useRef(null),l=u(t,c),[f,p]=y.useState(!1),[m,h]=y.useState(``);return y.useEffect(()=>{let e=c.current;e&&h((e.textContent??``).trim())},[a.children]),(0,b.jsx)(Ls.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,b.jsx)(Ds,{asChild:!0,...s,focusable:!r,children:(0,b.jsx)(d.div,{role:`menuitem`,"data-highlighted":f?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:P(e.onPointerMove,Hc(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,Hc(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>p(!0)),onBlur:P(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),mc=y.forwardRef(ks(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,b.jsx)(xc,{scope:e.__scopeMenu,checked:n,children:(0,b.jsx)(fc,{role:`menuitemcheckbox`,"aria-checked":Fc(n)?`mixed`:n,...i,ref:t,"data-state":Ic(n),onSelect:P(i.onSelect,()=>r?.(Fc(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[hc,gc]=Bs(`MenuRadioGroup`,{value:void 0,onValueChange:ks(()=>{},`onValueChange`)}),_c=y.forwardRef(ks(function(e,t){let{value:n,onValueChange:r,...i}=e,a=dt(r);return(0,b.jsx)(hc,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,b.jsx)(cc,{...i,ref:t})})},`MenuRadioGroup`)),vc=`MenuRadioItem`,yc=y.forwardRef(ks(function(e,t){let{value:n,...r}=e,i=gc(vc,e.__scopeMenu),a=n===i.value;return(0,b.jsx)(xc,{scope:e.__scopeMenu,checked:a,children:(0,b.jsx)(fc,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ic(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),bc=`MenuItemIndicator`,[xc,Sc]=Bs(bc,{checked:!1}),Cc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=Sc(bc,n);return(0,b.jsx)(Ne,{present:r||Fc(a.checked)||a.checked===!0,children:(0,b.jsx)(d.span,{...i,ref:t,"data-state":Ic(a.checked)})})},`MenuItemIndicator`)),wc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e;return(0,b.jsx)(d.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),Tc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e,i=Hs(n);return(0,b.jsx)(Xo,{...i,...r,ref:t})},`MenuArrow`)),Ec=`MenuSub`,[Dc,Oc]=Bs(Ec),kc=ks(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Gs(Ec,t),o=Hs(t),[s,c]=y.useState(null),[l,u]=y.useState(null),d=dt(i);return y.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,b.jsx)(qo,{...o,children:(0,b.jsx)(Ws,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,b.jsx)(Dc,{scope:t,contentId:Ue(),triggerId:Ue(),trigger:s,onTriggerChange:c,children:n})})})},`MenuSub`),Ac=`MenuSubTrigger`,jc=y.forwardRef(ks(function(e,t){let n=Gs(Ac,e.__scopeMenu),r=qs(Ac,e.__scopeMenu),i=Oc(Ac,e.__scopeMenu),a=nc(Ac,e.__scopeMenu),o=y.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},d=y.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);y.useEffect(()=>d,[d]),y.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let f=u(t,i.onTriggerChange);return(0,b.jsx)(Ys,{asChild:!0,...l,children:(0,b.jsx)(pc,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":Pc(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,Hc(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:P(e.onPointerLeave,Hc(e=>{d();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:P(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&Ps[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),Mc=`MenuSubContent`,Nc=y.forwardRef(ks(function(e,t){let n=Qs(ec,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Gs(ec,e.__scopeMenu),s=qs(ec,e.__scopeMenu),c=Oc(Mc,e.__scopeMenu),l=y.useRef(null),d=u(t,l);return(0,b.jsx)(Ls.Provider,{scope:e.__scopeMenu,children:(0,b.jsx)(Ne,{present:r||o.open,children:(0,b.jsx)(Ls.Slot,{scope:e.__scopeMenu,children:(0,b.jsx)(sc,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:d,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:P(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:P(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:P(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Fs[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function Pc(e){return e?`open`:`closed`}ks(Pc,`getOpenState`);function Fc(e){return e===`indeterminate`}ks(Fc,`isIndeterminate`);function Ic(e){return Fc(e)?`indeterminate`:e?`checked`:`unchecked`}ks(Ic,`getCheckedState`);function Lc(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}ks(Lc,`focusFirst`);function Rc(e,t){return e.map((n,r)=>e[(t+r)%e.length])}ks(Rc,`wrapArray`);function zc(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Rc(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}ks(zc,`getNextMatch`);function Bc(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}ks(Bc,`isPointInPolygon`);function Vc(e,t){return t?Bc({x:e.clientX,y:e.clientY},t):!1}ks(Vc,`isPointerInGraceArea`);function Hc(e){return t=>t.pointerType===`mouse`?e(t):void 0}ks(Hc,`whenMouse`);var Uc=Js,Wc=Ys,Gc=$s,Kc=rc,qc=cc,Jc=lc,Yc=fc,Xc=mc,Zc=_c,Qc=yc,$c=Cc,el=wc,tl=Tc,nl=kc,rl=jc,il=Nc,al=e({Arrow:()=>Wl,CheckboxItem:()=>zl,Content:()=>Fl,DropdownMenu:()=>ml,DropdownMenuArrow:()=>Ol,DropdownMenuCheckboxItem:()=>Cl,DropdownMenuContent:()=>yl,DropdownMenuGroup:()=>bl,DropdownMenuItem:()=>Sl,DropdownMenuItemIndicator:()=>El,DropdownMenuLabel:()=>xl,DropdownMenuPortal:()=>_l,DropdownMenuRadioGroup:()=>wl,DropdownMenuRadioItem:()=>Tl,DropdownMenuSeparator:()=>Dl,DropdownMenuSub:()=>kl,DropdownMenuSubContent:()=>jl,DropdownMenuSubTrigger:()=>Al,DropdownMenuTrigger:()=>gl,Group:()=>Il,Item:()=>Rl,ItemIndicator:()=>Hl,Label:()=>Ll,Portal:()=>Pl,RadioGroup:()=>Bl,RadioItem:()=>Vl,Root:()=>Ml,Separator:()=>Ul,Sub:()=>Gl,SubContent:()=>ql,SubTrigger:()=>Kl,Trigger:()=>Nl,createDropdownMenuScope:()=>ul}),ol=Object.defineProperty,sl=(e,t)=>ol(e,`name`,{value:t,configurable:!0}),cl=`DropdownMenu`,[ll,ul]=O(cl,[Vs]),dl=Vs(),[fl,pl]=ll(cl),ml=sl(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=dl(t),l=y.useRef(null),[u,d]=Te({prop:i,defaultProp:a??!1,onChange:o,caller:cl});return(0,b.jsx)(fl,{scope:t,triggerId:Ue(),triggerRef:l,contentId:Ue(),open:u,onOpenChange:d,onOpenToggle:y.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,b.jsx)(Uc,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),hl=`DropdownMenuTrigger`,gl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=pl(hl,n),o=dl(n),s=u(t,a.triggerRef);return(0,b.jsx)(Wc,{asChild:!0,...o,children:(0,b.jsx)(d.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:P(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:P(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),_l=sl(e=>{let{__scopeDropdownMenu:t,...n}=e,r=dl(t);return(0,b.jsx)(Gc,{...r,...n})},`DropdownMenuPortal`),vl=`DropdownMenuContent`,yl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=pl(vl,n),a=dl(n),o=y.useRef(!1);return(0,b.jsx)(Kc,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:P(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:P(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),bl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(qc,{...i,...r,ref:t})},`DropdownMenuGroup`)),xl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Jc,{...i,...r,ref:t})},`DropdownMenuLabel`)),Sl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Yc,{...i,...r,ref:t})},`DropdownMenuItem`)),Cl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Xc,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),wl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Zc,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),Tl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Qc,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),El=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)($c,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),Dl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(el,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Ol=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(tl,{...i,...r,ref:t})},`DropdownMenuArrow`)),kl=sl(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=dl(t),[s,c]=Te({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,b.jsx)(nl,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),Al=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(rl,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),jl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(il,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),Ml=ml,Nl=gl,Pl=_l,Fl=yl,Il=bl,Ll=xl,Rl=Sl,zl=Cl,Bl=wl,Vl=Tl,Hl=El,Ul=Dl,Wl=Ol,Gl=kl,Kl=Al,ql=jl,Jl=Object.defineProperty,Yl=(e,t)=>Jl(e,`name`,{value:t,configurable:!0}),[Xl,Zl]=O(`Tooltip`,[jo]),Ql=jo(),$l=`TooltipProvider`,eu=700,tu=`tooltip.open`,[nu,ru]=Xl($l),iu=Yl(e=>{let{__scopeTooltip:t,delayDuration:n=eu,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=y.useRef(!0),s=y.useRef(!1),c=y.useRef(0);return y.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,b.jsx)(nu,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:y.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),au=`Tooltip`,[ou,su]=Xl(au),cu=Yl(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=ru(au,e.__scopeTooltip),l=Ql(t),[u,d]=y.useState(null),[f,p]=y.useState(void 0),m=Ue(),h=y.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=y.useRef(!1),[x,S]=Te({prop:r,defaultProp:i??!1,onChange:Yl(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(tu))):c.onClose(),a?.(e)},`onChange`),caller:au}),C=y.useMemo(()=>x?v.current?`delayed-open`:`instant-open`:`closed`,[x]),w=y.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,S(!0)},[S]),T=y.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S(!1)},[S]),E=y.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,S(!0),h.current=0},_)},[_,S]);y.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let D=f??m;return(0,b.jsx)(qo,{...l,children:(0,b.jsx)(ou,{scope:t,contentId:D,setContentId:p,open:x,stateAttribute:C,trigger:u,onTriggerChange:d,onTriggerEnter:y.useCallback(()=>{c.isOpenDelayedRef.current?E():w()},[c.isOpenDelayedRef,E,w]),onTriggerLeave:y.useCallback(()=>{g?T():(window.clearTimeout(h.current),h.current=0)},[T,g]),onOpen:w,onClose:T,disableHoverableContent:g,children:n})})},`Tooltip`),lu=`TooltipTrigger`,uu=y.forwardRef(Yl(function(e,t){let{__scopeTooltip:n,...r}=e,i=su(lu,n),a=ru(lu,n),o=Ql(n),s=y.useRef(null),c=u(t,s,i.onTriggerChange),l=y.useRef(!1),f=y.useRef(!1),p=y.useCallback(()=>l.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener(`pointerup`,p),[p]),(0,b.jsx)(Jo,{asChild:!0,...o,children:(0,b.jsx)(d.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:P(e.onPointerMove,e=>{e.pointerType!==`touch`&&!f.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:P(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:P(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener(`pointerup`,p,{once:!0})}),onFocus:P(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:P(e.onBlur,i.onClose),onClick:P(e.onClick,i.onClose)})})},`TooltipTrigger`)),du=`TooltipPortal`,[fu,pu]=Xl(du,{forceMount:void 0}),mu=Yl(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=su(du,t);return(0,b.jsx)(fu,{scope:t,forceMount:n,children:(0,b.jsx)(Ne,{present:n||a.open,children:(0,b.jsx)(Gt,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),hu=`TooltipContent`,gu=y.forwardRef(Yl(function(e,t){let n=pu(hu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=su(hu,e.__scopeTooltip);return(0,b.jsx)(Ne,{present:r||o.open,children:o.disableHoverableContent?(0,b.jsx)(yu,{side:i,...a,ref:t}):(0,b.jsx)(_u,{side:i,...a,ref:t})})},`TooltipContent`)),_u=y.forwardRef(Yl(function(e,t){let n=su(hu,e.__scopeTooltip),r=ru(hu,e.__scopeTooltip),i=y.useRef(null),a=u(t,i),[o,s]=y.useState(null),{trigger:c,onClose:l}=n,d=i.current,{onPointerInTransitChange:f}=r,p=y.useCallback(()=>{s(null),f(!1)},[f]),m=y.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Su(r,xu(r,n.getBoundingClientRect())),a=Cu(t.getBoundingClientRect()),o=Tu([...i,...a]);s(o),f(!0)},[f]);return y.useEffect(()=>()=>p(),[p]),y.useEffect(()=>{if(c&&d){let e=Yl(e=>m(e,d),`handleTriggerLeave`),t=Yl(e=>m(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[c,d,m,p]),y.useEffect(()=>{if(o){let e=Yl(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||d?.contains(t),i=!wu(n,o);r?p():i&&(p(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,d,o,l,p]),(0,b.jsx)(yu,{...e,ref:a})},`TooltipContentHoverable`)),vu=f(`TooltipContent`),yu=y.forwardRef(Yl(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=su(hu,n),u=Ql(n),{onClose:d}=l;y.useEffect(()=>(document.addEventListener(tu,d),()=>document.removeEventListener(tu,d)),[d]),y.useEffect(()=>{if(l.trigger){let e=Yl(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return ge(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,b.jsx)(yt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,b.jsxs)(Yo,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.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:[(0,b.jsx)(vu,{children:r}),i?(0,b.jsx)(w,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),bu=y.forwardRef(Yl(function(e,t){let{__scopeTooltip:n,...r}=e,i=Ql(n);return(0,b.jsx)(Xo,{...i,...r,ref:t})},`TooltipArrow`));function xu(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Yl(xu,`getExitSideFromRect`);function Su(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Yl(Su,`getPaddedExitPoints`);function Cu(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Yl(Cu,`getPointsFromRect`);function wu(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Yl(wu,`isPointInPolygon`);function Tu(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Eu(t)}Yl(Tu,`getHull`);function Eu(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Yl(Eu,`getHullPresorted`);var Du=iu,Ou=cu,ku=uu,Au=mu,ju=gu,Mu=bu,Nu=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Pu={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Fu=new class{#e=Pu;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Iu(e){setTimeout(e,0)}var Lu=typeof window>`u`||`Deno`in globalThis;function Ru(){}function zu(e,t){return typeof e==`function`?e(t):e}function Bu(e){return typeof e==`number`&&e>=0&&e!==1/0}function Vu(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Hu(e,t){return typeof e==`function`?e(t):e}function Uu(e,t){return typeof e==`function`?e(t):e}function Wu(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Ku(o,t.options))return!1}else if(!Ju(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Gu(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(qu(t.options.mutationKey)!==qu(a))return!1}else if(!Ju(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Ku(e,t){return(t?.queryKeyHashFn||qu)(e)}function qu(e){return JSON.stringify(e,(e,t)=>$u(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Ju(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Ju(e[n],t[n])):!1}var Yu=Object.prototype.hasOwnProperty;function Xu(e,t){if(e===t)return e;let n=Qu(e)&&Qu(t);if(!n&&!($u(e)&&$u(t)))return t;let r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),a=i.length,o=n?Array(a):{},s=0;for(let c=0;c<a;c++){let a=n?c:i[c],l=e[a],u=t[a];if(l===u){o[a]=l,(n?c<r:Yu.call(e,a))&&s++;continue}if(l===null||u===null||typeof l!=`object`||typeof u!=`object`){o[a]=u;continue}let d=Xu(l,u);o[a]=d,d===l&&s++}return r===a&&s===r?e:o}function Zu(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Qu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function $u(e){if(!ed(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ed(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ed(e){return Object.prototype.toString.call(e)===`[object Object]`}function td(e){return new Promise(t=>{Fu.setTimeout(t,e)})}function nd(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Xu(e,t)}function rd(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function id(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ad=Symbol();function od(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ad?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function sd(e,t){return typeof e==`function`?e(...t):!!e}var cd=new class extends Nu{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!Lu&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function ld(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ud=Iu;function dd(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ud,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var fd=dd(),pd=new class extends Nu{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!Lu&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function md(e){return Math.min(1e3*2**e,3e4)}function hd(e){return(e??`online`)!==`online`||pd.isOnline()}var gd=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function _d(e){let t=!1,n=0,r,i=ld(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new gd(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>cd.isFocused()&&(e.networkMode===`always`||pd.isOnline())&&e.canRun(),u=()=>hd(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Lu?0:3),o=e.retryDelay??md,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),td(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var vd=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bu(this.gcTime)&&(this.#e=Fu.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Lu?1/0:3e5))}clearGcTimeout(){this.#e&&=(Fu.clearTimeout(this.#e),void 0)}},yd=class extends vd{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=xd(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=xd(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=nd(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(Ru).catch(Ru):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Uu(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ad||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Hu(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Vu(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=od(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=_d({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof gd&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof gd){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...bd(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:`success`,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),fd.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function bd(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:hd(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function xd(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Sd=class extends Nu{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=ld(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),wd(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Td(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Td(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Uu(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Zu(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ed(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Uu(this.options.enabled,this.#t)!==Uu(t.enabled,this.#t)||Hu(this.options.staleTime,this.#t)!==Hu(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Uu(this.options.enabled,this.#t)!==Uu(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Od(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`)),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Ru)),t}#g(){this.#b();let e=Hu(this.options.staleTime,this.#t);if(Lu||this.#r.isStale||!Bu(e))return;let t=Vu(this.#r.dataUpdatedAt,e)+1;this.#d=Fu.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!Lu&&Uu(this.options.enabled,this.#t)!==!1&&Bu(this.#p)&&this.#p!==0&&(this.#f=Fu.setInterval(()=>{(this.options.refetchIntervalInBackground||cd.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(Fu.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(Fu.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&wd(e,t),o=i&&Ed(e,n,t,r);(a||o)&&(l={...l,...bd(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=nd(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=nd(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Dd(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Uu(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=e=>{x.status===`error`?e.reject(x.error):x.data!==void 0&&e.resolve(x.data)},r=()=>{let e=this.#o=x.promise=ld();t(e)},i=this.#o;switch(i.status){case`pending`:e.queryHash===n.queryHash&&t(i);break;case`fulfilled`:(x.status===`error`||x.data!==i.value)&&r();break;case`rejected`:(x.status!==`error`||x.error!==i.reason)&&r()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Zu(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){fd.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Cd(e,t){return Uu(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||t.retryOnMount!==!1)}function wd(e,t){return Cd(e,t)||e.state.data!==void 0&&Td(e,t,t.refetchOnMount)}function Td(e,t,n){if(Uu(t.enabled,e)!==!1&&Hu(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Dd(e,t)}return!1}function Ed(e,t,n,r){return(e!==t||Uu(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Dd(e,n)}function Dd(e,t){return Uu(t.enabled,e)!==!1&&e.isStaleByTime(Hu(t.staleTime,e))}function Od(e,t){return!Zu(e.getCurrentResult(),t)}function kd(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener(`abort`,()=>{n=!0}),t.signal)})},u=od(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?id:rd;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?jd:Ad,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ad(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Ad(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function jd(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Md=class extends vd{#e;#t;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Nd(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status===`pending`?this.scheduleGc():this.#t.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#r({type:`continue`})};this.#n=_d({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#r({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#r({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let n=this.state.status===`pending`,r=!this.#n.canStart();try{if(n)t();else{this.#r({type:`pending`,variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#r({type:`pending`,context:t,variables:e,isPaused:r})}let i=await this.#n.start();return await this.#t.config.onSuccess?.(i,e,this.state.context,this),await this.options.onSuccess?.(i,e,this.state.context),await this.#t.config.onSettled?.(i,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(i,null,e,this.state.context),this.#r({type:`success`,data:i}),i}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#r({type:`error`,error:t})}}finally{this.#t.runNext(this)}}#r(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),fd.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:`updated`,action:e})})}};function Nd(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Pd=class extends Nu{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Md({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Fd(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Fd(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Fd(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Fd(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){fd.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Gu(t,e))}findAll(e={}){return this.getAll().filter(t=>Gu(e,t))}notify(e){fd.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return fd.batch(()=>Promise.all(e.map(e=>e.continue().catch(Ru))))}};function Fd(e){return e.options.scope?.id}var Id=class extends Nu{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Zu(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&qu(t.mutationKey)!==qu(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Nd();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){fd.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context;e?.type===`success`?(this.#r.onSuccess?.(e.data,t,n),this.#r.onSettled?.(e.data,null,t,n)):e?.type===`error`&&(this.#r.onError?.(e.error,t,n),this.#r.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach(e=>{e(this.#t)})})}},Ld=class extends Nu{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Ku(r,t),a=this.get(i);return a||(a=new yd({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){fd.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Wu(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Wu(e,t)):t}notify(e){fd.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){fd.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){fd.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Rd=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ld,this.#t=e.mutationCache||new Pd,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=cd.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=pd.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Hu(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=zu(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return fd.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;fd.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return fd.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=fd.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ru).catch(Ru)}invalidateQueries(e,t={}){return fd.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=fd.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Ru)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Ru)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Hu(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ru).catch(Ru)}fetchInfiniteQuery(e){return e.behavior=kd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ru).catch(Ru)}ensureInfiniteQueryData(e){return e.behavior=kd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return pd.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(qu(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Ju(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(qu(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Ju(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ku(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ad&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},zd=y.createContext(void 0),Bd=e=>{let t=y.useContext(zd);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Vd=({client:e,children:t})=>(y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,b.jsx)(zd.Provider,{value:e,children:t})),Hd=y.createContext(!1),Ud=()=>y.useContext(Hd);Hd.Provider;function Wd(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Gd=y.createContext(Wd()),Kd=()=>y.useContext(Gd),qd=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Jd=e=>{y.useEffect(()=>{e.clearReset()},[e])},Yd=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||sd(n,[e.error,r])),Xd=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Zd=(e,t)=>e.isLoading&&e.isFetching&&!t,Qd=(e,t)=>e?.suspense&&t.isPending,$d=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ef(e,t,n){let r=Ud(),i=Kd(),a=Bd(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Xd(o),qd(o,i),Jd(i);let s=!a.getQueryCache().get(o.queryHash),[c]=y.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!r&&e.subscribed!==!1;if(y.useSyncExternalStore(y.useCallback(e=>{let t=u?c.subscribe(fd.batchCalls(e)):Ru;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),y.useEffect(()=>{c.setOptions(o)},[o,c]),Qd(o,l))throw $d(o,c,i);if(Yd({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!Lu&&Zd(l,r)&&(s?$d(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ru).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function tf(e,t){return ef(e,Sd,t)}function nf(e,t){let n=Bd(t),[r]=y.useState(()=>new Id(n,e));y.useEffect(()=>{r.setOptions(e)},[r,e]);let i=y.useSyncExternalStore(y.useCallback(e=>r.subscribe(fd.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=y.useCallback((e,t)=>{r.mutate(e,t).catch(Ru)},[r]);if(i.error&&sd(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var rf=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),af=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),of=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),sf=e=>{let t=of(e);return t.charAt(0).toUpperCase()+t.slice(1)},cf={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},lf=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},uf=(0,y.createContext)({}),df=()=>(0,y.useContext)(uf),ff=(0,y.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=df()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,y.createElement)(`svg`,{ref:c,...cf,width:t??l??cf.width,height:t??l??cf.height,stroke:e??f,strokeWidth:m,className:rf(`lucide`,p,i),...!a&&!lf(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,y.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),F=(e,t)=>{let n=(0,y.forwardRef)(({className:n,...r},i)=>(0,y.createElement)(ff,{ref:i,iconNode:t,className:rf(`lucide-${af(sf(e))}`,`lucide-${e}`,n),...r}));return n.displayName=sf(e),n},pf=F(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),mf=F(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),hf=F(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),gf=F(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),_f=F(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),vf=F(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),yf=F(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),bf=F(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),xf=F(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Sf=F(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Cf=F(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),wf=F(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Tf=F(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Ef=F(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Df=F(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]]),Of=F(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),kf=F(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Af=F(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),jf=F(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Mf=F(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Nf=F(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),Pf=F(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Ff=F(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),If=F(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Lf=F(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Rf=F(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),zf=F(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),Bf=F(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Vf=F(`key`,[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]),Hf=F(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),Uf=F(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Wf=F(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),Gf=F(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),Kf=F(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),qf=F(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Jf=F(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Yf=F(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Xf=F(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Zf=F(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Qf=F(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),$f=F(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),ep=F(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),tp=F(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),np=F(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),rp=F(`shield-question-mark`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ip=F(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ap=F(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),op=F(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),sp=F(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),cp=F(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),lp=F(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),up=F(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),dp=F(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),fp=F(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),pp=F(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),mp=F(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);Object.freeze({status:`aborted`});function I(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var hp=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},gp=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},_p={};function vp(e){return e&&Object.assign(_p,e),_p}function yp(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function bp(e,t){return typeof t==`bigint`?t.toString():t}function xp(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Sp(e){return e==null}function Cp(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function wp(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var Tp=Symbol(`evaluating`);function Ep(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Tp)return r===void 0&&(r=Tp,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Dp(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Op(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kp(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ap(e){return JSON.stringify(e)}var jp=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Mp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Np=xp(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Pp(e){if(Mp(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return Mp(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Fp(e){return Pp(e)?{...e}:Array.isArray(e)?[...e]:e}var Ip=new Set([`string`,`number`,`symbol`]);function Lp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Rp(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function zp(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Bp={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Vp(e,t){let n=e._zod.def;return Rp(e,kp(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Op(this,`shape`,e),e},checks:[]}))}function Hp(e,t){let n=e._zod.def;return Rp(e,kp(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Op(this,`shape`,r),r},checks:[]}))}function Up(e,t){if(!Pp(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return Rp(e,kp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Op(this,`shape`,n),n},checks:[]}))}function Wp(e,t){if(!Pp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Rp(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Op(this,`shape`,n),n},checks:e._zod.def.checks})}function Gp(e,t){return Rp(e,kp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Op(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Kp(e,t,n){return Rp(t,kp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Op(this,`shape`,i),i},checks:[]}))}function qp(e,t,n){return Rp(t,kp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Op(this,`shape`,i),i},checks:[]}))}function Jp(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Yp(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Xp(e){return typeof e==`string`?e:e?.message}function Zp(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Xp(e.inst?._zod.def?.error?.(e))??Xp(t?.error?.(e))??Xp(n.customError?.(e))??Xp(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Qp(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function $p(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var em=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,bp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},tm=I(`$ZodError`,em),nm=I(`$ZodError`,em,{Parent:Error});function rm(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function im(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var am=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new hp;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Zp(e,a,vp())));throw jp(t,i?.callee),t}return o.value},om=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Zp(e,a,vp())));throw jp(t,i?.callee),t}return o.value},sm=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new hp;return a.issues.length?{success:!1,error:new(e??tm)(a.issues.map(e=>Zp(e,i,vp())))}:{success:!0,data:a.value}},cm=sm(nm),lm=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Zp(e,i,vp())))}:{success:!0,data:a.value}},um=lm(nm),dm=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return am(e)(t,n,i)},fm=e=>(t,n,r)=>am(e)(t,n,r),pm=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return om(e)(t,n,i)},mm=e=>async(t,n,r)=>om(e)(t,n,r),hm=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return sm(e)(t,n,i)},gm=e=>(t,n,r)=>sm(e)(t,n,r),_m=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return lm(e)(t,n,i)},vm=e=>async(t,n,r)=>lm(e)(t,n,r),ym=/^[cC][^\s-]{8,}$/,bm=/^[0-9a-z]+$/,xm=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sm=/^[0-9a-vA-V]{20}$/,Cm=/^[A-Za-z0-9]{27}$/,wm=/^[a-zA-Z0-9_-]{21}$/,Tm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Em=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Dm=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Om=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,km=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Am(){return new RegExp(km,`u`)}var jm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Nm=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Pm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Fm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Im=/^[A-Za-z0-9_-]*$/,Lm=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Rm=/^\+(?:[0-9]){6,14}[0-9]$/,zm=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Bm=RegExp(`^${zm}$`);function Vm(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Hm(e){return RegExp(`^${Vm(e)}$`)}function Um(e){let t=Vm({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${zm}T(?:${r})$`)}var Wm=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Gm=/^-?\d+$/,Km=/^-?\d+(?:\.\d+)?/,qm=/^(?:true|false)$/i,Jm=/^null$/i,Ym=/^[^A-Z]*$/,Xm=/^[^a-z]*$/,Zm=I(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Qm={number:`number`,bigint:`bigint`,object:`date`},$m=I(`$ZodCheckLessThan`,(e,t)=>{Zm.init(e,t);let n=Qm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),eh=I(`$ZodCheckGreaterThan`,(e,t)=>{Zm.init(e,t);let n=Qm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),th=I(`$ZodCheckMultipleOf`,(e,t)=>{Zm.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):wp(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),nh=I(`$ZodCheckNumberFormat`,(e,t)=>{Zm.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Bp[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Gm)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),rh=I(`$ZodCheckMaxLength`,(e,t)=>{var n;Zm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Qp(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ih=I(`$ZodCheckMinLength`,(e,t)=>{var n;Zm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Qp(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ah=I(`$ZodCheckLengthEquals`,(e,t)=>{var n;Zm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Qp(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),oh=I(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Zm.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),sh=I(`$ZodCheckRegex`,(e,t)=>{oh.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ch=I(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ym,oh.init(e,t)}),lh=I(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Xm,oh.init(e,t)}),uh=I(`$ZodCheckIncludes`,(e,t)=>{Zm.init(e,t);let n=Lp(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),dh=I(`$ZodCheckStartsWith`,(e,t)=>{Zm.init(e,t);let n=RegExp(`^${Lp(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),fh=I(`$ZodCheckEndsWith`,(e,t)=>{Zm.init(e,t);let n=RegExp(`.*${Lp(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ph=I(`$ZodCheckOverwrite`,(e,t)=>{Zm.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),mh=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
41
+ `},nr=0,rr=[];function ir(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),i=y.useState(nr++)[0],a=y.useState(En)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=tn([e.lockRef.current],(e.shards||[]).map($n),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=y.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Zn(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Wn(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Wn(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Xn(h,t,e,h===`h`?s:c,!0)},[]),c=y.useCallback(function(e){var n=e;if(rr.length&&rr[rr.length-1]===a){var r=`deltaY`in n?Qn(n):Zn(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&er(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map($n).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=y.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ar(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=y.useCallback(function(e){n.current=Zn(e),r.current=void 0},[]),d=y.useCallback(function(t){l(t.type,Qn(t),t.target,s(t,e.lockRef.current))},[]),f=y.useCallback(function(t){l(t.type,Zn(t),t.target,s(t,e.lockRef.current))},[]);y.useEffect(function(){return rr.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,zn),document.addEventListener(`touchmove`,c,zn),document.addEventListener(`touchstart`,u,zn),function(){rr=rr.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,zn),document.removeEventListener(`touchmove`,c,zn),document.removeEventListener(`touchstart`,u,zn)}},[]);var p=e.removeScrollBar,m=e.inert;return y.createElement(y.Fragment,null,m?y.createElement(a,{styles:tr(i)}):null,p?y.createElement(In,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ar(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var or=gn(_n,ir),sr=y.forwardRef(function(e,t){return y.createElement(yn,$t({},e,{ref:t,sideCar:or}))});sr.classNames=yn.classNames;var cr=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},lr=new WeakMap,ur=new WeakMap,dr={},fr=0,pr=function(e){return e&&(e.host||pr(e.parentNode))},mr=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=pr(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},hr=function(e,t,n,r){var i=mr(t,Array.isArray(e)?e:[e]);dr[n]||(dr[n]=new WeakMap);var a=dr[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(lr.get(e)||0)+1,l=(a.get(e)||0)+1;lr.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ur.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),fr++,function(){o.forEach(function(e){var t=lr.get(e)-1,i=a.get(e)-1;lr.set(e,t),a.set(e,i),t||(ur.has(e)||e.removeAttribute(r),ur.delete(e)),i||e.removeAttribute(n)}),fr--,fr||(lr=new WeakMap,lr=new WeakMap,ur=new WeakMap,dr={})}},gr=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||cr(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),hr(r,i,n,`aria-hidden`)):function(){return null}},_r=Object.defineProperty,vr=(e,t)=>_r(e,`name`,{value:t,configurable:!0}),yr=`Dialog`,[br,xr]=O(yr),[Sr,Cr]=br(yr),wr=vr(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=y.useRef(null),c=y.useRef(null),[l,u]=Te({prop:r,defaultProp:i??!1,onChange:a,caller:yr}),[d,f]=y.useState(0),[p,m]=y.useState(0);return(0,b.jsx)(Sr,{scope:t,triggerRef:s,contentRef:c,contentId:Ue(),titleId:Ue(),descriptionId:Ue(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:y.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Tr=`DialogTrigger`,Er=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Tr,n),a=u(t,i.triggerRef);return(0,b.jsx)(d.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Kr(i.open),...r,ref:a,onClick:P(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),Dr=`DialogPortal`,[Or,kr]=br(Dr,{forceMount:void 0}),Ar=vr(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Cr(Dr,t);return(0,b.jsx)(Or,{scope:t,forceMount:n,children:y.Children.map(r,e=>(0,b.jsx)(Ne,{present:n||a.open,children:(0,b.jsx)(Gt,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),jr=`DialogOverlay`,Mr=y.forwardRef(vr(function(e,t){let n=kr(jr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Cr(jr,e.__scopeDialog);return a.modal?(0,b.jsx)(Ne,{present:r||a.open,children:(0,b.jsx)(Pr,{...i,ref:t})}):null},`DialogOverlay`)),Nr=m(`DialogOverlay.RemoveScroll`),Pr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(jr,n),a=bt(),o=u(t,a);return(0,b.jsx)(sr,{as:Nr,allowPinchZoom:!0,shards:[i.contentRef],children:(0,b.jsx)(d.div,{"data-state":Kr(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Fr=`DialogContent`,Ir=y.forwardRef(vr(function(e,t){let n=kr(Fr,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Cr(Fr,e.__scopeDialog);return(0,b.jsx)(Ne,{present:r||a.open,children:a.modal?(0,b.jsx)(Lr,{...i,ref:t}):(0,b.jsx)(Rr,{...i,ref:t})})},`DialogContent`)),Lr=y.forwardRef(vr(function(e,t){let n=Cr(Fr,e.__scopeDialog),r=y.useRef(null),i=u(t,n.contentRef,r);return y.useEffect(()=>{let e=r.current;if(e)return gr(e)},[]),(0,b.jsx)(zr,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:P(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:P(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Rr=y.forwardRef(vr(function(e,t){let n=Cr(Fr,e.__scopeDialog),r=y.useRef(!1),i=y.useRef(!1);return(0,b.jsx)(zr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),zr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Cr(Fr,n);return Zt(),(0,b.jsx)(b.Fragment,{children:(0,b.jsx)(jt,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,b.jsx)(yt,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Kr(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Br=`DialogTitle`,Vr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Br,n),{setTitleCount:a}=i;return ge(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,b.jsx)(d.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Hr=`DialogDescription`,Ur=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Hr,n),{setDescriptionCount:a}=i;return ge(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,b.jsx)(d.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Wr=`DialogClose`,Gr=y.forwardRef(vr(function(e,t){let{__scopeDialog:n,...r}=e,i=Cr(Wr,n);return(0,b.jsx)(d.button,{type:`button`,...r,ref:t,onClick:P(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Kr(e){return e?`open`:`closed`}vr(Kr,`getState`);var qr=Object.defineProperty,Jr=(e,t)=>qr(e,`name`,{value:t,configurable:!0}),Yr=`Avatar`,[Xr,Zr]=O(Yr),Qr=[0,()=>void 0],[$r,ei]=Xr(Yr),ti=y.forwardRef(Jr(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=y.useState(`idle`),[o,s]=ci();return(0,b.jsx)($r,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,b.jsx)(d.span,{...r,ref:t})})},`Avatar`)),ni=`AvatarImage`,ri=y.forwardRef(Jr(function(e,t){let{__scopeAvatar:n,src:r,onLoadingStatusChange:i,...a}=e,o=ei(ni,n);o.setImageCount;let s=oi(r,{referrerPolicy:a.referrerPolicy,crossOrigin:a.crossOrigin,loadingStatus:o.imageLoadingStatus,setLoadingStatus:o.setImageLoadingStatus}),c=dt(e=>{i?.(e)}),l=y.useRef(s);return ge(()=>{let e=l.current;l.current=s,s!==e&&c(s)},[s,c]),s===`loaded`?(0,b.jsx)(d.img,{...a,ref:t,src:r}):null},`AvatarImage`)),ii=`AvatarFallback`,ai=y.forwardRef(Jr(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=ei(ii,n),[o,s]=y.useState(r===void 0);return y.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==`loaded`?(0,b.jsx)(d.span,{...i,ref:t}):null},`AvatarFallback`));function oi(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return ge(()=>{if(!e){n(`error`);return}let t=new window.Image,a=Jr(e=>{let t=e.currentTarget;n(si(t))},`handleLoad`),o=Jr(()=>n(`error`),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n(si(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(`idle`)}},[e,i,r,n]),t}Jr(oi,`useImageLoadingStatus`);function si(e){return e.complete?e.naturalWidth>0?`loaded`:`error`:`loading`}Jr(si,`getImageLoadingStatus`);function ci(){return Qr}Jr(ci,`useImageCount`);function li(e){}Jr(li,`useUpdateImageCount`);var ui=Object.defineProperty,di=(e,t)=>ui(e,`name`,{value:t,configurable:!0});function fi(e){let[t,n]=y.useState(void 0);return ge(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}di(fi,`useSize`);var pi=[`top`,`right`,`bottom`,`left`],mi=Math.min,hi=Math.max,gi=Math.round,_i=Math.floor,vi=e=>({x:e,y:e}),yi={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function bi(e,t,n){return hi(e,mi(t,n))}function xi(e,t){return typeof e==`function`?e(t):e}function Si(e){return e.split(`-`)[0]}function Ci(e){return e.split(`-`)[1]}function wi(e){return e===`x`?`y`:`x`}function Ti(e){return e===`y`?`height`:`width`}function Ei(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Di(e){return wi(Ei(e))}function Oi(e,t,n){n===void 0&&(n=!1);let r=Ci(e),i=Di(e),a=Ti(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Li(o)),[o,Li(o)]}function ki(e){let t=Li(e);return[Ai(e),t,Ai(t)]}function Ai(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ji=[`left`,`right`],Mi=[`right`,`left`],Ni=[`top`,`bottom`],Pi=[`bottom`,`top`];function Fi(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Mi:ji:t?ji:Mi;case`left`:case`right`:return t?Ni:Pi;default:return[]}}function Ii(e,t,n,r){let i=Ci(e),a=Fi(Si(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ai)))),a}function Li(e){let t=Si(e);return yi[t]+e.slice(t.length)}function Ri(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function zi(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ri(e)}function Bi(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Vi(e,t,n){let{reference:r,floating:i}=e,a=Ei(t),o=Di(t),s=Ti(o),c=Si(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Ci(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Hi(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=xi(t,e),p=zi(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Bi(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Bi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Ui=50,Wi=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Hi},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Vi(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Ui&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Vi(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Gi=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=xi(e,t)||{};if(l==null)return{};let d=zi(u),f={x:n,y:r},p=Di(i),m=Ti(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=mi(d[_],T),D=mi(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=bi(E,k,O),j=!c.arrow&&Ci(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Ki=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=xi(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Si(r),_=Ei(o),v=Si(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Li(o)]:ki(o)),x=p!==`none`;!d&&x&&b.push(...Ii(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Oi(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Ei(t)||T.every(e=>Ei(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Ei(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function qi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ji(e){return pi.some(t=>e[t]>=0)}var Yi=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=xi(e,t);switch(i){case`referenceHidden`:{let e=qi(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ji(e)}}}case`escaped`:{let e=qi(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ji(e)}}}default:return{}}}}},Xi=new Set([`left`,`top`]);async function Zi(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Si(n),s=Ci(n),c=Ei(n)===`y`,l=Xi.has(o)?-1:1,u=a&&c?-1:1,d=xi(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Qi=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Zi(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},$i=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=xi(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Ei(i),p=wi(f),m=u[p],h=u[f],g=(e,t)=>bi(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},ea=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=xi(e,t),u={x:n,y:r},d=Ei(i),f=wi(d),p=u[f],m=u[d],h=xi(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Xi.has(Si(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ta=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=xi(e,t),c=await i.detectOverflow(t,s),l=Si(n),u=Ci(n),d=Ei(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=mi(p-c[m],g),y=mi(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*hi(c.left,c.right):S=p-2*hi(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function na(){return typeof window<`u`}function ra(e){return oa(e)?(e.nodeName||``).toLowerCase():`#document`}function ia(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function aa(e){return((oa(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function oa(e){return na()?e instanceof Node||e instanceof ia(e).Node:!1}function sa(e){return na()?e instanceof Element||e instanceof ia(e).Element:!1}function ca(e){return na()?e instanceof HTMLElement||e instanceof ia(e).HTMLElement:!1}function la(e){return!na()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof ia(e).ShadowRoot}function ua(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=xa(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function da(e){return/^(table|td|th)$/.test(ra(e))}function fa(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var pa=/transform|translate|scale|rotate|perspective|filter/,ma=/paint|layout|strict|content/,ha=e=>!!e&&e!==`none`,ga;function _a(e){let t=sa(e)?xa(e):e;return ha(t.transform)||ha(t.translate)||ha(t.scale)||ha(t.rotate)||ha(t.perspective)||!ya()&&(ha(t.backdropFilter)||ha(t.filter))||pa.test(t.willChange||``)||ma.test(t.contain||``)}function va(e){let t=Ca(e);for(;ca(t)&&!ba(t);){if(_a(t))return t;if(fa(t))return null;t=Ca(t)}return null}function ya(){return ga??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ga}function ba(e){return/^(html|body|#document)$/.test(ra(e))}function xa(e){return ia(e).getComputedStyle(e)}function Sa(e){return sa(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ca(e){if(ra(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||la(e)&&e.host||aa(e);return la(t)?t.host:t}function wa(e){let t=Ca(e);return ba(t)?(e.ownerDocument||e).body:ca(t)&&ua(t)?t:wa(t)}function Ta(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=wa(e),i=r===e.ownerDocument?.body,a=ia(r);if(i){let e=Ea(a);return t.concat(a,a.visualViewport||[],ua(r)?r:[],e&&n?Ta(e):[])}return t.concat(r,Ta(r,[],n))}function Ea(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Da(e){let t=xa(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ca(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=gi(n)!==a||gi(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Oa(e){return sa(e)?e:e.contextElement}function ka(e){let t=Oa(e);if(!ca(t))return vi(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Da(t),o=(a?gi(n.width):n.width)/r,s=(a?gi(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Aa=vi(0);function ja(e){let t=ia(e);return!ya()||!t.visualViewport?Aa:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ma(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===ia(e)}function Na(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Oa(e),o=vi(1);t&&(r?sa(r)&&(o=ka(r)):o=ka(e));let s=Ma(a,n,r)?ja(a):vi(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=ia(a),t=sa(r)?ia(r):r,n=e,i=Ea(n);for(;i&&t!==n;){let e=ka(i),t=i.getBoundingClientRect(),r=xa(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=ia(i),i=Ea(n)}}return Bi({width:u,height:d,x:c,y:l})}function Pa(e,t){let n=Sa(e).scrollLeft;return t?t.left+n:Na(aa(e)).left+n}function Fa(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Pa(e,n),y:n.top+t.scrollTop}}function Ia(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=aa(r),s=t?fa(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=vi(1),u=vi(0),d=ca(r);if((d||!a)&&((ra(r)!==`body`||ua(o))&&(c=Sa(r)),d)){let e=Na(r);l=ka(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Fa(o,c):vi(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function La(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ra(e){let t=Sa(e),n=e.ownerDocument.body,r=hi(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=hi(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Pa(e),o=-t.scrollTop;return xa(n).direction===`rtl`&&(a+=hi(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var za=25;function Ba(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=ia(e),a=aa(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ya()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Pa(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=za&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Va(e,t){let n=Na(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ka(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ha(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ba(e,n,t);else if(t===`document`)r=Ra(aa(e));else if(sa(t))r=Va(t,n);else{let n=ja(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Bi(r)}function Ua(e,t){let n=t.get(e);if(n)return n;let r=Ta(e,[],!1).filter(e=>sa(e)&&ra(e)!==`body`),i=null,a=xa(e).position===`fixed`,o=a?Ca(e):e;for(;sa(o)&&!ba(o);){let e=xa(o),t=_a(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ca(o)}return t.set(e,r),r}function Wa(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?fa(t)?[]:Ua(t,this._c):[].concat(n),r],o=Ha(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ha(t,a[e],i);s=hi(n.top,s),c=mi(n.right,c),l=mi(n.bottom,l),u=hi(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ga(e){let{width:t,height:n}=Da(e);return{width:t,height:n}}function Ka(e,t,n){let r=ca(t),i=aa(t),a=n===`fixed`,o=Na(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=vi(0);if((r||!a)&&((ra(t)!==`body`||ua(i))&&(s=Sa(t)),r)){let e=Na(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Pa(i));let l=i&&!r&&!a?Fa(i,s):vi(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function qa(e){return xa(e).position===`static`}function Ja(e,t){if(!ca(e)||xa(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return aa(e)===n&&(n=n.ownerDocument.body),n}function Ya(e,t){let n=ia(e);if(fa(e))return n;if(!ca(e)){let t=Ca(e);for(;t&&!ba(t);){if(sa(t)&&!qa(t))return t;t=Ca(t)}return n}let r=Ja(e,t);for(;r&&da(r)&&qa(r);)r=Ja(r,t);return r&&ba(r)&&qa(r)&&!_a(r)?n:r||va(e)||n}var Xa=async function(e){let t=this.getOffsetParent||Ya,n=this.getDimensions,r=await n(e.floating);return{reference:Ka(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Za(e){return xa(e).direction===`rtl`}var Qa={convertOffsetParentRelativeRectToViewportRelativeRect:Ia,getDocumentElement:aa,getClippingRect:Wa,getOffsetParent:Ya,getElementRects:Xa,getClientRects:La,getDimensions:Ga,getScale:ka,isElement:sa,isRTL:Za};function $a(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function eo(e,t,n){let r=null,i,a=aa(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=_i(d),h=_i(a.clientWidth-(u+f)),g=_i(a.clientHeight-(d+p)),_=_i(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:hi(0,mi(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!$a(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=ia(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function to(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Oa(e),u=i||a?[...l?Ta(l):[],...t?Ta(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?eo(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Na(e):null;c&&g();function g(){let t=Na(e);h&&!$a(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var no=Qi,ro=$i,io=Ki,ao=ta,oo=Yi,so=Gi,co=ea,lo=(e,t,n)=>{let r=new Map,i=n??{},a={...Qa,...i.platform,_c:r};return Wi(e,t,{...i,platform:a})},uo=typeof document<`u`?y.useLayoutEffect:function(){};function fo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!fo(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!fo(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function po(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mo(e,t){let n=po(e);return Math.round(t*n)/n}function ho(e){let t=y.useRef(e);return uo(()=>{t.current=e}),t}function go(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=y.useState(r);fo(f,r)||p(r);let[m,h]=y.useState(null),[g,_]=y.useState(null),v=y.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=y.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=y.useRef(null),w=y.useRef(null),T=y.useRef(u),E=c!=null,D=ho(c),O=ho(i),k=ho(l),A=y.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),lo(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!fo(T.current,t)&&(T.current=t,Ut.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);uo(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=y.useRef(!1);uo(()=>(j.current=!0,()=>{j.current=!1}),[]),uo(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=y.useMemo(()=>({reference:C,floating:w,setReference:v,setFloating:b}),[v,b]),N=y.useMemo(()=>({reference:x,floating:S}),[x,S]),ee=y.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=mo(N.floating,u.x),r=mo(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...po(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:ee}),[u,A,M,N,ee])}var _o=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:so({element:r.current,padding:i}).fn(n):r?so({element:r,padding:i}).fn(n):{}}}},vo=(e,t)=>{let n=no(e);return{name:n.name,fn:n.fn,options:[e,t]}},yo=(e,t)=>{let n=ro(e);return{name:n.name,fn:n.fn,options:[e,t]}},bo=(e,t)=>({fn:co(e).fn,options:[e,t]}),xo=(e,t)=>{let n=io(e);return{name:n.name,fn:n.fn,options:[e,t]}},So=(e,t)=>{let n=ao(e);return{name:n.name,fn:n.fn,options:[e,t]}},Co=(e,t)=>{let n=oo(e);return{name:n.name,fn:n.fn,options:[e,t]}},wo=(e,t)=>{let n=_o(e);return{name:n.name,fn:n.fn,options:[e,t]}},To=Object.defineProperty,Eo=y.forwardRef(((e,t)=>To(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,b.jsx)(d.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,b.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),Do=Object.defineProperty,Oo=(e,t)=>Do(e,`name`,{value:t,configurable:!0}),ko=`Popper`,[Ao,jo]=O(ko),[Mo,No]=Ao(ko),Po=Oo(e=>{let{__scopePopper:t,children:n}=e,[r,i]=y.useState(null),[a,o]=y.useState(void 0);return(0,b.jsx)(Mo,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Fo=`PopperAnchor`,Io=y.forwardRef(Oo(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=No(Fo,n),o=y.useRef(null),s=a.onAnchorChange,c=y.useCallback(e=>{o.current=e,e&&s(e)},[s]),l=u(t,c),f=y.useRef(null);y.useEffect(()=>{if(!r)return;let e=f.current;f.current=r.current,e!==f.current&&s(f.current)});let p=a.placementState&&Ko(a.placementState),m=p?.[0],h=p?.[1];return r?null:(0,b.jsx)(d.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...i,ref:l})},`PopperAnchor`)),Lo=`PopperContent`,[Ro,zo]=Ao(Lo),Bo=y.forwardRef(Oo(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:p=`partial`,hideWhenDetached:m=!1,updatePositionStrategy:h=`optimized`,onPlaced:g,..._}=e,v=No(Lo,n),[x,S]=y.useState(null),C=u(t,S),[w,T]=y.useState(null),E=fi(w),D=E?.width??0,O=E?.height??0,k=r+(a===`center`?``:`-`+a),A=typeof f==`number`?f:{top:0,right:0,bottom:0,left:0,...f},j=Array.isArray(l)?l:[l],M=j.length>0,N={padding:A,boundary:j.filter(Wo),altBoundary:M},{refs:ee,floatingStyles:te,placement:ne,isPositioned:re,middlewareData:ie}=go({strategy:`fixed`,placement:k,whileElementsMounted:Oo((...e)=>to(...e,{animationFrame:h===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[vo({mainAxis:i+O,alignmentAxis:o}),c&&yo({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?bo():void 0,...N}),c&&xo({...N}),So({...N,apply:Oo(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),w&&wo({element:w,padding:s}),Go({arrowWidth:D,arrowHeight:O}),m&&Co({strategy:`referenceHidden`,...N,boundary:M?N.boundary:void 0})]}),ae=v.setPlacementState;ge(()=>(ae(ne),()=>{ae(void 0)}),[ne,ae]);let[oe,se]=Ko(ne),ce=dt(g);ge(()=>{re&&ce?.()},[re,ce]);let le=ie.arrow?.x,ue=ie.arrow?.y,de=ie.arrow?.centerOffset!==0,[P,fe]=y.useState();return ge(()=>{x&&fe(window.getComputedStyle(x).zIndex)},[x]),(0,b.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:re?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:P,"--radix-popper-transform-origin":[ie.transformOrigin?.x,ie.transformOrigin?.y].join(` `),...ie.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,b.jsx)(Ro,{scope:n,placedSide:oe,placedAlign:se,onArrowChange:T,arrowX:le,arrowY:ue,shouldHideArrow:de,children:(0,b.jsx)(d.div,{"data-side":oe,"data-align":se,..._,ref:C,style:{..._.style,animation:re?_.style?.animation:`none`}})})})},`PopperContent`)),Vo=`PopperArrow`,Ho={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Uo=y.forwardRef(Oo(function(e,t){let{__scopePopper:n,...r}=e,i=zo(Vo,n),a=Ho[i.placedSide];return(0,b.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,b.jsx)(Eo,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function Wo(e){return e!==null}Oo(Wo,`isNotNull`);var Go=Oo(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Ko(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Ko(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Oo(Ko,`getSideAndAlignFromPlacement`);var qo=Po,Jo=Io,Yo=Bo,Xo=Uo,Zo=Object.defineProperty,Qo=(e,t)=>Zo(e,`name`,{value:t,configurable:!0}),$o=!1;function es(){let[e,t]=y.useState($o);return y.useEffect(()=>{$o||($o=!0,t(!0))},[]),e}Qo(es,`useIsHydrated`);var ts=y.useSyncExternalStore;function ns(){return()=>{}}Qo(ns,`subscribe`);function rs(){return ts(ns,()=>!0,()=>!1)}Qo(rs,`useIsHydratedModern`);var is=typeof ts==`function`?rs:es,as=Object.defineProperty,os=(e,t)=>as(e,`name`,{value:t,configurable:!0}),ss=`rovingFocusGroup.onEntryFocus`,cs={bubbles:!1,cancelable:!0},ls=`RovingFocusGroup`,[us,ds,fs]=M(ls),[ps,ms]=O(ls,[fs]),[hs,gs]=ps(ls),_s=y.forwardRef(os(function(e,t){return(0,b.jsx)(us.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,b.jsx)(us.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,b.jsx)(vs,{...e,ref:t})})})},`RovingFocusGroup`)),vs=y.forwardRef(os(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:f=!1,...p}=e,m=y.useRef(null),h=u(t,m),g=ct(a),[_,v]=Te({prop:o,defaultProp:s??null,onChange:c,caller:ls}),[x,S]=y.useState(!1),C=dt(l),w=ds(n),T=y.useRef(!1),[E,D]=y.useState(0);return y.useEffect(()=>{let e=m.current;if(e)return e.addEventListener(ss,C),()=>e.removeEventListener(ss,C)},[C]),(0,b.jsx)(hs,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:y.useCallback(e=>v(e),[v]),onItemShiftTab:y.useCallback(()=>S(!0),[]),onFocusableItemAdd:y.useCallback(()=>D(e=>e+1),[]),onFocusableItemRemove:y.useCallback(()=>D(e=>e-1),[]),children:(0,b.jsx)(d.div,{tabIndex:x||E===0?-1:0,"data-orientation":r,...p,ref:h,style:{outline:`none`,...e.style},onMouseDown:P(e.onMouseDown,()=>{T.current=!0}),onFocus:P(e.onFocus,e=>{let t=!T.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(ss,cs);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=w().filter(e=>e.focusable);ws([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),f)}}T.current=!1}),onBlur:P(e.onBlur,()=>S(!1))})})},`RovingFocusGroupImpl`)),ys=`RovingFocusGroupItem`,bs=y.forwardRef(os(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Ue(),l=a||c,u=gs(ys,n),f=u.currentTabStopId===l,p=ds(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=u,_=is();return ge(()=>{if(_&&r)return m(),()=>h()},[_,r,m,h]),y.useEffect(()=>{if(!_&&r)return m(),()=>h()},[_,r,m,h]),(0,b.jsx)(us.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,b.jsx)(d.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:P(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:P(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:P(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Cs(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Ts(n,r+1):n.slice(r+1)}setTimeout(()=>ws(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),xs={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ss(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}os(Ss,`getDirectionAwareKey`);function Cs(e,t,n){let r=Ss(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return xs[r]}os(Cs,`getFocusIntent`);function ws(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}os(ws,`focusFirst`);function Ts(e,t){return e.map((n,r)=>e[(t+r)%e.length])}os(Ts,`wrapArray`);var Es=_s,Ds=bs,Os=Object.defineProperty,ks=(e,t)=>Os(e,`name`,{value:t,configurable:!0}),As=[`Enter`,` `],js=[`ArrowDown`,`PageUp`,`Home`],Ms=[`ArrowUp`,`PageDown`,`End`],Ns=[...js,...Ms],Ps={ltr:[...As,`ArrowRight`],rtl:[...As,`ArrowLeft`]},Fs={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Is=`Menu`,[Ls,Rs,zs]=M(Is),[Bs,Vs]=O(Is,[zs,jo,ms]),Hs=jo(),Us=ms(),[Ws,Gs]=Bs(Is),[Ks,qs]=Bs(Is),Js=ks(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Hs(t),[c,l]=y.useState(null),u=y.useRef(!1),d=dt(a),f=ct(i);return y.useEffect(()=>{let e=ks(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=ks(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),y.useEffect(()=>{if(!n)return;let e=ks(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,b.jsx)(qo,{...s,children:(0,b.jsx)(Ws,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,b.jsx)(Ks,{scope:t,onClose:y.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Ys=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e,i=Hs(n);return(0,b.jsx)(Jo,{...i,...r,ref:t})},`MenuAnchor`)),Xs=`MenuPortal`,[Zs,Qs]=Bs(Xs,{forceMount:void 0}),$s=ks(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Gs(Xs,t);return(0,b.jsx)(Zs,{scope:t,forceMount:n,children:(0,b.jsx)(Ne,{present:n||a.open,children:(0,b.jsx)(Gt,{asChild:!0,container:i,children:r})})})},`MenuPortal`),ec=`MenuContent`,[tc,nc]=Bs(ec),rc=y.forwardRef(ks(function(e,t){let n=Qs(ec,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Gs(ec,e.__scopeMenu),o=qs(ec,e.__scopeMenu);return(0,b.jsx)(Ls.Provider,{scope:e.__scopeMenu,children:(0,b.jsx)(Ne,{present:r||a.open,children:(0,b.jsx)(Ls.Slot,{scope:e.__scopeMenu,children:o.modal?(0,b.jsx)(ic,{...i,ref:t}):(0,b.jsx)(ac,{...i,ref:t})})})})},`MenuContent`)),ic=y.forwardRef(ks(function(e,t){let n=Gs(ec,e.__scopeMenu),r=y.useRef(null),i=u(t,r);return y.useEffect(()=>{let e=r.current;if(e)return gr(e)},[]),(0,b.jsx)(sc,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:P(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),ac=y.forwardRef(ks(function(e,t){let n=Gs(ec,e.__scopeMenu);return(0,b.jsx)(sc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),oc=m(`MenuContent.ScrollLock`),sc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=Gs(ec,n),v=qs(ec,n),x=Hs(n),S=Us(n),C=Rs(n),[w,T]=y.useState(null),E=y.useRef(null),D=u(t,E,_.onContentChange),O=y.useRef(0),k=y.useRef(``),A=y.useRef(0),j=y.useRef(null),M=y.useRef(`right`),N=y.useRef(0),ee=h?sr:y.Fragment,te=h?{as:oc,allowPinchZoom:!0}:void 0,ne=ks(e=>{let t=k.current+e,n=C().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=zc(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;ks((function e(t){k.current=t,window.clearTimeout(O.current),t!==``&&(O.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);y.useEffect(()=>()=>window.clearTimeout(O.current),[]),Zt();let re=y.useCallback(e=>M.current===j.current?.side&&Vc(e,j.current?.area),[]);return(0,b.jsx)(tc,{scope:n,searchRef:k,onItemEnter:y.useCallback(e=>{re(e)&&e.preventDefault()},[re]),onItemLeave:y.useCallback(e=>{re(e)||(E.current?.focus(),T(null))},[re]),onTriggerLeave:y.useCallback(e=>{re(e)&&e.preventDefault()},[re]),pointerGraceTimerRef:A,onPointerGraceIntentChange:y.useCallback(e=>{j.current=e},[]),children:(0,b.jsx)(ee,{...te,children:(0,b.jsx)(jt,{asChild:!0,trapped:i,onMountAutoFocus:P(a,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,b.jsx)(yt,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,b.jsx)(Es,{asChild:!0,...S,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:w,onCurrentTabStopIdChange:T,onEntryFocus:P(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,b.jsx)(Yo,{role:`menu`,"aria-orientation":`vertical`,"data-state":Pc(_.open),"data-radix-menu-content":``,dir:v.dir,...x,...g,ref:D,style:{outline:`none`,...g.style},onKeyDown:P(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ne(e.key));let i=E.current;if(e.target!==i||!Ns.includes(e.key))return;e.preventDefault();let a=C().filter(e=>!e.disabled).map(e=>e.ref.current);Ms.includes(e.key)&&a.reverse(),Lc(a)}),onBlur:P(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(O.current),k.current=``)}),onPointerMove:P(e.onPointerMove,Hc(e=>{let t=e.target,n=N.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>N.current?`right`:`left`;M.current=t,N.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),cc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e;return(0,b.jsx)(d.div,{role:`group`,...r,ref:t})},`MenuGroup`)),lc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e;return(0,b.jsx)(d.div,{...r,ref:t})},`MenuLabel`)),uc=`MenuItem`,dc=`menu.itemSelect`,fc=y.forwardRef(ks(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=y.useRef(null),o=qs(uc,e.__scopeMenu),s=nc(uc,e.__scopeMenu),c=u(t,a),l=y.useRef(!1),d=ks(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(dc,{bubbles:!0,cancelable:!0});e.addEventListener(dc,e=>r?.(e),{once:!0}),_(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,b.jsx)(pc,{...i,ref:c,disabled:n,onClick:P(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:P(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:P(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&As.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),pc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=nc(uc,n),s=Us(n),c=y.useRef(null),l=u(t,c),[f,p]=y.useState(!1),[m,h]=y.useState(``);return y.useEffect(()=>{let e=c.current;e&&h((e.textContent??``).trim())},[a.children]),(0,b.jsx)(Ls.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,b.jsx)(Ds,{asChild:!0,...s,focusable:!r,children:(0,b.jsx)(d.div,{role:`menuitem`,"data-highlighted":f?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:P(e.onPointerMove,Hc(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:P(e.onPointerLeave,Hc(e=>o.onItemLeave(e))),onFocus:P(e.onFocus,()=>p(!0)),onBlur:P(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),mc=y.forwardRef(ks(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,b.jsx)(xc,{scope:e.__scopeMenu,checked:n,children:(0,b.jsx)(fc,{role:`menuitemcheckbox`,"aria-checked":Fc(n)?`mixed`:n,...i,ref:t,"data-state":Ic(n),onSelect:P(i.onSelect,()=>r?.(Fc(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[hc,gc]=Bs(`MenuRadioGroup`,{value:void 0,onValueChange:ks(()=>{},`onValueChange`)}),_c=y.forwardRef(ks(function(e,t){let{value:n,onValueChange:r,...i}=e,a=dt(r);return(0,b.jsx)(hc,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,b.jsx)(cc,{...i,ref:t})})},`MenuRadioGroup`)),vc=`MenuRadioItem`,yc=y.forwardRef(ks(function(e,t){let{value:n,...r}=e,i=gc(vc,e.__scopeMenu),a=n===i.value;return(0,b.jsx)(xc,{scope:e.__scopeMenu,checked:a,children:(0,b.jsx)(fc,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ic(a),onSelect:P(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),bc=`MenuItemIndicator`,[xc,Sc]=Bs(bc,{checked:!1}),Cc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=Sc(bc,n);return(0,b.jsx)(Ne,{present:r||Fc(a.checked)||a.checked===!0,children:(0,b.jsx)(d.span,{...i,ref:t,"data-state":Ic(a.checked)})})},`MenuItemIndicator`)),wc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e;return(0,b.jsx)(d.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),Tc=y.forwardRef(ks(function(e,t){let{__scopeMenu:n,...r}=e,i=Hs(n);return(0,b.jsx)(Xo,{...i,...r,ref:t})},`MenuArrow`)),Ec=`MenuSub`,[Dc,Oc]=Bs(Ec),kc=ks(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Gs(Ec,t),o=Hs(t),[s,c]=y.useState(null),[l,u]=y.useState(null),d=dt(i);return y.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,b.jsx)(qo,{...o,children:(0,b.jsx)(Ws,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,b.jsx)(Dc,{scope:t,contentId:Ue(),triggerId:Ue(),trigger:s,onTriggerChange:c,children:n})})})},`MenuSub`),Ac=`MenuSubTrigger`,jc=y.forwardRef(ks(function(e,t){let n=Gs(Ac,e.__scopeMenu),r=qs(Ac,e.__scopeMenu),i=Oc(Ac,e.__scopeMenu),a=nc(Ac,e.__scopeMenu),o=y.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},d=y.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);y.useEffect(()=>d,[d]),y.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let f=u(t,i.onTriggerChange);return(0,b.jsx)(Ys,{asChild:!0,...l,children:(0,b.jsx)(pc,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":Pc(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:P(e.onPointerMove,Hc(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:P(e.onPointerLeave,Hc(e=>{d();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:P(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&Ps[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),Mc=`MenuSubContent`,Nc=y.forwardRef(ks(function(e,t){let n=Qs(ec,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Gs(ec,e.__scopeMenu),s=qs(ec,e.__scopeMenu),c=Oc(Mc,e.__scopeMenu),l=y.useRef(null),d=u(t,l);return(0,b.jsx)(Ls.Provider,{scope:e.__scopeMenu,children:(0,b.jsx)(Ne,{present:r||o.open,children:(0,b.jsx)(Ls.Slot,{scope:e.__scopeMenu,children:(0,b.jsx)(sc,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:d,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:P(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:P(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:P(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Fs[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function Pc(e){return e?`open`:`closed`}ks(Pc,`getOpenState`);function Fc(e){return e===`indeterminate`}ks(Fc,`isIndeterminate`);function Ic(e){return Fc(e)?`indeterminate`:e?`checked`:`unchecked`}ks(Ic,`getCheckedState`);function Lc(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}ks(Lc,`focusFirst`);function Rc(e,t){return e.map((n,r)=>e[(t+r)%e.length])}ks(Rc,`wrapArray`);function zc(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Rc(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}ks(zc,`getNextMatch`);function Bc(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}ks(Bc,`isPointInPolygon`);function Vc(e,t){return t?Bc({x:e.clientX,y:e.clientY},t):!1}ks(Vc,`isPointerInGraceArea`);function Hc(e){return t=>t.pointerType===`mouse`?e(t):void 0}ks(Hc,`whenMouse`);var Uc=Js,Wc=Ys,Gc=$s,Kc=rc,qc=cc,Jc=lc,Yc=fc,Xc=mc,Zc=_c,Qc=yc,$c=Cc,el=wc,tl=Tc,nl=kc,rl=jc,il=Nc,al=e({Arrow:()=>Wl,CheckboxItem:()=>zl,Content:()=>Fl,DropdownMenu:()=>ml,DropdownMenuArrow:()=>Ol,DropdownMenuCheckboxItem:()=>Cl,DropdownMenuContent:()=>yl,DropdownMenuGroup:()=>bl,DropdownMenuItem:()=>Sl,DropdownMenuItemIndicator:()=>El,DropdownMenuLabel:()=>xl,DropdownMenuPortal:()=>_l,DropdownMenuRadioGroup:()=>wl,DropdownMenuRadioItem:()=>Tl,DropdownMenuSeparator:()=>Dl,DropdownMenuSub:()=>kl,DropdownMenuSubContent:()=>jl,DropdownMenuSubTrigger:()=>Al,DropdownMenuTrigger:()=>gl,Group:()=>Il,Item:()=>Rl,ItemIndicator:()=>Hl,Label:()=>Ll,Portal:()=>Pl,RadioGroup:()=>Bl,RadioItem:()=>Vl,Root:()=>Ml,Separator:()=>Ul,Sub:()=>Gl,SubContent:()=>ql,SubTrigger:()=>Kl,Trigger:()=>Nl,createDropdownMenuScope:()=>ul}),ol=Object.defineProperty,sl=(e,t)=>ol(e,`name`,{value:t,configurable:!0}),cl=`DropdownMenu`,[ll,ul]=O(cl,[Vs]),dl=Vs(),[fl,pl]=ll(cl),ml=sl(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=dl(t),l=y.useRef(null),[u,d]=Te({prop:i,defaultProp:a??!1,onChange:o,caller:cl});return(0,b.jsx)(fl,{scope:t,triggerId:Ue(),triggerRef:l,contentId:Ue(),open:u,onOpenChange:d,onOpenToggle:y.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,b.jsx)(Uc,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),hl=`DropdownMenuTrigger`,gl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=pl(hl,n),o=dl(n),s=u(t,a.triggerRef);return(0,b.jsx)(Wc,{asChild:!0,...o,children:(0,b.jsx)(d.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:P(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:P(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),_l=sl(e=>{let{__scopeDropdownMenu:t,...n}=e,r=dl(t);return(0,b.jsx)(Gc,{...r,...n})},`DropdownMenuPortal`),vl=`DropdownMenuContent`,yl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=pl(vl,n),a=dl(n),o=y.useRef(!1);return(0,b.jsx)(Kc,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:P(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:P(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),bl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(qc,{...i,...r,ref:t})},`DropdownMenuGroup`)),xl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Jc,{...i,...r,ref:t})},`DropdownMenuLabel`)),Sl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Yc,{...i,...r,ref:t})},`DropdownMenuItem`)),Cl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Xc,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),wl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Zc,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),Tl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(Qc,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),El=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)($c,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),Dl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(el,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Ol=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(tl,{...i,...r,ref:t})},`DropdownMenuArrow`)),kl=sl(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=dl(t),[s,c]=Te({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,b.jsx)(nl,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),Al=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(rl,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),jl=y.forwardRef(sl(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=dl(n);return(0,b.jsx)(il,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),Ml=ml,Nl=gl,Pl=_l,Fl=yl,Il=bl,Ll=xl,Rl=Sl,zl=Cl,Bl=wl,Vl=Tl,Hl=El,Ul=Dl,Wl=Ol,Gl=kl,Kl=Al,ql=jl,Jl=Object.defineProperty,Yl=(e,t)=>Jl(e,`name`,{value:t,configurable:!0}),[Xl,Zl]=O(`Tooltip`,[jo]),Ql=jo(),$l=`TooltipProvider`,eu=700,tu=`tooltip.open`,[nu,ru]=Xl($l),iu=Yl(e=>{let{__scopeTooltip:t,delayDuration:n=eu,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=y.useRef(!0),s=y.useRef(!1),c=y.useRef(0);return y.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,b.jsx)(nu,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:y.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:y.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),au=`Tooltip`,[ou,su]=Xl(au),cu=Yl(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=ru(au,e.__scopeTooltip),l=Ql(t),[u,d]=y.useState(null),[f,p]=y.useState(void 0),m=Ue(),h=y.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=y.useRef(!1),[x,S]=Te({prop:r,defaultProp:i??!1,onChange:Yl(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(tu))):c.onClose(),a?.(e)},`onChange`),caller:au}),C=y.useMemo(()=>x?v.current?`delayed-open`:`instant-open`:`closed`,[x]),w=y.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,S(!0)},[S]),T=y.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S(!1)},[S]),E=y.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,S(!0),h.current=0},_)},[_,S]);y.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let D=f??m;return(0,b.jsx)(qo,{...l,children:(0,b.jsx)(ou,{scope:t,contentId:D,setContentId:p,open:x,stateAttribute:C,trigger:u,onTriggerChange:d,onTriggerEnter:y.useCallback(()=>{c.isOpenDelayedRef.current?E():w()},[c.isOpenDelayedRef,E,w]),onTriggerLeave:y.useCallback(()=>{g?T():(window.clearTimeout(h.current),h.current=0)},[T,g]),onOpen:w,onClose:T,disableHoverableContent:g,children:n})})},`Tooltip`),lu=`TooltipTrigger`,uu=y.forwardRef(Yl(function(e,t){let{__scopeTooltip:n,...r}=e,i=su(lu,n),a=ru(lu,n),o=Ql(n),s=y.useRef(null),c=u(t,s,i.onTriggerChange),l=y.useRef(!1),f=y.useRef(!1),p=y.useCallback(()=>l.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener(`pointerup`,p),[p]),(0,b.jsx)(Jo,{asChild:!0,...o,children:(0,b.jsx)(d.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:P(e.onPointerMove,e=>{e.pointerType!==`touch`&&!f.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:P(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:P(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener(`pointerup`,p,{once:!0})}),onFocus:P(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:P(e.onBlur,i.onClose),onClick:P(e.onClick,i.onClose)})})},`TooltipTrigger`)),du=`TooltipPortal`,[fu,pu]=Xl(du,{forceMount:void 0}),mu=Yl(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=su(du,t);return(0,b.jsx)(fu,{scope:t,forceMount:n,children:(0,b.jsx)(Ne,{present:n||a.open,children:(0,b.jsx)(Gt,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),hu=`TooltipContent`,gu=y.forwardRef(Yl(function(e,t){let n=pu(hu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=su(hu,e.__scopeTooltip);return(0,b.jsx)(Ne,{present:r||o.open,children:o.disableHoverableContent?(0,b.jsx)(yu,{side:i,...a,ref:t}):(0,b.jsx)(_u,{side:i,...a,ref:t})})},`TooltipContent`)),_u=y.forwardRef(Yl(function(e,t){let n=su(hu,e.__scopeTooltip),r=ru(hu,e.__scopeTooltip),i=y.useRef(null),a=u(t,i),[o,s]=y.useState(null),{trigger:c,onClose:l}=n,d=i.current,{onPointerInTransitChange:f}=r,p=y.useCallback(()=>{s(null),f(!1)},[f]),m=y.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Su(r,xu(r,n.getBoundingClientRect())),a=Cu(t.getBoundingClientRect()),o=Tu([...i,...a]);s(o),f(!0)},[f]);return y.useEffect(()=>()=>p(),[p]),y.useEffect(()=>{if(c&&d){let e=Yl(e=>m(e,d),`handleTriggerLeave`),t=Yl(e=>m(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[c,d,m,p]),y.useEffect(()=>{if(o){let e=Yl(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||d?.contains(t),i=!wu(n,o);r?p():i&&(p(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,d,o,l,p]),(0,b.jsx)(yu,{...e,ref:a})},`TooltipContentHoverable`)),vu=f(`TooltipContent`),yu=y.forwardRef(Yl(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=su(hu,n),u=Ql(n),{onClose:d}=l;y.useEffect(()=>(document.addEventListener(tu,d),()=>document.removeEventListener(tu,d)),[d]),y.useEffect(()=>{if(l.trigger){let e=Yl(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return ge(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,b.jsx)(yt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,b.jsxs)(Yo,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.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:[(0,b.jsx)(vu,{children:r}),i?(0,b.jsx)(w,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),bu=y.forwardRef(Yl(function(e,t){let{__scopeTooltip:n,...r}=e,i=Ql(n);return(0,b.jsx)(Xo,{...i,...r,ref:t})},`TooltipArrow`));function xu(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Yl(xu,`getExitSideFromRect`);function Su(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Yl(Su,`getPaddedExitPoints`);function Cu(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Yl(Cu,`getPointsFromRect`);function wu(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Yl(wu,`isPointInPolygon`);function Tu(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Eu(t)}Yl(Tu,`getHull`);function Eu(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Yl(Eu,`getHullPresorted`);var Du=iu,Ou=cu,ku=uu,Au=mu,ju=gu,Mu=bu,Nu=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Pu={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Fu=new class{#e=Pu;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Iu(e){setTimeout(e,0)}var Lu=typeof window>`u`||`Deno`in globalThis;function Ru(){}function zu(e,t){return typeof e==`function`?e(t):e}function Bu(e){return typeof e==`number`&&e>=0&&e!==1/0}function Vu(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Hu(e,t){return typeof e==`function`?e(t):e}function Uu(e,t){return typeof e==`function`?e(t):e}function Wu(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Ku(o,t.options))return!1}else if(!Ju(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Gu(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(qu(t.options.mutationKey)!==qu(a))return!1}else if(!Ju(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Ku(e,t){return(t?.queryKeyHashFn||qu)(e)}function qu(e){return JSON.stringify(e,(e,t)=>$u(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Ju(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Ju(e[n],t[n])):!1}var Yu=Object.prototype.hasOwnProperty;function Xu(e,t){if(e===t)return e;let n=Qu(e)&&Qu(t);if(!n&&!($u(e)&&$u(t)))return t;let r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),a=i.length,o=n?Array(a):{},s=0;for(let c=0;c<a;c++){let a=n?c:i[c],l=e[a],u=t[a];if(l===u){o[a]=l,(n?c<r:Yu.call(e,a))&&s++;continue}if(l===null||u===null||typeof l!=`object`||typeof u!=`object`){o[a]=u;continue}let d=Xu(l,u);o[a]=d,d===l&&s++}return r===a&&s===r?e:o}function Zu(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Qu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function $u(e){if(!ed(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ed(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ed(e){return Object.prototype.toString.call(e)===`[object Object]`}function td(e){return new Promise(t=>{Fu.setTimeout(t,e)})}function nd(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Xu(e,t)}function rd(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function id(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ad=Symbol();function od(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ad?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function sd(e,t){return typeof e==`function`?e(...t):!!e}var cd=new class extends Nu{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!Lu&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function ld(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ud=Iu;function dd(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ud,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var fd=dd(),pd=new class extends Nu{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!Lu&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function md(e){return Math.min(1e3*2**e,3e4)}function hd(e){return(e??`online`)!==`online`||pd.isOnline()}var gd=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function _d(e){let t=!1,n=0,r,i=ld(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new gd(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>cd.isFocused()&&(e.networkMode===`always`||pd.isOnline())&&e.canRun(),u=()=>hd(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Lu?0:3),o=e.retryDelay??md,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),td(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var vd=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Bu(this.gcTime)&&(this.#e=Fu.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Lu?1/0:3e5))}clearGcTimeout(){this.#e&&=(Fu.clearTimeout(this.#e),void 0)}},yd=class extends vd{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=xd(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=xd(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=nd(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(Ru).catch(Ru):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Uu(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ad||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Hu(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Vu(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=od(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=_d({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof gd&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof gd){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...bd(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:`success`,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),fd.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function bd(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:hd(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function xd(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Sd=class extends Nu{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=ld(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),wd(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Td(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Td(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Uu(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Zu(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Ed(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Uu(this.options.enabled,this.#t)!==Uu(t.enabled,this.#t)||Hu(this.options.staleTime,this.#t)!==Hu(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Uu(this.options.enabled,this.#t)!==Uu(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Od(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`)),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Ru)),t}#g(){this.#b();let e=Hu(this.options.staleTime,this.#t);if(Lu||this.#r.isStale||!Bu(e))return;let t=Vu(this.#r.dataUpdatedAt,e)+1;this.#d=Fu.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!Lu&&Uu(this.options.enabled,this.#t)!==!1&&Bu(this.#p)&&this.#p!==0&&(this.#f=Fu.setInterval(()=>{(this.options.refetchIntervalInBackground||cd.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(Fu.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(Fu.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&wd(e,t),o=i&&Ed(e,n,t,r);(a||o)&&(l={...l,...bd(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=nd(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=nd(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Dd(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Uu(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=e=>{x.status===`error`?e.reject(x.error):x.data!==void 0&&e.resolve(x.data)},r=()=>{let e=this.#o=x.promise=ld();t(e)},i=this.#o;switch(i.status){case`pending`:e.queryHash===n.queryHash&&t(i);break;case`fulfilled`:(x.status===`error`||x.data!==i.value)&&r();break;case`rejected`:(x.status!==`error`||x.error!==i.reason)&&r()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Zu(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){fd.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Cd(e,t){return Uu(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||t.retryOnMount!==!1)}function wd(e,t){return Cd(e,t)||e.state.data!==void 0&&Td(e,t,t.refetchOnMount)}function Td(e,t,n){if(Uu(t.enabled,e)!==!1&&Hu(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Dd(e,t)}return!1}function Ed(e,t,n,r){return(e!==t||Uu(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Dd(e,n)}function Dd(e,t){return Uu(t.enabled,e)!==!1&&e.isStaleByTime(Hu(t.staleTime,e))}function Od(e,t){return!Zu(e.getCurrentResult(),t)}function kd(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener(`abort`,()=>{n=!0}),t.signal)})},u=od(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?id:rd;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?jd:Ad,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ad(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Ad(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function jd(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Md=class extends vd{#e;#t;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Nd(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status===`pending`?this.scheduleGc():this.#t.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#r({type:`continue`})};this.#n=_d({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#r({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#r({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let n=this.state.status===`pending`,r=!this.#n.canStart();try{if(n)t();else{this.#r({type:`pending`,variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#r({type:`pending`,context:t,variables:e,isPaused:r})}let i=await this.#n.start();return await this.#t.config.onSuccess?.(i,e,this.state.context,this),await this.options.onSuccess?.(i,e,this.state.context),await this.#t.config.onSettled?.(i,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(i,null,e,this.state.context),this.#r({type:`success`,data:i}),i}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#r({type:`error`,error:t})}}finally{this.#t.runNext(this)}}#r(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),fd.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:`updated`,action:e})})}};function Nd(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Pd=class extends Nu{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Md({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Fd(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Fd(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Fd(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Fd(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){fd.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Gu(t,e))}findAll(e={}){return this.getAll().filter(t=>Gu(e,t))}notify(e){fd.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return fd.batch(()=>Promise.all(e.map(e=>e.continue().catch(Ru))))}};function Fd(e){return e.options.scope?.id}var Id=class extends Nu{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Zu(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&qu(t.mutationKey)!==qu(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Nd();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){fd.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context;e?.type===`success`?(this.#r.onSuccess?.(e.data,t,n),this.#r.onSettled?.(e.data,null,t,n)):e?.type===`error`&&(this.#r.onError?.(e.error,t,n),this.#r.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach(e=>{e(this.#t)})})}},Ld=class extends Nu{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Ku(r,t),a=this.get(i);return a||(a=new yd({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){fd.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Wu(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Wu(e,t)):t}notify(e){fd.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){fd.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){fd.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Rd=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ld,this.#t=e.mutationCache||new Pd,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=cd.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=pd.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Hu(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=zu(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return fd.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;fd.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return fd.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=fd.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ru).catch(Ru)}invalidateQueries(e,t={}){return fd.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=fd.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Ru)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Ru)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Hu(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ru).catch(Ru)}fetchInfiniteQuery(e){return e.behavior=kd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ru).catch(Ru)}ensureInfiniteQueryData(e){return e.behavior=kd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return pd.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(qu(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Ju(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(qu(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Ju(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ku(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ad&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},zd=y.createContext(void 0),Bd=e=>{let t=y.useContext(zd);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Vd=({client:e,children:t})=>(y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,b.jsx)(zd.Provider,{value:e,children:t})),Hd=y.createContext(!1),Ud=()=>y.useContext(Hd);Hd.Provider;function Wd(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Gd=y.createContext(Wd()),Kd=()=>y.useContext(Gd),qd=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Jd=e=>{y.useEffect(()=>{e.clearReset()},[e])},Yd=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||sd(n,[e.error,r])),Xd=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Zd=(e,t)=>e.isLoading&&e.isFetching&&!t,Qd=(e,t)=>e?.suspense&&t.isPending,$d=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function ef(e,t,n){let r=Ud(),i=Kd(),a=Bd(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Xd(o),qd(o,i),Jd(i);let s=!a.getQueryCache().get(o.queryHash),[c]=y.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!r&&e.subscribed!==!1;if(y.useSyncExternalStore(y.useCallback(e=>{let t=u?c.subscribe(fd.batchCalls(e)):Ru;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),y.useEffect(()=>{c.setOptions(o)},[o,c]),Qd(o,l))throw $d(o,c,i);if(Yd({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!Lu&&Zd(l,r)&&(s?$d(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ru).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function tf(e,t){return ef(e,Sd,t)}function nf(e,t){let n=Bd(t),[r]=y.useState(()=>new Id(n,e));y.useEffect(()=>{r.setOptions(e)},[r,e]);let i=y.useSyncExternalStore(y.useCallback(e=>r.subscribe(fd.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=y.useCallback((e,t)=>{r.mutate(e,t).catch(Ru)},[r]);if(i.error&&sd(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var rf=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),af=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),of=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),sf=e=>{let t=of(e);return t.charAt(0).toUpperCase()+t.slice(1)},cf={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},lf=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},uf=(0,y.createContext)({}),df=()=>(0,y.useContext)(uf),ff=(0,y.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=df()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,y.createElement)(`svg`,{ref:c,...cf,width:t??l??cf.width,height:t??l??cf.height,stroke:e??f,strokeWidth:m,className:rf(`lucide`,p,i),...!a&&!lf(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,y.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),F=(e,t)=>{let n=(0,y.forwardRef)(({className:n,...r},i)=>(0,y.createElement)(ff,{ref:i,iconNode:t,className:rf(`lucide-${af(sf(e))}`,`lucide-${e}`,n),...r}));return n.displayName=sf(e),n},pf=F(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),mf=F(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),hf=F(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),gf=F(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),_f=F(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),vf=F(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),yf=F(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),bf=F(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),xf=F(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Sf=F(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Cf=F(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),wf=F(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Tf=F(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Ef=F(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Df=F(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Of=F(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]]),kf=F(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Af=F(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),jf=F(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Mf=F(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Nf=F(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Pf=F(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),Ff=F(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),If=F(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Lf=F(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Rf=F(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),zf=F(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Bf=F(`flame`,[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]),Vf=F(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Hf=F(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),Uf=F(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Wf=F(`key`,[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]),Gf=F(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Kf=F(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),qf=F(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Jf=F(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),Yf=F(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),Xf=F(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),Zf=F(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Qf=F(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),$f=F(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),ep=F(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),tp=F(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),np=F(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),rp=F(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),ip=F(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),ap=F(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),op=F(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),sp=F(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),cp=F(`shield-question-mark`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),lp=F(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),up=F(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),dp=F(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),fp=F(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),pp=F(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),mp=F(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),hp=F(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),gp=F(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),_p=F(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),vp=F(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),yp=F(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),bp=F(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);Object.freeze({status:`aborted`});function I(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var xp=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Sp=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},Cp={};function wp(e){return e&&Object.assign(Cp,e),Cp}function Tp(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Ep(e,t){return typeof t==`bigint`?t.toString():t}function Dp(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Op(e){return e==null}function kp(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Ap(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var jp=Symbol(`evaluating`);function Mp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jp)return r===void 0&&(r=jp,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Np(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Pp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fp(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ip(e){return JSON.stringify(e)}var Lp=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Rp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var zp=Dp(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Bp(e){if(Rp(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return Rp(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Vp(e){return Bp(e)?{...e}:Array.isArray(e)?[...e]:e}var Hp=new Set([`string`,`number`,`symbol`]);function Up(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Wp(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Gp(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Kp={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function qp(e,t){let n=e._zod.def;return Wp(e,Fp(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Pp(this,`shape`,e),e},checks:[]}))}function Jp(e,t){let n=e._zod.def;return Wp(e,Fp(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Pp(this,`shape`,r),r},checks:[]}))}function Yp(e,t){if(!Bp(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return Wp(e,Fp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Pp(this,`shape`,n),n},checks:[]}))}function Xp(e,t){if(!Bp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Wp(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Pp(this,`shape`,n),n},checks:e._zod.def.checks})}function Zp(e,t){return Wp(e,Fp(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Pp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Qp(e,t,n){return Wp(t,Fp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Pp(this,`shape`,i),i},checks:[]}))}function $p(e,t,n){return Wp(t,Fp(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Pp(this,`shape`,i),i},checks:[]}))}function em(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function tm(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function nm(e){return typeof e==`string`?e:e?.message}function rm(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=nm(e.inst?._zod.def?.error?.(e))??nm(t?.error?.(e))??nm(n.customError?.(e))??nm(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function im(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function am(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var om=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ep,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sm=I(`$ZodError`,om),cm=I(`$ZodError`,om,{Parent:Error});function lm(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function um(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var dm=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new xp;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>rm(e,a,wp())));throw Lp(t,i?.callee),t}return o.value},fm=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>rm(e,a,wp())));throw Lp(t,i?.callee),t}return o.value},pm=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new xp;return a.issues.length?{success:!1,error:new(e??sm)(a.issues.map(e=>rm(e,i,wp())))}:{success:!0,data:a.value}},mm=pm(cm),hm=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>rm(e,i,wp())))}:{success:!0,data:a.value}},gm=hm(cm),_m=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return dm(e)(t,n,i)},vm=e=>(t,n,r)=>dm(e)(t,n,r),ym=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return fm(e)(t,n,i)},bm=e=>async(t,n,r)=>fm(e)(t,n,r),xm=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return pm(e)(t,n,i)},Sm=e=>(t,n,r)=>pm(e)(t,n,r),Cm=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return hm(e)(t,n,i)},wm=e=>async(t,n,r)=>hm(e)(t,n,r),Tm=/^[cC][^\s-]{8,}$/,Em=/^[0-9a-z]+$/,Dm=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Om=/^[0-9a-vA-V]{20}$/,km=/^[A-Za-z0-9]{27}$/,Am=/^[a-zA-Z0-9_-]{21}$/,jm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mm=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Nm=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Pm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Fm=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Im(){return new RegExp(Fm,`u`)}var Lm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Rm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,zm=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Bm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Hm=/^[A-Za-z0-9_-]*$/,Um=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Wm=/^\+(?:[0-9]){6,14}[0-9]$/,Gm=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Km=RegExp(`^${Gm}$`);function qm(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Jm(e){return RegExp(`^${qm(e)}$`)}function Ym(e){let t=qm({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Gm}T(?:${r})$`)}var Xm=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Zm=/^-?\d+$/,Qm=/^-?\d+(?:\.\d+)?/,$m=/^(?:true|false)$/i,eh=/^null$/i,th=/^[^A-Z]*$/,nh=/^[^a-z]*$/,rh=I(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ih={number:`number`,bigint:`bigint`,object:`date`},ah=I(`$ZodCheckLessThan`,(e,t)=>{rh.init(e,t);let n=ih[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),oh=I(`$ZodCheckGreaterThan`,(e,t)=>{rh.init(e,t);let n=ih[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),sh=I(`$ZodCheckMultipleOf`,(e,t)=>{rh.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Ap(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ch=I(`$ZodCheckNumberFormat`,(e,t)=>{rh.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Kp[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Zm)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),lh=I(`$ZodCheckMaxLength`,(e,t)=>{var n;rh.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Op(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=im(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),uh=I(`$ZodCheckMinLength`,(e,t)=>{var n;rh.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Op(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=im(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),dh=I(`$ZodCheckLengthEquals`,(e,t)=>{var n;rh.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Op(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=im(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),fh=I(`$ZodCheckStringFormat`,(e,t)=>{var n,r;rh.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ph=I(`$ZodCheckRegex`,(e,t)=>{fh.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),mh=I(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=th,fh.init(e,t)}),hh=I(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=nh,fh.init(e,t)}),gh=I(`$ZodCheckIncludes`,(e,t)=>{rh.init(e,t);let n=Up(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),_h=I(`$ZodCheckStartsWith`,(e,t)=>{rh.init(e,t);let n=RegExp(`^${Up(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),vh=I(`$ZodCheckEndsWith`,(e,t)=>{rh.init(e,t);let n=RegExp(`.*${Up(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),yh=I(`$ZodCheckOverwrite`,(e,t)=>{rh.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),bh=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
42
42
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
43
- `))}},hh={major:4,minor:1,patch:8},gh=I(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hh;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Jp(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new hp;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Jp(e,t))});else{if(e.issues.length===t)continue;r||=Jp(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Jp(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new hp;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new hp;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=cm(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return um(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),_h=I(`$ZodString`,(e,t)=>{gh.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Wm(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),vh=I(`$ZodStringFormat`,(e,t)=>{oh.init(e,t),_h.init(e,t)}),yh=I(`$ZodGUID`,(e,t)=>{t.pattern??=Em,vh.init(e,t)}),bh=I(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Dm(e)}else t.pattern??=Dm();vh.init(e,t)}),xh=I(`$ZodEmail`,(e,t)=>{t.pattern??=Om,vh.init(e,t)}),Sh=I(`$ZodURL`,(e,t)=>{vh.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:Lm.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Ch=I(`$ZodEmoji`,(e,t)=>{t.pattern??=Am(),vh.init(e,t)}),wh=I(`$ZodNanoID`,(e,t)=>{t.pattern??=wm,vh.init(e,t)}),Th=I(`$ZodCUID`,(e,t)=>{t.pattern??=ym,vh.init(e,t)}),Eh=I(`$ZodCUID2`,(e,t)=>{t.pattern??=bm,vh.init(e,t)}),Dh=I(`$ZodULID`,(e,t)=>{t.pattern??=xm,vh.init(e,t)}),Oh=I(`$ZodXID`,(e,t)=>{t.pattern??=Sm,vh.init(e,t)}),kh=I(`$ZodKSUID`,(e,t)=>{t.pattern??=Cm,vh.init(e,t)}),Ah=I(`$ZodISODateTime`,(e,t)=>{t.pattern??=Um(t),vh.init(e,t)}),jh=I(`$ZodISODate`,(e,t)=>{t.pattern??=Bm,vh.init(e,t)}),Mh=I(`$ZodISOTime`,(e,t)=>{t.pattern??=Hm(t),vh.init(e,t)}),Nh=I(`$ZodISODuration`,(e,t)=>{t.pattern??=Tm,vh.init(e,t)}),Ph=I(`$ZodIPv4`,(e,t)=>{t.pattern??=jm,vh.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),Fh=I(`$ZodIPv6`,(e,t)=>{t.pattern??=Mm,vh.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Ih=I(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Nm,vh.init(e,t)}),Lh=I(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Pm,vh.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Rh(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var zh=I(`$ZodBase64`,(e,t)=>{t.pattern??=Fm,vh.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Rh(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Bh(e){if(!Im.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Rh(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Vh=I(`$ZodBase64URL`,(e,t)=>{t.pattern??=Im,vh.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{Bh(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Hh=I(`$ZodE164`,(e,t)=>{t.pattern??=Rm,vh.init(e,t)});function Uh(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Wh=I(`$ZodJWT`,(e,t)=>{vh.init(e,t),e._zod.check=n=>{Uh(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Gh=I(`$ZodNumber`,(e,t)=>{gh.init(e,t),e._zod.pattern=e._zod.bag.pattern??Km,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Kh=I(`$ZodNumber`,(e,t)=>{nh.init(e,t),Gh.init(e,t)}),qh=I(`$ZodBoolean`,(e,t)=>{gh.init(e,t),e._zod.pattern=qm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Jh=I(`$ZodNull`,(e,t)=>{gh.init(e,t),e._zod.pattern=Jm,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Yh=I(`$ZodUnknown`,(e,t)=>{gh.init(e,t),e._zod.parse=e=>e}),Xh=I(`$ZodNever`,(e,t)=>{gh.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Zh(e,t,n){e.issues.length&&t.issues.push(...Yp(n,e.issues)),t.value[n]=e.value}var Qh=I(`$ZodArray`,(e,t)=>{gh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Zh(t,n,e))):Zh(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function $h(e,t,n,r){e.issues.length&&t.issues.push(...Yp(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function eg(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=zp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function tg(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>$h(e,n,i,t))):$h(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var ng=I(`$ZodObject`,(e,t)=>{gh.init(e,t);let n=xp(()=>eg(t));Ep(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Mp,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>$h(n,t,e,s))):$h(n,t,e,s)}return i?tg(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),rg=I(`$ZodObjectJIT`,(e,t)=>{ng.init(e,t);let n=e._zod.parse,r=xp(()=>eg(t)),i=e=>{let t=new mh([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Ap(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=Ap(e);t.write(`const ${n} = ${i(e)};`),t.write(`
43
+ `))}},xh={major:4,minor:1,patch:8},Sh=I(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=xh;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=em(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new xp;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=em(e,t))});else{if(e.issues.length===t)continue;r||=em(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(em(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new xp;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new xp;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=mm(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return gm(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Ch=I(`$ZodString`,(e,t)=>{Sh.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Xm(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),wh=I(`$ZodStringFormat`,(e,t)=>{fh.init(e,t),Ch.init(e,t)}),Th=I(`$ZodGUID`,(e,t)=>{t.pattern??=Mm,wh.init(e,t)}),Eh=I(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Nm(e)}else t.pattern??=Nm();wh.init(e,t)}),Dh=I(`$ZodEmail`,(e,t)=>{t.pattern??=Pm,wh.init(e,t)}),Oh=I(`$ZodURL`,(e,t)=>{wh.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:Um.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),kh=I(`$ZodEmoji`,(e,t)=>{t.pattern??=Im(),wh.init(e,t)}),Ah=I(`$ZodNanoID`,(e,t)=>{t.pattern??=Am,wh.init(e,t)}),jh=I(`$ZodCUID`,(e,t)=>{t.pattern??=Tm,wh.init(e,t)}),Mh=I(`$ZodCUID2`,(e,t)=>{t.pattern??=Em,wh.init(e,t)}),Nh=I(`$ZodULID`,(e,t)=>{t.pattern??=Dm,wh.init(e,t)}),Ph=I(`$ZodXID`,(e,t)=>{t.pattern??=Om,wh.init(e,t)}),Fh=I(`$ZodKSUID`,(e,t)=>{t.pattern??=km,wh.init(e,t)}),Ih=I(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ym(t),wh.init(e,t)}),Lh=I(`$ZodISODate`,(e,t)=>{t.pattern??=Km,wh.init(e,t)}),Rh=I(`$ZodISOTime`,(e,t)=>{t.pattern??=Jm(t),wh.init(e,t)}),zh=I(`$ZodISODuration`,(e,t)=>{t.pattern??=jm,wh.init(e,t)}),Bh=I(`$ZodIPv4`,(e,t)=>{t.pattern??=Lm,wh.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),Vh=I(`$ZodIPv6`,(e,t)=>{t.pattern??=Rm,wh.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Hh=I(`$ZodCIDRv4`,(e,t)=>{t.pattern??=zm,wh.init(e,t)}),Uh=I(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Bm,wh.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Wh(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Gh=I(`$ZodBase64`,(e,t)=>{t.pattern??=Vm,wh.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Wh(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Kh(e){if(!Hm.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Wh(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var qh=I(`$ZodBase64URL`,(e,t)=>{t.pattern??=Hm,wh.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{Kh(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Jh=I(`$ZodE164`,(e,t)=>{t.pattern??=Wm,wh.init(e,t)});function Yh(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Xh=I(`$ZodJWT`,(e,t)=>{wh.init(e,t),e._zod.check=n=>{Yh(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Zh=I(`$ZodNumber`,(e,t)=>{Sh.init(e,t),e._zod.pattern=e._zod.bag.pattern??Qm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Qh=I(`$ZodNumber`,(e,t)=>{ch.init(e,t),Zh.init(e,t)}),$h=I(`$ZodBoolean`,(e,t)=>{Sh.init(e,t),e._zod.pattern=$m,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),eg=I(`$ZodNull`,(e,t)=>{Sh.init(e,t),e._zod.pattern=eh,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),tg=I(`$ZodUnknown`,(e,t)=>{Sh.init(e,t),e._zod.parse=e=>e}),ng=I(`$ZodNever`,(e,t)=>{Sh.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function rg(e,t,n){e.issues.length&&t.issues.push(...tm(n,e.issues)),t.value[n]=e.value}var ig=I(`$ZodArray`,(e,t)=>{Sh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>rg(t,n,e))):rg(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function ag(e,t,n,r){e.issues.length&&t.issues.push(...tm(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function og(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Gp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function sg(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ag(e,n,i,t))):ag(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var cg=I(`$ZodObject`,(e,t)=>{Sh.init(e,t);let n=Dp(()=>og(t));Mp(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Rp,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>ag(n,t,e,s))):ag(n,t,e,s)}return i?sg(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),lg=I(`$ZodObjectJIT`,(e,t)=>{cg.init(e,t);let n=e._zod.parse,r=Dp(()=>og(t)),i=e=>{let t=new bh([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Ip(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=Ip(e);t.write(`const ${n} = ${i(e)};`),t.write(`
44
44
  if (${n}.issues.length) {
45
45
  payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
46
46
  ...iss,
@@ -57,40 +57,40 @@ import{i as e,n as t,o as n,r,t as i}from"./react-dom.B--7n7g5.js";import{_ as a
57
57
  newResult[${r}] = ${n}.value;
58
58
  }
59
59
 
60
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Mp,s=!_p.jitless,c=s&&Np.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?tg([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ig(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Jp(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Zp(e,r,vp())))}),t)}var ag=I(`$ZodUnion`,(e,t)=>{gh.init(e,t),Ep(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Ep(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Ep(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ep(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Cp(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>ig(t,i,e,a)):ig(s,i,e,a)}}),og=I(`$ZodIntersection`,(e,t)=>{gh.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>cg(e,t,n)):cg(e,i,a)}});function sg(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Pp(e)&&Pp(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=sg(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=sg(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function cg(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Jp(e))return e;let r=sg(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var lg=I(`$ZodRecord`,(e,t)=>{gh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Pp(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Yp(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Yp(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Zp(e,r,vp())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Yp(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Yp(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ug=I(`$ZodEnum`,(e,t)=>{gh.init(e,t);let n=yp(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Ip.has(typeof e)).map(e=>typeof e==`string`?Lp(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),dg=I(`$ZodLiteral`,(e,t)=>{if(gh.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Lp(e):e?Lp(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),fg=I(`$ZodTransform`,(e,t)=>{gh.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new gp(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new hp;return n.value=i,n}});function pg(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var mg=I(`$ZodOptional`,(e,t)=>{gh.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Ep(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ep(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Cp(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>pg(t,e.value)):pg(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),hg=I(`$ZodNullable`,(e,t)=>{gh.init(e,t),Ep(e._zod,`optin`,()=>t.innerType._zod.optin),Ep(e._zod,`optout`,()=>t.innerType._zod.optout),Ep(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Cp(e.source)}|null)$`):void 0}),Ep(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),gg=I(`$ZodDefault`,(e,t)=>{gh.init(e,t),e._zod.optin=`optional`,Ep(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>_g(e,t)):_g(r,t)}});function _g(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var vg=I(`$ZodPrefault`,(e,t)=>{gh.init(e,t),e._zod.optin=`optional`,Ep(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),yg=I(`$ZodNonOptional`,(e,t)=>{gh.init(e,t),Ep(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>bg(t,e)):bg(i,e)}});function bg(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var xg=I(`$ZodCatch`,(e,t)=>{gh.init(e,t),Ep(e._zod,`optin`,()=>t.innerType._zod.optin),Ep(e._zod,`optout`,()=>t.innerType._zod.optout),Ep(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Zp(e,n,vp()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Zp(e,n,vp()))},input:e.value}),e.issues=[]),e)}}),Sg=I(`$ZodPipe`,(e,t)=>{gh.init(e,t),Ep(e._zod,`values`,()=>t.in._zod.values),Ep(e._zod,`optin`,()=>t.in._zod.optin),Ep(e._zod,`optout`,()=>t.out._zod.optout),Ep(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Cg(e,t.in,n)):Cg(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Cg(e,t.out,n)):Cg(r,t.out,n)}});function Cg(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var wg=I(`$ZodReadonly`,(e,t)=>{gh.init(e,t),Ep(e._zod,`propValues`,()=>t.innerType._zod.propValues),Ep(e._zod,`values`,()=>t.innerType._zod.values),Ep(e._zod,`optin`,()=>t.innerType._zod.optin),Ep(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Tg):Tg(r)}});function Tg(e){return e.value=Object.freeze(e.value),e}var Eg=I(`$ZodLazy`,(e,t)=>{gh.init(e,t),Ep(e._zod,`innerType`,()=>t.getter()),Ep(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),Ep(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),Ep(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),Ep(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Dg=I(`$ZodCustom`,(e,t)=>{Zm.init(e,t),gh.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Og(t,n,r,e));Og(i,n,r,e)}});function Og(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push($p(e))}}var kg=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ag(){return new kg}var jg=Ag();function Mg(e,t){return new e({type:`string`,...L(t)})}function Ng(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function Pg(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function Fg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function Ig(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function Lg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Rg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function zg(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function Bg(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function Vg(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Hg(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Ug(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Wg(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Gg(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function Kg(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function qg(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function Jg(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function Yg(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function Xg(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function Zg(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function Qg(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function $g(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function e_(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function t_(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function n_(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function r_(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function i_(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function a_(e,t){return new e({type:`number`,checks:[],...L(t)})}function o_(e,t){return new e({type:`number`,coerce:!0,checks:[],...L(t)})}function s_(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function c_(e,t){return new e({type:`boolean`,...L(t)})}function l_(e,t){return new e({type:`null`,...L(t)})}function u_(e){return new e({type:`unknown`})}function d_(e,t){return new e({type:`never`,...L(t)})}function f_(e,t){return new $m({check:`less_than`,...L(t),value:e,inclusive:!1})}function p_(e,t){return new $m({check:`less_than`,...L(t),value:e,inclusive:!0})}function m_(e,t){return new eh({check:`greater_than`,...L(t),value:e,inclusive:!1})}function h_(e,t){return new eh({check:`greater_than`,...L(t),value:e,inclusive:!0})}function g_(e,t){return new th({check:`multiple_of`,...L(t),value:e})}function __(e,t){return new rh({check:`max_length`,...L(t),maximum:e})}function v_(e,t){return new ih({check:`min_length`,...L(t),minimum:e})}function y_(e,t){return new ah({check:`length_equals`,...L(t),length:e})}function b_(e,t){return new sh({check:`string_format`,format:`regex`,...L(t),pattern:e})}function x_(e){return new ch({check:`string_format`,format:`lowercase`,...L(e)})}function S_(e){return new lh({check:`string_format`,format:`uppercase`,...L(e)})}function C_(e,t){return new uh({check:`string_format`,format:`includes`,...L(t),includes:e})}function w_(e,t){return new dh({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function T_(e,t){return new fh({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function E_(e){return new ph({check:`overwrite`,tx:e})}function D_(e){return E_(t=>t.normalize(e))}function O_(){return E_(e=>e.trim())}function k_(){return E_(e=>e.toLowerCase())}function A_(){return E_(e=>e.toUpperCase())}function j_(e,t,n){return new e({type:`array`,element:t,...L(n)})}function M_(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function N_(e){let t=P_(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push($p(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push($p(r))}},e(n.value,n)));return t}function P_(e,t){let n=new Zm({check:`custom`,...L(t)});return n._zod.check=e,n}var F_=I(`ZodISODateTime`,(e,t)=>{Ah.init(e,t),ov.init(e,t)});function I_(e){return t_(F_,e)}var L_=I(`ZodISODate`,(e,t)=>{jh.init(e,t),ov.init(e,t)});function R_(e){return n_(L_,e)}var z_=I(`ZodISOTime`,(e,t)=>{Mh.init(e,t),ov.init(e,t)});function B_(e){return r_(z_,e)}var V_=I(`ZodISODuration`,(e,t)=>{Nh.init(e,t),ov.init(e,t)});function H_(e){return i_(V_,e)}var U_=(e,t)=>{tm.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>im(e,t)},flatten:{value:t=>rm(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,bp,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,bp,2)}},isEmpty:{get(){return e.issues.length===0}}})};I(`ZodError`,U_);var W_=I(`ZodError`,U_,{Parent:Error}),G_=am(W_),K_=om(W_),q_=sm(W_),J_=lm(W_),Y_=dm(W_),X_=fm(W_),Z_=pm(W_),Q_=mm(W_),$_=hm(W_),ev=gm(W_),tv=_m(W_),nv=vm(W_),rv=I(`ZodType`,(e,t)=>(gh.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>Rp(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>G_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>q_(e,t,n),e.parseAsync=async(t,n)=>K_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>J_(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Y_(e,t,n),e.decode=(t,n)=>X_(e,t,n),e.encodeAsync=async(t,n)=>Z_(e,t,n),e.decodeAsync=async(t,n)=>Q_(e,t,n),e.safeEncode=(t,n)=>$_(e,t,n),e.safeDecode=(t,n)=>ev(e,t,n),e.safeEncodeAsync=async(t,n)=>tv(e,t,n),e.safeDecodeAsync=async(t,n)=>nv(e,t,n),e.refine=(t,n)=>e.check(hy(t,n)),e.superRefine=t=>e.check(gy(t)),e.overwrite=t=>e.check(E_(t)),e.optional=()=>Zv(e),e.nullable=()=>$v(e),e.nullish=()=>Zv($v(e)),e.nonoptional=t=>ay(e,t),e.array=()=>B(e),e.or=t=>Bv([e,t]),e.and=t=>Hv(e,t),e.transform=t=>ly(e,Yv(t)),e.default=t=>ty(e,t),e.prefault=t=>ry(e,t),e.catch=t=>sy(e,t),e.pipe=t=>ly(e,t),e.readonly=()=>dy(e),e.describe=t=>{let n=e.clone();return jg.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return jg.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return jg.get(e);let n=e.clone();return jg.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),iv=I(`_ZodString`,(e,t)=>{_h.init(e,t),rv.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(b_(...t)),e.includes=(...t)=>e.check(C_(...t)),e.startsWith=(...t)=>e.check(w_(...t)),e.endsWith=(...t)=>e.check(T_(...t)),e.min=(...t)=>e.check(v_(...t)),e.max=(...t)=>e.check(__(...t)),e.length=(...t)=>e.check(y_(...t)),e.nonempty=(...t)=>e.check(v_(1,...t)),e.lowercase=t=>e.check(x_(t)),e.uppercase=t=>e.check(S_(t)),e.trim=()=>e.check(O_()),e.normalize=(...t)=>e.check(D_(...t)),e.toLowerCase=()=>e.check(k_()),e.toUpperCase=()=>e.check(A_())}),av=I(`ZodString`,(e,t)=>{_h.init(e,t),iv.init(e,t),e.email=t=>e.check(Ng(sv,t)),e.url=t=>e.check(zg(uv,t)),e.jwt=t=>e.check(e_(Tv,t)),e.emoji=t=>e.check(Bg(dv,t)),e.guid=t=>e.check(Pg(cv,t)),e.uuid=t=>e.check(Fg(lv,t)),e.uuidv4=t=>e.check(Ig(lv,t)),e.uuidv6=t=>e.check(Lg(lv,t)),e.uuidv7=t=>e.check(Rg(lv,t)),e.nanoid=t=>e.check(Vg(fv,t)),e.guid=t=>e.check(Pg(cv,t)),e.cuid=t=>e.check(Hg(pv,t)),e.cuid2=t=>e.check(Ug(mv,t)),e.ulid=t=>e.check(Wg(hv,t)),e.base64=t=>e.check(Zg(Sv,t)),e.base64url=t=>e.check(Qg(Cv,t)),e.xid=t=>e.check(Gg(gv,t)),e.ksuid=t=>e.check(Kg(_v,t)),e.ipv4=t=>e.check(qg(vv,t)),e.ipv6=t=>e.check(Jg(yv,t)),e.cidrv4=t=>e.check(Yg(bv,t)),e.cidrv6=t=>e.check(Xg(xv,t)),e.e164=t=>e.check($g(wv,t)),e.datetime=t=>e.check(I_(t)),e.date=t=>e.check(R_(t)),e.time=t=>e.check(B_(t)),e.duration=t=>e.check(H_(t))});function R(e){return Mg(av,e)}var ov=I(`ZodStringFormat`,(e,t)=>{vh.init(e,t),iv.init(e,t)}),sv=I(`ZodEmail`,(e,t)=>{xh.init(e,t),ov.init(e,t)}),cv=I(`ZodGUID`,(e,t)=>{yh.init(e,t),ov.init(e,t)}),lv=I(`ZodUUID`,(e,t)=>{bh.init(e,t),ov.init(e,t)}),uv=I(`ZodURL`,(e,t)=>{Sh.init(e,t),ov.init(e,t)}),dv=I(`ZodEmoji`,(e,t)=>{Ch.init(e,t),ov.init(e,t)}),fv=I(`ZodNanoID`,(e,t)=>{wh.init(e,t),ov.init(e,t)}),pv=I(`ZodCUID`,(e,t)=>{Th.init(e,t),ov.init(e,t)}),mv=I(`ZodCUID2`,(e,t)=>{Eh.init(e,t),ov.init(e,t)}),hv=I(`ZodULID`,(e,t)=>{Dh.init(e,t),ov.init(e,t)}),gv=I(`ZodXID`,(e,t)=>{Oh.init(e,t),ov.init(e,t)}),_v=I(`ZodKSUID`,(e,t)=>{kh.init(e,t),ov.init(e,t)}),vv=I(`ZodIPv4`,(e,t)=>{Ph.init(e,t),ov.init(e,t)}),yv=I(`ZodIPv6`,(e,t)=>{Fh.init(e,t),ov.init(e,t)}),bv=I(`ZodCIDRv4`,(e,t)=>{Ih.init(e,t),ov.init(e,t)}),xv=I(`ZodCIDRv6`,(e,t)=>{Lh.init(e,t),ov.init(e,t)}),Sv=I(`ZodBase64`,(e,t)=>{zh.init(e,t),ov.init(e,t)}),Cv=I(`ZodBase64URL`,(e,t)=>{Vh.init(e,t),ov.init(e,t)}),wv=I(`ZodE164`,(e,t)=>{Hh.init(e,t),ov.init(e,t)}),Tv=I(`ZodJWT`,(e,t)=>{Wh.init(e,t),ov.init(e,t)}),Ev=I(`ZodNumber`,(e,t)=>{Gh.init(e,t),rv.init(e,t),e.gt=(t,n)=>e.check(m_(t,n)),e.gte=(t,n)=>e.check(h_(t,n)),e.min=(t,n)=>e.check(h_(t,n)),e.lt=(t,n)=>e.check(f_(t,n)),e.lte=(t,n)=>e.check(p_(t,n)),e.max=(t,n)=>e.check(p_(t,n)),e.int=t=>e.check(Ov(t)),e.safe=t=>e.check(Ov(t)),e.positive=t=>e.check(m_(0,t)),e.nonnegative=t=>e.check(h_(0,t)),e.negative=t=>e.check(f_(0,t)),e.nonpositive=t=>e.check(p_(0,t)),e.multipleOf=(t,n)=>e.check(g_(t,n)),e.step=(t,n)=>e.check(g_(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function z(e){return a_(Ev,e)}var Dv=I(`ZodNumberFormat`,(e,t)=>{Kh.init(e,t),Ev.init(e,t)});function Ov(e){return s_(Dv,e)}var kv=I(`ZodBoolean`,(e,t)=>{qh.init(e,t),rv.init(e,t)});function Av(e){return c_(kv,e)}var jv=I(`ZodNull`,(e,t)=>{Jh.init(e,t),rv.init(e,t)});function Mv(e){return l_(jv,e)}var Nv=I(`ZodUnknown`,(e,t)=>{Yh.init(e,t),rv.init(e,t)});function Pv(){return u_(Nv)}var Fv=I(`ZodNever`,(e,t)=>{Xh.init(e,t),rv.init(e,t)});function Iv(e){return d_(Fv,e)}var Lv=I(`ZodArray`,(e,t)=>{Qh.init(e,t),rv.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(v_(t,n)),e.nonempty=t=>e.check(v_(1,t)),e.max=(t,n)=>e.check(__(t,n)),e.length=(t,n)=>e.check(y_(t,n)),e.unwrap=()=>e.element});function B(e,t){return j_(Lv,e,t)}var Rv=I(`ZodObject`,(e,t)=>{rg.init(e,t),rv.init(e,t),Ep(e,`shape`,()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Pv()}),e.loose=()=>e.clone({...e._zod.def,catchall:Pv()}),e.strict=()=>e.clone({...e._zod.def,catchall:Iv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Up(e,t),e.safeExtend=t=>Wp(e,t),e.merge=t=>Gp(e,t),e.pick=t=>Vp(e,t),e.omit=t=>Hp(e,t),e.partial=(...t)=>Kp(Xv,e,t[0]),e.required=(...t)=>qp(iy,e,t[0])});function V(e,t){return new Rv({type:`object`,get shape(){return Op(this,`shape`,e?Dp(e):{}),this.shape},...L(t)})}var zv=I(`ZodUnion`,(e,t)=>{ag.init(e,t),rv.init(e,t),e.options=t.options});function Bv(e,t){return new zv({type:`union`,options:e,...L(t)})}var Vv=I(`ZodIntersection`,(e,t)=>{og.init(e,t),rv.init(e,t)});function Hv(e,t){return new Vv({type:`intersection`,left:e,right:t})}var Uv=I(`ZodRecord`,(e,t)=>{lg.init(e,t),rv.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Wv(e,t,n){return new Uv({type:`record`,keyType:e,valueType:t,...L(n)})}var Gv=I(`ZodEnum`,(e,t)=>{ug.init(e,t),rv.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Gv({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Gv({...t,checks:[],...L(r),entries:i})}});function H(e,t){return new Gv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Kv=I(`ZodLiteral`,(e,t)=>{dg.init(e,t),rv.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function qv(e,t){return new Kv({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Jv=I(`ZodTransform`,(e,t)=>{fg.init(e,t),rv.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new gp(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push($p(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push($p(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Yv(e){return new Jv({type:`transform`,transform:e})}var Xv=I(`ZodOptional`,(e,t)=>{mg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Zv(e){return new Xv({type:`optional`,innerType:e})}var Qv=I(`ZodNullable`,(e,t)=>{hg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function $v(e){return new Qv({type:`nullable`,innerType:e})}var ey=I(`ZodDefault`,(e,t)=>{gg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ty(e,t){return new ey({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Fp(t)}})}var ny=I(`ZodPrefault`,(e,t)=>{vg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ry(e,t){return new ny({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Fp(t)}})}var iy=I(`ZodNonOptional`,(e,t)=>{yg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ay(e,t){return new iy({type:`nonoptional`,innerType:e,...L(t)})}var oy=I(`ZodCatch`,(e,t)=>{xg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sy(e,t){return new oy({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var cy=I(`ZodPipe`,(e,t)=>{Sg.init(e,t),rv.init(e,t),e.in=t.in,e.out=t.out});function ly(e,t){return new cy({type:`pipe`,in:e,out:t})}var uy=I(`ZodReadonly`,(e,t)=>{wg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function dy(e){return new uy({type:`readonly`,innerType:e})}var fy=I(`ZodLazy`,(e,t)=>{Eg.init(e,t),rv.init(e,t),e.unwrap=()=>e._zod.def.getter()});function py(e){return new fy({type:`lazy`,getter:e})}var my=I(`ZodCustom`,(e,t)=>{Dg.init(e,t),rv.init(e,t)});function hy(e,t={}){return M_(my,e,t)}function gy(e){return N_(e)}function _y(e){let t=py(()=>Bv([R(e),z(),Av(),Mv(),B(t),Wv(R(),t)]));return t}function vy(e){return o_(Ev,e)}var U=R().uuid(),W=R().datetime({offset:!0}),yy=R().regex(/^[a-f0-9]{64}$/);R().trim().min(1);var by=H([`owner`,`admin`,`security_manager`,`operator`,`viewer`,`auditor`]),xy=H([`R0`,`R1`,`R2`]),Sy=H([`public`,`internal`,`confidential`,`restricted`]);V({cursor:R().min(1).optional(),limit:vy().int().min(1).max(200).default(50)}),V({nextCursor:R().min(1).optional(),hasMore:Av()}),V({idempotencyKey:R().trim().min(8).max(200),expectedVersion:z().int().nonnegative().optional()}),V({type:R().default(`about:blank`),title:R(),status:z().int().min(400).max(599),detail:R().optional(),instance:R().optional(),code:R().regex(/^[a-z0-9_]+$/),requestId:R(),errors:B(V({path:R(),message:R(),code:R().optional()})).optional()});var Cy=V({providerId:R().nullable(),modelId:R().nullable(),inputTokens:z().int().nonnegative(),outputTokens:z().int().nonnegative(),reasoningTokens:z().int().nonnegative(),cacheReadTokens:z().int().nonnegative(),cacheWriteTokens:z().int().nonnegative(),estimatedCostUsd:z().nonnegative(),pricingSource:R().nullable(),pricingAsOf:R().nullable()}),wy=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),externalSessionId:R().nullable(),createdBy:U,status:H([`active`,`waiting`,`completed`,`failed`,`cancelled`]),mode:H([`autonomous`,`guided`]),model:R().nullable(),costUsd:z().nonnegative(),usage:Cy,sensitive:Av(),createdAt:W,lastActivityAt:W}),Ty=V({id:U,sessionId:U,role:H([`user`,`assistant`,`system`,`tool`]),redactedPreview:R(),sensitivePayloadArtifactId:U.nullable(),createdAt:W}),Ey=V({id:U,sessionId:U,runId:U.nullable(),stageId:U.nullable(),externalToolCallId:R().nullable(),toolName:R().min(1),status:H([`running`,`completed`,`failed`,`cancelled`]),inputHash:yy,outputArtifactId:U.nullable(),startedAt:W,completedAt:W.nullable()});V({session:wy,messages:B(Ty),toolActivities:B(Ey)}),V({expectedRunVersion:z().int().nonnegative(),reason:R().trim().min(1).max(1e3)});var Dy=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Oy=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ky=(e,t)=>e>>>t|e<<32-t,Ay=e=>ky(e,7)^ky(e,18)^e>>>3,jy=e=>ky(e,17)^ky(e,19)^e>>>10,My=e=>ky(e,2)^ky(e,13)^ky(e,22),Ny=e=>ky(e,6)^ky(e,11)^ky(e,25),Py=(e,t,n)=>e&t^~e&n,Fy=(e,t,n)=>e&t^e&n^t&n;function Iy(e){let t=new TextEncoder().encode(e),n=Math.floor(t.length*8/4294967296),r=t.length*8>>>0,i=new Uint8Array(((t.length+8>>6)+1)*64);i.set(t),i[t.length]=128;let a=new DataView(i.buffer);a.setUint32(i.length-8,n),a.setUint32(i.length-4,r);let o=new Uint32Array(Oy),s=new Uint32Array(64);for(let e=0;e<i.length;e+=64){for(let t=0;t<16;t++)s[t]=a.getUint32(e+t*4);for(let e=16;e<64;e++){let t=s[e-15],n=s[e-2];s[e]=jy(n)+s[e-7]+Ay(t)+s[e-16]>>>0}let t=o[0],n=o[1],r=o[2],i=o[3],c=o[4],l=o[5],u=o[6],d=o[7];for(let e=0;e<64;e++){let a=d+Ny(c)+Py(c,l,u)+Dy[e]+s[e]>>>0,o=My(t)+Fy(t,n,r)>>>0;d=u,u=l,l=c,c=i+a>>>0,i=r,r=n,n=t,t=a+o>>>0}o[0]=o[0]+t>>>0,o[1]=o[1]+n>>>0,o[2]=o[2]+r>>>0,o[3]=o[3]+i>>>0,o[4]=o[4]+c>>>0,o[5]=o[5]+l>>>0,o[6]=o[6]+u>>>0,o[7]=o[7]+d>>>0}let c=``;for(let e=0;e<8;e++)c+=o[e].toString(16).padStart(8,`0`);return c}var Ly=H([`informational`,`low`,`medium`,`high`,`critical`]),Ry=H([`clean`,`informational`,`actionable`,`critical`]),zy=V({fingerprint:yy.optional(),title:R().min(1),severity:H([`info`,`low`,`medium`,`high`,`critical`]),details:R().default(``),targetUrl:R().optional(),cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R().min(1)).default([]),remediation:R().default(``),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]).default(`candidate`),evidenceRefs:B(yy).default([])}),By=V({description:R().min(1),artifactType:R().min(1),data:_y().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional()}),Vy=H([`observation`,`artifact`,`control_result`,`manual_confirmation`,`report`]),Hy=V({fingerprint:yy,title:R().min(1),description:R().default(``),severity:Ly,cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R()).default([]),remediation:R().default(``),targetUrl:R().optional(),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]),evidenceRefs:B(yy).default([]),status:H([`open`]).default(`open`)}).strict(),Uy=V({fingerprint:yy,kind:Vy,title:R().min(1),summary:R().default(``),artifactType:R(),sha256:yy,timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional(),classification:Sy.default(`confidential`)}).strict(),Wy=V({satisfied:Av(),missing:B(R())}).strict(),Gy=V({id:U,runId:U,projectId:U,workflowKey:R().min(1),workflowVersionId:U,version:z().int().nonnegative(),contentHash:yy,target:R().min(1),scopeOrigins:B(R()).default([]),summary:R().default(``),posture:Ry,findings:B(Hy).default([]),unverifiedLeads:B(Hy).default([]),evidence:B(Uy).default([]),negativeControls:B(R()).default([]),classification:Sy.default(`confidential`),publicationState:H([`draft`,`blocked`,`published`]).default(`draft`),gate:Wy,parentContentHash:yy.nullable().default(null),editorialMarkdownHash:yy.nullable().default(null),publishedAt:W.optional(),createdAt:W}).strict();V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),target:R().min(1),model:R().min(1)}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),description:R().min(1),artifactType:R().min(1),data:_y().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative()}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),workflowKey:R().min(1),status:H([`succeeded`,`blocked`,`inconclusive`,`failed`]),terminationReason:R().max(300).optional(),findings:z().int().nonnegative(),evidence:z().int().nonnegative(),findingItems:B(zy).default([]),evidenceItems:B(By).default([]),negativeControls:B(R().min(1).max(4e3)).max(500).default([]),toolAttempts:z().int().nonnegative(),toolsExecuted:z().int().nonnegative(),toolsErrored:z().int().nonnegative(),pricingUnknown:Av().optional()}),V({runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),kind:H([`finding`,`evidence`]),index:z().int().nonnegative(),issues:B(R().max(120)).min(1).max(20)}),V({id:U,organizationId:U,name:R().trim().min(1).max(120),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({id:U,organizationId:U,workspaceId:U,name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),archivedAt:W.nullable(),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});var Ky=V({id:U,kind:H([`domain`,`ip`,`cidr`,`url`,`repository`,`api`,`android`,`ios`,`custom`]),locator:R().trim().min(1).max(2048),displayName:R().trim().min(1).max(240)}),qy=V({id:U,owner:R().trim().min(1),documentArtifactId:U,validFrom:W,validUntil:W,allowedActions:B(R().min(1)).min(1),prohibitedActions:B(R().min(1)),sha256:yy}),Jy=V({requestsPerSecond:z().positive().optional(),concurrency:z().int().positive().optional(),durationSeconds:z().int().positive(),costUsd:z().nonnegative().optional(),modelTokens:z().int().nonnegative().optional()}),Yy=V({projectId:U,name:R().trim().min(1).max(160),targets:B(Ky).min(1),exclusions:B(R().trim().min(1)),authorization:qy.optional(),allowedRisk:xy,allowedActions:B(R().min(1)),prohibitedActions:B(R().min(1)),limits:Jy,requiredWorkerClass:R().trim().min(1),requiredCapabilities:B(R().trim().min(1)),credentialReferences:B(R().trim().min(1)),dataClassification:Sy,retentionPolicyId:U.optional(),notificationChannels:B(R().trim().min(1))}).extend({id:U,organizationId:U,workspaceId:U,revision:z().int().positive(),inputHash:yy,createdAt:W,createdBy:U}),Xy=H([`open`,`in_progress`,`accepted_risk`,`false_positive`,`remediated`,`verified`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,title:R().min(1),description:R(),severity:H([`informational`,`low`,`medium`,`high`,`critical`]),status:Xy,fingerprint:yy,version:z().int().nonnegative(),firstSeenAt:W,lastSeenAt:W}),V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),stageId:U.nullable(),agentSessionId:U.nullable(),toolCallId:U.nullable(),kind:H([`observation`,`artifact`,`report`,`manual_confirmation`,`control_result`]),title:R().min(1),summary:R(),classification:Sy,artifactId:U.nullable(),sha256:yy,createdAt:W});var Zy=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,objectKey:R().min(1),sha256:yy,mimeType:R().min(1),size:z().int().nonnegative(),classification:Sy,createdBy:U,createdAt:W}),Qy=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`mobile-application`,`red-team-campaign`,`purple-team-validation`,`nist-csf-2`,`cis-controls-8-1`,`advanced-security-testing`,`remediation-validation`,`network-security-audit`]),$y=V({key:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),name:R().min(1),description:R().min(1),risk:xy,optional:Av().default(!1),requiredCapabilities:B(R().min(1)),skillRefs:B(R().min(1).max(80)).max(64).default([]),retrySafe:Av(),approvalCheckpoint:Av(),timeoutSeconds:z().int().positive()}),eb=V({id:U,key:Qy,version:R().regex(/^\d+\.\d+\.\d+$/),name:R().min(1),description:R().min(1),inputSchema:Wv(R(),Pv()),requiredCapabilities:B(R().min(1)),requiredIntegrations:B(R().min(1)),stages:B($y).min(1),evidenceRequirements:B(R().min(1)).min(1),completionCriteria:B(R().min(1)).min(1),publishedAt:W,contentHash:yy}),tb=V({code:H([`authorization_missing`,`authorization_expired`,`capability_missing`,`worker_missing`,`integration_missing`,`credential_missing`,`scope_invalid`,`approval_required`]),message:R().min(1),stageKey:R().optional(),capability:R().optional()}),nb=V({ready:Av(),launchState:H([`ready`,`blocked`,`awaiting_approval`]),highestRisk:xy,reasons:B(tb),matchingWorkerIds:B(U),inputHash:yy}),rb=H([`draft`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`cancel_requested`,`succeeded`,`failed`,`cancelled`,`expired`]),ib=H([`pending`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`paused`,`succeeded`,`failed`,`cancel_requested`,`cancelled`,`expired`,`skipped`]);V({projectId:U,assessmentProfileId:U,workflowKey:Qy,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Wv(R(),Pv()),workerClass:R().min(1),mode:H([`autonomous`,`guided`]).default(`autonomous`)});var ab=V({id:U,organizationId:U,workspaceId:U,projectId:U,assessmentId:U,assessmentProfileId:U,workflowVersionId:U,workflowKey:Qy,requestedBy:U,state:rb,risk:xy,inputHash:yy,workerClass:R(),mode:H([`autonomous`,`guided`]),attempt:z().int().positive(),retryOfRunId:U.nullable(),agentSessionId:U.nullable(),usage:Cy,version:z().int().nonnegative(),createdAt:W,startedAt:W.nullable(),completedAt:W.nullable()}),ob=V({id:U,runId:U,key:R().min(1),position:z().int().nonnegative(),risk:xy,state:ib,workerId:U.nullable(),version:z().int().nonnegative(),startedAt:W.nullable(),completedAt:W.nullable()});V({id:z().int().positive(),runId:U,stageId:U.nullable(),type:R().min(1),payload:Wv(R(),Pv()),occurredAt:W}),V({after:z().int().nonnegative().default(0)});var sb=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`network-security-audit`]);V({target:R().trim().min(1).max(2048),workflowKey:sb,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Wv(R(),Pv()).default({})}).extend({mode:H([`autonomous`,`guided`]).default(`autonomous`)}),V({owner:R().trim().min(2).max(200),statement:R().trim().min(20).max(2e3),validUntil:W});var cb=V({profile:Yy,authorization:qy,artifact:Zy}),lb=V({projectId:U,target:Ky,dossierKey:R().min(1),profileId:U,profileName:R().min(1),reusedProfile:Av()}),ub=V({binding:lb,readiness:nb}),db=V({binding:lb,run:ab,stages:B(ob),agentSession:wy}),fb=H([`pending`,`approved`,`rejected`,`expired`,`invalidated`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,stageId:U.nullable(),risk:xy,state:fb,requestedBy:U,requiredRole:H([`security_manager`,`owner_or_admin`]),decidedBy:U.nullable(),decisionRole:H([`owner`,`admin`,`security_manager`]).nullable(),workflowVersionId:U,inputHash:yy,scopeHash:yy,targetSetHash:yy,workerClass:R().min(1),actionSetHash:yy,expiresAt:W,decidedAt:W.nullable(),reason:R().nullable()}),V({decision:H([`approve`,`reject`]),reason:R().trim().min(1).max(2e3),passwordConfirmation:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,sequence:z().int().positive(),organizationId:U,workspaceId:U,projectId:U.nullable(),actorId:U.nullable(),authSessionId:U.nullable(),action:R().min(1),resourceType:R().min(1),resourceId:R().min(1),requestId:R().min(1),correlationId:R().nullable(),ip:R().nullable(),userAgent:R().nullable(),outcome:H([`succeeded`,`denied`,`failed`]),reason:R().nullable(),beforeHash:yy.nullable(),afterHash:yy.nullable(),previousEventHash:yy.nullable(),eventHash:yy,occurredAt:W}),V({id:U,workspaceId:U,governanceDays:z().int().min(2555),assessmentDaysAfterClosure:z().int().min(1095),rawSessionDays:z().int().min(180),authSessionInvestigationDays:z().int().min(30),version:z().int().nonnegative()}),V({id:U,workspaceId:U,name:R().min(1),reason:R().min(1),resourceType:H([`assessment`,`run`,`agent_session`,`finding`,`artifact`]),resourceId:U,releasedAt:W.nullable(),createdAt:W});var pb=H([`workspace:admin`,`project:write`,`workflow:configure`,`run:launch`,`run:approve:r1`,`run:approve:r2`,`finding:write`,`session:read`,`session:read_sensitive`,`evidence:read`,`evidence:read_sensitive`,`governance:read`,`governance:write`]);V({user:V({id:U,email:R().email(),displayName:R().min(1),mfaEnrolled:Av(),createdAt:W}),organizationId:U,memberships:B(V({workspaceId:U,workspaceName:R().min(1),role:by,permissions:B(pb)})),activeWorkspaceId:U}),V({id:U,userId:U,createdAt:W,lastSeenAt:W,expiresAt:W,ip:R().nullable(),userAgent:R().nullable(),current:Av()}),V({password:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,workspaceId:U,email:R().email(),role:by,expiresAt:W,acceptedAt:W.nullable(),createdAt:W});var mb=z().int().nonnegative(),hb=R().min(1),gb=H([`info`,`low`,`medium`,`high`,`critical`]),_b=H([`open`,`unverified`,`confirmed`,`remediating`,`remediated`,`verified`,`false_positive`,`accepted_risk`,`suppressed`]),vb=H([`cli`,`tui`,`web`,`github`,`system`]),yb=H([`scan`,`hunt`,`verify`,`import`]),bb=H([`queued`,`running`,`completed`,`failed`,`cancelled`]),xb=Wv(R(),Pv()),Sb=V({id:hb,workspaceID:hb,projectID:hb.nullable(),repositoryID:hb.nullable(),engagementID:hb.nullable(),targetID:hb.nullable(),parentRunID:hb.nullable(),sessionID:hb.nullable(),source:vb,kind:yb,status:bb,title:R(),requestedBy:R().nullable(),baseRevision:R().nullable(),headRevision:R().nullable(),promptRevision:R().nullable(),promptFingerprint:R().nullable(),configuration:xb.nullable(),summary:xb.nullable(),error:xb.nullable(),idempotencyKey:R().nullable(),createdAt:mb,startedAt:mb.nullable(),completedAt:mb.nullable(),updatedAt:mb}),Cb=V({runs:B(Sb),nextCursor:R().optional()}),wb=V({id:hb,fingerprint:R().min(1),title:R(),description:R().nullable(),severity:gb,status:_b,path:R().nullable(),line:z().int().nullable(),category:R().nullable(),firstSeenAt:mb,lastSeenAt:mb,updatedAt:mb}),Tb=V({findings:B(wb),total:z().int().nonnegative()}),Eb=V({id:hb,runID:hb.nullable(),operationID:hb.nullable(),kind:R(),verdict:R(),reason:R().nullable(),payload:xb.nullable(),createdAt:mb}),Db=V({finding:wb.extend({cwe:R().nullable(),cve:R().nullable(),cvssScore:z().nullable(),cvssVector:R().nullable(),remediation:R().nullable(),assignee:R().nullable(),resolvedAt:mb.nullable(),evidence:B(Eb)})}),Ob=V({id:hb,runID:hb,tool:R(),runtime:R(),status:R(),outcome:R(),title:R().nullable(),input:xb.nullable(),outputPreview:R().nullable(),error:xb.nullable(),startedAt:mb,completedAt:mb.nullable()}),kb=V({run:Sb,operations:B(Ob.omit({runID:!0})),findings:B(wb)}),Ab=V({id:hb,title:R(),kind:R(),source:R(),status:H([`running`,`failed`,`completed`]),runCount:z().int().nonnegative(),operationCount:z().int().nonnegative(),findingCount:z().int().nonnegative(),startedAt:mb,lastActivityAt:mb}),jb=V({session:Ab,runs:B(Sb),operations:B(Ob),findings:B(wb)}),Mb=V({id:hb,sequence:z().int().positive(),actorID:R().nullable(),action:R().min(1),objectType:R().min(1),objectID:R().min(1),outcome:H([`succeeded`,`denied`,`failed`]),details:xb.nullable(),createdAt:mb}),Nb=V({id:hb,workspaceId:hb,name:R(),slug:R(),archivedAt:mb.nullable(),createdAt:mb,updatedAt:mb}),Pb=V({id:hb,name:R(),role:R(),createdAt:mb,updatedAt:mb}),Fb=V({id:hb,name:R(),status:R(),capabilities:B(R()).default([]),lastSeenAt:mb.nullable()}),Ib=V({sessionId:R().nullable().optional(),runs:Wv(R(),z()),findings:V({total:z().int().nonnegative(),bySeverity:Wv(R(),z()),byStatus:Wv(R(),z())}),recentRuns:B(Sb),recentFindings:B(wb)}),Lb=V({count:z().int().nonnegative(),limit:z().int().positive(),hasMore:Av()});function Rb(e){return V({items:B(e),page:Lb})}V({workspaceId:U,clientId:U,batchId:U,records:B(V({id:U,kind:H([`agent_session`,`evidence`,`finding`,`governance_event`]),localSequence:z().int().positive(),payload:Wv(R(),Pv()),payloadHash:yy,occurredAt:W})).min(1).max(500)}),V({batchId:U,accepted:B(U),rejected:B(V({id:U,code:R(),detail:R()})),centralizedApproval:qv(!1)});var zb=H([`command_execution`,`read_files`,`write_files`,`http_request`,`run_exploit`,`dns_recon`,`state_mutation`,`skill_load`]);V({stageId:R().uuid(),workflowVersionId:R().uuid(),stageKey:R().min(1),requiredCapabilities:B(R().min(1)),allowedToolCategories:B(zb),allowedSkills:B(R().min(1).max(80)).max(64).default([]),retrySafe:Av(),timeoutMs:z().int().positive()});var Bb=V({workerClass:H([`network`,`web-api`,`mobile-lab`,`advanced-analysis`,`passive`]),capabilities:B(R().min(1)),tools:Wv(R(),R()),networkLocation:R().nullable(),devices:B(V({id:R(),platform:H([`android`,`ios`]),version:R()})),limits:V({concurrency:z().int().positive(),memoryMb:z().int().positive(),cpuMillis:z().int().positive(),durationSeconds:z().int().positive()})});V({token:R().min(32),name:R().trim().min(1).max(160),publicKey:R().min(32),capabilities:Bb}),V({expiresAt:W}),V({token:R().min(32),expiresAt:W}),V({worker:V({id:U,organizationId:U,workspaceId:U,name:R(),publicKey:R(),capabilities:Bb,status:H([`enrolling`,`online`,`offline`,`revoked`]),lastHeartbeatAt:W.nullable(),createdAt:W}),accessToken:R().min(32),expiresAt:W}),V({capabilities:Bb.optional(),runningJobIds:B(U)}),V({id:U,runId:U,stageId:U,workerId:U,leaseToken:R().min(32),leaseExpiresAt:W,attempt:z().int().positive(),payload:Wv(R(),Pv())}),V({leaseToken:R().min(32),events:B(V({idempotencyKey:R().min(8),type:R().min(1),occurredAt:W,payload:Wv(R(),Pv())})).min(1).max(500)});var Vb=V({leaseToken:R().min(32)});Vb.extend({extendSeconds:z().int().min(10).max(300).default(60)}),Vb.extend({outcome:H([`succeeded`,`failed`,`cancelled`]),summary:Wv(R(),Pv()).default({}),error:R().max(2e4).optional(),retrySafe:Av().default(!1)});function Hb(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Hb).join(`,`)}]`;let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${Hb(t[e])}`).join(`,`)}}`}function Ub(e){return Iy(typeof e==`string`?e:Hb(e))}function Wb(e){return`kifaru-workflow-${e}`}var G=(e,t,n,r,i={})=>({key:e,name:t,description:i.description??t,risk:n,optional:i.optional??!1,requiredCapabilities:r,skillRefs:i.skillRefs??(r.includes(`reporting`)?[`kifaru-vulnerability-report`]:r.some(e=>[`web-testing`,`authenticated-browser`,`api-client`,`api-security-testing`].includes(e))?[`kifaru-web-app-review`]:r.some(e=>[`mobile-static`,`mobile-device`,`mobile-proxy`].includes(e))?[`kifaru-mobile-app-review`]:[]),retrySafe:i.retrySafe??n!==`R2`,approvalCheckpoint:i.approvalCheckpoint??n!==`R0`,timeoutSeconds:i.timeoutSeconds??3600}),Gb=[{id:`10000000-0000-4000-8000-000000000101`,key:`internal-infrastructure`,name:`Internal Infrastructure Assessment`,description:`Customer-network discovery, configuration review, bounded validation, evidence capture, and reporting.`,requiredCapabilities:[`network-discovery`,`vulnerability-scanner`,`reporting`],stages:[G(`discovery`,`Discovery and inventory`,`R1`,[`network-discovery`]),G(`configuration-review`,`Configuration review`,`R1`,[`configuration-review`]),G(`vulnerability-checks`,`Vulnerability checks`,`R1`,[`vulnerability-scanner`]),G(`bounded-validation`,`Bounded validation`,`R1`,[`safe-validation`]),G(`exploitation`,`Approved exploitation`,`R2`,[`exploit-runner`],{retrySafe:!1,optional:!0}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`host and service inventory`,`tool output with provenance`,`validation evidence`],completionCriteria:[`authorized targets accounted for`,`all executed checks have outcomes`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000102`,key:`external-infrastructure`,name:`External Infrastructure Assessment`,description:`Internet-facing inventory, DNS, TLS, exposed-service, and known-vulnerability assessment with run comparison.`,requiredCapabilities:[`dns`,`tls`,`network-discovery`,`vulnerability-scanner`,`reporting`],stages:[G(`inventory`,`Domain and IP inventory`,`R1`,[`dns`]),G(`service-discovery`,`Exposed service discovery`,`R1`,[`network-discovery`,`tls`]),G(`vulnerability-checks`,`Known-vulnerability checks`,`R1`,[`vulnerability-scanner`]),G(`comparison`,`Previous-run comparison`,`R0`,[`run-comparison`],{approvalCheckpoint:!1}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`resolved inventory`,`service fingerprints`,`comparison baseline`],completionCriteria:[`all in-scope assets classified`,`material changes recorded`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000103`,key:`web-application`,name:`Web Application Assessment`,description:`Authenticated surface discovery, client analysis, focused testing, evidence gating, and reporting.`,requiredCapabilities:[`web-testing`,`reporting`],stages:[G(`surface-discovery`,`Surface discovery`,`R1`,[`web-testing`]),G(`authenticated-flows`,`Authenticated flow capture`,`R1`,[`authenticated-browser`],{optional:!0}),G(`client-analysis`,`Client-side analysis`,`R0`,[`source-analysis`],{approvalCheckpoint:!1}),G(`focused-testing`,`Focused vulnerability testing`,`R1`,[`web-testing`]),G(`destructive-payloads`,`Approved destructive payloads`,`R2`,[`exploit-runner`],{retrySafe:!1,optional:!0}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`request and response provenance`,`reproduction evidence`,`negative controls`],completionCriteria:[`authenticated roles exercised`,`findings pass evidence gate`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000104`,key:`api-security`,name:`API Security Assessment`,description:`Schema import, authorization mapping, object-access and state-machine testing, and differential probes.`,requiredCapabilities:[`api-client`,`api-security-testing`,`reporting`],stages:[G(`schema-import`,`API schema and request import`,`R0`,[`openapi`],{approvalCheckpoint:!1}),G(`auth-mapping`,`Authentication and authorization mapping`,`R1`,[`api-client`]),G(`object-access`,`Object access tests`,`R1`,[`api-security-testing`]),G(`state-machine`,`State-machine checks`,`R1`,[`api-security-testing`]),G(`differential-probes`,`Differential probes`,`R1`,[`api-security-testing`]),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`imported request source`,`identity and object matrix`,`differential responses`],completionCriteria:[`declared operations accounted for`,`authorization hypotheses resolved`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000105`,key:`mobile-application`,name:`Android and iOS Assessment`,description:`Static artifact analysis with optional dynamic mobile-lab execution on registered devices.`,requiredCapabilities:[`mobile-static`,`reporting`],stages:[G(`static-analysis`,`Static artifact analysis`,`R0`,[`mobile-static`],{approvalCheckpoint:!1}),G(`dynamic-analysis`,`Dynamic device analysis`,`R1`,[`mobile-device`,`mobile-proxy`],{optional:!0}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`artifact checksum`,`static analyzer output`,`device provenance for dynamic results`],completionCriteria:[`selected static or dynamic coverage is explicit`,`report artifact produced`],inputSchema:{coverage:{enum:[`static-only`,`full-dynamic`]}}},{id:`10000000-0000-4000-8000-000000000106`,key:`red-team-campaign`,name:`Red Team Campaign`,description:`Rules-of-engagement validation, reconnaissance, hypothesis execution, verification, and reporting.`,requiredCapabilities:[`red-team`,`reporting`],stages:[G(`roe-validation`,`Rules-of-engagement validation`,`R0`,[`authorization-review`],{approvalCheckpoint:!1}),G(`reconnaissance`,`Reconnaissance`,`R1`,[`network-discovery`]),G(`hypothesis-planning`,`Hypothesis planning`,`R0`,[`red-team`],{approvalCheckpoint:!1}),G(`execution`,`Approved campaign execution`,`R2`,[`red-team`],{retrySafe:!1}),G(`verification`,`Outcome verification`,`R1`,[`safe-validation`]),G(`reporting`,`Campaign reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`rules-of-engagement snapshot`,`action provenance`,`verification evidence`],completionCriteria:[`no persistence beyond authorization`,`all actions reconciled`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000107`,key:`purple-team-validation`,name:`Purple Team Validation`,description:`Vendor-neutral ATT&CK-aligned detection validation using signed, uploaded, or manually confirmed evidence.`,requiredCapabilities:[`detection-emulation`,`evidence-ingest`,`reporting`],stages:[G(`expectations`,`Detection expectation mapping`,`R0`,[`attack-mapping`],{approvalCheckpoint:!1}),G(`emulation`,`Controlled detection emulation`,`R1`,[`detection-emulation`]),G(`evidence-ingest`,`SIEM and EDR evidence ingest`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`outcomes`,`Detection outcome classification`,`R0`,[`attack-mapping`],{approvalCheckpoint:!1}),G(`reporting`,`Validation reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`ATT&CK technique identifier`,`detection expectation`,`signed or attributable result`],completionCriteria:[`every expectation has a four-state outcome`,`all outcomes link evidence`]},{id:`10000000-0000-4000-8000-000000000108`,key:`nist-csf-2`,name:`NIST CSF 2.0 Assessment`,description:`Versioned CSF evidence requests, observations, gaps, applicability decisions, and maturity notes.`,requiredCapabilities:[`compliance-nist`,`evidence-ingest`,`reporting`],stages:[G(`scope`,`Framework scope and applicability`,`R0`,[`compliance-nist`],{approvalCheckpoint:!1}),G(`evidence`,`Evidence collection`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`assessment`,`Requirement assessment`,`R0`,[`compliance-nist`],{approvalCheckpoint:!1}),G(`reporting`,`Assessment reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`pinned framework requirement`,`applicability decision`,`evidence or explicit gap`],completionCriteria:[`all applicable requirements assessed`,`output states assessment not certification`]},{id:`10000000-0000-4000-8000-000000000109`,key:`cis-controls-8-1`,name:`CIS Controls v8.1 Assessment`,description:`Implementation-group-aware evidence and test results mapped to versioned CIS safeguards.`,requiredCapabilities:[`compliance-cis`,`evidence-ingest`,`reporting`],stages:[G(`implementation-group`,`Implementation group selection`,`R0`,[`compliance-cis`],{approvalCheckpoint:!1}),G(`evidence`,`Safeguard evidence collection`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`assessment`,`Safeguard assessment`,`R0`,[`compliance-cis`],{approvalCheckpoint:!1}),G(`reporting`,`Assessment reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`pinned safeguard`,`implementation group`,`evidence or explicit gap`],completionCriteria:[`all selected safeguards assessed`,`output states assessment not certification`]},{id:`10000000-0000-4000-8000-00000000010a`,key:`advanced-security-testing`,name:`Advanced Security Testing`,description:`Curated source, binary, firmware, protocol, smart-contract, and bounded custom testing.`,requiredCapabilities:[`advanced-analysis`,`reporting`],stages:[G(`analysis`,`Selected advanced analysis`,`R0`,[`advanced-analysis`],{approvalCheckpoint:!1}),G(`bounded-fuzzing`,`Bounded protocol fuzzing`,`R2`,[`protocol-fuzzing`],{retrySafe:!1,optional:!0}),G(`validation`,`Result validation`,`R1`,[`safe-validation`]),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`selected subtype`,`toolchain versions`,`reproducible evidence`],completionCriteria:[`unsupported stages blocked before launch`,`report artifact produced`],inputSchema:{subtype:{enum:[`source-review`,`binary-firmware`,`protocol-fuzzing`,`smart-contract`,`custom`]}}},{id:`10000000-0000-4000-8000-00000000010b`,key:`remediation-validation`,name:`Remediation Validation`,description:`Finding-led validation that reuses original scope, evidence contracts, and safe reproduction steps.`,requiredCapabilities:[`safe-validation`,`reporting`],stages:[G(`baseline`,`Original evidence baseline`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`reproduction`,`Safe reproduction`,`R1`,[`safe-validation`]),G(`comparison`,`Before and after comparison`,`R0`,[`run-comparison`],{approvalCheckpoint:!1}),G(`finding-transition`,`Verified finding transition`,`R0`,[`finding-write`],{approvalCheckpoint:!1})],evidenceRequirements:[`original finding`,`before evidence`,`after evidence`],completionCriteria:[`only conclusive success marks verified`,`failed or inconclusive validation leaves finding open`],inputSchema:{findingIds:{type:`array`,minItems:1}}},{id:`10000000-0000-4000-8000-00000000010c`,key:`network-security-audit`,name:`Network Security Audit`,description:`Composite assessment that selects applicable child workflows and consolidates coverage and evidence.`,requiredCapabilities:[`workflow-orchestration`,`reporting`],stages:[G(`selection`,`Child workflow selection`,`R0`,[`workflow-orchestration`],{approvalCheckpoint:!1}),G(`combined-readiness`,`Combined readiness check`,`R0`,[`workflow-orchestration`],{approvalCheckpoint:!1}),G(`child-runs`,`Approved child runs`,`R1`,[`workflow-orchestration`]),G(`consolidation`,`Coverage and finding consolidation`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`child workflow versions`,`combined readiness decision`,`child run provenance`],completionCriteria:[`all selected children terminal`,`consolidated coverage identifies blocked work`],inputSchema:{childWorkflowKeys:{type:`array`,minItems:1}}}],Kb=`2026-09-06T00:00:00.000Z`;Gb.map(e=>{let t=Wb(e.key),n=e.stages.map(e=>({...e,timeoutSeconds:e.timeoutSeconds??3600,skillRefs:e.skillRefs.includes(t)?e.skillRefs:[...e.skillRefs,t]})),r={id:e.id,key:e.key,version:`1.1.0`,name:e.name,description:e.description,inputSchema:e.inputSchema??{},requiredCapabilities:e.requiredCapabilities,requiredIntegrations:e.requiredIntegrations??[],stages:n,evidenceRequirements:e.evidenceRequirements,completionCriteria:e.completionCriteria,publishedAt:Kb,contentHash:Ub({...e,stages:n})};return eb.parse(r)});var qb=V({items:B(eb)}),Jb=V({workflowKey:R(),skillName:R(),markdown:R(),revision:R(),customized:Av()}),Yb=V({runId:R(),workflowKey:R(),target:R(),permissionMode:H([`scoped`,`yolo`]),status:R(),dbPath:R(),reportPath:R()}),Xb=V({runId:R(),workflowKey:R(),target:R(),permissionMode:H([`scoped`,`yolo`]),status:H([`queued`,`running`,`completed`,`partial`,`failed`,`cancelled`]),startedAt:z(),finishedAt:z().nullable(),error:R().nullable(),reportAvailable:Av(),stages:B(V({key:R(),name:R(),status:R(),summary:R()}))}),Zb=V({items:B(Xb)}),Qb=V({items:B(V({runId:R(),workflowKey:R(),target:R(),posture:R(),findings:z(),unverifiedLeads:z().default(0),createdAt:R()}))}),$b=Rb(Pb),ex=Rb(Nb),tx=V({items:B(Yy)}),nx=Rb(Ab),rx=Rb(Mb),ix=Rb(Fb),ax=V({id:R(),label:R(),prefix:R().optional().default(``),tokenPrefix:R().optional(),role:R().optional().default(`admin`),workspaceId:R().optional().default(`default`),createdAt:R(),expiresAt:R().nullable().optional(),lastUsedAt:R().nullable().optional()}),ox=ax.extend({token:R()}),sx=V({items:B(ax)}),cx=V({provider:H([`azure-openai`,`openai-compatible`,`anthropic`]),scope:H([`user`,`workspace`]),ownerID:R(),workspaceID:R(),lastFour:R(),createdAt:R(),updatedAt:R()}),lx=V({items:B(cx)}),ux=V({items:B(V({version:z().int().nonnegative(),posture:R(),target:R(),contentHash:R(),classification:R(),publicationState:H([`draft`,`blocked`,`published`]),gate:V({satisfied:Av(),missing:B(R())}),publishedAt:R().nullable(),createdAt:R()}))}),dx=V({ext:R(),mimeType:R(),url:R().nullable(),rendered:Av()}),fx=V({version:z().int().nonnegative(),contentHash:R(),posture:R(),target:R(),classification:R(),record:Gy,renditions:B(dx)}),px=V({artifacts:B(V({artifactId:R(),mimeType:R(),size:z(),sha256:R()}))}),mx=V({version:z().int().nonnegative(),contentHash:R(),posture:R()}),hx=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function gx(e=fetch){async function t(t,n,r){let i=document.querySelector(`meta[name="csrf-token"]`)?.content||sessionStorage.getItem(`kifaru-csrf`)||document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`kifaru_csrf=`))?.slice(12),a=r?.method?.toUpperCase()??`GET`,o=await e(t,{credentials:`same-origin`,...r,headers:{accept:`application/json`,...a!==`GET`&&a!==`HEAD`&&i?{"x-csrf-token":i}:{},...r?.headers}});if(!o.ok&&o.status===401&&typeof window<`u`&&!window.location.pathname.startsWith(`/login`))throw window.location.href=`/login?redirect=${encodeURIComponent(window.location.pathname+window.location.search)}`,new hx(401,`unauthorized`,`Session expired. Redirecting to login.`);let s=await o.json().catch(()=>void 0);if(!o.ok){let e=s;throw new hx(o.status,e?.code??`request_failed`,e?.detail??`Request failed.`)}return n.parse(s)}return{workflows:()=>t(`/api/v1/workflows`,qb),workflowSkill:e=>t(`/api/v1/workflows/${encodeURIComponent(e)}/skill`,V({item:Jb})),saveWorkflowSkill:(e,n,r)=>t(`/api/v1/workflows/${encodeURIComponent(e)}/skill`,V({item:Jb}),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n,expectedRevision:r})}),runs:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??20)),n?.sessionId&&r.set(`sessionId`,n.sessionId),t(`/api/v1/runs?${r.toString()}`,Cb)},runDetail:e=>t(`/api/v1/runs/${encodeURIComponent(e)}`,kb),workspaces:()=>t(`/api/v1/workspaces`,$b),projects:()=>t(`/api/v1/projects`,ex),assessmentProfiles:()=>t(`/api/v1/assessment-profiles`,tx),authorizeAssessmentProfile:(e,n)=>t(`/api/v1/assessment-profiles/${encodeURIComponent(e)}/authorization-attestations`,cb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(n)}),findings:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e||`runId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??50)),n?.sessionId&&r.set(`sessionId`,n.sessionId),n?.runId&&r.set(`runId`,n.runId),t(`/api/v1/findings?${r.toString()}`,Tb)},finding:e=>t(`/api/v1/findings/${encodeURIComponent(e)}`,Db),updateFindingStatus:(e,n,r)=>t(`/api/v1/findings/${encodeURIComponent(e)}/status`,Db,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:n,...r?{note:r}:{}})}),agentSessions:()=>t(`/api/v1/agent/sessions?limit=50`,nx),agentSession:e=>t(`/api/v1/agent/sessions/${encodeURIComponent(e)}`,jb),governanceEvents:()=>t(`/api/v1/governance/audit-events?limit=50`,rx),workers:()=>t(`/api/v1/workers`,ix),overview:e=>{let n;return typeof e==`string`?n=e:e&&typeof e==`object`&&`sessionId`in e&&typeof e.sessionId==`string`&&(n=e.sessionId),t(n?`/api/v1/overview?sessionId=${encodeURIComponent(n)}`:`/api/v1/overview`,Ib)},tokens:()=>t(`/api/v1/tokens`,sx),modelCredentials:()=>t(`/api/v1/model-credentials`,lx),saveModelCredential:(e,n,r)=>t(`/api/v1/model-credentials/${e}/${n}`,V({item:cx}),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({apiKey:r})}),deleteModelCredential:(e,n)=>t(`/api/v1/model-credentials/${e}/${n}`,V({ok:Av()}),{method:`DELETE`}),myRole:()=>t(`/api/v1/me`,V({role:R()})),createInvitation:e=>t(`/api/v1/invitations`,V({token:R(),email:R(),expiresAt:R()}),{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({email:e})}),mintToken:e=>t(`/api/v1/tokens`,ox,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),revokeToken:e=>t(`/api/v1/tokens/${encodeURIComponent(e)}`,V({ok:Av()}),{method:`DELETE`}),targetAssessmentReadiness:e=>t(`/api/v1/assessments/readiness`,ub,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startTargetAssessment:e=>t(`/api/v1/assessments`,db,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startLocalRun:e=>t(`/api/v1/local-runs`,Yb,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),localRuns:()=>t(`/api/v1/local-runs`,Zb),localRun:e=>t(`/api/v1/local-runs/${encodeURIComponent(e)}`,V({item:Xb})),localReports:()=>t(`/api/v1/local-reports`,Qb),reportVersions:e=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports`,ux),reportVersion:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}`,fx),renderReportRenditions:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/renditions`,px,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({})}),publishEditedMarkdown:(e,n,r)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/editor`,mx,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({markdown:r})})}}var _x=gx(),vx=new Rd({defaultOptions:{queries:{staleTime:1e4,retry:2,refetchOnWindowFocus:!0}}}),yx=[{n:1,name:`Collection & Onboarding`,v:`--s1`},{n:2,name:`Storage & Security`,v:`--s2`},{n:3,name:`Use & Processing`,v:`--s3`},{n:4,name:`Sharing & Disclosure`,v:`--s4`},{n:5,name:`Retention`,v:`--s5`},{n:6,name:`Disposal & Erasure`,v:`--s6`}];function bx(e){return yx[Math.min(Math.max(e,1),yx.length)-1]}function xx(e){return e.name.split(` `)[0]}var Sx=[`Governance`,`Technical`,`People & 3rd-party`,`Assurance`],Cx=[`critical`,`high`,`medium`,`low`,`info`],wx={critical:0,high:1,medium:2,low:3,info:4},Tx={critical:`--crit`,high:`--high`,medium:`--med`,low:`--low`,info:`--info`},Ex={critical:`Critical`,high:`High`,medium:`Medium`,low:`Low`,info:`Info`};function Dx(e){return e===`informational`?`info`:Cx.includes(e)?e:`info`}function Ox(e){return e.length?[...e].sort((e,t)=>wx[e.severity]-wx[t.severity])[0].severity:null}function kx(e){return[...e].sort((e,t)=>wx[e.severity]-wx[t.severity])}function Ax(e){return e.status!==`remediated`&&e.status!==`verified`}var jx=/^(?:L|stage )([1-6])\s*·\s*P([0-3])\s*·\s*(.+)$/i;function Mx(e,t){let n=(e??``).trim(),r=jx.exec(n);if(r)return{stage:Number(r[1]),pillar:Number(r[2]),category:r[3],inferred:!1};let i=`${n} ${t??``}`.toLowerCase();return{stage:/sharing|disclos|transfer|cross-border|offshore|sftp|export|feed|webhook|api partner|integration/.test(i)?4:/retention|purge|backup|archive|dr site|snapshot|data lake/.test(i)?5:/eras|disposal|destroy|delete|decommission|shred/.test(i)?6:/consent|intake|onboarding|collection|telematics|form capture|survey/.test(i)?1:/encrypt|at rest|bucket|object store|database exposure|unencrypted|storage|nas|s3/.test(i)?2:3,pillar:/governance|dpia|retention schedule|policy|register|oversight|audit/.test(i)?0:/shared credential|third-party|tpa|vendor|partner|outsourc|staff|insider/.test(i)?2:1,category:n||`Agent finding`,inferred:!0}}function Nx(e){return e.map(e=>{let t=Mx(e.category,e.title);return{...e,severity:Dx(e.severity),stage:t.stage,pillar:t.pillar,displayCategory:t.inferred?`${t.category} (stage inferred)`:t.category,inferred:t.inferred}})}function Px(e){return Ox(e.filter(e=>e.status===`confirmed`||e.status===`verified`))}function Fx({title:e,sub:t,surface:n=!0,children:r}){return(0,b.jsxs)(`section`,{className:n?`bg-card rounded-xl border p-5`:void 0,children:[(0,b.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-3`,children:[(0,b.jsx)(`h2`,{children:e}),t?(0,b.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:t}):null]}),r]})}function Ix({children:e}){return(0,b.jsx)(`div`,{className:`kpis`,children:e})}function Lx({label:e,value:t,meta:n,hero:r,tone:i}){return(0,b.jsxs)(`div`,{className:r?`kpi hero`:`kpi`,children:[(0,b.jsx)(`div`,{className:`lab`,children:e}),r?(0,b.jsxs)(`div`,{className:`posture-pill val`,style:i?{color:`var(${Tx[i]})`}:void 0,children:[(0,b.jsx)(`span`,{className:`sq`}),t]}):(0,b.jsx)(`div`,{className:`val`,children:t}),n?(0,b.jsx)(`div`,{className:`meta`,children:n}):null]})}function Rx({counts:e}){let t=Math.max(...Cx.map(t=>e[t]),1);return(0,b.jsx)(`div`,{children:Cx.map(n=>(0,b.jsxs)(`div`,{className:`sevrow`,children:[(0,b.jsxs)(`span`,{className:`name`,children:[(0,b.jsx)(`span`,{className:`chip`,style:{background:`var(${Tx[n]})`}}),Ex[n]]}),(0,b.jsx)(`div`,{className:`track`,children:(0,b.jsx)(`div`,{className:`fill`,"data-empty":e[n]===0,style:{width:`${e[n]/t*100}%`,background:`var(${Tx[n]})`}})}),(0,b.jsx)(`span`,{className:`n`,children:e[n]})]},n))})}function zx({findings:e}){let t=yx.map(t=>e.filter(e=>e.stage===t.n).length),n=Math.max(...t,1);return(0,b.jsx)(`div`,{className:`stagebars`,children:yx.map((e,r)=>{let i=t[r];return(0,b.jsxs)(`div`,{className:`sbar`,children:[(0,b.jsx)(`span`,{className:`cnt`,children:i}),(0,b.jsx)(`div`,{className:`col`,style:{height:`${Math.max(i/n*112,i?10:2)}px`,background:`var(${e.v})`}}),(0,b.jsx)(`span`,{className:`idx`,children:e.n}),(0,b.jsx)(`span`,{className:`lb`,children:xx(e)})]},e.n)})})}function Bx({findings:e,onSelect:t,emptyLabel:n=`No findings.`}){return e.length?(0,b.jsx)(`div`,{className:`flist`,children:e.map(e=>{let n=bx(e.stage);return(0,b.jsxs)(`button`,{className:`frow`,type:`button`,onClick:t?()=>t(e):void 0,children:[(0,b.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Ex[e.severity]}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`span`,{className:`ftitle`,children:e.title}),(0,b.jsxs)(`span`,{className:`fmeta`,children:[(0,b.jsxs)(`span`,{className:`stagetag`,children:[(0,b.jsx)(`span`,{className:`d`,style:{background:`var(${n.v})`}}),`Stage `,n.n,` · `,xx(n)]}),(0,b.jsx)(`span`,{children:e.displayCategory}),e.path?(0,b.jsx)(`span`,{className:`font-mono`,children:e.path}):null]})]}),(0,b.jsx)(`span`,{className:`fright`,children:(0,b.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:e.status.replaceAll(`_`,` `)})})]},e.id)})}):(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n})}function Vx({findings:e,selected:t,onSelect:n}){return(0,b.jsx)(`div`,{className:`chain`,children:yx.map(r=>{let i=e.filter(e=>e.stage===r.n),a=Ox(i);return(0,b.jsxs)(`button`,{className:`stagenode`,type:`button`,"aria-pressed":r.n===t,onClick:()=>n(r.n),children:[(0,b.jsx)(`div`,{className:`top`,style:{background:`var(${r.v})`}}),a?(0,b.jsx)(`span`,{className:`worst`,style:{background:`var(${Tx[a]})`}}):null,(0,b.jsxs)(`div`,{className:`sn`,children:[`STAGE `,r.n]}),(0,b.jsx)(`div`,{className:`st`,children:r.name}),(0,b.jsxs)(`div`,{className:`sc`,style:{color:`var(${r.v})`},children:[i.length,(0,b.jsxs)(`small`,{children:[`finding`,i.length===1?``:`s`]})]})]},r.n)})})}function Hx({findings:e,onSelectStage:t}){return(0,b.jsx)(`div`,{style:{overflowX:`auto`},children:(0,b.jsxs)(`table`,{className:`matrix`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`rh`}),yx.map(e=>(0,b.jsxs)(`th`,{children:[(0,b.jsx)(`span`,{className:`flex flex-wrap gap-4 text-xs font-medium`,children:(0,b.jsx)(`i`,{className:`mcap`,style:{background:`var(${e.v})`}})}),(0,b.jsx)(`br`,{}),e.n]},e.n))]})}),(0,b.jsx)(`tbody`,{children:Sx.map((n,r)=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`rh`,children:n}),yx.map(i=>{let a=e.filter(e=>e.pillar===r&&e.stage===i.n),o=Ox(a);return o?(0,b.jsx)(`td`,{className:`has`,style:{background:`var(${Tx[o]})`,cursor:`pointer`},title:`${a.length} open at ${n} · stage ${i.n}`,onClick:()=>t(i.n),children:a.length},i.n):(0,b.jsx)(`td`,{children:`·`},i.n)})]},n))})]})})}function Ux({items:e}){return(0,b.jsx)(`div`,{className:`my-3.5 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:e.map(e=>(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`k`,children:e.k}),(0,b.jsx)(`div`,{className:e.mono?`v mono`:`v`,children:e.v})]},e.k))})}function Wx({title:e,children:t}){return(0,b.jsxs)(`div`,{className:`border-[var(--hair)] mt-4 border-t pt-3.5 [&>h3]:text-muted-foreground [&>h3]:mb-2 [&>h3]:text-[11px] [&>h3]:font-semibold [&>h3]:tracking-[0.1em] [&>h3]:uppercase`,children:[(0,b.jsx)(`h3`,{children:e}),t]})}function Gx({title:e,detail:t,verdict:n}){return(0,b.jsxs)(`div`,{className:`evi`,children:[(0,b.jsxs)(`svg`,{className:`ei`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,b.jsx)(`path`,{d:`M14 2v6h6`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`et`,children:e}),(0,b.jsx)(`div`,{className:`ed`,children:t})]}),(0,b.jsx)(`span`,{className:`verdict`,children:n})]})}var Kx=v(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`,critical:`border-[color-mix(in_srgb,var(--crit)_35%,transparent)] bg-[var(--crit-bg)] text-[var(--crit)]`,high:`border-[color-mix(in_srgb,var(--high)_35%,transparent)] bg-[var(--high-bg)] text-[var(--high)]`,medium:`border-[color-mix(in_srgb,var(--med)_35%,transparent)] bg-[var(--med-bg)] text-[var(--med)]`,low:`border-[color-mix(in_srgb,var(--low)_35%,transparent)] bg-[var(--low-bg)] text-[var(--low)]`,success:`border-[color-mix(in_srgb,var(--good)_35%,transparent)] bg-[var(--good-bg)] text-[var(--good)]`,info:`bg-[var(--info-bg)] text-[var(--info)]`}},defaultVariants:{variant:`default`}}),qx={critical:`critical`,failed:`critical`,blocked:`critical`,R2:`critical`,high:`high`,awaiting_approval:`high`,cancel_requested:`high`,R1:`high`,medium:`medium`,queued:`medium`,low:`low`,running:`low`,R0:`low`,succeeded:`success`,completed:`success`,confirmed:`success`,ok:`success`,verified:`success`,remediated:`success`,info:`info`,informational:`info`};function Jx(e){return e?qx[e]??`secondary`:`secondary`}function Yx({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?s:`span`;return(0,b.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:a(Kx({variant:t}),e),...r})}function Xx(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Zx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Qx=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$x={};function eS(e,t){return((t||$x).jsx?Qx:Zx).test(e)}var tS=/[ \t\n\f\r]/g;function nS(e){return typeof e==`object`?e.type===`text`&&rS(e.value):rS(e)}function rS(e){return e.replace(tS,``)===``}var iS=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};iS.prototype.normal={},iS.prototype.property={},iS.prototype.space=void 0;function aS(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new iS(n,r,t)}function oS(e){return e.toLowerCase()}var sS=class{constructor(e,t){this.attribute=t,this.property=e}};sS.prototype.attribute=``,sS.prototype.booleanish=!1,sS.prototype.boolean=!1,sS.prototype.commaOrSpaceSeparated=!1,sS.prototype.commaSeparated=!1,sS.prototype.defined=!1,sS.prototype.mustUseProperty=!1,sS.prototype.number=!1,sS.prototype.overloadedBoolean=!1,sS.prototype.property=``,sS.prototype.spaceSeparated=!1,sS.prototype.space=void 0;var cS=e({boolean:()=>uS,booleanish:()=>dS,commaOrSpaceSeparated:()=>hS,commaSeparated:()=>mS,number:()=>K,overloadedBoolean:()=>fS,spaceSeparated:()=>pS}),lS=0,uS=gS(),dS=gS(),fS=gS(),K=gS(),pS=gS(),mS=gS(),hS=gS();function gS(){return 2**++lS}var _S=Object.keys(cS),vS=class extends sS{constructor(e,t,n,r){let i=-1;if(super(e,t),yS(this,`space`,r),typeof n==`number`)for(;++i<_S.length;){let e=_S[i];yS(this,_S[i],(n&cS[e])===cS[e])}}};vS.prototype.defined=!0;function yS(e,t,n){n&&(e[t]=n)}function bS(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new vS(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[oS(r)]=r,n[oS(a.attribute)]=r}return new iS(t,n,e.space)}var xS=bS({properties:{ariaActiveDescendant:null,ariaAtomic:dS,ariaAutoComplete:null,ariaBusy:dS,ariaChecked:dS,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:pS,ariaCurrent:null,ariaDescribedBy:pS,ariaDetails:null,ariaDisabled:dS,ariaDropEffect:pS,ariaErrorMessage:null,ariaExpanded:dS,ariaFlowTo:pS,ariaGrabbed:dS,ariaHasPopup:null,ariaHidden:dS,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:pS,ariaLevel:K,ariaLive:null,ariaModal:dS,ariaMultiLine:dS,ariaMultiSelectable:dS,ariaOrientation:null,ariaOwns:pS,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:dS,ariaReadOnly:dS,ariaRelevant:null,ariaRequired:dS,ariaRoleDescription:pS,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:dS,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function SS(e,t){return t in e?e[t]:t}function CS(e,t){return SS(e,t.toLowerCase())}var wS=bS({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:mS,acceptCharset:pS,accessKey:pS,action:null,allow:null,allowFullScreen:uS,allowPaymentRequest:uS,allowUserMedia:uS,alpha:uS,alt:null,as:null,async:uS,autoCapitalize:null,autoComplete:pS,autoFocus:uS,autoPlay:uS,blocking:pS,capture:null,charSet:null,checked:uS,cite:null,className:pS,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:dS,controls:uS,controlsList:pS,coords:K|mS,crossOrigin:null,data:null,dateTime:null,decoding:null,default:uS,defer:uS,dir:null,dirName:null,disabled:uS,download:fS,draggable:dS,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:uS,formTarget:null,headers:pS,height:K,hidden:fS,high:K,href:null,hrefLang:null,htmlFor:pS,httpEquiv:pS,id:null,imageSizes:null,imageSrcSet:null,inert:uS,inputMode:null,integrity:null,is:null,isMap:uS,itemId:null,itemProp:pS,itemRef:pS,itemScope:uS,itemType:pS,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:uS,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:uS,muted:uS,name:null,nonce:null,noModule:uS,noValidate:uS,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:uS,optimum:K,pattern:null,ping:pS,placeholder:null,playsInline:uS,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:uS,referrerPolicy:null,rel:pS,required:uS,reversed:uS,rows:K,rowSpan:K,sandbox:pS,scope:null,scoped:uS,seamless:uS,selected:uS,shadowRootClonable:uS,shadowRootCustomElementRegistry:uS,shadowRootDelegatesFocus:uS,shadowRootMode:null,shadowRootSerializable:uS,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:dS,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:uS,useMap:null,value:dS,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:pS,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:uS,declare:uS,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:uS,noHref:uS,noShade:uS,noWrap:uS,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:dS,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:uS,disablePictureInPicture:uS,disableRemotePlayback:uS,exportParts:mS,part:pS,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:CS}),TS=bS({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:hS,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:pS,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:uS,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mS,g2:mS,glyphName:mS,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:hS,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:pS,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:hS,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:hS,rev:hS,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:hS,requiredFeatures:hS,requiredFonts:hS,requiredFormats:hS,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:hS,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:hS,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:hS,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:SS}),ES=bS({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),DS=bS({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:CS}),OS=bS({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),kS={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},AS=/[A-Z]/g,jS=/-[a-z]/g,MS=/^data[-\w.:]+$/i;function NS(e,t){let n=oS(t),r=t,i=sS;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&MS.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(jS,FS);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!jS.test(e)){let n=e.replace(AS,PS);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=vS}return new i(r,t)}function PS(e){return`-`+e.toLowerCase()}function FS(e){return e.charAt(1).toUpperCase()}var IS=aS([xS,wS,ES,DS,OS],`html`),LS=aS([xS,TS,ES,DS,OS],`svg`);function RS(e){return e.join(` `).trim()}var zS=r(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
61
- `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),BS=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(zS());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),VS=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),HS=r(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(BS()),r=VS();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),US=GS(`end`),WS=GS(`start`);function GS(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function KS(e){let t=WS(e),n=US(e);if(t&&n)return{start:t,end:n}}function qS(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?YS(e.position):`start`in e||`end`in e?YS(e):`line`in e||`column`in e?JS(e):``}function JS(e){return XS(e&&e.line)+`:`+XS(e&&e.column)}function YS(e){return JS(e&&e.start)+`-`+JS(e&&e.end)}function XS(e){return e&&typeof e==`number`?e:1}var ZS=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=qS(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ZS.prototype.file=``,ZS.prototype.name=``,ZS.prototype.reason=``,ZS.prototype.message=``,ZS.prototype.stack=``,ZS.prototype.column=void 0,ZS.prototype.line=void 0,ZS.prototype.ancestors=void 0,ZS.prototype.cause=void 0,ZS.prototype.fatal=void 0,ZS.prototype.place=void 0,ZS.prototype.ruleId=void 0,ZS.prototype.source=void 0;var QS=n(HS(),1),$S={}.hasOwnProperty,eC=new Map,tC=/[A-Z]/g,nC=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),rC=new Set([`td`,`th`]),iC=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function aC(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=gC(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=hC(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?LS:IS,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=oC(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function oC(e,t,n){if(t.type===`element`)return sC(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return cC(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return uC(e,t,n);if(t.type===`mdxjsEsm`)return lC(e,t);if(t.type===`root`)return dC(e,t,n);if(t.type===`text`)return fC(e,t)}function sC(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=LS,e.schema=i),e.ancestors.push(t);let a=SC(e,t.tagName,!1),o=_C(e,t),s=yC(e,t);return nC.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!nS(e)})),pC(e,o,a,t),mC(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function cC(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}CC(e,t.position)}function lC(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);CC(e,t.position)}function uC(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=LS,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:SC(e,t.name,!0),o=vC(e,t),s=yC(e,t);return pC(e,o,a,t),mC(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function dC(e,t,n){let r={};return mC(r,yC(e,t)),e.create(t,e.Fragment,r,n)}function fC(e,t){return t.value}function pC(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function mC(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function hC(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function gC(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=WS(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function _C(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&$S.call(t.properties,i)){let a=bC(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&rC.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function vC(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else CC(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else CC(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function yC(e,t){let n=[],r=-1,i=e.passKeys?new Map:eC;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=oC(e,a,o);s!==void 0&&n.push(s)}return n}function bC(e,t,n){let r=NS(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Xx(n):RS(n)),r.property===`style`){let t=typeof n==`object`?n:xC(e,String(n));return e.stylePropertyNameCase===`css`&&(t=wC(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?kS[r.property]||r.property:r.attribute,n]}}function xC(e,t){try{return(0,QS.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new ZS("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=iC+`#cannot-parse-style-attribute`,r}}function SC(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=eS(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=eS(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return $S.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);CC(e)}function CC(e,t){let n=new ZS("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=iC+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function wC(e){let t={},n;for(n in e)$S.call(e,n)&&(t[TC(n)]=e[n]);return t}function TC(e){let t=e.replace(tC,EC);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function EC(e){return`-`+e.toLowerCase()}var DC={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},OC={};function kC(e,t){let n=t||OC;return AC(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function AC(e,t,n){if(MC(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return jC(e.children,t,n)}return Array.isArray(e)?jC(e,t,n):``}function jC(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=AC(e[i],t,n);return r.join(``)}function MC(e){return!!(e&&typeof e==`object`)}var NC=document.createElement(`i`);function PC(e){let t=`&`+e+`;`;NC.innerHTML=t;let n=NC.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function FC(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function IC(e,t){return e.length>0?(FC(e,e.length,0,t),e):t}var LC={}.hasOwnProperty;function RC(e){let t={},n=-1;for(;++n<e.length;)zC(t,e[n]);return t}function zC(e,t){let n;for(n in t){let r=(LC.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){LC.call(r,a)||(r[a]=[]);let e=i[a];BC(r[a],Array.isArray(e)?e:e?[e]:[])}}}function BC(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);FC(e,0,0,r)}function VC(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function HC(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var UC=ew(/[A-Za-z]/),WC=ew(/[\dA-Za-z]/),GC=ew(/[#-'*+\--9=?A-Z^-~]/);function KC(e){return e!==null&&(e<32||e===127)}var qC=ew(/\d/),JC=ew(/[\dA-Fa-f]/),YC=ew(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function XC(e){return e!==null&&(e<0||e===32)}function ZC(e){return e===-2||e===-1||e===32}var QC=ew(/\p{P}|\p{S}/u),$C=ew(/\s/);function ew(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function tw(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&WC(e.charCodeAt(n+1))&&WC(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function nw(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return ZC(r)?(e.enter(n),s(r)):t(r)}function s(r){return ZC(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var rw={tokenize:iw};function iw(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),nw(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var aw={tokenize:sw},ow={tokenize:cw};function sw(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return FC(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ow,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(ow,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;FC(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function cw(e,t,n){return nw(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function lw(e){if(e===null||XC(e)||$C(e))return 1;if(QC(e))return 2}function uw(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var dw={name:`attention`,resolveAll:fw,tokenize:pw};function fw(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};mw(d,-c),mw(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=IC(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=IC(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=IC(l,uw(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=IC(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=IC(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,FC(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function pw(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=lw(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=lw(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function mw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var hw={name:`autolink`,tokenize:gw};function gw(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return UC(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||WC(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||WC(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||KC(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):GC(t)?(e.consume(t),l):n(t)}function u(e){return WC(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||WC(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var _w={partial:!0,tokenize:vw};function vw(e,t,n){return r;function r(t){return ZC(t)?nw(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var yw={continuation:{tokenize:xw},exit:Sw,name:`blockQuote`,tokenize:bw};function bw(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return ZC(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function xw(e,t,n){let r=this;return i;function i(t){return ZC(t)?nw(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(yw,t,n)(r)}}function Sw(e){e.exit(`blockQuote`)}var Cw={name:`characterEscape`,tokenize:ww};function ww(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return YC(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Tw={name:`characterReference`,tokenize:Ew};function Ew(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=WC,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=JC,u):(e.enter(`characterReferenceValue`),a=7,o=qC,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===WC&&!PC(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Dw={partial:!0,tokenize:Aw},Ow={concrete:!0,name:`codeFenced`,tokenize:kw};function kw(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),ZC(t)?nw(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Dw,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):ZC(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),nw(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&ZC(t)?nw(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(Dw,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),ZC(t)?nw(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),ZC(t)?nw(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Aw(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var jw={name:`codeIndented`,tokenize:Nw},Mw={partial:!0,tokenize:Pw};function Nw(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),nw(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(Mw,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Pw(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):nw(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var Fw={name:`codeText`,previous:Lw,resolve:Iw,tokenize:Rw};function Iw(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Lw(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Rw(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var zw=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Bw(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Bw(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Bw(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Bw(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Bw(this.left,t.reverse())}}}};function Bw(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Vw(e){let t={},n=-1,r,i,a,o,s,c,l,u=new zw(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Hw(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return FC(e,0,1/0,u.slice(0)),!l}function Hw(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Uw={resolve:Gw,tokenize:Kw},Ww={partial:!0,tokenize:qw};function Gw(e){return Vw(e),e}function Kw(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(Ww,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function qw(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),nw(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Jw(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||KC(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||XC(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||KC(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Yw(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!ZC(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Xw(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),nw(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Zw(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):ZC(i)?nw(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Qw={name:`definition`,tokenize:eT},$w={partial:!0,tokenize:tT};function eT(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Yw.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=HC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return XC(t)?Zw(e,l)(t):l(t)}function l(t){return Jw(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt($w,d,d)(t)}function d(t){return ZC(t)?nw(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function tT(e,t,n){return r;function r(t){return XC(t)?Zw(e,i)(t):n(t)}function i(t){return Xw(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return ZC(t)?nw(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var nT={name:`hardBreakEscape`,tokenize:rT};function rT(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var iT={name:`headingAtx`,resolve:aT,tokenize:oT};function aT(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},FC(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function oT(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||XC(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):ZC(n)?nw(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||XC(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var sT=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),cT=[`pre`,`script`,`style`,`textarea`],lT={concrete:!0,name:`htmlFlow`,resolveTo:fT,tokenize:pT},uT={partial:!0,tokenize:hT},dT={partial:!0,tokenize:mT};function fT(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function pT(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ne):UC(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):UC(a)?(e.consume(a),i=4,r.interrupt?t:ne):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ne):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return UC(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||XC(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&cT.includes(l)?(i=1,r.interrupt?t(s):O(s)):sT.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||WC(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return ZC(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||UC(t)?(e.consume(t),b):ZC(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||WC(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):ZC(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):ZC(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||XC(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||ZC(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):ZC(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),re):t===63&&i===3?(e.consume(t),ne):t===93&&i===5?(e.consume(t),te):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(uT,ie,k)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(dT,A,ie)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),ne):O(t)}function N(t){return t===47?(e.consume(t),o=``,ee):O(t)}function ee(t){if(t===62){let n=o.toLowerCase();return cT.includes(n)?(e.consume(t),re):O(t)}return UC(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ee):O(t)}function te(t){return t===93?(e.consume(t),ne):O(t)}function ne(t){return t===62?(e.consume(t),re):t===45&&i===2?(e.consume(t),ne):O(t)}function re(t){return t===null||q(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),re)}function ie(n){return e.exit(`htmlFlow`),t(n)}}function mT(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function hT(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(_w,t,n)}}var gT={name:`htmlText`,tokenize:_T};function _T(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):UC(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):UC(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):q(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return UC(t)?(e.consume(t),S):n(t)}function S(t){return t===45||WC(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,N(t)):ZC(t)?(e.consume(t),C):M(t)}function w(t){return t===45||WC(t)?(e.consume(t),w):t===47||t===62||XC(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||UC(t)?(e.consume(t),E):q(t)?(o=T,N(t)):ZC(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||WC(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,N(t)):ZC(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):q(t)?(o=O,N(t)):ZC(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):q(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||XC(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||XC(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return ZC(t)?nw(e,te,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):te(t)}function te(t){return e.enter(`htmlTextData`),o(t)}}var vT={name:`labelEnd`,resolveAll:ST,resolveTo:CT,tokenize:wT},yT={tokenize:TT},bT={tokenize:ET},xT={tokenize:DT};function ST(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&FC(e,0,e.length,n),e}function CT(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=IC(s,e.slice(a+1,a+r+3)),s=IC(s,[[`enter`,u,t]]),s=IC(s,uw(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=IC(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=IC(s,e.slice(o+1)),s=IC(s,[[`exit`,c,t]]),FC(e,a,e.length,s),e}function wT(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(HC(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(yT,u,o?u:d)(t):t===91?e.attempt(bT,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(xT,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function TT(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return XC(t)?Zw(e,a)(t):a(t)}function a(t){return t===41?u(t):Jw(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return XC(t)?Zw(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Xw(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return XC(t)?Zw(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function ET(e,t,n){let r=this;return i;function i(t){return Yw.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(HC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function DT(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var OT={name:`labelStartImage`,resolveAll:vT.resolveAll,tokenize:kT};function kT(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var AT={name:`labelStartLink`,resolveAll:vT.resolveAll,tokenize:jT};function jT(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var MT={name:`lineEnding`,tokenize:NT};function NT(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),nw(e,t,`linePrefix`)}}var PT={name:`thematicBreak`,tokenize:FT};function FT(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),ZC(t)?nw(e,s,`whitespace`)(t):s(t))}}var IT={continuation:{tokenize:BT},exit:HT,name:`list`,tokenize:zT},LT={partial:!0,tokenize:UT},RT={partial:!0,tokenize:VT};function zT(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:qC(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(PT,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return qC(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(_w,r.interrupt?n:u,e.attempt(LT,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return ZC(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function BT(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(_w,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,nw(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!ZC(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(RT,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,nw(e,e.attempt(IT,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function VT(e,t,n){let r=this;return nw(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function HT(e){e.exit(this.containerState.type)}function UT(e,t,n){let r=this;return nw(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!ZC(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var WT={name:`setextUnderline`,resolveTo:GT,tokenize:KT};function GT(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function KT(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),ZC(t)?nw(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var qT={tokenize:JT};function JT(e){let t=this,n=e.attempt(_w,r,e.attempt(this.parser.constructs.flowInitial,i,nw(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Uw,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var YT={resolveAll:$T()},XT=QT(`string`),ZT=QT(`text`);function QT(e){return{resolveAll:$T(e===`text`?eE:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function $T(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function eE(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var tE=e({attentionMarkers:()=>lE,contentInitial:()=>rE,disable:()=>uE,document:()=>nE,flow:()=>aE,flowInitial:()=>iE,insideSpan:()=>cE,string:()=>oE,text:()=>sE}),nE={42:IT,43:IT,45:IT,48:IT,49:IT,50:IT,51:IT,52:IT,53:IT,54:IT,55:IT,56:IT,57:IT,62:yw},rE={91:Qw},iE={[-2]:jw,[-1]:jw,32:jw},aE={35:iT,42:PT,45:[WT,PT],60:lT,61:WT,95:PT,96:Ow,126:Ow},oE={38:Tw,92:Cw},sE={[-5]:MT,[-4]:MT,[-3]:MT,33:OT,38:Tw,42:dw,60:[hw,gT],91:AT,92:[nT,Cw],93:vT,95:dw,96:Fw},cE={null:[dw,YT]},lE={null:[42,95]},uE={null:[]};function dE(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=IC(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=uw(a,l.events,l),l.events):[]}function f(e,t){return pE(p(e),t)}function p(e){return fE(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&FC(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function fE(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function pE(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
60
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Rp,s=!Cp.jitless,c=s&&zp.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?sg([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ug(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!em(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>rm(e,r,wp())))}),t)}var dg=I(`$ZodUnion`,(e,t)=>{Sh.init(e,t),Mp(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Mp(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Mp(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Mp(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>kp(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>ug(t,i,e,a)):ug(s,i,e,a)}}),fg=I(`$ZodIntersection`,(e,t)=>{Sh.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>mg(e,t,n)):mg(e,i,a)}});function pg(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Bp(e)&&Bp(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pg(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pg(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mg(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),em(e))return e;let r=pg(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var hg=I(`$ZodRecord`,(e,t)=>{Sh.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Bp(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...tm(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...tm(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>rm(e,r,wp())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...tm(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...tm(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),gg=I(`$ZodEnum`,(e,t)=>{Sh.init(e,t);let n=Tp(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Hp.has(typeof e)).map(e=>typeof e==`string`?Up(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),_g=I(`$ZodLiteral`,(e,t)=>{if(Sh.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Up(e):e?Up(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),vg=I(`$ZodTransform`,(e,t)=>{Sh.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Sp(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new xp;return n.value=i,n}});function yg(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var bg=I(`$ZodOptional`,(e,t)=>{Sh.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Mp(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Mp(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${kp(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>yg(t,e.value)):yg(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),xg=I(`$ZodNullable`,(e,t)=>{Sh.init(e,t),Mp(e._zod,`optin`,()=>t.innerType._zod.optin),Mp(e._zod,`optout`,()=>t.innerType._zod.optout),Mp(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${kp(e.source)}|null)$`):void 0}),Mp(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Sg=I(`$ZodDefault`,(e,t)=>{Sh.init(e,t),e._zod.optin=`optional`,Mp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Cg(e,t)):Cg(r,t)}});function Cg(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var wg=I(`$ZodPrefault`,(e,t)=>{Sh.init(e,t),e._zod.optin=`optional`,Mp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Tg=I(`$ZodNonOptional`,(e,t)=>{Sh.init(e,t),Mp(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Eg(t,e)):Eg(i,e)}});function Eg(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Dg=I(`$ZodCatch`,(e,t)=>{Sh.init(e,t),Mp(e._zod,`optin`,()=>t.innerType._zod.optin),Mp(e._zod,`optout`,()=>t.innerType._zod.optout),Mp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>rm(e,n,wp()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>rm(e,n,wp()))},input:e.value}),e.issues=[]),e)}}),Og=I(`$ZodPipe`,(e,t)=>{Sh.init(e,t),Mp(e._zod,`values`,()=>t.in._zod.values),Mp(e._zod,`optin`,()=>t.in._zod.optin),Mp(e._zod,`optout`,()=>t.out._zod.optout),Mp(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>kg(e,t.in,n)):kg(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>kg(e,t.out,n)):kg(r,t.out,n)}});function kg(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Ag=I(`$ZodReadonly`,(e,t)=>{Sh.init(e,t),Mp(e._zod,`propValues`,()=>t.innerType._zod.propValues),Mp(e._zod,`values`,()=>t.innerType._zod.values),Mp(e._zod,`optin`,()=>t.innerType._zod.optin),Mp(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(jg):jg(r)}});function jg(e){return e.value=Object.freeze(e.value),e}var Mg=I(`$ZodLazy`,(e,t)=>{Sh.init(e,t),Mp(e._zod,`innerType`,()=>t.getter()),Mp(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),Mp(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),Mp(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),Mp(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Ng=I(`$ZodCustom`,(e,t)=>{rh.init(e,t),Sh.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Pg(t,n,r,e));Pg(i,n,r,e)}});function Pg(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(am(e))}}var Fg=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ig(){return new Fg}var Lg=Ig();function Rg(e,t){return new e({type:`string`,...L(t)})}function zg(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function Bg(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function Vg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function Hg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function Ug(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Wg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function Gg(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function Kg(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function qg(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Jg(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Yg(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Xg(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Zg(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function Qg(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function $g(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function e_(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function t_(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function n_(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function r_(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function i_(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function a_(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function o_(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function s_(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function c_(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function l_(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function u_(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function d_(e,t){return new e({type:`number`,checks:[],...L(t)})}function f_(e,t){return new e({type:`number`,coerce:!0,checks:[],...L(t)})}function p_(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function m_(e,t){return new e({type:`boolean`,...L(t)})}function h_(e,t){return new e({type:`null`,...L(t)})}function g_(e){return new e({type:`unknown`})}function __(e,t){return new e({type:`never`,...L(t)})}function v_(e,t){return new ah({check:`less_than`,...L(t),value:e,inclusive:!1})}function y_(e,t){return new ah({check:`less_than`,...L(t),value:e,inclusive:!0})}function b_(e,t){return new oh({check:`greater_than`,...L(t),value:e,inclusive:!1})}function x_(e,t){return new oh({check:`greater_than`,...L(t),value:e,inclusive:!0})}function S_(e,t){return new sh({check:`multiple_of`,...L(t),value:e})}function C_(e,t){return new lh({check:`max_length`,...L(t),maximum:e})}function w_(e,t){return new uh({check:`min_length`,...L(t),minimum:e})}function T_(e,t){return new dh({check:`length_equals`,...L(t),length:e})}function E_(e,t){return new ph({check:`string_format`,format:`regex`,...L(t),pattern:e})}function D_(e){return new mh({check:`string_format`,format:`lowercase`,...L(e)})}function O_(e){return new hh({check:`string_format`,format:`uppercase`,...L(e)})}function k_(e,t){return new gh({check:`string_format`,format:`includes`,...L(t),includes:e})}function A_(e,t){return new _h({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function j_(e,t){return new vh({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function M_(e){return new yh({check:`overwrite`,tx:e})}function N_(e){return M_(t=>t.normalize(e))}function P_(){return M_(e=>e.trim())}function F_(){return M_(e=>e.toLowerCase())}function I_(){return M_(e=>e.toUpperCase())}function L_(e,t,n){return new e({type:`array`,element:t,...L(n)})}function R_(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function z_(e){let t=B_(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(am(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(am(r))}},e(n.value,n)));return t}function B_(e,t){let n=new rh({check:`custom`,...L(t)});return n._zod.check=e,n}var V_=I(`ZodISODateTime`,(e,t)=>{Ih.init(e,t),fv.init(e,t)});function H_(e){return s_(V_,e)}var U_=I(`ZodISODate`,(e,t)=>{Lh.init(e,t),fv.init(e,t)});function W_(e){return c_(U_,e)}var G_=I(`ZodISOTime`,(e,t)=>{Rh.init(e,t),fv.init(e,t)});function K_(e){return l_(G_,e)}var q_=I(`ZodISODuration`,(e,t)=>{zh.init(e,t),fv.init(e,t)});function J_(e){return u_(q_,e)}var Y_=(e,t)=>{sm.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>um(e,t)},flatten:{value:t=>lm(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ep,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ep,2)}},isEmpty:{get(){return e.issues.length===0}}})};I(`ZodError`,Y_);var X_=I(`ZodError`,Y_,{Parent:Error}),Z_=dm(X_),Q_=fm(X_),$_=pm(X_),ev=hm(X_),tv=_m(X_),nv=vm(X_),rv=ym(X_),iv=bm(X_),av=xm(X_),ov=Sm(X_),sv=Cm(X_),cv=wm(X_),lv=I(`ZodType`,(e,t)=>(Sh.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>Wp(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Z_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>$_(e,t,n),e.parseAsync=async(t,n)=>Q_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ev(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>tv(e,t,n),e.decode=(t,n)=>nv(e,t,n),e.encodeAsync=async(t,n)=>rv(e,t,n),e.decodeAsync=async(t,n)=>iv(e,t,n),e.safeEncode=(t,n)=>av(e,t,n),e.safeDecode=(t,n)=>ov(e,t,n),e.safeEncodeAsync=async(t,n)=>sv(e,t,n),e.safeDecodeAsync=async(t,n)=>cv(e,t,n),e.refine=(t,n)=>e.check(xy(t,n)),e.superRefine=t=>e.check(Sy(t)),e.overwrite=t=>e.check(M_(t)),e.optional=()=>ry(e),e.nullable=()=>ay(e),e.nullish=()=>ry(ay(e)),e.nonoptional=t=>dy(e,t),e.array=()=>B(e),e.or=t=>Kv([e,t]),e.and=t=>Jv(e,t),e.transform=t=>hy(e,ty(t)),e.default=t=>sy(e,t),e.prefault=t=>ly(e,t),e.catch=t=>py(e,t),e.pipe=t=>hy(e,t),e.readonly=()=>_y(e),e.describe=t=>{let n=e.clone();return Lg.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return Lg.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Lg.get(e);let n=e.clone();return Lg.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),uv=I(`_ZodString`,(e,t)=>{Ch.init(e,t),lv.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(E_(...t)),e.includes=(...t)=>e.check(k_(...t)),e.startsWith=(...t)=>e.check(A_(...t)),e.endsWith=(...t)=>e.check(j_(...t)),e.min=(...t)=>e.check(w_(...t)),e.max=(...t)=>e.check(C_(...t)),e.length=(...t)=>e.check(T_(...t)),e.nonempty=(...t)=>e.check(w_(1,...t)),e.lowercase=t=>e.check(D_(t)),e.uppercase=t=>e.check(O_(t)),e.trim=()=>e.check(P_()),e.normalize=(...t)=>e.check(N_(...t)),e.toLowerCase=()=>e.check(F_()),e.toUpperCase=()=>e.check(I_())}),dv=I(`ZodString`,(e,t)=>{Ch.init(e,t),uv.init(e,t),e.email=t=>e.check(zg(pv,t)),e.url=t=>e.check(Gg(gv,t)),e.jwt=t=>e.check(o_(jv,t)),e.emoji=t=>e.check(Kg(_v,t)),e.guid=t=>e.check(Bg(mv,t)),e.uuid=t=>e.check(Vg(hv,t)),e.uuidv4=t=>e.check(Hg(hv,t)),e.uuidv6=t=>e.check(Ug(hv,t)),e.uuidv7=t=>e.check(Wg(hv,t)),e.nanoid=t=>e.check(qg(vv,t)),e.guid=t=>e.check(Bg(mv,t)),e.cuid=t=>e.check(Jg(yv,t)),e.cuid2=t=>e.check(Yg(bv,t)),e.ulid=t=>e.check(Xg(xv,t)),e.base64=t=>e.check(r_(Ov,t)),e.base64url=t=>e.check(i_(kv,t)),e.xid=t=>e.check(Zg(Sv,t)),e.ksuid=t=>e.check(Qg(Cv,t)),e.ipv4=t=>e.check($g(wv,t)),e.ipv6=t=>e.check(e_(Tv,t)),e.cidrv4=t=>e.check(t_(Ev,t)),e.cidrv6=t=>e.check(n_(Dv,t)),e.e164=t=>e.check(a_(Av,t)),e.datetime=t=>e.check(H_(t)),e.date=t=>e.check(W_(t)),e.time=t=>e.check(K_(t)),e.duration=t=>e.check(J_(t))});function R(e){return Rg(dv,e)}var fv=I(`ZodStringFormat`,(e,t)=>{wh.init(e,t),uv.init(e,t)}),pv=I(`ZodEmail`,(e,t)=>{Dh.init(e,t),fv.init(e,t)}),mv=I(`ZodGUID`,(e,t)=>{Th.init(e,t),fv.init(e,t)}),hv=I(`ZodUUID`,(e,t)=>{Eh.init(e,t),fv.init(e,t)}),gv=I(`ZodURL`,(e,t)=>{Oh.init(e,t),fv.init(e,t)}),_v=I(`ZodEmoji`,(e,t)=>{kh.init(e,t),fv.init(e,t)}),vv=I(`ZodNanoID`,(e,t)=>{Ah.init(e,t),fv.init(e,t)}),yv=I(`ZodCUID`,(e,t)=>{jh.init(e,t),fv.init(e,t)}),bv=I(`ZodCUID2`,(e,t)=>{Mh.init(e,t),fv.init(e,t)}),xv=I(`ZodULID`,(e,t)=>{Nh.init(e,t),fv.init(e,t)}),Sv=I(`ZodXID`,(e,t)=>{Ph.init(e,t),fv.init(e,t)}),Cv=I(`ZodKSUID`,(e,t)=>{Fh.init(e,t),fv.init(e,t)}),wv=I(`ZodIPv4`,(e,t)=>{Bh.init(e,t),fv.init(e,t)}),Tv=I(`ZodIPv6`,(e,t)=>{Vh.init(e,t),fv.init(e,t)}),Ev=I(`ZodCIDRv4`,(e,t)=>{Hh.init(e,t),fv.init(e,t)}),Dv=I(`ZodCIDRv6`,(e,t)=>{Uh.init(e,t),fv.init(e,t)}),Ov=I(`ZodBase64`,(e,t)=>{Gh.init(e,t),fv.init(e,t)}),kv=I(`ZodBase64URL`,(e,t)=>{qh.init(e,t),fv.init(e,t)}),Av=I(`ZodE164`,(e,t)=>{Jh.init(e,t),fv.init(e,t)}),jv=I(`ZodJWT`,(e,t)=>{Xh.init(e,t),fv.init(e,t)}),Mv=I(`ZodNumber`,(e,t)=>{Zh.init(e,t),lv.init(e,t),e.gt=(t,n)=>e.check(b_(t,n)),e.gte=(t,n)=>e.check(x_(t,n)),e.min=(t,n)=>e.check(x_(t,n)),e.lt=(t,n)=>e.check(v_(t,n)),e.lte=(t,n)=>e.check(y_(t,n)),e.max=(t,n)=>e.check(y_(t,n)),e.int=t=>e.check(Pv(t)),e.safe=t=>e.check(Pv(t)),e.positive=t=>e.check(b_(0,t)),e.nonnegative=t=>e.check(x_(0,t)),e.negative=t=>e.check(v_(0,t)),e.nonpositive=t=>e.check(y_(0,t)),e.multipleOf=(t,n)=>e.check(S_(t,n)),e.step=(t,n)=>e.check(S_(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function z(e){return d_(Mv,e)}var Nv=I(`ZodNumberFormat`,(e,t)=>{Qh.init(e,t),Mv.init(e,t)});function Pv(e){return p_(Nv,e)}var Fv=I(`ZodBoolean`,(e,t)=>{$h.init(e,t),lv.init(e,t)});function Iv(e){return m_(Fv,e)}var Lv=I(`ZodNull`,(e,t)=>{eg.init(e,t),lv.init(e,t)});function Rv(e){return h_(Lv,e)}var zv=I(`ZodUnknown`,(e,t)=>{tg.init(e,t),lv.init(e,t)});function Bv(){return g_(zv)}var Vv=I(`ZodNever`,(e,t)=>{ng.init(e,t),lv.init(e,t)});function Hv(e){return __(Vv,e)}var Uv=I(`ZodArray`,(e,t)=>{ig.init(e,t),lv.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(w_(t,n)),e.nonempty=t=>e.check(w_(1,t)),e.max=(t,n)=>e.check(C_(t,n)),e.length=(t,n)=>e.check(T_(t,n)),e.unwrap=()=>e.element});function B(e,t){return L_(Uv,e,t)}var Wv=I(`ZodObject`,(e,t)=>{lg.init(e,t),lv.init(e,t),Mp(e,`shape`,()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Bv()}),e.loose=()=>e.clone({...e._zod.def,catchall:Bv()}),e.strict=()=>e.clone({...e._zod.def,catchall:Hv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Yp(e,t),e.safeExtend=t=>Xp(e,t),e.merge=t=>Zp(e,t),e.pick=t=>qp(e,t),e.omit=t=>Jp(e,t),e.partial=(...t)=>Qp(ny,e,t[0]),e.required=(...t)=>$p(uy,e,t[0])});function V(e,t){return new Wv({type:`object`,get shape(){return Pp(this,`shape`,e?Np(e):{}),this.shape},...L(t)})}var Gv=I(`ZodUnion`,(e,t)=>{dg.init(e,t),lv.init(e,t),e.options=t.options});function Kv(e,t){return new Gv({type:`union`,options:e,...L(t)})}var qv=I(`ZodIntersection`,(e,t)=>{fg.init(e,t),lv.init(e,t)});function Jv(e,t){return new qv({type:`intersection`,left:e,right:t})}var Yv=I(`ZodRecord`,(e,t)=>{hg.init(e,t),lv.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Xv(e,t,n){return new Yv({type:`record`,keyType:e,valueType:t,...L(n)})}var Zv=I(`ZodEnum`,(e,t)=>{gg.init(e,t),lv.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Zv({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Zv({...t,checks:[],...L(r),entries:i})}});function H(e,t){return new Zv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Qv=I(`ZodLiteral`,(e,t)=>{_g.init(e,t),lv.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $v(e,t){return new Qv({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var ey=I(`ZodTransform`,(e,t)=>{vg.init(e,t),lv.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Sp(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(am(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(am(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ty(e){return new ey({type:`transform`,transform:e})}var ny=I(`ZodOptional`,(e,t)=>{bg.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ry(e){return new ny({type:`optional`,innerType:e})}var iy=I(`ZodNullable`,(e,t)=>{xg.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ay(e){return new iy({type:`nullable`,innerType:e})}var oy=I(`ZodDefault`,(e,t)=>{Sg.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sy(e,t){return new oy({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vp(t)}})}var cy=I(`ZodPrefault`,(e,t)=>{wg.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ly(e,t){return new cy({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vp(t)}})}var uy=I(`ZodNonOptional`,(e,t)=>{Tg.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function dy(e,t){return new uy({type:`nonoptional`,innerType:e,...L(t)})}var fy=I(`ZodCatch`,(e,t)=>{Dg.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function py(e,t){return new fy({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var my=I(`ZodPipe`,(e,t)=>{Og.init(e,t),lv.init(e,t),e.in=t.in,e.out=t.out});function hy(e,t){return new my({type:`pipe`,in:e,out:t})}var gy=I(`ZodReadonly`,(e,t)=>{Ag.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _y(e){return new gy({type:`readonly`,innerType:e})}var vy=I(`ZodLazy`,(e,t)=>{Mg.init(e,t),lv.init(e,t),e.unwrap=()=>e._zod.def.getter()});function yy(e){return new vy({type:`lazy`,getter:e})}var by=I(`ZodCustom`,(e,t)=>{Ng.init(e,t),lv.init(e,t)});function xy(e,t={}){return R_(by,e,t)}function Sy(e){return z_(e)}function Cy(e){let t=yy(()=>Kv([R(e),z(),Iv(),Rv(),B(t),Xv(R(),t)]));return t}function wy(e){return f_(Mv,e)}var U=R().uuid(),W=R().datetime({offset:!0}),Ty=R().regex(/^[a-f0-9]{64}$/);R().trim().min(1);var Ey=H([`owner`,`admin`,`security_manager`,`operator`,`viewer`,`auditor`]),Dy=H([`R0`,`R1`,`R2`]),Oy=H([`public`,`internal`,`confidential`,`restricted`]);V({cursor:R().min(1).optional(),limit:wy().int().min(1).max(200).default(50)}),V({nextCursor:R().min(1).optional(),hasMore:Iv()}),V({idempotencyKey:R().trim().min(8).max(200),expectedVersion:z().int().nonnegative().optional()}),V({type:R().default(`about:blank`),title:R(),status:z().int().min(400).max(599),detail:R().optional(),instance:R().optional(),code:R().regex(/^[a-z0-9_]+$/),requestId:R(),errors:B(V({path:R(),message:R(),code:R().optional()})).optional()});var ky=V({providerId:R().nullable(),modelId:R().nullable(),inputTokens:z().int().nonnegative(),outputTokens:z().int().nonnegative(),reasoningTokens:z().int().nonnegative(),cacheReadTokens:z().int().nonnegative(),cacheWriteTokens:z().int().nonnegative(),estimatedCostUsd:z().nonnegative(),pricingSource:R().nullable(),pricingAsOf:R().nullable()}),Ay=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),externalSessionId:R().nullable(),createdBy:U,status:H([`active`,`waiting`,`completed`,`failed`,`cancelled`]),mode:H([`autonomous`,`guided`]),model:R().nullable(),costUsd:z().nonnegative(),usage:ky,sensitive:Iv(),createdAt:W,lastActivityAt:W}),jy=V({id:U,sessionId:U,role:H([`user`,`assistant`,`system`,`tool`]),redactedPreview:R(),sensitivePayloadArtifactId:U.nullable(),createdAt:W}),My=V({id:U,sessionId:U,runId:U.nullable(),stageId:U.nullable(),externalToolCallId:R().nullable(),toolName:R().min(1),status:H([`running`,`completed`,`failed`,`cancelled`]),inputHash:Ty,outputArtifactId:U.nullable(),startedAt:W,completedAt:W.nullable()});V({session:Ay,messages:B(jy),toolActivities:B(My)}),V({expectedRunVersion:z().int().nonnegative(),reason:R().trim().min(1).max(1e3)});var Ny=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Py=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fy=(e,t)=>e>>>t|e<<32-t,Iy=e=>Fy(e,7)^Fy(e,18)^e>>>3,Ly=e=>Fy(e,17)^Fy(e,19)^e>>>10,Ry=e=>Fy(e,2)^Fy(e,13)^Fy(e,22),zy=e=>Fy(e,6)^Fy(e,11)^Fy(e,25),By=(e,t,n)=>e&t^~e&n,Vy=(e,t,n)=>e&t^e&n^t&n;function Hy(e){let t=new TextEncoder().encode(e),n=Math.floor(t.length*8/4294967296),r=t.length*8>>>0,i=new Uint8Array(((t.length+8>>6)+1)*64);i.set(t),i[t.length]=128;let a=new DataView(i.buffer);a.setUint32(i.length-8,n),a.setUint32(i.length-4,r);let o=new Uint32Array(Py),s=new Uint32Array(64);for(let e=0;e<i.length;e+=64){for(let t=0;t<16;t++)s[t]=a.getUint32(e+t*4);for(let e=16;e<64;e++){let t=s[e-15],n=s[e-2];s[e]=Ly(n)+s[e-7]+Iy(t)+s[e-16]>>>0}let t=o[0],n=o[1],r=o[2],i=o[3],c=o[4],l=o[5],u=o[6],d=o[7];for(let e=0;e<64;e++){let a=d+zy(c)+By(c,l,u)+Ny[e]+s[e]>>>0,o=Ry(t)+Vy(t,n,r)>>>0;d=u,u=l,l=c,c=i+a>>>0,i=r,r=n,n=t,t=a+o>>>0}o[0]=o[0]+t>>>0,o[1]=o[1]+n>>>0,o[2]=o[2]+r>>>0,o[3]=o[3]+i>>>0,o[4]=o[4]+c>>>0,o[5]=o[5]+l>>>0,o[6]=o[6]+u>>>0,o[7]=o[7]+d>>>0}let c=``;for(let e=0;e<8;e++)c+=o[e].toString(16).padStart(8,`0`);return c}var Uy=H([`informational`,`low`,`medium`,`high`,`critical`]),Wy=H([`clean`,`informational`,`actionable`,`critical`]),Gy=V({fingerprint:Ty.optional(),title:R().min(1),severity:H([`info`,`low`,`medium`,`high`,`critical`]),details:R().default(``),targetUrl:R().optional(),cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R().min(1)).default([]),remediation:R().default(``),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]).default(`candidate`),evidenceRefs:B(Ty).default([])}),Ky=V({description:R().min(1),artifactType:R().min(1),data:Cy().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional()}),qy=H([`observation`,`artifact`,`control_result`,`manual_confirmation`,`report`]),Jy=V({fingerprint:Ty,title:R().min(1),description:R().default(``),severity:Uy,cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R()).default([]),remediation:R().default(``),targetUrl:R().optional(),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]),evidenceRefs:B(Ty).default([]),status:H([`open`]).default(`open`)}).strict(),Yy=V({fingerprint:Ty,kind:qy,title:R().min(1),summary:R().default(``),artifactType:R(),sha256:Ty,timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional(),classification:Oy.default(`confidential`)}).strict(),Xy=V({satisfied:Iv(),missing:B(R())}).strict(),Zy=V({id:U,runId:U,projectId:U,workflowKey:R().min(1),workflowVersionId:U,version:z().int().nonnegative(),contentHash:Ty,target:R().min(1),scopeOrigins:B(R()).default([]),summary:R().default(``),posture:Wy,findings:B(Jy).default([]),unverifiedLeads:B(Jy).default([]),evidence:B(Yy).default([]),negativeControls:B(R()).default([]),classification:Oy.default(`confidential`),publicationState:H([`draft`,`blocked`,`published`]).default(`draft`),gate:Xy,parentContentHash:Ty.nullable().default(null),editorialMarkdownHash:Ty.nullable().default(null),publishedAt:W.optional(),createdAt:W}).strict();V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),target:R().min(1),model:R().min(1)}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),description:R().min(1),artifactType:R().min(1),data:Cy().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative()}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),workflowKey:R().min(1),status:H([`succeeded`,`blocked`,`inconclusive`,`failed`]),terminationReason:R().max(300).optional(),findings:z().int().nonnegative(),evidence:z().int().nonnegative(),findingItems:B(Gy).default([]),evidenceItems:B(Ky).default([]),negativeControls:B(R().min(1).max(4e3)).max(500).default([]),toolAttempts:z().int().nonnegative(),toolsExecuted:z().int().nonnegative(),toolsErrored:z().int().nonnegative(),pricingUnknown:Iv().optional()}),V({runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),kind:H([`finding`,`evidence`]),index:z().int().nonnegative(),issues:B(R().max(120)).min(1).max(20)}),V({id:U,organizationId:U,name:R().trim().min(1).max(120),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({id:U,organizationId:U,workspaceId:U,name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),archivedAt:W.nullable(),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});var Qy=V({id:U,kind:H([`domain`,`ip`,`cidr`,`url`,`repository`,`api`,`android`,`ios`,`custom`]),locator:R().trim().min(1).max(2048),displayName:R().trim().min(1).max(240)}),$y=V({id:U,owner:R().trim().min(1),documentArtifactId:U,validFrom:W,validUntil:W,allowedActions:B(R().min(1)).min(1),prohibitedActions:B(R().min(1)),sha256:Ty}),eb=V({requestsPerSecond:z().positive().optional(),concurrency:z().int().positive().optional(),durationSeconds:z().int().positive(),costUsd:z().nonnegative().optional(),modelTokens:z().int().nonnegative().optional()}),tb=V({projectId:U,name:R().trim().min(1).max(160),targets:B(Qy).min(1),exclusions:B(R().trim().min(1)),authorization:$y.optional(),allowedRisk:Dy,allowedActions:B(R().min(1)),prohibitedActions:B(R().min(1)),limits:eb,requiredWorkerClass:R().trim().min(1),requiredCapabilities:B(R().trim().min(1)),credentialReferences:B(R().trim().min(1)),dataClassification:Oy,retentionPolicyId:U.optional(),notificationChannels:B(R().trim().min(1))}).extend({id:U,organizationId:U,workspaceId:U,revision:z().int().positive(),inputHash:Ty,createdAt:W,createdBy:U}),nb=H([`open`,`in_progress`,`accepted_risk`,`false_positive`,`remediated`,`verified`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,title:R().min(1),description:R(),severity:H([`informational`,`low`,`medium`,`high`,`critical`]),status:nb,fingerprint:Ty,version:z().int().nonnegative(),firstSeenAt:W,lastSeenAt:W}),V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),stageId:U.nullable(),agentSessionId:U.nullable(),toolCallId:U.nullable(),kind:H([`observation`,`artifact`,`report`,`manual_confirmation`,`control_result`]),title:R().min(1),summary:R(),classification:Oy,artifactId:U.nullable(),sha256:Ty,createdAt:W});var rb=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,objectKey:R().min(1),sha256:Ty,mimeType:R().min(1),size:z().int().nonnegative(),classification:Oy,createdBy:U,createdAt:W}),ib=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`mobile-application`,`red-team-campaign`,`purple-team-validation`,`nist-csf-2`,`cis-controls-8-1`,`advanced-security-testing`,`remediation-validation`,`network-security-audit`]),ab=V({key:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),name:R().min(1),description:R().min(1),risk:Dy,optional:Iv().default(!1),requiredCapabilities:B(R().min(1)),skillRefs:B(R().min(1).max(80)).max(64).default([]),retrySafe:Iv(),approvalCheckpoint:Iv(),timeoutSeconds:z().int().positive()}),ob=V({id:U,key:ib,version:R().regex(/^\d+\.\d+\.\d+$/),name:R().min(1),description:R().min(1),inputSchema:Xv(R(),Bv()),requiredCapabilities:B(R().min(1)),requiredIntegrations:B(R().min(1)),stages:B(ab).min(1),evidenceRequirements:B(R().min(1)).min(1),completionCriteria:B(R().min(1)).min(1),publishedAt:W,contentHash:Ty}),sb=V({code:H([`authorization_missing`,`authorization_expired`,`capability_missing`,`worker_missing`,`integration_missing`,`credential_missing`,`scope_invalid`,`approval_required`]),message:R().min(1),stageKey:R().optional(),capability:R().optional()}),cb=V({ready:Iv(),launchState:H([`ready`,`blocked`,`awaiting_approval`]),highestRisk:Dy,reasons:B(sb),matchingWorkerIds:B(U),inputHash:Ty}),lb=H([`draft`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`cancel_requested`,`succeeded`,`failed`,`cancelled`,`expired`]),ub=H([`pending`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`paused`,`succeeded`,`failed`,`cancel_requested`,`cancelled`,`expired`,`skipped`]);V({projectId:U,assessmentProfileId:U,workflowKey:ib,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Xv(R(),Bv()),workerClass:R().min(1),mode:H([`autonomous`,`guided`]).default(`autonomous`)});var db=V({id:U,organizationId:U,workspaceId:U,projectId:U,assessmentId:U,assessmentProfileId:U,workflowVersionId:U,workflowKey:ib,requestedBy:U,state:lb,risk:Dy,inputHash:Ty,workerClass:R(),mode:H([`autonomous`,`guided`]),attempt:z().int().positive(),retryOfRunId:U.nullable(),agentSessionId:U.nullable(),usage:ky,version:z().int().nonnegative(),createdAt:W,startedAt:W.nullable(),completedAt:W.nullable()}),fb=V({id:U,runId:U,key:R().min(1),position:z().int().nonnegative(),risk:Dy,state:ub,workerId:U.nullable(),version:z().int().nonnegative(),startedAt:W.nullable(),completedAt:W.nullable()});V({id:z().int().positive(),runId:U,stageId:U.nullable(),type:R().min(1),payload:Xv(R(),Bv()),occurredAt:W}),V({after:z().int().nonnegative().default(0)});var pb=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`network-security-audit`]);V({target:R().trim().min(1).max(2048),workflowKey:pb,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Xv(R(),Bv()).default({})}).extend({mode:H([`autonomous`,`guided`]).default(`autonomous`)}),V({owner:R().trim().min(2).max(200),statement:R().trim().min(20).max(2e3),validUntil:W});var mb=V({profile:tb,authorization:$y,artifact:rb}),hb=V({projectId:U,target:Qy,dossierKey:R().min(1),profileId:U,profileName:R().min(1),reusedProfile:Iv()}),gb=V({binding:hb,readiness:cb}),_b=V({binding:hb,run:db,stages:B(fb),agentSession:Ay}),vb=H([`pending`,`approved`,`rejected`,`expired`,`invalidated`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,stageId:U.nullable(),risk:Dy,state:vb,requestedBy:U,requiredRole:H([`security_manager`,`owner_or_admin`]),decidedBy:U.nullable(),decisionRole:H([`owner`,`admin`,`security_manager`]).nullable(),workflowVersionId:U,inputHash:Ty,scopeHash:Ty,targetSetHash:Ty,workerClass:R().min(1),actionSetHash:Ty,expiresAt:W,decidedAt:W.nullable(),reason:R().nullable()}),V({decision:H([`approve`,`reject`]),reason:R().trim().min(1).max(2e3),passwordConfirmation:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,sequence:z().int().positive(),organizationId:U,workspaceId:U,projectId:U.nullable(),actorId:U.nullable(),authSessionId:U.nullable(),action:R().min(1),resourceType:R().min(1),resourceId:R().min(1),requestId:R().min(1),correlationId:R().nullable(),ip:R().nullable(),userAgent:R().nullable(),outcome:H([`succeeded`,`denied`,`failed`]),reason:R().nullable(),beforeHash:Ty.nullable(),afterHash:Ty.nullable(),previousEventHash:Ty.nullable(),eventHash:Ty,occurredAt:W}),V({id:U,workspaceId:U,governanceDays:z().int().min(2555),assessmentDaysAfterClosure:z().int().min(1095),rawSessionDays:z().int().min(180),authSessionInvestigationDays:z().int().min(30),version:z().int().nonnegative()}),V({id:U,workspaceId:U,name:R().min(1),reason:R().min(1),resourceType:H([`assessment`,`run`,`agent_session`,`finding`,`artifact`]),resourceId:U,releasedAt:W.nullable(),createdAt:W});var yb=H([`workspace:admin`,`project:write`,`workflow:configure`,`run:launch`,`run:approve:r1`,`run:approve:r2`,`finding:write`,`session:read`,`session:read_sensitive`,`evidence:read`,`evidence:read_sensitive`,`governance:read`,`governance:write`]);V({user:V({id:U,email:R().email(),displayName:R().min(1),mfaEnrolled:Iv(),createdAt:W}),organizationId:U,memberships:B(V({workspaceId:U,workspaceName:R().min(1),role:Ey,permissions:B(yb)})),activeWorkspaceId:U}),V({id:U,userId:U,createdAt:W,lastSeenAt:W,expiresAt:W,ip:R().nullable(),userAgent:R().nullable(),current:Iv()}),V({password:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,workspaceId:U,email:R().email(),role:Ey,expiresAt:W,acceptedAt:W.nullable(),createdAt:W});var bb=z().int().nonnegative(),xb=R().min(1),Sb=H([`info`,`low`,`medium`,`high`,`critical`]),Cb=H([`open`,`unverified`,`confirmed`,`remediating`,`remediated`,`verified`,`false_positive`,`accepted_risk`,`suppressed`]),wb=H([`cli`,`tui`,`web`,`github`,`system`]),Tb=H([`scan`,`hunt`,`verify`,`import`]),Eb=H([`queued`,`running`,`completed`,`failed`,`cancelled`]),Db=Xv(R(),Bv()),Ob=V({id:xb,workspaceID:xb,projectID:xb.nullable(),repositoryID:xb.nullable(),engagementID:xb.nullable(),targetID:xb.nullable(),parentRunID:xb.nullable(),sessionID:xb.nullable(),source:wb,kind:Tb,status:Eb,title:R(),requestedBy:R().nullable(),baseRevision:R().nullable(),headRevision:R().nullable(),promptRevision:R().nullable(),promptFingerprint:R().nullable(),configuration:Db.nullable(),summary:Db.nullable(),error:Db.nullable(),idempotencyKey:R().nullable(),createdAt:bb,startedAt:bb.nullable(),completedAt:bb.nullable(),updatedAt:bb}),kb=V({runs:B(Ob),nextCursor:R().optional()}),Ab=V({id:xb,fingerprint:R().min(1),title:R(),description:R().nullable(),severity:Sb,status:Cb,path:R().nullable(),line:z().int().nullable(),category:R().nullable(),firstSeenAt:bb,lastSeenAt:bb,updatedAt:bb}),jb=V({findings:B(Ab),total:z().int().nonnegative()}),Mb=V({id:xb,runID:xb.nullable(),operationID:xb.nullable(),kind:R(),verdict:R(),reason:R().nullable(),payload:Db.nullable(),createdAt:bb}),Nb=V({finding:Ab.extend({cwe:R().nullable(),cve:R().nullable(),cvssScore:z().nullable(),cvssVector:R().nullable(),remediation:R().nullable(),assignee:R().nullable(),resolvedAt:bb.nullable(),evidence:B(Mb)})}),Pb=V({id:xb,runID:xb,tool:R(),runtime:R(),status:R(),outcome:R(),title:R().nullable(),input:Db.nullable(),outputPreview:R().nullable(),error:Db.nullable(),startedAt:bb,completedAt:bb.nullable()}),Fb=V({run:Ob,operations:B(Pb.omit({runID:!0})),findings:B(Ab)}),Ib=V({id:xb,title:R(),kind:R(),source:R(),status:H([`running`,`failed`,`completed`]),runCount:z().int().nonnegative(),operationCount:z().int().nonnegative(),findingCount:z().int().nonnegative(),startedAt:bb,lastActivityAt:bb}),Lb=V({session:Ib,runs:B(Ob),operations:B(Pb),findings:B(Ab)}),Rb=V({id:xb,sequence:z().int().positive(),actorID:R().nullable(),action:R().min(1),objectType:R().min(1),objectID:R().min(1),outcome:H([`succeeded`,`denied`,`failed`]),details:Db.nullable(),createdAt:bb}),zb=V({id:xb,workspaceId:xb,name:R(),slug:R(),archivedAt:bb.nullable(),createdAt:bb,updatedAt:bb}),Bb=V({id:xb,name:R(),role:R(),createdAt:bb,updatedAt:bb}),Vb=V({id:xb,name:R(),status:R(),capabilities:B(R()).default([]),lastSeenAt:bb.nullable()}),Hb=V({sessionId:R().nullable().optional(),runs:Xv(R(),z()),findings:V({total:z().int().nonnegative(),bySeverity:Xv(R(),z()),byStatus:Xv(R(),z())}),recentRuns:B(Ob),recentFindings:B(Ab)}),Ub=V({count:z().int().nonnegative(),limit:z().int().positive(),hasMore:Iv()});function Wb(e){return V({items:B(e),page:Ub})}V({workspaceId:U,clientId:U,batchId:U,records:B(V({id:U,kind:H([`agent_session`,`evidence`,`finding`,`governance_event`]),localSequence:z().int().positive(),payload:Xv(R(),Bv()),payloadHash:Ty,occurredAt:W})).min(1).max(500)}),V({batchId:U,accepted:B(U),rejected:B(V({id:U,code:R(),detail:R()})),centralizedApproval:$v(!1)});var Gb=H([`command_execution`,`read_files`,`write_files`,`http_request`,`run_exploit`,`dns_recon`,`state_mutation`,`skill_load`]);V({stageId:R().uuid(),workflowVersionId:R().uuid(),stageKey:R().min(1),requiredCapabilities:B(R().min(1)),allowedToolCategories:B(Gb),allowedSkills:B(R().min(1).max(80)).max(64).default([]),retrySafe:Iv(),timeoutMs:z().int().positive()});var Kb=V({workerClass:H([`network`,`web-api`,`mobile-lab`,`advanced-analysis`,`passive`]),capabilities:B(R().min(1)),tools:Xv(R(),R()),networkLocation:R().nullable(),devices:B(V({id:R(),platform:H([`android`,`ios`]),version:R()})),limits:V({concurrency:z().int().positive(),memoryMb:z().int().positive(),cpuMillis:z().int().positive(),durationSeconds:z().int().positive()})});V({token:R().min(32),name:R().trim().min(1).max(160),publicKey:R().min(32),capabilities:Kb}),V({expiresAt:W}),V({token:R().min(32),expiresAt:W}),V({worker:V({id:U,organizationId:U,workspaceId:U,name:R(),publicKey:R(),capabilities:Kb,status:H([`enrolling`,`online`,`offline`,`revoked`]),lastHeartbeatAt:W.nullable(),createdAt:W}),accessToken:R().min(32),expiresAt:W}),V({capabilities:Kb.optional(),runningJobIds:B(U)}),V({id:U,runId:U,stageId:U,workerId:U,leaseToken:R().min(32),leaseExpiresAt:W,attempt:z().int().positive(),payload:Xv(R(),Bv())}),V({leaseToken:R().min(32),events:B(V({idempotencyKey:R().min(8),type:R().min(1),occurredAt:W,payload:Xv(R(),Bv())})).min(1).max(500)});var qb=V({leaseToken:R().min(32)});qb.extend({extendSeconds:z().int().min(10).max(300).default(60)}),qb.extend({outcome:H([`succeeded`,`failed`,`cancelled`]),summary:Xv(R(),Bv()).default({}),error:R().max(2e4).optional(),retrySafe:Iv().default(!1)});function Jb(e){if(typeof e!=`object`||!e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Jb).join(`,`)}]`;let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${Jb(t[e])}`).join(`,`)}}`}function Yb(e){return Hy(typeof e==`string`?e:Jb(e))}function Xb(e){return`kifaru-workflow-${e}`}var G=(e,t,n,r,i={})=>({key:e,name:t,description:i.description??t,risk:n,optional:i.optional??!1,requiredCapabilities:r,skillRefs:i.skillRefs??(r.includes(`reporting`)?[`kifaru-vulnerability-report`]:r.some(e=>[`web-testing`,`authenticated-browser`,`api-client`,`api-security-testing`].includes(e))?[`kifaru-web-app-review`]:r.some(e=>[`mobile-static`,`mobile-device`,`mobile-proxy`].includes(e))?[`kifaru-mobile-app-review`]:[]),retrySafe:i.retrySafe??n!==`R2`,approvalCheckpoint:i.approvalCheckpoint??n!==`R0`,timeoutSeconds:i.timeoutSeconds??3600}),Zb=[{id:`10000000-0000-4000-8000-000000000101`,key:`internal-infrastructure`,name:`Internal Infrastructure Assessment`,description:`Customer-network discovery, configuration review, bounded validation, evidence capture, and reporting.`,requiredCapabilities:[`network-discovery`,`vulnerability-scanner`,`reporting`],stages:[G(`discovery`,`Discovery and inventory`,`R1`,[`network-discovery`]),G(`configuration-review`,`Configuration review`,`R1`,[`configuration-review`]),G(`vulnerability-checks`,`Vulnerability checks`,`R1`,[`vulnerability-scanner`]),G(`bounded-validation`,`Bounded validation`,`R1`,[`safe-validation`]),G(`exploitation`,`Approved exploitation`,`R2`,[`exploit-runner`],{retrySafe:!1,optional:!0}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`host and service inventory`,`tool output with provenance`,`validation evidence`],completionCriteria:[`authorized targets accounted for`,`all executed checks have outcomes`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000102`,key:`external-infrastructure`,name:`External Infrastructure Assessment`,description:`Internet-facing inventory, DNS, TLS, exposed-service, and known-vulnerability assessment with run comparison.`,requiredCapabilities:[`dns`,`tls`,`network-discovery`,`vulnerability-scanner`,`reporting`],stages:[G(`inventory`,`Domain and IP inventory`,`R1`,[`dns`]),G(`service-discovery`,`Exposed service discovery`,`R1`,[`network-discovery`,`tls`]),G(`vulnerability-checks`,`Known-vulnerability checks`,`R1`,[`vulnerability-scanner`]),G(`comparison`,`Previous-run comparison`,`R0`,[`run-comparison`],{approvalCheckpoint:!1}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`resolved inventory`,`service fingerprints`,`comparison baseline`],completionCriteria:[`all in-scope assets classified`,`material changes recorded`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000103`,key:`web-application`,name:`Web Application Assessment`,description:`Authenticated surface discovery, client analysis, focused testing, evidence gating, and reporting.`,requiredCapabilities:[`web-testing`,`reporting`],stages:[G(`surface-discovery`,`Surface discovery`,`R1`,[`web-testing`]),G(`authenticated-flows`,`Authenticated flow capture`,`R1`,[`authenticated-browser`],{optional:!0}),G(`client-analysis`,`Client-side analysis`,`R0`,[`source-analysis`],{approvalCheckpoint:!1}),G(`focused-testing`,`Focused vulnerability testing`,`R1`,[`web-testing`]),G(`destructive-payloads`,`Approved destructive payloads`,`R2`,[`exploit-runner`],{retrySafe:!1,optional:!0}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`request and response provenance`,`reproduction evidence`,`negative controls`],completionCriteria:[`authenticated roles exercised`,`findings pass evidence gate`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000104`,key:`api-security`,name:`API Security Assessment`,description:`Schema import, authorization mapping, object-access and state-machine testing, and differential probes.`,requiredCapabilities:[`api-client`,`api-security-testing`,`reporting`],stages:[G(`schema-import`,`API schema and request import`,`R0`,[`openapi`],{approvalCheckpoint:!1}),G(`auth-mapping`,`Authentication and authorization mapping`,`R1`,[`api-client`]),G(`object-access`,`Object access tests`,`R1`,[`api-security-testing`]),G(`state-machine`,`State-machine checks`,`R1`,[`api-security-testing`]),G(`differential-probes`,`Differential probes`,`R1`,[`api-security-testing`]),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`imported request source`,`identity and object matrix`,`differential responses`],completionCriteria:[`declared operations accounted for`,`authorization hypotheses resolved`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000105`,key:`mobile-application`,name:`Android and iOS Assessment`,description:`Static artifact analysis with optional dynamic mobile-lab execution on registered devices.`,requiredCapabilities:[`mobile-static`,`reporting`],stages:[G(`static-analysis`,`Static artifact analysis`,`R0`,[`mobile-static`],{approvalCheckpoint:!1}),G(`dynamic-analysis`,`Dynamic device analysis`,`R1`,[`mobile-device`,`mobile-proxy`],{optional:!0}),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`artifact checksum`,`static analyzer output`,`device provenance for dynamic results`],completionCriteria:[`selected static or dynamic coverage is explicit`,`report artifact produced`],inputSchema:{coverage:{enum:[`static-only`,`full-dynamic`]}}},{id:`10000000-0000-4000-8000-000000000106`,key:`red-team-campaign`,name:`Red Team Campaign`,description:`Rules-of-engagement validation, reconnaissance, hypothesis execution, verification, and reporting.`,requiredCapabilities:[`red-team`,`reporting`],stages:[G(`roe-validation`,`Rules-of-engagement validation`,`R0`,[`authorization-review`],{approvalCheckpoint:!1}),G(`reconnaissance`,`Reconnaissance`,`R1`,[`network-discovery`]),G(`hypothesis-planning`,`Hypothesis planning`,`R0`,[`red-team`],{approvalCheckpoint:!1}),G(`execution`,`Approved campaign execution`,`R2`,[`red-team`],{retrySafe:!1}),G(`verification`,`Outcome verification`,`R1`,[`safe-validation`]),G(`reporting`,`Campaign reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`rules-of-engagement snapshot`,`action provenance`,`verification evidence`],completionCriteria:[`no persistence beyond authorization`,`all actions reconciled`,`report artifact produced`]},{id:`10000000-0000-4000-8000-000000000107`,key:`purple-team-validation`,name:`Purple Team Validation`,description:`Vendor-neutral ATT&CK-aligned detection validation using signed, uploaded, or manually confirmed evidence.`,requiredCapabilities:[`detection-emulation`,`evidence-ingest`,`reporting`],stages:[G(`expectations`,`Detection expectation mapping`,`R0`,[`attack-mapping`],{approvalCheckpoint:!1}),G(`emulation`,`Controlled detection emulation`,`R1`,[`detection-emulation`]),G(`evidence-ingest`,`SIEM and EDR evidence ingest`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`outcomes`,`Detection outcome classification`,`R0`,[`attack-mapping`],{approvalCheckpoint:!1}),G(`reporting`,`Validation reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`ATT&CK technique identifier`,`detection expectation`,`signed or attributable result`],completionCriteria:[`every expectation has a four-state outcome`,`all outcomes link evidence`]},{id:`10000000-0000-4000-8000-000000000108`,key:`nist-csf-2`,name:`NIST CSF 2.0 Assessment`,description:`Versioned CSF evidence requests, observations, gaps, applicability decisions, and maturity notes.`,requiredCapabilities:[`compliance-nist`,`evidence-ingest`,`reporting`],stages:[G(`scope`,`Framework scope and applicability`,`R0`,[`compliance-nist`],{approvalCheckpoint:!1}),G(`evidence`,`Evidence collection`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`assessment`,`Requirement assessment`,`R0`,[`compliance-nist`],{approvalCheckpoint:!1}),G(`reporting`,`Assessment reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`pinned framework requirement`,`applicability decision`,`evidence or explicit gap`],completionCriteria:[`all applicable requirements assessed`,`output states assessment not certification`]},{id:`10000000-0000-4000-8000-000000000109`,key:`cis-controls-8-1`,name:`CIS Controls v8.1 Assessment`,description:`Implementation-group-aware evidence and test results mapped to versioned CIS safeguards.`,requiredCapabilities:[`compliance-cis`,`evidence-ingest`,`reporting`],stages:[G(`implementation-group`,`Implementation group selection`,`R0`,[`compliance-cis`],{approvalCheckpoint:!1}),G(`evidence`,`Safeguard evidence collection`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`assessment`,`Safeguard assessment`,`R0`,[`compliance-cis`],{approvalCheckpoint:!1}),G(`reporting`,`Assessment reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`pinned safeguard`,`implementation group`,`evidence or explicit gap`],completionCriteria:[`all selected safeguards assessed`,`output states assessment not certification`]},{id:`10000000-0000-4000-8000-00000000010a`,key:`advanced-security-testing`,name:`Advanced Security Testing`,description:`Curated source, binary, firmware, protocol, smart-contract, and bounded custom testing.`,requiredCapabilities:[`advanced-analysis`,`reporting`],stages:[G(`analysis`,`Selected advanced analysis`,`R0`,[`advanced-analysis`],{approvalCheckpoint:!1}),G(`bounded-fuzzing`,`Bounded protocol fuzzing`,`R2`,[`protocol-fuzzing`],{retrySafe:!1,optional:!0}),G(`validation`,`Result validation`,`R1`,[`safe-validation`]),G(`reporting`,`Evidence-backed reporting`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`selected subtype`,`toolchain versions`,`reproducible evidence`],completionCriteria:[`unsupported stages blocked before launch`,`report artifact produced`],inputSchema:{subtype:{enum:[`source-review`,`binary-firmware`,`protocol-fuzzing`,`smart-contract`,`custom`]}}},{id:`10000000-0000-4000-8000-00000000010b`,key:`remediation-validation`,name:`Remediation Validation`,description:`Finding-led validation that reuses original scope, evidence contracts, and safe reproduction steps.`,requiredCapabilities:[`safe-validation`,`reporting`],stages:[G(`baseline`,`Original evidence baseline`,`R0`,[`evidence-ingest`],{approvalCheckpoint:!1}),G(`reproduction`,`Safe reproduction`,`R1`,[`safe-validation`]),G(`comparison`,`Before and after comparison`,`R0`,[`run-comparison`],{approvalCheckpoint:!1}),G(`finding-transition`,`Verified finding transition`,`R0`,[`finding-write`],{approvalCheckpoint:!1})],evidenceRequirements:[`original finding`,`before evidence`,`after evidence`],completionCriteria:[`only conclusive success marks verified`,`failed or inconclusive validation leaves finding open`],inputSchema:{findingIds:{type:`array`,minItems:1}}},{id:`10000000-0000-4000-8000-00000000010c`,key:`network-security-audit`,name:`Network Security Audit`,description:`Composite assessment that selects applicable child workflows and consolidates coverage and evidence.`,requiredCapabilities:[`workflow-orchestration`,`reporting`],stages:[G(`selection`,`Child workflow selection`,`R0`,[`workflow-orchestration`],{approvalCheckpoint:!1}),G(`combined-readiness`,`Combined readiness check`,`R0`,[`workflow-orchestration`],{approvalCheckpoint:!1}),G(`child-runs`,`Approved child runs`,`R1`,[`workflow-orchestration`]),G(`consolidation`,`Coverage and finding consolidation`,`R0`,[`reporting`],{approvalCheckpoint:!1})],evidenceRequirements:[`child workflow versions`,`combined readiness decision`,`child run provenance`],completionCriteria:[`all selected children terminal`,`consolidated coverage identifies blocked work`],inputSchema:{childWorkflowKeys:{type:`array`,minItems:1}}}],Qb=`2026-09-06T00:00:00.000Z`;Zb.map(e=>{let t=Xb(e.key),n=e.stages.map(e=>({...e,timeoutSeconds:e.timeoutSeconds??3600,skillRefs:e.skillRefs.includes(t)?e.skillRefs:[...e.skillRefs,t]})),r={id:e.id,key:e.key,version:`1.1.0`,name:e.name,description:e.description,inputSchema:e.inputSchema??{},requiredCapabilities:e.requiredCapabilities,requiredIntegrations:e.requiredIntegrations??[],stages:n,evidenceRequirements:e.evidenceRequirements,completionCriteria:e.completionCriteria,publishedAt:Qb,contentHash:Yb({...e,stages:n})};return ob.parse(r)});var $b=V({items:B(ob)}),ex=V({workflowKey:R(),skillName:R(),markdown:R(),revision:R(),customized:Iv()}),tx=V({runId:R(),workflowKey:R(),target:R(),permissionMode:H([`scoped`,`yolo`]),status:R(),dbPath:R(),reportPath:R()}),nx=V({runId:R(),workflowKey:R(),target:R(),permissionMode:H([`scoped`,`yolo`]),status:H([`queued`,`running`,`completed`,`partial`,`failed`,`cancelled`]),startedAt:z(),finishedAt:z().nullable(),error:R().nullable(),reportAvailable:Iv(),stages:B(V({key:R(),name:R(),status:R(),summary:R()}))}),rx=V({items:B(nx)}),ix=V({items:B(V({runId:R(),workflowKey:R(),target:R(),posture:R(),findings:z(),unverifiedLeads:z().default(0),createdAt:R()}))}),ax=Wb(Bb),ox=Wb(zb),sx=V({items:B(tb)}),cx=Wb(Ib),lx=Wb(Rb),ux=Wb(Vb),dx=V({id:R(),label:R(),prefix:R().optional().default(``),tokenPrefix:R().optional(),role:R().optional().default(`admin`),workspaceId:R().optional().default(`default`),createdAt:R(),expiresAt:R().nullable().optional(),lastUsedAt:R().nullable().optional()}),fx=dx.extend({token:R()}),px=V({items:B(dx)}),mx=V({provider:H([`azure-openai`,`openai-compatible`,`anthropic`]),scope:H([`user`,`workspace`]),ownerID:R(),workspaceID:R(),lastFour:R(),createdAt:R(),updatedAt:R()}),hx=V({items:B(mx)}),gx=V({items:B(V({version:z().int().nonnegative(),posture:R(),target:R(),contentHash:R(),classification:R(),publicationState:H([`draft`,`blocked`,`published`]),gate:V({satisfied:Iv(),missing:B(R())}),publishedAt:R().nullable(),createdAt:R()}))}),_x=V({ext:R(),mimeType:R(),url:R().nullable(),rendered:Iv()}),vx=V({version:z().int().nonnegative(),contentHash:R(),posture:R(),target:R(),classification:R(),record:Zy,renditions:B(_x)}),yx=V({artifacts:B(V({artifactId:R(),mimeType:R(),size:z(),sha256:R()}))}),bx=V({version:z().int().nonnegative(),contentHash:R(),posture:R()}),xx=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function Sx(e=fetch){async function t(t,n,r){let i=document.querySelector(`meta[name="csrf-token"]`)?.content||sessionStorage.getItem(`kifaru-csrf`)||document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`kifaru_csrf=`))?.slice(12),a=r?.method?.toUpperCase()??`GET`,o=await e(t,{credentials:`same-origin`,...r,headers:{accept:`application/json`,...a!==`GET`&&a!==`HEAD`&&i?{"x-csrf-token":i}:{},...r?.headers}});if(!o.ok&&o.status===401&&typeof window<`u`&&!window.location.pathname.startsWith(`/login`))throw window.location.href=`/login?redirect=${encodeURIComponent(window.location.pathname+window.location.search)}`,new xx(401,`unauthorized`,`Session expired. Redirecting to login.`);let s=await o.json().catch(()=>void 0);if(!o.ok){let e=s;throw new xx(o.status,e?.code??`request_failed`,e?.detail??`Request failed.`)}return n.parse(s)}return{workflows:()=>t(`/api/v1/workflows`,$b),workflowSkill:e=>t(`/api/v1/workflows/${encodeURIComponent(e)}/skill`,V({item:ex})),saveWorkflowSkill:(e,n,r)=>t(`/api/v1/workflows/${encodeURIComponent(e)}/skill`,V({item:ex}),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n,expectedRevision:r})}),runs:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??20)),n?.sessionId&&r.set(`sessionId`,n.sessionId),t(`/api/v1/runs?${r.toString()}`,kb)},runDetail:e=>t(`/api/v1/runs/${encodeURIComponent(e)}`,Fb),workspaces:()=>t(`/api/v1/workspaces`,ax),projects:()=>t(`/api/v1/projects`,ox),assessmentProfiles:()=>t(`/api/v1/assessment-profiles`,sx),authorizeAssessmentProfile:(e,n)=>t(`/api/v1/assessment-profiles/${encodeURIComponent(e)}/authorization-attestations`,mb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(n)}),findings:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e||`runId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??50)),n?.sessionId&&r.set(`sessionId`,n.sessionId),n?.runId&&r.set(`runId`,n.runId),t(`/api/v1/findings?${r.toString()}`,jb)},finding:e=>t(`/api/v1/findings/${encodeURIComponent(e)}`,Nb),updateFindingStatus:(e,n,r)=>t(`/api/v1/findings/${encodeURIComponent(e)}/status`,Nb,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:n,...r?{note:r}:{}})}),agentSessions:()=>t(`/api/v1/agent/sessions?limit=50`,cx),agentSession:e=>t(`/api/v1/agent/sessions/${encodeURIComponent(e)}`,Lb),governanceEvents:()=>t(`/api/v1/governance/audit-events?limit=50`,lx),workers:()=>t(`/api/v1/workers`,ux),overview:e=>{let n;return typeof e==`string`?n=e:e&&typeof e==`object`&&`sessionId`in e&&typeof e.sessionId==`string`&&(n=e.sessionId),t(n?`/api/v1/overview?sessionId=${encodeURIComponent(n)}`:`/api/v1/overview`,Hb)},tokens:()=>t(`/api/v1/tokens`,px),modelCredentials:()=>t(`/api/v1/model-credentials`,hx),saveModelCredential:(e,n,r)=>t(`/api/v1/model-credentials/${e}/${n}`,V({item:mx}),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({apiKey:r})}),deleteModelCredential:(e,n)=>t(`/api/v1/model-credentials/${e}/${n}`,V({ok:Iv()}),{method:`DELETE`}),myRole:()=>t(`/api/v1/me`,V({role:R()})),createInvitation:e=>t(`/api/v1/invitations`,V({token:R(),email:R(),expiresAt:R()}),{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({email:e})}),mintToken:e=>t(`/api/v1/tokens`,fx,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),revokeToken:e=>t(`/api/v1/tokens/${encodeURIComponent(e)}`,V({ok:Iv()}),{method:`DELETE`}),targetAssessmentReadiness:e=>t(`/api/v1/assessments/readiness`,gb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startTargetAssessment:e=>t(`/api/v1/assessments`,_b,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startLocalRun:e=>t(`/api/v1/local-runs`,tx,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),localRuns:()=>t(`/api/v1/local-runs`,rx),localRun:e=>t(`/api/v1/local-runs/${encodeURIComponent(e)}`,V({item:nx})),localReports:()=>t(`/api/v1/local-reports`,ix),reportVersions:e=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports`,gx),reportVersion:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}`,vx),renderReportRenditions:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/renditions`,yx,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({})}),publishEditedMarkdown:(e,n,r)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/editor`,bx,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({markdown:r})})}}var Cx=Sx(),wx=new Rd({defaultOptions:{queries:{staleTime:1e4,retry:2,refetchOnWindowFocus:!0}}}),Tx=[{n:1,name:`Collection & Onboarding`,v:`--s1`},{n:2,name:`Storage & Security`,v:`--s2`},{n:3,name:`Use & Processing`,v:`--s3`},{n:4,name:`Sharing & Disclosure`,v:`--s4`},{n:5,name:`Retention`,v:`--s5`},{n:6,name:`Disposal & Erasure`,v:`--s6`}];function Ex(e){return Tx[Math.min(Math.max(e,1),Tx.length)-1]}function Dx(e){return e.name.split(` `)[0]}var Ox=[`Governance`,`Technical`,`People & 3rd-party`,`Assurance`],kx=[`critical`,`high`,`medium`,`low`,`info`],Ax={critical:0,high:1,medium:2,low:3,info:4},jx={critical:`--crit`,high:`--high`,medium:`--med`,low:`--low`,info:`--info`},Mx={critical:`Critical`,high:`High`,medium:`Medium`,low:`Low`,info:`Info`};function Nx(e){return e===`informational`?`info`:kx.includes(e)?e:`info`}function Px(e){return e.length?[...e].sort((e,t)=>Ax[e.severity]-Ax[t.severity])[0].severity:null}function Fx(e){return[...e].sort((e,t)=>Ax[e.severity]-Ax[t.severity])}function Ix(e){return e.status!==`remediated`&&e.status!==`verified`}var Lx=/^(?:L|stage )([1-6])\s*·\s*P([0-3])\s*·\s*(.+)$/i;function Rx(e,t){let n=(e??``).trim(),r=Lx.exec(n);if(r)return{stage:Number(r[1]),pillar:Number(r[2]),category:r[3],inferred:!1};let i=`${n} ${t??``}`.toLowerCase();return{stage:/sharing|disclos|transfer|cross-border|offshore|sftp|export|feed|webhook|api partner|integration/.test(i)?4:/retention|purge|backup|archive|dr site|snapshot|data lake/.test(i)?5:/eras|disposal|destroy|delete|decommission|shred/.test(i)?6:/consent|intake|onboarding|collection|telematics|form capture|survey/.test(i)?1:/encrypt|at rest|bucket|object store|database exposure|unencrypted|storage|nas|s3/.test(i)?2:3,pillar:/governance|dpia|retention schedule|policy|register|oversight|audit/.test(i)?0:/shared credential|third-party|tpa|vendor|partner|outsourc|staff|insider/.test(i)?2:1,category:n||`Agent finding`,inferred:!0}}function zx(e){return e.map(e=>{let t=Rx(e.category,e.title);return{...e,severity:Nx(e.severity),stage:t.stage,pillar:t.pillar,displayCategory:t.inferred?`${t.category} (stage inferred)`:t.category,inferred:t.inferred}})}function Bx(e){return Px(e.filter(e=>e.status===`confirmed`||e.status===`verified`))}function Vx({title:e,sub:t,surface:n=!0,children:r}){return(0,b.jsxs)(`section`,{className:n?`bg-card rounded-xl border p-5`:void 0,children:[(0,b.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-3`,children:[(0,b.jsx)(`h2`,{children:e}),t?(0,b.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:t}):null]}),r]})}function Hx({children:e}){return(0,b.jsx)(`div`,{className:`kpis`,children:e})}function Ux({label:e,value:t,meta:n,hero:r,tone:i}){return(0,b.jsxs)(`div`,{className:r?`kpi hero`:`kpi`,children:[(0,b.jsx)(`div`,{className:`lab`,children:e}),r?(0,b.jsxs)(`div`,{className:`posture-pill val`,style:i?{color:`var(${jx[i]})`}:void 0,children:[(0,b.jsx)(`span`,{className:`sq`}),t]}):(0,b.jsx)(`div`,{className:`val`,children:t}),n?(0,b.jsx)(`div`,{className:`meta`,children:n}):null]})}function Wx({counts:e}){let t=kx.reduce((t,n)=>t+(e[n]??0),0),n=Math.max(...kx.map(t=>e[t]??0),1);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-4.5 pt-1`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between text-2xs font-medium text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`tracking-wide uppercase font-semibold text-[10px]`,children:`Severity Profile`}),(0,b.jsxs)(`span`,{className:`font-mono text-2xs font-semibold text-foreground/80`,children:[t,` `,t===1?`finding`:`findings`,` total`]})]}),(0,b.jsx)(`div`,{className:`h-3 w-full rounded-full bg-muted/30 p-0.5 flex gap-1 overflow-hidden shadow-2xs`,children:t>0?kx.map(n=>{let r=e[n]??0;if(r===0)return null;let i=r/t*100;return(0,b.jsx)(`div`,{className:`h-full rounded-full transition-all duration-300 relative group cursor-pointer`,style:{width:`${i}%`,backgroundColor:`var(${jx[n]})`,boxShadow:`0 0 10px color-mix(in srgb, var(${jx[n]}) 40%, transparent)`},title:`${Mx[n]}: ${r} (${Math.round(i)}%)`},n)}):(0,b.jsx)(`div`,{className:`h-full w-full rounded-full bg-muted/40`})})]}),(0,b.jsx)(`div`,{className:`flex flex-col gap-2`,children:kx.map(r=>{let i=e[r]??0,a=t>0?Math.round(i/t*100):0,o=n>0?i/n*100:0,s=i===0;return(0,b.jsxs)(`div`,{className:`group flex items-center gap-3 px-2.5 py-1.5 rounded-lg hover:bg-muted/30 transition-all duration-150`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 w-24 shrink-0`,children:[(0,b.jsx)(`span`,{className:`size-2 rounded-full shrink-0 transition-transform duration-200 group-hover:scale-125`,style:{backgroundColor:`var(${jx[r]})`,boxShadow:s?void 0:`0 0 8px color-mix(in srgb, var(${jx[r]}) 70%, transparent)`}}),(0,b.jsx)(`span`,{className:`text-xs font-semibold text-foreground/90`,children:Mx[r]})]}),(0,b.jsx)(`div`,{className:`flex-1 h-2.5 rounded-full bg-muted/30 overflow-hidden relative p-[2px]`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ease-out`,style:{width:s?`0%`:`${o}%`,minWidth:s?`0px`:`8px`,background:`linear-gradient(90deg, color-mix(in srgb, var(${jx[r]}) 85%, white 15%), var(${jx[r]}))`}})}),(0,b.jsxs)(`div`,{className:`flex items-center justify-end gap-2.5 min-w-[64px] shrink-0 text-right`,children:[(0,b.jsx)(`span`,{className:`text-2xs font-mono text-muted-foreground/60 w-8`,children:s?``:`${a}%`}),(0,b.jsx)(`span`,{className:`text-xs font-mono font-semibold ${s?`text-muted-foreground/40`:`text-foreground font-bold`}`,children:i})]})]},r)})})]})}function Gx({findings:e}){let t=Tx.map(t=>e.filter(e=>e.stage===t.n).length),n=e.length,r=Math.max(...t,1);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-4.5 pt-1`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between text-2xs font-medium text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`tracking-wide uppercase font-semibold text-[10px]`,children:`Data Pipeline Spectrum`}),(0,b.jsx)(`span`,{className:`font-mono text-2xs font-semibold text-foreground/80`,children:`6 Lifecycle Stages`})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-6 gap-2 sm:gap-3 items-end h-[172px] px-1`,children:Tx.map((e,i)=>{let a=t[i],o=n>0?Math.round(a/n*100):0,s=a>0,c=Math.max(a/r*100,s?14:0);return(0,b.jsxs)(`div`,{className:`group flex flex-col items-center justify-end h-full gap-2 min-w-0`,title:`Stage ${e.n}: ${e.name} · ${a} ${a===1?`finding`:`findings`} (${o}%)`,children:[(0,b.jsx)(`div`,{className:`h-5 flex items-center justify-center`,children:(0,b.jsx)(`span`,{className:`text-xs font-mono transition-transform duration-200 group-hover:scale-110 ${s?`font-bold text-foreground`:`font-normal text-muted-foreground/35`}`,children:a})}),(0,b.jsx)(`div`,{className:`w-full max-w-[44px] h-[105px] rounded-xl bg-muted/25 hover:bg-muted/45 transition-colors relative flex flex-col justify-end p-1 overflow-hidden shadow-2xs`,children:s?(0,b.jsx)(`div`,{className:`w-full rounded-lg transition-all duration-500 ease-out`,style:{height:`${c}%`,background:`linear-gradient(180deg, var(${e.v}), color-mix(in srgb, var(${e.v}) 75%, black 15%))`,boxShadow:`0 2px 10px color-mix(in srgb, var(${e.v}) 35%, transparent)`}}):(0,b.jsx)(`div`,{className:`h-1 w-full rounded-full bg-muted-foreground/20 self-center mb-0.5`})}),(0,b.jsxs)(`div`,{className:`flex flex-col items-center gap-1 w-full pt-0.5`,children:[(0,b.jsx)(`span`,{className:`size-4.5 rounded-full text-[10px] font-mono font-semibold flex items-center justify-center transition-colors shadow-2xs`,style:{backgroundColor:s?`color-mix(in srgb, var(${e.v}) 22%, transparent)`:`var(--muted)`,color:s?`var(${e.v})`:`var(--muted-foreground)`},children:e.n}),(0,b.jsx)(`span`,{className:`text-[10px] sm:text-[11px] font-medium text-muted-foreground group-hover:text-foreground transition-colors max-w-full text-center leading-tight tracking-tight`,children:Dx(e)})]})]},e.n)})})]})}function Kx(e){let t=e.match(/\s*\((CWE-\d+)\)\s*$/i);return t?{title:e.replace(/\s*\((CWE-\d+)\)\s*$/i,``).trim(),cwe:t[1]?.toUpperCase()}:{title:e.trim(),cwe:void 0}}function qx(e){if(!e)return null;try{if(e.startsWith(`http://`)||e.startsWith(`https://`)){let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}}catch{}return e}function Jx(e){if(!e)return null;let t=e.toLowerCase();return t.includes(`dossier-finding`)||t===`agent finding`?null:e.replace(/\s*\(stage inferred\)/i,``).trim()}function Yx({severity:e}){let t={critical:{bg:`bg-[color-mix(in_srgb,var(--crit)_14%,transparent)]`,text:`text-[var(--crit)]`,border:`border-[color-mix(in_srgb,var(--crit)_28%,transparent)]`,glow:`var(--crit)`},high:{bg:`bg-[color-mix(in_srgb,var(--high)_14%,transparent)]`,text:`text-[var(--high)]`,border:`border-[color-mix(in_srgb,var(--high)_28%,transparent)]`,glow:`var(--high)`},medium:{bg:`bg-[color-mix(in_srgb,var(--med)_14%,transparent)]`,text:`text-[var(--med)]`,border:`border-[color-mix(in_srgb,var(--med)_28%,transparent)]`,glow:`var(--med)`},low:{bg:`bg-[color-mix(in_srgb,var(--low)_14%,transparent)]`,text:`text-[var(--low)]`,border:`border-[color-mix(in_srgb,var(--low)_28%,transparent)]`,glow:`var(--low)`},info:{bg:`bg-[color-mix(in_srgb,var(--info)_14%,transparent)]`,text:`text-[var(--info)]`,border:`border-[color-mix(in_srgb,var(--info)_28%,transparent)]`,glow:`var(--info)`}},n=t[e]??t.info;return(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-md text-[10.5px] font-mono font-bold tracking-wider uppercase border shrink-0 ${n.bg} ${n.text} ${n.border}`,children:[(0,b.jsx)(`span`,{className:`size-1.5 rounded-full shrink-0`,style:{backgroundColor:`var(${jx[e]})`,boxShadow:`0 0 6px ${n.glow}`}}),Mx[e]]})}function Xx({status:e}){let t=e.toLowerCase();return t===`confirmed`?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-semibold tracking-wide border border-amber-500/30 text-amber-600 dark:text-amber-400 bg-amber-500/10 shrink-0`,children:[(0,b.jsx)(op,{className:`size-3 shrink-0`}),`Confirmed`]}):t===`verified`?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-semibold tracking-wide border border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 shrink-0`,children:[(0,b.jsx)(sp,{className:`size-3 shrink-0`}),`Verified`]}):t===`resolved`||t===`remediated`?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-semibold tracking-wide border border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 shrink-0`,children:[(0,b.jsx)(Of,{className:`size-3 shrink-0`}),`Resolved`]}):t===`remediating`||t===`in_progress`?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-semibold tracking-wide border border-sky-500/30 text-sky-600 dark:text-sky-400 bg-sky-500/10 shrink-0`,children:[(0,b.jsx)(jf,{className:`size-3 shrink-0`}),`Remediating`]}):t===`false_positive`||t===`accepted_risk`||t===`suppressed`||t===`dismissed`?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-medium tracking-wide border border-border text-muted-foreground/60 bg-muted/10 line-through shrink-0`,children:[(0,b.jsx)(kf,{className:`size-3 shrink-0 opacity-60`}),t.replaceAll(`_`,` `)]}):(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-medium tracking-wide border border-border/70 text-muted-foreground bg-muted/20 shrink-0`,children:[(0,b.jsx)(`span`,{className:`size-1.5 rounded-full border border-current opacity-40 shrink-0`}),`Unverified`]})}function Zx({findings:e,onSelect:t,emptyLabel:n=`No findings.`}){return e.length?(0,b.jsx)(`div`,{className:`flex flex-col gap-1.5`,role:`list`,children:e.map(e=>{let n=Ex(e.stage),r=Kx(e.title),i=Jx(e.category),a=qx(e.path);return(0,b.jsxs)(`button`,{type:`button`,role:`listitem`,onClick:t?()=>t(e):void 0,className:`group relative flex items-center justify-between gap-3 sm:gap-4 px-3.5 py-3 rounded-xl border border-border/40 hover:border-border/90 bg-card/60 hover:bg-muted/30 hover:shadow-2xs transition-all duration-150 cursor-pointer w-full text-left`,children:[(0,b.jsx)(`div`,{className:`shrink-0 self-start sm:self-center`,children:(0,b.jsx)(Yx,{severity:e.severity})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,b.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,b.jsx)(`span`,{className:`text-[13px] sm:text-sm font-semibold text-foreground group-hover:text-primary transition-colors leading-snug line-clamp-1`,children:r.title})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:gap-2 text-2xs text-muted-foreground`,children:[(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md font-medium text-foreground/80 bg-muted/40 border border-border/40 shrink-0`,title:`Stage ${n.n}: ${n.name}`,children:[(0,b.jsx)(`span`,{className:`size-1.5 rounded-full shrink-0`,style:{backgroundColor:`var(${n.v})`}}),(0,b.jsxs)(`span`,{children:[`Stage `,n.n,` · `,Dx(n)]})]}),r.cwe?(0,b.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded font-mono font-bold text-[10px] tracking-wide bg-muted/60 text-foreground/75 border border-border/50 shrink-0`,children:r.cwe}):null,i?(0,b.jsx)(`span`,{className:`inline-flex items-center text-muted-foreground/80 font-medium truncate max-w-[160px]`,children:i}):null,a?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-mono text-muted-foreground/70 truncate max-w-[240px]`,children:[(0,b.jsx)(Vf,{className:`size-3 shrink-0 opacity-50`}),(0,b.jsx)(`span`,{className:`truncate`,children:a})]}):null]})]}),(0,b.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2.5 self-center`,children:[(0,b.jsx)(Xx,{status:e.status}),(0,b.jsx)(Ef,{className:`size-4 text-muted-foreground/30 group-hover:text-foreground group-hover:translate-x-0.5 transition-all shrink-0 hidden sm:block`})]})]},e.id)})}):(0,b.jsx)(`div`,{className:`py-8 text-center`,children:(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n})})}function Qx({findings:e,selected:t,onSelect:n}){return(0,b.jsx)(`div`,{className:`chain`,children:Tx.map(r=>{let i=e.filter(e=>e.stage===r.n),a=Px(i);return(0,b.jsxs)(`button`,{className:`stagenode`,type:`button`,"aria-pressed":r.n===t,onClick:()=>n(r.n),children:[(0,b.jsx)(`div`,{className:`top`,style:{background:`var(${r.v})`}}),a?(0,b.jsx)(`span`,{className:`worst`,style:{background:`var(${jx[a]})`}}):null,(0,b.jsxs)(`div`,{className:`sn`,children:[`STAGE `,r.n]}),(0,b.jsx)(`div`,{className:`st`,children:r.name}),(0,b.jsxs)(`div`,{className:`sc`,style:{color:`var(${r.v})`},children:[i.length,(0,b.jsxs)(`small`,{children:[`finding`,i.length===1?``:`s`]})]})]},r.n)})})}function $x({findings:e,onSelectStage:t}){return(0,b.jsx)(`div`,{style:{overflowX:`auto`},children:(0,b.jsxs)(`table`,{className:`matrix`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`rh`}),Tx.map(e=>(0,b.jsxs)(`th`,{children:[(0,b.jsx)(`span`,{className:`flex flex-wrap gap-4 text-xs font-medium`,children:(0,b.jsx)(`i`,{className:`mcap`,style:{background:`var(${e.v})`}})}),(0,b.jsx)(`br`,{}),e.n]},e.n))]})}),(0,b.jsx)(`tbody`,{children:Ox.map((n,r)=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`rh`,children:n}),Tx.map(i=>{let a=e.filter(e=>e.pillar===r&&e.stage===i.n),o=Px(a);return o?(0,b.jsx)(`td`,{className:`has`,style:{background:`var(${jx[o]})`,cursor:`pointer`},title:`${a.length} open at ${n} · stage ${i.n}`,onClick:()=>t(i.n),children:a.length},i.n):(0,b.jsx)(`td`,{children:`·`},i.n)})]},n))})]})})}function eS({items:e}){return(0,b.jsx)(`div`,{className:`my-3.5 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:e.map(e=>(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`k`,children:e.k}),(0,b.jsx)(`div`,{className:e.mono?`v mono`:`v`,children:e.v})]},e.k))})}function tS({title:e,children:t}){return(0,b.jsxs)(`div`,{className:`border-[var(--hair)] mt-4 border-t pt-3.5 [&>h3]:text-muted-foreground [&>h3]:mb-2 [&>h3]:text-[11px] [&>h3]:font-semibold [&>h3]:tracking-[0.1em] [&>h3]:uppercase`,children:[(0,b.jsx)(`h3`,{children:e}),t]})}function nS({title:e,detail:t,verdict:n}){return(0,b.jsxs)(`div`,{className:`evi`,children:[(0,b.jsxs)(`svg`,{className:`ei`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,b.jsx)(`path`,{d:`M14 2v6h6`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`et`,children:e}),(0,b.jsx)(`div`,{className:`ed`,children:t})]}),(0,b.jsx)(`span`,{className:`verdict`,children:n})]})}var rS=v(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`,critical:`border-[color-mix(in_srgb,var(--crit)_35%,transparent)] bg-[var(--crit-bg)] text-[var(--crit)]`,high:`border-[color-mix(in_srgb,var(--high)_35%,transparent)] bg-[var(--high-bg)] text-[var(--high)]`,medium:`border-[color-mix(in_srgb,var(--med)_35%,transparent)] bg-[var(--med-bg)] text-[var(--med)]`,low:`border-[color-mix(in_srgb,var(--low)_35%,transparent)] bg-[var(--low-bg)] text-[var(--low)]`,success:`border-[color-mix(in_srgb,var(--good)_35%,transparent)] bg-[var(--good-bg)] text-[var(--good)]`,info:`bg-[var(--info-bg)] text-[var(--info)]`}},defaultVariants:{variant:`default`}}),iS={critical:`critical`,failed:`critical`,blocked:`critical`,R2:`critical`,high:`high`,awaiting_approval:`high`,cancel_requested:`high`,R1:`high`,medium:`medium`,queued:`medium`,low:`low`,running:`low`,R0:`low`,succeeded:`success`,completed:`success`,confirmed:`success`,ok:`success`,verified:`success`,remediated:`success`,info:`info`,informational:`info`};function aS(e){return e?iS[e]??`secondary`:`secondary`}function oS({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?s:`span`;return(0,b.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:a(rS({variant:t}),e),...r})}function sS(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var cS=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lS=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uS={};function dS(e,t){return((t||uS).jsx?lS:cS).test(e)}var fS=/[ \t\n\f\r]/g;function pS(e){return typeof e==`object`?e.type===`text`&&mS(e.value):mS(e)}function mS(e){return e.replace(fS,``)===``}var hS=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};hS.prototype.normal={},hS.prototype.property={},hS.prototype.space=void 0;function gS(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new hS(n,r,t)}function _S(e){return e.toLowerCase()}var vS=class{constructor(e,t){this.attribute=t,this.property=e}};vS.prototype.attribute=``,vS.prototype.booleanish=!1,vS.prototype.boolean=!1,vS.prototype.commaOrSpaceSeparated=!1,vS.prototype.commaSeparated=!1,vS.prototype.defined=!1,vS.prototype.mustUseProperty=!1,vS.prototype.number=!1,vS.prototype.overloadedBoolean=!1,vS.prototype.property=``,vS.prototype.spaceSeparated=!1,vS.prototype.space=void 0;var yS=e({boolean:()=>xS,booleanish:()=>SS,commaOrSpaceSeparated:()=>ES,commaSeparated:()=>TS,number:()=>K,overloadedBoolean:()=>CS,spaceSeparated:()=>wS}),bS=0,xS=DS(),SS=DS(),CS=DS(),K=DS(),wS=DS(),TS=DS(),ES=DS();function DS(){return 2**++bS}var OS=Object.keys(yS),kS=class extends vS{constructor(e,t,n,r){let i=-1;if(super(e,t),AS(this,`space`,r),typeof n==`number`)for(;++i<OS.length;){let e=OS[i];AS(this,OS[i],(n&yS[e])===yS[e])}}};kS.prototype.defined=!0;function AS(e,t,n){n&&(e[t]=n)}function jS(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new kS(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[_S(r)]=r,n[_S(a.attribute)]=r}return new hS(t,n,e.space)}var MS=jS({properties:{ariaActiveDescendant:null,ariaAtomic:SS,ariaAutoComplete:null,ariaBusy:SS,ariaChecked:SS,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:wS,ariaCurrent:null,ariaDescribedBy:wS,ariaDetails:null,ariaDisabled:SS,ariaDropEffect:wS,ariaErrorMessage:null,ariaExpanded:SS,ariaFlowTo:wS,ariaGrabbed:SS,ariaHasPopup:null,ariaHidden:SS,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wS,ariaLevel:K,ariaLive:null,ariaModal:SS,ariaMultiLine:SS,ariaMultiSelectable:SS,ariaOrientation:null,ariaOwns:wS,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:SS,ariaReadOnly:SS,ariaRelevant:null,ariaRequired:SS,ariaRoleDescription:wS,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:SS,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function NS(e,t){return t in e?e[t]:t}function PS(e,t){return NS(e,t.toLowerCase())}var FS=jS({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:TS,acceptCharset:wS,accessKey:wS,action:null,allow:null,allowFullScreen:xS,allowPaymentRequest:xS,allowUserMedia:xS,alpha:xS,alt:null,as:null,async:xS,autoCapitalize:null,autoComplete:wS,autoFocus:xS,autoPlay:xS,blocking:wS,capture:null,charSet:null,checked:xS,cite:null,className:wS,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:SS,controls:xS,controlsList:wS,coords:K|TS,crossOrigin:null,data:null,dateTime:null,decoding:null,default:xS,defer:xS,dir:null,dirName:null,disabled:xS,download:CS,draggable:SS,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:xS,formTarget:null,headers:wS,height:K,hidden:CS,high:K,href:null,hrefLang:null,htmlFor:wS,httpEquiv:wS,id:null,imageSizes:null,imageSrcSet:null,inert:xS,inputMode:null,integrity:null,is:null,isMap:xS,itemId:null,itemProp:wS,itemRef:wS,itemScope:xS,itemType:wS,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:xS,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:xS,muted:xS,name:null,nonce:null,noModule:xS,noValidate:xS,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:xS,optimum:K,pattern:null,ping:wS,placeholder:null,playsInline:xS,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:xS,referrerPolicy:null,rel:wS,required:xS,reversed:xS,rows:K,rowSpan:K,sandbox:wS,scope:null,scoped:xS,seamless:xS,selected:xS,shadowRootClonable:xS,shadowRootCustomElementRegistry:xS,shadowRootDelegatesFocus:xS,shadowRootMode:null,shadowRootSerializable:xS,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:SS,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:xS,useMap:null,value:SS,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wS,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:xS,declare:xS,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:xS,noHref:xS,noShade:xS,noWrap:xS,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:SS,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:xS,disablePictureInPicture:xS,disableRemotePlayback:xS,exportParts:TS,part:wS,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:PS}),IS=jS({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:ES,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:wS,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:xS,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:TS,g2:TS,glyphName:TS,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:ES,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wS,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ES,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ES,rev:ES,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ES,requiredFeatures:ES,requiredFonts:ES,requiredFormats:ES,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:ES,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ES,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ES,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:NS}),LS=jS({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),RS=jS({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:PS}),zS=jS({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),BS={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},VS=/[A-Z]/g,HS=/-[a-z]/g,US=/^data[-\w.:]+$/i;function WS(e,t){let n=_S(t),r=t,i=vS;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&US.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(HS,KS);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!HS.test(e)){let n=e.replace(VS,GS);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=kS}return new i(r,t)}function GS(e){return`-`+e.toLowerCase()}function KS(e){return e.charAt(1).toUpperCase()}var qS=gS([MS,FS,LS,RS,zS],`html`),JS=gS([MS,IS,LS,RS,zS],`svg`);function YS(e){return e.join(` `).trim()}var XS=r(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
61
+ `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),ZS=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(XS());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),QS=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),$S=r(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(ZS()),r=QS();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),eC=nC(`end`),tC=nC(`start`);function nC(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function rC(e){let t=tC(e),n=eC(e);if(t&&n)return{start:t,end:n}}function iC(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?oC(e.position):`start`in e||`end`in e?oC(e):`line`in e||`column`in e?aC(e):``}function aC(e){return sC(e&&e.line)+`:`+sC(e&&e.column)}function oC(e){return aC(e&&e.start)+`-`+aC(e&&e.end)}function sC(e){return e&&typeof e==`number`?e:1}var cC=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=iC(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};cC.prototype.file=``,cC.prototype.name=``,cC.prototype.reason=``,cC.prototype.message=``,cC.prototype.stack=``,cC.prototype.column=void 0,cC.prototype.line=void 0,cC.prototype.ancestors=void 0,cC.prototype.cause=void 0,cC.prototype.fatal=void 0,cC.prototype.place=void 0,cC.prototype.ruleId=void 0,cC.prototype.source=void 0;var lC=n($S(),1),uC={}.hasOwnProperty,dC=new Map,fC=/[A-Z]/g,pC=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),mC=new Set([`td`,`th`]),hC=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function gC(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=DC(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=EC(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?JS:qS,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=_C(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function _C(e,t,n){if(t.type===`element`)return vC(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return yC(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return xC(e,t,n);if(t.type===`mdxjsEsm`)return bC(e,t);if(t.type===`root`)return SC(e,t,n);if(t.type===`text`)return CC(e,t)}function vC(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=JS,e.schema=i),e.ancestors.push(t);let a=NC(e,t.tagName,!1),o=OC(e,t),s=AC(e,t);return pC.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!pS(e)})),wC(e,o,a,t),TC(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function yC(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}PC(e,t.position)}function bC(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);PC(e,t.position)}function xC(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=JS,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:NC(e,t.name,!0),o=kC(e,t),s=AC(e,t);return wC(e,o,a,t),TC(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function SC(e,t,n){let r={};return TC(r,AC(e,t)),e.create(t,e.Fragment,r,n)}function CC(e,t){return t.value}function wC(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function TC(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function EC(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function DC(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=tC(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function OC(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&uC.call(t.properties,i)){let a=jC(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&mC.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function kC(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else PC(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else PC(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function AC(e,t){let n=[],r=-1,i=e.passKeys?new Map:dC;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=_C(e,a,o);s!==void 0&&n.push(s)}return n}function jC(e,t,n){let r=WS(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?sS(n):YS(n)),r.property===`style`){let t=typeof n==`object`?n:MC(e,String(n));return e.stylePropertyNameCase===`css`&&(t=FC(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?BS[r.property]||r.property:r.attribute,n]}}function MC(e,t){try{return(0,lC.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new cC("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=hC+`#cannot-parse-style-attribute`,r}}function NC(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=dS(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=dS(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return uC.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);PC(e)}function PC(e,t){let n=new cC("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=hC+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function FC(e){let t={},n;for(n in e)uC.call(e,n)&&(t[IC(n)]=e[n]);return t}function IC(e){let t=e.replace(fC,LC);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function LC(e){return`-`+e.toLowerCase()}var RC={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},zC={};function BC(e,t){let n=t||zC;return VC(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function VC(e,t,n){if(UC(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return HC(e.children,t,n)}return Array.isArray(e)?HC(e,t,n):``}function HC(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=VC(e[i],t,n);return r.join(``)}function UC(e){return!!(e&&typeof e==`object`)}var WC=document.createElement(`i`);function GC(e){let t=`&`+e+`;`;WC.innerHTML=t;let n=WC.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function KC(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function qC(e,t){return e.length>0?(KC(e,e.length,0,t),e):t}var JC={}.hasOwnProperty;function YC(e){let t={},n=-1;for(;++n<e.length;)XC(t,e[n]);return t}function XC(e,t){let n;for(n in t){let r=(JC.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){JC.call(r,a)||(r[a]=[]);let e=i[a];ZC(r[a],Array.isArray(e)?e:e?[e]:[])}}}function ZC(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);KC(e,0,0,r)}function QC(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function $C(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var ew=dw(/[A-Za-z]/),tw=dw(/[\dA-Za-z]/),nw=dw(/[#-'*+\--9=?A-Z^-~]/);function rw(e){return e!==null&&(e<32||e===127)}var iw=dw(/\d/),aw=dw(/[\dA-Fa-f]/),ow=dw(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function sw(e){return e!==null&&(e<0||e===32)}function cw(e){return e===-2||e===-1||e===32}var lw=dw(/\p{P}|\p{S}/u),uw=dw(/\s/);function dw(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function fw(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&tw(e.charCodeAt(n+1))&&tw(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function pw(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return cw(r)?(e.enter(n),s(r)):t(r)}function s(r){return cw(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var mw={tokenize:hw};function hw(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),pw(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var gw={tokenize:vw},_w={tokenize:yw};function vw(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return KC(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(_w,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(_w,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;KC(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function yw(e,t,n){return pw(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function bw(e){if(e===null||sw(e)||uw(e))return 1;if(lw(e))return 2}function xw(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Sw={name:`attention`,resolveAll:Cw,tokenize:ww};function Cw(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Tw(d,-c),Tw(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=qC(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=qC(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=qC(l,xw(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=qC(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=qC(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,KC(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function ww(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=bw(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=bw(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Tw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ew={name:`autolink`,tokenize:Dw};function Dw(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return ew(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||tw(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||tw(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||rw(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):nw(t)?(e.consume(t),l):n(t)}function u(e){return tw(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||tw(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Ow={partial:!0,tokenize:kw};function kw(e,t,n){return r;function r(t){return cw(t)?pw(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var Aw={continuation:{tokenize:Mw},exit:Nw,name:`blockQuote`,tokenize:jw};function jw(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return cw(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Mw(e,t,n){let r=this;return i;function i(t){return cw(t)?pw(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Aw,t,n)(r)}}function Nw(e){e.exit(`blockQuote`)}var Pw={name:`characterEscape`,tokenize:Fw};function Fw(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return ow(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Iw={name:`characterReference`,tokenize:Lw};function Lw(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=tw,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=aw,u):(e.enter(`characterReferenceValue`),a=7,o=iw,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===tw&&!GC(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Rw={partial:!0,tokenize:Vw},zw={concrete:!0,name:`codeFenced`,tokenize:Bw};function Bw(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),cw(t)?pw(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Rw,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):cw(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),pw(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&cw(t)?pw(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(Rw,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),cw(t)?pw(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),cw(t)?pw(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Vw(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Hw={name:`codeIndented`,tokenize:Ww},Uw={partial:!0,tokenize:Gw};function Ww(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),pw(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(Uw,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Gw(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):pw(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var Kw={name:`codeText`,previous:Jw,resolve:qw,tokenize:Yw};function qw(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Jw(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Yw(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Xw=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Zw(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Zw(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Zw(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Zw(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Zw(this.left,t.reverse())}}}};function Zw(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Qw(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Xw(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,$w(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return KC(e,0,1/0,u.slice(0)),!l}function $w(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var eT={resolve:nT,tokenize:rT},tT={partial:!0,tokenize:iT};function nT(e){return Qw(e),e}function rT(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(tT,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function iT(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),pw(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function aT(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||rw(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||sw(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||rw(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function oT(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!cw(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function sT(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),pw(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function cT(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):cw(i)?pw(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var lT={name:`definition`,tokenize:dT},uT={partial:!0,tokenize:fT};function dT(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return oT.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=$C(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return sw(t)?cT(e,l)(t):l(t)}function l(t){return aT(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(uT,d,d)(t)}function d(t){return cw(t)?pw(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function fT(e,t,n){return r;function r(t){return sw(t)?cT(e,i)(t):n(t)}function i(t){return sT(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return cw(t)?pw(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var pT={name:`hardBreakEscape`,tokenize:mT};function mT(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var hT={name:`headingAtx`,resolve:gT,tokenize:_T};function gT(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},KC(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function _T(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||sw(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):cw(n)?pw(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||sw(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var vT=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),yT=[`pre`,`script`,`style`,`textarea`],bT={concrete:!0,name:`htmlFlow`,resolveTo:CT,tokenize:wT},xT={partial:!0,tokenize:ET},ST={partial:!0,tokenize:TT};function CT(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function wT(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ne):ew(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):ew(a)?(e.consume(a),i=4,r.interrupt?t:ne):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ne):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return ew(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||sw(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&yT.includes(l)?(i=1,r.interrupt?t(s):O(s)):vT.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||tw(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return cw(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||ew(t)?(e.consume(t),b):cw(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||tw(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):cw(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):cw(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||sw(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||cw(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):cw(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),re):t===63&&i===3?(e.consume(t),ne):t===93&&i===5?(e.consume(t),te):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(xT,ie,k)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(ST,A,ie)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),ne):O(t)}function N(t){return t===47?(e.consume(t),o=``,ee):O(t)}function ee(t){if(t===62){let n=o.toLowerCase();return yT.includes(n)?(e.consume(t),re):O(t)}return ew(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ee):O(t)}function te(t){return t===93?(e.consume(t),ne):O(t)}function ne(t){return t===62?(e.consume(t),re):t===45&&i===2?(e.consume(t),ne):O(t)}function re(t){return t===null||q(t)?(e.exit(`htmlFlowData`),ie(t)):(e.consume(t),re)}function ie(n){return e.exit(`htmlFlow`),t(n)}}function TT(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function ET(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Ow,t,n)}}var DT={name:`htmlText`,tokenize:OT};function OT(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):ew(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):ew(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):q(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return ew(t)?(e.consume(t),S):n(t)}function S(t){return t===45||tw(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,N(t)):cw(t)?(e.consume(t),C):M(t)}function w(t){return t===45||tw(t)?(e.consume(t),w):t===47||t===62||sw(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||ew(t)?(e.consume(t),E):q(t)?(o=T,N(t)):cw(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||tw(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,N(t)):cw(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):q(t)?(o=O,N(t)):cw(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):q(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||sw(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||sw(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return cw(t)?pw(e,te,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):te(t)}function te(t){return e.enter(`htmlTextData`),o(t)}}var kT={name:`labelEnd`,resolveAll:NT,resolveTo:PT,tokenize:FT},AT={tokenize:IT},jT={tokenize:LT},MT={tokenize:RT};function NT(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&KC(e,0,e.length,n),e}function PT(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=qC(s,e.slice(a+1,a+r+3)),s=qC(s,[[`enter`,u,t]]),s=qC(s,xw(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=qC(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=qC(s,e.slice(o+1)),s=qC(s,[[`exit`,c,t]]),KC(e,a,e.length,s),e}function FT(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes($C(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(AT,u,o?u:d)(t):t===91?e.attempt(jT,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(MT,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function IT(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return sw(t)?cT(e,a)(t):a(t)}function a(t){return t===41?u(t):aT(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return sw(t)?cT(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?sT(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return sw(t)?cT(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function LT(e,t,n){let r=this;return i;function i(t){return oT.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes($C(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function RT(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var zT={name:`labelStartImage`,resolveAll:kT.resolveAll,tokenize:BT};function BT(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var VT={name:`labelStartLink`,resolveAll:kT.resolveAll,tokenize:HT};function HT(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var UT={name:`lineEnding`,tokenize:WT};function WT(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),pw(e,t,`linePrefix`)}}var GT={name:`thematicBreak`,tokenize:KT};function KT(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),cw(t)?pw(e,s,`whitespace`)(t):s(t))}}var qT={continuation:{tokenize:ZT},exit:$T,name:`list`,tokenize:XT},JT={partial:!0,tokenize:eE},YT={partial:!0,tokenize:QT};function XT(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:iw(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(GT,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return iw(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Ow,r.interrupt?n:u,e.attempt(JT,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return cw(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function ZT(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Ow,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,pw(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!cw(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(YT,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,pw(e,e.attempt(qT,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function QT(e,t,n){let r=this;return pw(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function $T(e){e.exit(this.containerState.type)}function eE(e,t,n){let r=this;return pw(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!cw(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var tE={name:`setextUnderline`,resolveTo:nE,tokenize:rE};function nE(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function rE(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),cw(t)?pw(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var iE={tokenize:aE};function aE(e){let t=this,n=e.attempt(Ow,r,e.attempt(this.parser.constructs.flowInitial,i,pw(e,e.attempt(this.parser.constructs.flow,i,e.attempt(eT,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var oE={resolveAll:uE()},sE=lE(`string`),cE=lE(`text`);function lE(e){return{resolveAll:uE(e===`text`?dE:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function uE(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function dE(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var fE=e({attentionMarkers:()=>bE,contentInitial:()=>mE,disable:()=>xE,document:()=>pE,flow:()=>gE,flowInitial:()=>hE,insideSpan:()=>yE,string:()=>_E,text:()=>vE}),pE={42:qT,43:qT,45:qT,48:qT,49:qT,50:qT,51:qT,52:qT,53:qT,54:qT,55:qT,56:qT,57:qT,62:Aw},mE={91:lT},hE={[-2]:Hw,[-1]:Hw,32:Hw},gE={35:hT,42:GT,45:[tE,GT],60:bT,61:tE,95:GT,96:zw,126:zw},_E={38:Iw,92:Pw},vE={[-5]:UT,[-4]:UT,[-3]:UT,33:zT,38:Iw,42:Sw,60:[Ew,DT],91:VT,92:[pT,Pw],93:kT,95:Sw,96:Kw},yE={null:[Sw,oE]},bE={null:[42,95]},xE={null:[]};function SE(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=qC(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=xw(a,l.events,l),l.events):[]}function f(e,t){return wE(p(e),t)}function p(e){return CE(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&KC(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function CE(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function wE(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
62
62
  `;break;case-3:o=`\r
63
- `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function mE(e){let t={constructs:RC([tE,...(e||{}).extensions||[]]),content:n(rw),defined:[],document:n(aw),flow:n(qT),lazy:{},string:n(XT),text:n(ZT)};return t;function n(e){return n;function n(n){return dE(t,e,n)}}}function hE(e){for(;!Vw(e););return e}var gE=/[\0\t\n\r]/g;function _E(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(gE.lastIndex=u,c=gE.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var vE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function yE(e){return e.replace(vE,bE)}function bE(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return VC(n.slice(t?2:1),t?16:10)}return PC(n)||e}var xE={}.hasOwnProperty;function SE(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),CE(n)(hE(mE(n).document().write(_E()(e,t,!0))))}function CE(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(be),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ge),blockQuote:a(P),characterEscape:T,characterReference:T,codeFenced:a(fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(fe,o),codeText:a(pe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(he),hardBreakEscape:a(_e),hardBreakTrailing:a(_e),htmlFlow:a(ve,o),htmlFlowData:T,htmlText:a(ve,o),htmlTextData:T,image:a(ye),label:o,link:a(be),listItem:a(Se),listItemValue:f,listOrdered:a(xe,d),listUnordered:a(xe),paragraph:a(Ce),reference:ae,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ge),strong:a(we),thematicBreak:a(Ee)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:te,labelText:ee,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:oe,resourceDestinationString:ne,resourceTitleString:re,resource:ie,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};TE(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];xE.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||DE).call(a,void 0,e[0])}for(r.position={start:wE(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:wE(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:wE(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||DE).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+qS({start:e.start,end:e.end})+`): it’s not open`);n.position.end=wE(e.end)}function u(){return kC(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=HC(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Te(),n.position={start:wE(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=wE(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=wE(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=yE(t),n.identifier=HC(t).toLowerCase()}function te(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ie(){this.data.inReference=void 0}function ae(){this.data.referenceType=`collapsed`}function oe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=HC(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function se(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=VC(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=PC(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=wE(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function P(){return{type:`blockquote`,children:[]}}function fe(){return{type:`code`,lang:null,meta:null,value:``}}function pe(){return{type:`inlineCode`,value:``}}function me(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function he(){return{type:`emphasis`,children:[]}}function ge(){return{type:`heading`,depth:0,children:[]}}function _e(){return{type:`break`}}function ve(){return{type:`html`,value:``}}function ye(){return{type:`image`,title:null,url:``,alt:null}}function be(){return{type:`link`,title:null,url:``,children:[]}}function xe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Se(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ce(){return{type:`paragraph`,children:[]}}function we(){return{type:`strong`,children:[]}}function Te(){return{type:`text`,value:``}}function Ee(){return{type:`thematicBreak`}}}function wE(e){return{line:e.line,column:e.column,offset:e.offset}}function TE(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?TE(e,r):EE(e,r)}}function EE(e,t){let n;for(n in t)if(xE.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function DE(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+qS({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+qS({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+qS({start:t.start,end:t.end})+`) is still open`)}function OE(e){let t=this;t.parser=n;function n(n){return SE(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function kE(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function AE(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
64
- `}]}function jE(e,t){let n=t.value?t.value+`
65
- `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function ME(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function NE(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PE(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=tw(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function FE(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function IE(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function LE(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function RE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return LE(e,t);let i={src:tw(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function zE(e,t){let n={src:tw(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function BE(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function VE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return LE(e,t);let i={href:tw(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function HE(e,t){let n={href:tw(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function UE(e,t,n){let r=e.all(t),i=n?WE(n):GE(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
63
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function TE(e){let t={constructs:YC([fE,...(e||{}).extensions||[]]),content:n(mw),defined:[],document:n(gw),flow:n(iE),lazy:{},string:n(sE),text:n(cE)};return t;function n(e){return n;function n(n){return SE(t,e,n)}}}function EE(e){for(;!Qw(e););return e}var DE=/[\0\t\n\r]/g;function OE(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(DE.lastIndex=u,c=DE.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var kE=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function AE(e){return e.replace(kE,jE)}function jE(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return QC(n.slice(t?2:1),t?16:10)}return GC(n)||e}var ME={}.hasOwnProperty;function NE(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),PE(n)(EE(TE(n).document().write(OE()(e,t,!0))))}function PE(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(be),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ge),blockQuote:a(P),characterEscape:T,characterReference:T,codeFenced:a(fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(fe,o),codeText:a(pe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(he),hardBreakEscape:a(_e),hardBreakTrailing:a(_e),htmlFlow:a(ve,o),htmlFlowData:T,htmlText:a(ve,o),htmlTextData:T,image:a(ye),label:o,link:a(be),listItem:a(Se),listItemValue:f,listOrdered:a(xe,d),listUnordered:a(xe),paragraph:a(Ce),reference:ae,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ge),strong:a(we),thematicBreak:a(Ee)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:te,labelText:ee,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:oe,resourceDestinationString:ne,resourceTitleString:re,resource:ie,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};IE(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];ME.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||RE).call(a,void 0,e[0])}for(r.position={start:FE(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:FE(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:FE(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||RE).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+iC({start:e.start,end:e.end})+`): it’s not open`);n.position.end=FE(e.end)}function u(){return BC(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=$C(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Te(),n.position={start:FE(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=FE(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=FE(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=AE(t),n.identifier=$C(t).toLowerCase()}function te(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ie(){this.data.inReference=void 0}function ae(){this.data.referenceType=`collapsed`}function oe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=$C(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function se(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=QC(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=GC(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=FE(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function P(){return{type:`blockquote`,children:[]}}function fe(){return{type:`code`,lang:null,meta:null,value:``}}function pe(){return{type:`inlineCode`,value:``}}function me(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function he(){return{type:`emphasis`,children:[]}}function ge(){return{type:`heading`,depth:0,children:[]}}function _e(){return{type:`break`}}function ve(){return{type:`html`,value:``}}function ye(){return{type:`image`,title:null,url:``,alt:null}}function be(){return{type:`link`,title:null,url:``,children:[]}}function xe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Se(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ce(){return{type:`paragraph`,children:[]}}function we(){return{type:`strong`,children:[]}}function Te(){return{type:`text`,value:``}}function Ee(){return{type:`thematicBreak`}}}function FE(e){return{line:e.line,column:e.column,offset:e.offset}}function IE(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?IE(e,r):LE(e,r)}}function LE(e,t){let n;for(n in t)if(ME.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function RE(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+iC({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+iC({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+iC({start:t.start,end:t.end})+`) is still open`)}function zE(e){let t=this;t.parser=n;function n(n){return NE(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function BE(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function VE(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
64
+ `}]}function HE(e,t){let n=t.value?t.value+`
65
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function UE(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WE(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GE(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=fw(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function KE(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qE(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function JE(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function YE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return JE(e,t);let i={src:fw(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function XE(e,t){let n={src:fw(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function ZE(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function QE(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return JE(e,t);let i={href:fw(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function $E(e,t){let n={href:fw(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function eD(e,t,n){let r=e.all(t),i=n?tD(n):nD(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
66
66
  `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
67
- `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function WE(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=GE(n[r])}return t}function GE(e){return e.spread??e.children.length>1}function KE(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function qE(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JE(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function YE(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XE(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=WS(t.children[1]),o=US(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function ZE(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function QE(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var $E=9,eD=32;function tD(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(nD(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(nD(t.slice(i),i>0,!1)),a.join(``)}function nD(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===$E||t===eD;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===$E||t===eD;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function rD(e,t){let n={type:`text`,value:tD(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function iD(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var aD={blockquote:kE,break:AE,code:jE,delete:ME,emphasis:NE,footnoteReference:PE,heading:FE,html:IE,imageReference:RE,image:zE,inlineCode:BE,linkReference:VE,link:HE,listItem:UE,list:KE,paragraph:qE,root:JE,strong:YE,table:XE,tableCell:QE,tableRow:ZE,text:rD,thematicBreak:iD,toml:oD,yaml:oD,definition:oD,footnoteDefinition:oD};function oD(){}var{defineProperty:sD}=Object,cD=typeof self==`object`?self:globalThis,lD=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new cD[e](t)},uD=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?sD(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof cD[e]==`function`?lD(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(lD(a,o),i)};return r},dD=e=>uD(new Map,e)(0),fD=``,{toString:pD}={},{keys:mD,is:hD}=Object,gD=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=pD.call(e).slice(8,-1);switch(n){case`Array`:return[1,fD];case`Object`:return[2,fD];case`Date`:return[3,fD];case`RegExp`:return[4,fD];case`Map`:return[5,fD];case`Set`:return[6,fD];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},_D=([e,t])=>e===0&&(t===`function`||t===`symbol`),vD=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=gD(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&hD(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of mD(o))(e||!_D(gD(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?fD:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(_D(gD(n))||_D(gD(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!_D(gD(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},yD=(e,{json:t,lossy:n}={})=>{let r=[];return vD(!(t||n),!!t,new Map,r)(e),r},bD=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?dD(yD(e,t)):structuredClone(e):(e,t)=>dD(yD(e,t));function xD(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function SD(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function CD(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||xD,r=e.options.footnoteBackLabel||SD,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=tw(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...bD(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
67
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function tD(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=nD(n[r])}return t}function nD(e){return e.spread??e.children.length>1}function rD(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function iD(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function aD(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function oD(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sD(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=tC(t.children[1]),o=eC(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function cD(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function lD(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var uD=9,dD=32;function fD(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(pD(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(pD(t.slice(i),i>0,!1)),a.join(``)}function pD(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===uD||t===dD;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===uD||t===dD;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function mD(e,t){let n={type:`text`,value:fD(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function hD(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var gD={blockquote:BE,break:VE,code:HE,delete:UE,emphasis:WE,footnoteReference:GE,heading:KE,html:qE,imageReference:YE,image:XE,inlineCode:ZE,linkReference:QE,link:$E,listItem:eD,list:rD,paragraph:iD,root:aD,strong:oD,table:sD,tableCell:lD,tableRow:cD,text:mD,thematicBreak:hD,toml:_D,yaml:_D,definition:_D,footnoteDefinition:_D};function _D(){}var{defineProperty:vD}=Object,yD=typeof self==`object`?self:globalThis,bD=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new yD[e](t)},xD=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?vD(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof yD[e]==`function`?bD(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(bD(a,o),i)};return r},SD=e=>xD(new Map,e)(0),CD=``,{toString:wD}={},{keys:TD,is:ED}=Object,DD=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=wD.call(e).slice(8,-1);switch(n){case`Array`:return[1,CD];case`Object`:return[2,CD];case`Date`:return[3,CD];case`RegExp`:return[4,CD];case`Map`:return[5,CD];case`Set`:return[6,CD];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},OD=([e,t])=>e===0&&(t===`function`||t===`symbol`),kD=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=DD(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&ED(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of TD(o))(e||!OD(DD(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?CD:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(OD(DD(n))||OD(DD(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!OD(DD(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},AD=(e,{json:t,lossy:n}={})=>{let r=[];return kD(!(t||n),!!t,new Map,r)(e),r},jD=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?SD(AD(e,t)):structuredClone(e):(e,t)=>SD(AD(e,t));function MD(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function ND(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function PD(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||MD,r=e.options.footnoteBackLabel||ND,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=fw(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...jD(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
68
68
  `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
69
- `}]}}var wD=(function(e){if(e==null)return kD;if(typeof e==`function`)return OD(e);if(typeof e==`object`)return Array.isArray(e)?TD(e):ED(e);if(typeof e==`string`)return DD(e);throw Error(`Expected function, string, or object as test`)});function TD(e){let t=[],n=-1;for(;++n<e.length;)t[n]=wD(e[n]);return OD(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ED(e){let t=e;return OD(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function DD(e){return OD(t);function t(t){return t&&t.type===e}}function OD(e){return t;function t(t,n,r){return!!(AD(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function kD(){return!0}function AD(e){return typeof e==`object`&&!!e&&`type`in e}function jD(e){return e}var MD=[];function ND(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=wD(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+jD(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=MD,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=PD(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function PD(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?MD:[e]}function FD(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),ND(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var ID={}.hasOwnProperty,LD={};function RD(e,t){let n=t||LD,r=new Map,i=new Map,a={all:s,applyData:BD,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...aD,...n.handlers},one:o,options:n,patch:zD,wrap:HD};return FD(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(ID.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=bD(n);return r.children=a.all(e),r}return bD(e)}return(a.options.unknownHandler||VD)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=UD(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=UD(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function zD(e,t){e.position&&(t.position=KS(e))}function BD(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,bD(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function VD(e,t){let n=t.data||{},r=`value`in t&&!(ID.call(n,`hProperties`)||ID.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function HD(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
69
+ `}]}}var FD=(function(e){if(e==null)return BD;if(typeof e==`function`)return zD(e);if(typeof e==`object`)return Array.isArray(e)?ID(e):LD(e);if(typeof e==`string`)return RD(e);throw Error(`Expected function, string, or object as test`)});function ID(e){let t=[],n=-1;for(;++n<e.length;)t[n]=FD(e[n]);return zD(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function LD(e){let t=e;return zD(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function RD(e){return zD(t);function t(t){return t&&t.type===e}}function zD(e){return t;function t(t,n,r){return!!(VD(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function BD(){return!0}function VD(e){return typeof e==`object`&&!!e&&`type`in e}function HD(e){return e}var UD=[];function WD(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=FD(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+HD(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=UD,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=GD(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function GD(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?UD:[e]}function KD(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),WD(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var qD={}.hasOwnProperty,JD={};function YD(e,t){let n=t||JD,r=new Map,i=new Map,a={all:s,applyData:ZD,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...gD,...n.handlers},one:o,options:n,patch:XD,wrap:$D};return KD(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(qD.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=jD(n);return r.children=a.all(e),r}return jD(e)}return(a.options.unknownHandler||QD)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=eO(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=eO(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function XD(e,t){e.position&&(t.position=rC(e))}function ZD(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,jD(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function QD(e,t){let n=t.data||{},r=`value`in t&&!(qD.call(n,`hProperties`)||qD.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function $D(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
70
70
  `});++r<e.length;)r&&n.push({type:`text`,value:`
71
71
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
72
- `}),n}function UD(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function WD(e,t){let n=RD(e,t),r=n.one(e,void 0),i=CD(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
73
- `},i)),a}function GD(e,t){return e&&`run`in e?async function(n,r){let i=WD(n,{file:r,...t});await e.run(i,r)}:function(n,r){return WD(n,{file:r,...e||t})}}function KD(e){if(e)throw e}var qD=r(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function JD(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function YD(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?XD(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function XD(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var ZD={basename:QD,dirname:$D,extname:eO,join:tO,sep:`/`};function QD(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);iO(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function $D(e){if(iO(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function eO(e){iO(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function tO(...e){let t=-1,n;for(;++t<e.length;)iO(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:nO(n)}function nO(e){iO(e);let t=e.codePointAt(0)===47,n=rO(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function rO(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function iO(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var aO={cwd:oO};function oO(){return`/`}function sO(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function cO(e){if(typeof e==`string`)e=new URL(e);else if(!sO(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return lO(e)}function lO(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var uO=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],dO=class{constructor(e){let t;t=e?sO(e)?{path:e}:typeof e==`string`||hO(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:aO.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<uO.length;){let e=uO[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)uO.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?ZD.basename(this.path):void 0}set basename(e){pO(e,`basename`),fO(e,`basename`),this.path=ZD.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?ZD.dirname(this.path):void 0}set dirname(e){mO(this.basename,`dirname`),this.path=ZD.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?ZD.extname(this.path):void 0}set extname(e){if(fO(e,`extname`),mO(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=ZD.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){sO(e)&&(e=cO(e)),pO(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?ZD.basename(this.path,this.extname):void 0}set stem(e){pO(e,`stem`),fO(e,`stem`),this.path=ZD.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new ZS(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function fO(e,t){if(e&&e.includes(ZD.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+ZD.sep+"`")}function pO(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function mO(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function hO(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var gO=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),_O=n(qD(),1),vO={}.hasOwnProperty,yO=new class e extends gO{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=YD()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,_O.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(SO(`data`,this.frozen),this.namespace[e]=t,this):vO.call(this.namespace,e)&&this.namespace[e]||void 0:e?(SO(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=TO(e),n=this.parser||this.Parser;return bO(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),bO(`process`,this.parser||this.Parser),xO(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=TO(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);DO(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),bO(`processSync`,this.parser||this.Parser),xO(`processSync`,this.compiler||this.Compiler),this.process(e,r),wO(`processSync`,`process`,t),n;function r(e,r){t=!0,KD(e),n=r}}run(e,t,n){CO(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=TO(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),wO(`runSync`,`run`,n),r;function i(e,t){KD(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=TO(t),r=this.compiler||this.Compiler;return xO(`stringify`,r),CO(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(SO(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,_O.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];JD(o)&&JD(r)&&(r=(0,_O.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function bO(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function xO(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function SO(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function CO(e){if(!JD(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function wO(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function TO(e){return EO(e)?e:new dO(e)}function EO(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function DO(e){return typeof e==`string`||OO(e)}function OO(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var kO=[],AO={allowDangerousHtml:!0},jO=/^(https?|ircs?|mailto|xmpp)$/i,MO=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function NO(e){let t=PO(e),n=FO(e);return IO(t.runSync(t.parse(n),n),e)}function PO(e){let t=e.rehypePlugins||kO,n=e.remarkPlugins||kO,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...AO}:AO;return yO().use(OE).use(n).use(GD,r).use(t)}function FO(e){let t=e.children||``,n=new dO;return typeof t==`string`?n.value=t:``+t,n}function IO(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||LO;for(let e of MO)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return FD(e,l),aC(e,{Fragment:b.Fragment,components:i,ignoreInvalidStyle:!0,jsx:b.jsx,jsxs:b.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in DC)if(Object.hasOwn(DC,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=DC[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function LO(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||jO.test(e.slice(0,t))?e:``}function RO(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function zO(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function BO(e,t,n){let r=wD((n||{}).ignore||[]),i=VO(t),a=-1;for(;++a<i.length;)ND(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function VO(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([HO(e[0]),UO(e[1])])}return t}function HO(e){return typeof e==`string`?new RegExp(zO(e),`g`):e}function UO(e){return typeof e==`function`?e:function(){return e}}var WO=`phrasing`,GO=[`autolink`,`link`,`image`,`label`];function KO(){return{transforms:[ek],enter:{literalAutolink:JO,literalAutolinkEmail:YO,literalAutolinkHttp:YO,literalAutolinkWww:YO},exit:{literalAutolink:$O,literalAutolinkEmail:QO,literalAutolinkHttp:XO,literalAutolinkWww:ZO}}}function qO(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:WO,notInConstruct:GO},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:WO,notInConstruct:GO},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:WO,notInConstruct:GO}]}}function JO(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function YO(e){this.config.enter.autolinkProtocol.call(this,e)}function XO(e){this.config.exit.autolinkProtocol.call(this,e)}function ZO(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function QO(e){this.config.exit.autolinkEmail.call(this,e)}function $O(e){this.exit(e)}function ek(e){BO(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,tk],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,nk]],{ignore:[`link`,`linkReference`]})}function tk(e,t,n,r,i){let a=``;if(!ak(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!rk(n)))return!1;let o=ik(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function nk(e,t,n,r){return!ak(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function rk(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ik(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=RO(e,`(`),a=RO(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function ak(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||$C(n)||QC(n))&&(!t||n!==47)}hk.peek=mk;function ok(){this.buffer()}function sk(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function ck(){this.buffer()}function lk(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function uk(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=HC(this.sliceSerialize(e)).toLowerCase(),n.label=t}function dk(e){this.exit(e)}function fk(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=HC(this.sliceSerialize(e)).toLowerCase(),n.label=t}function pk(e){this.exit(e)}function mk(){return`[`}function hk(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function gk(){return{enter:{gfmFootnoteCallString:ok,gfmFootnoteCall:sk,gfmFootnoteDefinitionLabelString:ck,gfmFootnoteDefinition:lk},exit:{gfmFootnoteCallString:uk,gfmFootnoteCall:dk,gfmFootnoteDefinitionLabelString:fk,gfmFootnoteDefinition:pk}}}function _k(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:hk},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
74
- `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?yk:vk))),s(),o}}function vk(e,t,n){return t===0?e:yk(e,t,n)}function yk(e,t,n){return(n?``:` `)+e}var bk=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Tk.peek=Ek;function xk(){return{canContainEols:[`delete`],enter:{strikethrough:Ck},exit:{strikethrough:wk}}}function Sk(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:bk}],handlers:{delete:Tk}}}function Ck(e){this.enter({type:`delete`,children:[]},e)}function wk(e){this.exit(e)}function Tk(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Ek(){return`~`}function Dk(e){return e.length}function Ok(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Dk,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=kk(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=Ak(r[d]);else{let e=Ak(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
75
- `)}function kk(e){return e==null?``:String(e)}function Ak(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function jk(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Mk);return i(),o}function Mk(e,t,n){return`>`+(n?``:` `)+e}function Nk(e,t){return Pk(e,t.inConstruct,!0)&&!Pk(e,t.notInConstruct,!1)}function Pk(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Fk(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
76
- `&&Nk(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
77
- `}function Ik(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Lk(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Rk(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function zk(e,t,n,r){let i=Rk(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(Lk(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Bk);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Ik(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
72
+ `}),n}function eO(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function tO(e,t){let n=YD(e,t),r=n.one(e,void 0),i=PD(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
73
+ `},i)),a}function nO(e,t){return e&&`run`in e?async function(n,r){let i=tO(n,{file:r,...t});await e.run(i,r)}:function(n,r){return tO(n,{file:r,...e||t})}}function rO(e){if(e)throw e}var iO=r(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function aO(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function oO(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?sO(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function sO(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var cO={basename:lO,dirname:uO,extname:dO,join:fO,sep:`/`};function lO(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);hO(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function uO(e){if(hO(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function dO(e){hO(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function fO(...e){let t=-1,n;for(;++t<e.length;)hO(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:pO(n)}function pO(e){hO(e);let t=e.codePointAt(0)===47,n=mO(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function mO(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function hO(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var gO={cwd:_O};function _O(){return`/`}function vO(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function yO(e){if(typeof e==`string`)e=new URL(e);else if(!vO(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return bO(e)}function bO(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var xO=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],SO=class{constructor(e){let t;t=e?vO(e)?{path:e}:typeof e==`string`||EO(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:gO.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<xO.length;){let e=xO[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)xO.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?cO.basename(this.path):void 0}set basename(e){wO(e,`basename`),CO(e,`basename`),this.path=cO.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?cO.dirname(this.path):void 0}set dirname(e){TO(this.basename,`dirname`),this.path=cO.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?cO.extname(this.path):void 0}set extname(e){if(CO(e,`extname`),TO(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=cO.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){vO(e)&&(e=yO(e)),wO(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?cO.basename(this.path,this.extname):void 0}set stem(e){wO(e,`stem`),CO(e,`stem`),this.path=cO.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new cC(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function CO(e,t){if(e&&e.includes(cO.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+cO.sep+"`")}function wO(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function TO(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function EO(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var DO=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),OO=n(iO(),1),kO={}.hasOwnProperty,AO=new class e extends DO{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=oO()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,OO.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(NO(`data`,this.frozen),this.namespace[e]=t,this):kO.call(this.namespace,e)&&this.namespace[e]||void 0:e?(NO(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=IO(e),n=this.parser||this.Parser;return jO(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),jO(`process`,this.parser||this.Parser),MO(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=IO(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);RO(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),jO(`processSync`,this.parser||this.Parser),MO(`processSync`,this.compiler||this.Compiler),this.process(e,r),FO(`processSync`,`process`,t),n;function r(e,r){t=!0,rO(e),n=r}}run(e,t,n){PO(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=IO(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),FO(`runSync`,`run`,n),r;function i(e,t){rO(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=IO(t),r=this.compiler||this.Compiler;return MO(`stringify`,r),PO(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(NO(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,OO.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];aO(o)&&aO(r)&&(r=(0,OO.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function jO(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function MO(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function NO(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function PO(e){if(!aO(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function FO(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function IO(e){return LO(e)?e:new SO(e)}function LO(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function RO(e){return typeof e==`string`||zO(e)}function zO(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var BO=[],VO={allowDangerousHtml:!0},HO=/^(https?|ircs?|mailto|xmpp)$/i,UO=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function WO(e){let t=GO(e),n=KO(e);return qO(t.runSync(t.parse(n),n),e)}function GO(e){let t=e.rehypePlugins||BO,n=e.remarkPlugins||BO,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...VO}:VO;return AO().use(zE).use(n).use(nO,r).use(t)}function KO(e){let t=e.children||``,n=new SO;return typeof t==`string`?n.value=t:``+t,n}function qO(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||JO;for(let e of UO)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return KD(e,l),gC(e,{Fragment:b.Fragment,components:i,ignoreInvalidStyle:!0,jsx:b.jsx,jsxs:b.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in RC)if(Object.hasOwn(RC,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=RC[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function JO(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||HO.test(e.slice(0,t))?e:``}function YO(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function XO(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function ZO(e,t,n){let r=FD((n||{}).ignore||[]),i=QO(t),a=-1;for(;++a<i.length;)WD(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function QO(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([$O(e[0]),ek(e[1])])}return t}function $O(e){return typeof e==`string`?new RegExp(XO(e),`g`):e}function ek(e){return typeof e==`function`?e:function(){return e}}var tk=`phrasing`,nk=[`autolink`,`link`,`image`,`label`];function rk(){return{transforms:[dk],enter:{literalAutolink:ak,literalAutolinkEmail:ok,literalAutolinkHttp:ok,literalAutolinkWww:ok},exit:{literalAutolink:uk,literalAutolinkEmail:lk,literalAutolinkHttp:sk,literalAutolinkWww:ck}}}function ik(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:tk,notInConstruct:nk},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:tk,notInConstruct:nk},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:tk,notInConstruct:nk}]}}function ak(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function ok(e){this.config.enter.autolinkProtocol.call(this,e)}function sk(e){this.config.exit.autolinkProtocol.call(this,e)}function ck(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function lk(e){this.config.exit.autolinkEmail.call(this,e)}function uk(e){this.exit(e)}function dk(e){ZO(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,fk],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,pk]],{ignore:[`link`,`linkReference`]})}function fk(e,t,n,r,i){let a=``;if(!gk(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!mk(n)))return!1;let o=hk(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function pk(e,t,n,r){return!gk(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function mk(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function hk(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=YO(e,`(`),a=YO(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function gk(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||uw(n)||lw(n))&&(!t||n!==47)}Ek.peek=Tk;function _k(){this.buffer()}function vk(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function yk(){this.buffer()}function bk(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function xk(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$C(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Sk(e){this.exit(e)}function Ck(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$C(this.sliceSerialize(e)).toLowerCase(),n.label=t}function wk(e){this.exit(e)}function Tk(){return`[`}function Ek(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Dk(){return{enter:{gfmFootnoteCallString:_k,gfmFootnoteCall:vk,gfmFootnoteDefinitionLabelString:yk,gfmFootnoteDefinition:bk},exit:{gfmFootnoteCallString:xk,gfmFootnoteCall:Sk,gfmFootnoteDefinitionLabelString:Ck,gfmFootnoteDefinition:wk}}}function Ok(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Ek},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
74
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Ak:kk))),s(),o}}function kk(e,t,n){return t===0?e:Ak(e,t,n)}function Ak(e,t,n){return(n?``:` `)+e}var jk=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Ik.peek=Lk;function Mk(){return{canContainEols:[`delete`],enter:{strikethrough:Pk},exit:{strikethrough:Fk}}}function Nk(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:jk}],handlers:{delete:Ik}}}function Pk(e){this.enter({type:`delete`,children:[]},e)}function Fk(e){this.exit(e)}function Ik(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Lk(){return`~`}function Rk(e){return e.length}function zk(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Rk,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=Bk(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=Vk(r[d]);else{let e=Vk(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
75
+ `)}function Bk(e){return e==null?``:String(e)}function Vk(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Hk(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Uk);return i(),o}function Uk(e,t,n){return`>`+(n?``:` `)+e}function Wk(e,t){return Gk(e,t.inConstruct,!0)&&!Gk(e,t.notInConstruct,!1)}function Gk(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Kk(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
76
+ `&&Wk(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
77
+ `}function qk(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Jk(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Yk(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Xk(e,t,n,r){let i=Yk(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(Jk(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Zk);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(qk(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
78
78
  `,encode:["`"],...s.current()})),t()}return u+=s.move(`
79
79
  `),a&&(u+=s.move(a+`
80
- `)),u+=s.move(c),l(),u}function Bk(e,t,n){return(n?``:` `)+e}function Vk(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Hk(e,t,n,r){let i=Vk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
81
- `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Uk(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Wk(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Gk(e,t,n){let r=lw(e),i=lw(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Kk.peek=qk;function Kk(e,t,n,r){let i=Uk(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Gk(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Wk(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Gk(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Wk(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function qk(e,t,n){return n.options.emphasis||`*`}function Jk(e,t){let n=!1;return FD(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&kC(e)&&(t.options.setext||n))}function Yk(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Jk(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
80
+ `)),u+=s.move(c),l(),u}function Zk(e,t,n){return(n?``:` `)+e}function Qk(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function $k(e,t,n,r){let i=Qk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
81
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function eA(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function tA(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function nA(e,t,n){let r=bw(e),i=bw(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}rA.peek=iA;function rA(e,t,n,r){let i=eA(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=nA(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=tA(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=nA(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+tA(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function iA(e,t,n){return n.options.emphasis||`*`}function aA(e,t){let n=!1;return KD(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&BC(e)&&(t.options.setext||n))}function oA(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(aA(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
82
82
  `,after:`
83
83
  `});return r(),t(),o+`
84
84
  `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
85
85
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
86
- `,...a.current()});return/^[\t ]/.test(l)&&(l=Wk(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Xk.peek=Zk;function Xk(e){return e.value||``}function Zk(){return`<`}Qk.peek=$k;function Qk(e,t,n,r){let i=Vk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function $k(){return`!`}eA.peek=tA;function eA(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function tA(){return`!`}nA.peek=rA;function nA(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function rA(){return"`"}function iA(e,t){let n=kC(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}aA.peek=oA;function aA(e,t,n,r){let i=Vk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(iA(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function oA(e,t,n){return iA(e,n)?`<`:`[`}sA.peek=cA;function sA(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function cA(){return`[`}function lA(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function uA(e){let t=lA(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function dA(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function fA(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function pA(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?dA(n):lA(n),s=e.ordered?o===`.`?`)`:`.`:uA(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),fA(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function mA(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function hA(e,t,n,r){let i=mA(n),a=n.bulletCurrent||lA(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function gA(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var _A=wD([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function vA(e,t,n,r){return(e.children.some(function(e){return _A(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function yA(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}bA.peek=xA;function bA(e,t,n,r){let i=yA(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Gk(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Wk(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Gk(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Wk(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function xA(e,t,n){return n.options.strong||`*`}function SA(e,t,n,r){return n.safe(e.value,r)}function CA(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function wA(e,t,n){let r=(fA(n)+(n.options.ruleSpaces?` `:``)).repeat(CA(n));return n.options.ruleSpaces?r.slice(0,-1):r}var TA={blockquote:jk,break:Fk,code:zk,definition:Hk,emphasis:Kk,hardBreak:Fk,heading:Yk,html:Xk,image:Qk,imageReference:eA,inlineCode:nA,link:aA,linkReference:sA,list:pA,listItem:hA,paragraph:gA,root:vA,strong:bA,text:SA,thematicBreak:wA};function EA(){return{enter:{table:DA,tableData:jA,tableHeader:jA,tableRow:kA},exit:{codeText:MA,table:OA,tableData:AA,tableHeader:AA,tableRow:AA}}}function DA(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function OA(e){this.exit(e),this.data.inTable=void 0}function kA(e){this.enter({type:`tableRow`,children:[]},e)}function AA(e){this.exit(e)}function jA(e){this.enter({type:`tableCell`,children:[]},e)}function MA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,NA));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function NA(e,t){return t===`|`?t:e}function PA(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
86
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=tA(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}sA.peek=cA;function sA(e){return e.value||``}function cA(){return`<`}lA.peek=uA;function lA(e,t,n,r){let i=Qk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function uA(){return`!`}dA.peek=fA;function dA(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function fA(){return`!`}pA.peek=mA;function pA(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function mA(){return"`"}function hA(e,t){let n=BC(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}gA.peek=_A;function gA(e,t,n,r){let i=Qk(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(hA(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function _A(e,t,n){return hA(e,n)?`<`:`[`}vA.peek=yA;function vA(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function yA(){return`[`}function bA(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function xA(e){let t=bA(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function SA(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function CA(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function wA(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?SA(n):bA(n),s=e.ordered?o===`.`?`)`:`.`:xA(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),CA(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function TA(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function EA(e,t,n,r){let i=TA(n),a=n.bulletCurrent||bA(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function DA(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var OA=FD([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function kA(e,t,n,r){return(e.children.some(function(e){return OA(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function AA(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}jA.peek=MA;function jA(e,t,n,r){let i=AA(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=nA(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=tA(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=nA(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+tA(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function MA(e,t,n){return n.options.strong||`*`}function NA(e,t,n,r){return n.safe(e.value,r)}function PA(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function FA(e,t,n){let r=(CA(n)+(n.options.ruleSpaces?` `:``)).repeat(PA(n));return n.options.ruleSpaces?r.slice(0,-1):r}var IA={blockquote:Hk,break:Kk,code:Xk,definition:$k,emphasis:rA,hardBreak:Kk,heading:oA,html:sA,image:lA,imageReference:dA,inlineCode:pA,link:gA,linkReference:vA,list:wA,listItem:EA,paragraph:DA,root:kA,strong:jA,text:NA,thematicBreak:FA};function LA(){return{enter:{table:RA,tableData:HA,tableHeader:HA,tableRow:BA},exit:{codeText:UA,table:zA,tableData:VA,tableHeader:VA,tableRow:VA}}}function RA(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function zA(e){this.exit(e),this.data.inTable=void 0}function BA(e){this.enter({type:`tableRow`,children:[]},e)}function VA(e){this.exit(e)}function HA(e){this.enter({type:`tableCell`,children:[]},e)}function UA(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,WA));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function WA(e,t){return t===`|`?t:e}function GA(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
87
87
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
88
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Ok(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=TA.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function FA(){return{exit:{taskListCheckValueChecked:LA,taskListCheckValueUnchecked:LA,paragraph:RA}}}function IA(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:zA}}}function LA(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function RA(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function zA(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=TA.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function BA(){return[KO(),gk(),xk(),EA(),FA()]}function VA(e){return{extensions:[qO(),_k(e),Sk(),PA(e),IA()]}}var HA={tokenize:nj,partial:!0},UA={tokenize:rj,partial:!0},WA={tokenize:ij,partial:!0},GA={tokenize:aj,partial:!0},KA={tokenize:oj,partial:!0},qA={name:`wwwAutolink`,tokenize:ej,previous:sj},JA={name:`protocolAutolink`,tokenize:tj,previous:cj},YA={name:`emailAutolink`,tokenize:$A,previous:lj},XA={};function ZA(){return{text:XA}}for(var QA=48;QA<123;)XA[QA]=YA,QA++,QA===58?QA=65:QA===91&&(QA=97);XA[43]=YA,XA[45]=YA,XA[46]=YA,XA[95]=YA,XA[72]=[YA,JA],XA[104]=[YA,JA],XA[87]=[YA,qA],XA[119]=[YA,qA];function $A(e,t,n){let r=this,i,a;return o;function o(t){return!uj(t)||!lj.call(r,r.previous)||dj(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return uj(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(KA,u,l)(t):t===45||t===95||WC(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&UC(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function ej(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!sj.call(r,r.previous)||dj(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(HA,e.attempt(UA,e.attempt(WA,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function tj(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&cj.call(r,r.previous)&&!dj(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(UC(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||KC(t)||XC(t)||$C(t)||QC(t)?n(t):e.attempt(UA,e.attempt(WA,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function nj(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function rj(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(GA,c,s)(t):t===null||XC(t)||$C(t)||t!==45&&QC(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function ij(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(GA,t,a)(o):o===null||XC(o)||$C(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function aj(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||XC(o)||$C(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||XC(e)||$C(e)?t(e):r(e)}function a(e){return UC(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):UC(t)?(e.consume(t),o):n(t)}}function oj(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return WC(e)?n(e):t(e)}}function sj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||XC(e)}function cj(e){return!UC(e)}function lj(e){return!(e===47||uj(e))}function uj(e){return e===43||e===45||e===46||e===95||WC(e)}function dj(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var fj={tokenize:bj,partial:!0};function pj(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:_j,continuation:{tokenize:vj},exit:yj}},text:{91:{name:`gfmFootnoteCall`,tokenize:gj},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:mj,resolveTo:hj}}}}function mj(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=HC(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function hj(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function gj(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||XC(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(HC(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return XC(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function _j(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||XC(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=HC(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return XC(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),nw(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function vj(e,t,n){return e.check(_w,t,e.attempt(fj,t,n))}function yj(e){e.exit(`gfmFootnoteDefinition`)}function bj(e,t,n){let r=this;return nw(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function xj(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&FC(o,o.length,0,uw(s,e.slice(r+1,n),t)),FC(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),FC(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=lw(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=lw(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Sj=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Cj(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Cj(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function wj(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Tj(){return{flow:{null:{name:`table`,tokenize:Ej,resolveAll:Dj}}}}function Ej(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):ZC(t)?nw(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||XC(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,ZC(t)?nw(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return ZC(t)?nw(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return ZC(t)?nw(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):ZC(n)?nw(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||XC(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Dj(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Sj;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(kj(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Oj(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Oj(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Oj(f,t,o,i,n,d)):(o[0]=o[1],d=Oj(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&kj(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=wj(t.events,n))}return e}function Oj(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Aj(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Aj(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Aj(t.events,n[2]),a=Aj(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Aj(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function kj(e,t,n,r,i){let a=[],o=Aj(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Aj(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var jj={name:`tasklistCheck`,tokenize:Nj};function Mj(){return{text:{91:jj}}}function Nj(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return XC(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):ZC(r)?e.check({tokenize:Pj},t,n)(r):n(r)}}function Pj(e,t,n){return nw(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Fj(e){return RC([ZA(),pj(),xj(e),Tj(),Mj()])}var Ij={};function Lj(e){let t=this,n=e||Ij,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Fj(n)),a.push(BA()),o.push(VA(n))}var Rj={a:({children:e,...t})=>(0,b.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer`,className:`text-primary underline underline-offset-2`,children:e}),code:({className:e,children:t,...n})=>/language-/.test(e??``)?(0,b.jsx)(`code`,{...n,className:`block overflow-auto rounded-md border bg-[var(--plane)] p-3 font-mono text-xs whitespace-pre-wrap`,children:t}):(0,b.jsx)(`code`,{...n,className:`rounded-sm bg-[var(--plane)] px-1 py-0.5 font-mono text-[0.85em]`,children:t}),pre:({children:e,...t})=>(0,b.jsx)(`pre`,{...t,className:`my-1 overflow-auto`,children:e}),blockquote:({children:e,...t})=>(0,b.jsx)(`blockquote`,{...t,className:`border-l-2 border-border pl-3 text-muted-foreground`,children:e}),table:({children:e,...t})=>(0,b.jsx)(`div`,{className:`overflow-auto`,children:(0,b.jsx)(`table`,{...t,className:`w-full text-xs`,children:e})})};function zj({children:e,className:t}){return(0,b.jsx)(`div`,{className:a(`md-body grid gap-2 text-sm leading-relaxed [&_h1]:mt-1 [&_h2]:mt-2 [&_h3]:mt-1`,t),children:(0,b.jsx)(NO,{remarkPlugins:[Lj],components:Rj,children:e})})}var Bj={clean:`success`,informational:`neutral`,actionable:`warning`,critical:`critical`},Vj={critical:`critical`,high:`error`,medium:`warning`,low:`neutral`,informational:`neutral`};function Hj(){let e=Bd(),t=tf({queryKey:[`runs`],queryFn:()=>_x.runs()}),n=t.data?.runs??[],[r,i]=(0,y.useState)(null),a=tf({queryKey:[`report-versions`,r],queryFn:()=>_x.reportVersions(r),enabled:!!r}).data?.items??[],[s,c]=(0,y.useState)(null);(0,y.useEffect)(()=>{n.length>0&&!n.some(e=>e.id===r)&&i(n[0].id)},[n,r]),(0,y.useEffect)(()=>{if(a.length===0){c(null);return}a.some(e=>e.version===s)||c(a[0].version)},[r,a,s]);let l=tf({queryKey:[`report-version`,r,s],queryFn:()=>_x.reportVersion(r,s),enabled:!!r&&s!==null}),u=l.data?.record,d=l.data?.renditions.find(e=>e.ext===`md`)?.url??null,f=tf({queryKey:[`report-md`,r,s],queryFn:async()=>{let e=await fetch(d,{credentials:`same-origin`});if(!e.ok)throw Error(`Rendition fetch failed: ${e.status}`);return e.text()},enabled:d!==null}),[p,m]=(0,y.useState)(!1),[g,_]=(0,y.useState)(null),v=()=>{e.invalidateQueries({queryKey:[`report-versions`,r]}),e.invalidateQueries({queryKey:[`report-version`,r]}),e.invalidateQueries({queryKey:[`report-md`,r]})},x=nf({mutationFn:()=>_x.renderReportRenditions(r,s),onSuccess:()=>{m(!1),v()}}),S=nf({mutationFn:()=>_x.publishEditedMarkdown(r,s,g),onSuccess:e=>{_(null),m(!1),c(e.version),v()}});return t.isLoading?(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsx)(Uj,{}),(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading hosted runs…`})})]}):n.length===0?(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsx)(Uj,{}),(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`No hosted runs yet. Launch an assessment and its report will appear here on completion.`})})]}):(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsx)(Uj,{}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`mb-0`,children:`Generated report`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`The structured record is read-only; edits create new auditable versions.`})]}),(0,b.jsxs)(`div`,{className:`bg-card flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border p-3`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Run`}),(0,b.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:r??``,onChange:e=>{i(e.target.value),c(null)},children:n.map(e=>(0,b.jsxs)(`option`,{value:e.id,children:[e.title,` — `,Gj(e.status)]},e.id))})]}),a.length>0?(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Version`}),a.map(e=>(0,b.jsxs)(o,{variant:e.version===s?`secondary`:`outline`,size:`sm`,className:`aria-pressed:border-primary`,"aria-pressed":e.version===s,onClick:()=>{c(e.version),m(!1)},children:[`v`,e.version,` · `,e.publicationState]},e.version))]}):null]}),a.length===0?(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No report has been generated for this run yet. Reports are produced when a run reaches a terminal state.`})}):(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[u?(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(Yx,{variant:Jx(Bj[u.posture]??`neutral`),children:u.posture.toUpperCase()}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`v`,l.data?.version,` · `,u.contentHash.slice(0,12),` · `,u.classification,` ·`,` `,u.publicationState]})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsx)(`h2`,{children:u.target}),(0,b.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Export`}),l.data?.renditions.filter(e=>e.url).length?l.data.renditions.filter(e=>e.url).map(e=>(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:e.url,download:!0,children:[(0,b.jsx)(Pf,{}),` `,e.ext.toUpperCase()]})},e.ext)):(0,b.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:u.publicationState===`published`?`Use “Ensure renditions” below to generate files.`:`Publish to generate downloadable files.`})]})]}),(0,b.jsxs)(`p`,{className:`text-muted-foreground`,children:[u.workflowKey,` · `,u.findings.length,` finding(s) · `,u.evidence.length,` evidence row(s)`]}),u.gate.satisfied?null:(0,b.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Publication blocked: missing `,u.gate.missing.join(`, `),`.`]}),u.summary?(0,b.jsx)(`p`,{children:u.summary}):null,u.findings.length>0?(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Finding`}),(0,b.jsx)(`th`,{children:`Target`})]})}),(0,b.jsx)(`tbody`,{children:u.findings.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:Jx(Vj[e.severity]??`neutral`),children:e.severity})}),(0,b.jsx)(`td`,{children:e.title}),(0,b.jsx)(`td`,{className:`text-muted-foreground`,children:e.targetUrl??`—`})]},e.fingerprint))})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`No confirmed findings recorded — posture never claims a clean bill by default.`}),u.unverifiedLeads.length>0?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h3`,{children:`Unverified leads`}),(0,b.jsx)(`ul`,{children:u.unverifiedLeads.map(e=>(0,b.jsxs)(`li`,{children:[e.title,` `,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.disposition,`)`]})]},e.fingerprint))})]}):null,u.negativeControls.length>0?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h3`,{children:`Negative controls`}),(0,b.jsx)(`ul`,{children:u.negativeControls.map(e=>(0,b.jsx)(`li`,{children:e},e))})]}):null]}):(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{children:`Select a run and version.`})}),l.data?(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(`h3`,{children:`Markdown rendition`}),(0,b.jsx)(`span`,{className:`flex flex-wrap items-center gap-2.5`,children:l.data.renditions.filter(e=>e.url).map(e=>(0,b.jsx)(o,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:e.url,download:!0,children:[(0,b.jsx)(Pf,{}),` `,e.ext]})},e.ext))})]}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{margin:`0.5rem 0`},children:[(0,b.jsxs)(o,{variant:`ghost`,onClick:()=>m(e=>!e),disabled:S.isPending,children:[p?(0,b.jsx)(If,{}):(0,b.jsx)(qf,{}),` `,p?`View`:`Edit`]}),(0,b.jsxs)(o,{variant:`ghost`,onClick:()=>x.mutate(),disabled:x.isPending||u?.publicationState!==`published`,title:`Create any missing immutable report renditions`,children:[(0,b.jsx)(Qf,{}),` Ensure renditions`]})]}),p?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`textarea`,{className:`w-full resize-y rounded-lg border bg-[var(--surface-2)] p-3 font-mono text-[0.85rem] leading-normal`,value:g??f.data??``,onChange:e=>_(e.target.value),rows:24}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{marginTop:`0.5rem`},children:[(0,b.jsxs)(o,{onClick:()=>S.mutate(),disabled:S.isPending||!g?.trim(),children:[(0,b.jsx)($f,{}),` Save as v`,(l.data?.version??0)+1]}),S.isError?(0,b.jsxs)(`span`,{className:`text-destructive text-sm`,children:[`Save failed: `,String(S.error)]}):null]})]}):f.isLoading?(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading markdown…`}):f.isError||d===null?(0,b.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No rendered markdown yet`,d===null?``:` (unavailable)`,` — regenerate to produce it.`]}):(0,b.jsx)(`div`,{className:`max-h-[32rem] overflow-auto rounded-lg border bg-[var(--plane)] p-4`,children:(0,b.jsx)(zj,{children:f.data??``})})]}):null]})]})}function Uj(){let e=tf({queryKey:[`local-reports`],queryFn:()=>_x.localReports(),refetchInterval:5e3,retry:!1}),t=e.data?.items??[],[n,r]=(0,y.useState)(null),i=n&&t.some(e=>e.runId===n)?n:t[0]?.runId,a=i?`/api/v1/local-reports/${encodeURIComponent(i)}`:null,s=tf({queryKey:[`local-report-md`,i],queryFn:async()=>{let e=await fetch(`${a}/md`,{credentials:`same-origin`});if(!e.ok)throw Error(`Markdown fetch failed: ${e.status}`);return e.text()},enabled:!!a}),c=tf({queryKey:[`local-report-json`,i],queryFn:async()=>{let e=await fetch(`${a}/json`,{credentials:`same-origin`});if(!e.ok)throw Error(`Report fetch failed: ${e.status}`);return Gy.parse(await e.json())},enabled:!!a});if(e.isError)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-destructive text-sm`,children:`Could not load local report files. Check that local reports are enabled and your session can access this workspace.`})]});if(e.isLoading)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Checking completed report files…`})]});if(!t.length)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No completed report files are available for this workspace yet.`})]});let l=c.data;return(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Rendered from the Markdown file written when an agent run completes.`})]}),(0,b.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:i??``,onChange:e=>r(e.target.value),children:t.map(e=>(0,b.jsxs)(`option`,{value:e.runId,children:[e.workflowKey,` · `,e.target,` · `,e.findings+e.unverifiedLeads,` findings`]},e.runId))})]}),a?(0,b.jsx)(`div`,{className:`my-3 flex flex-wrap gap-2`,children:[`md`,`xlsx`,`pdf`,`json`].map(e=>(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:`${a}/${e}`,download:`${i}.${e}`,children:[(0,b.jsx)(Pf,{}),` `,e.toUpperCase()]})},e))}):null,l?(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[l.findings.length,` confirmed findings · `,l.unverifiedLeads.length,` unverified leads · `,l.evidence.length,` evidence rows · `,l.posture,` posture`]}):null,l&&l.findings.length+l.unverifiedLeads.length>0?(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Finding`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Asset`}),(0,b.jsx)(`th`,{children:`Root cause`}),(0,b.jsx)(`th`,{children:`Impact`}),(0,b.jsx)(`th`,{children:`Corrective action`}),(0,b.jsx)(`th`,{children:`Evidence`})]})}),(0,b.jsx)(`tbody`,{children:[...l.findings,...l.unverifiedLeads].map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{children:e.severity}),(0,b.jsx)(`td`,{children:e.title}),(0,b.jsx)(`td`,{children:e.disposition}),(0,b.jsx)(`td`,{children:e.targetUrl??`—`}),(0,b.jsx)(`td`,{children:e.rootCause||`Not recorded`}),(0,b.jsx)(`td`,{children:e.impact||`Not recorded`}),(0,b.jsx)(`td`,{children:e.remediation||`Not recorded`}),(0,b.jsxs)(`td`,{children:[e.evidenceRefs.length,` ref(s)`]})]},e.fingerprint))})]})}):null,s.isLoading?(0,b.jsx)(`p`,{children:`Loading report file…`}):s.isError?(0,b.jsx)(`p`,{className:`text-destructive`,children:`Could not read the Markdown report file.`}):(0,b.jsx)(`div`,{className:`mt-4 max-h-[40rem] overflow-auto rounded-lg border p-4`,children:(0,b.jsx)(zj,{children:s.data??``})})]})}function Wj(){let e=tf({queryKey:[`local-reports`],queryFn:()=>_x.localReports(),refetchInterval:5e3,retry:!1}).data?.items??[],[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(!1),[a,s]=(0,y.useState)(!1),c=t&&e.some(e=>e.runId===t)?t:e[0]?.runId,l=c?`/api/v1/local-reports/${encodeURIComponent(c)}`:null,u=tf({queryKey:[`local-report-json`,c],queryFn:async()=>{let e=await fetch(`${l}/json`,{credentials:`same-origin`});if(!e.ok)throw Error(`Report fetch failed: ${e.status}`);return Gy.parse(await e.json())},enabled:!!l&&r});if(!e.length)return null;let d=u.data;return(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{children:`Local headless runs`}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[e.length,` report`,e.length===1?``:`s`,` · separate from the agent session selected above.`]})]}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,"aria-expanded":r,onClick:()=>i(e=>!e),children:r?`Hide local runs`:`Browse local runs`})]}),r?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`mt-3 flex flex-wrap items-center gap-2 text-sm`,children:[`Run`,(0,b.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:c??``,onChange:e=>{n(e.target.value),s(!1)},children:e.map(e=>(0,b.jsxs)(`option`,{value:e.runId,children:[e.workflowKey,` · `,e.target]},e.runId))})]}),l?(0,b.jsxs)(`div`,{className:`my-3 flex gap-2`,children:[(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:`${l}/xlsx`,download:!0,children:[(0,b.jsx)(Pf,{}),` Export Excel`]})}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:`${l}/pdf`,download:!0,children:[(0,b.jsx)(Pf,{}),` Export PDF`]})})]}):null,d?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[d.findings.length,` confirmed · `,d.unverifiedLeads.length,` unverified · `,d.evidence.length,` evidence rows`]}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,className:`mt-2`,"aria-expanded":a,onClick:()=>s(e=>!e),children:a?`Hide RCA table`:`Show RCA table`}),a?(0,b.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Finding and analysis`}),(0,b.jsx)(`th`,{children:`Asset`}),(0,b.jsx)(`th`,{children:`Root cause`}),(0,b.jsx)(`th`,{children:`Impact`}),(0,b.jsx)(`th`,{children:`Corrective action`}),(0,b.jsx)(`th`,{children:`Evidence`})]})}),(0,b.jsx)(`tbody`,{children:[...d.findings,...d.unverifiedLeads].map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[e.severity,(0,b.jsx)(`br`,{}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.disposition})]}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(`details`,{children:[(0,b.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:e.title}),(0,b.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,b.jsx)(`p`,{children:e.description||`No description recorded.`}),e.invariant?(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Security invariant:`}),` `,e.invariant]}):null,e.reproduction.length?(0,b.jsx)(`ol`,{className:`list-decimal pl-5`,children:e.reproduction.map((e,t)=>(0,b.jsx)(`li`,{children:e},t))}):null]})]})}),(0,b.jsx)(`td`,{children:e.targetUrl??`—`}),(0,b.jsx)(`td`,{children:e.rootCause||`Not recorded`}),(0,b.jsx)(`td`,{children:e.impact||`Not recorded`}),(0,b.jsx)(`td`,{children:e.remediation||`Not recorded`}),(0,b.jsx)(`td`,{children:e.evidenceRefs.length?e.evidenceRefs.map(e=>(0,b.jsx)(`code`,{className:`block`,children:e.slice(0,12)},e)):`No linked refs`})]},e.fingerprint))})]})}):null]}):u.isError?(0,b.jsx)(`p`,{className:`text-destructive`,children:`Could not read the local finding record.`}):(0,b.jsx)(`p`,{children:`Loading findings…`})]}):null]})}function Gj(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var Kj=[`Reported`,`Confirmed`,`Remediating`,`Resolved`],qj={open:0,unverified:0,confirmed:1,remediating:2,remediated:3,verified:3},Jj={false_positive:`Dismissed as a false positive`,accepted_risk:`Accepted as residual risk`,suppressed:`Suppressed`};function Yj(e){let t={label:`Confirm as risk`,status:`confirmed`,icon:(0,b.jsx)(tp,{size:14})},n={label:`Dismiss (false positive)`,status:`false_positive`,icon:(0,b.jsx)(Of,{size:14}),variant:`outline`},r={label:`Start remediation`,status:`remediating`,icon:(0,b.jsx)(pp,{size:14})},i={label:`Mark resolved`,status:`remediated`,icon:(0,b.jsx)(Sf,{size:14})},a={label:`Verify fix`,status:`verified`,icon:(0,b.jsx)(np,{size:14})},o={label:`Accept risk`,status:`accepted_risk`,icon:(0,b.jsx)(np,{size:14}),variant:`outline`},s={label:`Reopen`,status:`confirmed`,icon:(0,b.jsx)(gf,{size:14}),variant:`outline`};switch(e){case`open`:case`unverified`:return[t,n];case`confirmed`:return[r,i,o,n];case`remediating`:return[i,a,o];case`remediated`:return[a,s];case`verified`:return[s];default:return[{...s,label:`Reopen finding`}]}}function Xj({findingId:e,onBack:t}){let n=Bd(),r=tf({queryKey:[`finding`,e],queryFn:()=>_x.finding(e)}),i=nf({mutationFn:t=>_x.updateFindingStatus(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`finding`,e]}),n.invalidateQueries({queryKey:[`findings`]}),n.invalidateQueries({queryKey:[`overview`]})}});if(r.isLoading)return(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading finding…`})});if(r.isError||!r.data)return(0,b.jsx)(h,{children:(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,b.jsx)(`p`,{className:`text-destructive`,children:`Could not load this finding.`}),t?(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:t,children:[(0,b.jsx)(gf,{size:14}),` Back`]}):null]})});let a=r.data.finding,s=Dx(a.severity),c=Mx(a.category,a.title),l=bx(c.stage),u=qj[a.status],d=Jj[a.status],f=Yj(a.status);return(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(Yx,{variant:Jx(s),children:Ex[s]}),(0,b.jsx)(Yx,{variant:Jx(a.status),children:Qj(a.status)}),a.cvssScore==null?null:(0,b.jsxs)(Yx,{variant:`outline`,children:[`CVSS `,a.cvssScore]})]}),(0,b.jsx)(`h1`,{className:`text-xl font-semibold`,children:a.title}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[a.path??`unscoped asset`,a.line==null?``:`:${a.line}`,` · Stage `,c.stage,` `,xx(l),` · Pillar `,Sx[c.pillar],c.inferred?` (inferred)`:``]})]}),t?(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:t,children:[(0,b.jsx)(gf,{size:14}),` Back`]}):null]}),(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolution`}),d?(0,b.jsx)(Yx,{variant:`secondary`,children:d}):null]}),d?(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This finding is off the remediation track. Reopen it to return it to the queue.`}):(0,b.jsx)(`ol`,{className:`mt-1 grid grid-cols-4 gap-2`,"aria-label":`Resolution progress`,children:Kj.map((e,t)=>(0,b.jsxs)(`li`,{className:`grid gap-1.5`,children:[(0,b.jsx)(`span`,{className:`h-1.5 rounded-full`,style:{background:u!=null&&t<=u?`var(--good)`:`var(--border)`},"aria-hidden":`true`}),(0,b.jsx)(`span`,{className:u===t?`text-xs font-semibold`:`text-muted-foreground text-xs`,children:e})]},e))})]}),(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Verify & triage`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Move this finding through its lifecycle. Changes are audited.`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,b.jsxs)(o,{size:`sm`,variant:e.variant??`default`,disabled:i.isPending,onClick:()=>i.mutate(e.status),children:[e.icon,` `,e.label]},`${e.label}:${e.status}`))}),i.isError?(0,b.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Update failed: `,String(i.error?.message??i.error)]}):null]}),a.description?(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Description`}),(0,b.jsx)(zj,{children:a.description})]}):null,a.remediation?(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Remediation`}),(0,b.jsx)(zj,{children:a.remediation})]}):null,(0,b.jsxs)(h,{children:[(0,b.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[`Evidence (`,a.evidence.length,`)`]}),a.evidence.length?(0,b.jsx)(`div`,{className:`grid gap-2`,children:a.evidence.map(e=>(0,b.jsx)(Gx,{title:`${e.kind}${e.reason?` — ${e.reason}`:``}`,detail:(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[new Date(e.createdAt).toLocaleString(),e.runID?` · run ${e.runID.slice(0,12)}`:``]}),verdict:e.verdict},e.id))}):(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No operation-level evidence linked yet. Source findings stay unverified until evidence confirms them.`})]}),(a.cwe||a.cve||a.cvssVector||a.assignee||a.resolvedAt)&&(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Metadata`}),(0,b.jsxs)(`dl`,{className:`grid gap-1.5 text-sm sm:grid-cols-2`,children:[a.cwe?(0,b.jsx)(Zj,{k:`CWE`,v:a.cwe}):null,a.cve?(0,b.jsx)(Zj,{k:`CVE`,v:a.cve}):null,a.cvssVector?(0,b.jsx)(Zj,{k:`CVSS vector`,v:a.cvssVector,mono:!0}):null,a.assignee?(0,b.jsx)(Zj,{k:`Assignee`,v:a.assignee}):null,a.resolvedAt?(0,b.jsx)(Zj,{k:`Resolved`,v:new Date(a.resolvedAt).toLocaleString()}):null,(0,b.jsx)(Zj,{k:`Fingerprint`,v:a.fingerprint,mono:!0})]})]})]})}function Zj({k:e,v:t,mono:n}){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground text-2xs w-28 shrink-0 font-semibold tracking-[0.08em] uppercase`,children:e}),(0,b.jsx)(`dd`,{className:n?`font-mono text-xs break-all`:``,children:t})]})}function Qj(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var $j=null;function eM(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=$j;$j=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{$j=n}}function tM(){if(!$j)throw Error(`No resource fiber available`);return $j}function nM(){return $j}var rM=typeof process<`u`&&!1,iM=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),aM=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},oM=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(rM)throw Error(`tap: committed history is shorter than the replay base.`);break}uM(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;lM(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)sM(e.changelog[t]);aM(e)}}},sM=e=>{uM(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},cM=(e,t)=>{e.wipCommitCallbacks.push(t)},lM=(e,t)=>{e.rollbackCallbacks.push(t)},uM=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),lM(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},dM=Symbol.for(`react.memo_cache_sentinel`),fM=e=>Array(e).fill(dM),pM=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,lM(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=fM(t),r[i]=a):rM&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},mM=e=>pM(tM(),e),hM=y.default.__COMPILER_RUNTIME?.c??(e=>(0,y.useMemo)(()=>{let t=fM(e);return t[dM]=!0,t},[])),gM=()=>nM()!==null,J=e=>gM()?mM(e):hM(e),_M=(e,...t)=>Object.assign(Object.create(null),e,...t),vM=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},yM=()=>{throw Error(`Hook order changed between renders`)},bM=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function xM(e,t){let n=tM(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?bM():i.type===`effect`?i:yM();if(i===void 0&&(n.isFirstRender||vM(),n.cells[r]=a,n.effectCells.push(a)),a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);cM(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var SM=(e,t)=>{rM&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
88
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return zk(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=IA.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function KA(){return{exit:{taskListCheckValueChecked:JA,taskListCheckValueUnchecked:JA,paragraph:YA}}}function qA(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:XA}}}function JA(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function YA(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function XA(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=IA.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function ZA(){return[rk(),Dk(),Mk(),LA(),KA()]}function QA(e){return{extensions:[ik(),Ok(e),Nk(),GA(e),qA()]}}var $A={tokenize:pj,partial:!0},ej={tokenize:mj,partial:!0},tj={tokenize:hj,partial:!0},nj={tokenize:gj,partial:!0},rj={tokenize:_j,partial:!0},ij={name:`wwwAutolink`,tokenize:dj,previous:vj},aj={name:`protocolAutolink`,tokenize:fj,previous:yj},oj={name:`emailAutolink`,tokenize:uj,previous:bj},sj={};function cj(){return{text:sj}}for(var lj=48;lj<123;)sj[lj]=oj,lj++,lj===58?lj=65:lj===91&&(lj=97);sj[43]=oj,sj[45]=oj,sj[46]=oj,sj[95]=oj,sj[72]=[oj,aj],sj[104]=[oj,aj],sj[87]=[oj,ij],sj[119]=[oj,ij];function uj(e,t,n){let r=this,i,a;return o;function o(t){return!xj(t)||!bj.call(r,r.previous)||Sj(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return xj(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(rj,u,l)(t):t===45||t===95||tw(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&ew(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function dj(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!vj.call(r,r.previous)||Sj(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check($A,e.attempt(ej,e.attempt(tj,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function fj(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&yj.call(r,r.previous)&&!Sj(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(ew(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||rw(t)||sw(t)||uw(t)||lw(t)?n(t):e.attempt(ej,e.attempt(tj,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function pj(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function mj(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(nj,c,s)(t):t===null||sw(t)||uw(t)||t!==45&&lw(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function hj(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(nj,t,a)(o):o===null||sw(o)||uw(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function gj(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||sw(o)||uw(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||sw(e)||uw(e)?t(e):r(e)}function a(e){return ew(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):ew(t)?(e.consume(t),o):n(t)}}function _j(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return tw(e)?n(e):t(e)}}function vj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||sw(e)}function yj(e){return!ew(e)}function bj(e){return!(e===47||xj(e))}function xj(e){return e===43||e===45||e===46||e===95||tw(e)}function Sj(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Cj={tokenize:jj,partial:!0};function wj(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Oj,continuation:{tokenize:kj},exit:Aj}},text:{91:{name:`gfmFootnoteCall`,tokenize:Dj},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Tj,resolveTo:Ej}}}}function Tj(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=$C(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Ej(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Dj(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||sw(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes($C(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return sw(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Oj(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||sw(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=$C(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return sw(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),pw(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function kj(e,t,n){return e.check(Ow,t,e.attempt(Cj,t,n))}function Aj(e){e.exit(`gfmFootnoteDefinition`)}function jj(e,t,n){let r=this;return pw(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Mj(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&KC(o,o.length,0,xw(s,e.slice(r+1,n),t)),KC(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),KC(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=bw(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=bw(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Nj=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Pj(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Pj(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function Fj(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Ij(){return{flow:{null:{name:`table`,tokenize:Lj,resolveAll:Rj}}}}function Lj(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):cw(t)?pw(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||sw(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,cw(t)?pw(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return cw(t)?pw(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return cw(t)?pw(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):cw(n)?pw(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||sw(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Rj(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Nj;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Bj(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=zj(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=zj(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=zj(f,t,o,i,n,d)):(o[0]=o[1],d=zj(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Bj(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Fj(t.events,n))}return e}function zj(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Vj(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Vj(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Vj(t.events,n[2]),a=Vj(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Vj(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Bj(e,t,n,r,i){let a=[],o=Vj(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Vj(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Hj={name:`tasklistCheck`,tokenize:Wj};function Uj(){return{text:{91:Hj}}}function Wj(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return sw(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):cw(r)?e.check({tokenize:Gj},t,n)(r):n(r)}}function Gj(e,t,n){return pw(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Kj(e){return YC([cj(),wj(),Mj(e),Ij(),Uj()])}var qj={};function Jj(e){let t=this,n=e||qj,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Kj(n)),a.push(ZA()),o.push(QA(n))}var Yj={a:({children:e,...t})=>(0,b.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer`,className:`text-primary underline underline-offset-2`,children:e}),code:({className:e,children:t,...n})=>/language-/.test(e??``)?(0,b.jsx)(`code`,{...n,className:`block overflow-auto rounded-md border bg-[var(--plane)] p-3 font-mono text-xs whitespace-pre-wrap`,children:t}):(0,b.jsx)(`code`,{...n,className:`rounded-sm bg-[var(--plane)] px-1 py-0.5 font-mono text-[0.85em]`,children:t}),pre:({children:e,...t})=>(0,b.jsx)(`pre`,{...t,className:`my-1 overflow-auto`,children:e}),blockquote:({children:e,...t})=>(0,b.jsx)(`blockquote`,{...t,className:`border-l-2 border-border pl-3 text-muted-foreground`,children:e}),table:({children:e,...t})=>(0,b.jsx)(`div`,{className:`overflow-auto`,children:(0,b.jsx)(`table`,{...t,className:`w-full text-xs`,children:e})})};function Xj({children:e,className:t}){return(0,b.jsx)(`div`,{className:a(`md-body grid gap-2 text-sm leading-relaxed [&_h1]:mt-1 [&_h2]:mt-2 [&_h3]:mt-1`,t),children:(0,b.jsx)(WO,{remarkPlugins:[Jj],components:Yj,children:e})})}var Zj={clean:`success`,informational:`neutral`,actionable:`warning`,critical:`critical`},Qj={critical:`critical`,high:`error`,medium:`warning`,low:`neutral`,informational:`neutral`};function $j(){let e=Bd(),t=tf({queryKey:[`runs`],queryFn:()=>Cx.runs()}),n=t.data?.runs??[],[r,i]=(0,y.useState)(null),a=tf({queryKey:[`report-versions`,r],queryFn:()=>Cx.reportVersions(r),enabled:!!r}).data?.items??[],[s,c]=(0,y.useState)(null);(0,y.useEffect)(()=>{n.length>0&&!n.some(e=>e.id===r)&&i(n[0].id)},[n,r]),(0,y.useEffect)(()=>{if(a.length===0){c(null);return}a.some(e=>e.version===s)||c(a[0].version)},[r,a,s]);let l=tf({queryKey:[`report-version`,r,s],queryFn:()=>Cx.reportVersion(r,s),enabled:!!r&&s!==null}),u=l.data?.record,d=l.data?.renditions.find(e=>e.ext===`md`)?.url??null,f=tf({queryKey:[`report-md`,r,s],queryFn:async()=>{let e=await fetch(d,{credentials:`same-origin`});if(!e.ok)throw Error(`Rendition fetch failed: ${e.status}`);return e.text()},enabled:d!==null}),[p,m]=(0,y.useState)(!1),[g,_]=(0,y.useState)(null),v=()=>{e.invalidateQueries({queryKey:[`report-versions`,r]}),e.invalidateQueries({queryKey:[`report-version`,r]}),e.invalidateQueries({queryKey:[`report-md`,r]})},x=nf({mutationFn:()=>Cx.renderReportRenditions(r,s),onSuccess:()=>{m(!1),v()}}),S=nf({mutationFn:()=>Cx.publishEditedMarkdown(r,s,g),onSuccess:e=>{_(null),m(!1),c(e.version),v()}});return t.isLoading?(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsx)(eM,{}),(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading hosted runs…`})})]}):n.length===0?(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsx)(eM,{}),(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`No hosted runs yet. Launch an assessment and its report will appear here on completion.`})})]}):(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsx)(eM,{}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`mb-0`,children:`Generated report`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`The structured record is read-only; edits create new auditable versions.`})]}),(0,b.jsxs)(`div`,{className:`bg-card flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border p-3`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Run`}),(0,b.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:r??``,onChange:e=>{i(e.target.value),c(null)},children:n.map(e=>(0,b.jsxs)(`option`,{value:e.id,children:[e.title,` — `,nM(e.status)]},e.id))})]}),a.length>0?(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Version`}),a.map(e=>(0,b.jsxs)(o,{variant:e.version===s?`secondary`:`outline`,size:`sm`,className:`aria-pressed:border-primary`,"aria-pressed":e.version===s,onClick:()=>{c(e.version),m(!1)},children:[`v`,e.version,` · `,e.publicationState]},e.version))]}):null]}),a.length===0?(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No report has been generated for this run yet. Reports are produced when a run reaches a terminal state.`})}):(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[u?(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(oS,{variant:aS(Zj[u.posture]??`neutral`),children:u.posture.toUpperCase()}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`v`,l.data?.version,` · `,u.contentHash.slice(0,12),` · `,u.classification,` ·`,` `,u.publicationState]})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsx)(`h2`,{children:u.target}),(0,b.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Export`}),l.data?.renditions.filter(e=>e.url).length?l.data.renditions.filter(e=>e.url).map(e=>(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:e.url,download:!0,children:[(0,b.jsx)(Ff,{}),` `,e.ext.toUpperCase()]})},e.ext)):(0,b.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:u.publicationState===`published`?`Use “Ensure renditions” below to generate files.`:`Publish to generate downloadable files.`})]})]}),(0,b.jsxs)(`p`,{className:`text-muted-foreground`,children:[u.workflowKey,` · `,u.findings.length,` finding(s) · `,u.evidence.length,` evidence row(s)`]}),u.gate.satisfied?null:(0,b.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Publication blocked: missing `,u.gate.missing.join(`, `),`.`]}),u.summary?(0,b.jsx)(`p`,{children:u.summary}):null,u.findings.length>0?(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Finding`}),(0,b.jsx)(`th`,{children:`Target`})]})}),(0,b.jsx)(`tbody`,{children:u.findings.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:aS(Qj[e.severity]??`neutral`),children:e.severity})}),(0,b.jsx)(`td`,{children:e.title}),(0,b.jsx)(`td`,{className:`text-muted-foreground`,children:e.targetUrl??`—`})]},e.fingerprint))})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`No confirmed findings recorded — posture never claims a clean bill by default.`}),u.unverifiedLeads.length>0?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h3`,{children:`Unverified leads`}),(0,b.jsx)(`ul`,{children:u.unverifiedLeads.map(e=>(0,b.jsxs)(`li`,{children:[e.title,` `,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.disposition,`)`]})]},e.fingerprint))})]}):null,u.negativeControls.length>0?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h3`,{children:`Negative controls`}),(0,b.jsx)(`ul`,{children:u.negativeControls.map(e=>(0,b.jsx)(`li`,{children:e},e))})]}):null]}):(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{children:`Select a run and version.`})}),l.data?(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(`h3`,{children:`Markdown rendition`}),(0,b.jsx)(`span`,{className:`flex flex-wrap items-center gap-2.5`,children:l.data.renditions.filter(e=>e.url).map(e=>(0,b.jsx)(o,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:e.url,download:!0,children:[(0,b.jsx)(Ff,{}),` `,e.ext]})},e.ext))})]}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{margin:`0.5rem 0`},children:[(0,b.jsxs)(o,{variant:`ghost`,onClick:()=>m(e=>!e),disabled:S.isPending,children:[p?(0,b.jsx)(Lf,{}):(0,b.jsx)(Zf,{}),` `,p?`View`:`Edit`]}),(0,b.jsxs)(o,{variant:`ghost`,onClick:()=>x.mutate(),disabled:x.isPending||u?.publicationState!==`published`,title:`Create any missing immutable report renditions`,children:[(0,b.jsx)(np,{}),` Ensure renditions`]})]}),p?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`textarea`,{className:`w-full resize-y rounded-lg border bg-[var(--surface-2)] p-3 font-mono text-[0.85rem] leading-normal`,value:g??f.data??``,onChange:e=>_(e.target.value),rows:24}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{marginTop:`0.5rem`},children:[(0,b.jsxs)(o,{onClick:()=>S.mutate(),disabled:S.isPending||!g?.trim(),children:[(0,b.jsx)(rp,{}),` Save as v`,(l.data?.version??0)+1]}),S.isError?(0,b.jsxs)(`span`,{className:`text-destructive text-sm`,children:[`Save failed: `,String(S.error)]}):null]})]}):f.isLoading?(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading markdown…`}):f.isError||d===null?(0,b.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No rendered markdown yet`,d===null?``:` (unavailable)`,` — regenerate to produce it.`]}):(0,b.jsx)(`div`,{className:`max-h-[32rem] overflow-auto rounded-lg border bg-[var(--plane)] p-4`,children:(0,b.jsx)(Xj,{children:f.data??``})})]}):null]})]})}function eM(){let e=tf({queryKey:[`local-reports`],queryFn:()=>Cx.localReports(),refetchInterval:5e3,retry:!1}),t=e.data?.items??[],[n,r]=(0,y.useState)(null),i=n&&t.some(e=>e.runId===n)?n:t[0]?.runId,a=i?`/api/v1/local-reports/${encodeURIComponent(i)}`:null,s=tf({queryKey:[`local-report-md`,i],queryFn:async()=>{let e=await fetch(`${a}/md`,{credentials:`same-origin`});if(!e.ok)throw Error(`Markdown fetch failed: ${e.status}`);return e.text()},enabled:!!a}),c=tf({queryKey:[`local-report-json`,i],queryFn:async()=>{let e=await fetch(`${a}/json`,{credentials:`same-origin`});if(!e.ok)throw Error(`Report fetch failed: ${e.status}`);return Zy.parse(await e.json())},enabled:!!a});if(e.isError)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-destructive text-sm`,children:`Could not load local report files. Check that local reports are enabled and your session can access this workspace.`})]});if(e.isLoading)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Checking completed report files…`})]});if(!t.length)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No completed report files are available for this workspace yet.`})]});let l=c.data;return(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{children:`Agent reports`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Rendered from the Markdown file written when an agent run completes.`})]}),(0,b.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:i??``,onChange:e=>r(e.target.value),children:t.map(e=>(0,b.jsxs)(`option`,{value:e.runId,children:[e.workflowKey,` · `,e.target,` · `,e.findings+e.unverifiedLeads,` findings`]},e.runId))})]}),a?(0,b.jsx)(`div`,{className:`my-3 flex flex-wrap gap-2`,children:[`md`,`xlsx`,`pdf`,`json`].map(e=>(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:`${a}/${e}`,download:`${i}.${e}`,children:[(0,b.jsx)(Ff,{}),` `,e.toUpperCase()]})},e))}):null,l?(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[l.findings.length,` confirmed findings · `,l.unverifiedLeads.length,` unverified leads · `,l.evidence.length,` evidence rows · `,l.posture,` posture`]}):null,l&&l.findings.length+l.unverifiedLeads.length>0?(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Finding`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Asset`}),(0,b.jsx)(`th`,{children:`Root cause`}),(0,b.jsx)(`th`,{children:`Impact`}),(0,b.jsx)(`th`,{children:`Corrective action`}),(0,b.jsx)(`th`,{children:`Evidence`})]})}),(0,b.jsx)(`tbody`,{children:[...l.findings,...l.unverifiedLeads].map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{children:e.severity}),(0,b.jsx)(`td`,{children:e.title}),(0,b.jsx)(`td`,{children:e.disposition}),(0,b.jsx)(`td`,{children:e.targetUrl??`—`}),(0,b.jsx)(`td`,{children:e.rootCause||`Not recorded`}),(0,b.jsx)(`td`,{children:e.impact||`Not recorded`}),(0,b.jsx)(`td`,{children:e.remediation||`Not recorded`}),(0,b.jsxs)(`td`,{children:[e.evidenceRefs.length,` ref(s)`]})]},e.fingerprint))})]})}):null,s.isLoading?(0,b.jsx)(`p`,{children:`Loading report file…`}):s.isError?(0,b.jsx)(`p`,{className:`text-destructive`,children:`Could not read the Markdown report file.`}):(0,b.jsx)(`div`,{className:`mt-4 max-h-[40rem] overflow-auto rounded-lg border p-4`,children:(0,b.jsx)(Xj,{children:s.data??``})})]})}function tM(){let e=tf({queryKey:[`local-reports`],queryFn:()=>Cx.localReports(),refetchInterval:5e3,retry:!1}).data?.items??[],[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(!1),[a,s]=(0,y.useState)(!1),c=t&&e.some(e=>e.runId===t)?t:e[0]?.runId,l=c?`/api/v1/local-reports/${encodeURIComponent(c)}`:null,u=tf({queryKey:[`local-report-json`,c],queryFn:async()=>{let e=await fetch(`${l}/json`,{credentials:`same-origin`});if(!e.ok)throw Error(`Report fetch failed: ${e.status}`);return Zy.parse(await e.json())},enabled:!!l&&r});if(!e.length)return null;let d=u.data;return(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{children:`Local headless runs`}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[e.length,` report`,e.length===1?``:`s`,` · separate from the agent session selected above.`]})]}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,"aria-expanded":r,onClick:()=>i(e=>!e),children:r?`Hide local runs`:`Browse local runs`})]}),r?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`mt-3 flex flex-wrap items-center gap-2 text-sm`,children:[`Run`,(0,b.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:c??``,onChange:e=>{n(e.target.value),s(!1)},children:e.map(e=>(0,b.jsxs)(`option`,{value:e.runId,children:[e.workflowKey,` · `,e.target]},e.runId))})]}),l?(0,b.jsxs)(`div`,{className:`my-3 flex gap-2`,children:[(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:`${l}/xlsx`,download:!0,children:[(0,b.jsx)(Ff,{}),` Export Excel`]})}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,b.jsxs)(`a`,{href:`${l}/pdf`,download:!0,children:[(0,b.jsx)(Ff,{}),` Export PDF`]})})]}):null,d?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[d.findings.length,` confirmed · `,d.unverifiedLeads.length,` unverified · `,d.evidence.length,` evidence rows`]}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,className:`mt-2`,"aria-expanded":a,onClick:()=>s(e=>!e),children:a?`Hide RCA table`:`Show RCA table`}),a?(0,b.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Finding and analysis`}),(0,b.jsx)(`th`,{children:`Asset`}),(0,b.jsx)(`th`,{children:`Root cause`}),(0,b.jsx)(`th`,{children:`Impact`}),(0,b.jsx)(`th`,{children:`Corrective action`}),(0,b.jsx)(`th`,{children:`Evidence`})]})}),(0,b.jsx)(`tbody`,{children:[...d.findings,...d.unverifiedLeads].map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[e.severity,(0,b.jsx)(`br`,{}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.disposition})]}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(`details`,{children:[(0,b.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:e.title}),(0,b.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,b.jsx)(`p`,{children:e.description||`No description recorded.`}),e.invariant?(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Security invariant:`}),` `,e.invariant]}):null,e.reproduction.length?(0,b.jsx)(`ol`,{className:`list-decimal pl-5`,children:e.reproduction.map((e,t)=>(0,b.jsx)(`li`,{children:e},t))}):null]})]})}),(0,b.jsx)(`td`,{children:e.targetUrl??`—`}),(0,b.jsx)(`td`,{children:e.rootCause||`Not recorded`}),(0,b.jsx)(`td`,{children:e.impact||`Not recorded`}),(0,b.jsx)(`td`,{children:e.remediation||`Not recorded`}),(0,b.jsx)(`td`,{children:e.evidenceRefs.length?e.evidenceRefs.map(e=>(0,b.jsx)(`code`,{className:`block`,children:e.slice(0,12)},e)):`No linked refs`})]},e.fingerprint))})]})}):null]}):u.isError?(0,b.jsx)(`p`,{className:`text-destructive`,children:`Could not read the local finding record.`}):(0,b.jsx)(`p`,{children:`Loading findings…`})]}):null]})}function nM(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var rM=[`Reported`,`Confirmed`,`Remediating`,`Resolved`],iM={open:0,unverified:0,confirmed:1,remediating:2,remediated:3,verified:3},aM={false_positive:`Dismissed as a false positive`,accepted_risk:`Accepted as residual risk`,suppressed:`Suppressed`};function oM(e){let t={label:`Confirm as risk`,status:`confirmed`,icon:(0,b.jsx)(op,{size:14})},n={label:`Dismiss (false positive)`,status:`false_positive`,icon:(0,b.jsx)(kf,{size:14}),variant:`outline`},r={label:`Start remediation`,status:`remediating`,icon:(0,b.jsx)(yp,{size:14})},i={label:`Mark resolved`,status:`remediated`,icon:(0,b.jsx)(Cf,{size:14})},a={label:`Verify fix`,status:`verified`,icon:(0,b.jsx)(sp,{size:14})},o={label:`Accept risk`,status:`accepted_risk`,icon:(0,b.jsx)(sp,{size:14}),variant:`outline`},s={label:`Reopen`,status:`confirmed`,icon:(0,b.jsx)(_f,{size:14}),variant:`outline`};switch(e){case`open`:case`unverified`:return[t,n];case`confirmed`:return[r,i,o,n];case`remediating`:return[i,a,o];case`remediated`:return[a,s];case`verified`:return[s];default:return[{...s,label:`Reopen finding`}]}}function sM({findingId:e,onBack:t}){let n=Bd(),r=tf({queryKey:[`finding`,e],queryFn:()=>Cx.finding(e)}),i=nf({mutationFn:t=>Cx.updateFindingStatus(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`finding`,e]}),n.invalidateQueries({queryKey:[`findings`]}),n.invalidateQueries({queryKey:[`overview`]})}});if(r.isLoading)return(0,b.jsx)(h,{children:(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading finding…`})});if(r.isError||!r.data)return(0,b.jsx)(h,{children:(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,b.jsx)(`p`,{className:`text-destructive`,children:`Could not load this finding.`}),t?(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:t,children:[(0,b.jsx)(_f,{size:14}),` Back`]}):null]})});let a=r.data.finding,s=Nx(a.severity),c=Rx(a.category,a.title),l=Ex(c.stage),u=iM[a.status],d=aM[a.status],f=oM(a.status);return(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(oS,{variant:aS(s),children:Mx[s]}),(0,b.jsx)(oS,{variant:aS(a.status),children:lM(a.status)}),a.cvssScore==null?null:(0,b.jsxs)(oS,{variant:`outline`,children:[`CVSS `,a.cvssScore]})]}),(0,b.jsx)(`h1`,{className:`text-xl font-semibold`,children:a.title}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[a.path??`unscoped asset`,a.line==null?``:`:${a.line}`,` · Stage `,c.stage,` `,Dx(l),` · Pillar `,Ox[c.pillar],c.inferred?` (inferred)`:``]})]}),t?(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:t,children:[(0,b.jsx)(_f,{size:14}),` Back`]}):null]}),(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolution`}),d?(0,b.jsx)(oS,{variant:`secondary`,children:d}):null]}),d?(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This finding is off the remediation track. Reopen it to return it to the queue.`}):(0,b.jsx)(`ol`,{className:`mt-1 grid grid-cols-4 gap-2`,"aria-label":`Resolution progress`,children:rM.map((e,t)=>(0,b.jsxs)(`li`,{className:`grid gap-1.5`,children:[(0,b.jsx)(`span`,{className:`h-1.5 rounded-full`,style:{background:u!=null&&t<=u?`var(--good)`:`var(--border)`},"aria-hidden":`true`}),(0,b.jsx)(`span`,{className:u===t?`text-xs font-semibold`:`text-muted-foreground text-xs`,children:e})]},e))})]}),(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Verify & triage`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Move this finding through its lifecycle. Changes are audited.`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,b.jsxs)(o,{size:`sm`,variant:e.variant??`default`,disabled:i.isPending,onClick:()=>i.mutate(e.status),children:[e.icon,` `,e.label]},`${e.label}:${e.status}`))}),i.isError?(0,b.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Update failed: `,String(i.error?.message??i.error)]}):null]}),a.description?(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Description`}),(0,b.jsx)(Xj,{children:a.description})]}):null,a.remediation?(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Remediation`}),(0,b.jsx)(Xj,{children:a.remediation})]}):null,(0,b.jsxs)(h,{children:[(0,b.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[`Evidence (`,a.evidence.length,`)`]}),a.evidence.length?(0,b.jsx)(`div`,{className:`grid gap-2`,children:a.evidence.map(e=>(0,b.jsx)(nS,{title:`${e.kind}${e.reason?` — ${e.reason}`:``}`,detail:(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[new Date(e.createdAt).toLocaleString(),e.runID?` · run ${e.runID.slice(0,12)}`:``]}),verdict:e.verdict},e.id))}):(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No operation-level evidence linked yet. Source findings stay unverified until evidence confirms them.`})]}),(a.cwe||a.cve||a.cvssVector||a.assignee||a.resolvedAt)&&(0,b.jsxs)(h,{children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Metadata`}),(0,b.jsxs)(`dl`,{className:`grid gap-1.5 text-sm sm:grid-cols-2`,children:[a.cwe?(0,b.jsx)(cM,{k:`CWE`,v:a.cwe}):null,a.cve?(0,b.jsx)(cM,{k:`CVE`,v:a.cve}):null,a.cvssVector?(0,b.jsx)(cM,{k:`CVSS vector`,v:a.cvssVector,mono:!0}):null,a.assignee?(0,b.jsx)(cM,{k:`Assignee`,v:a.assignee}):null,a.resolvedAt?(0,b.jsx)(cM,{k:`Resolved`,v:new Date(a.resolvedAt).toLocaleString()}):null,(0,b.jsx)(cM,{k:`Fingerprint`,v:a.fingerprint,mono:!0})]})]})]})}function cM({k:e,v:t,mono:n}){return(0,b.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,b.jsx)(`dt`,{className:`text-muted-foreground text-2xs w-28 shrink-0 font-semibold tracking-[0.08em] uppercase`,children:e}),(0,b.jsx)(`dd`,{className:n?`font-mono text-xs break-all`:``,children:t})]})}function lM(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var uM=null;function dM(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=uM;uM=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{uM=n}}function fM(){if(!uM)throw Error(`No resource fiber available`);return uM}function pM(){return uM}var mM=typeof process<`u`&&!1,hM=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),gM=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},_M=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(mM)throw Error(`tap: committed history is shorter than the replay base.`);break}xM(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;bM(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)vM(e.changelog[t]);gM(e)}}},vM=e=>{xM(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},yM=(e,t)=>{e.wipCommitCallbacks.push(t)},bM=(e,t)=>{e.rollbackCallbacks.push(t)},xM=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),bM(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},SM=Symbol.for(`react.memo_cache_sentinel`),CM=e=>Array(e).fill(SM),wM=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,bM(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=CM(t),r[i]=a):mM&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},TM=e=>wM(fM(),e),EM=y.default.__COMPILER_RUNTIME?.c??(e=>(0,y.useMemo)(()=>{let t=CM(e);return t[SM]=!0,t},[])),DM=()=>pM()!==null,J=e=>DM()?TM(e):EM(e),OM=(e,...t)=>Object.assign(Object.create(null),e,...t),kM=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},AM=()=>{throw Error(`Hook order changed between renders`)},jM=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function MM(e,t){let n=fM(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?jM():i.type===`effect`?i:AM();if(i===void 0&&(n.isFirstRender||kM(),n.cells[r]=a,n.effectCells.push(a)),a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);yM(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var NM=(e,t)=>{mM&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
89
89
 
90
- Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},CM=(e,t)=>{cM(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},wM=(e,t)=>{let n=tM(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||vM();let a=e();return rM&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&yM();let a=i;if(SM(a.wipDeps,t))return a.isDirty&&CM(n,a),a.wip;let o=e();return rM&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,lM(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),CM(n,a),o};function TM(e){return wM(()=>({current:e}),[])}var EM=Symbol(`tap.Context.defaultValue`),DM=e=>e,OM=new Map,kM=new Set,AM=()=>new Map(OM),jM=(e,t)=>{let n=OM;OM=e;try{return t()}finally{OM=n}},MM=(e,t)=>{e[EM]=t},NM=e=>typeof e==`object`&&!!e&&EM in e,PM=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),FM=e=>NM(e)||PM(e),IM=e=>{if(!NM(e)){if(PM(e)){MM(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},LM=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);IM(e);let r=e,i=tM(),a=TM(void 0),o=a.current===void 0||!Object.is(a.current.value,t);xM(()=>{a.current={value:t}},[t]);let s=OM.get(r),c=s!==void 0||OM.has(r);OM.set(r,{value:t,source:i});try{return RM(r,o,n)}finally{c?OM.set(r,s):OM.delete(r)}},RM=(e,t,n)=>{let r=kM.has(e);t?kM.add(e):kM.delete(e);try{return n()}finally{r?kM.add(e):kM.delete(e)}},zM=e=>{IM(e);let t=e,n=BM(t,e),r=tM();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},BM=(e,t)=>OM.get(e)??{value:DM(t)[EM],source:null},VM=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},HM=(e,t=e.wipContextDeps)=>{let n=nM();n&&t&&(n.wipContextDeps=VM(n,e,n.wipContextDeps,t))},UM=()=>kM.size>0,WM=e=>{if(!e.contextDeps||!UM())return!1;for(let t of kM.keys())if(e.contextDeps.has(t))return!0;return!1},GM=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,sM(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},KM=(e,t,n,r,i)=>{let a=r?r(n):n;rM&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=nM();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else GM(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function qM(e,t,n,r){let i=tM(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:yM();i.isFirstRender||vM();let s=KM(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,rM&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):rM&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(uM(i,s),s.workInProgress=t)}return s.isDirty&&cM(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function JM(e,t,n){return qM(e,t,n,!1)}var YM=(e,t)=>typeof t==`function`?t(e):t,XM=e=>e===void 0?void 0:typeof e==`function`?e():e;function ZM(e){return qM(YM,e,XM,!0)}var QM=(e,t)=>wM(()=>e,t);function $M(e){let t=tM(),n=TM(e);return n.current!==e&&cM(t,()=>{n.current=e}),QM(((...e)=>{if(rM&&nM())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var eN=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,tN=()=>{},nN=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(tN,tN):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},rN=e=>eN(e)?nN(e):zM(e),iN=!1,aN=(e,t,n=t)=>{let r=tM().isNeverMounted,i=r?n():t();rM&&!iN&&(!r||n===t)&&(Object.is(i,t())||(iN=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=JM(e=>e+1,0),o=TM(0),s=$M(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return xM(()=>e(()=>{s()&&a()}),[e]),xM(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},oN=(e,t)=>{},sN=0,cN=()=>{let e=TM(null);return e.current??=`:tap${sN++}:`,e.current},lN=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?xM(r):xM(r,[...n,e])},uN=y.default;function dN(e){let t=(0,y.useRef)(e);return(0,y.useInsertionEffect)(()=>{t.current=e}),(0,y.useCallback)(((...e)=>t.current(...e)),[])}var fN=uN.useEffectEvent??dN,pN=()=>nM()!==null,mN=y.default,hN=e=>pN()?ZM(e):mN.useState(e),gN=(e,t,n)=>pN()?JM(e,t,n):mN.useReducer(e,t,n),Y=e=>pN()?TM(e):mN.useRef(e),_N=(e,t)=>pN()?wM(e,t):mN.useMemo(e,t),vN=(e,t)=>pN()?QM(e,t):mN.useCallback(e,t),X=(e,t)=>pN()?xM(e,t):mN.useEffect(e,t),yN=(e,t)=>pN()?xM(e,t):mN.useLayoutEffect(e,t),bN=e=>pN()?$M(e):fN(e),xN=(e,t,n)=>pN()?aN(e,t,n):mN.useSyncExternalStore(e,t,n),SN=(e,t)=>pN()?void 0:mN.useDebugValue(e,t),CN=(e,t)=>pN()?xM(e,t):mN.useInsertionEffect(e,t),wN=()=>pN()?cN():mN.useId(),TN=(e,t,n)=>pN()?lN(e,t,n):mN.useImperativeHandle(e,t,n),Z=e=>mN.forwardRef(e),EN=(e,t)=>mN.memo(e,t),DN=mN.Fragment,ON=(...e)=>mN.createElement(...e),kN=(...e)=>mN.cloneElement(...e),AN=e=>mN.isValidElement(e);mN.Children,mN.Suspense;var jN=e=>{let t=mN.createContext(e);return MM(t,e),t},MN=e=>pN()&&FM(e)?rN(e):mN.use(e),NN=e=>pN()&&FM(e)?rN(e):mN.useContext(e);function PN(e){return(...t)=>({hook:e,args:t})}function FN(e,t,n){return typeof t==`function`?(...n)=>FN(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var IN=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},LN=50,RN={schedulers:new Set,isScheduled:!1},zN=null,BN=[],VN=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(zN&&(zN.get(this)??0)>=LN)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,RN.schedulers.add(this),WN()}runTask(){zN?.set(this,(zN.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},HN=[];new VN(()=>{let e=HN.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}IN(t,`Errors occurred while running scheduled tasks`)});var UN=e=>{if(zN!==null){BN.push(e);return}e()},WN=()=>{RN.isScheduled||(RN.isScheduled=!0,KN())},GN=()=>{let e=zN;zN=new Map;let t=[];try{for(let e of RN.schedulers)if(RN.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(zN=e,RN.schedulers.clear(),RN.isScheduled=!1,zN===null)for(;BN.length>0;)try{BN.shift()()}catch(e){t.push(e)}}IN(t,`Errors occurred during flushSync`)},KN=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),GN()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(GN,0)})(),qN=e=>{if(zN!==null)return rM&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=RN;RN={schedulers:new Set,isScheduled:!0};try{let t=e();return GN(),t}finally{let e=RN.schedulers;if(RN=t,e.size>0){for(let t of e)RN.schedulers.add(t);WN()}}};function JN(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}IN(t,`Errors during commit`)}function YN(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var XN=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!SM(e.deps,e.setupDeps);function ZN(e){let t=[],n=[];for(let t of e.effectCells)XN(t)&&n.push(t);for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){t.push(e)}finally{e.cleanup=void 0}for(let e of n)try{YN(e)}catch(e){t.push(e)}IN(t,`Errors during commit`)}function QN(e){let t=[];for(let n of e.effectCells)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}IN(t,`Errors during cleanup`)}var $N={useState:ZM,useReducer:JM,useRef:TM,useMemo:wM,useCallback:QM,useEffect:xM,useLayoutEffect:xM,useInsertionEffect:xM,useEffectEvent:$M,useContext:zM,use:rN,useSyncExternalStore:aN,useDebugValue:oN,useId:cN,useImperativeHandle:lN,useMemoCache:mM},eP=y.default,tP=eP.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??eP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nP=tP==null?null:`H`in tP?{get current(){return tP.H},set current(e){tP.H=e}}:`ReactCurrentDispatcher`in tP?{get current(){return tP.ReactCurrentDispatcher.current},set current(e){tP.ReactCurrentDispatcher.current=e}}:null;function rP(e){if(!nP)return e();let t=nP.current;nP.current=$N;try{return e()}finally{nP.current=t}}function iP(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function aP(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function oP(e){e.isMounted&&(e.isMounted=!1,QN(e))}function sP(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,eM(e,()=>{r=rP(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw aP(e),t}return HM(e),r}function cP(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=rM&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,aM(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),JN(t)),n&&(ZN(e),QN(e)),ZN(e)}var lP=()=>{let e=tM();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},uP=()=>`child`,dP=()=>null,fP=()=>{if(!rM)return dP;let e=Y(0);return hN(()=>e.current++),e.current===2?uP:dP},pP=()=>nM()?lP:fP(),mP=e=>e(),hP=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}IN(t,`Errors occurred while notifying Tap root subscribers`)},gP=(e,t,n)=>{let r=new VN(()=>s.handleUpdate()),i=[],a=iM((e,t)=>{(i.length!==0||e())&&(i.push(t),r.markDirty())}),o=iP(mP,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{oM(a,a.committedVersion);for(let e of i)rM&&o.devStrictMode&&e(),e();return oM(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,UN(()=>hP(s.subscribers)))},finishFlush:(e,t,n)=>{aM(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&cP(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{rM&&o.devStrictMode&&jM(s.context,()=>sP(o,[s.committedRender])),t=jM(s.context,()=>sP(o,[s.committedRender]))}catch(e){if(oM(a,a.committedVersion),eN(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},_P=e=>{let[,t]=hN(0),n=pP(),r=Y(null),i=r.current??=gP(e,n(),t),a=AM(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=jM(a,()=>sP(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),X(()=>(i.isMounted=!0,()=>{i.isMounted=!1,oP(i.fiber)}),[i]),X(()=>{if(c.processed){i.fiber.isMounted||(cP(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}cP(i.fiber),i.publish(c.value,c.version)}),_N(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},vP=()=>{let e=Y(0),t=e.current,n=tM();return{version:t,markDirty:_N(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},yP=()=>{let[e]=hN(()=>iM((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=gN((t,n)=>(oM(e,t),t+ +!!n()),0),[,r]=hN(0);return oM(e,t),{root:e,version:t,markDirty:void 0}},bP=()=>{let e=pP(),{root:t,version:n,markDirty:r}=nM()?vP():yP();return{version:n,createFiber:vN((n,i,a)=>iP(n,t,a?()=>{a(),r?.()}:r,e()),[])}},xP=(e,t,n)=>{let r=Y(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,X(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&SM(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function SP(e){let{version:t,createFiber:n}=bP(),r=_N(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=xP(()=>({value:sP(r,e.args)}),[r,t,e.args],WM(r));return X(()=>()=>oP(r),[r]),X(()=>{cP(r)},[r,i]),i.value}var CP=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},wP=(e,t)=>!e.isDirty&&!WM(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&SM(e.committedDeps,t),TP=e=>{if(!UM())return!1;for(let{fiber:t}of e.values())if(WM(t))return!0;return!1};function EP(e){let[t]=hN(()=>new Map),{version:n,createFiber:r}=bP(),i=TP(t),a=xP(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>CP(t,c));l={fiber:e,next:{value:sP(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>CP(t,c)),n=sP(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(wP(l,s.deps))typeof l.next==`object`&&aP(l.fiber),l.fiber.contextDeps&&HM(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=sP(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return X(()=>()=>{for(let e of t.keys())oP(t.get(e).fiber)},[t]),X(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(oP(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&cP(n.fiber):(r.remount&&(oP(n.fiber),n.fiber=r.remount),cP(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var DP=e=>e(),OP=e=>{let{createFiber:t}=bP(),n=_N(()=>t(DP,void 0),[t]),r=sP(n,[e]);X(()=>()=>{oP(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,cP(n))};return X(a),{value:r,effects:a}},kP=PN(()=>{let e=J(4),[t,n]=hN(AP),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{let r=_M(n.renderers);return r[e]=[...r[e]??[],t],{...n,renderers:r}}),()=>{n(n=>{let r=_M(n.renderers),i=r[e]?.filter(e=>e!==t)??[];return i.length>0?r[e]=i:delete r[e],{...n,renderers:r}})}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function AP(){return{renderers:_M(),fallbacks:[]}}var jP=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},MP=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n=_M();return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools!==void 0&&Object.hasOwn(e.tools,i)?e.tools[i]:void 0;if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=jP(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=jP({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||=_M(),e.tools[i]=jP(a),Object.hasOwn(n,i)||(n[i]=r)}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...e.unstable_composerMetadata,...t.unstable_composerMetadata}),e},{})},NP=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},PP=e=>e,FP=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),IP=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!FP.has(e))return!1}},LP=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},RP=Symbol(`assistant-ui.store.clientId`),zP=Symbol(`assistant-ui.store.instanceTag`),BP=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===RP?WP(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===RP||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(typeof n!=`symbol`&&n in t())return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},VP=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===RP)return n();let i=IP(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},HP=e=>e?.source!=null,UP=e=>e?.source===null,WP=e=>e[RP]??e,GP=e=>e[zP]??WP(e),KP=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,qP=e=>{let t=[];for(let n in e)KP(n)||t.push(n);return t},JP=class extends LP{#e;constructor(e){super(),this.#e=e}get(e,t){let n=IP(t,`OptionalAssistantClient`);if(n!==!1)return n;if(KP(t))return;let r=this.#e[t];return HP(r)?r:void 0}ownKeys(){return qP(this.#e)}has(e,t){return!KP(t)&&t in this.#e}},YP=e=>new Proxy({},new JP(e)),XP=()=>()=>{},ZP=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,QP=class extends LP{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return XP;if(t===`optional`)return this.#r??=YP(this.#n());let n=IP(t,this.#e);return n===!1?VP(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},$P=((e,t)=>{let n=new Proxy({},new QP(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>ZP),eF=()=>new Proxy({},{get(e,t){let n=IP(t,`AssistantClient`);return n===!1?VP(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),tF=jN($P),nF=()=>{},rF=new WeakMap,iF=e=>rF.get(e)??nF,aF=(e,t)=>{rF.set(e,t)},oF=()=>NN(tF),sF=(e,t)=>LM(tF,e,t),cF=Symbol(`assistant-ui.transform-scopes`);function lF(e,t){let n=e;if(n[cF])throw Error(`transformScopes is already attached to this resource`);n[cF]=t}function uF(e){return e[cF]}var dF=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},fF=e=>{console.error(`NotificationManager: event listener error`,e)},pF=(e,t,n)=>{try{let r=e(t,n);r!==null&&(typeof r==`object`||typeof r==`function`)&&typeof r.then==`function`&&Promise.resolve(r).catch(fF)}catch(e){fF(e)}},mF=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.get(n)===a&&e.delete(n)}},emit(n,r,i){(e.has(n)||t.size!==0)&&queueMicrotask(()=>{let a=e.get(n);if(a)for(let e of a)pF(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)pF(n,e,i)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},hF=()=>hN(mF)[0],gF=Symbol(`assistant-ui.store.clientIndex`),_F=e=>e[gF],vF=jN([]),yF=()=>MN(vF),bF=(e,t)=>{let n=J(3),r=yF(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],LM(vF,i,t)},xF=jN(null),SF=Symbol(`aui.scope-effect-unapplied`),CF=(e,t)=>LM(xF,e,t),wF=()=>{let e=MN(xF);if(!e)throw Error(`AssistantTapContext is not available`);return e},TF=()=>wF().clientRef,EF=(e,t,n)=>{let r=J(8),{clientRef:i}=wF(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&HP(t)?GP(t):void 0},a=SF,o,s=e=>{if(o?.(),o=void 0,a=SF,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],X(a,o)},DF=()=>{let e=J(3),{emit:t}=wF(),n=yF(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],bN(r)},OF=jN(void 0),kF=(e,t)=>{let n=MN(OF);return LM(OF,e??n,t)},AF=()=>{let e=J(3),[t]=hN(jF),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>()=>queueMicrotask(()=>t.abort()),r=[t],e[0]=t,e[1]=n,e[2]=r),CN(n,r),t.signal};function jF(){return new AbortController}var MF=Symbol(`assistant-ui.store.getValue`),NF=e=>{let t=e[MF];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},PF=new Map;function FF(e){let t=PF.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[MF];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},PF.set(e,t)),t}var IF=class extends LP{boundFns;cachedReceiver;outputRef;tagRef;index;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===MF)return this.outputRef.current;if(t===gF)return this.index;if(t===zP)return this.tagRef.current;let r=IP(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=FF(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===MF||t===gF||t===zP||t in this.outputRef.current}},LF=e=>{let t=Y(null),n=Y(null),r=_N(()=>({}),[e.hook,e.key]),i=yF().length,a=_N(()=>new Proxy({},new IF(t,n,i)),[i]),o=bF(a,function(){return SP(e)});return t.current||(t.current=o,n.current=r),X(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},RF=PN(LF),zF=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},BF=e=>{let t=_N(()=>({}),[]);return t.v!==void 0&&zF(t.v,e)?t.v:(t.v=e,e)},VF=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&zF(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},HF=(()=>{try{return!1}catch{return!1}})(),UF=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=uF(e.hook);if(a){a(n,t),i=!0;break}}}return n},WF=e=>e.hook===pI,GF=e=>{if(!WF(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},KF=Symbol.for(`aui.event-receiver-ref`),qF=(e,t)=>{let n=e===$P?eF():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=YP(r),enumerable:!1}),r},JF=({notifications:e,clientRef:t})=>_N(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=dF(n),o=n[KF];if(i!==`*`&&!o&&UP(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`)return r(e);let a=((o??t).current??this)[i];if(!HP(a))return;let s=WP(a);if(s===n[_F(s)])return r(e)});if(i!==`*`){if(o){if(t.parent===$P)return s}else if(UP(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),YF=e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=GF(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=BF(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],BF(o)},XF=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=t?e:RF(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],SP(r)},ZF=PN((e,t)=>{let n=oF(),r=WF(t),i=XF(t,r),a=r?i:i.methods,o=YF(t),s=_N(()=>BP({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),QF=e=>{let t=J(2),n;return t[0]===e?n=t[1]:(n=e.map(cI),t[0]=e,t[1]=n),EP(n)},$F=(e,t)=>{let n=BF(t),r=_N(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},eI=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=qF(e,JF({notifications:r,clientRef:n}));return{client:$F(i,[e,...CF({clientRef:n,emit:r.emit},function(){return sF(i,function(){return QF(t)})})])}},tI=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=OP(function(){let i=hF(),{client:a}=kF(n,function(){return eI({parent:e,entries:t,clientRef:r,notifications:i})});return X(()=>e.subscribe(i.notifySubscribers),[e,i]),X(()=>i.notifySubscribers()),a});return CN(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},nI=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=OP(function(){let i=hF(),a=_P(function(){return kF(n,function(){return eI({parent:e,entries:t,clientRef:r,notifications:i})})}),o=xN(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return X(()=>{let t=()=>qN(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return CN(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},rI=(e,t,n,r)=>{let{get:i}=r.args[0],a=xN(e.subscribe,()=>i(e),()=>i(e)),o=YF(r),s=_N(()=>BP({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},iI=(e,t)=>{if(HF){let[e]=hN(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!WF(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=Y({parent:e,current:null}).current,r=qF(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=dF(t);if(i===`*`)return e.on(t,r);let o=t[KF];if(!o&&UP(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[KF]:o??n},r)}}),i=$F(r,[e,...t.map(([t,n])=>rI(e,r,t,n))]);return CN(()=>{n.parent=e,n.current=i},[i,e,n]),i},aI=(e,t)=>{let n=J(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(UF(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(lI),n[3]=i,n[4]=a);let[o]=hN(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},oI=(e,t,n,r)=>{let{entries:i,rooted:a}=aI(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:iI(e,i)}},sI=(e,t,n)=>oI(e,t,tI,n);function Q(e){let t=oF();if(e){let{client:n,effects:r}=oI(t,e,nI,AF());return r&&aF(n,r),n}return t}function cI(e){let[t,n]=e;return FN(t,ZF(t,n))}function lI(e){let[,t]=e;return!WF(t)}var uI=e=>{let t;class n extends LP{get(t,n){let r=IP(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!KP(i)&&HP(e[i]))return NF(e[i]())}ownKeys(){return qP(e)}has(t,n){return!KP(n)&&n in e}}class r extends LP{get(r,i){let a=IP(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!KP(o))return NF(e[o]())}ownKeys(){return[...qP(e),`optional`]}has(t,n){return n===`optional`||!KP(n)&&n in e}}return new Proxy({},new r)},dI=new WeakMap,fI=e=>{let t=dI.get(e);return t||(t=uI(e),dI.set(e,t)),t},$=e=>{let t=J(6),n=Q(),r;t[0]===n?r=t[1]:(r=fI(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=xN(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return SN(s),s},pI=e=>{let t=J(3),{get:n}=e,r=Q(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],$(i)},mI=PN(pI),hI=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function gI(e){let t=J(12),n;t[0]===e?n=t[1]:(n=e.map(yI),t[0]=e,t[1]=n);let r=EP(n),i;t[2]===e?i=t[3]:(i=e.reduce(vI,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(_I),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function _I(e){return e.state}function vI(e,t,n){return e[hI(t)]=n,e}function yI(e){return FN(hI(e),RF(e),e.deps)}var bI=(e,t=0)=>t===0?Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight:e.scrollHeight-t-e.scrollTop-e.clientHeight<=1||e.scrollHeight-t<=e.clientHeight,xI=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,SI=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,CI=Symbol(`skip-update`),wI=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}},TI=e=>{wI(e)},EI=(e,t)=>e===void 0||t===void 0?e===t:zF(e,t),DI=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){wI(this._subscribers)}},OI=class extends DI{_state;constructor(e){super(),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}getServerSnapshot;setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},kI=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){NP(this._subscriptions,e,t);return}wI(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{let e=this._connection;this._connection=void 0,e?.()}}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},AI=class extends kI{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===CI)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===CI||EI(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},jI=class extends kI{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==CI&&(this._previousState===void 0||!EI(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},MI=class extends kI{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();if(r===t)return;t=r;let i=n;n=void 0;try{i?.()}finally{n=r?.subscribe(e),e()}});return()=>TI([()=>r?.(),()=>n?.()])}},NI=class extends kI{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=this.outerSubscribe(()=>{let e=this.config.binding.getState();if(e===n)return;n=e;let i=r;r=void 0;try{i?.()}finally{r=e?.unstable_on(this.config.event,t)}});return()=>TI([()=>i?.(),()=>r?.()])}},PI=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return MP(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}this._providerUnsubscribes.set(t,n),this.notifySubscribers();let r=!1;return()=>{if(r)return;r=!0,this._providers.delete(t);let e=this._providerUnsubscribes.get(t);this._providerUnsubscribes.delete(t);let n=!1,i,a=e=>{try{e()}catch(e){n?console.error(e):(n=!0,i=e)}};if(e&&a(e),a(()=>this.notifySubscribers()),n)throw i}}_subscribers=new Set;notifySubscribers(){wI(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},FI=[],II={modelName:void 0,toolNames:FI},LI=(e,t)=>e===t||zF(e,t),RI=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():FI,a=i.length?i:FI;return r===t.modelName&&LI(a,t.toolNames)?t:{modelName:r,toolNames:a}},zI=PN(()=>{let e=J(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new PI,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>RI(n,II),e[1]=r):r=e[1];let[i,a]=hN(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>RI(n,e)),n.subscribe(()=>{a(e=>RI(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),X(o,s);let c;e[4]===i?c=e[5]:(c=()=>RI(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),BI=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},VI=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,HI=e=>function(t){return BI(e,t)},UI=e=>{let t=J(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[FN(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=EP(i)[0],[o,s]=hN(GI),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=TF(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,renderText:n?.renderText,standalone:n?.standalone??!1};return s(t=>{let n=_M(t);return n[e]=[...n[e]??[],r],n}),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[],i=_M(t);return n.length>0?(i[e]=n,i):(delete i[e],i)})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?HI(i):void 0);a&&e.push(f(t,a,{standalone:VI(r),renderText:i}))}return()=>{e.forEach(KI)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),X(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(qI,_M());return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),EF(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},WI=PN(UI);lF(UI,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=zI())});function GI(){return _M()}function KI(e){return e()}function qI(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var JI=e=>xN(e.subscribe,e.getState,e.getServerSnapshot),YI=Symbol.for(`assistant-ui.silent-runtime-action`),XI=e=>typeof e==`object`&&!!e&&YI in e,ZI=(e,t)=>{let n=t();return n.catch(t=>{XI(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},QI=PN(e=>{let t=J(9),{runtime:n}=e,r=JI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>ZI(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),$I=PN(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=QI({runtime:a}),t[3]=a,t[4]=o),SP(o)}),eL=PN(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),tL=PN(e=>{let t=J(63),{threadIdRef:n,messageIdRef:r,runtime:i,isSuggestion:a}=e,o=JI(i),s=DF(),c=Y(!1),l,u;t[0]!==s||t[1]!==r||t[2]!==i||t[3]!==n?(l=()=>{let e=[],t=i.unstable_on(`send`,e=>{let t=c.current;c.current=!1,s(`composer.send`,{threadId:n.current,...r&&{messageId:r.current},chars:e.chars,attachments:e.attachments,...t?{suggestion:!0}:void 0})});e.push(t);let a=i.unstable_on(`attachmentAdd`,e=>{s(`composer.attachmentAdd`,{threadId:n.current,...r&&{messageId:r.current},...e.contentType?{contentType:e.contentType}:void 0})});return e.push(a),e.push(i.unstable_on(`attachmentAddError`,e=>{s(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message,...e.contentType?{contentType:e.contentType}:void 0})})),()=>{for(let t of e)t()}},u=[i,s,n,r],t[0]=s,t[1]=r,t[2]=i,t[3]=n,t[4]=l,t[5]=u):(l=t[4],u=t[5]),X(l,u);let d;if(t[6]!==i||t[7]!==o.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>FN(e.id,$I({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),d=o.attachments.map(e),t[6]=i,t[7]=o.attachments,t[8]=d}else d=t[8];let f=gI(d),p=o.queue,m;if(t[11]!==p||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>FN(e.id,eL({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),m=p.map(e),t[11]=p,t[12]=i,t[13]=m}else m=t[13];let h=gI(m),g=o.type??`thread`,_;t[16]!==f.state||t[17]!==p||t[18]!==o.attachmentAccept||t[19]!==o.canCancel||t[20]!==o.canSend||t[21]!==o.dictation||t[22]!==o.isEditing||t[23]!==o.isEmpty||t[24]!==o.quote||t[25]!==o.role||t[26]!==o.runConfig||t[27]!==o.text||t[28]!==g?(_={text:o.text,role:o.role,attachments:f.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:g,dictation:o.dictation,quote:o.quote,queue:p},t[16]=f.state,t[17]=p,t[18]=o.attachmentAccept,t[19]=o.canCancel,t[20]=o.canSend,t[21]=o.dictation,t[22]=o.isEditing,t[23]=o.isEmpty,t[24]=o.quote,t[25]=o.role,t[26]=o.runConfig,t[27]=o.text,t[28]=g,t[29]=_):_=t[29];let v=_,y;t[30]===v?y=t[31]:(y=()=>v,t[30]=v,t[31]=y);let b;t[32]!==a||t[33]!==i?(b=e=>{let t=i.getState();c.current=t.canSend&&(a?.(t.text)??!1),i.send(e)},t[32]=a,t[33]=i,t[34]=b):b=t[34];let x;t[35]!==s||t[36]!==r||t[37]!==i||t[38]!==n?(x=()=>{!r&&i.getState().canCancel&&s(`composer.cancel`,{threadId:n.current}),i.cancel()},t[35]=s,t[36]=r,t[37]=i,t[38]=n,t[39]=x):x=t[39];let S=i.beginEdit??nL,C;t[40]===f?C=t[41]:(C=e=>`id`in e?f.get({key:e.id}):f.get(e),t[40]=f,t[41]=C);let w;t[42]===h?w=t[43]:(w=e=>`id`in e?h.get({key:e.id}):h.get(e),t[42]=h,t[43]=w);let T;t[44]===i?T=t[45]:(T=()=>i,t[44]=i,t[45]=T);let E;return t[46]!==i.addAttachment||t[47]!==i.clearAttachments||t[48]!==i.reset||t[49]!==i.setQuote||t[50]!==i.setRole||t[51]!==i.setRunConfig||t[52]!==i.setText||t[53]!==i.startDictation||t[54]!==i.stopDictation||t[55]!==S||t[56]!==C||t[57]!==w||t[58]!==T||t[59]!==y||t[60]!==b||t[61]!==x?(E={getState:y,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:b,cancel:x,beginEdit:S,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:C,queueItem:w,__internal_getRuntime:T},t[46]=i.addAttachment,t[47]=i.clearAttachments,t[48]=i.reset,t[49]=i.setQuote,t[50]=i.setRole,t[51]=i.setRunConfig,t[52]=i.setText,t[53]=i.startDictation,t[54]=i.stopDictation,t[55]=S,t[56]=C,t[57]=w,t[58]=T,t[59]=y,t[60]=b,t[61]=x,t[62]=E):E=t[62],E});function nL(){throw Error(`beginEdit is not supported in this runtime`)}var rL=e=>({get current(){return e()}}),iL=PN(e=>{let t=J(13),{runtime:n}=e,r=JI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),aL=PN(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=QI({runtime:a}),t[3]=a,t[4]=o),SP(o)}),oL=PN(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=iL({runtime:a}),t[3]=a,t[4]=o),SP(o)}),sL=PN(e=>{let t=J(74),{runtime:n,threadIdRef:r,threadId:i}=e,a=JI(n),o=DF(),[s,c]=hN(!1),[l,u]=hN(!1),d;t[0]===n?d=t[1]:(d=rL(()=>n.getState().id),t[0]=n,t[1]=d);let f=d,p=Y(a.status),m;t[2]!==o||t[3]!==n||t[4]!==i?(m=e=>{o(e,{threadId:i,messageId:n.getState().id})},t[2]=o,t[3]=n,t[4]=i,t[5]=m):m=t[5];let h=m,g,_;t[6]!==o||t[7]!==a.id||t[8]!==a.status||t[9]!==i?(g=()=>{let e=a.status,t=p.current;p.current=e,e?.type===`incomplete`&&e.reason===`error`&&(t?.type!==`incomplete`||t.reason!==`error`)&&o(`message.error`,{threadId:i,messageId:a.id,reason:`error`})},_=[a.status,a.id,o,i],t[6]=o,t[7]=a.id,t[8]=a.status,t[9]=i,t[10]=g,t[11]=_):(g=t[10],_=t[11]),X(g,_);let v;t[12]!==f||t[13]!==n.composer||t[14]!==r?(v=tL({runtime:n.composer,threadIdRef:r,messageIdRef:f}),t[12]=f,t[13]=n.composer,t[14]=r,t[15]=v):v=t[15];let y=LF(v),b;if(t[16]!==n||t[17]!==a.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>FN(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,oL({runtime:n,index:t}),[n,t]),t[19]=n,t[20]=e),b=a.content.map(e),t[16]=n,t[17]=a.content,t[18]=b}else b=t[18];let x=gI(b),S;t[21]===a.attachments?S=t[22]:(S=a.attachments??[],t[21]=a.attachments,t[22]=S);let C;if(t[23]!==n||t[24]!==S){let e;t[26]===n?e=t[27]:(e=(e,t)=>FN(e.id,aL({runtime:n,index:t}),[n,t]),t[26]=n,t[27]=e),C=S.map(e),t[23]=n,t[24]=S,t[25]=C}else C=t[25];let w=gI(C),T=a,E;t[28]!==y.state||t[29]!==s||t[30]!==l||t[31]!==x.state||t[32]!==T?(E={...T,parts:x.state,composer:y.state,isCopied:s,isHovering:l},t[28]=y.state,t[29]=s,t[30]=l,t[31]=x.state,t[32]=T,t[33]=E):E=t[33];let D=E,O;t[34]===D?O=t[35]:(O=()=>D,t[34]=D,t[35]=O);let k;t[36]===y.methods?k=t[37]:(k=()=>y.methods,t[36]=y.methods,t[37]=k);let A;t[38]===n?A=t[39]:(A=()=>n.delete(),t[38]=n,t[39]=A);let j,M;t[40]!==h||t[41]!==n?(j=e=>(h(`message.reload`),n.reload(e)),M=()=>(h(`message.speak`),n.speak()),t[40]=h,t[41]=n,t[42]=j,t[43]=M):(j=t[42],M=t[43]);let N,ee;t[44]===n?(N=t[45],ee=t[46]):(N=()=>n.stopSpeaking(),ee=e=>n.submitFeedback(e),t[44]=n,t[45]=N,t[46]=ee);let te;t[47]!==h||t[48]!==n?(te=e=>(h(`message.branchSwitched`),n.switchToBranch(e)),t[47]=h,t[48]=n,t[49]=te):te=t[49];let ne;t[50]===n?ne=t[51]:(ne=()=>n.unstable_getCopyText(),t[50]=n,t[51]=ne);let re;t[52]===x?re=t[53]:(re=e=>`index`in e?x.get({index:e.index}):x.get({key:`toolCallId-${e.toolCallId}`}),t[52]=x,t[53]=re);let ie;t[54]===w?ie=t[55]:(ie=e=>`id`in e?w.get({key:e.id}):w.get(e),t[54]=w,t[55]=ie);let ae;t[56]===h?ae=t[57]:(ae=e=>{e&&h(`message.copied`),c(e)},t[56]=h,t[57]=ae);let oe;t[58]===n?oe=t[59]:(oe=()=>n,t[58]=n,t[59]=oe);let se;return t[60]!==O||t[61]!==k||t[62]!==A||t[63]!==j||t[64]!==M||t[65]!==N||t[66]!==ee||t[67]!==te||t[68]!==ne||t[69]!==re||t[70]!==ie||t[71]!==ae||t[72]!==oe?(se={getState:O,composer:k,delete:A,reload:j,speak:M,stopSpeaking:N,submitFeedback:ee,switchToBranch:te,getCopyText:ne,part:re,attachment:ie,setIsCopied:ae,setIsHovering:u,__internal_getRuntime:oe},t[60]=O,t[61]=k,t[62]=A,t[63]=j,t[64]=M,t[65]=N,t[66]=ee,t[67]=te,t[68]=ne,t[69]=re,t[70]=ie,t[71]=ae,t[72]=oe,t[73]=se):se=t[73],se}),cL=e=>{let t=_N(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n?.suggestions[r.length];r.push(t&&zF(t,e)?t:e)});let i=n&&zF(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},lL=PN(e=>({getState:()=>e})),uL=e=>{let t=J(9),n=cL(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(fL),t[0]=n.suggestions,t[1]=r);let i=gI(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},dL=PN(e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e.map(pL),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),uL(r)});function fL(e,t){return FN(t,lL(e),[e])}function pL(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var mL=Object.freeze({type:`complete`}),hL=Object.freeze({type:`running`}),gL=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),_L=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return hL;if(n===`complete`)return mL;if(n!==`incomplete`)return;let{reason:r}=t;return gL[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},vL=(e,t,n)=>{if(e.role!==`assistant`)return mL;if(n.type===`tool-call`)return n.result===void 0?e.status:mL;if(e.status.type===`running`){let e=_L(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?mL:r?e.status:mL},yL=e=>`reason`in e?e.reason:void 0,bL=e=>`error`in e?e.error:void 0,xL=32,SL=new WeakMap,CL=e=>SL.get(e)??e.id,wL=(e,t,n)=>`status`in e&&e.status?vL(e,t,n):mL,TL=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>xL))for(let[l,u]of e.entries())for(let[e,d]of u.content.entries()){if(d.type!==`tool-call`||d.messages===void 0)continue;let f=d.messages,p=wL(u,e,d),m=yL(p),h=bL(p),g=`${c}${l}.${e}`,_=t.get(g),v=_?.part===d&&_.statusType===p.type&&_.statusReason===m&&Object.is(_.statusError,h)&&_.messages===f&&_.task.messageId===u.id&&_.task.parentTaskId===n&&_.task.depth===s?_.task:{id:d.toolCallId,toolName:d.toolName,args:d.args,result:d.result,...d.isError===void 0?void 0:{isError:d.isError},status:p,timing:d.timing,messageId:u.id,parentTaskId:n,depth:s,messages:f};v!==_?.task&&(a=!1,SL.set(v,g)),r.push(v),i.set(g,{task:v,part:d,statusType:p.type,statusReason:m,statusError:h,messages:f}),o(f,v.id,s+1,`${g}.`)}};o(n,null,0,``);let s=a&&r.length===e.length&&r.every((t,n)=>t===e[n])?e:r;return e=s,t=i,s}},EL=PN(({task:e})=>({getState:()=>e})),DL=PN(e=>{let t=J(7),{runtime:n,id:r,threadIdRef:i,threadId:a}=e,o;t[0]!==r||t[1]!==n?(o=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==s||t[4]!==a||t[5]!==i?(c=sL({runtime:s,threadIdRef:i,threadId:a}),t[3]=s,t[4]=a,t[5]=i,t[6]=c):c=t[6],SP(c)}),OL=PN(e=>{let t=J(93),{runtime:n}=e,r=JI(n),i=DF(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return e.push(n.unstable_on(`toolApprovalAnswered`,e=>{let t=n.getState()?.threadId||`unknown`;i(`thread.toolApprovalAnswered`,{threadId:t,...e})})),()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),X(a,o);let s;t[4]===n?s=t[5]:(s=rL(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==i||t[7]!==n?(l=e=>{i(e,{threadId:n.getState().threadId})},t[6]=i,t[7]=n,t[8]=l):l=t[8];let u=l,d;t[9]===n?d=t[10]:(d=e=>n.getState().suggestions.some(t=>t.prompt===e),t[9]=n,t[10]=d);let f=d,p;t[11]!==f||t[12]!==n.composer||t[13]!==c?(p=tL({runtime:n.composer,threadIdRef:c,isSuggestion:f}),t[11]=f,t[12]=n.composer,t[13]=c,t[14]=p):p=t[14];let m=LF(p),h;t[15]===r.suggestions?h=t[16]:(h=dL(r.suggestions),t[15]=r.suggestions,t[16]=h);let g=LF(h),_;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=TL(),t[17]=_):_=t[17];let v=_,y;t[18]===r.messages?y=t[19]:(y=v(r.messages),t[18]=r.messages,t[19]=y);let b=y,x;t[20]===b?x=t[21]:(x=b.map(kL),t[20]=b,t[21]=x);let S=gI(x),C;if(t[22]!==n||t[23]!==r.messages||t[24]!==r.threadId||t[25]!==c){let e;t[27]!==n||t[28]!==r.threadId||t[29]!==c?(e=e=>FN(e.id,DL({runtime:n,id:e.id,threadIdRef:c,threadId:r.threadId}),[n,e.id,c,r.threadId]),t[27]=n,t[28]=r.threadId,t[29]=c,t[30]=e):e=t[30],C=r.messages.map(e),t[22]=n,t[23]=r.messages,t[24]=r.threadId,t[25]=c,t[26]=C}else C=t[26];let w=gI(C),T=w.state.length===0&&!r.isLoading,E;t[31]!==m.state||t[32]!==w.state||t[33]!==r.capabilities||t[34]!==r.extras||t[35]!==r.isDisabled||t[36]!==r.isLoading||t[37]!==r.isRunning||t[38]!==r.speech||t[39]!==r.state||t[40]!==r.suggestions||t[41]!==r.voice||t[42]!==T||t[43]!==b?(E={isEmpty:T,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:m.state,messages:w.state,tasks:b},t[31]=m.state,t[32]=w.state,t[33]=r.capabilities,t[34]=r.extras,t[35]=r.isDisabled,t[36]=r.isLoading,t[37]=r.isRunning,t[38]=r.speech,t[39]=r.state,t[40]=r.suggestions,t[41]=r.voice,t[42]=T,t[43]=b,t[44]=E):E=t[44];let D=E,O;t[45]===D?O=t[46]:(O=()=>D,t[45]=D,t[46]=O);let k;t[47]===m.methods?k=t[48]:(k=()=>m.methods,t[47]=m.methods,t[48]=k);let A;t[49]===g?A=t[50]:(A=()=>g.methods,t[49]=g,t[50]=A);let j;t[51]!==S||t[52]!==b?(j=e=>{if(`id`in e){let t=b.find(t=>t.id===e.id);return S.get({key:t?CL(t):e.id})}return S.get(e)},t[51]=S,t[52]=b,t[53]=j):j=t[53];let M;t[54]!==i||t[55]!==f||t[56]!==n?(M=e=>{let t=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if((t.role??`user`)===`user`){let e=t.content.map(AL).join(``);i(`composer.send`,{threadId:n.getState().threadId,chars:e.length,attachments:t.attachments?.length??0,...f(e)?{suggestion:!0}:void 0})}n.append(e)},t[54]=i,t[55]=f,t[56]=n,t[57]=M):M=t[57];let N;t[58]!==u||t[59]!==n||t[60]!==r.isRunning?(N=()=>{r.isRunning&&u(`thread.cancelRun`),n.cancelRun()},t[58]=u,t[59]=n,t[60]=r.isRunning,t[61]=N):N=t[61];let ee;t[62]!==u||t[63]!==n?(ee=()=>{n.connectVoice(),u(`thread.voiceStarted`)},t[62]=u,t[63]=n,t[64]=ee):ee=t[64];let te;t[65]===w?te=t[66]:(te=e=>`id`in e?w.get({key:e.id}):w.get(e),t[65]=w,t[66]=te);let ne;t[67]===n?ne=t[68]:(ne=()=>n,t[67]=n,t[68]=ne);let re;return t[69]!==n.deleteMessage||t[70]!==n.disconnectVoice||t[71]!==n.export||t[72]!==n.getModelContext||t[73]!==n.getVoiceVolume||t[74]!==n.import||t[75]!==n.importExternalState||t[76]!==n.muteVoice||t[77]!==n.reset||t[78]!==n.resumeRun||t[79]!==n.startRun||t[80]!==n.stopSpeaking||t[81]!==n.subscribeVoiceVolume||t[82]!==n.unmuteVoice||t[83]!==O||t[84]!==k||t[85]!==A||t[86]!==j||t[87]!==M||t[88]!==N||t[89]!==ee||t[90]!==te||t[91]!==ne?(re={getState:O,composer:k,suggestions:A,task:j,append:M,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:N,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:ee,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:te,__internal_getRuntime:ne},t[69]=n.deleteMessage,t[70]=n.disconnectVoice,t[71]=n.export,t[72]=n.getModelContext,t[73]=n.getVoiceVolume,t[74]=n.import,t[75]=n.importExternalState,t[76]=n.muteVoice,t[77]=n.reset,t[78]=n.resumeRun,t[79]=n.startRun,t[80]=n.stopSpeaking,t[81]=n.subscribeVoiceVolume,t[82]=n.unmuteVoice,t[83]=O,t[84]=k,t[85]=A,t[86]=j,t[87]=M,t[88]=N,t[89]=ee,t[90]=te,t[91]=ne,t[92]=re):re=t[92],re});function kL(e){return FN(CL(e),EL({task:e}),[e])}function AL(e){return e.type===`text`?e.text:``}var jL=(e,t)=>ZI(`thread list ${e}`,t),ML=PN(e=>{let t=J(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=JI(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o,c=DF(),{isMain:l,id:u}=a,d;t[3]!==l||t[4]!==u?(d={isMain:l,threadId:u},t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=Y(d),p,m;t[6]!==c||t[7]!==l||t[8]!==u?(p=()=>{let e=f.current;(e.isMain!==l||e.threadId!==u)&&(f.current={isMain:l,threadId:u},c(l?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:u}))},m=[l,u,c],t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=m):(p=t[9],m=t[10]),X(p,m);let h;t[11]===s?h=t[12]:(h=()=>s,t[11]=s,t[12]=h);let g,_,v,y,b,x,S;t[13]===n?(g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20]):(b=e=>jL(`switch`,()=>n.switchTo(e)),x=e=>jL(`rename`,()=>n.rename(e)),S=e=>jL(`update custom metadata`,()=>n.updateCustom(e)),g=()=>jL(`archive`,()=>n.archive()),_=()=>jL(`unarchive`,()=>n.unarchive()),v=()=>jL(`delete`,()=>n.delete()),y=e=>jL(`generate title`,()=>n.generateTitle(e)),t[13]=n,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S);let C;t[21]===n?C=t[22]:(C=()=>n,t[21]=n,t[22]=C);let w;return t[23]!==n.detach||t[24]!==n.initialize||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==y||t[29]!==C||t[30]!==h||t[31]!==b||t[32]!==x||t[33]!==S?(w={getState:h,switchTo:b,rename:x,updateCustom:S,archive:g,unarchive:_,delete:v,generateTitle:y,initialize:n.initialize,detach:n.detach,__internal_getRuntime:C},t[23]=n.detach,t[24]=n.initialize,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=C,t[30]=h,t[31]=b,t[32]=x,t[33]=S,t[34]=w):w=t[34],w}),NL=e=>{let t=J(4),n=DF(),r=Y(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)},PL=PN(e=>{let t=J(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=ML({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],SP(s)}),FL=PN(e=>{let t=J(48),{runtime:n,__internal_assistantRuntime:r}=e,i=JI(n);NL(i.mainThreadId);let a=DF(),o,s;t[0]!==a||t[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:r}=e;t!==n.getState().mainThreadId&&a(`thread.${r}`,{threadId:t})}),s=[n,a],t[0]=a,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),X(o,s);let c;t[4]===n.main?c=t[5]:(c=OL({runtime:n.main}),t[4]=n.main,t[5]=c);let l=LF(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>FN(e,PL({runtime:n,id:e,mainThreadIsRunning:l.state.isRunning}),[n,e,l.state.isRunning])),t[6]=l.state,t[7]=n,t[8]=i.threadItems,t[9]=u):u=t[9];let d=gI(u),f=i.newThreadId??null,p;t[10]!==l.state||t[11]!==i.archivedThreadIds||t[12]!==i.hasMore||t[13]!==i.isLoading||t[14]!==i.isLoadingMore||t[15]!==i.loadError||t[16]!==i.mainThreadId||t[17]!==i.threadIds||t[18]!==f||t[19]!==d.state?(p={mainThreadId:i.mainThreadId,newThreadId:f,isLoading:i.isLoading,loadError:i.loadError,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:d.state,main:l.state},t[10]=l.state,t[11]=i.archivedThreadIds,t[12]=i.hasMore,t[13]=i.isLoading,t[14]=i.isLoadingMore,t[15]=i.loadError,t[16]=i.mainThreadId,t[17]=i.threadIds,t[18]=f,t[19]=d.state,t[20]=p):p=t[20];let m=p,h;t[21]===m?h=t[22]:(h=()=>m,t[21]=m,t[22]=h);let g;t[23]===l.methods?g=t[24]:(g=()=>l.methods,t[23]=l.methods,t[24]=g);let _;t[25]!==m||t[26]!==d?(_=e=>{if(e===`main`)return d.get({key:m.mainThreadId});if(`id`in e)return d.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?m.archivedThreadIds[t]:m.threadIds[t];return d.get({key:r})},t[25]=m,t[26]=d,t[27]=_):_=t[27];let v,y,b,x,S,C;t[28]===n?(v=t[29],y=t[30],b=t[31],x=t[32],S=t[33],C=t[34]):(v=(e,t)=>jL(`switch`,()=>n.switchToThread(e,t)),y=()=>jL(`create`,()=>n.switchToNewThread()),b=()=>n.getLoadThreadsPromise(),x=()=>n.reload(),S=()=>n.reloadMainThread(),C=()=>n.loadMore(),t[28]=n,t[29]=v,t[30]=y,t[31]=b,t[32]=x,t[33]=S,t[34]=C);let w;t[35]===r?w=t[36]:(w=()=>r,t[35]=r,t[36]=w);let T;return t[37]!==v||t[38]!==y||t[39]!==b||t[40]!==x||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==h||t[45]!==g||t[46]!==_?(T={getState:h,thread:g,item:_,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:b,reload:x,reloadMainThread:S,loadMore:C,__internal_getAssistantRuntime:w},t[37]=v,t[38]=y,t[39]=b,t[40]=x,t[41]=S,t[42]=C,t[43]=w,t[44]=h,t[45]=g,t[46]=_,t[47]=T):T=t[47],T}),IL=(e,t)=>{e.thread??=mI({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=mI({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=mI({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=zI()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=mI({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},LL=e=>{let t=J(7),n=TF(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),EF(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=FL({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),SP(a)},RL=PN(LL);lF(LL,(e,t)=>{IL(e,t),!e.tools&&t.tools.source===null&&(e.tools=WI({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=kP())});var zL=e=>{let{children:t,condition:n}=e;return $(n)?t:null};zL.displayName=`AuiIf`;var BL=PP({}),VL=({effects:e})=>{"use no memo";return yN(e),null},HL=Z(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=oF();if(HF){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==$P)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??$P:a?e.value??$P:o,c=AF(),{client:l,effects:u}=sI(s,n??BL,c);return TN(t,()=>l,[l]),(0,b.jsx)(OF.Provider,{value:c,children:(0,b.jsxs)(tF.Provider,{value:l,children:[(0,b.jsx)(VL,{effects:iF(s)}),u&&(0,b.jsx)(VL,{effects:u}),r]})})}),UL=e=>{let t=Q(),n=Y(!1),r=n.current?null:e(t);return $(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},WL=Object.freeze({});function GL(e){let t=J(3),{getItemState:n,children:r}=e,i=UL(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],KL(a)}var KL=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return _N(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?WL:t?.props])??e},qL=(e,t)=>{let n=J(11),r=Q(),i=bN(t),a;n[0]===e?a=n[1]:(a=dF(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],X(c,l)},JL=e=>e._core?.RenderComponent,YL=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=JL(e),a=PP({...n,threads:RL(e)});return(0,b.jsxs)(HL,{extends:t,config:a,children:[i&&(0,b.jsx)(i,{}),r]})},XL=EN(e=>{let t=J(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,b.jsx)(YL,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s});function ZL(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function QL(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>QL(e,t+1)):ZL(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&QL(n,t+1)):!1}var $L=100,eR=(e,t,n)=>{if(e===t)return!0;if(n>$L||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>eR(e,t[r],n+1));if(Array.isArray(t)||!ZL(e)||!ZL(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&eR(e[r],t[r],n+1))},tR=(e,t)=>!QL(e)||!QL(t)?!1:eR(e,t,0);function nR(e){let t=Y(e);return t.current!==e&&!tR(t.current,e)&&(t.current=e),t.current}function rR(e){let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&tR(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r}var iR=Symbol.for(`aui.tool-response`),aR=`<no result>`,oR=class e{get[iR](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?aR:t,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&iR in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?aR:t})}},sR=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},cR=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o=0,s,c,l=()=>(a=void 0,c??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),c),u=e=>{n||r||(r=!0,console.error(e),l(),i.error(e),s?.reject(e),s=void 0)},d=a=>{a.promise||=a.reader.read().then(({done:c,value:l})=>{a.promise=void 0,!(n||r)&&(c?(e.splice(e.indexOf(a),1),a.reader.releaseLock(),t&&e.length===0&&o===0&&i.close()):i.enqueue(l),s?.resolve(),s=void 0)}).catch(u)},f=new ReadableStream({start(e){i=e},pull(){return s=sR(),e.forEach(e=>{d(e)}),s.promise},async cancel(){n=!0;let e=l();s?.resolve(),s=void 0,await e}}),p=c=>{if(e.length>0&&(a=void 0),!a){let c=[];a=c,o++,Promise.resolve().then(()=>{if(o--,a===c&&(a=void 0),!(n||r)){for(let e of c)i.enqueue(e);t&&e.length===0&&o===0&&i.close(),s?.resolve(),s=void 0}}).catch(u)}a.push(c)};return{readable:f,isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&o===0&&i.close())},addStream:(i,o)=>{let s=o?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);a=void 0;let c={reader:i.getReader(),pipeTask:s};e.push(c),d(c)},enqueue(e){if(!(n||r)){if(t)throw Error(`Cannot add streams after the run callback has settled.`);p(e)}}}},lR=e=>e instanceof TypeError,uR=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!lR(e))throw e;n?.(e)}},dR=e=>{try{e.close()}catch(e){if(!lR(e))throw e}},fR=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),pR=(e,t)=>{let n;return[fR({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},mR=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};if(this._isClosed){if(this._strict)throw TypeError(`Cannot append to a closed TextStreamController`);return uR(this._controller,t,this._warnDroppedAfterClose),this}return uR(this._controller,t),this}_warnDroppedAfterClose=e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))};close(){this._isClosed||(this._isClosed=!0,uR(this._controller,{type:`part-finish`,path:[]}),dR(this._controller))}},hR=(e,t={})=>fR(e,e=>new mR(e,t)),gR=(e={})=>pR(t=>new mR(t,e)),_R=class{_isClosed=!1;_mergeTask;_controller;constructor(e,t={}){this._controller=e;let n=hR({start:e=>{this._argsTextController=e}},t),r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:r=!0,uR(this._controller,e);break;case`part-finish`:r||uR(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),uR(this._controller,{type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;uR(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?aR:t,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,uR(this._controller,{type:`part-finish`,path:[]}),dR(this._controller))}},vR=(e={})=>pR(t=>new _R(t,e)),yR=class{value=-1;up(){return++this.value}},bR=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var xR=class extends TransformStream{constructor(e){let t=new yR,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},SR=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},CR=SR(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),wR=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:cR(),contentCounter:new yR}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new bR(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new xR(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=gR({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=gR({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??CR(),[i,a]=vR({strict:this._state.strict});return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function TR(e,t={}){let n=new wR(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function ER(e={}){let{resolve:t,promise:n}=sR(),r;return[TR(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var DR=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},OR=r(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),kR=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},AR=/[0-9a-fA-F]/;function jR(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!AR.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`+`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var MR=n(OR(),1),NR=Symbol(`aui.parse-partial-json-object.meta`),PR=e=>e?.[NR],FR=e=>{if(e.length===0)return{[NR]:{state:`partial`,partialPath:[]}};try{let t=MR.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[NR]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=jR(e),r=MR.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[NR]={state:`partial`,partialPath:n},r}catch{return}}},IR=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return IR(s,{state:`partial`,partialPath:o},i)},LR=(e,t)=>{let n=PR(e);if(!n)throw Error(`unable to determine object state`);return IR(e,n,t.map(String))},RR=new Set([`__proto__`,`constructor`,`prototype`]);function zR(e){if(RR.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var BR=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);let r=[],i=e;for(let e=0;e<t.length;e++){if(i??={},typeof i!=`object`)throw Error(`Invalid path: [${t.slice(e).join(`, `)}]`);let n=t[e];if(zR(n),Array.isArray(i)){let a=Number(n);if(!Number.isInteger(a)||String(a)!==String(n))throw Error(`Expected array index at [${t.slice(e).join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>i.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${i.length}`)),a=i.length}r.push({kind:`array`,state:i,key:a}),i=Object.hasOwn(i,a)?i[a]:void 0}else{let e=i;r.push({kind:`object`,state:e,key:n}),i=Object.hasOwn(e,n)?e[n]:void 0}}let a=n(i);for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.kind===`array`){let e=[...t.state];e[t.key]=a,a=e}else{let e={...t.state};e[t.key]=a,a=e}}return a}},VR=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},HR=(e,t)=>({...e,parts:t,get content(){return this.parts}}),UR=(e,t)=>HR(e,[...e.parts,t]),WR=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),GR=16,KR=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:HR(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},qR=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return UR(e,{type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`tool-call`)return UR(e,{type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}});if(r.type===`source`)return UR(e,{type:`source`,sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`file`)return UR(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return UR(e,{type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}});{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),UR(e,{type:`reasoning`,text:``,status:{type:`running`}})}},JR=(e,t,n)=>KR(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`,status:e.status.type===`running`?{type:`running`,isArgsComplete:!0}:e.status}:e:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),YR=(e,t,n)=>KR(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),XR=(e,t,n)=>KR(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=FR(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),ZR=(e,t,n)=>KR(e,t,n,e=>e.type===`tool-call`?{...e,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}:(n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e)),QR=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=$R(t);return{...e,status:n}},$R=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},ez=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),tz=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),nz=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),rz=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:CR(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},iz=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},az=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),oz=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},sz=(e,t,n=0)=>{let r=n>0?n:oz(t);if(r>0)return e.getTiming(r);let i=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(i+=e.text);return e.getTiming(void 0,i||void 0)},cz=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},lz=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??WR(),a,o,s=new VR,c=new Set,l=(e,t)=>{c.has(e)||c.size>=GR||(c.add(e),console.warn(t))},u,d=t?cz(()=>{u?.enqueue(i)}):()=>{u?.enqueue(i)};super({start(e){u=e},transform(e){s.recordChunk();let t=e.type;switch(t){case`part-start`:i=qR(i,e,l),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=JR(i,e,l);break;case`part-finish`:i=YR(i,e,l);break;case`text-delta`:{let t=XR(i,e,l);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=ZR(i,e,l);break;case`message-finish`:o=e.usage?.outputTokens,i=QR(i,e);break;case`annotations`:i=ez(i,e);break;case`data`:i=tz(i,e);break;case`step-start`:i=nz(i,e);break;case`step-finish`:i=rz(i,e);break;case`error`:i=iz(i,e),n?.(e.error);break;case`update-state`:a??=new BR(i.metadata.unstable_state,{strict:r}),i=az(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:sz(s,i,o)}}),d()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&e.result===void 0)??!1;i=QR(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:sz(s,i,o)}},e.enqueue(i)}}})}};async function*uz(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function dz(e){return e[Symbol.asyncIterator]??=uz,e}var fz=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new lz))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return dz(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function pz(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function mz(e,t){let n=e;for(let e of t){if(n==null||!Object.hasOwn(n,e))return;n=n[e]}return n}var hz=class{resolve;reject;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(LR(e,this.fieldPath)===`complete`){let t=mz(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=mz(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},gz=class{controller;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=mz(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),LR(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},_z=class{controller;disposed=!1;fieldPath;lastValue=void 0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=mz(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}LR(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},vz=class{controller;disposed=!1;fieldPath;nextIndex=0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=mz(e,this.fieldPath);if(!Array.isArray(t))return;for(;this.nextIndex<t.length&&LR(e,[...this.fieldPath,this.nextIndex])===`complete`;this.nextIndex++)this.controller.enqueue(t[this.nextIndex]);LR(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},yz=class{argTextDeltas;handles=new Set;accumulatedText=``;parsedTextLength=-1;args=void 0;finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=this.argTextDeltas.getReader();for(;;){let{value:t,done:n}=await e.read();if(n)break;this.accumulatedText+=t,this.handles.size!==0&&this.parseCurrentArgs()&&this.updateHandles()}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}parseCurrentArgs(){if(this.parsedTextLength===this.accumulatedText.length)return!1;let e=FR(this.accumulatedText);return this.parsedTextLength=this.accumulatedText.length,e===void 0?(this.args??=FR(``),!1):(this.args=e,!0)}updateHandles(){for(let e of this.handles)e.update(this.args),e.isDisposed&&this.handles.delete(e)}activateHandle(e){if(this.parseCurrentArgs(),e.update(this.args),!e.isDisposed){if(this.finished){e.end(this.args);return}this.handles.add(e)}}get(...e){return new Promise((t,n)=>{let r=new hz(t,n,e);this.activateHandle(r)})}streamValues(...e){let t=e,n;return dz(new ReadableStream({start:e=>{n=new gz(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return dz(new ReadableStream({start:e=>{n=new _z(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return dz(new ReadableStream({start:e=>{n=new vz(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},bz=class{promise;constructor(e){this.promise=e}get(){return this.promise}},xz=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new yz(e.readable);let{promise:t,resolve:n}=sR();this.resolve=n,this.response=new bz(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},Sz=Symbol.for(`assistant-stream.tool-execution-id`),Cz=(e,t,n,r,i)=>{try{let a=t?.(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},wz=e=>e.join(`,`),Tz=(e,t)=>{let n={...e};return Object.defineProperty(n,Sz,{value:t,enumerable:!0}),n},Ez=class extends DR{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({async transform(e,s){let c=a.get(wz(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?Tz(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new xz,o=Symbol();a.set(String(n),o),r.set(o,i),t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(wz(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);await n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(wz(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new oR({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent,messages:e.messages})),i.add(t);break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(wz(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(await u.finishArgsText(),i.has(l))break;let d=!1,f=pz(()=>{let e;try{e=MR.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,Cz(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&Cz(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new oR({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),uR(s,Tz({type:`result`,path:e.path,...r},l))},n=>{d&&Cz(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new oR({result:String(n),isError:!0});u.setResponse(r),uR(s,Tz({type:`result`,path:e.path,...r},l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(wz(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(wz(e.path)))};o?o.then(()=>{c(),uR(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new kR).pipeThrough(s)})}},Dz=Symbol.for(`assistant-stream.tool-execution-id`),Oz=Symbol(`assistant-stream.tool-aborted`),kz=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,Az=e=>typeof e?.then==`function`,jz=async(e,t,n=!1)=>{let r,i=new Promise(e=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>e(Oz))):e(Oz)},t.aborted?r():t.addEventListener(`abort`,r,{once:!0})});try{return await Promise.race([e,i])}finally{t.removeEventListener(`abort`,r)}},Mz=()=>new oR({result:`Tool execution was cancelled.`,isError:!0});function Nz(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return Mz();let a=e;if(kz(i.parameters)){let e=i.parameters[`~standard`].validate(n.args),r=Az(e)?await jz(e,t):e;if(r===Oz)return Mz();r.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(r.issues)}`)}))}if(t.aborted)return Mz();let o=await jz((async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[Dz]:n.executionId},o=await a(n.args,e),s=oR.toResponse(o);if(i.toModelOutput&&!s.isError&&s.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:s.result});return new oR({result:s.result,artifact:s.artifact,isError:s.isError,messages:s.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return s})(),t,!0);return o===Oz?Mz():o})(i.execute):void 0}function Pz(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[Dz]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function Fz(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new Ez({execute:e=>Nz(i(),a(),e,s),streamCall:({reader:e,...t})=>Pz(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}var Iz=new Set([`http://json-schema.org/draft-07/schema`,`https://json-schema.org/draft-07/schema`]);function Lz(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}function Rz(e){return typeof e==`object`&&!!e&&`toJSONSchema`in e&&typeof e.toJSONSchema==`function`}function zz(e){return typeof e==`object`&&!!e&&`toJSON`in e&&typeof e.toJSON==`function`}function Bz(e){if(typeof e==`object`&&e){let t=e.$schema;if(typeof t==`string`&&!Iz.has(t.replace(/#$/,``)))throw Error(`The schema library was asked for a draft-07 JSON Schema and returned "${t}". Upgrade the library, or pass a plain JSON Schema object instead.`)}return e}function Vz(e){if(Lz(e)){let t=e[`~standard`].jsonSchema;if(typeof t==`object`&&t&&typeof t.input==`function`)return Bz(t.input({target:`draft-07`}))}if(Rz(e))return e.toJSONSchema({target:`draft-07`});if(zz(e))return e.toJSON();if(Lz(e)){let{vendor:t}=e[`~standard`],n=t===`zod`?`convert it with z.toJSONSchema(schema)`:`wrap the schema with ${t}'s Standard JSON Schema helper`;throw Error(`Could not convert the "${t}" schema to JSON Schema: it has no "~standard.jsonSchema" converter. Upgrade ${t} to a release that implements Standard JSON Schema, ${n}, or pass a plain JSON Schema object instead.`)}return e}function Hz(e){let{required:t,...n}=e;return n.properties&&=Object.fromEntries(Object.entries(n.properties).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?[e,Hz(t)]:[e,t])),n}function Uz(e){return nR(_N(()=>{try{let t=Vz(e);return QL(t)?t:null}catch{return null}},[e]))}var Wz=e=>{let t=J(17),n=Q(),r;t[0]===e?r=t[1]:(r=t=>t.unstable_interactables.definitions[e]?.state,t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>t.unstable_interactables.persistence[e],t[2]=e,t[3]=a);let o=$(a),s;t[4]!==n||t[5]!==e?(s=t=>{n.unstable_interactables.setState(e,e=>typeof t==`function`?t(e):t)},t[4]=n,t[5]=e,t[6]=s):s=t[6];let c=s,l;t[7]===n?l=t[8]:(l=()=>n.unstable_interactables.flush(),t[7]=n,t[8]=l);let u=l,d=o?.isPending??!1,f=o?.error,p;t[9]!==u||t[10]!==c||t[11]!==d||t[12]!==f?(p={setState:c,isPending:d,error:f,flush:u},t[9]=u,t[10]=c,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==i||t[15]!==p?(m=[i,p],t[14]=i,t[15]=p,t[16]=m):m=t[16],m};function Gz(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function Kz(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var qz=e=>{if(!ZL(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function Jz(e,t,n){let r=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(r=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);r=r.filter(t=>{let n=qz(t);return n===void 0?!e.has(t):!e.has(n)})}let i=t.update;if(Array.isArray(i)&&i.length>0){let e=new Map;for(let t of i){let n=qz(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}r=r.map(t=>{let n=qz(t);if(n===void 0||!ZL(t))return t;let r=e.get(n);return r?{...t,...r}:t})}if(Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!ZL(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;r=[...r,...e]}return r}function Yz(e,t,n){if(!ZL(e)||!ZL(t))return t;let r=ZL(n?.arrayBaseline)?n.arrayBaseline:e,i=Object.entries(e);for(let[e,a]of Object.entries(t)){let t=r[e];if(Array.isArray(t)&&ZL(a)){let r=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0;i.push([e,Jz(t,a,r)])}else i.push([e,a])}return Object.fromEntries(i)}function Xz(e,t){if(!ZL(e)||!ZL(t))return;for(let n of Object.keys(e))if(!Object.hasOwn(t,n))return;let n=[];for(let[r,i]of Object.entries(t))(!Object.hasOwn(e,r)||!tR(e[r],i))&&n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var Zz=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},Qz=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=ZL(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},$z=e=>{let t=ZL(e)?e.addedItemIds:void 0;if(!ZL(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},eB=new WeakMap;function tB(e,t,n){let r=eB.get(e);r||(r=new Map,eB.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=Kz(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=Gz(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:Yz(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=Zz(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&Qz(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=$z(r.result);s.push({state:i?Yz(e.state,n,{idFactory:i}):Yz(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function nB(e,t,n){let r=tB(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function rB(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=nB(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(tR(r.state,n.state))continue;let i=Xz(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var iB=(e,t)=>{let n=Q(),r=wN().replace(/[^a-zA-Z0-9]/g,``),i=Kz(e),a=$(e=>{let t=e.optional.part;return t?.type===`tool-call`?t:void 0}),o;if(a?.toolName===i){let e=a.result,t=a.args;e?.success!==!1&&(typeof e?.id==`string`?o=e.id:typeof t?.id==`string`&&(o=t.id))}let s=t.id??o??r,c=a?.toolName===e||a?.toolName===i?`thread`:void 0,l=Y(t.stateSchema);l.current=t.stateSchema;let u=Uz(t.stateSchema),d=Y(t.initialState);d.current=t.initialState;let f=$(()=>n.unstable_interactables);X(()=>f.register({id:s,name:e,description:t.description,stateSchema:l.current,initialState:d.current,updateRender:t.updateRender,...c?{scope:c}:{}}),[f,s,e,t.description,u,c,t.updateRender]);let p=a?.toolCallId,[m,h]=Wz(s),{setState:g}=h,_=$(rR(t=>{if(!c||!p)return;let n=tB(t.thread.messages,s,e);if(!n.some(e=>e.origin===`create`&&e.toolCallId===s))return;let r=n.find(e=>e.toolCallId===p);if(!r)return;let i=n.findLast(e=>e.toolCallId!==void 0)?.toolCallId;return{state:r.state,isLatest:i===p}})),v=_N(()=>_&&{state:_.state,isLatest:_.isLatest,restore:()=>g(_.state)},[_,g]);return[m===void 0?t.initialState:m,{id:s,version:v,...h}]},aB=jN(null),oB=(e,t)=>LM(aB,e,t),sB=()=>NN(aB),cB={},lB=e=>{let t=BF(e??cB);return e==null?null:t},uB=Symbol(`innerMessage`),dB=Symbol(`innerMessages`),fB=[],pB=(e,t)=>{uB in e||(e[uB]=t)},mB=e=>{let t=`messages`in e?e.messages:e,n=t[dB]||t[uB];return n?Array.isArray(n)?n:(t[dB]=[n],t[dB]):fB},hB=`__external_store_fallback_`,gB=SR(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7);function _B(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var vB=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},yB=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?_B(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId||`tool-${gB()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:FR(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=vB(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=vB(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>vB(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},bB=e=>e.type===`tool-call`&&e.result===void 0,xB=e=>{if(e.type!==`tool-call`||e.result!==void 0)return!1;let t=e.messages?.at(-1);return t?.role===`assistant`&&t.status.type===`running`},SB=e=>e.type!==`tool-call`||e.result!==void 0?!1:e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,CB=Symbol(`autoStatus`),wB=Object.freeze(Object.assign({type:`running`},{[CB]:!0})),TB=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[CB]:!0})),EB=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[CB]:!0})),DB=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[CB]:!0})),OB=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[CB]:!0})),kB=e=>e[CB]===!0,AB=(e,t,n,r,i,a,o)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[CB]:!0}):e&&t?wB:n?OB:o&&!a?wB:r?DB:a?EB:TB,jB=e=>AB(!1,!1,typeof e!=`string`&&e.some(SB),typeof e!=`string`&&e.some(bB)),MB=(e,t,n)=>AB(t,n,typeof e!=`string`&&e.some(SB),typeof e!=`string`&&e.some(bB),void 0,void 0,typeof e!=`string`&&e.some(xB)),NB=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},PB=(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},FB=500,IB=({adapterRef:e,snapshot:t,updatePersistenceStatus:n})=>{let r=Y(void 0),i=Y(0),a=Y(new Map),o=Y(0),s=Y([]),c=Y(new Set),l=Y([]),u=Y(()=>{}),d=vN(e=>{if(c.current.size===0)return;let n=new Set(c.current);c.current.clear();let r=++i.current;for(let e of n)a.current.set(e,r);return{adapter:e,payload:t(),dirtyIds:n,seq:r}},[t]),f=vN(e=>{let t=d(e);t&&(o.current===0?u.current(t):l.current.push(t))},[d]),p=vN(async t=>{let i=t??(e.current?d(e.current):void 0);if(!i){if(o.current===0){for(let e of s.current)e();s.current=[]}return}let{adapter:f,payload:p,dirtyIds:m,seq:h}=i;o.current+=1,n(e=>{let t=_M(e);for(let e of m)t[e]={isPending:!0,error:void 0};return t});let g=e=>{let t=[];for(let e of m)a.current.get(e)!==h||c.current.has(e)||(a.current.delete(e),t.push(e));t.length!==0&&n(n=>{let r=!1,i=_M(n);for(let a of t)n[a]!==void 0&&(e===void 0?delete i[a]:i[a]=e,r=!0);return r?i:n})};try{await f.save(p),g(void 0)}catch(e){g({isPending:!1,error:e})}finally{--o.current;let t=l.current.shift()??(e.current&&c.current.size>0?d(e.current):void 0);if(t)r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),u.current(t);else if(o.current===0){for(let e of s.current)e();s.current=[]}}},[e,d,n]);return u.current=e=>{p(e)},{flushIfPending:vN(()=>{r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),e.current&&f(e.current)},[e,f]),schedulePersistence:vN(t=>{e.current&&(c.current.add(t),r.current!==void 0&&clearTimeout(r.current),r.current=setTimeout(()=>{r.current=void 0,o.current===0&&e.current?f(e.current):r.current=setTimeout(()=>{r.current=void 0,e.current&&f(e.current)},FB)},FB))},[e,f]),flush:vN(async()=>{if(r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),!(o.current>0||c.current.size>0||l.current.length>0))return;let t=new Promise(e=>{s.current.push(e)});return e.current&&f(e.current),t},[e,f])}},LB={type:`string`,description:`The id of the instance to update, as shown in its state snapshot in the conversation.`},RB={type:`string`,description:`The id of an item currently in this list.`},zB=e=>{let t=e.properties;return ZL(t)&&t.id!==void 0},BB=e=>({...e,required:[`id`]}),VB=e=>{let{id:t,...n}=ZL(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(e=>e!==`id`):e.required;return{...e,properties:n,required:r}},HB=(e,t)=>{if(!ZL(e)||e.type!==`array`)return e;let n=e.items;if(Array.isArray(n)||!ZL(n))return e;let r=zB(n),i={add:{type:`array`,items:r?VB(n):n},remove:{type:`array`,items:r?RB:n},clear:{type:`boolean`}};return r&&(i.update={type:`array`,items:BB(n)}),{type:`object`,description:`Operations for array field "${t}". To change one item use update with its id; add new items (their ids are assigned for you), remove items by id, or clear to empty. Change only the items you mean to — never resend the whole array to edit one item.`,properties:i,additionalProperties:!1}},UB=e=>{let t=new Set;for(let[n,r]of Object.entries(e))ZL(r)&&r.type===`array`&&ZL(r.items)&&zB(r.items)&&t.add(n);return t},WB=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,HB(t,e)]));function GB(e){if(!e||typeof e!=`object`||e.type!==`object`)return{type:`object`,properties:{id:LB},required:[`id`],additionalProperties:!0};let{id:t,...n}=e.properties??{};return{...e,properties:{id:LB,...WB(n)},required:[`id`]}}function KB(e,t,n,r=new Map){let i=Object.values(e);if(i.length===0)return;let a=new Map;for(let e of i){let t=a.get(e.name)??[];t.push(e),a.set(e.name,t)}let o={};for(let[i,s]of a){let a=Kz(i);if(o[a])continue;let c=s[0],l=t.get(c.id),u=l&&ZL(l.properties)?UB(l.properties):new Set,d=t=>{if(typeof t==`string`){let n=e[t];return n?.name===i?n:void 0}return s.length===1?c:void 0};o[a]={type:`frontend`,description:`Update the state of interactable component "${i}". ${c.description} Pass the id of the instance to update — instance ids and current state appear in the conversation as state snapshots. Only include the fields you want to change; omitted fields keep their current values.`,parameters:GB(l),streamCall:async(e,{toolCallId:t})=>{try{for await(let i of e.args.streamValues()){if(!i||typeof i!=`object`)continue;let e=i,a=Object.keys(e);if(a.indexOf(`id`)===a.length-1)continue;let{id:o,...s}=e;if(Object.keys(s).length===0)continue;let c=d(o);if(!c)continue;let l=r.get(t),u=l?.targetId===c.id?l.state:c.state;(!l||l.targetId!==c.id)&&r.set(t,{targetId:c.id,state:c.state}),n(c.id,e=>Yz(e,s,{arrayBaseline:u}))}}catch{}},execute:async(e,{toolCallId:t})=>{let{id:a,...o}=e??{},c=d(a);if(!c){let e=s.map(e=>e.id);return{success:!1,error:`Unknown id ${JSON.stringify(a)} for interactable "${i}". Valid ids: ${e.join(`, `)}`}}let l=r.get(t);r.delete(t);let f=_M();n(c.id,e=>Yz(e,o,{arrayBaseline:l?.targetId===c.id?l.state:void 0,idFactory:e=>{let t=gB();return(f[e]??=[]).push(t),t},idKeyedFields:u}));let p={success:!0,id:c.id};return Object.keys(f).length>0&&(p.addedItemIds={...f}),p}}}return{tools:o,unstable_composerMetadata:{interactables:i.map(e=>({id:e.id,name:e.name,state:e.state}))}}}var qB=(e,t,n)=>e.some(e=>e.role===`assistant`&&e.content?.some(e=>{if(!e||typeof e!=`object`)return!1;let r=e;return r.type===`tool-call`&&r.toolCallId===t&&r.toolName===n})),JB=({persistence:e}={})=>{let[t,n]=hN(()=>({definitions:_M(),persistence:_M()})),r=TF(),i=Y(t),a=Y(new Set),o=Y(new Map),s=Y(new Map),c=Y(new Map),l=Y(new Map),u=Y(new Map),d=Y(new Map),f=Y(new Map),p=Y(new Map),m=Y(new Set),h=Y(void 0),g=vN(e=>{let t=e(i.current);i.current=t,n(t)},[]),_=vN(()=>{let e=_M();for(let[t,n]of Object.entries(i.current.definitions))n.scope!==`thread`&&(e[t]={name:n.name,state:n.state});return e},[]),{flushIfPending:v,schedulePersistence:y,flush:b}=IB({adapterRef:h,snapshot:_,updatePersistenceStatus:vN(e=>{g(t=>{let n=e(t.persistence);return n===t.persistence?t:{...t,persistence:n}})},[g])}),x=vN((e,t)=>{let n=t.shouldStash??(()=>!0),r=t.shouldApply??(()=>!0);for(let[r,i]of Object.entries(e))n(r)&&t.stash.set(r,i.state);g(t=>{let n=!1,i=_M(t.definitions);for(let[t,a]of Object.entries(e)){let e=i[t];e&&r(t,e)&&(i[t]={...e,state:a.state},n=!0)}return n?{...t,definitions:i}:t})},[g]),S=vN(e=>{x(e,{stash:l.current})},[x]),C=vN(e=>{x(e,{stash:p.current,shouldStash:e=>!m.current.has(e),shouldApply:(e,t)=>!m.current.has(e)&&t.scope!==`thread`})},[x]),w=vN(async e=>{if(e.load)try{let t=await e.load();if(!t||h.current!==e)return;C(t)}catch(e){console.warn(`[Interactables] Persistence load failed.`,e)}},[C]),T=vN(e=>{h.current!==e&&v(),h.current=e,e&&w(e)},[v,w]),E=vN(()=>{let e=r.current;if(!e)return;let t=e.threadListItem;if(t.source!=null)return t().getState().id;let n=e.threads;if(n.source!=null)return n().getState().mainThreadId},[r]);X(()=>{if(e)return T(e),()=>{h.current===e&&T(void 0)}},[e,T]);let D=vN((e,t)=>{m.current.add(e),g(n=>{let r=n.definitions[e];return r?{...n,definitions:_M(n.definitions,{[e]:{...r,state:t(r.state)}})}:n}),i.current.definitions[e]?.scope!==`thread`&&y(e)},[y,g]),O=_N(()=>({getModelContext:()=>{let e=i.current.definitions;return KB(e,o.current,D,c.current)??{}},subscribe:e=>(a.current.add(e),()=>{a.current.delete(e)})}),[D]);X(()=>{wI(a.current)},[t]),EF(`modelContext`,()=>r.current.modelContext().register(O),[O]);let k=vN((e,t)=>{let n=r.current?.tools;return!n||n.source==null?!1:(t.unsubscribe=n().setToolUI(Kz(e),t.render,{standalone:!0}),!0)},[r]);return EF(`tools`,()=>{for(let[e,t]of f.current)t.unsubscribe?.(),t.unsubscribe=void 0,k(e,t);return()=>{for(let e of f.current.values())e.unsubscribe?.(),e.unsubscribe=void 0}},[k]),{getState:()=>i.current,register:vN(e=>{let t=r.current?.thread,n=t&&t.source!=null?t().getState().messages??[]:[],i=e.scope??(qB(n,e.id,e.name)?`thread`:`app`);d.current.set(e.id,(d.current.get(e.id)??0)+1);let a;if(e.updateRender){let t=f.current.get(e.name),n=t??{count:0,render:e.updateRender,unsubscribe:void 0};n.count++,t||f.current.set(e.name,n),!n.unsubscribe&&k(e.name,n),a=()=>{let t=f.current.get(e.name);t&&--t.count===0&&(f.current.delete(e.name),t.unsubscribe?.(),t.unsubscribe=void 0)}}if(s.current.get(e.id)!==e.stateSchema){s.current.set(e.id,e.stateSchema),o.current.delete(e.id);try{let t=Vz(e.stateSchema);o.current.set(e.id,Hz(t))}catch(t){console.warn(`[Interactables] Failed to create partial schema for "${e.name}". The update tool will accept arbitrary fields without validation.`,t)}}let c=i===`thread`?E():void 0,m=i===`thread`?c?u.current.get(c)?.get(e.id):void 0:l.current.get(e.id);i===`thread`?c&&u.current.get(c)?.delete(e.id):l.current.delete(e.id);let h=i===`thread`?void 0:p.current.get(e.id),_=i===`thread`?nB(n,e.id,e.name):void 0;return g(t=>({...t,definitions:_M(t.definitions,{[e.id]:{id:e.id,name:e.name,description:e.description,stateSchema:e.stateSchema,initialState:e.initialState,scope:i,state:t.definitions[e.id]?.state??m??_?.state??h??e.initialState}})})),()=>{a?.();let t=(d.current.get(e.id)??1)-1;if(t>0){d.current.set(e.id,t);return}d.current.delete(e.id),v(),g(t=>{let n=t.definitions[e.id];if(n){if(n.scope===`thread`){let t=E();if(t){let r=u.current.get(t);r||(r=new Map,u.current.set(t,r)),r.set(e.id,n.state)}}else l.current.set(e.id,n.state)}s.current.delete(e.id),o.current.delete(e.id);let r=_M(t.definitions),i=_M(t.persistence);return delete r[e.id],delete i[e.id],{...t,definitions:r,persistence:i}})}},[v,r,E,k,g]),setState:D,exportState:_,importState:S,setPersistenceAdapter:T,flush:b}},YB=PN(JB);lF(JB,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=zI())});var XB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({attachment:mI({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},ZB=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({attachment:mI({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},QB=e=>{let t=J(6),{runtime:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({threadListItem:ML({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},$B=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({message:mI({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:mI({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},eV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({part:mI({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},tV=PN(e=>{let t=J(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:rV,resumeToolCall:iV,respondToToolApproval:aV},t[5]=o,t[6]=s),s}),nV=e=>{let t=J(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=Q(),s;t[0]!==a||t[1]!==n?(s=PP({part:tV({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,b.jsx)(HL,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function rV(){throw Error(`Not supported`)}function iV(){throw Error(`Not supported`)}function aV(){throw Error(`Not supported`)}var oV=e=>{for(let t of e)if(t?.status.type===`running`)return hL;return e.at(-1)?.status??mL},sV=(e,t)=>{let n={running:0,complete:0,incomplete:0,requiresAction:0},r=mL,i=!1;for(let a of t)switch(r=e[a]?.status??mL,r.type){case`running`:n.running++,i=!0;break;case`complete`:n.complete++;break;case`incomplete`:n.incomplete++;break;case`requires-action`:n.requiresAction++}return{status:i?hL:r,counts:n}},cV=PN(e=>{let t=J(11),{parts:n,getMessagePart:r}=e,[i,a]=hN(!0),o;t[0]===n?o=t[1]:(o=oV(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),lV=e=>{let t=J(4),{startIndex:n,endIndex:r,children:i}=e,a=$(uV).slice(n,r+1),o=Q(),s=PP({chainOfThought:cV({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message.part({index:n+t})}})}),c;return t[0]!==i||t[1]!==s||t[2]!==o?(c=(0,b.jsx)(HL,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function uV(e){return e.message.parts}var dV=e=>{let t=J(7),{index:n,archived:r,children:i}=e,a=Q(),o;t[0]!==r||t[1]!==n?(o=PP({threadListItem:mI({source:`threads`,query:{type:`index`,index:n,archived:r},get:e=>e.threads.item({index:n,archived:r})})}),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==a||t[4]!==i||t[5]!==s?(c=(0,b.jsx)(HL,{extends:a,config:s,children:i}),t[3]=a,t[4]=i,t[5]=s,t[6]=c):c=t[6],c},fV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({suggestion:mI({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},pV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({queueItem:mI({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},mV=Symbol.for(`assistant-ui.message-not-sent`),hV=e=>typeof e==`object`&&!!e&&mV in e,gV=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},_V=class extends gV{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},vV=class extends _V{get source(){return`thread-composer`}},yV=class extends _V{get source(){return`edit-composer`}},bV=class extends gV{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},xV=Object.freeze([]),SV=Object.freeze({}),CV=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??xV,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??SV,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??xV,value:e?.text??``}),wV=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??xV,runConfig:e?.runConfig??SV,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??xV,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),TV=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new NI({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},EV=class extends TV{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new jI({path:e.path,getState:()=>CV(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new vV(new AI({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:CI},subscribe:e=>this._core.subscribe(e)}),this._core)}},DV=class extends TV{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new jI({path:e.path,getState:()=>wV(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new yV(new AI({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:CI},subscribe:e=>this._core.subscribe(e)}),this._core)}},OV=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
90
+ Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},PM=(e,t)=>{yM(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},FM=(e,t)=>{let n=fM(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||kM();let a=e();return mM&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&AM();let a=i;if(NM(a.wipDeps,t))return a.isDirty&&PM(n,a),a.wip;let o=e();return mM&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,bM(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),PM(n,a),o};function IM(e){return FM(()=>({current:e}),[])}var LM=Symbol(`tap.Context.defaultValue`),RM=e=>e,zM=new Map,BM=new Set,VM=()=>new Map(zM),HM=(e,t)=>{let n=zM;zM=e;try{return t()}finally{zM=n}},UM=(e,t)=>{e[LM]=t},WM=e=>typeof e==`object`&&!!e&&LM in e,GM=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),KM=e=>WM(e)||GM(e),qM=e=>{if(!WM(e)){if(GM(e)){UM(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},JM=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);qM(e);let r=e,i=fM(),a=IM(void 0),o=a.current===void 0||!Object.is(a.current.value,t);MM(()=>{a.current={value:t}},[t]);let s=zM.get(r),c=s!==void 0||zM.has(r);zM.set(r,{value:t,source:i});try{return YM(r,o,n)}finally{c?zM.set(r,s):zM.delete(r)}},YM=(e,t,n)=>{let r=BM.has(e);t?BM.add(e):BM.delete(e);try{return n()}finally{r?BM.add(e):BM.delete(e)}},XM=e=>{qM(e);let t=e,n=ZM(t,e),r=fM();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},ZM=(e,t)=>zM.get(e)??{value:RM(t)[LM],source:null},QM=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},$M=(e,t=e.wipContextDeps)=>{let n=pM();n&&t&&(n.wipContextDeps=QM(n,e,n.wipContextDeps,t))},eN=()=>BM.size>0,tN=e=>{if(!e.contextDeps||!eN())return!1;for(let t of BM.keys())if(e.contextDeps.has(t))return!0;return!1},nN=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,vM(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},rN=(e,t,n,r,i)=>{let a=r?r(n):n;mM&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=pM();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else nN(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function iN(e,t,n,r){let i=fM(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:AM();i.isFirstRender||kM();let s=rN(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,mM&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):mM&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(xM(i,s),s.workInProgress=t)}return s.isDirty&&yM(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function aN(e,t,n){return iN(e,t,n,!1)}var oN=(e,t)=>typeof t==`function`?t(e):t,sN=e=>e===void 0?void 0:typeof e==`function`?e():e;function cN(e){return iN(oN,e,sN,!0)}var lN=(e,t)=>FM(()=>e,t);function uN(e){let t=fM(),n=IM(e);return n.current!==e&&yM(t,()=>{n.current=e}),lN(((...e)=>{if(mM&&pM())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var dN=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,fN=()=>{},pN=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(fN,fN):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},mN=e=>dN(e)?pN(e):XM(e),hN=!1,gN=(e,t,n=t)=>{let r=fM().isNeverMounted,i=r?n():t();mM&&!hN&&(!r||n===t)&&(Object.is(i,t())||(hN=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=aN(e=>e+1,0),o=IM(0),s=uN(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return MM(()=>e(()=>{s()&&a()}),[e]),MM(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},_N=(e,t)=>{},vN=0,yN=()=>{let e=IM(null);return e.current??=`:tap${vN++}:`,e.current},bN=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?MM(r):MM(r,[...n,e])},xN=y.default;function SN(e){let t=(0,y.useRef)(e);return(0,y.useInsertionEffect)(()=>{t.current=e}),(0,y.useCallback)(((...e)=>t.current(...e)),[])}var CN=xN.useEffectEvent??SN,wN=()=>pM()!==null,TN=y.default,EN=e=>wN()?cN(e):TN.useState(e),DN=(e,t,n)=>wN()?aN(e,t,n):TN.useReducer(e,t,n),Y=e=>wN()?IM(e):TN.useRef(e),ON=(e,t)=>wN()?FM(e,t):TN.useMemo(e,t),kN=(e,t)=>wN()?lN(e,t):TN.useCallback(e,t),X=(e,t)=>wN()?MM(e,t):TN.useEffect(e,t),AN=(e,t)=>wN()?MM(e,t):TN.useLayoutEffect(e,t),jN=e=>wN()?uN(e):CN(e),MN=(e,t,n)=>wN()?gN(e,t,n):TN.useSyncExternalStore(e,t,n),NN=(e,t)=>wN()?void 0:TN.useDebugValue(e,t),PN=(e,t)=>wN()?MM(e,t):TN.useInsertionEffect(e,t),FN=()=>wN()?yN():TN.useId(),IN=(e,t,n)=>wN()?bN(e,t,n):TN.useImperativeHandle(e,t,n),Z=e=>TN.forwardRef(e),LN=(e,t)=>TN.memo(e,t),RN=TN.Fragment,zN=(...e)=>TN.createElement(...e),BN=(...e)=>TN.cloneElement(...e),VN=e=>TN.isValidElement(e);TN.Children,TN.Suspense;var HN=e=>{let t=TN.createContext(e);return UM(t,e),t},UN=e=>wN()&&KM(e)?mN(e):TN.use(e),WN=e=>wN()&&KM(e)?mN(e):TN.useContext(e);function GN(e){return(...t)=>({hook:e,args:t})}function KN(e,t,n){return typeof t==`function`?(...n)=>KN(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var qN=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},JN=50,YN={schedulers:new Set,isScheduled:!1},XN=null,ZN=[],QN=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(XN&&(XN.get(this)??0)>=JN)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,YN.schedulers.add(this),tP()}runTask(){XN?.set(this,(XN.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},$N=[];new QN(()=>{let e=$N.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}qN(t,`Errors occurred while running scheduled tasks`)});var eP=e=>{if(XN!==null){ZN.push(e);return}e()},tP=()=>{YN.isScheduled||(YN.isScheduled=!0,rP())},nP=()=>{let e=XN;XN=new Map;let t=[];try{for(let e of YN.schedulers)if(YN.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(XN=e,YN.schedulers.clear(),YN.isScheduled=!1,XN===null)for(;ZN.length>0;)try{ZN.shift()()}catch(e){t.push(e)}}qN(t,`Errors occurred during flushSync`)},rP=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),nP()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(nP,0)})(),iP=e=>{if(XN!==null)return mM&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=YN;YN={schedulers:new Set,isScheduled:!0};try{let t=e();return nP(),t}finally{let e=YN.schedulers;if(YN=t,e.size>0){for(let t of e)YN.schedulers.add(t);tP()}}};function aP(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}qN(t,`Errors during commit`)}function oP(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var sP=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!NM(e.deps,e.setupDeps);function cP(e){let t=[],n=[];for(let t of e.effectCells)sP(t)&&n.push(t);for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){t.push(e)}finally{e.cleanup=void 0}for(let e of n)try{oP(e)}catch(e){t.push(e)}qN(t,`Errors during commit`)}function lP(e){let t=[];for(let n of e.effectCells)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}qN(t,`Errors during cleanup`)}var uP={useState:cN,useReducer:aN,useRef:IM,useMemo:FM,useCallback:lN,useEffect:MM,useLayoutEffect:MM,useInsertionEffect:MM,useEffectEvent:uN,useContext:XM,use:mN,useSyncExternalStore:gN,useDebugValue:_N,useId:yN,useImperativeHandle:bN,useMemoCache:TM},dP=y.default,fP=dP.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??dP.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,pP=fP==null?null:`H`in fP?{get current(){return fP.H},set current(e){fP.H=e}}:`ReactCurrentDispatcher`in fP?{get current(){return fP.ReactCurrentDispatcher.current},set current(e){fP.ReactCurrentDispatcher.current=e}}:null;function mP(e){if(!pP)return e();let t=pP.current;pP.current=uP;try{return e()}finally{pP.current=t}}function hP(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function gP(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function _P(e){e.isMounted&&(e.isMounted=!1,lP(e))}function vP(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,dM(e,()=>{r=mP(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw gP(e),t}return $M(e),r}function yP(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=mM&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,gM(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),aP(t)),n&&(cP(e),lP(e)),cP(e)}var bP=()=>{let e=fM();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},xP=()=>`child`,SP=()=>null,CP=()=>{if(!mM)return SP;let e=Y(0);return EN(()=>e.current++),e.current===2?xP:SP},wP=()=>pM()?bP:CP(),TP=e=>e(),EP=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}qN(t,`Errors occurred while notifying Tap root subscribers`)},DP=(e,t,n)=>{let r=new QN(()=>s.handleUpdate()),i=[],a=hM((e,t)=>{(i.length!==0||e())&&(i.push(t),r.markDirty())}),o=hP(TP,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{_M(a,a.committedVersion);for(let e of i)mM&&o.devStrictMode&&e(),e();return _M(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,eP(()=>EP(s.subscribers)))},finishFlush:(e,t,n)=>{gM(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&yP(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{mM&&o.devStrictMode&&HM(s.context,()=>vP(o,[s.committedRender])),t=HM(s.context,()=>vP(o,[s.committedRender]))}catch(e){if(_M(a,a.committedVersion),dN(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},OP=e=>{let[,t]=EN(0),n=wP(),r=Y(null),i=r.current??=DP(e,n(),t),a=VM(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=HM(a,()=>vP(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),X(()=>(i.isMounted=!0,()=>{i.isMounted=!1,_P(i.fiber)}),[i]),X(()=>{if(c.processed){i.fiber.isMounted||(yP(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}yP(i.fiber),i.publish(c.value,c.version)}),ON(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},kP=()=>{let e=Y(0),t=e.current,n=fM();return{version:t,markDirty:ON(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},AP=()=>{let[e]=EN(()=>hM((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=DN((t,n)=>(_M(e,t),t+ +!!n()),0),[,r]=EN(0);return _M(e,t),{root:e,version:t,markDirty:void 0}},jP=()=>{let e=wP(),{root:t,version:n,markDirty:r}=pM()?kP():AP();return{version:n,createFiber:kN((n,i,a)=>hP(n,t,a?()=>{a(),r?.()}:r,e()),[])}},MP=(e,t,n)=>{let r=Y(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,X(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&NM(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function NP(e){let{version:t,createFiber:n}=jP(),r=ON(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=MP(()=>({value:vP(r,e.args)}),[r,t,e.args],tN(r));return X(()=>()=>_P(r),[r]),X(()=>{yP(r)},[r,i]),i.value}var PP=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},FP=(e,t)=>!e.isDirty&&!tN(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&NM(e.committedDeps,t),IP=e=>{if(!eN())return!1;for(let{fiber:t}of e.values())if(tN(t))return!0;return!1};function LP(e){let[t]=EN(()=>new Map),{version:n,createFiber:r}=jP(),i=IP(t),a=MP(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>PP(t,c));l={fiber:e,next:{value:vP(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>PP(t,c)),n=vP(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(FP(l,s.deps))typeof l.next==`object`&&gP(l.fiber),l.fiber.contextDeps&&$M(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=vP(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return X(()=>()=>{for(let e of t.keys())_P(t.get(e).fiber)},[t]),X(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(_P(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&yP(n.fiber):(r.remount&&(_P(n.fiber),n.fiber=r.remount),yP(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var RP=e=>e(),zP=e=>{let{createFiber:t}=jP(),n=ON(()=>t(RP,void 0),[t]),r=vP(n,[e]);X(()=>()=>{_P(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,yP(n))};return X(a),{value:r,effects:a}},BP=GN(()=>{let e=J(4),[t,n]=EN(VP),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{let r=OM(n.renderers);return r[e]=[...r[e]??[],t],{...n,renderers:r}}),()=>{n(n=>{let r=OM(n.renderers),i=r[e]?.filter(e=>e!==t)??[];return i.length>0?r[e]=i:delete r[e],{...n,renderers:r}})}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function VP(){return{renderers:OM(),fallbacks:[]}}var HP=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},UP=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n=OM();return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools!==void 0&&Object.hasOwn(e.tools,i)?e.tools[i]:void 0;if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=HP(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=HP({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||=OM(),e.tools[i]=HP(a),Object.hasOwn(n,i)||(n[i]=r)}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...e.unstable_composerMetadata,...t.unstable_composerMetadata}),e},{})},WP=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},GP=e=>e,KP=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),qP=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!KP.has(e))return!1}},JP=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},YP=Symbol(`assistant-ui.store.clientId`),XP=Symbol(`assistant-ui.store.instanceTag`),ZP=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===YP?tF(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===YP||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(typeof n!=`symbol`&&n in t())return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},QP=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===YP)return n();let i=qP(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},$P=e=>e?.source!=null,eF=e=>e?.source===null,tF=e=>e[YP]??e,nF=e=>e[XP]??tF(e),rF=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,iF=e=>{let t=[];for(let n in e)rF(n)||t.push(n);return t},aF=class extends JP{#e;constructor(e){super(),this.#e=e}get(e,t){let n=qP(t,`OptionalAssistantClient`);if(n!==!1)return n;if(rF(t))return;let r=this.#e[t];return $P(r)?r:void 0}ownKeys(){return iF(this.#e)}has(e,t){return!rF(t)&&t in this.#e}},oF=e=>new Proxy({},new aF(e)),sF=()=>()=>{},cF=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,lF=class extends JP{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return sF;if(t===`optional`)return this.#r??=oF(this.#n());let n=qP(t,this.#e);return n===!1?QP(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},uF=((e,t)=>{let n=new Proxy({},new lF(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>cF),dF=()=>new Proxy({},{get(e,t){let n=qP(t,`AssistantClient`);return n===!1?QP(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),fF=HN(uF),pF=()=>{},mF=new WeakMap,hF=e=>mF.get(e)??pF,gF=(e,t)=>{mF.set(e,t)},_F=()=>WN(fF),vF=(e,t)=>JM(fF,e,t),yF=Symbol(`assistant-ui.transform-scopes`);function bF(e,t){let n=e;if(n[yF])throw Error(`transformScopes is already attached to this resource`);n[yF]=t}function xF(e){return e[yF]}var SF=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},CF=e=>{console.error(`NotificationManager: event listener error`,e)},wF=(e,t,n)=>{try{let r=e(t,n);r!==null&&(typeof r==`object`||typeof r==`function`)&&typeof r.then==`function`&&Promise.resolve(r).catch(CF)}catch(e){CF(e)}},TF=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.get(n)===a&&e.delete(n)}},emit(n,r,i){(e.has(n)||t.size!==0)&&queueMicrotask(()=>{let a=e.get(n);if(a)for(let e of a)wF(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)wF(n,e,i)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},EF=()=>EN(TF)[0],DF=Symbol(`assistant-ui.store.clientIndex`),OF=e=>e[DF],kF=HN([]),AF=()=>UN(kF),jF=(e,t)=>{let n=J(3),r=AF(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],JM(kF,i,t)},MF=HN(null),NF=Symbol(`aui.scope-effect-unapplied`),PF=(e,t)=>JM(MF,e,t),FF=()=>{let e=UN(MF);if(!e)throw Error(`AssistantTapContext is not available`);return e},IF=()=>FF().clientRef,LF=(e,t,n)=>{let r=J(8),{clientRef:i}=FF(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&$P(t)?nF(t):void 0},a=NF,o,s=e=>{if(o?.(),o=void 0,a=NF,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],X(a,o)},RF=()=>{let e=J(3),{emit:t}=FF(),n=AF(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],jN(r)},zF=HN(void 0),BF=(e,t)=>{let n=UN(zF);return JM(zF,e??n,t)},VF=()=>{let e=J(3),[t]=EN(HF),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>()=>queueMicrotask(()=>t.abort()),r=[t],e[0]=t,e[1]=n,e[2]=r),PN(n,r),t.signal};function HF(){return new AbortController}var UF=Symbol(`assistant-ui.store.getValue`),WF=e=>{let t=e[UF];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},GF=new Map;function KF(e){let t=GF.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[UF];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},GF.set(e,t)),t}var qF=class extends JP{boundFns;cachedReceiver;outputRef;tagRef;index;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===UF)return this.outputRef.current;if(t===DF)return this.index;if(t===XP)return this.tagRef.current;let r=qP(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=KF(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===UF||t===DF||t===XP||t in this.outputRef.current}},JF=e=>{let t=Y(null),n=Y(null),r=ON(()=>({}),[e.hook,e.key]),i=AF().length,a=ON(()=>new Proxy({},new qF(t,n,i)),[i]),o=jF(a,function(){return NP(e)});return t.current||(t.current=o,n.current=r),X(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},YF=GN(JF),XF=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},ZF=e=>{let t=ON(()=>({}),[]);return t.v!==void 0&&XF(t.v,e)?t.v:(t.v=e,e)},QF=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&XF(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},$F=(()=>{try{return!1}catch{return!1}})(),eI=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=xF(e.hook);if(a){a(n,t),i=!0;break}}}return n},tI=e=>e.hook===wI,nI=e=>{if(!tI(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},rI=Symbol.for(`aui.event-receiver-ref`),iI=(e,t)=>{let n=e===uF?dF():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=oF(r),enumerable:!1}),r},aI=({notifications:e,clientRef:t})=>ON(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=SF(n),o=n[rI];if(i!==`*`&&!o&&eF(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`)return r(e);let a=((o??t).current??this)[i];if(!$P(a))return;let s=tF(a);if(s===n[OF(s)])return r(e)});if(i!==`*`){if(o){if(t.parent===uF)return s}else if(eF(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),oI=e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=nI(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=ZF(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],ZF(o)},sI=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=t?e:YF(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],NP(r)},cI=GN((e,t)=>{let n=_F(),r=tI(t),i=sI(t,r),a=r?i:i.methods,o=oI(t),s=ON(()=>ZP({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),lI=e=>{let t=J(2),n;return t[0]===e?n=t[1]:(n=e.map(yI),t[0]=e,t[1]=n),LP(n)},uI=(e,t)=>{let n=ZF(t),r=ON(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},dI=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=iI(e,aI({notifications:r,clientRef:n}));return{client:uI(i,[e,...PF({clientRef:n,emit:r.emit},function(){return vF(i,function(){return lI(t)})})])}},fI=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=zP(function(){let i=EF(),{client:a}=BF(n,function(){return dI({parent:e,entries:t,clientRef:r,notifications:i})});return X(()=>e.subscribe(i.notifySubscribers),[e,i]),X(()=>i.notifySubscribers()),a});return PN(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},pI=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=zP(function(){let i=EF(),a=OP(function(){return BF(n,function(){return dI({parent:e,entries:t,clientRef:r,notifications:i})})}),o=MN(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return X(()=>{let t=()=>iP(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return PN(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},mI=(e,t,n,r)=>{let{get:i}=r.args[0],a=MN(e.subscribe,()=>i(e),()=>i(e)),o=oI(r),s=ON(()=>ZP({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},hI=(e,t)=>{if($F){let[e]=EN(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!tI(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=Y({parent:e,current:null}).current,r=iI(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=SF(t);if(i===`*`)return e.on(t,r);let o=t[rI];if(!o&&eF(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[rI]:o??n},r)}}),i=uI(r,[e,...t.map(([t,n])=>mI(e,r,t,n))]);return PN(()=>{n.parent=e,n.current=i},[i,e,n]),i},gI=(e,t)=>{let n=J(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(eI(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(bI),n[3]=i,n[4]=a);let[o]=EN(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},_I=(e,t,n,r)=>{let{entries:i,rooted:a}=gI(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:hI(e,i)}},vI=(e,t,n)=>_I(e,t,fI,n);function Q(e){let t=_F();if(e){let{client:n,effects:r}=_I(t,e,pI,VF());return r&&gF(n,r),n}return t}function yI(e){let[t,n]=e;return KN(t,cI(t,n))}function bI(e){let[,t]=e;return!tI(t)}var xI=e=>{let t;class n extends JP{get(t,n){let r=qP(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!rF(i)&&$P(e[i]))return WF(e[i]())}ownKeys(){return iF(e)}has(t,n){return!rF(n)&&n in e}}class r extends JP{get(r,i){let a=qP(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!rF(o))return WF(e[o]())}ownKeys(){return[...iF(e),`optional`]}has(t,n){return n===`optional`||!rF(n)&&n in e}}return new Proxy({},new r)},SI=new WeakMap,CI=e=>{let t=SI.get(e);return t||(t=xI(e),SI.set(e,t)),t},$=e=>{let t=J(6),n=Q(),r;t[0]===n?r=t[1]:(r=CI(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=MN(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return NN(s),s},wI=e=>{let t=J(3),{get:n}=e,r=Q(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],$(i)},TI=GN(wI),EI=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function DI(e){let t=J(12),n;t[0]===e?n=t[1]:(n=e.map(AI),t[0]=e,t[1]=n);let r=LP(n),i;t[2]===e?i=t[3]:(i=e.reduce(kI,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(OI),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function OI(e){return e.state}function kI(e,t,n){return e[EI(t)]=n,e}function AI(e){return KN(EI(e),YF(e),e.deps)}var jI=(e,t=0)=>t===0?Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight:e.scrollHeight-t-e.scrollTop-e.clientHeight<=1||e.scrollHeight-t<=e.clientHeight,MI=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,NI=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,PI=Symbol(`skip-update`),FI=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}},II=e=>{FI(e)},LI=(e,t)=>e===void 0||t===void 0?e===t:XF(e,t),RI=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){FI(this._subscribers)}},zI=class extends RI{_state;constructor(e){super(),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}getServerSnapshot;setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},BI=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){WP(this._subscriptions,e,t);return}FI(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{let e=this._connection;this._connection=void 0,e?.()}}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},VI=class extends BI{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===PI)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===PI||LI(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},HI=class extends BI{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==PI&&(this._previousState===void 0||!LI(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},UI=class extends BI{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();if(r===t)return;t=r;let i=n;n=void 0;try{i?.()}finally{n=r?.subscribe(e),e()}});return()=>II([()=>r?.(),()=>n?.()])}},WI=class extends BI{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=this.outerSubscribe(()=>{let e=this.config.binding.getState();if(e===n)return;n=e;let i=r;r=void 0;try{i?.()}finally{r=e?.unstable_on(this.config.event,t)}});return()=>II([()=>i?.(),()=>r?.()])}},GI=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return UP(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}this._providerUnsubscribes.set(t,n),this.notifySubscribers();let r=!1;return()=>{if(r)return;r=!0,this._providers.delete(t);let e=this._providerUnsubscribes.get(t);this._providerUnsubscribes.delete(t);let n=!1,i,a=e=>{try{e()}catch(e){n?console.error(e):(n=!0,i=e)}};if(e&&a(e),a(()=>this.notifySubscribers()),n)throw i}}_subscribers=new Set;notifySubscribers(){FI(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},KI=[],qI={modelName:void 0,toolNames:KI},JI=(e,t)=>e===t||XF(e,t),YI=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():KI,a=i.length?i:KI;return r===t.modelName&&JI(a,t.toolNames)?t:{modelName:r,toolNames:a}},XI=GN(()=>{let e=J(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new GI,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>YI(n,qI),e[1]=r):r=e[1];let[i,a]=EN(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>YI(n,e)),n.subscribe(()=>{a(e=>YI(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),X(o,s);let c;e[4]===i?c=e[5]:(c=()=>YI(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),ZI=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},QI=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,$I=e=>function(t){return ZI(e,t)},eL=e=>{let t=J(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[KN(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=LP(i)[0],[o,s]=EN(nL),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=IF(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,renderText:n?.renderText,standalone:n?.standalone??!1};return s(t=>{let n=OM(t);return n[e]=[...n[e]??[],r],n}),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[],i=OM(t);return n.length>0?(i[e]=n,i):(delete i[e],i)})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?$I(i):void 0);a&&e.push(f(t,a,{standalone:QI(r),renderText:i}))}return()=>{e.forEach(rL)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),X(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(iL,OM());return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),LF(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},tL=GN(eL);bF(eL,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=XI())});function nL(){return OM()}function rL(e){return e()}function iL(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var aL=e=>MN(e.subscribe,e.getState,e.getServerSnapshot),oL=Symbol.for(`assistant-ui.silent-runtime-action`),sL=e=>typeof e==`object`&&!!e&&oL in e,cL=(e,t)=>{let n=t();return n.catch(t=>{sL(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},lL=GN(e=>{let t=J(9),{runtime:n}=e,r=aL(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>cL(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),uL=GN(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=lL({runtime:a}),t[3]=a,t[4]=o),NP(o)}),dL=GN(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),fL=GN(e=>{let t=J(63),{threadIdRef:n,messageIdRef:r,runtime:i,isSuggestion:a}=e,o=aL(i),s=RF(),c=Y(!1),l,u;t[0]!==s||t[1]!==r||t[2]!==i||t[3]!==n?(l=()=>{let e=[],t=i.unstable_on(`send`,e=>{let t=c.current;c.current=!1,s(`composer.send`,{threadId:n.current,...r&&{messageId:r.current},chars:e.chars,attachments:e.attachments,...t?{suggestion:!0}:void 0})});e.push(t);let a=i.unstable_on(`attachmentAdd`,e=>{s(`composer.attachmentAdd`,{threadId:n.current,...r&&{messageId:r.current},...e.contentType?{contentType:e.contentType}:void 0})});return e.push(a),e.push(i.unstable_on(`attachmentAddError`,e=>{s(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message,...e.contentType?{contentType:e.contentType}:void 0})})),()=>{for(let t of e)t()}},u=[i,s,n,r],t[0]=s,t[1]=r,t[2]=i,t[3]=n,t[4]=l,t[5]=u):(l=t[4],u=t[5]),X(l,u);let d;if(t[6]!==i||t[7]!==o.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>KN(e.id,uL({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),d=o.attachments.map(e),t[6]=i,t[7]=o.attachments,t[8]=d}else d=t[8];let f=DI(d),p=o.queue,m;if(t[11]!==p||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>KN(e.id,dL({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),m=p.map(e),t[11]=p,t[12]=i,t[13]=m}else m=t[13];let h=DI(m),g=o.type??`thread`,_;t[16]!==f.state||t[17]!==p||t[18]!==o.attachmentAccept||t[19]!==o.canCancel||t[20]!==o.canSend||t[21]!==o.dictation||t[22]!==o.isEditing||t[23]!==o.isEmpty||t[24]!==o.quote||t[25]!==o.role||t[26]!==o.runConfig||t[27]!==o.text||t[28]!==g?(_={text:o.text,role:o.role,attachments:f.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:g,dictation:o.dictation,quote:o.quote,queue:p},t[16]=f.state,t[17]=p,t[18]=o.attachmentAccept,t[19]=o.canCancel,t[20]=o.canSend,t[21]=o.dictation,t[22]=o.isEditing,t[23]=o.isEmpty,t[24]=o.quote,t[25]=o.role,t[26]=o.runConfig,t[27]=o.text,t[28]=g,t[29]=_):_=t[29];let v=_,y;t[30]===v?y=t[31]:(y=()=>v,t[30]=v,t[31]=y);let b;t[32]!==a||t[33]!==i?(b=e=>{let t=i.getState();c.current=t.canSend&&(a?.(t.text)??!1),i.send(e)},t[32]=a,t[33]=i,t[34]=b):b=t[34];let x;t[35]!==s||t[36]!==r||t[37]!==i||t[38]!==n?(x=()=>{!r&&i.getState().canCancel&&s(`composer.cancel`,{threadId:n.current}),i.cancel()},t[35]=s,t[36]=r,t[37]=i,t[38]=n,t[39]=x):x=t[39];let S=i.beginEdit??pL,C;t[40]===f?C=t[41]:(C=e=>`id`in e?f.get({key:e.id}):f.get(e),t[40]=f,t[41]=C);let w;t[42]===h?w=t[43]:(w=e=>`id`in e?h.get({key:e.id}):h.get(e),t[42]=h,t[43]=w);let T;t[44]===i?T=t[45]:(T=()=>i,t[44]=i,t[45]=T);let E;return t[46]!==i.addAttachment||t[47]!==i.clearAttachments||t[48]!==i.reset||t[49]!==i.setQuote||t[50]!==i.setRole||t[51]!==i.setRunConfig||t[52]!==i.setText||t[53]!==i.startDictation||t[54]!==i.stopDictation||t[55]!==S||t[56]!==C||t[57]!==w||t[58]!==T||t[59]!==y||t[60]!==b||t[61]!==x?(E={getState:y,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:b,cancel:x,beginEdit:S,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:C,queueItem:w,__internal_getRuntime:T},t[46]=i.addAttachment,t[47]=i.clearAttachments,t[48]=i.reset,t[49]=i.setQuote,t[50]=i.setRole,t[51]=i.setRunConfig,t[52]=i.setText,t[53]=i.startDictation,t[54]=i.stopDictation,t[55]=S,t[56]=C,t[57]=w,t[58]=T,t[59]=y,t[60]=b,t[61]=x,t[62]=E):E=t[62],E});function pL(){throw Error(`beginEdit is not supported in this runtime`)}var mL=e=>({get current(){return e()}}),hL=GN(e=>{let t=J(13),{runtime:n}=e,r=aL(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),gL=GN(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=lL({runtime:a}),t[3]=a,t[4]=o),NP(o)}),_L=GN(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=hL({runtime:a}),t[3]=a,t[4]=o),NP(o)}),vL=GN(e=>{let t=J(74),{runtime:n,threadIdRef:r,threadId:i}=e,a=aL(n),o=RF(),[s,c]=EN(!1),[l,u]=EN(!1),d;t[0]===n?d=t[1]:(d=mL(()=>n.getState().id),t[0]=n,t[1]=d);let f=d,p=Y(a.status),m;t[2]!==o||t[3]!==n||t[4]!==i?(m=e=>{o(e,{threadId:i,messageId:n.getState().id})},t[2]=o,t[3]=n,t[4]=i,t[5]=m):m=t[5];let h=m,g,_;t[6]!==o||t[7]!==a.id||t[8]!==a.status||t[9]!==i?(g=()=>{let e=a.status,t=p.current;p.current=e,e?.type===`incomplete`&&e.reason===`error`&&(t?.type!==`incomplete`||t.reason!==`error`)&&o(`message.error`,{threadId:i,messageId:a.id,reason:`error`})},_=[a.status,a.id,o,i],t[6]=o,t[7]=a.id,t[8]=a.status,t[9]=i,t[10]=g,t[11]=_):(g=t[10],_=t[11]),X(g,_);let v;t[12]!==f||t[13]!==n.composer||t[14]!==r?(v=fL({runtime:n.composer,threadIdRef:r,messageIdRef:f}),t[12]=f,t[13]=n.composer,t[14]=r,t[15]=v):v=t[15];let y=JF(v),b;if(t[16]!==n||t[17]!==a.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>KN(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,_L({runtime:n,index:t}),[n,t]),t[19]=n,t[20]=e),b=a.content.map(e),t[16]=n,t[17]=a.content,t[18]=b}else b=t[18];let x=DI(b),S;t[21]===a.attachments?S=t[22]:(S=a.attachments??[],t[21]=a.attachments,t[22]=S);let C;if(t[23]!==n||t[24]!==S){let e;t[26]===n?e=t[27]:(e=(e,t)=>KN(e.id,gL({runtime:n,index:t}),[n,t]),t[26]=n,t[27]=e),C=S.map(e),t[23]=n,t[24]=S,t[25]=C}else C=t[25];let w=DI(C),T=a,E;t[28]!==y.state||t[29]!==s||t[30]!==l||t[31]!==x.state||t[32]!==T?(E={...T,parts:x.state,composer:y.state,isCopied:s,isHovering:l},t[28]=y.state,t[29]=s,t[30]=l,t[31]=x.state,t[32]=T,t[33]=E):E=t[33];let D=E,O;t[34]===D?O=t[35]:(O=()=>D,t[34]=D,t[35]=O);let k;t[36]===y.methods?k=t[37]:(k=()=>y.methods,t[36]=y.methods,t[37]=k);let A;t[38]===n?A=t[39]:(A=()=>n.delete(),t[38]=n,t[39]=A);let j,M;t[40]!==h||t[41]!==n?(j=e=>(h(`message.reload`),n.reload(e)),M=()=>(h(`message.speak`),n.speak()),t[40]=h,t[41]=n,t[42]=j,t[43]=M):(j=t[42],M=t[43]);let N,ee;t[44]===n?(N=t[45],ee=t[46]):(N=()=>n.stopSpeaking(),ee=e=>n.submitFeedback(e),t[44]=n,t[45]=N,t[46]=ee);let te;t[47]!==h||t[48]!==n?(te=e=>(h(`message.branchSwitched`),n.switchToBranch(e)),t[47]=h,t[48]=n,t[49]=te):te=t[49];let ne;t[50]===n?ne=t[51]:(ne=()=>n.unstable_getCopyText(),t[50]=n,t[51]=ne);let re;t[52]===x?re=t[53]:(re=e=>`index`in e?x.get({index:e.index}):x.get({key:`toolCallId-${e.toolCallId}`}),t[52]=x,t[53]=re);let ie;t[54]===w?ie=t[55]:(ie=e=>`id`in e?w.get({key:e.id}):w.get(e),t[54]=w,t[55]=ie);let ae;t[56]===h?ae=t[57]:(ae=e=>{e&&h(`message.copied`),c(e)},t[56]=h,t[57]=ae);let oe;t[58]===n?oe=t[59]:(oe=()=>n,t[58]=n,t[59]=oe);let se;return t[60]!==O||t[61]!==k||t[62]!==A||t[63]!==j||t[64]!==M||t[65]!==N||t[66]!==ee||t[67]!==te||t[68]!==ne||t[69]!==re||t[70]!==ie||t[71]!==ae||t[72]!==oe?(se={getState:O,composer:k,delete:A,reload:j,speak:M,stopSpeaking:N,submitFeedback:ee,switchToBranch:te,getCopyText:ne,part:re,attachment:ie,setIsCopied:ae,setIsHovering:u,__internal_getRuntime:oe},t[60]=O,t[61]=k,t[62]=A,t[63]=j,t[64]=M,t[65]=N,t[66]=ee,t[67]=te,t[68]=ne,t[69]=re,t[70]=ie,t[71]=ae,t[72]=oe,t[73]=se):se=t[73],se}),yL=e=>{let t=ON(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n?.suggestions[r.length];r.push(t&&XF(t,e)?t:e)});let i=n&&XF(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},bL=GN(e=>({getState:()=>e})),xL=e=>{let t=J(9),n=yL(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(CL),t[0]=n.suggestions,t[1]=r);let i=DI(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},SL=GN(e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e.map(wL),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),xL(r)});function CL(e,t){return KN(t,bL(e),[e])}function wL(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var TL=Object.freeze({type:`complete`}),EL=Object.freeze({type:`running`}),DL=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),OL=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return EL;if(n===`complete`)return TL;if(n!==`incomplete`)return;let{reason:r}=t;return DL[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},kL=(e,t,n)=>{if(e.role!==`assistant`)return TL;if(n.type===`tool-call`)return n.result===void 0?e.status:TL;if(e.status.type===`running`){let e=OL(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?TL:r?e.status:TL},AL=e=>`reason`in e?e.reason:void 0,jL=e=>`error`in e?e.error:void 0,ML=32,NL=new WeakMap,PL=e=>NL.get(e)??e.id,FL=(e,t,n)=>`status`in e&&e.status?kL(e,t,n):TL,IL=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>ML))for(let[l,u]of e.entries())for(let[e,d]of u.content.entries()){if(d.type!==`tool-call`||d.messages===void 0)continue;let f=d.messages,p=FL(u,e,d),m=AL(p),h=jL(p),g=`${c}${l}.${e}`,_=t.get(g),v=_?.part===d&&_.statusType===p.type&&_.statusReason===m&&Object.is(_.statusError,h)&&_.messages===f&&_.task.messageId===u.id&&_.task.parentTaskId===n&&_.task.depth===s?_.task:{id:d.toolCallId,toolName:d.toolName,args:d.args,result:d.result,...d.isError===void 0?void 0:{isError:d.isError},status:p,timing:d.timing,messageId:u.id,parentTaskId:n,depth:s,messages:f};v!==_?.task&&(a=!1,NL.set(v,g)),r.push(v),i.set(g,{task:v,part:d,statusType:p.type,statusReason:m,statusError:h,messages:f}),o(f,v.id,s+1,`${g}.`)}};o(n,null,0,``);let s=a&&r.length===e.length&&r.every((t,n)=>t===e[n])?e:r;return e=s,t=i,s}},LL=GN(({task:e})=>({getState:()=>e})),RL=GN(e=>{let t=J(7),{runtime:n,id:r,threadIdRef:i,threadId:a}=e,o;t[0]!==r||t[1]!==n?(o=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==s||t[4]!==a||t[5]!==i?(c=vL({runtime:s,threadIdRef:i,threadId:a}),t[3]=s,t[4]=a,t[5]=i,t[6]=c):c=t[6],NP(c)}),zL=GN(e=>{let t=J(93),{runtime:n}=e,r=aL(n),i=RF(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return e.push(n.unstable_on(`toolApprovalAnswered`,e=>{let t=n.getState()?.threadId||`unknown`;i(`thread.toolApprovalAnswered`,{threadId:t,...e})})),()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),X(a,o);let s;t[4]===n?s=t[5]:(s=mL(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==i||t[7]!==n?(l=e=>{i(e,{threadId:n.getState().threadId})},t[6]=i,t[7]=n,t[8]=l):l=t[8];let u=l,d;t[9]===n?d=t[10]:(d=e=>n.getState().suggestions.some(t=>t.prompt===e),t[9]=n,t[10]=d);let f=d,p;t[11]!==f||t[12]!==n.composer||t[13]!==c?(p=fL({runtime:n.composer,threadIdRef:c,isSuggestion:f}),t[11]=f,t[12]=n.composer,t[13]=c,t[14]=p):p=t[14];let m=JF(p),h;t[15]===r.suggestions?h=t[16]:(h=SL(r.suggestions),t[15]=r.suggestions,t[16]=h);let g=JF(h),_;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=IL(),t[17]=_):_=t[17];let v=_,y;t[18]===r.messages?y=t[19]:(y=v(r.messages),t[18]=r.messages,t[19]=y);let b=y,x;t[20]===b?x=t[21]:(x=b.map(BL),t[20]=b,t[21]=x);let S=DI(x),C;if(t[22]!==n||t[23]!==r.messages||t[24]!==r.threadId||t[25]!==c){let e;t[27]!==n||t[28]!==r.threadId||t[29]!==c?(e=e=>KN(e.id,RL({runtime:n,id:e.id,threadIdRef:c,threadId:r.threadId}),[n,e.id,c,r.threadId]),t[27]=n,t[28]=r.threadId,t[29]=c,t[30]=e):e=t[30],C=r.messages.map(e),t[22]=n,t[23]=r.messages,t[24]=r.threadId,t[25]=c,t[26]=C}else C=t[26];let w=DI(C),T=w.state.length===0&&!r.isLoading,E;t[31]!==m.state||t[32]!==w.state||t[33]!==r.capabilities||t[34]!==r.extras||t[35]!==r.isDisabled||t[36]!==r.isLoading||t[37]!==r.isRunning||t[38]!==r.speech||t[39]!==r.state||t[40]!==r.suggestions||t[41]!==r.voice||t[42]!==T||t[43]!==b?(E={isEmpty:T,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:m.state,messages:w.state,tasks:b},t[31]=m.state,t[32]=w.state,t[33]=r.capabilities,t[34]=r.extras,t[35]=r.isDisabled,t[36]=r.isLoading,t[37]=r.isRunning,t[38]=r.speech,t[39]=r.state,t[40]=r.suggestions,t[41]=r.voice,t[42]=T,t[43]=b,t[44]=E):E=t[44];let D=E,O;t[45]===D?O=t[46]:(O=()=>D,t[45]=D,t[46]=O);let k;t[47]===m.methods?k=t[48]:(k=()=>m.methods,t[47]=m.methods,t[48]=k);let A;t[49]===g?A=t[50]:(A=()=>g.methods,t[49]=g,t[50]=A);let j;t[51]!==S||t[52]!==b?(j=e=>{if(`id`in e){let t=b.find(t=>t.id===e.id);return S.get({key:t?PL(t):e.id})}return S.get(e)},t[51]=S,t[52]=b,t[53]=j):j=t[53];let M;t[54]!==i||t[55]!==f||t[56]!==n?(M=e=>{let t=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if((t.role??`user`)===`user`){let e=t.content.map(VL).join(``);i(`composer.send`,{threadId:n.getState().threadId,chars:e.length,attachments:t.attachments?.length??0,...f(e)?{suggestion:!0}:void 0})}n.append(e)},t[54]=i,t[55]=f,t[56]=n,t[57]=M):M=t[57];let N;t[58]!==u||t[59]!==n||t[60]!==r.isRunning?(N=()=>{r.isRunning&&u(`thread.cancelRun`),n.cancelRun()},t[58]=u,t[59]=n,t[60]=r.isRunning,t[61]=N):N=t[61];let ee;t[62]!==u||t[63]!==n?(ee=()=>{n.connectVoice(),u(`thread.voiceStarted`)},t[62]=u,t[63]=n,t[64]=ee):ee=t[64];let te;t[65]===w?te=t[66]:(te=e=>`id`in e?w.get({key:e.id}):w.get(e),t[65]=w,t[66]=te);let ne;t[67]===n?ne=t[68]:(ne=()=>n,t[67]=n,t[68]=ne);let re;return t[69]!==n.deleteMessage||t[70]!==n.disconnectVoice||t[71]!==n.export||t[72]!==n.getModelContext||t[73]!==n.getVoiceVolume||t[74]!==n.import||t[75]!==n.importExternalState||t[76]!==n.muteVoice||t[77]!==n.reset||t[78]!==n.resumeRun||t[79]!==n.startRun||t[80]!==n.stopSpeaking||t[81]!==n.subscribeVoiceVolume||t[82]!==n.unmuteVoice||t[83]!==O||t[84]!==k||t[85]!==A||t[86]!==j||t[87]!==M||t[88]!==N||t[89]!==ee||t[90]!==te||t[91]!==ne?(re={getState:O,composer:k,suggestions:A,task:j,append:M,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:N,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:ee,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:te,__internal_getRuntime:ne},t[69]=n.deleteMessage,t[70]=n.disconnectVoice,t[71]=n.export,t[72]=n.getModelContext,t[73]=n.getVoiceVolume,t[74]=n.import,t[75]=n.importExternalState,t[76]=n.muteVoice,t[77]=n.reset,t[78]=n.resumeRun,t[79]=n.startRun,t[80]=n.stopSpeaking,t[81]=n.subscribeVoiceVolume,t[82]=n.unmuteVoice,t[83]=O,t[84]=k,t[85]=A,t[86]=j,t[87]=M,t[88]=N,t[89]=ee,t[90]=te,t[91]=ne,t[92]=re):re=t[92],re});function BL(e){return KN(PL(e),LL({task:e}),[e])}function VL(e){return e.type===`text`?e.text:``}var HL=(e,t)=>cL(`thread list ${e}`,t),UL=GN(e=>{let t=J(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=aL(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o,c=RF(),{isMain:l,id:u}=a,d;t[3]!==l||t[4]!==u?(d={isMain:l,threadId:u},t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=Y(d),p,m;t[6]!==c||t[7]!==l||t[8]!==u?(p=()=>{let e=f.current;(e.isMain!==l||e.threadId!==u)&&(f.current={isMain:l,threadId:u},c(l?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:u}))},m=[l,u,c],t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=m):(p=t[9],m=t[10]),X(p,m);let h;t[11]===s?h=t[12]:(h=()=>s,t[11]=s,t[12]=h);let g,_,v,y,b,x,S;t[13]===n?(g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20]):(b=e=>HL(`switch`,()=>n.switchTo(e)),x=e=>HL(`rename`,()=>n.rename(e)),S=e=>HL(`update custom metadata`,()=>n.updateCustom(e)),g=()=>HL(`archive`,()=>n.archive()),_=()=>HL(`unarchive`,()=>n.unarchive()),v=()=>HL(`delete`,()=>n.delete()),y=e=>HL(`generate title`,()=>n.generateTitle(e)),t[13]=n,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S);let C;t[21]===n?C=t[22]:(C=()=>n,t[21]=n,t[22]=C);let w;return t[23]!==n.detach||t[24]!==n.initialize||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==y||t[29]!==C||t[30]!==h||t[31]!==b||t[32]!==x||t[33]!==S?(w={getState:h,switchTo:b,rename:x,updateCustom:S,archive:g,unarchive:_,delete:v,generateTitle:y,initialize:n.initialize,detach:n.detach,__internal_getRuntime:C},t[23]=n.detach,t[24]=n.initialize,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=C,t[30]=h,t[31]=b,t[32]=x,t[33]=S,t[34]=w):w=t[34],w}),WL=e=>{let t=J(4),n=RF(),r=Y(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)},GL=GN(e=>{let t=J(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=UL({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],NP(s)}),KL=GN(e=>{let t=J(48),{runtime:n,__internal_assistantRuntime:r}=e,i=aL(n);WL(i.mainThreadId);let a=RF(),o,s;t[0]!==a||t[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:r}=e;t!==n.getState().mainThreadId&&a(`thread.${r}`,{threadId:t})}),s=[n,a],t[0]=a,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),X(o,s);let c;t[4]===n.main?c=t[5]:(c=zL({runtime:n.main}),t[4]=n.main,t[5]=c);let l=JF(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>KN(e,GL({runtime:n,id:e,mainThreadIsRunning:l.state.isRunning}),[n,e,l.state.isRunning])),t[6]=l.state,t[7]=n,t[8]=i.threadItems,t[9]=u):u=t[9];let d=DI(u),f=i.newThreadId??null,p;t[10]!==l.state||t[11]!==i.archivedThreadIds||t[12]!==i.hasMore||t[13]!==i.isLoading||t[14]!==i.isLoadingMore||t[15]!==i.loadError||t[16]!==i.mainThreadId||t[17]!==i.threadIds||t[18]!==f||t[19]!==d.state?(p={mainThreadId:i.mainThreadId,newThreadId:f,isLoading:i.isLoading,loadError:i.loadError,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:d.state,main:l.state},t[10]=l.state,t[11]=i.archivedThreadIds,t[12]=i.hasMore,t[13]=i.isLoading,t[14]=i.isLoadingMore,t[15]=i.loadError,t[16]=i.mainThreadId,t[17]=i.threadIds,t[18]=f,t[19]=d.state,t[20]=p):p=t[20];let m=p,h;t[21]===m?h=t[22]:(h=()=>m,t[21]=m,t[22]=h);let g;t[23]===l.methods?g=t[24]:(g=()=>l.methods,t[23]=l.methods,t[24]=g);let _;t[25]!==m||t[26]!==d?(_=e=>{if(e===`main`)return d.get({key:m.mainThreadId});if(`id`in e)return d.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?m.archivedThreadIds[t]:m.threadIds[t];return d.get({key:r})},t[25]=m,t[26]=d,t[27]=_):_=t[27];let v,y,b,x,S,C;t[28]===n?(v=t[29],y=t[30],b=t[31],x=t[32],S=t[33],C=t[34]):(v=(e,t)=>HL(`switch`,()=>n.switchToThread(e,t)),y=()=>HL(`create`,()=>n.switchToNewThread()),b=()=>n.getLoadThreadsPromise(),x=()=>n.reload(),S=()=>n.reloadMainThread(),C=()=>n.loadMore(),t[28]=n,t[29]=v,t[30]=y,t[31]=b,t[32]=x,t[33]=S,t[34]=C);let w;t[35]===r?w=t[36]:(w=()=>r,t[35]=r,t[36]=w);let T;return t[37]!==v||t[38]!==y||t[39]!==b||t[40]!==x||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==h||t[45]!==g||t[46]!==_?(T={getState:h,thread:g,item:_,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:b,reload:x,reloadMainThread:S,loadMore:C,__internal_getAssistantRuntime:w},t[37]=v,t[38]=y,t[39]=b,t[40]=x,t[41]=S,t[42]=C,t[43]=w,t[44]=h,t[45]=g,t[46]=_,t[47]=T):T=t[47],T}),qL=(e,t)=>{e.thread??=TI({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=TI({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=TI({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=XI()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=TI({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},JL=e=>{let t=J(7),n=IF(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),LF(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=KL({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),NP(a)},YL=GN(JL);bF(JL,(e,t)=>{qL(e,t),!e.tools&&t.tools.source===null&&(e.tools=tL({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=BP())});var XL=e=>{let{children:t,condition:n}=e;return $(n)?t:null};XL.displayName=`AuiIf`;var ZL=GP({}),QL=({effects:e})=>{"use no memo";return AN(e),null},$L=Z(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=_F();if($F){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==uF)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??uF:a?e.value??uF:o,c=VF(),{client:l,effects:u}=vI(s,n??ZL,c);return IN(t,()=>l,[l]),(0,b.jsx)(zF.Provider,{value:c,children:(0,b.jsxs)(fF.Provider,{value:l,children:[(0,b.jsx)(QL,{effects:hF(s)}),u&&(0,b.jsx)(QL,{effects:u}),r]})})}),eR=e=>{let t=Q(),n=Y(!1),r=n.current?null:e(t);return $(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},tR=Object.freeze({});function nR(e){let t=J(3),{getItemState:n,children:r}=e,i=eR(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],rR(a)}var rR=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return ON(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?tR:t?.props])??e},iR=(e,t)=>{let n=J(11),r=Q(),i=jN(t),a;n[0]===e?a=n[1]:(a=SF(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],X(c,l)},aR=e=>e._core?.RenderComponent,oR=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=aR(e),a=GP({...n,threads:YL(e)});return(0,b.jsxs)($L,{extends:t,config:a,children:[i&&(0,b.jsx)(i,{}),r]})},sR=LN(e=>{let t=J(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,b.jsx)(oR,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s});function cR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lR(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>lR(e,t+1)):cR(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&lR(n,t+1)):!1}var uR=100,dR=(e,t,n)=>{if(e===t)return!0;if(n>uR||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>dR(e,t[r],n+1));if(Array.isArray(t)||!cR(e)||!cR(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&dR(e[r],t[r],n+1))},fR=(e,t)=>!lR(e)||!lR(t)?!1:dR(e,t,0);function pR(e){let t=Y(e);return t.current!==e&&!fR(t.current,e)&&(t.current=e),t.current}function mR(e){let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&fR(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r}var hR=Symbol.for(`aui.tool-response`),gR=`<no result>`,_R=class e{get[hR](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?gR:t,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&hR in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?gR:t})}},vR=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},yR=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o=0,s,c,l=()=>(a=void 0,c??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),c),u=e=>{n||r||(r=!0,console.error(e),l(),i.error(e),s?.reject(e),s=void 0)},d=a=>{a.promise||=a.reader.read().then(({done:c,value:l})=>{a.promise=void 0,!(n||r)&&(c?(e.splice(e.indexOf(a),1),a.reader.releaseLock(),t&&e.length===0&&o===0&&i.close()):i.enqueue(l),s?.resolve(),s=void 0)}).catch(u)},f=new ReadableStream({start(e){i=e},pull(){return s=vR(),e.forEach(e=>{d(e)}),s.promise},async cancel(){n=!0;let e=l();s?.resolve(),s=void 0,await e}}),p=c=>{if(e.length>0&&(a=void 0),!a){let c=[];a=c,o++,Promise.resolve().then(()=>{if(o--,a===c&&(a=void 0),!(n||r)){for(let e of c)i.enqueue(e);t&&e.length===0&&o===0&&i.close(),s?.resolve(),s=void 0}}).catch(u)}a.push(c)};return{readable:f,isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&o===0&&i.close())},addStream:(i,o)=>{let s=o?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);a=void 0;let c={reader:i.getReader(),pipeTask:s};e.push(c),d(c)},enqueue(e){if(!(n||r)){if(t)throw Error(`Cannot add streams after the run callback has settled.`);p(e)}}}},bR=e=>e instanceof TypeError,xR=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!bR(e))throw e;n?.(e)}},SR=e=>{try{e.close()}catch(e){if(!bR(e))throw e}},CR=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),wR=(e,t)=>{let n;return[CR({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},TR=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};if(this._isClosed){if(this._strict)throw TypeError(`Cannot append to a closed TextStreamController`);return xR(this._controller,t,this._warnDroppedAfterClose),this}return xR(this._controller,t),this}_warnDroppedAfterClose=e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))};close(){this._isClosed||(this._isClosed=!0,xR(this._controller,{type:`part-finish`,path:[]}),SR(this._controller))}},ER=(e,t={})=>CR(e,e=>new TR(e,t)),DR=(e={})=>wR(t=>new TR(t,e)),OR=class{_isClosed=!1;_mergeTask;_controller;constructor(e,t={}){this._controller=e;let n=ER({start:e=>{this._argsTextController=e}},t),r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:r=!0,xR(this._controller,e);break;case`part-finish`:r||xR(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),xR(this._controller,{type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;xR(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?gR:t,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,xR(this._controller,{type:`part-finish`,path:[]}),SR(this._controller))}},kR=(e={})=>wR(t=>new OR(t,e)),AR=class{value=-1;up(){return++this.value}},jR=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var MR=class extends TransformStream{constructor(e){let t=new AR,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},NR=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},PR=NR(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),FR=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:yR(),contentCounter:new AR}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new jR(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new MR(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=DR({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=DR({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??PR(),[i,a]=kR({strict:this._state.strict});return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function IR(e,t={}){let n=new FR(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function LR(e={}){let{resolve:t,promise:n}=vR(),r;return[IR(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var RR=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},zR=r(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),BR=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},VR=/[0-9a-fA-F]/;function HR(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!VR.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`+`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var UR=n(zR(),1),WR=Symbol(`aui.parse-partial-json-object.meta`),GR=e=>e?.[WR],KR=e=>{if(e.length===0)return{[WR]:{state:`partial`,partialPath:[]}};try{let t=UR.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[WR]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=HR(e),r=UR.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[WR]={state:`partial`,partialPath:n},r}catch{return}}},qR=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return qR(s,{state:`partial`,partialPath:o},i)},JR=(e,t)=>{let n=GR(e);if(!n)throw Error(`unable to determine object state`);return qR(e,n,t.map(String))},YR=new Set([`__proto__`,`constructor`,`prototype`]);function XR(e){if(YR.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var ZR=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);let r=[],i=e;for(let e=0;e<t.length;e++){if(i??={},typeof i!=`object`)throw Error(`Invalid path: [${t.slice(e).join(`, `)}]`);let n=t[e];if(XR(n),Array.isArray(i)){let a=Number(n);if(!Number.isInteger(a)||String(a)!==String(n))throw Error(`Expected array index at [${t.slice(e).join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>i.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${i.length}`)),a=i.length}r.push({kind:`array`,state:i,key:a}),i=Object.hasOwn(i,a)?i[a]:void 0}else{let e=i;r.push({kind:`object`,state:e,key:n}),i=Object.hasOwn(e,n)?e[n]:void 0}}let a=n(i);for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.kind===`array`){let e=[...t.state];e[t.key]=a,a=e}else{let e={...t.state};e[t.key]=a,a=e}}return a}},QR=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},$R=(e,t)=>({...e,parts:t,get content(){return this.parts}}),ez=(e,t)=>$R(e,[...e.parts,t]),tz=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),nz=16,rz=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:$R(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},iz=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return ez(e,{type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`tool-call`)return ez(e,{type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}});if(r.type===`source`)return ez(e,{type:`source`,sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`file`)return ez(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return ez(e,{type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}});{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),ez(e,{type:`reasoning`,text:``,status:{type:`running`}})}},az=(e,t,n)=>rz(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`,status:e.status.type===`running`?{type:`running`,isArgsComplete:!0}:e.status}:e:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),oz=(e,t,n)=>rz(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),sz=(e,t,n)=>rz(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=KR(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),cz=(e,t,n)=>rz(e,t,n,e=>e.type===`tool-call`?{...e,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}:(n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e)),lz=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=uz(t);return{...e,status:n}},uz=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},dz=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),fz=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),pz=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),mz=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:PR(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},hz=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},gz=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),_z=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},vz=(e,t,n=0)=>{let r=n>0?n:_z(t);if(r>0)return e.getTiming(r);let i=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(i+=e.text);return e.getTiming(void 0,i||void 0)},yz=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},bz=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??tz(),a,o,s=new QR,c=new Set,l=(e,t)=>{c.has(e)||c.size>=nz||(c.add(e),console.warn(t))},u,d=t?yz(()=>{u?.enqueue(i)}):()=>{u?.enqueue(i)};super({start(e){u=e},transform(e){s.recordChunk();let t=e.type;switch(t){case`part-start`:i=iz(i,e,l),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=az(i,e,l);break;case`part-finish`:i=oz(i,e,l);break;case`text-delta`:{let t=sz(i,e,l);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=cz(i,e,l);break;case`message-finish`:o=e.usage?.outputTokens,i=lz(i,e);break;case`annotations`:i=dz(i,e);break;case`data`:i=fz(i,e);break;case`step-start`:i=pz(i,e);break;case`step-finish`:i=mz(i,e);break;case`error`:i=hz(i,e),n?.(e.error);break;case`update-state`:a??=new ZR(i.metadata.unstable_state,{strict:r}),i=gz(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:vz(s,i,o)}}),d()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&e.result===void 0)??!1;i=lz(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:vz(s,i,o)}},e.enqueue(i)}}})}};async function*xz(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function Sz(e){return e[Symbol.asyncIterator]??=xz,e}var Cz=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new bz))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return Sz(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function wz(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function Tz(e,t){let n=e;for(let e of t){if(n==null||!Object.hasOwn(n,e))return;n=n[e]}return n}var Ez=class{resolve;reject;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(JR(e,this.fieldPath)===`complete`){let t=Tz(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=Tz(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},Dz=class{controller;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=Tz(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),JR(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},Oz=class{controller;disposed=!1;fieldPath;lastValue=void 0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=Tz(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}JR(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},kz=class{controller;disposed=!1;fieldPath;nextIndex=0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=Tz(e,this.fieldPath);if(!Array.isArray(t))return;for(;this.nextIndex<t.length&&JR(e,[...this.fieldPath,this.nextIndex])===`complete`;this.nextIndex++)this.controller.enqueue(t[this.nextIndex]);JR(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},Az=class{argTextDeltas;handles=new Set;accumulatedText=``;parsedTextLength=-1;args=void 0;finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=this.argTextDeltas.getReader();for(;;){let{value:t,done:n}=await e.read();if(n)break;this.accumulatedText+=t,this.handles.size!==0&&this.parseCurrentArgs()&&this.updateHandles()}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}parseCurrentArgs(){if(this.parsedTextLength===this.accumulatedText.length)return!1;let e=KR(this.accumulatedText);return this.parsedTextLength=this.accumulatedText.length,e===void 0?(this.args??=KR(``),!1):(this.args=e,!0)}updateHandles(){for(let e of this.handles)e.update(this.args),e.isDisposed&&this.handles.delete(e)}activateHandle(e){if(this.parseCurrentArgs(),e.update(this.args),!e.isDisposed){if(this.finished){e.end(this.args);return}this.handles.add(e)}}get(...e){return new Promise((t,n)=>{let r=new Ez(t,n,e);this.activateHandle(r)})}streamValues(...e){let t=e,n;return Sz(new ReadableStream({start:e=>{n=new Dz(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return Sz(new ReadableStream({start:e=>{n=new Oz(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return Sz(new ReadableStream({start:e=>{n=new kz(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},jz=class{promise;constructor(e){this.promise=e}get(){return this.promise}},Mz=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new Az(e.readable);let{promise:t,resolve:n}=vR();this.resolve=n,this.response=new jz(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},Nz=Symbol.for(`assistant-stream.tool-execution-id`),Pz=(e,t,n,r,i)=>{try{let a=t?.(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},Fz=e=>e.join(`,`),Iz=(e,t)=>{let n={...e};return Object.defineProperty(n,Nz,{value:t,enumerable:!0}),n},Lz=class extends RR{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({async transform(e,s){let c=a.get(Fz(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?Iz(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new Mz,o=Symbol();a.set(String(n),o),r.set(o,i),t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(Fz(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);await n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(Fz(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new _R({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent,messages:e.messages})),i.add(t);break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(Fz(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(await u.finishArgsText(),i.has(l))break;let d=!1,f=wz(()=>{let e;try{e=UR.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,Pz(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&Pz(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new _R({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),xR(s,Iz({type:`result`,path:e.path,...r},l))},n=>{d&&Pz(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new _R({result:String(n),isError:!0});u.setResponse(r),xR(s,Iz({type:`result`,path:e.path,...r},l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(Fz(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(Fz(e.path)))};o?o.then(()=>{c(),xR(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new BR).pipeThrough(s)})}},Rz=Symbol.for(`assistant-stream.tool-execution-id`),zz=Symbol(`assistant-stream.tool-aborted`),Bz=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,Vz=e=>typeof e?.then==`function`,Hz=async(e,t,n=!1)=>{let r,i=new Promise(e=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>e(zz))):e(zz)},t.aborted?r():t.addEventListener(`abort`,r,{once:!0})});try{return await Promise.race([e,i])}finally{t.removeEventListener(`abort`,r)}},Uz=()=>new _R({result:`Tool execution was cancelled.`,isError:!0});function Wz(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return Uz();let a=e;if(Bz(i.parameters)){let e=i.parameters[`~standard`].validate(n.args),r=Vz(e)?await Hz(e,t):e;if(r===zz)return Uz();r.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(r.issues)}`)}))}if(t.aborted)return Uz();let o=await Hz((async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[Rz]:n.executionId},o=await a(n.args,e),s=_R.toResponse(o);if(i.toModelOutput&&!s.isError&&s.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:s.result});return new _R({result:s.result,artifact:s.artifact,isError:s.isError,messages:s.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return s})(),t,!0);return o===zz?Uz():o})(i.execute):void 0}function Gz(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[Rz]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function Kz(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new Lz({execute:e=>Wz(i(),a(),e,s),streamCall:({reader:e,...t})=>Gz(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}var qz=new Set([`http://json-schema.org/draft-07/schema`,`https://json-schema.org/draft-07/schema`]);function Jz(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}function Yz(e){return typeof e==`object`&&!!e&&`toJSONSchema`in e&&typeof e.toJSONSchema==`function`}function Xz(e){return typeof e==`object`&&!!e&&`toJSON`in e&&typeof e.toJSON==`function`}function Zz(e){if(typeof e==`object`&&e){let t=e.$schema;if(typeof t==`string`&&!qz.has(t.replace(/#$/,``)))throw Error(`The schema library was asked for a draft-07 JSON Schema and returned "${t}". Upgrade the library, or pass a plain JSON Schema object instead.`)}return e}function Qz(e){if(Jz(e)){let t=e[`~standard`].jsonSchema;if(typeof t==`object`&&t&&typeof t.input==`function`)return Zz(t.input({target:`draft-07`}))}if(Yz(e))return e.toJSONSchema({target:`draft-07`});if(Xz(e))return e.toJSON();if(Jz(e)){let{vendor:t}=e[`~standard`],n=t===`zod`?`convert it with z.toJSONSchema(schema)`:`wrap the schema with ${t}'s Standard JSON Schema helper`;throw Error(`Could not convert the "${t}" schema to JSON Schema: it has no "~standard.jsonSchema" converter. Upgrade ${t} to a release that implements Standard JSON Schema, ${n}, or pass a plain JSON Schema object instead.`)}return e}function $z(e){let{required:t,...n}=e;return n.properties&&=Object.fromEntries(Object.entries(n.properties).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?[e,$z(t)]:[e,t])),n}function eB(e){return pR(ON(()=>{try{let t=Qz(e);return lR(t)?t:null}catch{return null}},[e]))}var tB=e=>{let t=J(17),n=Q(),r;t[0]===e?r=t[1]:(r=t=>t.unstable_interactables.definitions[e]?.state,t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>t.unstable_interactables.persistence[e],t[2]=e,t[3]=a);let o=$(a),s;t[4]!==n||t[5]!==e?(s=t=>{n.unstable_interactables.setState(e,e=>typeof t==`function`?t(e):t)},t[4]=n,t[5]=e,t[6]=s):s=t[6];let c=s,l;t[7]===n?l=t[8]:(l=()=>n.unstable_interactables.flush(),t[7]=n,t[8]=l);let u=l,d=o?.isPending??!1,f=o?.error,p;t[9]!==u||t[10]!==c||t[11]!==d||t[12]!==f?(p={setState:c,isPending:d,error:f,flush:u},t[9]=u,t[10]=c,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==i||t[15]!==p?(m=[i,p],t[14]=i,t[15]=p,t[16]=m):m=t[16],m};function nB(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function rB(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var iB=e=>{if(!cR(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function aB(e,t,n){let r=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(r=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);r=r.filter(t=>{let n=iB(t);return n===void 0?!e.has(t):!e.has(n)})}let i=t.update;if(Array.isArray(i)&&i.length>0){let e=new Map;for(let t of i){let n=iB(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}r=r.map(t=>{let n=iB(t);if(n===void 0||!cR(t))return t;let r=e.get(n);return r?{...t,...r}:t})}if(Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!cR(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;r=[...r,...e]}return r}function oB(e,t,n){if(!cR(e)||!cR(t))return t;let r=cR(n?.arrayBaseline)?n.arrayBaseline:e,i=Object.entries(e);for(let[e,a]of Object.entries(t)){let t=r[e];if(Array.isArray(t)&&cR(a)){let r=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0;i.push([e,aB(t,a,r)])}else i.push([e,a])}return Object.fromEntries(i)}function sB(e,t){if(!cR(e)||!cR(t))return;for(let n of Object.keys(e))if(!Object.hasOwn(t,n))return;let n=[];for(let[r,i]of Object.entries(t))(!Object.hasOwn(e,r)||!fR(e[r],i))&&n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var cB=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},lB=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=cR(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},uB=e=>{let t=cR(e)?e.addedItemIds:void 0;if(!cR(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},dB=new WeakMap;function fB(e,t,n){let r=dB.get(e);r||(r=new Map,dB.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=rB(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=nB(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:oB(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=cB(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&lB(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=uB(r.result);s.push({state:i?oB(e.state,n,{idFactory:i}):oB(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function pB(e,t,n){let r=fB(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function mB(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=pB(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(fR(r.state,n.state))continue;let i=sB(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var hB=(e,t)=>{let n=Q(),r=FN().replace(/[^a-zA-Z0-9]/g,``),i=rB(e),a=$(e=>{let t=e.optional.part;return t?.type===`tool-call`?t:void 0}),o;if(a?.toolName===i){let e=a.result,t=a.args;e?.success!==!1&&(typeof e?.id==`string`?o=e.id:typeof t?.id==`string`&&(o=t.id))}let s=t.id??o??r,c=a?.toolName===e||a?.toolName===i?`thread`:void 0,l=Y(t.stateSchema);l.current=t.stateSchema;let u=eB(t.stateSchema),d=Y(t.initialState);d.current=t.initialState;let f=$(()=>n.unstable_interactables);X(()=>f.register({id:s,name:e,description:t.description,stateSchema:l.current,initialState:d.current,updateRender:t.updateRender,...c?{scope:c}:{}}),[f,s,e,t.description,u,c,t.updateRender]);let p=a?.toolCallId,[m,h]=tB(s),{setState:g}=h,_=$(mR(t=>{if(!c||!p)return;let n=fB(t.thread.messages,s,e);if(!n.some(e=>e.origin===`create`&&e.toolCallId===s))return;let r=n.find(e=>e.toolCallId===p);if(!r)return;let i=n.findLast(e=>e.toolCallId!==void 0)?.toolCallId;return{state:r.state,isLatest:i===p}})),v=ON(()=>_&&{state:_.state,isLatest:_.isLatest,restore:()=>g(_.state)},[_,g]);return[m===void 0?t.initialState:m,{id:s,version:v,...h}]},gB=HN(null),_B=(e,t)=>JM(gB,e,t),vB=()=>WN(gB),yB={},bB=e=>{let t=ZF(e??yB);return e==null?null:t},xB=Symbol(`innerMessage`),SB=Symbol(`innerMessages`),CB=[],wB=(e,t)=>{xB in e||(e[xB]=t)},TB=e=>{let t=`messages`in e?e.messages:e,n=t[SB]||t[xB];return n?Array.isArray(n)?n:(t[SB]=[n],t[SB]):CB},EB=`__external_store_fallback_`,DB=NR(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7);function OB(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var kB=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},AB=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?OB(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId||`tool-${DB()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:KR(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=kB(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=kB(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>kB(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},jB=e=>e.type===`tool-call`&&e.result===void 0,MB=e=>{if(e.type!==`tool-call`||e.result!==void 0)return!1;let t=e.messages?.at(-1);return t?.role===`assistant`&&t.status.type===`running`},NB=e=>e.type!==`tool-call`||e.result!==void 0?!1:e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,PB=Symbol(`autoStatus`),FB=Object.freeze(Object.assign({type:`running`},{[PB]:!0})),IB=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[PB]:!0})),LB=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[PB]:!0})),RB=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[PB]:!0})),zB=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[PB]:!0})),BB=e=>e[PB]===!0,VB=(e,t,n,r,i,a,o)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[PB]:!0}):e&&t?FB:n?zB:o&&!a?FB:r?RB:a?LB:IB,HB=e=>VB(!1,!1,typeof e!=`string`&&e.some(NB),typeof e!=`string`&&e.some(jB)),UB=(e,t,n)=>VB(t,n,typeof e!=`string`&&e.some(NB),typeof e!=`string`&&e.some(jB),void 0,void 0,typeof e!=`string`&&e.some(MB)),WB=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},GB=(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},KB=500,qB=({adapterRef:e,snapshot:t,updatePersistenceStatus:n})=>{let r=Y(void 0),i=Y(0),a=Y(new Map),o=Y(0),s=Y([]),c=Y(new Set),l=Y([]),u=Y(()=>{}),d=kN(e=>{if(c.current.size===0)return;let n=new Set(c.current);c.current.clear();let r=++i.current;for(let e of n)a.current.set(e,r);return{adapter:e,payload:t(),dirtyIds:n,seq:r}},[t]),f=kN(e=>{let t=d(e);t&&(o.current===0?u.current(t):l.current.push(t))},[d]),p=kN(async t=>{let i=t??(e.current?d(e.current):void 0);if(!i){if(o.current===0){for(let e of s.current)e();s.current=[]}return}let{adapter:f,payload:p,dirtyIds:m,seq:h}=i;o.current+=1,n(e=>{let t=OM(e);for(let e of m)t[e]={isPending:!0,error:void 0};return t});let g=e=>{let t=[];for(let e of m)a.current.get(e)!==h||c.current.has(e)||(a.current.delete(e),t.push(e));t.length!==0&&n(n=>{let r=!1,i=OM(n);for(let a of t)n[a]!==void 0&&(e===void 0?delete i[a]:i[a]=e,r=!0);return r?i:n})};try{await f.save(p),g(void 0)}catch(e){g({isPending:!1,error:e})}finally{--o.current;let t=l.current.shift()??(e.current&&c.current.size>0?d(e.current):void 0);if(t)r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),u.current(t);else if(o.current===0){for(let e of s.current)e();s.current=[]}}},[e,d,n]);return u.current=e=>{p(e)},{flushIfPending:kN(()=>{r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),e.current&&f(e.current)},[e,f]),schedulePersistence:kN(t=>{e.current&&(c.current.add(t),r.current!==void 0&&clearTimeout(r.current),r.current=setTimeout(()=>{r.current=void 0,o.current===0&&e.current?f(e.current):r.current=setTimeout(()=>{r.current=void 0,e.current&&f(e.current)},KB)},KB))},[e,f]),flush:kN(async()=>{if(r.current!==void 0&&(clearTimeout(r.current),r.current=void 0),!(o.current>0||c.current.size>0||l.current.length>0))return;let t=new Promise(e=>{s.current.push(e)});return e.current&&f(e.current),t},[e,f])}},JB={type:`string`,description:`The id of the instance to update, as shown in its state snapshot in the conversation.`},YB={type:`string`,description:`The id of an item currently in this list.`},XB=e=>{let t=e.properties;return cR(t)&&t.id!==void 0},ZB=e=>({...e,required:[`id`]}),QB=e=>{let{id:t,...n}=cR(e.properties)?e.properties:{},r=Array.isArray(e.required)?e.required.filter(e=>e!==`id`):e.required;return{...e,properties:n,required:r}},$B=(e,t)=>{if(!cR(e)||e.type!==`array`)return e;let n=e.items;if(Array.isArray(n)||!cR(n))return e;let r=XB(n),i={add:{type:`array`,items:r?QB(n):n},remove:{type:`array`,items:r?YB:n},clear:{type:`boolean`}};return r&&(i.update={type:`array`,items:ZB(n)}),{type:`object`,description:`Operations for array field "${t}". To change one item use update with its id; add new items (their ids are assigned for you), remove items by id, or clear to empty. Change only the items you mean to — never resend the whole array to edit one item.`,properties:i,additionalProperties:!1}},eV=e=>{let t=new Set;for(let[n,r]of Object.entries(e))cR(r)&&r.type===`array`&&cR(r.items)&&XB(r.items)&&t.add(n);return t},tV=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,$B(t,e)]));function nV(e){if(!e||typeof e!=`object`||e.type!==`object`)return{type:`object`,properties:{id:JB},required:[`id`],additionalProperties:!0};let{id:t,...n}=e.properties??{};return{...e,properties:{id:JB,...tV(n)},required:[`id`]}}function rV(e,t,n,r=new Map){let i=Object.values(e);if(i.length===0)return;let a=new Map;for(let e of i){let t=a.get(e.name)??[];t.push(e),a.set(e.name,t)}let o={};for(let[i,s]of a){let a=rB(i);if(o[a])continue;let c=s[0],l=t.get(c.id),u=l&&cR(l.properties)?eV(l.properties):new Set,d=t=>{if(typeof t==`string`){let n=e[t];return n?.name===i?n:void 0}return s.length===1?c:void 0};o[a]={type:`frontend`,description:`Update the state of interactable component "${i}". ${c.description} Pass the id of the instance to update — instance ids and current state appear in the conversation as state snapshots. Only include the fields you want to change; omitted fields keep their current values.`,parameters:nV(l),streamCall:async(e,{toolCallId:t})=>{try{for await(let i of e.args.streamValues()){if(!i||typeof i!=`object`)continue;let e=i,a=Object.keys(e);if(a.indexOf(`id`)===a.length-1)continue;let{id:o,...s}=e;if(Object.keys(s).length===0)continue;let c=d(o);if(!c)continue;let l=r.get(t),u=l?.targetId===c.id?l.state:c.state;(!l||l.targetId!==c.id)&&r.set(t,{targetId:c.id,state:c.state}),n(c.id,e=>oB(e,s,{arrayBaseline:u}))}}catch{}},execute:async(e,{toolCallId:t})=>{let{id:a,...o}=e??{},c=d(a);if(!c){let e=s.map(e=>e.id);return{success:!1,error:`Unknown id ${JSON.stringify(a)} for interactable "${i}". Valid ids: ${e.join(`, `)}`}}let l=r.get(t);r.delete(t);let f=OM();n(c.id,e=>oB(e,o,{arrayBaseline:l?.targetId===c.id?l.state:void 0,idFactory:e=>{let t=DB();return(f[e]??=[]).push(t),t},idKeyedFields:u}));let p={success:!0,id:c.id};return Object.keys(f).length>0&&(p.addedItemIds={...f}),p}}}return{tools:o,unstable_composerMetadata:{interactables:i.map(e=>({id:e.id,name:e.name,state:e.state}))}}}var iV=(e,t,n)=>e.some(e=>e.role===`assistant`&&e.content?.some(e=>{if(!e||typeof e!=`object`)return!1;let r=e;return r.type===`tool-call`&&r.toolCallId===t&&r.toolName===n})),aV=({persistence:e}={})=>{let[t,n]=EN(()=>({definitions:OM(),persistence:OM()})),r=IF(),i=Y(t),a=Y(new Set),o=Y(new Map),s=Y(new Map),c=Y(new Map),l=Y(new Map),u=Y(new Map),d=Y(new Map),f=Y(new Map),p=Y(new Map),m=Y(new Set),h=Y(void 0),g=kN(e=>{let t=e(i.current);i.current=t,n(t)},[]),_=kN(()=>{let e=OM();for(let[t,n]of Object.entries(i.current.definitions))n.scope!==`thread`&&(e[t]={name:n.name,state:n.state});return e},[]),{flushIfPending:v,schedulePersistence:y,flush:b}=qB({adapterRef:h,snapshot:_,updatePersistenceStatus:kN(e=>{g(t=>{let n=e(t.persistence);return n===t.persistence?t:{...t,persistence:n}})},[g])}),x=kN((e,t)=>{let n=t.shouldStash??(()=>!0),r=t.shouldApply??(()=>!0);for(let[r,i]of Object.entries(e))n(r)&&t.stash.set(r,i.state);g(t=>{let n=!1,i=OM(t.definitions);for(let[t,a]of Object.entries(e)){let e=i[t];e&&r(t,e)&&(i[t]={...e,state:a.state},n=!0)}return n?{...t,definitions:i}:t})},[g]),S=kN(e=>{x(e,{stash:l.current})},[x]),C=kN(e=>{x(e,{stash:p.current,shouldStash:e=>!m.current.has(e),shouldApply:(e,t)=>!m.current.has(e)&&t.scope!==`thread`})},[x]),w=kN(async e=>{if(e.load)try{let t=await e.load();if(!t||h.current!==e)return;C(t)}catch(e){console.warn(`[Interactables] Persistence load failed.`,e)}},[C]),T=kN(e=>{h.current!==e&&v(),h.current=e,e&&w(e)},[v,w]),E=kN(()=>{let e=r.current;if(!e)return;let t=e.threadListItem;if(t.source!=null)return t().getState().id;let n=e.threads;if(n.source!=null)return n().getState().mainThreadId},[r]);X(()=>{if(e)return T(e),()=>{h.current===e&&T(void 0)}},[e,T]);let D=kN((e,t)=>{m.current.add(e),g(n=>{let r=n.definitions[e];return r?{...n,definitions:OM(n.definitions,{[e]:{...r,state:t(r.state)}})}:n}),i.current.definitions[e]?.scope!==`thread`&&y(e)},[y,g]),O=ON(()=>({getModelContext:()=>{let e=i.current.definitions;return rV(e,o.current,D,c.current)??{}},subscribe:e=>(a.current.add(e),()=>{a.current.delete(e)})}),[D]);X(()=>{FI(a.current)},[t]),LF(`modelContext`,()=>r.current.modelContext().register(O),[O]);let k=kN((e,t)=>{let n=r.current?.tools;return!n||n.source==null?!1:(t.unsubscribe=n().setToolUI(rB(e),t.render,{standalone:!0}),!0)},[r]);return LF(`tools`,()=>{for(let[e,t]of f.current)t.unsubscribe?.(),t.unsubscribe=void 0,k(e,t);return()=>{for(let e of f.current.values())e.unsubscribe?.(),e.unsubscribe=void 0}},[k]),{getState:()=>i.current,register:kN(e=>{let t=r.current?.thread,n=t&&t.source!=null?t().getState().messages??[]:[],i=e.scope??(iV(n,e.id,e.name)?`thread`:`app`);d.current.set(e.id,(d.current.get(e.id)??0)+1);let a;if(e.updateRender){let t=f.current.get(e.name),n=t??{count:0,render:e.updateRender,unsubscribe:void 0};n.count++,t||f.current.set(e.name,n),!n.unsubscribe&&k(e.name,n),a=()=>{let t=f.current.get(e.name);t&&--t.count===0&&(f.current.delete(e.name),t.unsubscribe?.(),t.unsubscribe=void 0)}}if(s.current.get(e.id)!==e.stateSchema){s.current.set(e.id,e.stateSchema),o.current.delete(e.id);try{let t=Qz(e.stateSchema);o.current.set(e.id,$z(t))}catch(t){console.warn(`[Interactables] Failed to create partial schema for "${e.name}". The update tool will accept arbitrary fields without validation.`,t)}}let c=i===`thread`?E():void 0,m=i===`thread`?c?u.current.get(c)?.get(e.id):void 0:l.current.get(e.id);i===`thread`?c&&u.current.get(c)?.delete(e.id):l.current.delete(e.id);let h=i===`thread`?void 0:p.current.get(e.id),_=i===`thread`?pB(n,e.id,e.name):void 0;return g(t=>({...t,definitions:OM(t.definitions,{[e.id]:{id:e.id,name:e.name,description:e.description,stateSchema:e.stateSchema,initialState:e.initialState,scope:i,state:t.definitions[e.id]?.state??m??_?.state??h??e.initialState}})})),()=>{a?.();let t=(d.current.get(e.id)??1)-1;if(t>0){d.current.set(e.id,t);return}d.current.delete(e.id),v(),g(t=>{let n=t.definitions[e.id];if(n){if(n.scope===`thread`){let t=E();if(t){let r=u.current.get(t);r||(r=new Map,u.current.set(t,r)),r.set(e.id,n.state)}}else l.current.set(e.id,n.state)}s.current.delete(e.id),o.current.delete(e.id);let r=OM(t.definitions),i=OM(t.persistence);return delete r[e.id],delete i[e.id],{...t,definitions:r,persistence:i}})}},[v,r,E,k,g]),setState:D,exportState:_,importState:S,setPersistenceAdapter:T,flush:b}},oV=GN(aV);bF(aV,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=XI())});var sV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({attachment:TI({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},cV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({attachment:TI({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},lV=e=>{let t=J(6),{runtime:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({threadListItem:UL({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},uV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({message:TI({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:TI({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},dV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({part:TI({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},fV=GN(e=>{let t=J(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:mV,resumeToolCall:hV,respondToToolApproval:gV},t[5]=o,t[6]=s),s}),pV=e=>{let t=J(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=Q(),s;t[0]!==a||t[1]!==n?(s=GP({part:fV({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,b.jsx)($L,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function mV(){throw Error(`Not supported`)}function hV(){throw Error(`Not supported`)}function gV(){throw Error(`Not supported`)}var _V=e=>{for(let t of e)if(t?.status.type===`running`)return EL;return e.at(-1)?.status??TL},vV=(e,t)=>{let n={running:0,complete:0,incomplete:0,requiresAction:0},r=TL,i=!1;for(let a of t)switch(r=e[a]?.status??TL,r.type){case`running`:n.running++,i=!0;break;case`complete`:n.complete++;break;case`incomplete`:n.incomplete++;break;case`requires-action`:n.requiresAction++}return{status:i?EL:r,counts:n}},yV=GN(e=>{let t=J(11),{parts:n,getMessagePart:r}=e,[i,a]=EN(!0),o;t[0]===n?o=t[1]:(o=_V(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),bV=e=>{let t=J(4),{startIndex:n,endIndex:r,children:i}=e,a=$(xV).slice(n,r+1),o=Q(),s=GP({chainOfThought:yV({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message.part({index:n+t})}})}),c;return t[0]!==i||t[1]!==s||t[2]!==o?(c=(0,b.jsx)($L,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function xV(e){return e.message.parts}var SV=e=>{let t=J(7),{index:n,archived:r,children:i}=e,a=Q(),o;t[0]!==r||t[1]!==n?(o=GP({threadListItem:TI({source:`threads`,query:{type:`index`,index:n,archived:r},get:e=>e.threads.item({index:n,archived:r})})}),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==a||t[4]!==i||t[5]!==s?(c=(0,b.jsx)($L,{extends:a,config:s,children:i}),t[3]=a,t[4]=i,t[5]=s,t[6]=c):c=t[6],c},CV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({suggestion:TI({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},wV=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({queueItem:TI({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},TV=Symbol.for(`assistant-ui.message-not-sent`),EV=e=>typeof e==`object`&&!!e&&TV in e,DV=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},OV=class extends DV{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},kV=class extends OV{get source(){return`thread-composer`}},AV=class extends OV{get source(){return`edit-composer`}},jV=class extends DV{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},MV=Object.freeze([]),NV=Object.freeze({}),PV=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??MV,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??NV,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??MV,value:e?.text??``}),FV=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??MV,runConfig:e?.runConfig??NV,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??MV,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),IV=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new WI({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},LV=class extends IV{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new HI({path:e.path,getState:()=>PV(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new kV(new VI({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:PI},subscribe:e=>this._core.subscribe(e)}),this._core)}},RV=class extends IV{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new HI({path:e.path,getState:()=>FV(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new AV(new VI({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:PI},subscribe:e=>this._core.subscribe(e)}),this._core)}},zV=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
91
91
 
92
- `),kV=`ui://`,AV=e=>!!e?.startsWith(kV),jV=e=>e.display===`text`||e.allowFreeform===!0,MV={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},NV=(e,t)=>{let n=t.text;if(n!==void 0&&!jV(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){let n=e.options?.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(MV,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=MV[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:e.id,approved:r,...i!==void 0&&{optionId:i},...n!==void 0&&{text:n},...t.reason!=null&&{reason:t.reason}}},PV=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=oR.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,isError:a.isError,...a.artifact!==void 0&&{artifact:a.artifact},...a.modelContent!==void 0&&{modelContent:a.modelContent}})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);return this.threadApi.getState().respondToToolApproval(NV(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},FV=(e,t)=>{let n=e.content[t];if(!n)return CI;let r=vL(e,t,n);return Object.freeze({...n,[uB]:n[uB],status:r})},IV=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new DV(new MI({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e,comment:t}){let n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:e,...t===void 0?void 0:{comment:t}})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return OV(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new PV(new AI({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>FV(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new PV(new AI({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?CI:FV(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new bV(new AI({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:CI},subscribe:e=>this._core.subscribe(e)}))}},LV=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),RV=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),zV=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId===void 0?e.at(-1)?.id??null:t.parentId,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},BV=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},VV=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:BV(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),HV=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new AI({path:e.path,getState:()=>VV(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>TI([r,i])}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new EV(new MI({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){let t=this._threadBinding.getState().append(zV(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!hV(e))throw e})}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(RV(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(LV(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new IV(new AI({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return CI;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[uB]:e[uB],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new NI({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},UV=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),WV=class extends DI{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},GV=e=>{let t=J(6),{adapters:n,children:r}=e,i=NN(aB),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,b.jsx)(aB.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},KV=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(e){let t=this._core.getState();return this._threadListBinding.generateTitle(t.id,e)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,(e!==`switchedTo`||a)&&(e===`switchedAway`&&a||NP([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},qV=Promise.resolve(),JV=()=>{},YV=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,loadError:e.loadError,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),XV=(e,t)=>{if(t===void 0)return CI;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:CI},ZV=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=HV){this._core=e,this._runtimeFactory=t;let n=new jI({path:{},getState:()=>YV(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new KV(new AI({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>XV(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new MI({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){return this._core.unstable_subscribeThreadEvents?.(e)??JV}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??qV}reloadMainThread(){return this._core.reloadMainThread?.()??qV}loadMore(){return this._core.loadMore?.()??qV}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new AI({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>XV(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new MI({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(e))}getItemByIndex(e){return new KV(new AI({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>XV(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new KV(new AI({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>XV(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new KV(this._createItemStateBinding(e),this._core)}},QV=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new ZV(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},$V=new WeakMap,eH=e=>$V.get(e)??0,tH=(e,t)=>eH(e)===t,nH=e=>{$V.set(e,eH(e)+1)},rH=class{_contextProvider=new PI;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},iH=Object.freeze([]),aH=`DEFAULT_THREAD_ID`,oH=Object.freeze([aH]),sH=Object.freeze({id:aH,remoteId:void 0,externalId:void 0,status:`regular`}),cH=Promise.resolve(),lH=Object.freeze(_M({[aH]:sH})),uH=class extends DI{_mainThreadId=aH;_threads=oH;_archivedThreads=iH;_threadData=lH;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return cH}_mainThread;get mainThreadId(){return this._mainThreadId}threadFactory;constructor(e={},t){super(),this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return Object.hasOwn(this._threadData,e)?this._threadData[e]:void 0}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??aH,i=e.threads??iH,a=e.archivedThreads??iH,o=n.threadId??aH,s=n.threads??iH,c=n.archivedThreads??iH;(t||(n.isLoading??!1)!==(e.isLoading??!1)||o!==r||s!==i||c!==a)&&((s!==i||c!==a||o!==r)&&(this._threadData=_M(lH,Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[]))),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??iH),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??iH),(t||o!==r)&&(t||nH(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=_M(this._threadData,{[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}})),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},dH={fromArray:e=>{let t=e.map(e=>yB(e,gB(),jB(e.content)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>({...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:yB(e,e.id,jB(e.content))}})})},fH=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},pH=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},mH=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}selectPathTo(e){for(let t=e;t;t=t.prev)(t.prev??this.root).next=t}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],t.prev=e,fH(t)===this.head?this.selectPathTo(t):i.next===null&&(i.next=t,this.head===i&&(this.head=fH(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new pH(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=fH(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;this.selectPathTo(t),this.head=fH(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t,this.selectPathTo(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[],t=[...this.root.children].reverse();for(;t.length>0;){let n=this.messages.get(t.pop());if(!n)continue;for(let e=n.children.length-1;e>=0;e--)t.push(n.children[e]);if(n.current.metadata?.isOptimistic)continue;let r=n.prev;for(;r&&r.current.metadata?.isOptimistic;)r=r.prev;e.push({message:n.current,parentId:r?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},hH=Object.freeze([]);function*gH(e){for(let t of e)if(t?.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e&&e.type===`tool-call`&&(yield{part:e,messageId:t.id},e.messages?.length&&(yield*gH(e.messages)))}function _H(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=e.name.toLowerCase(),i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&r.endsWith(e)||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function vH(e){let t=gB();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function yH(e){let t=[];for(let n of e)n.type!==`text`&&t.push(vH(n));return t}var bH=e=>`content`in e&&!(`lastModified`in e),xH=e=>e.status.type===`complete`,SH=class{operations=new Set;start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){return!e.cancelled&&(e.attachmentIds.add(t),!0)}finish(e){this.operations.delete(e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t))}cancelAll(){for(let e of this.operations)e.cancelled=!0;this.operations.clear()}},CH=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},wH=class extends DI{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_isSending=!1;_removedDuringSend=new Set;_sendGeneration=0;_attachmentAddOperations=new SH;_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._rebaseDictation(``),this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!xH(e));await Promise.all(t.map(async t=>e.remove(t)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){if(this._cancelAllAttachmentAdds(),this._isSending)for(let e of this._attachments)this._removedDuringSend.add(e.id);let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;if(this._dictationSession)try{this._dictationSession.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation()}let t=this.getAttachmentAdapter(),n=this.attachments.map(async e=>{if(xH(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)}),r=this.attachments,i=this.text,a=this._quote,o=this.role,s=this.runConfig;this._quote=void 0,this._text=``,this._isSending=!0;let c=++this._sendGeneration;this._notifySubscribers();let l;try{l=await Promise.all(n)}catch(e){throw c===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=a,this._notifySubscribers()),Promise.allSettled(n).then(()=>{c===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),e}if(c!==this._sendGeneration)return;let u=new Set(r.map(e=>e.id));this._attachments=this._attachments.filter(e=>!u.has(e.id)),this._isSending=!1,this._notifySubscribers();let d=l.filter(e=>!this._removedDuringSend.has(e.id));this._removedDuringSend.clear();let f={createdAt:new Date,role:o,content:i?[{type:`text`,text:i}]:[],attachments:d,runConfig:s,metadata:{custom:{...a?{quote:a}:{}}}},p={text:i,quote:a,attachments:d},m;try{m=this.handleSend(f,e)}catch(e){throw this._restoreUnsentDraft(e,c,p),e}m&&m.catch(e=>{this._restoreUnsentDraft(e,c,p)}),this._notifyEventSubscribers(`send`,{chars:i.length,attachments:d.length})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text===e.text&&this._quote===e.quote&&t&&(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,t,n){hV(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return hH}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(bH(e)){let t=this.getAttachmentAdapter();if(t&&!_H({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.contentType),r}let n={id:e.id??gB(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{...n.contentType?{contentType:n.contentType}:void 0});return}let t=this.getAttachmentAdapter();if(!t){let t=`Attachments are not supported`,n=Error(t);throw this._safeEmitAttachmentAddError(`no-adapter`,t,void 0,n,e.type),n}if(!_H({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.type),r}let n=this._attachmentAddOperations.start(),r=e=>{if(!this._attachmentAddOperations.accept(n,e.id))return!1;let t=this._attachments.findIndex(t=>t.id===e.id);return this._attachments=t===-1?[...this._attachments,e]:[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers(),!0},i;try{await CH(t.add({file:e}),e=>(i=e,r(e)))}catch(t){if(this._attachmentAddOperations.isCancelled(n))return;throw i&&r({...i,status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}}),this._safeEmitAttachmentAddError(`adapter-error`,t instanceof Error?t.message:String(t),i?.id,t instanceof Error?t:void 0,i?.contentType||e.type),t}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(i?.status.type===`incomplete`&&i.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,i.status.message??`Attachment upload did not complete successfully.`,i.id,void 0,i.contentType||e.type):this._notifyEventSubscribers(`attachmentAdd`,{...i?.contentType?{contentType:i.contentType}:e.type?{contentType:e.type}:void 0}))}_safeEmitAttachmentAddError(e,t,n,r,i){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r},...i?{contentType:i}:void 0})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!xH(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!xH(t)?{...t,status:{type:`incomplete`,reason:`error`,message:n}}:t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);let t=this._dictationSession!==void 0;if(this._dictationSession){let e=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(e)}let n=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let r;try{r=e.listen()}catch(e){if(t)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Dictation replacement rollback notification threw`,e)}throw e}this._dictationSession=r;let i=++this._dictationSessionIdCounter;this._activeDictationSessionId=i,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();let a=r.onSpeech(e=>{if(!this._isActiveSession(i,r))return;let t=e.isFinal!==!1,n=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+n+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=n+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(a);let o=r.onSpeechStart(()=>{this._isActiveSession(i,r)&&(this._dictation={status:{type:`running`},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);let s=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:i})});this._dictationUnsubscribes.push(s);let c=setInterval(()=>{this._isActiveSession(i,r)&&r.status.type===`ended`&&this._cleanupDictation({sessionId:i})},100);this._dictationUnsubscribes.push(()=>clearInterval(c))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;this._stopDictationSession(e,()=>this._cleanupDictation({sessionId:t}))}_stopDictationSession(e,t=()=>{}){let n;try{n=e.stop()}catch(e){console.error(`[assistant-ui] Dictation session stop threw`,e),t();return}n.then(t,e=>{console.error(`[assistant-ui] Dictation session stop rejected`,e),t()})}_cleanupDictation(e){if(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;let t=e=>{try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}};try{let n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``;for(let e of n)t(e);e?.notify!==!1&&t(()=>this._notifySubscribers())}finally{this._isCleaningDictation=!1}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&NP(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},TH=e=>e.capabilities?.cancel?BV(e):!1,EH=class extends wH{get canCancel(){return TH(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this.runtime.voice&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??hH,t=this.runtime.getQueueItems?.()??hH,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.runtime.voice!==void 0,r=this.queue;return this.runtime.subscribe(()=>{let i=!1,a=this.canCancel;e!==a&&(e=a,i=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,i=!0);let o=this.runtime.voice!==void 0;n!==o&&(n=o,i=!0),r!==this.queue&&(r=this.queue,i=!0),i&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},DH=class extends wH{get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this.runtime.voice&&!this._isSending}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e;let i=e.voice!==void 0,a=e.subscribe(()=>{let t=e.voice!==void 0;t!==i&&(i=t,this._notifySubscribers())});this.endEditCallback=()=>{a(),t()},this._parentId=n,this._sourceId=r.id,this.setText(OV(r)),this.setRole(r.role);let o;r.role===`user`?(o=[...r.attachments??[],...yH(r.content)],this._nonTextPassthrough=[]):(o=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(o),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},OH=class extends DI{_isInitialized=!1;repository=new mH;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();if(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e){let t=new Set(e.map(e=>e.id));this._cachedMergedMessages=[...e,...this._voiceMessages.filter(e=>!t.has(e.id))],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new EH(this);_contextProvider;constructor(e){super(),this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=rB(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}_isVoiceMessage(e){return e!==null&&this._voiceMessages.some(t=>t.id===e)}_resolveAppendParent(e){return this._isVoiceMessage(e)?this._getBaseMessages().at(-1)?.id??null:e}beginEdit(e){if(this.voice)throw Error(`Cannot edit a message while a voice session is connected`);if(this._isVoiceMessage(e))throw Error(`Voice transcript messages cannot be edited`);if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new DH(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&NP(n,t,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,t,n,r){this._notifyEventSubscribers(`toolApprovalAnswered`,{messageId:e,toolCallId:t,toolName:n,approved:r})}submitFeedback({messageId:e,type:t,comment:n}){let r=this.adapters?.feedback,i=this.getMessageById(e);if(!i)throw Error(`Message not found: ${e}`);let{message:a,parentId:o}=i,s=n?.trim(),c={type:t,...s?{comment:s}:void 0};if(r?.submit({message:a,...c}),a.role===`assistant`){let t={...a,metadata:{...a.metadata,submittedFeedback:c}},n=this._voiceMessages.findIndex(t=>t.id===e);n===-1?this.repository.addOrUpdateMessage(o,t):(this._voiceMessages[n]=t,this._currentAssistantMsg===a&&(this._currentAssistantMsg=t),this._markVoiceMessagesDirty())}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let n=this.getMessageById(e);if(!n)throw Error(`Message not found: ${e}`);let{message:r}=n,i=this._stopSpeaking,a;try{i?.(),a=t.speak(OV(r))}catch(e){if(i&&!this._stopSpeaking)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Speech rollback notification threw`,e)}throw e}let o,s=()=>{this._stopSpeaking=void 0,this.speech=void 0;let e=o;o=void 0,e?.()},c=()=>{if(this._stopSpeaking===c)try{s()}finally{a.cancel()}},l=()=>{this._stopSpeaking===c&&(a.status.type===`ended`?wI([s,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:a.status},this._notifySubscribers()))};this._stopSpeaking=c;try{if(o=a.subscribe(l),this._stopSpeaking!==c){o();return}l()}catch(e){if(this._stopSpeaking===c)try{wI([c,()=>this._notifySubscribers()])}catch(e){console.error(`[assistant-ui] Speech rollback cleanup threw`,e)}throw e}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);wI([this._stopSpeaking,()=>this._notifySubscribers()])}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){if(this.isRunning)return!0;let e=this._getBaseMessages().at(-1);return e?.role===`assistant`&&(e.status.type===`running`||e.status.type===`requires-action`)}connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);if(this._isRunActive())throw Error(`Cannot start a voice session while a run is in progress or paused on a pending tool action`);let t=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice cleanup threw before reconnect`,e)}let n;try{n=e.connect({})}catch(e){throw t&&this._voiceSession===void 0&&this._onVoiceDisconnected(),e}this._voiceSession=n;let r=[];this._voiceUnsubs=r;let i=()=>{if(this._voiceSession===n&&this._voiceUnsubs===r)return!1;try{wI(r.splice(0))}catch(e){console.error(`[assistant-ui] Detached voice setup cleanup threw`,e)}return!0};try{let e=`listening`;if(this.voice={status:n.status,isMuted:n.isMuted,mode:e},this._voiceVolume=0,this._notifySubscribers(),i()||(r.push(n.onStatusChange(t=>{this._voiceSession===n&&(t.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0,this._onVoiceDisconnected()):this.voice={status:t,isMuted:n.isMuted,mode:e},this._notifySubscribers())})),i())||(r.push(n.onModeChange(t=>{e=t,this.voice&&(this.voice={...this.voice,mode:t},this._notifySubscribers())})),i())||(r.push(n.onVolumeChange(e=>{this._voiceVolume=e,NP(this._voiceVolumeSubscribers,void 0,`Voice volume`)})),i()))return;r.push(n.onTranscript(e=>{this._handleVoiceTranscript(e)})),i()||this._onVoiceConnected()}catch(e){if(this._voiceSession===n&&this._voiceUnsubs===r){try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice rollback cleanup threw`,e)}t&&this._voiceSession===void 0&&this._onVoiceDisconnected()}else i();throw e}}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`){if(this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal){let t={id:gB(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{modality:`voice`,custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]};this._voiceMessages.push(t),this._commitVoiceMessage(t),this._markVoiceMessagesDirty(),this._notifySubscribers()}}else{let t=e.isFinal?{type:`complete`,reason:`stop`}:{type:`running`};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:gB(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],modality:`voice`,custom:{}},status:t,createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let n=this._voiceMessages.indexOf(this._currentAssistantMsg);if(n===-1)return;let r={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],status:t};this._voiceMessages[n]=r,this._currentAssistantMsg=r}e.isFinal&&(this._commitVoiceMessage(this._currentAssistantMsg),this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(e=!0){let t=this._voiceMessages.at(-1);if(t?.role===`assistant`&&t.status.type===`running`){let n=this._voiceMessages.length-1;this._voiceMessages[n]={...t,status:{type:`complete`,reason:`stop`}},this._commitVoiceMessage(this._voiceMessages[n]),this._currentAssistantMsg=null,this._markVoiceMessagesDirty(),e&&this._notifySubscribers()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;let t=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];let n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;let r=this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0;this._voiceMessages=[],this._markVoiceMessagesDirty();try{wI([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>NP(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this._notifySubscribers()])}finally{e&&n&&this._voiceSession===void 0&&this._onVoiceDisconnected()}}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(dH.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>NP([n],{},`Thread runtime "${e}"`))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&NP([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},kH=Symbol.for(`assistant-stream.tool-execution-id`),AH=e=>{try{return JSON.parse(e),!0}catch{return!1}},jH=e=>{try{return JSON.parse(e)}catch{return}},MH=(e,t)=>{let n=jH(e),r=jH(t);return n===void 0||r===void 0?!1:tR(n,r)},NH=e=>e[kH],PH=class{_getTools;_callbacks;_isClientToolCall;_entries=new Map;_humanInput=new Map;_executing=new Set;_discardedToolCallIds=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t,n){this._getTools=e,this._callbacks=t,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){let[e,t]=ER();this._controller=t;let n=Fz(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new kR).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(e){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),e?.discardPending)for(let[e,t]of this._entries)t.controller&&(t.argsComplete||t.hasResult||(this._discardedToolCallIds.add(e),t.skipExecute=!0));if(this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let t=new Set(this._executing);return new Promise(e=>{this._settledResolvers.push({executionIds:t,resolve:e})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=NH(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=NH(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._humanInput.get(e)?.executionId!==t&&this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=NH(e),r=this._entries.get(t);r&&r.executionId===n&&(r?.hasResult||r.skipExecute||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_warnProviderOwnedSkip(e,t){}_shouldCloseArgsStream({argsText:e,hasResult:t,clientOwned:n}){return t?!0:AH(e)?n||!this._isRunning:!1}_startActiveEntry(e,t,n,r){let i={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1,clientOwned:r};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)if(t.controller){if(!t.argsComplete&&!t.hasResult){this._entries.delete(e);continue}this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)MH(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(AH(e.argsText)&&AH(t.argsText)&&MH(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:e.clientOwned})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let{part:n}of gH(e)){let e=this._entries.get(n.toolCallId);if(t){e?.controller||this._entries.set(n.toolCallId,{toolName:n.toolName,argsText:n.argsText,hasResult:n.result!==void 0});continue}let r=e;if(n.result!==void 0&&this._discardedToolCallIds.delete(n.toolCallId),r&&!r.controller){if(r.hasResult||(n.argsText===r.argsText||AH(r.argsText)&&AH(n.argsText)&&MH(r.argsText,n.argsText))&&n.result===void 0)continue;this._entries.delete(n.toolCallId),r=void 0}if(!r){let e=this._isClientToolCall?.(n),t=n.result===void 0&&e===!1;t&&this._warnProviderOwnedSkip(n.toolName,n.toolCallId),r=this._startActiveEntry(n.toolCallId,n.toolName,n.result!==void 0||t||this._discardedToolCallIds.has(n.toolCallId),e===!0)}if(n.approval!==void 0&&(r.skipExecute=!0),this._processArgsText(r,n),n.result!==void 0&&!r.hasResult){let{controller:e}=r;if(!e)continue;r.hasResult=!0,r.argsComplete=!0,e.setResponse(new oR({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent===void 0?{}:{modelContent:n.modelContent}})),e.close()}}}},FH=Object.freeze([]),IH=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},LH=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,RH=class extends OH{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}suggestions=[];extras=void 0;_converter=new NB;_pendingDeleteEvictions=new Set;_optimistic=null;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;_toolStatuses=new Map;_effectiveIsRunning=!1;_inTrackerUpdate=!1;_pendingRunningRefresh=!1;_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){let e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?`runStart`:`runEnd`,{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){let t=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e;let r=this._getEffectiveIsRunning(e),i=e.unstable_messageRepositoryInstance,a=i!==void 0&&i!==this.repository;a&&(this.repository=i,this._pendingDeleteEvictions.clear()),n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let o=e.suggestions??FH;zF(this.suggestions,o)||(this.suggestions=o);let s={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};zF(this._capabilities,s)||(this._capabilities=s);let c;if(e.messageRepository){if(n&&!a&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository&&t===r){this._notifySubscribers();return}let i=e.messageRepository.messages,o=e.messageRepository.headId??i.at(-1)?.message.id??null;if(n&&!a&&n.messageRepository===e.messageRepository)this.repository.resetHead(o),c=this.repository.getMessages();else{let e=new Set(i.map(({message:e})=>e.id));for(let{message:e,parentId:t}of i)this.repository.addOrUpdateMessage(t,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(o),c=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new NB;else if(!a&&n.isRunning===e.isRunning&&n.messages===e.messages&&t===r){this._notifySubscribers();return}}c=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,i)=>{if(!e.convertMessage)return n;let a=i===(e.messages?.length??0)-1,o=`${hB}${i}`;if(t&&(t.role!==`assistant`||!kB(t.status)||t.status===MB(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return pB(e,n),e}return t}let s=e.convertMessage(n,i),c=yB(s,o,MB(s.content,a,r));return pB(c,n),c}):e.messages;let i=new Set,o=[];for(let e=c.length-1;e>=0;e--){let t=c[e];if(i.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}i.add(t.id),o.push(t)}o.length!==c.length&&(c=o.reverse());for(let e=0;e<c.length;e++){let t=c[e],n=c[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}if(this._pendingDeleteEvictions.size>0){let e=new Set(c.map(e=>e.id));for(let t of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(t),!e.has(t)){try{this.repository.getMessage(t)}catch{continue}this.repository.deleteMessage(t)}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);c.length>0&&this.ensureInitialized(),this._effectiveIsRunning=r,t!==r&&(r?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let l=null;if(LH(r,c)){let e=c.at(-1)?.id??null;this._optimistic?.parentId!==e&&(this._optimistic={id:gB(),parentId:e}),l=this._optimistic.id,this.repository.addOrUpdateMessage(e,yB({role:`assistant`,content:[],metadata:{isOptimistic:!0}},l,{type:`running`}))}l===null&&(this._optimistic=null),this.repository.resetHead(l??c.at(-1)?.id??null);let u=this.repository.getMessages();if((!this._messages||!PB(this._messages,u))&&(this._messages=u),this._voiceMessages.length>0){let e=new Set(this._messages.map(e=>e.id)),t=this._voiceMessages.filter(t=>!e.has(t.id));t.length!==this._voiceMessages.length&&(this._voiceMessages=t,this._markVoiceMessagesDirty())}a&&this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new PH(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;IH(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{this._store.setToolStatuses?.(Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}},e=>this._store.unstable_isClientToolCall?.(e)),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(let{part:e,messageId:t}of gH(this._messages))this._toolCallToMessageId.set(e.toolCallId,t);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t={...e,parentId:this._resolveAppendParent(e.parentId)};if(this.voice)throw Error(`Cannot send a text message while a voice session is connected`);if(this._isVoiceMessage(t.sourceId))throw Error(`Voice transcript messages cannot be edited`);let n=t.sourceId!=null||t.parentId!==(this._getBaseMessages().at(-1)?.id??null);t=!n&&this._store.queue&&this._store.queue===this._transformedQueue?t:this.enrichAppendMetadata(t);let r=eH(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!n&&this._store.queue){if(i&&await i,!tH(this,r))return;t.steer??this._getEffectiveIsRunning(this._store)?this._store.queue.steer(t):this._store.queue.enqueue(t);return}if(i?.catch(()=>{}),(t.startRun??t.role===`user`)&&await this._toolInvocations?.abort({discardPending:!0}),tH(this,r)){if(n){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._pendingDeleteEvictions.clear(),await this._store.onEdit(t)}else await this._store.onNew(t)}}_commitVoiceMessage(e){this._store.onVoiceTranscript?.(e)}async deleteMessage(e){if(this._store.onDelete){this.repository.getMessages().some(t=>t.id===e)&&this._pendingDeleteEvictions.add(e);try{await this._store.onDelete(e)}catch(t){throw this._pendingDeleteEvictions.delete(e),t}return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._getEffectiveIsRunning(this._store)&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this._pendingDeleteEvictions.clear(),this.updateMessages(t.filter(t=>t.id!==e)),this._evictDeletedMessage(e)}_evictDeletedMessage(e){if(!e.startsWith(`__external_store_fallback_`)){try{this.repository.getMessage(e)}catch{return}this.repository.deleteMessage(e),this._publishRepositoryMessages()}}_publishRepositoryMessages(){let e=this.repository.getMessages();PB(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){return this._store?.queue?.items??hH}getSteerQueueItems(){return this._store?.queue?.steerItems??hH}moveQueueItem(e,t){this._store?.queue?.move(e,t)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);this._pendingDeleteEvictions.clear(),await this._toolInvocations?.abort({discardPending:!0}),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.queue?.__internal_notifyCancelled?.()}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);let e=eH(this);this._toolInvocations?.abort({discardPending:!0}),this._store.queue?.__internal_notifyCancelled?.(),IH(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let t=this.repository.getMessages(),n=t[t.length-1],r=this._store.setMessages!==void 0&&n?.role===`user`&&n.id===t.at(-1)?.id&&n.content.every(e=>e.type===`text`)?n:void 0,i;if(r){let e={text:OV(r),attachments:r.attachments,quote:r.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(r.id),i={id:r.id,draft:e})}this._publishRepositoryMessages(),setTimeout(()=>{if(tH(this,e)){if(this.dropEmptyOptimisticHead(),i){let e=this.repository.getMessages();e.at(-1)?.id===i.id?this.repository.deleteMessage(i.id):e.some(e=>e.id===i.id)&&this.composer.retractDraft(i.draft)}this._publishRepositoryMessages(),this.updateMessages(this._messages)}},0)}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);IH(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);let t=this.messages.findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId)),n=t?.content.find(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId);try{return Promise.resolve(this._store.onRespondToToolApproval(e)).then(()=>{t&&n?.type===`tool-call`&&this._notifyToolApprovalAnswered(t.id,n.toolCallId,n.toolName,e.approved)})}catch(e){return Promise.reject(e)}}reset(e){let t=new mH;t.import(dH.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(mB))}},zH=e=>e.adapters?.threadList??{},BH=class extends rH{threads;constructor(e){super(),this.threads=new uH(zH(e),()=>new RH(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(zH(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},VH=e=>{let t=J(21),{modelContext:n,feedback:r}=sB()??{},i;bb0:{if(!r||e.adapters?.feedback){i=e;break bb0}let n;t[0]!==r||t[1]!==e.adapters?(n={...e.adapters,feedback:r},t[0]=r,t[1]=e.adapters,t[2]=n):n=t[2];let a;t[3]!==e||t[4]!==n?(a={...e,adapters:n},t[3]=e,t[4]=n,t[5]=a):a=t[5],i=a}let a=i,o;t[6]===a?o=t[7]:(o=()=>new BH(a),t[6]=a,t[7]=o);let[s]=hN(o),c;t[8]===s.threads?c=t[9]:(c=()=>()=>{nH(s.threads.getMainThreadRuntimeCore())},t[8]=s.threads,t[9]=c);let l;t[10]===s?l=t[11]:(l=[s],t[10]=s,t[11]=l),X(c,l);let u;t[12]!==a||t[13]!==s?(u=()=>{s.setAdapter(a)},t[12]=a,t[13]=s,t[14]=u):u=t[14],X(u);let d,f;t[15]!==n||t[16]!==s?(d=()=>{if(n)return s.registerModelContextProvider(n)},f=[n,s],t[15]=n,t[16]=s,t[17]=d,t[18]=f):(d=t[17],f=t[18]),X(d,f);let p;return t[19]===s?p=t[20]:(p=new QV(s),t[19]=s,t[20]=p),p},HH=e=>e.status?.type!==`running`,UH=async(e,t)=>{let n=fz.fromAssistantStream(e);for await(let e of n){let n=e.parts.filter(e=>e.type===`text`)[0]?.text;n?.trim()&&await t(n)}},WH=(e,t)=>{let n=()=>void t.generateTitle({automatic:!0}).catch(e=>{XI(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(HH);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},GH=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=vN(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=Y(!1);c.current||s(),X(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=Y(void 0),u=Y(!1),d=Y(void 0),f=Y(!1),p=bN(()=>{if(u.current||i.getState().status!==`new`)return;u.current=!0;let e=i.initialize();l.current=e,e.then(()=>{f.current&&(d.current?.(),d.current=WH(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=bN(()=>(p(),l.current));return X(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),X(()=>{if(!a?.threads?.main)return;u.current=!1,f.current=!0;let e=a.threads.main.unstable_on(`initialize`,p);return()=>{f.current=!1,e(),d.current?.(),d.current=void 0}},[a]),a},KH=PN(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s})=>{let c=_N(()=>new KV(new AI({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:CI},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:l}=sI(i,{threadListItem:ML({runtime:c})});return kF(s,function(){return sF(l,function(){return oB(a,function(){return GH({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:c})})})})}),qH=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],JH=e=>{let t=J(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),yN(r,i),null},YH=class extends DI{runtimeHook;adapterStore=new OI({defaultAdapters:null,threadAdapters:new Map});hostStore=new OI({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);return t?(t.runtime&&nH(t.runtime),t.unsubscribeRunning?.(),t.unsubscribeRunning=void 0,t.destroy.abort(),t.destroy=new AbortController,t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime;r.runtime=t,r.publishedGeneration=n,i!==t&&this._trackRunning(e,r),this._notifySubscribers(),i!==void 0&&i!==t&&wI(this.replacedSubscribers)}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){t.unsubscribeRunning?.();let n=t.runtime;if(!n){t.unsubscribeRunning=void 0,this._setRunning(t,!1);return}this._setRunning(t,BV(n));let r=[n.subscribe(()=>{this._setRunning(t,BV(n))}),...qH.map(t=>n.unstable_on(t,()=>{NP(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>{for(let e of r)e()}}_setRunning(e,t){e.isRunning!==t&&(e.isRunning=t,wI(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&nH(t.runtime),t?.unsubscribeRunning?.(),t?.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState();this.hostStore.setState({...t,hookEpoch:t.hookEpoch+1})}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e})}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r})}__internal_dispose(){for(let e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){let e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t,destroy:n}])=>({id:e,generation:t,destroySignal:n.signal}))})}_threadElements(e,{threads:t,hookEpoch:n},r){let i=this.runtimeHook;return t.map(({id:t,generation:a,destroySignal:o})=>{let s=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return FN(`${t}:${a}:${n}`,KH({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:s,publish:this._publish,destroySignal:o}))})}__internal_useHost(e){let t=JI(this.hostStore),n=JI(this.adapterStore);return EP(this._threadElements(e,t,n))}__internal_RenderThreadRuntimes=({provider:e})=>(JI(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,b.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>{let t=JI(this.hostStore),n=JI(this.adapterStore),r=this._threadElements(e,t,n),{effects:i}=OP(function(){return EP(r)});return yN(i),null};_OuterActiveThreadProvider=EN(({threadId:e,provider:t})=>{let n=_N(()=>new ZV(this.parent).getItemById(e),[e]),r=Y(!1);return X(()=>{},[t]),(0,b.jsx)(QB,{runtime:n,children:(0,b.jsx)(t,{children:(0,b.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=sB();return this.pendingThreadAdapters.set(e,n),yN(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,b.jsx)(JH,{detectorRef:t})}};function XH(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var ZH=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),QH=class extends DI{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>ZH(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=ZH(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},$H=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),eU=new class extends WV{get error(){return $H}messages=[];composer=UV($H,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject($H)}};function tU(e){return e}var nU=`__LOCALID_`,rU=e=>e||void 0,iU=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=_M(t.threadIdMap),a=_M(t.threadData),o=new Set([...n,...r]);for(let t of e){switch(t.status){case`regular`:case`archived`:break;default:{let e=t.status;throw Error(`Unsupported state: ${e}`)}}let e=i[t.remoteId],s=e===void 0?void 0:a[e],c=s?.id??t.remoteId,l=e??tU(c),u=s!==void 0&&s.status!==`new`?s.initializeTask:void 0;o.has(c)?s!==void 0&&s.status!==t.status&&(t.status===`regular`?(r=r.filter(e=>e!==c),n.push(c)):(n=n.filter(e=>e!==c),r.push(c))):(o.add(c),t.status===`regular`?n.push(c):r.push(c)),i[c]=l,i[t.remoteId]=l,a[l]={...s?.localOrigin===!0?{localOrigin:!0}:{},id:c,remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,initializeTask:u??Promise.resolve({remoteId:t.remoteId,externalId:t.externalId})}}return{threadIds:n,archivedThreadIds:r,threadIdMap:i,threadData:a}},aU=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:_M(),threadData:_M()}),oU=e=>{let t;do t=`${nU}${gB()}`;while(e.threadIdMap[t]);let n=tU(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:_M(e.threadIdMap,{[t]:n}),threadData:_M(e.threadData,{[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},sU=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);(e===void 0||e===`new`)&&(e!==void 0||t.localOrigin===!0)&&(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?2**53-1:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),{...e,threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]}},cU=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),lU=(e,t)=>{let n=Object.hasOwn(e.threadIdMap,t)?e.threadIdMap[t]:void 0;if(n!==void 0)return Object.hasOwn(e.threadData,n)?e.threadData[n]:void 0},uU=(e,t,n,r,i)=>{let a=tU(t),o=Object.hasOwn(e.threadData,a)?e.threadData[a]:void 0;if(!o)return{state:e,removedMappingId:void 0,survivorMappingId:a};let s=Object.hasOwn(e.threadIdMap,n)?e.threadIdMap[n]:void 0,c=s!==void 0&&s!==a&&Object.hasOwn(e.threadData,s)?e.threadData[s]:void 0,l=s!==void 0&&c!==void 0?{mappingId:s,data:c}:void 0,u=i!==void 0&&Object.hasOwn(e.threadIdMap,i)?e.threadIdMap[i]:void 0,d=l!==void 0&&u===l.mappingId?l.mappingId:a,f=l===void 0?void 0:d===a?l.mappingId:a,p=r??l?.data.externalId,m=_M(e.threadData);f!==void 0&&delete m[f];let h={...o,id:d,initializeTask:Promise.resolve({remoteId:n,externalId:p}),remoteId:n,externalId:p};m[d]={...l?.data,...h,title:o.title??l?.data.title,lastMessageAt:(`lastMessageAt`in o?o.lastMessageAt:void 0)??(l&&`lastMessageAt`in l.data?l.data.lastMessageAt:void 0),custom:o.custom??l?.data.custom};let g=_M(e.threadIdMap);if(f!==void 0)for(let[e,t]of Object.entries(g))t===f&&(g[e]=d);g[t]=d,g[n]=d;let _=e=>l===void 0?e:e.filter(e=>e!==l.data.id).map(e=>e===o.id?d:e);return{state:{...e,threadIds:_(e.threadIds),archivedThreadIds:_(e.archivedThreadIds),threadIdMap:g,threadData:m},removedMappingId:f,survivorMappingId:d}},dU=(e,t,n,r)=>{let i=lU(e,t);if(!i)return e;let{id:a,status:o}=i;if(o===n)return e;let s;if(n!==`deleted`){if(i.status===`new`){if(r===void 0)return e;s={...i,initializeTask:r,status:n}}else s={...i,status:n}}let c={...e};switch(o){case`new`:c.newThreadId=void 0;break;case`regular`:c.threadIds=c.threadIds.filter(e=>e!==a);break;case`archived`:c.archivedThreadIds=c.archivedThreadIds.filter(e=>e!==a);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:c.threadIds=[a,...c.threadIds];break;case`archived`:c.archivedThreadIds=[a,...c.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t],r=_M(c.threadData);delete r[n],c.threadData=r;let i=_M(c.threadIdMap);for(let[e,t]of Object.entries(i))t===n&&delete i[e];c.threadIdMap=i;break}default:throw Error(`Unsupported state: ${n}`)}return s!==void 0&&(c.threadData={...c.threadData,[a]:s}),c},fU=(e,t,n)=>dU(e,t,n,void 0),pU=(e,t,n)=>dU(e,t,`regular`,n),mU=class extends Error{[YI]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}};function hU(e,t){let n=e.get(t);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualTitle:void 0,latestExplicit:null,nextOrder:0},e.set(t,n)),n}function gU(e,t,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualTitle===void 0&&e.get(t)===n&&e.delete(t)}function _U(e,t){return!t.superseded&&(e.latestExplicit?.order??0)<=t.order}function vU(e,t){return(e.latestExplicit?.order??0)<t.order}function yU(e,t,n){let r=hU(e,t),i,a=new Promise(e=>{i=e}),o={title:n,order:++r.nextOrder,settled:a,settle:i};r.pendingClaim=o,r.inFlightClaims.add(o);for(let e of r.generations)e.order<o.order&&(e.claim=o);return o}function bU(e,t,n,r){n.settle(r);let i=e.get(t);i!==void 0&&(i.inFlightClaims.delete(n),i.pendingClaim===n&&(i.pendingClaim=null,r&&(i.manualTitle=n.title)),gU(e,t,i))}function xU(e,t,n){let r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,gU(e,t,n),r}function SU(e,t){e.delete(t)}function CU(e,t,n){let r=hU(e,t);if(n&&r.pendingClaim===null&&xU(e,t,r)!==void 0)return null;let i,a=new Promise(e=>{i=e}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,beforeGenerationClaims:n?[]:[...r.inFlightClaims],superseded:!1,persisted:a,settlePersisted:i};if(!n){r.pendingClaim=null,r.manualTitle=void 0,r.latestExplicit=o;for(let e of r.generations)e.automatic&&(e.superseded=!0)}return r.generations.add(o),o}async function wU({states:e,threadId:t,automatic:n,generate:r,rename:i,applyTitle:a}){let o=hU(e,t),s=CU(e,t,n);if(s===null)return;let c,l=s.order,u=async e=>{let t=await e.settled;if(s.claim===e)return t||(s.claim=null,o.pendingClaim===e&&(o.pendingClaim=null)),t},d=()=>n&&xU(e,t,o)!==void 0,f=async()=>{if(c!==void 0)for(;;){let e=s.claim;if(e!==null&&e.order>l&&vU(o,e)){await u(e)===!0&&(c=e.title,l=e.order,await i(e.title));continue}let t=o.latestExplicit;if(t===null||t.order<=l)return;let n=await t.persisted;if(o.latestExplicit===t){if(l=t.order,n===void 0||n===c)return;c=n,await i(n)}}},p=async()=>{if(s.beforeGenerationClaims.length>0&&await Promise.all(s.beforeGenerationClaims.map(e=>e.settled)),s.claim!==null){let e=await u(s.claim);if(e===!0){s.superseded=!0;return}if(e===!1&&d())return}if(!_U(o,s))return;let e=!1,t;for(await r(async n=>{e=!0,t=n,n!==void 0&&(c=n);let r=s.claim;if(r!==null){if(await u(r)!==!1)return;if(d()){s.superseded=!0;return}}_U(o,s)&&await a(t)});;){let n=s.claim;if(n===null)return;let r=await u(n);if(r!==void 0){if(r===!1){if(d())return;e&&_U(o,s)&&await a(t);return}if(!vU(o,n))return;if(await i(n.title),c=n.title,l=n.order,s.claim===n){if(!_U(o,s))return;await a(n.title),s.superseded=!0;return}}}};try{await p(),await f()}finally{s.settlePersisted(c),o.generations.delete(s),gU(e,t,o)}}var TU=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),EU=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),DU=aU(),OU=class extends DI{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_titleStates=new Map;_mainThreadId;_state=new QH(DU);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,b.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=lB(e());return n==null?t:(0,b.jsx)(GV,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?DN:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=cU(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>e===this._loadGeneration?{...t,isLoading:!0,loadError:void 0}:t,then:(r,i)=>{if(e!==this._loadGeneration)return r;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads({...r,loadError:void 0},i.threads,rU(i.nextCursor));let a=iU(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return sU({...r,isLoading:!1,loadError:void 0,cursor:rU(i.nextCursor),threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadIdMap:a.threadIdMap,threadData:a.threadData},r,n)}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1,loadError:n});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads({...this._state.baseValue,loadError:n},[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?{...e,isLoadingMore:!0}:e,then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=iU(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:rU(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new YH(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new OI(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;providerStore;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0}),this._titleStates.clear()),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new mU}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new mU}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,n=t&&Object.hasOwn(e.threadData,t)?e.threadData[t]:void 0;n?.status===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i)for(let t of Object.values(e.threadData))i.has(t.id)||(t.status===`new`||t.remoteId!==void 0)&&r.push(t);this._staleThreadIdsOnReplace=void 0;let a={threadIds:[],archivedThreadIds:[],threadIdMap:_M(),threadData:_M()};for(let e of r){let t=tU(e.id);Object.hasOwn(a.threadData,t)||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=iU(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=tU(e.id),n=Object.hasOwn(l,t)?l[t]:void 0;n!==void 0&&(n.status===`regular`&&!o.includes(n.id)?o.push(n.id):n.status===`archived`&&!s.includes(n.id)&&s.push(n.id))}let u={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(c,e.newThreadId)?void 0:e.newThreadId};if(lU(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=oU(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))d.has(t.id)||this._hookManager.stopThreadRuntime(t.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get loadError(){return this._state.value.loadError}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return lU(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&XH(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||eU}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw TU(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return lU(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new mU;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=tU(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw TU(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n!==this._switchGeneration)return;let o=this.getItemById(i.id);o?.id===i.id&&(o.status===`archived`&&t?.unarchive!==!1&&(await o.initializeTask,n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)||o.status===`archived`&&(await this.unarchive(o.id),n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)))||(this._mainThreadId=o.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?this._startSwitchToNewThread(!1):this._startSwitchToThread(e,void 0,!1)}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=oU(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw TU(e,`initializing it`);if(t.status===`new`)throw EU(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}this._requireAdapterGeneration(n);let r=t.initialize(e),i,{remoteId:a,externalId:o}=await this._state.optimisticUpdate({execute:()=>r,optimistic:t=>pU(t,e,r),then:(t,{remoteId:r,externalId:a})=>{if(n!==this._adapterGeneration)return t;let o=uU(t,e,r,a,e);return i=o.removedMappingId,i===this._mainThreadId&&(this._mainThreadId=o.survivorMappingId),o.state}});return this._requireAdapterGeneration(n),i!==void 0&&this._hookManager.stopThreadRuntime(i),{remoteId:a,externalId:o}};generateTitle=async(e,t)=>{this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw TU(e,`generating its title`);if(i.status===`new`)throw EU(e,i.status,`generate a title`);let{remoteId:a}=await i.initializeTask;this._requireAdapterGeneration(r);let o=this._hookManager.getThreadRuntimeCore(i.id);if(!o)return;let s=o.messages.filter(HH);await wU({states:this._titleStates,threadId:i.id,automatic:t?.automatic===!0,generate:async e=>{let t=await n.generateTitle(a,s);this._requireAdapterGeneration(r),await UH(t,e)},rename:async e=>{this._requireAdapterGeneration(r),await n.rename(a,e)},applyTitle:async e=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:t=>{if(r!==this._adapterGeneration)return t;let n=lU(t,i.id);return n?{...t,threadData:{...t.threadData,[n.id]:{...n,title:e}}}:t}})}})};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw TU(e,`renaming it`);if(i.status===`new`)throw EU(e,i.status,`be renamed`);let a=yU(this._titleStates,i.id,t);try{let o=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=lU(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}});return bU(this._titleStates,i.id,a,!0),o}catch(e){throw bU(this._titleStates,i.id,a,!1),e}}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw TU(e,`updating its custom metadata`);if(i.status===`new`)throw EU(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=lU(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){let e=this._switchTask,n=!e||e===t;n&&(e=this.switchToNewThread()),t=e;try{await e}catch(t){if(n&&this._switchTask===e)throw t}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw TU(e,`archiving it`);if(r.status!==`regular`)throw EU(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>fU(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw TU(e,`unarchiving it`);if(r.status!==`archived`)throw EU(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>fU(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw TU(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw EU(e,r.status,`be deleted`);await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n);let i=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>fU(e,r.id,`deleted`)});return this._hookManager.stopThreadRuntime(r.id),SU(this._titleStates,r.id),i}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw TU(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw EU(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new OI([]);__internal_RenderComponent=()=>{let e=wN();X(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=JI(this.boundIdsStore),n=JI(this.providerStore),r=Q();return(t.length===0||t[0]===e)&&(0,b.jsxs)(GV,{adapters:this._runtimeAdapters,children:[(0,b.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,b.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},kU=class extends rH{threads;constructor(e){super(),this.threads=new OU(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},AU=e=>{let t=J(18),n;t[0]===e?n=t[1]:(n=()=>new kU(e),t[0]=e,t[1]=n);let[r]=hN(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>queueMicrotask(()=>r.threads.__internal_dispose()),t[2]=r.threads,t[3]=i);let a;t[4]===r?a=t[5]:(a=[r],t[4]=r,t[5]=a),CN(i,a);let o;t[6]!==e||t[7]!==r.threads?(o=()=>{r.threads.__internal_setOptions(e),r.threads.__internal_load()},t[6]=e,t[7]=r.threads,t[8]=o):o=t[8];let s;t[9]!==e||t[10]!==r?(s=[r,e],t[9]=e,t[10]=r,t[11]=s):s=t[11],X(o,s);let c;t[12]===r.threads?c=t[13]:(c=()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{r.threads.loadError!==void 0&&r.threads.reload()},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},t[12]=r.threads,t[13]=c);let l;t[14]===r?l=t[15]:(l=[r],t[14]=r,t[15]=l),X(c,l);let u;return t[16]===r?u=t[17]:(u=new QV(r),t[16]=r,t[17]=u),u},jU=e=>{let[t]=hN(()=>new OI(e.runtimeHook));yN(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=Y(e.initialThreadId),r=vN(function(){return JI({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()},[t]),i=bN(t=>e.onThreadIdChange?.(t)),a=_N(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(Q().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return AU(a)},MU=e=>{let t=J(6),{id:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=PP({message:mI({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:mI({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)(HL,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},NU=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,PU=()=>null,FU=new WeakMap,IU=(e,t)=>{let n=FU.get(e);return n||(n=new Set(e.map(e=>e.id)),FU.set(e,n)),n.has(t)},LU=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message??PU:e.SystemMessage??e.Message??PU;default:throw Error(`Unknown message role: ${t}`)}},RU=e=>{let t=J(6),{components:n}=e,r=$(WU),i=$(GU),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=LU(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,b.jsx)(o,{}),t[4]=o,t[5]=s),s},zU=EN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(RU,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)($B,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&NU(e.components,t.components));zU.displayName=`ThreadPrimitive.MessageByIndex`;var BU=EN(e=>{let t=J(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>IU(e.thread.messages,n),t[0]=n,t[1]=i),!$(i))return null;let a;t[2]===r?a=t[3]:(a=(0,b.jsx)(RU,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,b.jsx)(MU,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&NU(e.components,t.components));BU.displayName=`ThreadPrimitive.Unstable_MessageById`;var VU=({children:e})=>{let t=$(VF(e=>e.thread.messages.map(e=>e.id)));return _N(()=>t.length===0?null:t.map((t,n)=>(0,b.jsx)($B,{index:n,children:(0,b.jsx)(GL,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},t)),[t,e])},HU=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(VU,{children:()=>(0,b.jsx)(RU,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(VU,{children:r}),t[2]=r,t[3]=i),i};HU.displayName=`ThreadPrimitive.Messages`;var UU=EN(HU,(e,t)=>e.children||t.children?e.children===t.children:NU(e.components,t.components));function WU(e){return e.message.role}function GU(e){return e.message.composer.isEditing}var KU=e=>{let t=e.message.metadata;if(t&&typeof t==`object`)return t.custom?.quote},qU=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},JU=e=>typeof e==`object`&&!!e,YU=e=>e==null?[]:Array.isArray(e)?e:[e],XU=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!JU(e)||!(`component`in e)||typeof e.component!=`string`)return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,b.jsx)(n,{component:i,props:a},s??r);throw new qU(i)}return ON(c,{...a??{},key:s??r},...YU(o).map((e,i)=>XU(e,t,n,`${r}/${i}`)))},ZU=e=>{let t=J(11),{spec:n,components:r,Fallback:i}=e,a=n?.root,o;t[0]===a?o=t[1]:(o=YU(a),t[0]=a,t[1]=o);let s=o,c;if(t[2]!==i||t[3]!==r||t[4]!==s){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>XU(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],c=s.map(e),t[2]=i,t[3]=r,t[4]=s,t[5]=c}else c=t[5];let l;return t[9]===c?l=t[10]:(l=(0,b.jsx)(b.Fragment,{children:c}),t[9]=c,t[10]=l),l};ZU.displayName=`GenerativeUIRender`;var QU=e=>{let t=J(4),{components:n,spec:r,Fallback:i}=e,a=$($U),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,b.jsx)(ZU,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};QU.displayName=`MessagePrimitive.GenerativeUI`;function $U(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var eW=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},tW=(e,t,n)=>{let r=[];if(t){let t=eW(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=eW(`toolGroup`),n=eW(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},nW=e=>{let t=J(10),n=$(VF(EW)),r=$(VF(OW)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=tW(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},rW=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},iW=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),aW=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>iW(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},oW={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},sW=e=>{let t=J(41),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?oW.Text:i,m=a===void 0?oW.Reasoning:a,h=o===void 0?oW.Image:o,g=s===void 0?oW.Source:s,_=c===void 0?oW.File:c,v=l===void 0?oW.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let x=y,S=Q(),C=$(kW),w=C.type;if(w===`tool-call`){let e=S.part.addToolResult,n=S.part.resumeToolCall,r=S.part.respondToToolApproval;if(`Override`in x){let i;return t[4]!==e||t[5]!==C||t[6]!==r||t[7]!==n||t[8]!==x.Override?(i=(0,b.jsx)(x.Override,{...C,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=C,t[6]=r,t[7]=n,t[8]=x.Override,t[9]=i):i=t[9],i}let i=x.by_name?.[C.toolName]??x.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==C||t[13]!==r||t[14]!==n?(a=(0,b.jsx)(rW,{...C,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=C,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(C.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(w){case`text`:{let e;return t[16]!==p||t[17]!==C?(e=(0,b.jsx)(p,{...C}),t[16]=p,t[17]=C,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==m||t[20]!==C?(e=(0,b.jsx)(m,{...C}),t[19]=m,t[20]=C,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==g||t[23]!==C?(e=(0,b.jsx)(g,{...C}),t[22]=g,t[23]=C,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==h||t[26]!==C?(e=(0,b.jsx)(h,{...C}),t[25]=h,t[26]=C,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==_||t[29]!==C?(e=(0,b.jsx)(_,{...C}),t[28]=_,t[29]=C,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==v||t[32]!==C?(e=(0,b.jsx)(v,{...C}),t[31]=v,t[32]=C,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[C.name]??d?.Fallback,n;return t[34]!==e||t[35]!==C?(n=(0,b.jsx)(aW,{...C,Fallback:e}),t[34]=e,t[35]=C,t[36]=n):n=t[36],n}case`generative-ui`:{if(!f?.components)return null;let e=C,n;return t[37]!==f.Fallback||t[38]!==f.components||t[39]!==e.spec?(n=(0,b.jsx)(ZU,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[37]=f.Fallback,t[38]=f.components,t[39]=e.spec,t[40]=n):n=t[40],n}default:return console.warn(`Unknown message part type: ${w}`),null}},cW=EN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(sW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(eV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);cW.displayName=`MessagePrimitive.PartByIndex`;var lW=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,b.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,b.jsx)(nV,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},uW=Object.freeze({type:`complete`}),dW=Object.freeze({type:`running`}),fW=EN(e=>{let t=J(6),{components:n}=e,r=$(AW);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,b.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??oW.Text,a;return t[3]!==r||t[4]!==i?(a=(0,b.jsx)(lW,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),pW=EN(e=>{let t=J(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!$(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,b.jsx)(fW,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),mW=EN(e=>{let t=J(4),{Quote:n}=e,r=$(KU);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,b.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function hW(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(AV(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var gW=()=>{let e=J(6),t=Q(),n=$(jW),r=$(MW);if(!r||n.type!==`tool-call`)return null;let i;return e[0]!==r||e[1]!==t.part.addToolResult||e[2]!==t.part.respondToToolApproval||e[3]!==t.part.resumeToolCall||e[4]!==n?(i=(0,b.jsx)(r,{...n,addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval}),e[0]=r,e[1]=t.part.addToolResult,e[2]=t.part.respondToToolApproval,e[3]=t.part.resumeToolCall,e[4]=n,e[5]=i):i=e[5],i},_W=()=>{let e=J(3),t=$(NW),n=$(PW);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,b.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},vW=()=>{let e=J(2),t=$(FW);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,b.jsx)(gW,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,b.jsx)(_W,{}),e[1]=t):t=e[1],t}return null},yW=Object.freeze({type:`text`,text:``,status:dW}),bW=({children:e})=>{let t=Q(),n=$(e=>e.dataRenderers);return(0,b.jsx)(GL,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=hW(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,b.jsx)(gW,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=iW(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,b.jsx)(_W,{}):null}}return e}})})},xW=e=>{let t=J(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(bW,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(eV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},SW=e=>{let t=J(9),{children:n}=e,r=$(IW),i=$(LW),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:yW}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,b.jsx)(nV,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,b.jsx)(xW,{index:t,children:e=>n(e)??(0,b.jsx)(vW,{})},t),t[7]=n,t[8]=e),o=(0,b.jsx)(b.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},CW=e=>{let t=J(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,b.jsx)(SW,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,b.jsx)(wW,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};CW.displayName=`MessagePrimitive.Parts`;var wW=e=>{let t=J(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=$(RW),{ranges:a,partIds:o}=nW(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,b.jsx)(fW,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,b.jsx)(cW,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,b.jsx)(lV,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,b.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}if(e.type===`toolGroup`){let t=n?.ToolGroup??oW.ToolGroup;return(0,b.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,b.jsx)(cW,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??oW.ReasoningGroup;return(0,b.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,b.jsx)(cW,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,b.jsx)(mW,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,b.jsx)(pW,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,b.jsxs)(b.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function TW(e){return e.type}function EW(e){return e.message.parts.map(TW)}function DW(e){return e.type===`tool-call`?e.toolCallId:void 0}function OW(e){return e.message.parts.map(DW)}function kW(e){return e.part}function AW(e){return e.message.status??uW}function jW(e){return e.part}function MW(e){return e.part.type===`tool-call`?hW(e.tools,e.part):null}function NW(e){return e.part}function PW(e){return e.part.type===`data`?iW(e.dataRenderers,e.part.name,void 0)??null:null}function FW(e){return e.part.type}function IW(e){return e.message.parts.length}function LW(e){return(e.message.status?.type??`complete`)===`running`}function RW(e){return e.message.parts.length}var zW=Symbol.for(`@assistant-ui/groupBy.memoKey`),BW=e=>{let t=e,n=((e,n)=>{if(e.type===`tool-call`){if((AV(e.mcp?.app?.resourceUri)||(n?.toolUIs?.[e.toolName]?.[0]?.standalone??!1))&&t[`standalone-tool-call`]!==void 0)return t[`standalone-tool-call`];let r=t[`tool-call:${e.toolName}`];return r===void 0?t[`tool-call`]??[]:r}return t[e.type]??[]}),r=Object.keys(e).sort().map(t=>[t,e[t]]);return n[zW]=`groupPartByType:${JSON.stringify(r)}`,n},VW=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},HW=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},UW=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:HW(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:VW(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:VW(s),idKey:HW(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},WW=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},GW=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},KW=(e,t,n)=>{if(e.type===`part`)return(0,b.jsx)(xW,{index:e.index,children:({part:e})=>n({part:e,children:(0,b.jsx)(GW,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let{status:r,counts:i}=sV(t,e.indices),a={type:e.key,status:r,counts:i,indices:e.indices};return(0,b.jsx)(DN,{children:n({part:a,children:(0,b.jsx)(b.Fragment,{children:e.children.map(e=>KW(e,t,n))})})},e.idKey??e.nodeKey)},qW=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=$(VF(e=>e.message.parts)),i=$(e=>e.tools.toolUIs),a=$(e=>t!==`never`&&e.message.status?.type===`running`),o=_N(()=>{let t={toolUIs:i};return UW(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[zW]??e,i]);return(0,b.jsxs)(b.Fragment,{children:[o.map(e=>KW(e,r,n)),WW(t,r,a)&&n({part:{type:`indicator`},children:(0,b.jsx)(GW,{})})]})};qW.displayName=`MessagePrimitive.GroupedParts`;var JW=EN(e=>{let t=J(5),{children:n}=e,r=$(KU);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,b.jsx)(b.Fragment,{children:i}),t[3]=i,t[4]=a),a});JW.displayName=`MessagePrimitive.Quote`;var YW=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},XW=e=>{let t=J(5),{components:n}=e,r=$(eG);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=YW(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,b.jsx)(o,{}),t[3]=o,t[4]=s),s},ZW=EN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(XW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(XB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);ZW.displayName=`MessagePrimitive.AttachmentByIndex`;var QW=({children:e})=>{let t=$(VF(e=>e.message.role===`user`?(e.message.attachments??[]).map(e=>e.id):[]));return _N(()=>t.map((t,n)=>(0,b.jsx)(XB,{index:n,children:(0,b.jsx)(GL,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},$W=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(QW,{children:e=>{let{attachment:t}=e,r=YW(n,t);return r?(0,b.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(QW,{children:r}),t[2]=r,t[3]=i),i};$W.displayName=`MessagePrimitive.Attachments`;function eG(e){return e.attachment}var tG=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},nG=e=>{let t=J(5),{components:n}=e,r=$(oG);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=tG(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,b.jsx)(a,{}),t[3]=a,t[4]=o),o},rG=EN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(nG,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(ZB,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);rG.displayName=`ComposerPrimitive.AttachmentByIndex`;var iG=({children:e})=>{let t=$(VF(e=>e.composer.attachments.map(e=>e.id)));return _N(()=>t.map((t,n)=>(0,b.jsx)(ZB,{index:n,children:(0,b.jsx)(GL,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},aG=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(iG,{children:e=>{let{attachment:t}=e,r=tG(n,t);return r?(0,b.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(iG,{children:r}),t[2]=r,t[3]=i),i};aG.displayName=`ComposerPrimitive.Attachments`;function oG(e){return e.attachment}var sG=EN(({children:e})=>{let t=$(VF(e=>e.composer.queue.map(e=>e.id)));return _N(()=>t.map((t,n)=>(0,b.jsx)(pV,{index:n,children:(0,b.jsx)(GL,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});sG.displayName=`ComposerPrimitive.Queue`;var cG=EN(e=>{let t=J(6),{index:n,archived:r,components:i}=e,a=r!==void 0&&r,o=i.ThreadListItem,s;t[0]===o?s=t[1]:(s=(0,b.jsx)(o,{}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==n||t[4]!==s?(c=(0,b.jsx)(dV,{index:n,archived:a,children:s}),t[2]=a,t[3]=n,t[4]=s,t[5]=c):c=t[5],c},(e,t)=>e.index===t.index&&e.archived===t.archived&&e.components.ThreadListItem===t.components.ThreadListItem);cG.displayName=`ThreadListPrimitive.ItemByIndex`;var lG=({archived:e,children:t})=>{let n=$(VF(t=>e?t.threads.archivedThreadIds:t.threads.threadIds));return _N(()=>n.map((n,r)=>(0,b.jsx)(dV,{index:r,archived:e,children:(0,b.jsx)(GL,{getItemState:t=>t.threads.item({index:r,archived:e}).getState(),children:e=>t({get threadListItem(){return e()}})})},n)),[n,e,t])},uG=e=>{let t=J(8),{archived:n,components:r,children:i}=e,a=n!==void 0&&n;if(r){let e=r.ThreadListItem,n;t[0]===e?n=t[1]:(n=()=>(0,b.jsx)(e,{}),t[0]=e,t[1]=n);let i;return t[2]!==a||t[3]!==n?(i=(0,b.jsx)(lG,{archived:a,children:n}),t[2]=a,t[3]=n,t[4]=i):i=t[4],i}let o;return t[5]!==a||t[6]!==i?(o=(0,b.jsx)(lG,{archived:a,children:i}),t[5]=a,t[6]=i,t[7]=o):o=t[7],o};uG.displayName=`ThreadListPrimitive.Items`;var dG=e=>{let{children:t}=e;return $(fG)?t:null};dG.displayName=`MessagePartPrimitive.InProgress`;function fG(e){return e.part.status.type===`running`}var pG=e=>{let t=J(2),{fallback:n}=e,r=$(mG)||n,i;return t[0]===r?i=t[1]:(i=(0,b.jsx)(b.Fragment,{children:r}),t[0]=r,t[1]=i),i};pG.displayName=`ThreadListItemPrimitive.Title`;function mG(e){return e.threadListItem.title}var hG=e=>{let t=J(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,b.jsx)(r,{}),t[0]=r,t[1]=i),i},gG=EN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(hG,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(fV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);gG.displayName=`ThreadPrimitive.SuggestionByIndex`;var _G=({children:e})=>{let t=$(e=>e.suggestions.suggestions.length);return _N(()=>t===0?null:Array.from({length:t},(t,n)=>(0,b.jsx)(fV,{index:n,children:(0,b.jsx)(GL,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},vG=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(_G,{children:()=>(0,b.jsx)(hG,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(_G,{children:r}),t[2]=r,t[3]=i),i};vG.displayName=`ThreadPrimitive.Suggestions`;var yG=EN(vG,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),bG=e=>{let t=J(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],$(n)},xG=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),bG(r)?n:null};xG.displayName=`ComposerPrimitive.If`;var SG=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,CG=e=>!e.composer.canCancel,wG=e=>e.composer.isEditing||e.optional.thread?.voice!==void 0||e.optional.thread?.capabilities.edit===!1,TG=e=>e.thread.isRunning||e.thread.isDisabled||e.thread.voice!==void 0||e.message.role!==`assistant`||!e.thread.capabilities.reload,EG=e=>e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(e=>e.type===`text`&&e.text.length>0),DG=e=>e.message.branchNumber<=1||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,OG=e=>e.message.branchNumber>=e.message.branchCount||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,kG=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,AG=e=>{if(e.message.status?.type!==`incomplete`||e.message.status.reason!==`error`)return;let t=e.message.status.error;return typeof t==`string`?t:typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:t??`An error occurred`},jG=e=>!e.threads.hasMore||e.threads.isLoading||e.threads.isLoadingMore,MG=()=>{let e=J(5),t=Q(),n=$(SG),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},NG=()=>{let e=J(5),t=Q(),n=$(CG),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},PG=()=>{let e=J(5),t=Q(),n=$(FG),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function FG(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var IG=()=>{let e=J(5),t=Q(),n=$(LG),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function LG(e){return!e.composer.isEditing}var RG=e=>{let t=J(15),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=Q(),s=$(EG),c=$(zG),l=$(BG),u=$(VG),d=Y(void 0),f=Y(0),p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>()=>{f.current+=1,d.current!==void 0&&(clearTimeout(d.current),d.current=void 0,o.message.setIsCopied(!1))},m=[o],t[2]=o,t[3]=p,t[4]=m),X(p,m);let h;t[5]!==o||t[6]!==u||t[7]!==a||t[8]!==i||t[9]!==l?(h=()=>{if(!i)return;let e=l?u:o.message.getCopyText();if(!e)return;let t=f.current,n;try{n=i(e)}catch{return}Promise.resolve(n).then(()=>{t===f.current&&(d.current!==void 0&&clearTimeout(d.current),o.message.setIsCopied(!0),d.current=setTimeout(()=>{d.current=void 0,o.message.setIsCopied(!1)},a))},HG)},t[5]=o,t[6]=u,t[7]=a,t[8]=i,t[9]=l,t[10]=h):h=t[10];let g=h,_=s||!i,v;return t[11]!==g||t[12]!==c||t[13]!==_?(v={copy:g,disabled:_,isCopied:c},t[11]=g,t[12]=c,t[13]=_,t[14]=v):v=t[14],v};function zG(e){return e.message.isCopied}function BG(e){return e.composer.isEditing}function VG(e){return e.composer.text}function HG(){}var UG=()=>{let e=J(5),t=Q(),n=$(wG),r;e[0]===t?r=e[1]:(r=()=>{t.composer.beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},WG=()=>{let e=J(5),t=Q(),n=$(TG),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},GG=()=>{let e=J(5),t=Q(),n=$(qG),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},KG=()=>{let e=J(5),t=Q(),n=$(JG),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function qG(e){return e.message.metadata.submittedFeedback?.type===`positive`}function JG(e){return e.message.metadata.submittedFeedback?.type===`negative`}var YG=()=>{let e=J(5),t=Q(),n=$(ZG),r;e[0]===t?r=e[1]:(r=async()=>{t.message.speak()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function XG(e){return e.type===`text`&&e.text.length>0}function ZG(e){return e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(XG)}var QG=()=>{let e=J(5),t=Q(),n=$($G),r;e[0]===t?r=e[1]:(r=()=>{t.message.stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function $G(e){return e.message.speech==null}var eK=()=>{let e=J(5),t=Q(),n=$(OG),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`next`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={next:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},tK=()=>{let e=J(5),t=Q(),n=$(DG),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`previous`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={previous:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},nK=e=>{let t=J(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=Q(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>kG(e,s),t[0]=s,t[1]=c);let l=$(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let{isRunning:e,capabilities:t}=o.thread.getState();if(e&&!t.queue)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&!e&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(rK).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function rK(e){return e.trim()}var iK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.archive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={archive:r},e[2]=r,e[3]=i),i},aK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.delete()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={delete:r},e[2]=r,e[3]=i),i},oK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.unarchive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={unarchive:r},e[2]=r,e[3]=i),i},sK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.switchTo()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchTo:r},e[2]=r,e[3]=i),i},cK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threads.switchToNewThread()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchToNewThread:r},e[2]=r,e[3]=i),i},lK=()=>{let e=J(5),t=Q(),n=$(jG),r;e[0]===t?r=e[1]:(r=()=>{t.threads.loadMore()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={loadMore:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},uK=()=>$(AG),dK=e=>{let{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c,...l}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c},otherOptions:l}};function fK(e,t){function n(n){let r=NN(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function pK(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var mK=jN(null),{useThreadViewport:hK,useThreadViewportStore:gK}=pK(fK(mK,`ThreadPrimitive.Viewport`),`useThreadViewport`),_K=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},vK=(e=>e?_K(e):_K),yK=e=>e;function bK(e,t=yK){let n=y.useSyncExternalStore(e.subscribe,y.useCallback(()=>t(e.getState()),[e,t]),y.useCallback(()=>t(e.getInitialState()),[e,t]));return y.useDebugValue(n),n}var xK=e=>{let t=vK(e),n=e=>bK(t,e);return Object.assign(n,t),n},SK=(e=>e?xK(e):xK),CK=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},wK=(e={})=>{let t=new Set,n=CK(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=CK(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=SK(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{NP(t,()=>({behavior:e}),`Thread viewport`)},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},TK=e=>e,EK=e=>{let t=J(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=gK(n),i;t[1]===e?i=t[2]:(i=()=>wK(e),t[1]=e,t[2]=i);let[a]=hN(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(e=>{a.getState().scrollToBottom(e)}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),X(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&TK(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),X(c,l),a},DK=e=>{let t=J(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=EK(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=hN(o),c;return t[4]!==n||t[5]!==s?(c=(0,b.jsx)(mK.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},OK=()=>{let e=J(3),t=Q(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),X(n,r),null},kK=EN(e=>{let t=J(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,b.jsx)(OK,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,b.jsx)(DK,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,b.jsxs)(XL,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),AK=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,jK={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(AK)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},MK=Object.defineProperty,NK=(e,t)=>MK(e,`name`,{value:t,configurable:!0});function PK(e,t=globalThis?.document){let n=dt(e);y.useEffect(()=>{let e=NK(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}NK(PK,`useEscapeKeydown`);var FK=d;FK.dispatchDiscreteCustomEvent=_,FK.Root=d;var IK=Object.defineProperty,LK=(e,t)=>{let n={};for(var r in e)IK(n,r,{get:e[r],enumerable:!0});return t||IK(n,Symbol.toStringTag,{value:`Module`}),n},RK=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function zK(e,t){return kN(e,void 0,t===void 0?e.props.children:t)}function BK(e,t,n){return(0,b.jsx)(s,{...n,children:zK(e,t)})}function VK(e){let t=Z((t,n)=>{let r=J(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&AN(o)){let e=s,t;r[5]!==a||r[6]!==o?(t=zK(o,a),r[5]=a,r[6]=o,r[7]=t):t=r[7];let i;return r[8]!==n||r[9]!==e||r[10]!==t?(i=(0,b.jsx)(c,{...e,asChild:!0,ref:n,children:t}),r[8]=n,r[9]=e,r[10]=t,r[11]=i):i=r[11],i}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,b.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function HK(e){let t=FK[e],n=VK(t);return n.displayName=`Primitive.${e}`,n}var UK=RK.reduce((e,t)=>(e[t]=HK(t),e),{}),WK={Hidden:`hidden`,Floating:`floating`,Normal:`normal`},GK=e=>{let t=J(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return WK.Hidden;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?WK.Floating:WK.Normal:WK.Hidden:WK.Normal},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],$(o)},KK=jN(null),qK=()=>NN(KK),JK=Z((e,t)=>{let n=J(18),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({hideWhenRunning:a,autohide:r,autohideFloat:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let[s,c]=hN(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(YK),()=>{e||(e=!0,c(XK))}},n[5]=l):l=n[5];let u=l,d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={acquireInteractionLock:u},n[6]=d):d=n[6];let f=d,p=s>0,m;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==p?(m={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:p},n[7]=r,n[8]=i,n[9]=a,n[10]=p,n[11]=m):m=n[11];let h=GK(m);if(h===WK.Hidden)return null;let g;n[12]===h?g=n[13]:(g=h===WK.Floating?{"data-floating":`true`}:null,n[12]=h,n[13]=g);let _;return n[14]!==t||n[15]!==o||n[16]!==g?(_=(0,b.jsx)(KK.Provider,{value:f,children:(0,b.jsx)(UK.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});JK.displayName=`ActionBarPrimitive.Root`;function YK(e){return e+1}function XK(e){return Math.max(0,e-1)}var ZK=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:$K},t[2]=i,t[3]=a);let{copy:o,disabled:s}=RG(a);return s?null:o},QK=Z((e,t)=>{let n=J(20),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({copiedDuration:r,onClick:a,disabled:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=$(eq),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=ZK(c),u;n[7]===s?u=n[8]:(u=s?{"data-copied":`true`}:{},n[7]=s,n[8]=u);let d=i||!l,f;n[9]===l?f=n[10]:(f=()=>{l?.()},n[9]=l,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=P(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==o||n[16]!==u||n[17]!==d||n[18]!==p?(m=(0,b.jsx)(UK.button,{type:`button`,...u,...o,ref:t,disabled:d,onClick:p}),n[14]=t,n[15]=o,n[16]=u,n[17]=d,n[18]=p,n[19]=m):m=n[19],m});QK.displayName=`ActionBarPrimitive.Copy`;function $K(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function eq(e){return e.message.isCopied}var tq=(e,t,n=[])=>{let r=Z((e,r)=>{let i=J(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=UK,l=o.disabled||!s,u=P(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,b.jsx)(c.button,{type:`button`,...o,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},nq=tq(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=WG();return e?null:t}),rq=tq(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=UG();return e?null:t}),iq=tq(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=YG();return e?null:t}),aq=()=>{let{disabled:e,stopSpeaking:t}=QG();return e?null:t},oq=Z((e,t)=>{let n=J(10),r=aq(),i=!r,a;n[0]===r?a=n[1]:(a=()=>{r?.()},n[0]=r,n[1]=a);let o;n[2]!==e.onClick||n[3]!==a?(o=P(e.onClick,a),n[2]=e.onClick,n[3]=a,n[4]=o):o=n[4];let s;return n[5]!==e||n[6]!==t||n[7]!==i||n[8]!==o?(s=(0,b.jsx)(UK.button,{type:`button`,disabled:i,...e,ref:t,onClick:o}),n[5]=e,n[6]=t,n[7]=i,n[8]=o,n[9]=s):s=n[9],s});oq.displayName=`ActionBarPrimitive.StopSpeaking`;var sq=()=>{let{submit:e}=GG();return e},cq=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(lq),s=sq(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=P(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,b.jsx)(UK.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});cq.displayName=`ActionBarPrimitive.FeedbackPositive`;function lq(e){return e.message.metadata.submittedFeedback?.type===`positive`}var uq=()=>{let{submit:e}=KG();return e},dq=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(fq),s=uq(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=P(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,b.jsx)(UK.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});dq.displayName=`ActionBarPrimitive.FeedbackNegative`;function fq(e){return e.message.metadata.submittedFeedback?.type===`negative`}var pq=e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=Q(),o=$(gq),s;return t[2]!==a.message||t[3]!==r||t[4]!==i?(s=async()=>{let e=a.message.getCopyText();if(!e)return;if(i){await i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r??`message-${Date.now()}.md`,o.click(),setTimeout(()=>URL.revokeObjectURL(n),4e4)},t[2]=a.message,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},mq=Z((e,t)=>{let n=J(19),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({filename:i,onExport:o,onClick:a,disabled:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==i||n[7]!==o?(c={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=c):c=n[8];let l=pq(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.().catch(_q)},n[9]=l,n[10]=d);let f;n[11]!==a||n[12]!==d?(f=P(a,d),n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;return n[14]!==t||n[15]!==s||n[16]!==u||n[17]!==f?(p=(0,b.jsx)(UK.button,{type:`button`,...s,ref:t,disabled:u,onClick:f}),n[14]=t,n[15]=s,n[16]=u,n[17]=f,n[18]=p):p=n[18],p});mq.displayName=`ActionBarPrimitive.ExportMarkdown`;function hq(e){return e.type===`text`&&e.text.length>0}function gq(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(hq)}function _q(e){console.error(`[assistant-ui] markdown export failed:`,e)}var vq=LK({Copy:()=>QK,Edit:()=>rq,ExportMarkdown:()=>mq,FeedbackNegative:()=>dq,FeedbackPositive:()=>cq,Reload:()=>nq,Root:()=>JK,Speak:()=>iq,StopSpeaking:()=>oq}),yq=ul(),bq=e=>{let t=J(25),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({__scopeActionBarMore:n,open:i,onOpenChange:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=yq(n),s=qK(),c=Y(null),l=i!==void 0,u;t[5]===s?u=t[6]:(u=e=>{if(e){if(c.current)return;c.current=s?.acquireInteractionLock()??null;return}c.current?.(),c.current=null},t[5]=s,t[6]=u);let d=u,f;t[7]!==l||t[8]!==r||t[9]!==d?(f=e=>{l||d(e),r?.(e)},t[7]=l,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p=f,m,h;t[11]!==l||t[12]!==i||t[13]!==d?(m=()=>{l&&d(!!i)},h=[l,i,d],t[11]=l,t[12]=i,t[13]=d,t[14]=m,t[15]=h):(m=t[14],h=t[15]),X(m,h);let g,_;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{c.current?.(),c.current=null},_=[],t[16]=g,t[17]=_):(g=t[16],_=t[17]),X(g,_);let v;t[18]===i?v=t[19]:(v=i===void 0?null:{open:i},t[18]=i,t[19]=v);let y;return t[20]!==p||t[21]!==a||t[22]!==o||t[23]!==v?(y=(0,b.jsx)(Ml,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};bq.displayName=`ActionBarMorePrimitive.Root`;var xq=VK(Nl),Sq=VK(Fl),Cq=VK(Rl),wq=VK(Ul),Tq=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=yq(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(xq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});Tq.displayName=`ActionBarMorePrimitive.Trigger`;var Eq=Z((e,t)=>{let n=J(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({__scopeActionBarMore:r,portalProps:i,sideOffset:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?4:o,c=yq(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,b.jsx)(Sq,{...c,...a,ref:t,sideOffset:s}),n[5]=t,n[6]=a,n[7]=c,n[8]=s,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==c||n[12]!==l?(u=(0,b.jsx)(Pl,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});Eq.displayName=`ActionBarMorePrimitive.Content`;var Dq=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=yq(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(Cq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});Dq.displayName=`ActionBarMorePrimitive.Item`;var Oq=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=yq(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(wq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});Oq.displayName=`ActionBarMorePrimitive.Separator`;var kq=LK({Content:()=>Eq,Item:()=>Dq,Root:()=>bq,Separator:()=>Oq,Trigger:()=>Tq}),Aq=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,b.jsx)(UK.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});Aq.displayName=`AttachmentPrimitive.Root`;var jq=Z((e,t)=>{let n=J(4),r=$(Mq),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,b.jsx)(UK.div,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});jq.displayName=`AttachmentPrimitive.unstable_Thumb`;function Mq(e){let t=e.attachment.name,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?`.${t.slice(n+1)}`:e.attachment.type}var Nq=()=>{let e=J(2),t=$(Pq),n;return e[0]===t?n=e[1]:(n=(0,b.jsx)(b.Fragment,{children:t}),e[0]=t,e[1]=n),n};Nq.displayName=`AttachmentPrimitive.Name`;function Pq(e){return e.attachment.name}var Fq=tq(`AttachmentPrimitive.Remove`,()=>{let e=J(2),t=Q(),n;return e[0]===t.attachment?n=e[1]:(n=()=>{t.attachment.remove()},e[0]=t.attachment,e[1]=n),n}),Iq=LK({Name:()=>Nq,Remove:()=>Fq,Root:()=>Aq,unstable_Thumb:()=>jq}),Lq=tq(`BranchPickerPrimitive.Next`,()=>{let{disabled:e,next:t}=eK();return e?null:t}),Rq=tq(`BranchPickerPrimitive.Previous`,()=>{let{disabled:e,previous:t}=tK();return e?null:t}),zq=()=>$(Vq),Bq=()=>{let e=J(2),t=zq(),n;return e[0]===t?n=e[1]:(n=(0,b.jsx)(b.Fragment,{children:t}),e[0]=t,e[1]=n),n};Bq.displayName=`BranchPickerPrimitive.Count`;function Vq(e){return e.message.branchCount}var Hq=()=>$(Wq),Uq=()=>{let e=J(2),t=Hq(),n;return e[0]===t?n=e[1]:(n=(0,b.jsx)(b.Fragment,{children:t}),e[0]=t,e[1]=n),n};Uq.displayName=`BranchPickerPrimitive.Number`;function Wq(e){return e.message.branchNumber}var Gq=Z((e,t)=>{let n=J(11),r,i;n[0]===e?(r=n[1],i=n[2]):({hideWhenSingleBranch:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e=>!r||e.message.branchCount>=2,n[3]=r,n[4]=a);let o;n[5]!==t||n[6]!==i?(o=(0,b.jsx)(UK.div,{...i,ref:t}),n[5]=t,n[6]=i,n[7]=o):o=n[7];let s;return n[8]!==a||n[9]!==o?(s=(0,b.jsx)(zL,{condition:a,children:o}),n[8]=a,n[9]=o,n[10]=s):s=n[10],s});Gq.displayName=`BranchPickerPrimitive.Root`;var Kq=LK({Count:()=>Bq,Next:()=>Lq,Number:()=>Uq,Previous:()=>Rq,Root:()=>Gq}),qq=jN(null),Jq=()=>NN(qq),Yq=e=>{let t=J(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=Y(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(Xq),o.current=e.map(Zq)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,b.jsx)(qq.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function Xq(e,t){return t[1]-e[1]}function Zq(e){let[t]=e;return t}var Qq=jN(null),$q=jN(null),eJ=()=>{let e=NN(Qq);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},tJ=()=>NN(Qq),nJ=()=>{let e=NN($q);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},rJ=()=>{let e=eJ();return xN(e.subscribe,e.getTriggers,e.getTriggers)},iJ=new Map,aJ=()=>()=>{},oJ=()=>iJ,sJ=()=>{let e=tJ();return xN(e?e.subscribe:aJ,e?e.getTriggers:oJ,e?e.getTriggers:oJ)},cJ=()=>null,lJ=()=>{let e=tJ();return xN(e?e.subscribeAria:aJ,e?e.getActiveAria:cJ,e?e.getActiveAria:cJ)};function uJ(){let e=J(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=Y(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var dJ=e=>{let t=J(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=Y(a),{notify:s,subscribe:c}=uJ(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return pJ;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=Y(null),g=Y(null),{notify:_,subscribe:v}=uJ(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let x=y,S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>h.current,t[8]=S):S=t[8];let C=S,w;t[9]!==u||t[10]!==c||t[11]!==v?(w={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:C,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=w):w=t[12];let T=w,E;t[13]===x?E=t[14]:(E={setActiveAria:x},t[13]=x,t[14]=E);let D=E,O;t[15]!==D||t[16]!==n?(O=(0,b.jsx)($q.Provider,{value:D,children:n}),t[15]=D,t[16]=n,t[17]=O):O=t[17];let k;return t[18]!==O||t[19]!==T?(k=(0,b.jsx)(Qq.Provider,{value:T,children:O}),t[18]=O,t[19]=T,t[20]=k):k=t[20],k},fJ=e=>{let t=J(4),{children:n}=e;if(Jq()){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(dJ,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,b.jsx)(Yq,{children:(0,b.jsx)(dJ,{children:n})}),t[2]=n,t[3]=r),r};fJ.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function pJ(){}var mJ=/\s/u;function hJ(e,t,n,r){if(r===null)return null;let{query:i,offset:a,endOffset:o}=r;return a<0||a+t.length>n||!e.startsWith(t,a)||o<a+t.length||o>e.length?null:{query:i,offset:a,endOffset:o}}function gJ(e,t,n,r){if(r)return hJ(e,t,n,r(e,t,n));let i=e.slice(0,n);for(let e=i.length-1;e>=0;e--){let r=i[e];if(mJ.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!mJ.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var _J=PN(e=>{let t=J(8),{text:n,triggerChar:r,matcher:i}=e,[a,o]=hN(n.length),s=Math.min(a,n.length),c;t[0]!==i||t[1]!==s||t[2]!==n||t[3]!==r?(c=gJ(n,r,s,i),t[0]=i,t[1]=s,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=c,u=l?.query??``,d;return t[5]!==u||t[6]!==l?(d={trigger:l,query:u,setCursorPosition:o},t[5]=u,t[6]=l,t[7]=d):d=t[7],d});function vJ(e){return`type`in e}var yJ=PN(e=>{let t=J(22),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=hN(0),m;t[0]!==i||t[1]!==r||t[2]!==n?(m={navigableList:n,isSearchMode:r,activeCategoryId:i},t[0]=i,t[1]=r,t[2]=n,t[3]=m):m=t[3];let[h,g]=hN(m);(h.navigableList!==n||h.isSearchMode!==r||h.activeCategoryId!==i)&&(g({navigableList:n,isSearchMode:r,activeCategoryId:i}),p(0));let _;t[4]!==f||t[5]!==n.length?(_=e=>{e<0||e>=n.length||e!==f&&p(e)},t[4]=f,t[5]=n.length,t[6]=_):_=t[6];let v=bN(_),y;t[7]!==i||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==n||t[12]!==s||t[13]!==a||t[14]!==l||t[15]!==c?(y=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(vJ(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[7]=i,t[8]=d,t[9]=u,t[10]=f,t[11]=n,t[12]=s,t[13]=a,t[14]=l,t[15]=c,t[16]=y):y=t[16];let b=bN(y),x=n[f],S=s&&x?`${o}-option-${x.id}`:void 0,C;return t[17]!==b||t[18]!==v||t[19]!==f||t[20]!==S?(C={highlightedIndex:f,highlightedItemId:S,highlightIndex:v,handleKeyDown:b},t[17]=b,t[18]=v,t[19]=f,t[20]=S,t[21]=C):C=t[21],C});function bJ(e,t){return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var xJ=PN(e=>{let t=J(35),{adapter:n,query:r,open:i}=e,[a,o]=hN(null),[s,c]=hN(i);s!==i&&(c(i),i||o(null));let l;bb0:{if(!i||!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],l=e;break bb0}let e;t[1]===n?e=t[2]:(e=n.categories(),t[1]=n,t[2]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],f=e;break bb1}let e;t[4]!==n||t[5]!==d?(e=n.categoryItems(d),t[4]=n,t[5]=d,t[6]=e):e=t[6],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[7]!==n||t[8]!==r?(e=n.search(r),t[7]=n,t[8]=r,t[9]=e):e=t[9],m=e;break bb2}let e;if(t[10]!==n||t[11]!==u||t[12]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))bJ(r,i)&&e.push(r);t[10]=n,t[11]=u,t[12]=r,t[13]=e}else e=t[13];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[14]=e):e=t[14],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[15]!==u||t[16]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[15]=u,t[16]=r,t[17]=e}else e=t[17];_=e}let v=_,y;bb4:{if(g){let e;t[18]===h?e=t[19]:(e=h??[],t[18]=h,t[19]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[20]!==p||t[21]!==r){let n=r.toLowerCase();e=p.filter(e=>bJ(e,n)),t[20]=p,t[21]=r,t[22]=e}else e=t[22];y=e}let b=y,x;bb5:{if(g){let e;t[23]===h?e=t[24]:(e=h??[],t[23]=h,t[24]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[25]=C):C=t[25];let w=bN(C),T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[26]=T):T=t[26];let E=bN(T),D;return t[27]!==d||t[28]!==v||t[29]!==b||t[30]!==E||t[31]!==g||t[32]!==S||t[33]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[27]=d,t[28]=v,t[29]=b,t[30]=E,t[31]=g,t[32]=S,t[33]=w,t[34]=D):D=t[34],D}),SJ=PN(e=>{let t=J(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=Y(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>(s.current=e,()=>{s.current===e&&(s.current=null)}),t[0]=c):c=t[0];let l=bN(c),u;t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==r?(u=e=>{if(!r||!n)return;if(s.current?.(e)){o();return}let t=i.composer.getState().text,c=t.slice(0,r.offset),l=t.slice(r.endOffset),u=()=>{let t=n.formatter.serialize(e);i.composer.setText(c+t+(l.startsWith(` `)?l:` ${l}`)),a(c.length+t.length+1)};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?(i.composer.setText(c+(l.startsWith(` `)?l.slice(1):l)),a(c.length)):u(),n.onExecute(e)),o()},t[1]=i,t[2]=n,t[3]=o,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=bN(u),f;t[7]!==o||t[8]!==a||t[9]!==r?(f=()=>{o(),r&&a(r.offset)},t[7]=o,t[8]=a,t[9]=r,t[10]=f):f=t[10];let p=bN(f),m;return t[11]!==p||t[12]!==l||t[13]!==d?(m={selectItem:d,close:p,registerSelectItemOverride:l},t[11]=p,t[12]=l,t[13]=d,t[14]=m):m=t[14],m}),CJ=PN(e=>{let t=J(47),{adapter:n,text:r,triggerChar:i,matcher:a,behavior:o,aui:s,popoverId:c,isLoading:l}=e,u;t[0]!==a||t[1]!==r||t[2]!==i?(u=_J({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=SP(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=xJ({adapter:n,query:d.query,open:f}),t[4]=n,t[5]=d.query,t[6]=f,t[7]=p):p=t[7];let m=SP(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=bN(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=SJ({behavior:o,trigger:d.trigger,aui:s,triggerChar:i,setCursorPosition:d.setCursorPosition,onSelected:g}),t[10]=s,t[11]=o,t[12]=d.setCursorPosition,t[13]=d.trigger,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v=SP(_),y;t[17]!==d.query||t[18]!==m.activeCategoryId||t[19]!==m.goBack||t[20]!==m.isSearchMode||t[21]!==m.navigableList||t[22]!==m.selectCategory||t[23]!==f||t[24]!==c||t[25]!==v.close||t[26]!==v.selectItem?(y=yJ({navigableList:m.navigableList,isSearchMode:m.isSearchMode,activeCategoryId:m.activeCategoryId,query:d.query,popoverId:c,open:f,selectItem:v.selectItem,selectCategory:m.selectCategory,goBack:m.goBack,close:v.close}),t[17]=d.query,t[18]=m.activeCategoryId,t[19]=m.goBack,t[20]=m.isSearchMode,t[21]=m.navigableList,t[22]=m.selectCategory,t[23]=f,t[24]=c,t[25]=v.close,t[26]=v.selectItem,t[27]=y):y=t[27];let b=SP(y),x;return t[28]!==d.query||t[29]!==d.setCursorPosition||t[30]!==l||t[31]!==b.handleKeyDown||t[32]!==b.highlightIndex||t[33]!==b.highlightedIndex||t[34]!==b.highlightedItemId||t[35]!==m.activeCategoryId||t[36]!==m.categories||t[37]!==m.goBack||t[38]!==m.isSearchMode||t[39]!==m.items||t[40]!==m.selectCategory||t[41]!==f||t[42]!==c||t[43]!==v.close||t[44]!==v.registerSelectItemOverride||t[45]!==v.selectItem?(x={open:f,query:d.query,activeCategoryId:m.activeCategoryId,categories:m.categories,items:m.items,highlightedIndex:b.highlightedIndex,isSearchMode:m.isSearchMode,isLoading:l,popoverId:c,highlightedItemId:b.highlightedItemId,selectCategory:m.selectCategory,goBack:m.goBack,selectItem:v.selectItem,close:v.close,highlightIndex:b.highlightIndex,handleKeyDown:b.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:v.registerSelectItemOverride},t[28]=d.query,t[29]=d.setCursorPosition,t[30]=l,t[31]=b.handleKeyDown,t[32]=b.highlightIndex,t[33]=b.highlightedIndex,t[34]=b.highlightedItemId,t[35]=m.activeCategoryId,t[36]=m.categories,t[37]=m.goBack,t[38]=m.isSearchMode,t[39]=m.items,t[40]=m.selectCategory,t[41]=f,t[42]=c,t[43]=v.close,t[44]=v.registerSelectItemOverride,t[45]=v.selectItem,t[46]=x):x=t[46],x}),wJ=jN(null),TJ=()=>{let e=NN(wJ);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},EJ=()=>NN(wJ),DJ=jN(null),OJ=()=>{let e=NN(DJ);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},kJ=Z((e,t)=>{let n=J(69),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({char:a,matcher:s,adapter:r,isLoading:l,"aria-label":i,children:o,...c}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=l!==void 0&&l,d=Q(),f=$(AJ),p=wN(),m=Y(s),h;n[8]===s?h=n[9]:(h=()=>{m.current=s},n[8]=s,n[9]=h),X(h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>(e,t,n)=>m.current(e,t,n),n[10]=g):g=n[10];let[_]=hN(g),v=s!==void 0,y=Y(null),[x,S]=hN(null),C=Y(0),w;n[11]===a?w=n[12]:(w=e=>(C.current+=1,y.current=e,S(e),()=>{C.current=Math.max(0,C.current-1),y.current===e&&(y.current=null,S(null))}),n[11]=a,n[12]=w);let T=w,E;n[13]===T?E=n[14]:(E={register:T},n[13]=T,n[14]=E);let D=E,O=x??void 0,k;n[15]!==r||n[16]!==d||n[17]!==a||n[18]!==u||n[19]!==s||n[20]!==p||n[21]!==O||n[22]!==f?(k=CJ({adapter:r,text:f,triggerChar:a,matcher:s,behavior:O,aui:d,popoverId:p,isLoading:u}),n[15]=r,n[16]=d,n[17]=a,n[18]=u,n[19]=s,n[20]=p,n[21]=O,n[22]=f,n[23]=k):k=n[23];let A=SP(k),j;n[24]===A?j=n[25]:(j=()=>A,n[24]=A,n[25]=j);let M=bN(j),N=eJ(),ee;n[26]!==x||n[27]!==a||n[28]!==M||n[29]!==v||n[30]!==_||n[31]!==N?(ee=()=>N.register({char:a,...v?{matcher:_}:{},...x?{behavior:x}:{},resource:M()}),n[26]=x,n[27]=a,n[28]=M,n[29]=v,n[30]=_,n[31]=N,n[32]=ee):ee=n[32];let te;n[33]!==x||n[34]!==a||n[35]!==v||n[36]!==N?(te=[N,a,v,x],n[33]=x,n[34]=a,n[35]=v,n[36]=N,n[37]=te):te=n[37],X(ee,te);let ne=Jq(),re;n[38]!==M||n[39]!==ne?(re=()=>{if(ne)return ne.register(M())},n[38]=M,n[39]=ne,n[40]=re):re=n[40];let ie;n[41]===ne?ie=n[42]:(ie=[ne],n[41]=ne,n[42]=ie),X(re,ie);let ae=x!==null&&A.open,oe=nJ(),se,ce;n[43]!==oe||n[44]!==a||n[45]!==ae?(se=()=>{if(ae)return()=>{oe.setActiveAria(a,null)}},ce=[oe,a,ae],n[43]=oe,n[44]=a,n[45]=ae,n[46]=se,n[47]=ce):(se=n[46],ce=n[47]),X(se,ce);let le,ue;n[48]!==oe||n[49]!==a||n[50]!==ae||n[51]!==p||n[52]!==A.highlightedItemId?(le=()=>{ae&&oe.setActiveAria(a,{popoverId:p,highlightedItemId:A.highlightedItemId})},ue=[oe,a,p,ae,A.highlightedItemId],n[48]=oe,n[49]=a,n[50]=ae,n[51]=p,n[52]=A.highlightedItemId,n[53]=le,n[54]=ue):(le=n[53],ue=n[54]),X(le,ue);let de;n[55]!==i||n[56]!==o||n[57]!==t||n[58]!==ae||n[59]!==p||n[60]!==c||n[61]!==A.highlightedItemId?(de=ae?(0,b.jsx)(UK.div,{role:`listbox`,id:p,"aria-label":i??`Suggestions`,"aria-activedescendant":A.highlightedItemId,"data-state":`open`,...c,ref:t,children:o}):o,n[55]=i,n[56]=o,n[57]=t,n[58]=ae,n[59]=p,n[60]=c,n[61]=A.highlightedItemId,n[62]=de):de=n[62];let P;n[63]!==A||n[64]!==de?(P=(0,b.jsx)(wJ.Provider,{value:A,children:de}),n[63]=A,n[64]=de,n[65]=P):P=n[65];let fe;return n[66]!==D||n[67]!==P?(fe=(0,b.jsx)(DJ.Provider,{value:D,children:P}),n[66]=D,n[67]=P,n[68]=fe):fe=n[68],fe});kJ.displayName=`ComposerPrimitive.TriggerPopover`;function AJ(e){return e.composer.text}var jJ=()=>{let e=J(2),{disabled:t,send:n}=MG(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},MJ=tq(`ComposerPrimitive.Send`,jJ),NJ=jN(null),PJ=()=>NN(NJ),FJ=`[contenteditable]:not([contenteditable='false'])`,IJ=`textarea:not(:disabled), ${FJ}`,LJ=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,FJ,`[tabindex]`].join(`, `),RJ=Z((e,t)=>{let n=J(24),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({onSubmit:a,onMouseDown:i,compact:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=jJ(),[c,l]=hN(!1),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={setMultiline:l},n[5]=u):u=n[5];let d=u,f;n[6]===r?f=n[7]:(f=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
93
- `):!1,n[6]=r,n[7]=f);let p=$(f)&&!c,m;n[8]===s?m=n[9]:(m=e=>{e.preventDefault(),s&&s()},n[8]=s,n[9]=m);let h=m,g=zJ,_=r?d:null,v=p?``:void 0,y;n[10]!==h||n[11]!==a?(y=P(a,h),n[10]=h,n[11]=a,n[12]=y):y=n[12];let x;n[13]===i?x=n[14]:(x=P(i,g),n[13]=i,n[14]=x);let S;n[15]!==t||n[16]!==o||n[17]!==v||n[18]!==y||n[19]!==x?(S=(0,b.jsx)(UK.form,{...o,"data-compact":v,ref:t,onSubmit:y,onMouseDown:x}),n[15]=t,n[16]=o,n[17]=v,n[18]=y,n[19]=x,n[20]=S):S=n[20];let C;return n[21]!==_||n[22]!==S?(C=(0,b.jsx)(NJ.Provider,{value:_,children:S}),n[21]=_,n[22]=S,n[23]=C):C=n[23],C});RJ.displayName=`ComposerPrimitive.Root`;function zJ(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(LJ);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(IJ);r&&(e.preventDefault(),r.focus())}var BJ=e=>{let t=J(4),n=dt(e),r=hK(VJ),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)};function VJ(e){return e.onScrollToBottom}var HJ=()=>!1,UJ=()=>{},WJ=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return UJ;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),xN(r,i,HJ)};function GJ(){return $(KJ)}function KJ(e){return e.composer.isEditing?e.composer.text:``}function qJ(e){return!!$(JJ)||!!e}function JJ(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function YJ(){let e=J(4),t=lJ();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function XJ(){return XJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},XJ.apply(null,arguments)}function ZJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var QJ=y.useLayoutEffect,$J=function(e){var t=y.useRef(e);return QJ(function(){t.current=e}),t},eY=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},tY=function(e,t){var n=y.useRef();return y.useCallback(function(r){e.current=r,n.current&&eY(n.current,null),n.current=t,t&&eY(t,r)},[t])},nY={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},rY=function(e){Object.keys(nY).forEach(function(t){e.style.setProperty(t,nY[t],`important`)})},iY=null,aY=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function oY(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),iY||(iY=document.createElement(`textarea`),iY.setAttribute(`tabindex`,`-1`),iY.setAttribute(`aria-hidden`,`true`),rY(iY)),iY.parentNode===null&&document.body.appendChild(iY);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;iY.style[t]=o[t]}),rY(iY),iY.value=t;var c=aY(iY,e);iY.value=t,c=aY(iY,e),iY.value=`x`;var l=iY.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var sY=function(){},cY=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},lY=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],uY=!!document.documentElement.currentStyle,dY=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=cY(lY,t),r=n.boxSizing;return r===``?null:(uY&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function fY(e,t,n){var r=$J(n);y.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var pY=function(e,t){fY(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},mY=function(e){fY(window,`resize`,e)},hY=function(e){fY(document.fonts,`loadingdone`,e)},gY=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],_Y=y.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?sY:a,s=e.onHeightChange,c=s===void 0?sY:s,l=ZJ(e,gY),u=l.value!==void 0,d=y.useRef(null),f=tY(d,t),p=y.useRef(0),m=y.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:dY(e);if(t){m.current=t;var a=oY(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return y.useLayoutEffect(h),pY(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),mY(h),hY(h),y.createElement(`textarea`,XJ({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),vY=`(pointer: coarse) and (not (any-pointer: fine))`,yY=Z(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:c,submitOnEnter:l,submitMode:d,cancelOnEscape:f=!0,unstable_focusOnRunStart:p=!0,unstable_focusOnScrollToBottom:m=!0,unstable_focusOnThreadSwitched:h=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:_=!0,onHeightChange:v,...y},x)=>{let S=Q(),C=Jq(),w=PJ(),T=d??(l===!1?`none`:`enter`),E=WJ(g?vY:null),D=g&&E&&T===`enter`?`none`:T,O=GJ(),k=qJ(r),A=Y(null),j=u(x,A),M=Y(!1);PK(e=>{if(!A.current?.contains(e.target)||e.isComposing)return;if(C){for(let t of C.getPlugins())if(t.handleKeyDown(e))return}if(!f)return;let t=S.composer;t.getState().canCancel&&(t.cancel(),e.preventDefault())});let N=e=>{if(!k&&!e.nativeEvent.isComposing){if(C){for(let t of C.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=S.thread.getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&T!==`none`&&S.composer.getState().canSend){e.preventDefault(),S.composer.send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;D===`ctrlEnter`?r=e.ctrlKey||e.metaKey:D===`enter`&&(r=!0),r&&(e.preventDefault(),A.current?.closest(`form`)?.requestSubmit())}}},ee=async e=>{if(!_)return;let t=S.thread.getState().capabilities,n=Array.from(e.clipboardData?.files||[]);t.attachments&&n.length>0&&(e.preventDefault(),await Promise.all(n.map(async e=>{try{await S.composer.addAttachment(e)}catch{}})))},te=(e,t)=>{if(v?.(e,t),!w)return;let n=A.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&w.setMultiline(!0)},ne=e&&!k,re=vN(()=>{let e=A.current;e&&ne&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[ne]);X(()=>re(),[re]),BJ(()=>{S.composer.getState().type===`thread`&&m&&re()}),X(()=>{if(S.composer.getState().type===`thread`&&p)return S.on(`thread.runStart`,re)},[p,re,S]),X(()=>{if(S.composer.getState().type===`thread`&&h)return S.on(`threads.selectionChanged`,re)},[h,re,S]),X(()=>{O===``&&w?.setMultiline(!1)},[O,w]);let ie=YJ(),ae={name:`input`,value:O,...y,...ie,ref:j,disabled:k,onChange:P(i,e=>{if(!S.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;M.current&&!t&&(M.current=!1);let n=t||M.current;if(qN(()=>{S.composer.setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(C)for(let e of C.getPlugins())e.setCursorPosition(r)}),onKeyDown:P(a,N),onCompositionStart:P(y.onCompositionStart,()=>{M.current=!0}),onCompositionEnd:P(y.onCompositionEnd,e=>{if(M.current=!1,!S.composer.getState().isEditing)return;let t=e.target;qN(()=>{S.composer.setText(t.value)});let n=t.selectionStart??t.value.length;if(C)for(let e of C.getPlugins())e.setCursorPosition(n)}),onSelect:P(c,e=>{if(M.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(C)for(let e of C.getPlugins())e.setCursorPosition(n)}),onPaste:P(o,ee),...w?{onHeightChange:te}:v===void 0?{}:{onHeightChange:v}};if(n&&AN(n))return BK(n,y.children,ae);let oe=t?s:_Y;return(0,b.jsx)(oe,{...ae})});yY.displayName=`ComposerPrimitive.Input`;var bY=tq(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=NG();return e?null:t}),xY=tq(`ComposerPrimitive.AddAttachment`,e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=IG(),s=Q(),c;return t[2]!==o||t[3]!==s.composer||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer.getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=async t=>{let n=t.target.files;if(!n)return;let r=Array.from(n,async e=>{try{await o(e)}catch{}});document.body.removeChild(e),await Promise.all(r)},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s.composer,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),SY=Z(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,c]=hN(!1),l=Q(),u=vN(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}c(!0)}},[e,l]),d=vN(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}o||c(!0)}},[e,o,l]),f=vN(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||c(!1)},[e]),p=vN(async t=>{if(e||(c(!1),!t.dataTransfer.types.includes(`Files`)))return;t.preventDefault();let n=Array.from(t.dataTransfer.files);l.thread.getState().capabilities.attachments&&n.length!==0&&await Promise.all(n.map(async e=>{try{await l.composer.addAttachment(e)}catch{}}))},[e,l]),m={...o?{"data-dragging":`true`}:null,...i,onDragEnterCapture:P(i.onDragEnterCapture,u),onDragOverCapture:P(i.onDragOverCapture,d),onDragLeaveCapture:P(i.onDragLeaveCapture,f),onDropCapture:P(i.onDropCapture,p),ref:a};if(n&&AN(n))return BK(n,r,m);let h=t?s:`div`;return(0,b.jsx)(h,{...m,children:r})});SY.displayName=`ComposerPrimitive.AttachmentDropzone`;var CY=tq(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=PG();return e?null:t}),wY=tq(`ComposerPrimitive.StopDictation`,()=>{let e=J(2),t=Q(),n=$(TY),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function TY(e){return e.composer.dictation!=null}var EY=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(DY);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,b.jsx)(UK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});EY.displayName=`ComposerPrimitive.DictationTranscript`;function DY(e){return e.composer.dictation?.transcript}var OY=Z((e,t)=>{let n=J(3);if(!$(jY))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,b.jsx)(UK.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});OY.displayName=`ComposerPrimitive.Quote`;var kY=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(MY);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,b.jsx)(UK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});kY.displayName=`ComposerPrimitive.QuoteText`;var AY=Z((e,t)=>{let n=J(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(),o;n[3]===a?o=n[4]:(o=()=>{a.composer.setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=P(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,b.jsx)(UK.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});AY.displayName=`ComposerPrimitive.QuoteDismiss`;function jY(e){return e.composer.quote}function MY(e){return e.composer.quote?.text}var NY=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=TJ();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,b.jsx)(UK.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});NY.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var PY=Z((e,t)=>{let n=J(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=TJ(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let x=y,S=`${p}-option-${r}`,C=v?``:void 0,w;n[16]!==h||n[17]!==i?(w=P(i,h),n[16]=h,n[17]=i,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==a?(T=P(a,x),n[19]=x,n[20]=a,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,b.jsx)(UK.button,{type:`button`,role:`option`,id:S,"aria-selected":v,"data-highlighted":C,...o,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=v,n[24]=o,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});PY.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var FY=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=TJ();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,b.jsx)(UK.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});FY.displayName=`ComposerPrimitive.TriggerPopoverItems`;var IY=Z((e,t)=>{let n=J(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=TJ(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,x;n[13]!==l||n[14]!==v?(x=()=>{l(v)},n[13]=l,n[14]=v,n[15]=x):x=n[15];let S=x,C=`${m}-option-${i.id}`,w=y?``:void 0,T;n[16]!==g||n[17]!==a?(T=P(a,g),n[16]=g,n[17]=a,n[18]=T):T=n[18];let E;n[19]!==S||n[20]!==o?(E=P(o,S),n[19]=S,n[20]=o,n[21]=E):E=n[21];let D;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==C||n[26]!==w||n[27]!==T||n[28]!==E?(D=(0,b.jsx)(UK.button,{type:`button`,role:`option`,id:C,"aria-selected":y,"data-highlighted":w,...s,ref:t,onClick:T,onMouseMove:E}),n[22]=t,n[23]=y,n[24]=s,n[25]=C,n[26]=w,n[27]=T,n[28]=E,n[29]=D):D=n[29],D});IY.displayName=`ComposerPrimitive.TriggerPopoverItem`;var LY=Z((e,t)=>{let n=J(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=TJ();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=P(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,b.jsx)(UK.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});LY.displayName=`ComposerPrimitive.TriggerPopoverBack`;var RY=e=>{let t=J(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=OJ(),o=Y(r),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{o.current=r},c=[r],t[0]=r,t[1]=s,t[2]=c),CN(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e={kind:`action`,formatter:n??jK,onExecute:e=>o.current(e),...i===void 0?{}:{removeOnExecute:i}};return a(e)},u=[a,n,i],t[3]=n,t[4]=a,t[5]=i,t[6]=l,t[7]=u):(l=t[6],u=t[7]),X(l,u),null};RY.displayName=`ComposerPrimitive.TriggerPopoverAction`;var zY=e=>{let t=J(7),{formatter:n,onInserted:r}=e,{register:i}=OJ(),a=Y(r),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{a.current=r},s=[r],t[0]=r,t[1]=o,t[2]=s),CN(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n??jK,onInserted:e=>a.current?.(e)}),l=[i,n],t[3]=n,t[4]=i,t[5]=c,t[6]=l):(c=t[5],l=t[6]),X(c,l),null};zY.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var BY=Object.assign(kJ,{Directive:zY,Action:RY}),VY=LK({AddAttachment:()=>xY,AttachmentByIndex:()=>rG,AttachmentDropzone:()=>SY,Attachments:()=>aG,Cancel:()=>bY,Dictate:()=>CY,DictationTranscript:()=>EY,If:()=>xG,Input:()=>yY,Queue:()=>sG,Quote:()=>OY,QuoteDismiss:()=>AY,QuoteText:()=>kY,Root:()=>RJ,Send:()=>MJ,StopDictation:()=>wY,Unstable_TriggerPopover:()=>BY,Unstable_TriggerPopoverBack:()=>LY,Unstable_TriggerPopoverCategories:()=>NY,Unstable_TriggerPopoverCategoryItem:()=>PY,Unstable_TriggerPopoverItem:()=>IY,Unstable_TriggerPopoverItems:()=>FY,Unstable_TriggerPopoverRoot:()=>fJ,unstable_useTriggerPopoverRootContext:()=>eJ,unstable_useTriggerPopoverRootContextOptional:()=>tJ,unstable_useTriggerPopoverScopeContext:()=>TJ,unstable_useTriggerPopoverScopeContextOptional:()=>EJ,unstable_useTriggerPopoverTriggers:()=>rJ,unstable_useTriggerPopoverTriggersOptional:()=>sJ}),HY=Object.freeze({type:`complete`}),UY=Object.freeze({type:`text`,text:``,status:HY}),WY=()=>$(GY);function GY(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?UY:e.part}var KY=jN(null),qY=e=>({useSmoothStatus:SK(()=>e)}),JY=e=>{let t=J(6),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={optional:!0},t[0]=r):r=t[0];let i=XY(r),a=Q(),o;t[1]===a.part?o=t[2]:(o=()=>qY(a.part.getState().status),t[1]=a.part,t[2]=o);let[s]=hN(o);if(i)return n;let c;return t[3]!==n||t[4]!==s?(c=(0,b.jsx)(KY.Provider,{value:s,children:n}),t[3]=n,t[4]=s,t[5]=c):c=t[5],c},YY=e=>{let t=Z((t,n)=>{let r=J(3),i=t,a;return r[0]!==n||r[1]!==i?(a=(0,b.jsx)(JY,{children:(0,b.jsx)(e,{...i,ref:n})}),r[0]=n,r[1]=i,r[2]=a):a=r[2],a});return t.displayName=e.displayName,t};function XY(e){let t=NN(KY);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:ZY,useSmoothStatusStore:QY}=pK(XY,`useSmoothStatus`),$Y=250,eX=5,tX=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=$Y;maxCharIntervalMs=eX;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},nX=Object.freeze({type:`running`}),rX=(e,t)=>e!==void 0&&e>0?e:t,iX=(e,t=!1)=>{let{text:n}=e,r=WJ(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=rX(i?.drainMs,$Y),s=rX(i?.maxCharIntervalMs,eX),c=rX(i?.maxCharsPerFrame,1/0),l=rX(i?.minCommitMs,0),[u,d]=hN(e.status.type===`running`?``:n),f=Q(),p=$(()=>f.part),[m,h]=hN(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=QY({optional:!0}),_=dt(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?nX:e.status;TK(g).setState(n,!0)}});X(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?nX:e.status;TK(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=hN(new tX(u,_));X(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=Y(p);return X(()=>{if(!a){v.stop();return}let t=y.current!==p;if(y.current=p,t||!n.startsWith(v.targetText)){e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=0,v.start()):(v.currentText=n,v.targetText=n,v.stop(),_(n));return}if(v.targetText=n,e.status.type!==`running`){if(v.currentText===``){v.currentText=n,v.stop(),_(n);return}v.start();return}v.start()},[v,a,n,e.status.type,p,_]),X(()=>()=>{v.stop()},[v]),_N(()=>a?{...e,text:u,status:n===u?e.status:nX}:e,[a,u,e,n])},aX=Object.freeze({type:`complete`}),oX=Object.freeze({type:`image`,image:``,status:aX}),sX=()=>$(cX);function cX(e){return e.part.type===`image`?e.part:oX}var lX=Z(({smooth:e=!0,component:t=UK.span,render:n,...r},i)=>{let{text:a,status:o}=iX(WY(),e),s={"data-status":o.type,...r,ref:i};return n&&AN(n)?BK(n,a,s):(0,b.jsx)(t,{...s,children:a})});lX.displayName=`MessagePartPrimitive.Text`;var uX=Z((e,t)=>{let n=J(4),{image:r}=sX(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,b.jsx)(UK.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});uX.displayName=`MessagePartPrimitive.Image`;var dX=Z((e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=(0,b.jsx)(UK.div,{role:`alert`,...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});dX.displayName=`ErrorPrimitive.Root`;var fX=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=uK();if(a===void 0)return null;let o=r??String(a),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,b.jsx)(UK.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});fX.displayName=`ErrorPrimitive.Message`;var pX=LK({Message:()=>fX,Root:()=>dX}),mX=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},hX=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},gX=e=>e.dataset.messageId,_X=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},vX=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},yX=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},bX=()=>{let e=J(4),t=Q(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=$(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),mX(i)},xX=()=>{let e=J(2),t=hK(OX),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},SX=()=>{let e=J(2),t=hK(kX),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},CX=(e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],mX(r)},wX=e=>{let t=J(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:hX(i.tallerThan,e),visibleHeight:hX(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],mX(i)},TX=e=>{let t=J(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=bX(),a=u(n,i),o=$(AX),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,b.jsx)(UK.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},EX=e=>{let t=J(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=bX(),o=xX(),s=SX(),c=CX(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let d=wX(l),f=u(n,a,c,d),p=$(jX),m=o?``:void 0,h=s?``:void 0,g;return t[7]!==p||t[8]!==r||t[9]!==f||t[10]!==m||t[11]!==h?(g=(0,b.jsx)(UK.div,{...r,ref:f,"data-message-id":p,"data-aui-top-anchor-user":m,"data-aui-top-anchor-target":h}),t[7]=p,t[8]=r,t[9]=f,t[10]=m,t[11]=h,t[12]=g):g=t[12],g},DX=Z((e,t)=>{let n=J(7),r=gK();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,b.jsx)(EX,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,b.jsx)(TX,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});DX.displayName=`MessagePrimitive.Root`;function OX(e){return e.topAnchorTurn?.anchorId}function kX(e){return e.topAnchorTurn?.targetId}function AX(e){return e.message.id}function jX(e){return e.message.id}var MX={...oW,Text:()=>(0,b.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,b.jsx)(lX,{}),(0,b.jsx)(dG,{children:(0,b.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,b.jsx)(uX,{})},NX=e=>{let t=J(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,b.jsx)(CW,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{...n,Text:n.Text??MX.Text,Image:n.Image??MX.Image}:MX,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,b.jsx)(CW,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};NX.displayName=`MessagePrimitive.Parts`;var PX=e=>{let t=J(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],$(n)},FX=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),PX(r)?n:null};FX.displayName=`MessagePrimitive.If`;var IX=e=>{let{children:t}=e;return uK()===void 0?null:t};IX.displayName=`MessagePrimitive.Error`;var LX=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??n,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=typeof e==`string`?e:void 0;n.push({groupKey:t,indices:r})}return n},RX=e=>{let t=J(4),n=$(YX),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},zX=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},BX=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},VX={Text:()=>(0,b.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,b.jsx)(lX,{}),(0,b.jsx)(dG,{children:(0,b.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,b.jsx)(uX,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},HX=e=>{let t=J(37),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?VX.Text:i,p=a===void 0?VX.Reasoning:a,m=o===void 0?VX.Image:o,h=s===void 0?VX.Source:s,g=c===void 0?VX.File:c,_=l===void 0?VX.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,x=Q(),S=$(XX),C=S.type;if(C===`tool-call`){let e=x.part.addToolResult,n=x.part.resumeToolCall,r=x.part.respondToToolApproval;if(`Override`in y){let i;return t[4]!==e||t[5]!==S||t[6]!==r||t[7]!==n||t[8]!==y.Override?(i=(0,b.jsx)(y.Override,{...S,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=S,t[6]=r,t[7]=n,t[8]=y.Override,t[9]=i):i=t[9],i}let i=y.by_name?.[S.toolName]??y.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==S||t[13]!==r||t[14]!==n?(a=(0,b.jsx)(zX,{...S,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=S,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[16]!==f||t[17]!==S?(e=(0,b.jsx)(f,{...S}),t[16]=f,t[17]=S,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==p||t[20]!==S?(e=(0,b.jsx)(p,{...S}),t[19]=p,t[20]=S,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==h||t[23]!==S?(e=(0,b.jsx)(h,{...S}),t[22]=h,t[23]=S,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==m||t[26]!==S?(e=(0,b.jsx)(m,{...S}),t[25]=m,t[26]=S,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==g||t[29]!==S?(e=(0,b.jsx)(g,{...S}),t[28]=g,t[29]=S,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==_||t[32]!==S?(e=(0,b.jsx)(_,{...S}),t[31]=_,t[32]=S,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[34]!==e||t[35]!==S?(n=(0,b.jsx)(BX,{...S,Fallback:e}),t[34]=e,t[35]=S,t[36]=n):n=t[36],n}default:return console.warn(`Unknown message part type: ${C}`),null}},UX=EN(e=>{let t=J(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(HX,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(eV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),WX=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,b.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,b.jsx)(nV,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},GX=Object.freeze({type:`complete`}),KX=EN(e=>{let t=J(6),{components:n}=e,r=$(ZX);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,b.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??VX.Text,a;return t[3]!==r||t[4]!==i?(a=(0,b.jsx)(WX,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),qX=e=>{let t=J(9),{groupingFunction:n,components:r}=e,i=$(QX),a=RX(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,b.jsx)(KX,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>{let n=r?.Group??VX.Group;return(0,b.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,b.jsx)(UX,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`)},t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,b.jsx)(b.Fragment,{children:s}),t[7]=s,t[8]=c),c};qX.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var JX=e=>{let t=J(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,b.jsx)(qX,{...r,components:n,groupingFunction:LX}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};JX.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function YX(e){return e.message.parts}function XX(e){return e.part}function ZX(e){return e.message.status??GX}function QX(e){return e.message.parts.length}var $X=LK({AttachmentByIndex:()=>ZW,Attachments:()=>$W,Content:()=>NX,Error:()=>IX,GenerativeUI:()=>QU,GroupedParts:()=>qW,If:()=>FX,PartByIndex:()=>cW,Parts:()=>NX,Quote:()=>JW,Root:()=>DX,Unstable_PartsGrouped:()=>qX,Unstable_PartsGroupedByParentId:()=>JX}),eZ=e=>{let t=J(2),n=dt(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(tZ)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),mX(r)};function tZ(e){return e.type!==`attributes`||e.attributeName!==`style`}var nZ=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=Y(null),a=$(e=>e.thread.messages.length>0),o=$(e=>e.thread.isRunning),s=Y(!1),c=Y(null),l=gK();e===void 0&&(e=l.getState().turnAnchor!==`top`);let d=Y(0),f=Y(0),p=Y(0),m=Y(0),h=Y(null),g=Y(e),_=Y(e);yN(()=>{let t=_.current;if(_.current=e,t||!e)return;let n=i.current;g.current=n!==null&&bI(n)},[e]);let v=vN(e=>{let t=i.current;t&&(g.current=!0,h.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),y=vN(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),b=vN(e=>{h.current=e,y(),c.current=requestAnimationFrame(()=>{c.current=null,v(e)})},[y,v]);yN(()=>()=>y(),[y]);let x=vN(()=>{let e=l.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[l]),S=()=>{let t=i.current;if(!t)return;let n=l.getState().isAtBottom,r=bI(t);if(!(!r&&d.current<t.scrollTop)){let i=SI({scrollTop:d.current,scrollHeight:f.current},t);r?(xI(t)&&(h.current=null),e&&(g.current=!0)):i&&(y(),h.current=null,g.current=!1),(r||h.current===null)&&r!==n&&TK(l).setState({isAtBottom:r})}d.current=t.scrollTop,f.current=t.scrollHeight},C=eZ(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===p.current&&r===m.current)return;p.current=n,m.current=r;let a=h.current;a&&x()?h.current=null:a?v(a):e&&!(o&&x())&&g.current&&v(`instant`),S()}),w=mX(e=>{let t=()=>{h.current=null};return e.addEventListener(`scroll`,S),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,S),e.removeEventListener(`pointerdown`,t)}});return yN(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,h.current===null&&b(`instant`))}},[a,b,n]),BJ(({behavior:e})=>{v(e)}),qL(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&b(`auto`)}),qL(`threads.selectionChanged`,()=>{r&&b(`instant`)}),u(C,w,i)},rZ=Z((e,t)=>{let n=J(6),r=Q(),i,a;n[0]===r?(i=n[1],a=n[2]):(i=()=>{let e=e=>{if(e.key===`Escape`&&!(e.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},a=[r],n[0]=r,n[1]=i,n[2]=a),X(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,b.jsx)(UK.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});rZ.displayName=`ThreadPrimitive.Root`;var iZ=e=>{let{children:t}=e;return $(aZ)?t:null};iZ.displayName=`ThreadPrimitive.Empty`;function aZ(e){return e.thread.isEmpty}var oZ=e=>{let t=J(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],$(n)},sZ=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),oZ(r)?n:null};sZ.displayName=`ThreadPrimitive.If`;var cZ=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],mX(r)},lZ=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},uZ=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:lZ(e)-lZ(t)},dZ=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=uZ(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},fZ=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=dZ(t)+n.clientHeight;return Math.max(0,r-e)},pZ=({viewport:e,reserve:t,...n})=>fZ({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),mZ=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},hZ=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},gZ=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o){a.disconnect(),t&&(vX(t,0),t.remove());return}if(!s&&!c&&!l&&r.topAnchorTurn){a.disconnect(),t?.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!s||!c||!l){a.disconnect(),t&&(vX(t,0),t.remove());return}if(t??=_X(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),vX(t,pZ({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=gX(s);if(u!==void 0&&n===u)return;let d=yX(dZ({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=hZ(r),a=mZ(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},_Z=e=>{let t=J(4),n=gK(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return gZ(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),yN(r,i)},vZ=(e,t)=>{if(!e)return!1;let n=t.findIndex(t=>t.id===e.targetId);return n<1?!1:t[n-1]?.id===e.anchorId&&t.slice(n+1).every(e=>e.role===`user`)},yZ=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},bZ=e=>yZ(e)?.anchorId,xZ=e=>yZ(e)?.targetId,SZ=()=>cZ(hK(DZ),OZ),CZ=()=>mX(hK(kZ)),wZ=e=>{let t=J(19),n=gK(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return bZ(t.thread)},t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return xZ(t.thread)},t[2]=e,t[3]=a);let o=$(a),s=hK(AZ),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&vZ(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=$(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{s&&!d&&n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),yN(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;(t?.anchorId!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),yN(m,h)},TZ=Z((e,t)=>{let n=J(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let d=nZ(l),f=SZ(),p=CZ(),m=gK(),h;n[12]===m?h=n[13]:(h=m.getState(),n[12]=m,n[13]=h);let g=h.turnAnchor===`top`;wZ(g),_Z(g);let _=u(t,d,f,p),v;return n[14]!==i||n[15]!==_||n[16]!==a?(v=(0,b.jsx)(UK.div,{...a,ref:_,children:i}),n[14]=i,n[15]=_,n[16]=a,n[17]=v):v=n[17],v});TZ.displayName=`ThreadPrimitive.ViewportScrollable`;var EZ=Z((e,t)=>{let n=J(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,b.jsx)(TZ,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,b.jsx)(DK,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});EZ.displayName=`ThreadPrimitive.Viewport`;function DZ(e){return e.registerViewport}function OZ(e){return e.clientHeight}function kZ(e){return e.registerViewportElement}function AZ(e){return e.topAnchorTurn}var jZ=Z((e,t)=>{let n=J(3),r=cZ(hK(MZ),NZ),i=u(t,r),a;return n[0]!==e||n[1]!==i?(a=(0,b.jsx)(UK.div,{...e,ref:i}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});jZ.displayName=`ThreadPrimitive.ViewportFooter`;function MZ(e){return e.registerContentInset}function NZ(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var PZ=tq(`ThreadPrimitive.ScrollToBottom`,e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=hK(FZ),a=gK(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function FZ(e){return e.isAtBottom}var IZ=tq(`ThreadPrimitive.Suggestion`,e=>{let t=J(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=nK(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),LZ=LK({Empty:()=>iZ,If:()=>sZ,MessageByIndex:()=>zU,Messages:()=>UU,Root:()=>rZ,ScrollToBottom:()=>PZ,Suggestion:()=>IZ,SuggestionByIndex:()=>gG,Suggestions:()=>yG,Unstable_MessageById:()=>BU,Viewport:()=>EZ,ViewportFooter:()=>jZ,ViewportProvider:()=>DK}),RZ=Z((e,t)=>{let n=J(4),r=$(zZ),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,b.jsx)(UK.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});RZ.displayName=`SuggestionPrimitive.Title`;function zZ(e){return e.suggestion.title}var BZ=Z((e,t)=>{let n=J(4),r=$(VZ),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,b.jsx)(UK.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});BZ.displayName=`SuggestionPrimitive.Description`;function VZ(e){return e.suggestion.label}var HZ=tq(`SuggestionPrimitive.Trigger`,e=>{let t=J(4),{send:n,clearComposer:r}=e,i=$(UZ),a;t[0]!==r||t[1]!==i||t[2]!==n?(a={prompt:i,send:n,clearComposer:r},t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3];let{trigger:o,disabled:s}=nK(a);return s?null:o},[`send`,`clearComposer`]);function UZ(e){return e.suggestion.prompt}var WZ=LK({Description:()=>BZ,Title:()=>RZ,Trigger:()=>HZ}),GZ=Z((e,t)=>{let n=J(15),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(KZ),{switchToNewThread:s}=cK(),c;n[4]===o?c=n[5]:(c=o?{"data-active":`true`,"aria-current":`true`}:null,n[4]=o,n[5]=c);let l;n[6]!==i||n[7]!==s?(l=P(i,s),n[6]=i,n[7]=s,n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==t||n[11]!==a||n[12]!==c||n[13]!==l?(u=(0,b.jsx)(UK.button,{type:`button`,...c,...a,ref:t,disabled:r,onClick:l}),n[9]=r,n[10]=t,n[11]=a,n[12]=c,n[13]=l,n[14]=u):u=n[14],u});GZ.displayName=`ThreadListPrimitive.New`;function KZ(e){return e.threads.newThreadId===e.threads.mainThreadId}var qZ=tq(`ThreadListPrimitive.LoadMore`,()=>{let{loadMore:e,disabled:t}=lK();return t?null:e}),[JZ,YZ]=M(`ThreadList`),XZ=JZ,ZZ=jN(null),QZ=ZZ.Provider,$Z=()=>NN(ZZ),eQ=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,b.jsx)(XZ.Provider,{scope:void 0,children:(0,b.jsx)(XZ.Slot,{scope:void 0,children:(0,b.jsx)(UK.div,{...e,ref:t})})}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});eQ.displayName=`ThreadListPrimitive.Root`;var tQ=LK({ItemByIndex:()=>cG,Items:()=>uG,LoadMore:()=>qZ,New:()=>GZ,Root:()=>eQ}),nQ=Z((e,t)=>{let n=$(e=>e.threads.mainThreadId===e.threadListItem.id),r=Y(null),i=Y(null),a=_N(()=>({triggerRef:r,moreRef:i}),[]),o=YZ(void 0),s=ct(),c=e=>{let t=s===`rtl`?`ArrowLeft`:`ArrowRight`,n=s===`rtl`?`ArrowRight`:`ArrowLeft`,a=r.current,c=i.current;if(a&&e.target===a){if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=o().map(e=>e.ref.current).filter(e=>e!==null),n=t[t.indexOf(a)+(e.key===`ArrowDown`?1:-1)];n&&(n.focus(),e.preventDefault())}else e.key===t&&c&&(c.focus(),e.preventDefault())}else c&&e.target===c&&e.key===n&&(a?.focus(),e.preventDefault())};return(0,b.jsx)(QZ,{value:a,children:(0,b.jsx)(UK.div,{...n?{"data-active":`true`,"aria-current":`true`}:null,...e,onKeyDown:P(e.onKeyDown,c),ref:t})})});nQ.displayName=`ThreadListItemPrimitive.Root`;var rQ=tq(`ThreadListItemPrimitive.Archive`,()=>{let{archive:e}=iK();return e}),iQ=tq(`ThreadListItemPrimitive.Unarchive`,()=>{let{unarchive:e}=oK();return e}),aQ=tq(`ThreadListItemPrimitive.Delete`,()=>{let{delete:e}=aK();return e}),oQ=tq(`ThreadListItemPrimitive.Trigger`,()=>{let{switchTo:e}=sK();return e}),sQ=Z((e,t)=>{let n=J(3),r=$Z(),i=u(t,r?.triggerRef),a;return n[0]!==e||n[1]!==i?(a=(0,b.jsx)(XZ.ItemSlot,{scope:void 0,children:(0,b.jsx)(oQ,{...e,ref:i})}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});sQ.displayName=`ThreadListItemPrimitive.Trigger`;var cQ=LK({Archive:()=>rQ,Delete:()=>aQ,Root:()=>nQ,Title:()=>pG,Trigger:()=>sQ,Unarchive:()=>iQ}),lQ=ul(),uQ=jN(()=>{}),dQ=()=>NN(uQ),fQ=jN(!1),pQ=()=>NN(fQ),mQ=e=>{let t=J(26),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({__scopeThreadListItemMore:n,open:o,defaultOpen:r,onOpenChange:a,sharedFocusGroup:c,modal:i,...s}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c!==void 0&&c,u=l?!1:i??!0,d=lQ(n),f=r??!1,p;t[8]===a?p=t[9]:(p=a?{onChange:a}:{},t[8]=a,t[9]=p);let m;t[10]!==o||t[11]!==f||t[12]!==p?(m={prop:o,defaultProp:f,caller:`ThreadListItemMorePrimitive.Root`,...p},t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13];let[h,g]=Te(m),_;t[14]!==u||t[15]!==h||t[16]!==s||t[17]!==d||t[18]!==g?(_=(0,b.jsx)(Ml,{...d,...s,modal:u,open:h,onOpenChange:g}),t[14]=u,t[15]=h,t[16]=s,t[17]=d,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==g||t[21]!==_?(v=(0,b.jsx)(uQ.Provider,{value:g,children:_}),t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;return t[23]!==l||t[24]!==v?(y=(0,b.jsx)(fQ.Provider,{value:l,children:v}),t[23]=l,t[24]=v,t[25]=y):y=t[25],y};mQ.displayName=`ThreadListItemMorePrimitive.Root`;var hQ=Z((e,t)=>{let n=J(10),{__scopeThreadListItemMore:r,...i}=e,a=lQ(r),o=$Z(),s=dQ(),c=pQ(),l=u(t,o?.moreRef),d=ct()===`rtl`?`ArrowLeft`:`ArrowRight`,f=xq,p;n[0]!==d||n[1]!==s||n[2]!==c?(p=e=>{c&&e.key===d&&(e.preventDefault(),s(!0))},n[0]=d,n[1]=s,n[2]=c,n[3]=p):p=n[3];let m=P(i.onKeyDown,p),h;return n[4]!==f||n[5]!==l||n[6]!==i||n[7]!==a||n[8]!==m?(h=(0,b.jsx)(f,{...a,...i,onKeyDown:m,ref:l}),n[4]=f,n[5]=l,n[6]=i,n[7]=a,n[8]=m,n[9]=h):h=n[9],h});hQ.displayName=`ThreadListItemMorePrimitive.Trigger`;var gQ=Z((e,t)=>{let n=J(21),{__scopeThreadListItemMore:r,portalProps:i,sideOffset:a,...o}=e,s=a===void 0?4:a,c=lQ(r),l=dQ(),u=$Z(),d=pQ(),f=ct()===`rtl`?`ArrowRight`:`ArrowLeft`,p=al,m=Sq,h;n[0]!==f||n[1]!==u?.moreRef||n[2]!==l||n[3]!==d?(h=e=>{d&&e.key===f&&(e.preventDefault(),l(!1),u?.moreRef.current?.focus())},n[0]=f,n[1]=u?.moreRef,n[2]=l,n[3]=d,n[4]=h):h=n[4];let g=P(o.onKeyDown,h),_;n[5]!==u?.moreRef||n[6]!==d?(_=()=>{d&&u?.moreRef.current?.focus()},n[5]=u?.moreRef,n[6]=d,n[7]=_):_=n[7];let v=P(o.onEscapeKeyDown,_),y;n[8]!==m||n[9]!==t||n[10]!==o||n[11]!==c||n[12]!==s||n[13]!==g||n[14]!==v?(y=(0,b.jsx)(m,{...c,...o,onKeyDown:g,onEscapeKeyDown:v,ref:t,sideOffset:s}),n[8]=m,n[9]=t,n[10]=o,n[11]=c,n[12]=s,n[13]=g,n[14]=v,n[15]=y):y=n[15];let x;return n[16]!==i||n[17]!==c||n[18]!==p.Portal||n[19]!==y?(x=(0,b.jsx)(p.Portal,{...c,...i,children:y}),n[16]=i,n[17]=c,n[18]=p.Portal,n[19]=y,n[20]=x):x=n[20],x});gQ.displayName=`ThreadListItemMorePrimitive.Content`;var _Q=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=lQ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(Cq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});_Q.displayName=`ThreadListItemMorePrimitive.Item`;var vQ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=lQ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(wq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});vQ.displayName=`ThreadListItemMorePrimitive.Separator`;var yQ=LK({Content:()=>gQ,Item:()=>_Q,Root:()=>mQ,Separator:()=>vQ,Trigger:()=>hQ}),bQ=(e,t)=>{let n=J(5),r=Y(null),i=Y(null),a,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>()=>{i.current?.()},o=[],n[0]=a,n[1]=o):(a=n[0],o=n[1]),X(a,o);let s;return n[2]!==e||n[3]!==t?(s=()=>{i.current?.(),(function(){if(r.current||!e.current)return;let t=e.current;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`scroll`||e===`auto`){r.current=t;break}t=t.parentElement}})();let n=r.current;if(!n)return;let a=n.scrollTop,o=n.style.scrollbarWidth,s=getComputedStyle(n),c=s.direction===`rtl`?`paddingLeft`:`paddingRight`,l=n.style[c],u=n.offsetWidth-n.clientWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.borderRightWidth),d=n.ownerDocument,f=(n===d.documentElement||n===d.body)&&u<=0?(d.defaultView?.innerWidth??0)-d.documentElement.clientWidth:u;n.style.scrollbarWidth=`none`,f>0&&(n.style[c]=`${parseFloat(s[c])+f}px`);let p=()=>{n.style.scrollbarWidth=o,n.style[c]=l},m=()=>n.scrollTop=a;n.addEventListener(`scroll`,m);let h=setTimeout(()=>{n.removeEventListener(`scroll`,m),p(),i.current=null},t);i.current=()=>{clearTimeout(h),n.removeEventListener(`scroll`,m),p()}},n[2]=e,n[3]=t,n[4]=s):s=n[4],s},xQ=()=>{let e=J(3),t=$(SQ),n=$(CQ),r=t!==void 0&&t.completedAt===void 0&&n,[i,a]=hN(wQ),o,s;if(e[0]===r?(o=e[1],s=e[2]):(o=()=>{if(!r)return;a(Date.now());let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},s=[r],e[0]=r,e[1]=o,e[2]=s),X(o,s),t!==void 0){if(t.completedAt!==void 0)return Math.max(0,t.completedAt-t.startedAt);if(r)return Math.max(0,i-t.startedAt)}};function SQ(e){let t=e.optional.part;return t?.type===`tool-call`?t.timing:void 0}function CQ(e){let t=e.optional.part;return t?.type===`tool-call`&&t.status.type===`running`}function wQ(){return Date.now()}var TQ=LK({AssistantRuntimeImpl:()=>QV,BaseAssistantRuntimeCore:()=>rH,CompositeContextProvider:()=>PI,DefaultThreadComposerRuntimeCore:()=>EH,MessageRepository:()=>mH,ThreadRuntimeImpl:()=>HV,getAutoStatus:()=>AB,splitLocalRuntimeOptions:()=>dK,useComposerInputPluginRegistryOptional:()=>Jq,useSmooth:()=>iX,useSmoothStatus:()=>ZY,withSmoothContextProvider:()=>YY}),EQ=(e,t)=>`${e}:${t}`,DQ=e=>({id:e,status:`idle`}),OQ=e=>({threadId:e,metadata:DQ(e),messages:[],streamingMessageIndex:void 0,toolExecutions:{},runStatus:`idle`,queue:{steering:[],followUp:[]},contextUsage:void 0,compaction:{active:!1},retry:{active:!1,attempt:0},hostUiRequests:[],readiness:void 0,lastError:void 0,loadState:`pending`,lastSeq:0}),kQ=e=>e?.role===`assistant`,AQ=(e,t)=>e.status===t?e:{...e,status:t},jQ=(e,t,n)=>e.compactionActive===t.active&&e.retryActive===n.active&&e.retryAttempt===n.attempt?e:{...e,compactionActive:t.active,retryActive:n.active,retryAttempt:n.attempt},MQ=(e,t)=>{let n=t.metadata.status===`running`?`running`:t.metadata.status===`failed`?`failed`:`idle`,r=n!==`running`,i=t.seq!==void 0&&t.seq<e.lastSeq,a=t.metadata.compactionActive??(!r&&e.compaction.active),o=t.metadata.retryActive??(!r&&e.retry.active),s=i?e.compaction:a?{...e.compaction,active:!0}:{active:!1},c=i?e.retry:o?{active:!0,attempt:t.metadata.retryAttempt??e.retry.attempt}:{active:!1,attempt:0};return{...e,metadata:jQ(t.metadata,s,c),messages:t.messages,streamingMessageIndex:void 0,toolExecutions:{},runStatus:n,compaction:s,retry:c,queue:{steering:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`steer`).map(e=>e.content),followUp:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`followUp`).map(e=>e.content)},contextUsage:t.metadata.contextUsage??e.contextUsage,hostUiRequests:t.hostUiRequests??[],readiness:t.readiness??e.readiness,lastError:t.lastError,loadState:`loaded`}},NQ=(e,t,n)=>{let r=e.slice();return r[t]=n,r},PQ=(e,t,n)=>({...e,toolExecutions:{...e.toolExecutions,[t]:{toolCallId:t,status:`running`,...e.toolExecutions[t],...n}}}),FQ=(e,t)=>e.hostUiRequests.some(e=>e.id===t)?{...e,hostUiRequests:e.hostUiRequests.filter(e=>e.id!==t)}:e,IQ=(e,t)=>{if(t.type!==`snapshot`&&t.type!==`error`&&t.seq<=e.lastSeq)return e;let n=n=>n===e&&t.seq<=e.lastSeq?n:{...n,lastSeq:Math.max(e.lastSeq,t.seq)};switch(t.type){case`snapshot`:return n(MQ(e,t.snapshot));case`agent_start`:return n({...e,runStatus:`running`,lastError:void 0,metadata:AQ(e.metadata,`running`)});case`agent_end`:{let r=t.willRetry===!0;return n({...e,runStatus:r?`running`:`idle`,streamingMessageIndex:void 0,metadata:AQ(e.metadata,r?`running`:`idle`)})}case`message_start`:{let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:kQ(t.message)?r.length-1:e.streamingMessageIndex})}case`message_update`:{if(e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length)return n({...e,messages:NQ(e.messages,e.streamingMessageIndex,t.message)});let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:r.length-1})}case`message_end`:return e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length?n({...e,messages:NQ(e.messages,e.streamingMessageIndex,t.message),streamingMessageIndex:void 0}):n({...e,streamingMessageIndex:void 0});case`tool_execution_start`:return n(PQ(e,t.toolCallId,{toolName:t.toolName,args:t.args,status:`running`}));case`tool_execution_update`:return n(PQ(e,t.toolCallId,{...t.toolName===void 0?{}:{toolName:t.toolName},partialResult:t.partialResult,status:`running`}));case`tool_execution_end`:return n(PQ(e,t.toolCallId,{partialResult:t.result,status:t.isError?`error`:`complete`}));case`queue_update`:return n({...e,queue:{steering:t.steering,followUp:t.followUp}});case`compaction_start`:{let r={active:!0,reason:t.reason};return n({...e,compaction:r,metadata:jQ(e.metadata,r,e.retry)})}case`compaction_end`:{let t={active:!1};return n({...e,compaction:t,metadata:jQ(e.metadata,t,e.retry)})}case`auto_retry_start`:{let r={active:!0,attempt:t.attempt};return n({...e,retry:r,metadata:jQ(e.metadata,e.compaction,r)})}case`auto_retry_end`:{let t={active:!1,attempt:0};return n({...e,retry:t,metadata:jQ(e.metadata,e.compaction,t)})}case`context_usage`:return n({...e,contextUsage:t.contextUsage});case`session_info_changed`:{let r={...e.metadata};return t.name===void 0?delete r.title:r.title=t.name,n({...e,metadata:r})}case`thinking_level_changed`:return n({...e,metadata:{...e.metadata,config:{...e.metadata.config,thinkingLevel:t.level}}});case`extension_ui_request`:return e.hostUiRequests.some(e=>e.id===t.request.id)?n(e):n({...e,hostUiRequests:[...e.hostUiRequests,t.request]});case`extension_ui_resolved`:return n(FQ(e,t.requestId));case`error`:return n({...e,lastError:t.error,runStatus:`failed`,metadata:AQ(e.metadata,`failed`)});case`agent_settled`:case`entry_appended`:return n(e);default:return n(e)}},LQ=e=>{let t=new Map,n=[];for(let r of e)r.toolCallId!==void 0&&zQ(r)?t.has(r.toolCallId)?n.push(r):t.set(r.toolCallId,r):n.push(r);return{toolAssociated:t,freeStanding:n}},RQ=(e,t)=>({requestId:e,confirmed:t}),zQ=e=>{switch(e.kind){case`confirm`:return{id:e.id,prompt:`${e.title}\n${e.message}`};case`select`:return e.options.length===0?void 0:{id:e.id,prompt:e.title,display:`select`,options:e.options.map((e,t)=>({id:String(t),kind:`_${t}`,label:e}))};case`input`:case`editor`:return{id:e.id,prompt:e.title,display:`text`}}},BQ=(e,t)=>{if(e.kind===`confirm`)return RQ(e.id,t.approved);if(!t.approved)return{requestId:e.id,dismissed:!0};let n=e.kind===`select`?e.options.find((e,n)=>String(n)===t.optionId):t.text;if(n===void 0)throw Error(`Pi ${e.kind} request "${e.id}" was not answered with ${e.kind===`select`?`one of its options`:`text`}`);return{requestId:e.id,value:n}},VQ=e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(e.dismissed)return;if(typeof e.value==`string`)return e.value}},HQ=(e,t)=>{let n=VQ(t);return n===void 0?{requestId:e,dismissed:!0}:{requestId:e,value:n}};function UQ(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}function WQ(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var GQ=e=>`pi-msg:${e}`,KQ=e=>`pi-step:${e}`,qQ=(e,t)=>/^data:/i.test(e)?e:`data:${t};base64,${e}`,JQ=e=>new Date(typeof e.timestamp==`number`?e.timestamp:0),YQ=e=>{if(!e)return{};let t=e.filter(e=>e.type===`text`).map(e=>e.text).join(``);return e.every(e=>e.type===`text`)?{result:t}:{result:t,modelContent:e.flatMap(e=>{if(e.type===`text`)return[{type:`text`,text:e.text}];let t=UQ(e.data);return[{type:`file`,data:t?.data??e.data,mediaType:t?.mimeType??e.mimeType}]})}},XQ=e=>{if(e==null)return;let t=e.content;if(Array.isArray(t))return t.filter(e=>typeof e==`object`&&!!e&&(e.type===`text`&&typeof e.text==`string`||e.type===`image`&&typeof e.data==`string`&&typeof e.mimeType==`string`))},ZQ=e=>typeof e==`string`?[{type:`text`,text:e}]:e.map(e=>e.type===`image`?{type:`image`,image:qQ(e.data,e.mimeType)}:{type:`text`,text:e.text}),QQ=(e,t)=>({type:`data`,name:e,data:t}),$Q=e=>{let t=new Map;for(let n of e){if(n.role!==`toolResult`)continue;let e=n;t.set(e.toolCallId,{...YQ(XQ({content:e.content})),isError:e.isError,details:e.details})}return t},e$=(e,t,n,r,i,a)=>{let o=KQ(n);e.lastAssistant=t,e.steps.push({messageId:o,usage:{inputTokens:t.usage?.input??0,outputTokens:t.usage?.output??0}});for(let n of t.content)if(n.type===`text`)e.parts.push({type:`text`,text:n.text,parentId:o});else if(n.type===`thinking`){let t=n.thinking||(n.redacted?`[reasoning redacted]`:``);e.parts.push({type:`reasoning`,text:t,parentId:o})}else if(n.type===`toolCall`){let t=i.get(n.id),s=r.toolExecutions[n.id],c=t??YQ(XQ(s?.partialResult)),l=t?.isError??s?.status===`error`,u=a.get(n.id),d=u&&zQ(u),f={type:`tool-call`,toolCallId:n.id,toolName:n.name,args:n.arguments??{},argsText:JSON.stringify(n.arguments??{}),parentId:o,...c.result===void 0?{}:{result:c.result},...c.modelContent===void 0?{}:{modelContent:c.modelContent},...l?{isError:!0}:{},...d?{approval:d}:{}};d&&(e.hasPendingHostUi=!0),e.parts.push(f)}},t$=(e,t,n)=>{let r=e.lastAssistant,i=n$(e,t,n);return{id:GQ(e.firstIndex),role:`assistant`,createdAt:JQ(r),content:e.parts,...i?{status:i}:{},metadata:{steps:e.steps,custom:{pi:{provider:r.provider,model:r.model,api:r.api,usage:r.usage,stopReason:r.stopReason,...r.errorMessage?{errorMessage:r.errorMessage}:{}}}}}},n$=(e,t,n)=>{if(e.hasPendingHostUi)return{type:`requires-action`,reason:`interrupt`};let r=e.lastAssistant;return t.runStatus===`running`&&n&&r.stopReason!==`error`&&r.stopReason!==`aborted`?{type:`running`}:r.stopReason===`error`?{type:`incomplete`,reason:`error`,...r.errorMessage?{error:r.errorMessage}:{}}:r.stopReason===`aborted`?{type:`incomplete`,reason:`cancelled`}:r.stopReason===`length`?{type:`incomplete`,reason:`length`}:{type:`complete`,reason:`stop`}},r$=e=>{let{messages:t}=e,n=$Q(t),r=LQ(e.hostUiRequests).toolAssociated,i=[],a=null,o=t=>{a&&=(i.push(t$(a,e,t)),null)};return t.forEach((s,c)=>{let l=c===t.length-1;switch(s.role){case`assistant`:a||={firstIndex:c,parts:[],steps:[],lastAssistant:s,hasPendingHostUi:!1},e$(a,s,c,e,n,r),l&&o(!0);break;case`toolResult`:break;case`user`:o(!1),i.push({id:GQ(c),role:`user`,createdAt:JQ(s),content:ZQ(s.content)});break;case`bashExecution`:{o(!1);let e=s;i.push(i$(c,e,`pi-bash-execution`,{command:e.command,output:e.output,exitCode:e.exitCode,cancelled:e.cancelled,truncated:e.truncated,fullOutputPath:e.fullOutputPath}));break}case`custom`:{o(!1);let e=s;if(!e.display)break;i.push({id:GQ(c),role:`assistant`,createdAt:JQ(e),content:[QQ(`pi-custom-message`,{customType:e.customType,details:e.details}),...ZQ(e.content)]});break}case`branchSummary`:{o(!1);let e=s;i.push(i$(c,e,`pi-branch-summary`,{summary:e.summary,fromId:e.fromId}));break}case`compactionSummary`:{o(!1);let e=s;i.push(i$(c,e,`pi-compaction-summary`,{summary:e.summary,tokensBefore:e.tokensBefore}));break}default:o(!1),i.push(i$(c,s,`pi-unsupported-message`,{role:s.role,message:s}))}}),o(!0),i},i$=(e,t,n,r)=>({id:GQ(e),role:`assistant`,createdAt:JQ(t),content:[QQ(n,r)]}),a$=(e,t)=>e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():void 0,o$=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,s$=(e,t)=>{if(e===t)return!0;let n=a$(e,t);if(n!==void 0)return n;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!s$(e[n],t[n]))return!1;return!0}if(o$(e)||o$(t)){if(!o$(e)||!o$(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!s$(e[r],t[r]))return!1;return!0}return!1},c$=(e,t)=>e.id===t.id&&e.role===t.role&&s$(e.createdAt,t.createdAt)&&s$(e.content,t.content)&&s$(e.status,t.status)&&s$(e.metadata,t.metadata),l$=(e,t)=>{let n=e.length!==t.length,r=e.map((e,r)=>{let i=t[r];return i&&c$(e,i)?i:(n=!0,e)});return n?r:t},u$=(e,t)=>l$(r$(e),t),d$={snapshot:!0,agent_start:!0,agent_end:!0,agent_settled:!0,turn_start:!0,turn_end:!0,message_start:!0,message_update:!0,message_end:!0,tool_execution_start:!0,tool_execution_update:!0,tool_execution_end:!0,queue_update:!0,compaction_start:!0,compaction_end:!0,entry_appended:!0,auto_retry_start:!0,auto_retry_end:!0,session_info_changed:!0,thinking_level_changed:!0,context_usage:!0,extension_ui_request:!0,extension_ui_resolved:!0,error:!0},f$=e=>Object.prototype.hasOwnProperty.call(d$,e),p$=e=>e instanceof Error?e.message:String(e),m$=e=>{if(typeof globalThis.requestAnimationFrame==`function`){globalThis.requestAnimationFrame(()=>e());return}setTimeout(e,16)},h$=e=>{for(let t of e)try{t()}catch(e){console.error(`[react-pi] Listener threw an error`,e)}},g$=new Set([`snapshot`,`agent_start`,`agent_end`,`message_start`,`message_update`,`message_end`,`tool_execution_update`,`tool_execution_end`,`extension_ui_request`,`extension_ui_resolved`]),_$=new Set([`message_update`,`tool_execution_update`]),v$=new Set([`snapshot`,`agent_start`,`agent_end`,`queue_update`,`compaction_start`,`compaction_end`,`auto_retry_start`,`auto_retry_end`,`session_info_changed`,`thinking_level_changed`,`context_usage`,`extension_ui_request`,`extension_ui_resolved`,`error`]),y$=e=>{let t=/^data:([^;,]+)(?:;base64)?,(.*)$/is.exec(e);return t?{type:`image`,mimeType:t[1].toLowerCase(),data:t[2]}:{type:`image`,mimeType:`image/png`,data:e}},b$=e=>[...e.content,...e.attachments?.flatMap(e=>e.content??[])??[]],x$=(e,t)=>{let n=b$(e),r=[],i=[];for(let e of n)e.type===`text`?r.push(e.text):e.type===`image`&&i.push(y$(e.image));return{content:r.join(`
92
+ `),BV=`ui://`,VV=e=>!!e?.startsWith(BV),HV=e=>e.display===`text`||e.allowFreeform===!0,UV={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},WV=(e,t)=>{let n=t.text;if(n!==void 0&&!HV(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){let n=e.options?.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(UV,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=UV[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:e.id,approved:r,...i!==void 0&&{optionId:i},...n!==void 0&&{text:n},...t.reason!=null&&{reason:t.reason}}},GV=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=_R.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,isError:a.isError,...a.artifact!==void 0&&{artifact:a.artifact},...a.modelContent!==void 0&&{modelContent:a.modelContent}})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);return this.threadApi.getState().respondToToolApproval(WV(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},KV=(e,t)=>{let n=e.content[t];if(!n)return PI;let r=kL(e,t,n);return Object.freeze({...n,[xB]:n[xB],status:r})},qV=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new RV(new UI({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e,comment:t}){let n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:e,...t===void 0?void 0:{comment:t}})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return zV(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new GV(new VI({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>KV(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new GV(new VI({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?PI:KV(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new jV(new VI({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:PI},subscribe:e=>this._core.subscribe(e)}))}},JV=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),YV=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),XV=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId===void 0?e.at(-1)?.id??null:t.parentId,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},ZV=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},QV=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:ZV(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),$V=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new VI({path:e.path,getState:()=>QV(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>II([r,i])}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new LV(new UI({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){let t=this._threadBinding.getState().append(XV(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!EV(e))throw e})}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(YV(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(JV(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new qV(new VI({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return PI;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[xB]:e[xB],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new WI({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},eH=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),tH=class extends RI{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},nH=e=>{let t=J(6),{adapters:n,children:r}=e,i=WN(gB),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,b.jsx)(gB.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},rH=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(e){let t=this._core.getState();return this._threadListBinding.generateTitle(t.id,e)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,(e!==`switchedTo`||a)&&(e===`switchedAway`&&a||WP([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},iH=Promise.resolve(),aH=()=>{},oH=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,loadError:e.loadError,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),sH=(e,t)=>{if(t===void 0)return PI;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:PI},cH=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=$V){this._core=e,this._runtimeFactory=t;let n=new HI({path:{},getState:()=>oH(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new rH(new VI({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>sH(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new UI({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){return this._core.unstable_subscribeThreadEvents?.(e)??aH}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??iH}reloadMainThread(){return this._core.reloadMainThread?.()??iH}loadMore(){return this._core.loadMore?.()??iH}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new VI({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>sH(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new UI({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(e))}getItemByIndex(e){return new rH(new VI({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>sH(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new rH(new VI({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>sH(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new rH(this._createItemStateBinding(e),this._core)}},lH=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new cH(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},uH=new WeakMap,dH=e=>uH.get(e)??0,fH=(e,t)=>dH(e)===t,pH=e=>{uH.set(e,dH(e)+1)},mH=class{_contextProvider=new GI;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},hH=Object.freeze([]),gH=`DEFAULT_THREAD_ID`,_H=Object.freeze([gH]),vH=Object.freeze({id:gH,remoteId:void 0,externalId:void 0,status:`regular`}),yH=Promise.resolve(),bH=Object.freeze(OM({[gH]:vH})),xH=class extends RI{_mainThreadId=gH;_threads=_H;_archivedThreads=hH;_threadData=bH;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return yH}_mainThread;get mainThreadId(){return this._mainThreadId}threadFactory;constructor(e={},t){super(),this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return Object.hasOwn(this._threadData,e)?this._threadData[e]:void 0}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??gH,i=e.threads??hH,a=e.archivedThreads??hH,o=n.threadId??gH,s=n.threads??hH,c=n.archivedThreads??hH;(t||(n.isLoading??!1)!==(e.isLoading??!1)||o!==r||s!==i||c!==a)&&((s!==i||c!==a||o!==r)&&(this._threadData=OM(bH,Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[]))),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??hH),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??hH),(t||o!==r)&&(t||pH(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=OM(this._threadData,{[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}})),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},SH={fromArray:e=>{let t=e.map(e=>AB(e,DB(),HB(e.content)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>({...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:AB(e,e.id,HB(e.content))}})})},CH=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},wH=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},TH=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}selectPathTo(e){for(let t=e;t;t=t.prev)(t.prev??this.root).next=t}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],t.prev=e,CH(t)===this.head?this.selectPathTo(t):i.next===null&&(i.next=t,this.head===i&&(this.head=CH(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new wH(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=CH(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;this.selectPathTo(t),this.head=CH(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t,this.selectPathTo(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[],t=[...this.root.children].reverse();for(;t.length>0;){let n=this.messages.get(t.pop());if(!n)continue;for(let e=n.children.length-1;e>=0;e--)t.push(n.children[e]);if(n.current.metadata?.isOptimistic)continue;let r=n.prev;for(;r&&r.current.metadata?.isOptimistic;)r=r.prev;e.push({message:n.current,parentId:r?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},EH=Object.freeze([]);function*DH(e){for(let t of e)if(t?.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e&&e.type===`tool-call`&&(yield{part:e,messageId:t.id},e.messages?.length&&(yield*DH(e.messages)))}function OH(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=e.name.toLowerCase(),i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&r.endsWith(e)||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function kH(e){let t=DB();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function AH(e){let t=[];for(let n of e)n.type!==`text`&&t.push(kH(n));return t}var jH=e=>`content`in e&&!(`lastModified`in e),MH=e=>e.status.type===`complete`,NH=class{operations=new Set;start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){return!e.cancelled&&(e.attachmentIds.add(t),!0)}finish(e){this.operations.delete(e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t))}cancelAll(){for(let e of this.operations)e.cancelled=!0;this.operations.clear()}},PH=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},FH=class extends RI{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_isSending=!1;_removedDuringSend=new Set;_sendGeneration=0;_attachmentAddOperations=new NH;_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._rebaseDictation(``),this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!MH(e));await Promise.all(t.map(async t=>e.remove(t)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){if(this._cancelAllAttachmentAdds(),this._isSending)for(let e of this._attachments)this._removedDuringSend.add(e.id);let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;if(this._dictationSession)try{this._dictationSession.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation()}let t=this.getAttachmentAdapter(),n=this.attachments.map(async e=>{if(MH(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)}),r=this.attachments,i=this.text,a=this._quote,o=this.role,s=this.runConfig;this._quote=void 0,this._text=``,this._isSending=!0;let c=++this._sendGeneration;this._notifySubscribers();let l;try{l=await Promise.all(n)}catch(e){throw c===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=a,this._notifySubscribers()),Promise.allSettled(n).then(()=>{c===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),e}if(c!==this._sendGeneration)return;let u=new Set(r.map(e=>e.id));this._attachments=this._attachments.filter(e=>!u.has(e.id)),this._isSending=!1,this._notifySubscribers();let d=l.filter(e=>!this._removedDuringSend.has(e.id));this._removedDuringSend.clear();let f={createdAt:new Date,role:o,content:i?[{type:`text`,text:i}]:[],attachments:d,runConfig:s,metadata:{custom:{...a?{quote:a}:{}}}},p={text:i,quote:a,attachments:d},m;try{m=this.handleSend(f,e)}catch(e){throw this._restoreUnsentDraft(e,c,p),e}m&&m.catch(e=>{this._restoreUnsentDraft(e,c,p)}),this._notifyEventSubscribers(`send`,{chars:i.length,attachments:d.length})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text===e.text&&this._quote===e.quote&&t&&(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,t,n){EV(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return EH}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(jH(e)){let t=this.getAttachmentAdapter();if(t&&!OH({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.contentType),r}let n={id:e.id??DB(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{...n.contentType?{contentType:n.contentType}:void 0});return}let t=this.getAttachmentAdapter();if(!t){let t=`Attachments are not supported`,n=Error(t);throw this._safeEmitAttachmentAddError(`no-adapter`,t,void 0,n,e.type),n}if(!OH({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.type),r}let n=this._attachmentAddOperations.start(),r=e=>{if(!this._attachmentAddOperations.accept(n,e.id))return!1;let t=this._attachments.findIndex(t=>t.id===e.id);return this._attachments=t===-1?[...this._attachments,e]:[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers(),!0},i;try{await PH(t.add({file:e}),e=>(i=e,r(e)))}catch(t){if(this._attachmentAddOperations.isCancelled(n))return;throw i&&r({...i,status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}}),this._safeEmitAttachmentAddError(`adapter-error`,t instanceof Error?t.message:String(t),i?.id,t instanceof Error?t:void 0,i?.contentType||e.type),t}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(i?.status.type===`incomplete`&&i.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,i.status.message??`Attachment upload did not complete successfully.`,i.id,void 0,i.contentType||e.type):this._notifyEventSubscribers(`attachmentAdd`,{...i?.contentType?{contentType:i.contentType}:e.type?{contentType:e.type}:void 0}))}_safeEmitAttachmentAddError(e,t,n,r,i){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r},...i?{contentType:i}:void 0})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!MH(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!MH(t)?{...t,status:{type:`incomplete`,reason:`error`,message:n}}:t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);let t=this._dictationSession!==void 0;if(this._dictationSession){let e=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(e)}let n=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let r;try{r=e.listen()}catch(e){if(t)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Dictation replacement rollback notification threw`,e)}throw e}this._dictationSession=r;let i=++this._dictationSessionIdCounter;this._activeDictationSessionId=i,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();let a=r.onSpeech(e=>{if(!this._isActiveSession(i,r))return;let t=e.isFinal!==!1,n=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+n+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=n+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(a);let o=r.onSpeechStart(()=>{this._isActiveSession(i,r)&&(this._dictation={status:{type:`running`},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);let s=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:i})});this._dictationUnsubscribes.push(s);let c=setInterval(()=>{this._isActiveSession(i,r)&&r.status.type===`ended`&&this._cleanupDictation({sessionId:i})},100);this._dictationUnsubscribes.push(()=>clearInterval(c))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;this._stopDictationSession(e,()=>this._cleanupDictation({sessionId:t}))}_stopDictationSession(e,t=()=>{}){let n;try{n=e.stop()}catch(e){console.error(`[assistant-ui] Dictation session stop threw`,e),t();return}n.then(t,e=>{console.error(`[assistant-ui] Dictation session stop rejected`,e),t()})}_cleanupDictation(e){if(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;let t=e=>{try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}};try{let n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``;for(let e of n)t(e);e?.notify!==!1&&t(()=>this._notifySubscribers())}finally{this._isCleaningDictation=!1}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&WP(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},IH=e=>e.capabilities?.cancel?ZV(e):!1,LH=class extends FH{get canCancel(){return IH(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this.runtime.voice&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??EH,t=this.runtime.getQueueItems?.()??EH,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.runtime.voice!==void 0,r=this.queue;return this.runtime.subscribe(()=>{let i=!1,a=this.canCancel;e!==a&&(e=a,i=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,i=!0);let o=this.runtime.voice!==void 0;n!==o&&(n=o,i=!0),r!==this.queue&&(r=this.queue,i=!0),i&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},RH=class extends FH{get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this.runtime.voice&&!this._isSending}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e;let i=e.voice!==void 0,a=e.subscribe(()=>{let t=e.voice!==void 0;t!==i&&(i=t,this._notifySubscribers())});this.endEditCallback=()=>{a(),t()},this._parentId=n,this._sourceId=r.id,this.setText(zV(r)),this.setRole(r.role);let o;r.role===`user`?(o=[...r.attachments??[],...AH(r.content)],this._nonTextPassthrough=[]):(o=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(o),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},zH=class extends RI{_isInitialized=!1;repository=new TH;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();if(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e){let t=new Set(e.map(e=>e.id));this._cachedMergedMessages=[...e,...this._voiceMessages.filter(e=>!t.has(e.id))],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new LH(this);_contextProvider;constructor(e){super(),this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=mB(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}_isVoiceMessage(e){return e!==null&&this._voiceMessages.some(t=>t.id===e)}_resolveAppendParent(e){return this._isVoiceMessage(e)?this._getBaseMessages().at(-1)?.id??null:e}beginEdit(e){if(this.voice)throw Error(`Cannot edit a message while a voice session is connected`);if(this._isVoiceMessage(e))throw Error(`Voice transcript messages cannot be edited`);if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new RH(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&WP(n,t,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,t,n,r){this._notifyEventSubscribers(`toolApprovalAnswered`,{messageId:e,toolCallId:t,toolName:n,approved:r})}submitFeedback({messageId:e,type:t,comment:n}){let r=this.adapters?.feedback,i=this.getMessageById(e);if(!i)throw Error(`Message not found: ${e}`);let{message:a,parentId:o}=i,s=n?.trim(),c={type:t,...s?{comment:s}:void 0};if(r?.submit({message:a,...c}),a.role===`assistant`){let t={...a,metadata:{...a.metadata,submittedFeedback:c}},n=this._voiceMessages.findIndex(t=>t.id===e);n===-1?this.repository.addOrUpdateMessage(o,t):(this._voiceMessages[n]=t,this._currentAssistantMsg===a&&(this._currentAssistantMsg=t),this._markVoiceMessagesDirty())}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let n=this.getMessageById(e);if(!n)throw Error(`Message not found: ${e}`);let{message:r}=n,i=this._stopSpeaking,a;try{i?.(),a=t.speak(zV(r))}catch(e){if(i&&!this._stopSpeaking)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Speech rollback notification threw`,e)}throw e}let o,s=()=>{this._stopSpeaking=void 0,this.speech=void 0;let e=o;o=void 0,e?.()},c=()=>{if(this._stopSpeaking===c)try{s()}finally{a.cancel()}},l=()=>{this._stopSpeaking===c&&(a.status.type===`ended`?FI([s,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:a.status},this._notifySubscribers()))};this._stopSpeaking=c;try{if(o=a.subscribe(l),this._stopSpeaking!==c){o();return}l()}catch(e){if(this._stopSpeaking===c)try{FI([c,()=>this._notifySubscribers()])}catch(e){console.error(`[assistant-ui] Speech rollback cleanup threw`,e)}throw e}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);FI([this._stopSpeaking,()=>this._notifySubscribers()])}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){if(this.isRunning)return!0;let e=this._getBaseMessages().at(-1);return e?.role===`assistant`&&(e.status.type===`running`||e.status.type===`requires-action`)}connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);if(this._isRunActive())throw Error(`Cannot start a voice session while a run is in progress or paused on a pending tool action`);let t=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice cleanup threw before reconnect`,e)}let n;try{n=e.connect({})}catch(e){throw t&&this._voiceSession===void 0&&this._onVoiceDisconnected(),e}this._voiceSession=n;let r=[];this._voiceUnsubs=r;let i=()=>{if(this._voiceSession===n&&this._voiceUnsubs===r)return!1;try{FI(r.splice(0))}catch(e){console.error(`[assistant-ui] Detached voice setup cleanup threw`,e)}return!0};try{let e=`listening`;if(this.voice={status:n.status,isMuted:n.isMuted,mode:e},this._voiceVolume=0,this._notifySubscribers(),i()||(r.push(n.onStatusChange(t=>{this._voiceSession===n&&(t.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0,this._onVoiceDisconnected()):this.voice={status:t,isMuted:n.isMuted,mode:e},this._notifySubscribers())})),i())||(r.push(n.onModeChange(t=>{e=t,this.voice&&(this.voice={...this.voice,mode:t},this._notifySubscribers())})),i())||(r.push(n.onVolumeChange(e=>{this._voiceVolume=e,WP(this._voiceVolumeSubscribers,void 0,`Voice volume`)})),i()))return;r.push(n.onTranscript(e=>{this._handleVoiceTranscript(e)})),i()||this._onVoiceConnected()}catch(e){if(this._voiceSession===n&&this._voiceUnsubs===r){try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice rollback cleanup threw`,e)}t&&this._voiceSession===void 0&&this._onVoiceDisconnected()}else i();throw e}}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`){if(this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal){let t={id:DB(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{modality:`voice`,custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]};this._voiceMessages.push(t),this._commitVoiceMessage(t),this._markVoiceMessagesDirty(),this._notifySubscribers()}}else{let t=e.isFinal?{type:`complete`,reason:`stop`}:{type:`running`};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:DB(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],modality:`voice`,custom:{}},status:t,createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let n=this._voiceMessages.indexOf(this._currentAssistantMsg);if(n===-1)return;let r={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],status:t};this._voiceMessages[n]=r,this._currentAssistantMsg=r}e.isFinal&&(this._commitVoiceMessage(this._currentAssistantMsg),this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(e=!0){let t=this._voiceMessages.at(-1);if(t?.role===`assistant`&&t.status.type===`running`){let n=this._voiceMessages.length-1;this._voiceMessages[n]={...t,status:{type:`complete`,reason:`stop`}},this._commitVoiceMessage(this._voiceMessages[n]),this._currentAssistantMsg=null,this._markVoiceMessagesDirty(),e&&this._notifySubscribers()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;let t=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];let n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;let r=this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0;this._voiceMessages=[],this._markVoiceMessagesDirty();try{FI([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>WP(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this._notifySubscribers()])}finally{e&&n&&this._voiceSession===void 0&&this._onVoiceDisconnected()}}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(SH.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>WP([n],{},`Thread runtime "${e}"`))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&WP([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},BH=Symbol.for(`assistant-stream.tool-execution-id`),VH=e=>{try{return JSON.parse(e),!0}catch{return!1}},HH=e=>{try{return JSON.parse(e)}catch{return}},UH=(e,t)=>{let n=HH(e),r=HH(t);return n===void 0||r===void 0?!1:fR(n,r)},WH=e=>e[BH],GH=class{_getTools;_callbacks;_isClientToolCall;_entries=new Map;_humanInput=new Map;_executing=new Set;_discardedToolCallIds=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t,n){this._getTools=e,this._callbacks=t,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){let[e,t]=LR();this._controller=t;let n=Kz(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new BR).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(e){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),e?.discardPending)for(let[e,t]of this._entries)t.controller&&(t.argsComplete||t.hasResult||(this._discardedToolCallIds.add(e),t.skipExecute=!0));if(this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let t=new Set(this._executing);return new Promise(e=>{this._settledResolvers.push({executionIds:t,resolve:e})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=WH(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=WH(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._humanInput.get(e)?.executionId!==t&&this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=WH(e),r=this._entries.get(t);r&&r.executionId===n&&(r?.hasResult||r.skipExecute||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_warnProviderOwnedSkip(e,t){}_shouldCloseArgsStream({argsText:e,hasResult:t,clientOwned:n}){return t?!0:VH(e)?n||!this._isRunning:!1}_startActiveEntry(e,t,n,r){let i={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1,clientOwned:r};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)if(t.controller){if(!t.argsComplete&&!t.hasResult){this._entries.delete(e);continue}this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)UH(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(VH(e.argsText)&&VH(t.argsText)&&UH(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:e.clientOwned})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let{part:n}of DH(e)){let e=this._entries.get(n.toolCallId);if(t){e?.controller||this._entries.set(n.toolCallId,{toolName:n.toolName,argsText:n.argsText,hasResult:n.result!==void 0});continue}let r=e;if(n.result!==void 0&&this._discardedToolCallIds.delete(n.toolCallId),r&&!r.controller){if(r.hasResult||(n.argsText===r.argsText||VH(r.argsText)&&VH(n.argsText)&&UH(r.argsText,n.argsText))&&n.result===void 0)continue;this._entries.delete(n.toolCallId),r=void 0}if(!r){let e=this._isClientToolCall?.(n),t=n.result===void 0&&e===!1;t&&this._warnProviderOwnedSkip(n.toolName,n.toolCallId),r=this._startActiveEntry(n.toolCallId,n.toolName,n.result!==void 0||t||this._discardedToolCallIds.has(n.toolCallId),e===!0)}if(n.approval!==void 0&&(r.skipExecute=!0),this._processArgsText(r,n),n.result!==void 0&&!r.hasResult){let{controller:e}=r;if(!e)continue;r.hasResult=!0,r.argsComplete=!0,e.setResponse(new _R({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent===void 0?{}:{modelContent:n.modelContent}})),e.close()}}}},KH=Object.freeze([]),qH=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},JH=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,YH=class extends zH{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}suggestions=[];extras=void 0;_converter=new WB;_pendingDeleteEvictions=new Set;_optimistic=null;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;_toolStatuses=new Map;_effectiveIsRunning=!1;_inTrackerUpdate=!1;_pendingRunningRefresh=!1;_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){let e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?`runStart`:`runEnd`,{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){let t=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e;let r=this._getEffectiveIsRunning(e),i=e.unstable_messageRepositoryInstance,a=i!==void 0&&i!==this.repository;a&&(this.repository=i,this._pendingDeleteEvictions.clear()),n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let o=e.suggestions??KH;XF(this.suggestions,o)||(this.suggestions=o);let s={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};XF(this._capabilities,s)||(this._capabilities=s);let c;if(e.messageRepository){if(n&&!a&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository&&t===r){this._notifySubscribers();return}let i=e.messageRepository.messages,o=e.messageRepository.headId??i.at(-1)?.message.id??null;if(n&&!a&&n.messageRepository===e.messageRepository)this.repository.resetHead(o),c=this.repository.getMessages();else{let e=new Set(i.map(({message:e})=>e.id));for(let{message:e,parentId:t}of i)this.repository.addOrUpdateMessage(t,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(o),c=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new WB;else if(!a&&n.isRunning===e.isRunning&&n.messages===e.messages&&t===r){this._notifySubscribers();return}}c=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,i)=>{if(!e.convertMessage)return n;let a=i===(e.messages?.length??0)-1,o=`${EB}${i}`;if(t&&(t.role!==`assistant`||!BB(t.status)||t.status===UB(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return wB(e,n),e}return t}let s=e.convertMessage(n,i),c=AB(s,o,UB(s.content,a,r));return wB(c,n),c}):e.messages;let i=new Set,o=[];for(let e=c.length-1;e>=0;e--){let t=c[e];if(i.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}i.add(t.id),o.push(t)}o.length!==c.length&&(c=o.reverse());for(let e=0;e<c.length;e++){let t=c[e],n=c[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}if(this._pendingDeleteEvictions.size>0){let e=new Set(c.map(e=>e.id));for(let t of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(t),!e.has(t)){try{this.repository.getMessage(t)}catch{continue}this.repository.deleteMessage(t)}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);c.length>0&&this.ensureInitialized(),this._effectiveIsRunning=r,t!==r&&(r?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let l=null;if(JH(r,c)){let e=c.at(-1)?.id??null;this._optimistic?.parentId!==e&&(this._optimistic={id:DB(),parentId:e}),l=this._optimistic.id,this.repository.addOrUpdateMessage(e,AB({role:`assistant`,content:[],metadata:{isOptimistic:!0}},l,{type:`running`}))}l===null&&(this._optimistic=null),this.repository.resetHead(l??c.at(-1)?.id??null);let u=this.repository.getMessages();if((!this._messages||!GB(this._messages,u))&&(this._messages=u),this._voiceMessages.length>0){let e=new Set(this._messages.map(e=>e.id)),t=this._voiceMessages.filter(t=>!e.has(t.id));t.length!==this._voiceMessages.length&&(this._voiceMessages=t,this._markVoiceMessagesDirty())}a&&this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new GH(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;qH(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{this._store.setToolStatuses?.(Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}},e=>this._store.unstable_isClientToolCall?.(e)),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(let{part:e,messageId:t}of DH(this._messages))this._toolCallToMessageId.set(e.toolCallId,t);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t={...e,parentId:this._resolveAppendParent(e.parentId)};if(this.voice)throw Error(`Cannot send a text message while a voice session is connected`);if(this._isVoiceMessage(t.sourceId))throw Error(`Voice transcript messages cannot be edited`);let n=t.sourceId!=null||t.parentId!==(this._getBaseMessages().at(-1)?.id??null);t=!n&&this._store.queue&&this._store.queue===this._transformedQueue?t:this.enrichAppendMetadata(t);let r=dH(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!n&&this._store.queue){if(i&&await i,!fH(this,r))return;t.steer??this._getEffectiveIsRunning(this._store)?this._store.queue.steer(t):this._store.queue.enqueue(t);return}if(i?.catch(()=>{}),(t.startRun??t.role===`user`)&&await this._toolInvocations?.abort({discardPending:!0}),fH(this,r)){if(n){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._pendingDeleteEvictions.clear(),await this._store.onEdit(t)}else await this._store.onNew(t)}}_commitVoiceMessage(e){this._store.onVoiceTranscript?.(e)}async deleteMessage(e){if(this._store.onDelete){this.repository.getMessages().some(t=>t.id===e)&&this._pendingDeleteEvictions.add(e);try{await this._store.onDelete(e)}catch(t){throw this._pendingDeleteEvictions.delete(e),t}return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._getEffectiveIsRunning(this._store)&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this._pendingDeleteEvictions.clear(),this.updateMessages(t.filter(t=>t.id!==e)),this._evictDeletedMessage(e)}_evictDeletedMessage(e){if(!e.startsWith(`__external_store_fallback_`)){try{this.repository.getMessage(e)}catch{return}this.repository.deleteMessage(e),this._publishRepositoryMessages()}}_publishRepositoryMessages(){let e=this.repository.getMessages();GB(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){return this._store?.queue?.items??EH}getSteerQueueItems(){return this._store?.queue?.steerItems??EH}moveQueueItem(e,t){this._store?.queue?.move(e,t)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);this._pendingDeleteEvictions.clear(),await this._toolInvocations?.abort({discardPending:!0}),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.queue?.__internal_notifyCancelled?.()}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);let e=dH(this);this._toolInvocations?.abort({discardPending:!0}),this._store.queue?.__internal_notifyCancelled?.(),qH(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let t=this.repository.getMessages(),n=t[t.length-1],r=this._store.setMessages!==void 0&&n?.role===`user`&&n.id===t.at(-1)?.id&&n.content.every(e=>e.type===`text`)?n:void 0,i;if(r){let e={text:zV(r),attachments:r.attachments,quote:r.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(r.id),i={id:r.id,draft:e})}this._publishRepositoryMessages(),setTimeout(()=>{if(fH(this,e)){if(this.dropEmptyOptimisticHead(),i){let e=this.repository.getMessages();e.at(-1)?.id===i.id?this.repository.deleteMessage(i.id):e.some(e=>e.id===i.id)&&this.composer.retractDraft(i.draft)}this._publishRepositoryMessages(),this.updateMessages(this._messages)}},0)}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);qH(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);let t=this.messages.findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId)),n=t?.content.find(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId);try{return Promise.resolve(this._store.onRespondToToolApproval(e)).then(()=>{t&&n?.type===`tool-call`&&this._notifyToolApprovalAnswered(t.id,n.toolCallId,n.toolName,e.approved)})}catch(e){return Promise.reject(e)}}reset(e){let t=new TH;t.import(SH.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(TB))}},XH=e=>e.adapters?.threadList??{},ZH=class extends mH{threads;constructor(e){super(),this.threads=new xH(XH(e),()=>new YH(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(XH(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},QH=e=>{let t=J(21),{modelContext:n,feedback:r}=vB()??{},i;bb0:{if(!r||e.adapters?.feedback){i=e;break bb0}let n;t[0]!==r||t[1]!==e.adapters?(n={...e.adapters,feedback:r},t[0]=r,t[1]=e.adapters,t[2]=n):n=t[2];let a;t[3]!==e||t[4]!==n?(a={...e,adapters:n},t[3]=e,t[4]=n,t[5]=a):a=t[5],i=a}let a=i,o;t[6]===a?o=t[7]:(o=()=>new ZH(a),t[6]=a,t[7]=o);let[s]=EN(o),c;t[8]===s.threads?c=t[9]:(c=()=>()=>{pH(s.threads.getMainThreadRuntimeCore())},t[8]=s.threads,t[9]=c);let l;t[10]===s?l=t[11]:(l=[s],t[10]=s,t[11]=l),X(c,l);let u;t[12]!==a||t[13]!==s?(u=()=>{s.setAdapter(a)},t[12]=a,t[13]=s,t[14]=u):u=t[14],X(u);let d,f;t[15]!==n||t[16]!==s?(d=()=>{if(n)return s.registerModelContextProvider(n)},f=[n,s],t[15]=n,t[16]=s,t[17]=d,t[18]=f):(d=t[17],f=t[18]),X(d,f);let p;return t[19]===s?p=t[20]:(p=new lH(s),t[19]=s,t[20]=p),p},$H=e=>e.status?.type!==`running`,eU=async(e,t)=>{let n=Cz.fromAssistantStream(e);for await(let e of n){let n=e.parts.filter(e=>e.type===`text`)[0]?.text;n?.trim()&&await t(n)}},tU=(e,t)=>{let n=()=>void t.generateTitle({automatic:!0}).catch(e=>{sL(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some($H);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},nU=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=kN(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=Y(!1);c.current||s(),X(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=Y(void 0),u=Y(!1),d=Y(void 0),f=Y(!1),p=jN(()=>{if(u.current||i.getState().status!==`new`)return;u.current=!0;let e=i.initialize();l.current=e,e.then(()=>{f.current&&(d.current?.(),d.current=tU(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=jN(()=>(p(),l.current));return X(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),X(()=>{if(!a?.threads?.main)return;u.current=!1,f.current=!0;let e=a.threads.main.unstable_on(`initialize`,p);return()=>{f.current=!1,e(),d.current?.(),d.current=void 0}},[a]),a},rU=GN(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s})=>{let c=ON(()=>new rH(new VI({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:PI},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:l}=vI(i,{threadListItem:UL({runtime:c})});return BF(s,function(){return vF(l,function(){return _B(a,function(){return nU({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:c})})})})}),iU=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],aU=e=>{let t=J(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),AN(r,i),null},oU=class extends RI{runtimeHook;adapterStore=new zI({defaultAdapters:null,threadAdapters:new Map});hostStore=new zI({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);return t?(t.runtime&&pH(t.runtime),t.unsubscribeRunning?.(),t.unsubscribeRunning=void 0,t.destroy.abort(),t.destroy=new AbortController,t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime;r.runtime=t,r.publishedGeneration=n,i!==t&&this._trackRunning(e,r),this._notifySubscribers(),i!==void 0&&i!==t&&FI(this.replacedSubscribers)}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){t.unsubscribeRunning?.();let n=t.runtime;if(!n){t.unsubscribeRunning=void 0,this._setRunning(t,!1);return}this._setRunning(t,ZV(n));let r=[n.subscribe(()=>{this._setRunning(t,ZV(n))}),...iU.map(t=>n.unstable_on(t,()=>{WP(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>{for(let e of r)e()}}_setRunning(e,t){e.isRunning!==t&&(e.isRunning=t,FI(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&pH(t.runtime),t?.unsubscribeRunning?.(),t?.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState();this.hostStore.setState({...t,hookEpoch:t.hookEpoch+1})}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e})}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r})}__internal_dispose(){for(let e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){let e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t,destroy:n}])=>({id:e,generation:t,destroySignal:n.signal}))})}_threadElements(e,{threads:t,hookEpoch:n},r){let i=this.runtimeHook;return t.map(({id:t,generation:a,destroySignal:o})=>{let s=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return KN(`${t}:${a}:${n}`,rU({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:s,publish:this._publish,destroySignal:o}))})}__internal_useHost(e){let t=aL(this.hostStore),n=aL(this.adapterStore);return LP(this._threadElements(e,t,n))}__internal_RenderThreadRuntimes=({provider:e})=>(aL(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,b.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>{let t=aL(this.hostStore),n=aL(this.adapterStore),r=this._threadElements(e,t,n),{effects:i}=zP(function(){return LP(r)});return AN(i),null};_OuterActiveThreadProvider=LN(({threadId:e,provider:t})=>{let n=ON(()=>new cH(this.parent).getItemById(e),[e]),r=Y(!1);return X(()=>{},[t]),(0,b.jsx)(lV,{runtime:n,children:(0,b.jsx)(t,{children:(0,b.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=vB();return this.pendingThreadAdapters.set(e,n),AN(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,b.jsx)(aU,{detectorRef:t})}};function sU(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var cU=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),lU=class extends RI{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>cU(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=cU(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},uU=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),dU=new class extends tH{get error(){return uU}messages=[];composer=eH(uU,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(uU)}};function fU(e){return e}var pU=`__LOCALID_`,mU=e=>e||void 0,hU=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=OM(t.threadIdMap),a=OM(t.threadData),o=new Set([...n,...r]);for(let t of e){switch(t.status){case`regular`:case`archived`:break;default:{let e=t.status;throw Error(`Unsupported state: ${e}`)}}let e=i[t.remoteId],s=e===void 0?void 0:a[e],c=s?.id??t.remoteId,l=e??fU(c),u=s!==void 0&&s.status!==`new`?s.initializeTask:void 0;o.has(c)?s!==void 0&&s.status!==t.status&&(t.status===`regular`?(r=r.filter(e=>e!==c),n.push(c)):(n=n.filter(e=>e!==c),r.push(c))):(o.add(c),t.status===`regular`?n.push(c):r.push(c)),i[c]=l,i[t.remoteId]=l,a[l]={...s?.localOrigin===!0?{localOrigin:!0}:{},id:c,remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,initializeTask:u??Promise.resolve({remoteId:t.remoteId,externalId:t.externalId})}}return{threadIds:n,archivedThreadIds:r,threadIdMap:i,threadData:a}},gU=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:OM(),threadData:OM()}),_U=e=>{let t;do t=`${pU}${DB()}`;while(e.threadIdMap[t]);let n=fU(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:OM(e.threadIdMap,{[t]:n}),threadData:OM(e.threadData,{[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},vU=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);(e===void 0||e===`new`)&&(e!==void 0||t.localOrigin===!0)&&(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?2**53-1:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),{...e,threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]}},yU=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),bU=(e,t)=>{let n=Object.hasOwn(e.threadIdMap,t)?e.threadIdMap[t]:void 0;if(n!==void 0)return Object.hasOwn(e.threadData,n)?e.threadData[n]:void 0},xU=(e,t,n,r,i)=>{let a=fU(t),o=Object.hasOwn(e.threadData,a)?e.threadData[a]:void 0;if(!o)return{state:e,removedMappingId:void 0,survivorMappingId:a};let s=Object.hasOwn(e.threadIdMap,n)?e.threadIdMap[n]:void 0,c=s!==void 0&&s!==a&&Object.hasOwn(e.threadData,s)?e.threadData[s]:void 0,l=s!==void 0&&c!==void 0?{mappingId:s,data:c}:void 0,u=i!==void 0&&Object.hasOwn(e.threadIdMap,i)?e.threadIdMap[i]:void 0,d=l!==void 0&&u===l.mappingId?l.mappingId:a,f=l===void 0?void 0:d===a?l.mappingId:a,p=r??l?.data.externalId,m=OM(e.threadData);f!==void 0&&delete m[f];let h={...o,id:d,initializeTask:Promise.resolve({remoteId:n,externalId:p}),remoteId:n,externalId:p};m[d]={...l?.data,...h,title:o.title??l?.data.title,lastMessageAt:(`lastMessageAt`in o?o.lastMessageAt:void 0)??(l&&`lastMessageAt`in l.data?l.data.lastMessageAt:void 0),custom:o.custom??l?.data.custom};let g=OM(e.threadIdMap);if(f!==void 0)for(let[e,t]of Object.entries(g))t===f&&(g[e]=d);g[t]=d,g[n]=d;let _=e=>l===void 0?e:e.filter(e=>e!==l.data.id).map(e=>e===o.id?d:e);return{state:{...e,threadIds:_(e.threadIds),archivedThreadIds:_(e.archivedThreadIds),threadIdMap:g,threadData:m},removedMappingId:f,survivorMappingId:d}},SU=(e,t,n,r)=>{let i=bU(e,t);if(!i)return e;let{id:a,status:o}=i;if(o===n)return e;let s;if(n!==`deleted`){if(i.status===`new`){if(r===void 0)return e;s={...i,initializeTask:r,status:n}}else s={...i,status:n}}let c={...e};switch(o){case`new`:c.newThreadId=void 0;break;case`regular`:c.threadIds=c.threadIds.filter(e=>e!==a);break;case`archived`:c.archivedThreadIds=c.archivedThreadIds.filter(e=>e!==a);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:c.threadIds=[a,...c.threadIds];break;case`archived`:c.archivedThreadIds=[a,...c.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t],r=OM(c.threadData);delete r[n],c.threadData=r;let i=OM(c.threadIdMap);for(let[e,t]of Object.entries(i))t===n&&delete i[e];c.threadIdMap=i;break}default:throw Error(`Unsupported state: ${n}`)}return s!==void 0&&(c.threadData={...c.threadData,[a]:s}),c},CU=(e,t,n)=>SU(e,t,n,void 0),wU=(e,t,n)=>SU(e,t,`regular`,n),TU=class extends Error{[oL]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}};function EU(e,t){let n=e.get(t);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualTitle:void 0,latestExplicit:null,nextOrder:0},e.set(t,n)),n}function DU(e,t,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualTitle===void 0&&e.get(t)===n&&e.delete(t)}function OU(e,t){return!t.superseded&&(e.latestExplicit?.order??0)<=t.order}function kU(e,t){return(e.latestExplicit?.order??0)<t.order}function AU(e,t,n){let r=EU(e,t),i,a=new Promise(e=>{i=e}),o={title:n,order:++r.nextOrder,settled:a,settle:i};r.pendingClaim=o,r.inFlightClaims.add(o);for(let e of r.generations)e.order<o.order&&(e.claim=o);return o}function jU(e,t,n,r){n.settle(r);let i=e.get(t);i!==void 0&&(i.inFlightClaims.delete(n),i.pendingClaim===n&&(i.pendingClaim=null,r&&(i.manualTitle=n.title)),DU(e,t,i))}function MU(e,t,n){let r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,DU(e,t,n),r}function NU(e,t){e.delete(t)}function PU(e,t,n){let r=EU(e,t);if(n&&r.pendingClaim===null&&MU(e,t,r)!==void 0)return null;let i,a=new Promise(e=>{i=e}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,beforeGenerationClaims:n?[]:[...r.inFlightClaims],superseded:!1,persisted:a,settlePersisted:i};if(!n){r.pendingClaim=null,r.manualTitle=void 0,r.latestExplicit=o;for(let e of r.generations)e.automatic&&(e.superseded=!0)}return r.generations.add(o),o}async function FU({states:e,threadId:t,automatic:n,generate:r,rename:i,applyTitle:a}){let o=EU(e,t),s=PU(e,t,n);if(s===null)return;let c,l=s.order,u=async e=>{let t=await e.settled;if(s.claim===e)return t||(s.claim=null,o.pendingClaim===e&&(o.pendingClaim=null)),t},d=()=>n&&MU(e,t,o)!==void 0,f=async()=>{if(c!==void 0)for(;;){let e=s.claim;if(e!==null&&e.order>l&&kU(o,e)){await u(e)===!0&&(c=e.title,l=e.order,await i(e.title));continue}let t=o.latestExplicit;if(t===null||t.order<=l)return;let n=await t.persisted;if(o.latestExplicit===t){if(l=t.order,n===void 0||n===c)return;c=n,await i(n)}}},p=async()=>{if(s.beforeGenerationClaims.length>0&&await Promise.all(s.beforeGenerationClaims.map(e=>e.settled)),s.claim!==null){let e=await u(s.claim);if(e===!0){s.superseded=!0;return}if(e===!1&&d())return}if(!OU(o,s))return;let e=!1,t;for(await r(async n=>{e=!0,t=n,n!==void 0&&(c=n);let r=s.claim;if(r!==null){if(await u(r)!==!1)return;if(d()){s.superseded=!0;return}}OU(o,s)&&await a(t)});;){let n=s.claim;if(n===null)return;let r=await u(n);if(r!==void 0){if(r===!1){if(d())return;e&&OU(o,s)&&await a(t);return}if(!kU(o,n))return;if(await i(n.title),c=n.title,l=n.order,s.claim===n){if(!OU(o,s))return;await a(n.title),s.superseded=!0;return}}}};try{await p(),await f()}finally{s.settlePersisted(c),o.generations.delete(s),DU(e,t,o)}}var IU=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),LU=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),RU=gU(),zU=class extends RI{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_titleStates=new Map;_mainThreadId;_state=new lU(RU);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,b.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=bB(e());return n==null?t:(0,b.jsx)(nH,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?RN:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=yU(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>e===this._loadGeneration?{...t,isLoading:!0,loadError:void 0}:t,then:(r,i)=>{if(e!==this._loadGeneration)return r;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads({...r,loadError:void 0},i.threads,mU(i.nextCursor));let a=hU(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return vU({...r,isLoading:!1,loadError:void 0,cursor:mU(i.nextCursor),threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadIdMap:a.threadIdMap,threadData:a.threadData},r,n)}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1,loadError:n});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads({...this._state.baseValue,loadError:n},[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?{...e,isLoadingMore:!0}:e,then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=hU(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:mU(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new oU(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new zI(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;providerStore;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0}),this._titleStates.clear()),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new TU}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new TU}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,n=t&&Object.hasOwn(e.threadData,t)?e.threadData[t]:void 0;n?.status===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i)for(let t of Object.values(e.threadData))i.has(t.id)||(t.status===`new`||t.remoteId!==void 0)&&r.push(t);this._staleThreadIdsOnReplace=void 0;let a={threadIds:[],archivedThreadIds:[],threadIdMap:OM(),threadData:OM()};for(let e of r){let t=fU(e.id);Object.hasOwn(a.threadData,t)||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=hU(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=fU(e.id),n=Object.hasOwn(l,t)?l[t]:void 0;n!==void 0&&(n.status===`regular`&&!o.includes(n.id)?o.push(n.id):n.status===`archived`&&!s.includes(n.id)&&s.push(n.id))}let u={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(c,e.newThreadId)?void 0:e.newThreadId};if(bU(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=_U(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))d.has(t.id)||this._hookManager.stopThreadRuntime(t.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get loadError(){return this._state.value.loadError}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return bU(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&sU(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||dU}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw IU(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return bU(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new TU;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=fU(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw IU(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n!==this._switchGeneration)return;let o=this.getItemById(i.id);o?.id===i.id&&(o.status===`archived`&&t?.unarchive!==!1&&(await o.initializeTask,n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)||o.status===`archived`&&(await this.unarchive(o.id),n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)))||(this._mainThreadId=o.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?this._startSwitchToNewThread(!1):this._startSwitchToThread(e,void 0,!1)}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=_U(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw IU(e,`initializing it`);if(t.status===`new`)throw LU(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}this._requireAdapterGeneration(n);let r=t.initialize(e),i,{remoteId:a,externalId:o}=await this._state.optimisticUpdate({execute:()=>r,optimistic:t=>wU(t,e,r),then:(t,{remoteId:r,externalId:a})=>{if(n!==this._adapterGeneration)return t;let o=xU(t,e,r,a,e);return i=o.removedMappingId,i===this._mainThreadId&&(this._mainThreadId=o.survivorMappingId),o.state}});return this._requireAdapterGeneration(n),i!==void 0&&this._hookManager.stopThreadRuntime(i),{remoteId:a,externalId:o}};generateTitle=async(e,t)=>{this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw IU(e,`generating its title`);if(i.status===`new`)throw LU(e,i.status,`generate a title`);let{remoteId:a}=await i.initializeTask;this._requireAdapterGeneration(r);let o=this._hookManager.getThreadRuntimeCore(i.id);if(!o)return;let s=o.messages.filter($H);await FU({states:this._titleStates,threadId:i.id,automatic:t?.automatic===!0,generate:async e=>{let t=await n.generateTitle(a,s);this._requireAdapterGeneration(r),await eU(t,e)},rename:async e=>{this._requireAdapterGeneration(r),await n.rename(a,e)},applyTitle:async e=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:t=>{if(r!==this._adapterGeneration)return t;let n=bU(t,i.id);return n?{...t,threadData:{...t.threadData,[n.id]:{...n,title:e}}}:t}})}})};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw IU(e,`renaming it`);if(i.status===`new`)throw LU(e,i.status,`be renamed`);let a=AU(this._titleStates,i.id,t);try{let o=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=bU(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}});return jU(this._titleStates,i.id,a,!0),o}catch(e){throw jU(this._titleStates,i.id,a,!1),e}}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw IU(e,`updating its custom metadata`);if(i.status===`new`)throw LU(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=bU(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){let e=this._switchTask,n=!e||e===t;n&&(e=this.switchToNewThread()),t=e;try{await e}catch(t){if(n&&this._switchTask===e)throw t}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw IU(e,`archiving it`);if(r.status!==`regular`)throw LU(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>CU(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw IU(e,`unarchiving it`);if(r.status!==`archived`)throw LU(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>CU(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw IU(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw LU(e,r.status,`be deleted`);await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n);let i=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>CU(e,r.id,`deleted`)});return this._hookManager.stopThreadRuntime(r.id),NU(this._titleStates,r.id),i}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw IU(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw LU(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new zI([]);__internal_RenderComponent=()=>{let e=FN();X(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=aL(this.boundIdsStore),n=aL(this.providerStore),r=Q();return(t.length===0||t[0]===e)&&(0,b.jsxs)(nH,{adapters:this._runtimeAdapters,children:[(0,b.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,b.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},BU=class extends mH{threads;constructor(e){super(),this.threads=new zU(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},VU=e=>{let t=J(18),n;t[0]===e?n=t[1]:(n=()=>new BU(e),t[0]=e,t[1]=n);let[r]=EN(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>queueMicrotask(()=>r.threads.__internal_dispose()),t[2]=r.threads,t[3]=i);let a;t[4]===r?a=t[5]:(a=[r],t[4]=r,t[5]=a),PN(i,a);let o;t[6]!==e||t[7]!==r.threads?(o=()=>{r.threads.__internal_setOptions(e),r.threads.__internal_load()},t[6]=e,t[7]=r.threads,t[8]=o):o=t[8];let s;t[9]!==e||t[10]!==r?(s=[r,e],t[9]=e,t[10]=r,t[11]=s):s=t[11],X(o,s);let c;t[12]===r.threads?c=t[13]:(c=()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{r.threads.loadError!==void 0&&r.threads.reload()},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},t[12]=r.threads,t[13]=c);let l;t[14]===r?l=t[15]:(l=[r],t[14]=r,t[15]=l),X(c,l);let u;return t[16]===r?u=t[17]:(u=new lH(r),t[16]=r,t[17]=u),u},HU=e=>{let[t]=EN(()=>new zI(e.runtimeHook));AN(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=Y(e.initialThreadId),r=kN(function(){return aL({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()},[t]),i=jN(t=>e.onThreadIdChange?.(t)),a=ON(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(Q().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return VU(a)},UU=e=>{let t=J(6),{id:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=GP({message:TI({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:TI({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,b.jsx)($L,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},WU=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,GU=()=>null,KU=new WeakMap,qU=(e,t)=>{let n=KU.get(e);return n||(n=new Set(e.map(e=>e.id)),KU.set(e,n)),n.has(t)},JU=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message??GU:e.SystemMessage??e.Message??GU;default:throw Error(`Unknown message role: ${t}`)}},YU=e=>{let t=J(6),{components:n}=e,r=$(tW),i=$(nW),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=JU(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,b.jsx)(o,{}),t[4]=o,t[5]=s),s},XU=LN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(YU,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(uV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&WU(e.components,t.components));XU.displayName=`ThreadPrimitive.MessageByIndex`;var ZU=LN(e=>{let t=J(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>qU(e.thread.messages,n),t[0]=n,t[1]=i),!$(i))return null;let a;t[2]===r?a=t[3]:(a=(0,b.jsx)(YU,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,b.jsx)(UU,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&WU(e.components,t.components));ZU.displayName=`ThreadPrimitive.Unstable_MessageById`;var QU=({children:e})=>{let t=$(QF(e=>e.thread.messages.map(e=>e.id)));return ON(()=>t.length===0?null:t.map((t,n)=>(0,b.jsx)(uV,{index:n,children:(0,b.jsx)(nR,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},t)),[t,e])},$U=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(QU,{children:()=>(0,b.jsx)(YU,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(QU,{children:r}),t[2]=r,t[3]=i),i};$U.displayName=`ThreadPrimitive.Messages`;var eW=LN($U,(e,t)=>e.children||t.children?e.children===t.children:WU(e.components,t.components));function tW(e){return e.message.role}function nW(e){return e.message.composer.isEditing}var rW=e=>{let t=e.message.metadata;if(t&&typeof t==`object`)return t.custom?.quote},iW=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},aW=e=>typeof e==`object`&&!!e,oW=e=>e==null?[]:Array.isArray(e)?e:[e],sW=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!aW(e)||!(`component`in e)||typeof e.component!=`string`)return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,b.jsx)(n,{component:i,props:a},s??r);throw new iW(i)}return zN(c,{...a??{},key:s??r},...oW(o).map((e,i)=>sW(e,t,n,`${r}/${i}`)))},cW=e=>{let t=J(11),{spec:n,components:r,Fallback:i}=e,a=n?.root,o;t[0]===a?o=t[1]:(o=oW(a),t[0]=a,t[1]=o);let s=o,c;if(t[2]!==i||t[3]!==r||t[4]!==s){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>sW(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],c=s.map(e),t[2]=i,t[3]=r,t[4]=s,t[5]=c}else c=t[5];let l;return t[9]===c?l=t[10]:(l=(0,b.jsx)(b.Fragment,{children:c}),t[9]=c,t[10]=l),l};cW.displayName=`GenerativeUIRender`;var lW=e=>{let t=J(4),{components:n,spec:r,Fallback:i}=e,a=$(uW),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,b.jsx)(cW,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};lW.displayName=`MessagePrimitive.GenerativeUI`;function uW(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var dW=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},fW=(e,t,n)=>{let r=[];if(t){let t=dW(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=dW(`toolGroup`),n=dW(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},pW=e=>{let t=J(10),n=$(QF(LW)),r=$(QF(zW)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=fW(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},mW=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},hW=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),gW=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>hW(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},_W={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},vW=e=>{let t=J(41),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?_W.Text:i,m=a===void 0?_W.Reasoning:a,h=o===void 0?_W.Image:o,g=s===void 0?_W.Source:s,_=c===void 0?_W.File:c,v=l===void 0?_W.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let x=y,S=Q(),C=$(BW),w=C.type;if(w===`tool-call`){let e=S.part.addToolResult,n=S.part.resumeToolCall,r=S.part.respondToToolApproval;if(`Override`in x){let i;return t[4]!==e||t[5]!==C||t[6]!==r||t[7]!==n||t[8]!==x.Override?(i=(0,b.jsx)(x.Override,{...C,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=C,t[6]=r,t[7]=n,t[8]=x.Override,t[9]=i):i=t[9],i}let i=x.by_name?.[C.toolName]??x.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==C||t[13]!==r||t[14]!==n?(a=(0,b.jsx)(mW,{...C,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=C,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(C.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(w){case`text`:{let e;return t[16]!==p||t[17]!==C?(e=(0,b.jsx)(p,{...C}),t[16]=p,t[17]=C,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==m||t[20]!==C?(e=(0,b.jsx)(m,{...C}),t[19]=m,t[20]=C,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==g||t[23]!==C?(e=(0,b.jsx)(g,{...C}),t[22]=g,t[23]=C,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==h||t[26]!==C?(e=(0,b.jsx)(h,{...C}),t[25]=h,t[26]=C,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==_||t[29]!==C?(e=(0,b.jsx)(_,{...C}),t[28]=_,t[29]=C,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==v||t[32]!==C?(e=(0,b.jsx)(v,{...C}),t[31]=v,t[32]=C,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[C.name]??d?.Fallback,n;return t[34]!==e||t[35]!==C?(n=(0,b.jsx)(gW,{...C,Fallback:e}),t[34]=e,t[35]=C,t[36]=n):n=t[36],n}case`generative-ui`:{if(!f?.components)return null;let e=C,n;return t[37]!==f.Fallback||t[38]!==f.components||t[39]!==e.spec?(n=(0,b.jsx)(cW,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[37]=f.Fallback,t[38]=f.components,t[39]=e.spec,t[40]=n):n=t[40],n}default:return console.warn(`Unknown message part type: ${w}`),null}},yW=LN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(vW,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(dV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);yW.displayName=`MessagePrimitive.PartByIndex`;var bW=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,b.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,b.jsx)(pV,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},xW=Object.freeze({type:`complete`}),SW=Object.freeze({type:`running`}),CW=LN(e=>{let t=J(6),{components:n}=e,r=$(VW);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,b.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??_W.Text,a;return t[3]!==r||t[4]!==i?(a=(0,b.jsx)(bW,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),wW=LN(e=>{let t=J(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!$(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,b.jsx)(CW,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),TW=LN(e=>{let t=J(4),{Quote:n}=e,r=$(rW);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,b.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function EW(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(VV(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var DW=()=>{let e=J(6),t=Q(),n=$(HW),r=$(UW);if(!r||n.type!==`tool-call`)return null;let i;return e[0]!==r||e[1]!==t.part.addToolResult||e[2]!==t.part.respondToToolApproval||e[3]!==t.part.resumeToolCall||e[4]!==n?(i=(0,b.jsx)(r,{...n,addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval}),e[0]=r,e[1]=t.part.addToolResult,e[2]=t.part.respondToToolApproval,e[3]=t.part.resumeToolCall,e[4]=n,e[5]=i):i=e[5],i},OW=()=>{let e=J(3),t=$(WW),n=$(GW);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,b.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},kW=()=>{let e=J(2),t=$(KW);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,b.jsx)(DW,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,b.jsx)(OW,{}),e[1]=t):t=e[1],t}return null},AW=Object.freeze({type:`text`,text:``,status:SW}),jW=({children:e})=>{let t=Q(),n=$(e=>e.dataRenderers);return(0,b.jsx)(nR,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=EW(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,b.jsx)(DW,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=hW(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,b.jsx)(OW,{}):null}}return e}})})},MW=e=>{let t=J(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(jW,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(dV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},NW=e=>{let t=J(9),{children:n}=e,r=$(qW),i=$(JW),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:AW}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,b.jsx)(pV,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,b.jsx)(MW,{index:t,children:e=>n(e)??(0,b.jsx)(kW,{})},t),t[7]=n,t[8]=e),o=(0,b.jsx)(b.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},PW=e=>{let t=J(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,b.jsx)(NW,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,b.jsx)(FW,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};PW.displayName=`MessagePrimitive.Parts`;var FW=e=>{let t=J(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=$(YW),{ranges:a,partIds:o}=pW(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,b.jsx)(CW,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,b.jsx)(yW,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,b.jsx)(bV,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,b.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}if(e.type===`toolGroup`){let t=n?.ToolGroup??_W.ToolGroup;return(0,b.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,b.jsx)(yW,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??_W.ReasoningGroup;return(0,b.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,b.jsx)(yW,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,b.jsx)(TW,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,b.jsx)(wW,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,b.jsxs)(b.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function IW(e){return e.type}function LW(e){return e.message.parts.map(IW)}function RW(e){return e.type===`tool-call`?e.toolCallId:void 0}function zW(e){return e.message.parts.map(RW)}function BW(e){return e.part}function VW(e){return e.message.status??xW}function HW(e){return e.part}function UW(e){return e.part.type===`tool-call`?EW(e.tools,e.part):null}function WW(e){return e.part}function GW(e){return e.part.type===`data`?hW(e.dataRenderers,e.part.name,void 0)??null:null}function KW(e){return e.part.type}function qW(e){return e.message.parts.length}function JW(e){return(e.message.status?.type??`complete`)===`running`}function YW(e){return e.message.parts.length}var XW=Symbol.for(`@assistant-ui/groupBy.memoKey`),ZW=e=>{let t=e,n=((e,n)=>{if(e.type===`tool-call`){if((VV(e.mcp?.app?.resourceUri)||(n?.toolUIs?.[e.toolName]?.[0]?.standalone??!1))&&t[`standalone-tool-call`]!==void 0)return t[`standalone-tool-call`];let r=t[`tool-call:${e.toolName}`];return r===void 0?t[`tool-call`]??[]:r}return t[e.type]??[]}),r=Object.keys(e).sort().map(t=>[t,e[t]]);return n[XW]=`groupPartByType:${JSON.stringify(r)}`,n},QW=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},$W=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},eG=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:$W(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:QW(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:QW(s),idKey:$W(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},tG=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},nG=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},rG=(e,t,n)=>{if(e.type===`part`)return(0,b.jsx)(MW,{index:e.index,children:({part:e})=>n({part:e,children:(0,b.jsx)(nG,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let{status:r,counts:i}=vV(t,e.indices),a={type:e.key,status:r,counts:i,indices:e.indices};return(0,b.jsx)(RN,{children:n({part:a,children:(0,b.jsx)(b.Fragment,{children:e.children.map(e=>rG(e,t,n))})})},e.idKey??e.nodeKey)},iG=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=$(QF(e=>e.message.parts)),i=$(e=>e.tools.toolUIs),a=$(e=>t!==`never`&&e.message.status?.type===`running`),o=ON(()=>{let t={toolUIs:i};return eG(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[XW]??e,i]);return(0,b.jsxs)(b.Fragment,{children:[o.map(e=>rG(e,r,n)),tG(t,r,a)&&n({part:{type:`indicator`},children:(0,b.jsx)(nG,{})})]})};iG.displayName=`MessagePrimitive.GroupedParts`;var aG=LN(e=>{let t=J(5),{children:n}=e,r=$(rW);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,b.jsx)(b.Fragment,{children:i}),t[3]=i,t[4]=a),a});aG.displayName=`MessagePrimitive.Quote`;var oG=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},sG=e=>{let t=J(5),{components:n}=e,r=$(dG);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=oG(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,b.jsx)(o,{}),t[3]=o,t[4]=s),s},cG=LN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(sG,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(sV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);cG.displayName=`MessagePrimitive.AttachmentByIndex`;var lG=({children:e})=>{let t=$(QF(e=>e.message.role===`user`?(e.message.attachments??[]).map(e=>e.id):[]));return ON(()=>t.map((t,n)=>(0,b.jsx)(sV,{index:n,children:(0,b.jsx)(nR,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},uG=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(lG,{children:e=>{let{attachment:t}=e,r=oG(n,t);return r?(0,b.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(lG,{children:r}),t[2]=r,t[3]=i),i};uG.displayName=`MessagePrimitive.Attachments`;function dG(e){return e.attachment}var fG=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},pG=e=>{let t=J(5),{components:n}=e,r=$(_G);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=fG(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,b.jsx)(a,{}),t[3]=a,t[4]=o),o},mG=LN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(pG,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(cV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);mG.displayName=`ComposerPrimitive.AttachmentByIndex`;var hG=({children:e})=>{let t=$(QF(e=>e.composer.attachments.map(e=>e.id)));return ON(()=>t.map((t,n)=>(0,b.jsx)(cV,{index:n,children:(0,b.jsx)(nR,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},gG=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(hG,{children:e=>{let{attachment:t}=e,r=fG(n,t);return r?(0,b.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(hG,{children:r}),t[2]=r,t[3]=i),i};gG.displayName=`ComposerPrimitive.Attachments`;function _G(e){return e.attachment}var vG=LN(({children:e})=>{let t=$(QF(e=>e.composer.queue.map(e=>e.id)));return ON(()=>t.map((t,n)=>(0,b.jsx)(wV,{index:n,children:(0,b.jsx)(nR,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});vG.displayName=`ComposerPrimitive.Queue`;var yG=LN(e=>{let t=J(6),{index:n,archived:r,components:i}=e,a=r!==void 0&&r,o=i.ThreadListItem,s;t[0]===o?s=t[1]:(s=(0,b.jsx)(o,{}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==n||t[4]!==s?(c=(0,b.jsx)(SV,{index:n,archived:a,children:s}),t[2]=a,t[3]=n,t[4]=s,t[5]=c):c=t[5],c},(e,t)=>e.index===t.index&&e.archived===t.archived&&e.components.ThreadListItem===t.components.ThreadListItem);yG.displayName=`ThreadListPrimitive.ItemByIndex`;var bG=({archived:e,children:t})=>{let n=$(QF(t=>e?t.threads.archivedThreadIds:t.threads.threadIds));return ON(()=>n.map((n,r)=>(0,b.jsx)(SV,{index:r,archived:e,children:(0,b.jsx)(nR,{getItemState:t=>t.threads.item({index:r,archived:e}).getState(),children:e=>t({get threadListItem(){return e()}})})},n)),[n,e,t])},xG=e=>{let t=J(8),{archived:n,components:r,children:i}=e,a=n!==void 0&&n;if(r){let e=r.ThreadListItem,n;t[0]===e?n=t[1]:(n=()=>(0,b.jsx)(e,{}),t[0]=e,t[1]=n);let i;return t[2]!==a||t[3]!==n?(i=(0,b.jsx)(bG,{archived:a,children:n}),t[2]=a,t[3]=n,t[4]=i):i=t[4],i}let o;return t[5]!==a||t[6]!==i?(o=(0,b.jsx)(bG,{archived:a,children:i}),t[5]=a,t[6]=i,t[7]=o):o=t[7],o};xG.displayName=`ThreadListPrimitive.Items`;var SG=e=>{let{children:t}=e;return $(CG)?t:null};SG.displayName=`MessagePartPrimitive.InProgress`;function CG(e){return e.part.status.type===`running`}var wG=e=>{let t=J(2),{fallback:n}=e,r=$(TG)||n,i;return t[0]===r?i=t[1]:(i=(0,b.jsx)(b.Fragment,{children:r}),t[0]=r,t[1]=i),i};wG.displayName=`ThreadListItemPrimitive.Title`;function TG(e){return e.threadListItem.title}var EG=e=>{let t=J(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,b.jsx)(r,{}),t[0]=r,t[1]=i),i},DG=LN(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)(EG,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(CV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);DG.displayName=`ThreadPrimitive.SuggestionByIndex`;var OG=({children:e})=>{let t=$(e=>e.suggestions.suggestions.length);return ON(()=>t===0?null:Array.from({length:t},(t,n)=>(0,b.jsx)(CV,{index:n,children:(0,b.jsx)(nR,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},kG=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(OG,{children:()=>(0,b.jsx)(EG,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,b.jsx)(OG,{children:r}),t[2]=r,t[3]=i),i};kG.displayName=`ThreadPrimitive.Suggestions`;var AG=LN(kG,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),jG=e=>{let t=J(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],$(n)},MG=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),jG(r)?n:null};MG.displayName=`ComposerPrimitive.If`;var NG=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,PG=e=>!e.composer.canCancel,FG=e=>e.composer.isEditing||e.optional.thread?.voice!==void 0||e.optional.thread?.capabilities.edit===!1,IG=e=>e.thread.isRunning||e.thread.isDisabled||e.thread.voice!==void 0||e.message.role!==`assistant`||!e.thread.capabilities.reload,LG=e=>e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(e=>e.type===`text`&&e.text.length>0),RG=e=>e.message.branchNumber<=1||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,zG=e=>e.message.branchNumber>=e.message.branchCount||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,BG=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,VG=e=>{if(e.message.status?.type!==`incomplete`||e.message.status.reason!==`error`)return;let t=e.message.status.error;return typeof t==`string`?t:typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:t??`An error occurred`},HG=e=>!e.threads.hasMore||e.threads.isLoading||e.threads.isLoadingMore,UG=()=>{let e=J(5),t=Q(),n=$(NG),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},WG=()=>{let e=J(5),t=Q(),n=$(PG),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},GG=()=>{let e=J(5),t=Q(),n=$(KG),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function KG(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var qG=()=>{let e=J(5),t=Q(),n=$(JG),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function JG(e){return!e.composer.isEditing}var YG=e=>{let t=J(15),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=Q(),s=$(LG),c=$(XG),l=$(ZG),u=$(QG),d=Y(void 0),f=Y(0),p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>()=>{f.current+=1,d.current!==void 0&&(clearTimeout(d.current),d.current=void 0,o.message.setIsCopied(!1))},m=[o],t[2]=o,t[3]=p,t[4]=m),X(p,m);let h;t[5]!==o||t[6]!==u||t[7]!==a||t[8]!==i||t[9]!==l?(h=()=>{if(!i)return;let e=l?u:o.message.getCopyText();if(!e)return;let t=f.current,n;try{n=i(e)}catch{return}Promise.resolve(n).then(()=>{t===f.current&&(d.current!==void 0&&clearTimeout(d.current),o.message.setIsCopied(!0),d.current=setTimeout(()=>{d.current=void 0,o.message.setIsCopied(!1)},a))},$G)},t[5]=o,t[6]=u,t[7]=a,t[8]=i,t[9]=l,t[10]=h):h=t[10];let g=h,_=s||!i,v;return t[11]!==g||t[12]!==c||t[13]!==_?(v={copy:g,disabled:_,isCopied:c},t[11]=g,t[12]=c,t[13]=_,t[14]=v):v=t[14],v};function XG(e){return e.message.isCopied}function ZG(e){return e.composer.isEditing}function QG(e){return e.composer.text}function $G(){}var eK=()=>{let e=J(5),t=Q(),n=$(FG),r;e[0]===t?r=e[1]:(r=()=>{t.composer.beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},tK=()=>{let e=J(5),t=Q(),n=$(IG),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},nK=()=>{let e=J(5),t=Q(),n=$(iK),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},rK=()=>{let e=J(5),t=Q(),n=$(aK),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function iK(e){return e.message.metadata.submittedFeedback?.type===`positive`}function aK(e){return e.message.metadata.submittedFeedback?.type===`negative`}var oK=()=>{let e=J(5),t=Q(),n=$(cK),r;e[0]===t?r=e[1]:(r=async()=>{t.message.speak()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function sK(e){return e.type===`text`&&e.text.length>0}function cK(e){return e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(sK)}var lK=()=>{let e=J(5),t=Q(),n=$(uK),r;e[0]===t?r=e[1]:(r=()=>{t.message.stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function uK(e){return e.message.speech==null}var dK=()=>{let e=J(5),t=Q(),n=$(zG),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`next`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={next:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},fK=()=>{let e=J(5),t=Q(),n=$(RG),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`previous`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={previous:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},pK=e=>{let t=J(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=Q(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>BG(e,s),t[0]=s,t[1]=c);let l=$(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let{isRunning:e,capabilities:t}=o.thread.getState();if(e&&!t.queue)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&!e&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(mK).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function mK(e){return e.trim()}var hK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.archive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={archive:r},e[2]=r,e[3]=i),i},gK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.delete()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={delete:r},e[2]=r,e[3]=i),i},_K=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.unarchive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={unarchive:r},e[2]=r,e[3]=i),i},vK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.switchTo()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchTo:r},e[2]=r,e[3]=i),i},yK=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threads.switchToNewThread()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchToNewThread:r},e[2]=r,e[3]=i),i},bK=()=>{let e=J(5),t=Q(),n=$(HG),r;e[0]===t?r=e[1]:(r=()=>{t.threads.loadMore()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={loadMore:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},xK=()=>$(VG),SK=e=>{let{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c,...l}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c},otherOptions:l}};function CK(e,t){function n(n){let r=WN(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function wK(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var TK=HN(null),{useThreadViewport:EK,useThreadViewportStore:DK}=wK(CK(TK,`ThreadPrimitive.Viewport`),`useThreadViewport`),OK=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},kK=(e=>e?OK(e):OK),AK=e=>e;function jK(e,t=AK){let n=y.useSyncExternalStore(e.subscribe,y.useCallback(()=>t(e.getState()),[e,t]),y.useCallback(()=>t(e.getInitialState()),[e,t]));return y.useDebugValue(n),n}var MK=e=>{let t=kK(e),n=e=>jK(t,e);return Object.assign(n,t),n},NK=(e=>e?MK(e):MK),PK=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},FK=(e={})=>{let t=new Set,n=PK(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=PK(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=NK(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{WP(t,()=>({behavior:e}),`Thread viewport`)},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},IK=e=>e,LK=e=>{let t=J(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=DK(n),i;t[1]===e?i=t[2]:(i=()=>FK(e),t[1]=e,t[2]=i);let[a]=EN(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(e=>{a.getState().scrollToBottom(e)}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),X(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&IK(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),X(c,l),a},RK=e=>{let t=J(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=LK(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=EN(o),c;return t[4]!==n||t[5]!==s?(c=(0,b.jsx)(TK.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},zK=()=>{let e=J(3),t=Q(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),X(n,r),null},BK=LN(e=>{let t=J(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,b.jsx)(zK,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,b.jsx)(RK,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,b.jsxs)(sR,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),VK=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,HK={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(VK)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},UK=Object.defineProperty,WK=(e,t)=>UK(e,`name`,{value:t,configurable:!0});function GK(e,t=globalThis?.document){let n=dt(e);y.useEffect(()=>{let e=WK(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}WK(GK,`useEscapeKeydown`);var KK=d;KK.dispatchDiscreteCustomEvent=_,KK.Root=d;var qK=Object.defineProperty,JK=(e,t)=>{let n={};for(var r in e)qK(n,r,{get:e[r],enumerable:!0});return t||qK(n,Symbol.toStringTag,{value:`Module`}),n},YK=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function XK(e,t){return BN(e,void 0,t===void 0?e.props.children:t)}function ZK(e,t,n){return(0,b.jsx)(s,{...n,children:XK(e,t)})}function QK(e){let t=Z((t,n)=>{let r=J(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&VN(o)){let e=s,t;r[5]!==a||r[6]!==o?(t=XK(o,a),r[5]=a,r[6]=o,r[7]=t):t=r[7];let i;return r[8]!==n||r[9]!==e||r[10]!==t?(i=(0,b.jsx)(c,{...e,asChild:!0,ref:n,children:t}),r[8]=n,r[9]=e,r[10]=t,r[11]=i):i=r[11],i}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,b.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function $K(e){let t=KK[e],n=QK(t);return n.displayName=`Primitive.${e}`,n}var eq=YK.reduce((e,t)=>(e[t]=$K(t),e),{}),tq={Hidden:`hidden`,Floating:`floating`,Normal:`normal`},nq=e=>{let t=J(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return tq.Hidden;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?tq.Floating:tq.Normal:tq.Hidden:tq.Normal},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],$(o)},rq=HN(null),iq=()=>WN(rq),aq=Z((e,t)=>{let n=J(18),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({hideWhenRunning:a,autohide:r,autohideFloat:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let[s,c]=EN(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(oq),()=>{e||(e=!0,c(sq))}},n[5]=l):l=n[5];let u=l,d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={acquireInteractionLock:u},n[6]=d):d=n[6];let f=d,p=s>0,m;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==p?(m={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:p},n[7]=r,n[8]=i,n[9]=a,n[10]=p,n[11]=m):m=n[11];let h=nq(m);if(h===tq.Hidden)return null;let g;n[12]===h?g=n[13]:(g=h===tq.Floating?{"data-floating":`true`}:null,n[12]=h,n[13]=g);let _;return n[14]!==t||n[15]!==o||n[16]!==g?(_=(0,b.jsx)(rq.Provider,{value:f,children:(0,b.jsx)(eq.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});aq.displayName=`ActionBarPrimitive.Root`;function oq(e){return e+1}function sq(e){return Math.max(0,e-1)}var cq=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:uq},t[2]=i,t[3]=a);let{copy:o,disabled:s}=YG(a);return s?null:o},lq=Z((e,t)=>{let n=J(20),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({copiedDuration:r,onClick:a,disabled:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=$(dq),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=cq(c),u;n[7]===s?u=n[8]:(u=s?{"data-copied":`true`}:{},n[7]=s,n[8]=u);let d=i||!l,f;n[9]===l?f=n[10]:(f=()=>{l?.()},n[9]=l,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=P(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==o||n[16]!==u||n[17]!==d||n[18]!==p?(m=(0,b.jsx)(eq.button,{type:`button`,...u,...o,ref:t,disabled:d,onClick:p}),n[14]=t,n[15]=o,n[16]=u,n[17]=d,n[18]=p,n[19]=m):m=n[19],m});lq.displayName=`ActionBarPrimitive.Copy`;function uq(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function dq(e){return e.message.isCopied}var fq=(e,t,n=[])=>{let r=Z((e,r)=>{let i=J(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=eq,l=o.disabled||!s,u=P(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,b.jsx)(c.button,{type:`button`,...o,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},pq=fq(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=tK();return e?null:t}),mq=fq(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=eK();return e?null:t}),hq=fq(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=oK();return e?null:t}),gq=()=>{let{disabled:e,stopSpeaking:t}=lK();return e?null:t},_q=Z((e,t)=>{let n=J(10),r=gq(),i=!r,a;n[0]===r?a=n[1]:(a=()=>{r?.()},n[0]=r,n[1]=a);let o;n[2]!==e.onClick||n[3]!==a?(o=P(e.onClick,a),n[2]=e.onClick,n[3]=a,n[4]=o):o=n[4];let s;return n[5]!==e||n[6]!==t||n[7]!==i||n[8]!==o?(s=(0,b.jsx)(eq.button,{type:`button`,disabled:i,...e,ref:t,onClick:o}),n[5]=e,n[6]=t,n[7]=i,n[8]=o,n[9]=s):s=n[9],s});_q.displayName=`ActionBarPrimitive.StopSpeaking`;var vq=()=>{let{submit:e}=nK();return e},yq=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(bq),s=vq(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=P(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,b.jsx)(eq.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});yq.displayName=`ActionBarPrimitive.FeedbackPositive`;function bq(e){return e.message.metadata.submittedFeedback?.type===`positive`}var xq=()=>{let{submit:e}=rK();return e},Sq=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(Cq),s=xq(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=P(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,b.jsx)(eq.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});Sq.displayName=`ActionBarPrimitive.FeedbackNegative`;function Cq(e){return e.message.metadata.submittedFeedback?.type===`negative`}var wq=e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=Q(),o=$(Dq),s;return t[2]!==a.message||t[3]!==r||t[4]!==i?(s=async()=>{let e=a.message.getCopyText();if(!e)return;if(i){await i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r??`message-${Date.now()}.md`,o.click(),setTimeout(()=>URL.revokeObjectURL(n),4e4)},t[2]=a.message,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},Tq=Z((e,t)=>{let n=J(19),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({filename:i,onExport:o,onClick:a,disabled:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==i||n[7]!==o?(c={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=c):c=n[8];let l=wq(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.().catch(Oq)},n[9]=l,n[10]=d);let f;n[11]!==a||n[12]!==d?(f=P(a,d),n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;return n[14]!==t||n[15]!==s||n[16]!==u||n[17]!==f?(p=(0,b.jsx)(eq.button,{type:`button`,...s,ref:t,disabled:u,onClick:f}),n[14]=t,n[15]=s,n[16]=u,n[17]=f,n[18]=p):p=n[18],p});Tq.displayName=`ActionBarPrimitive.ExportMarkdown`;function Eq(e){return e.type===`text`&&e.text.length>0}function Dq(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(Eq)}function Oq(e){console.error(`[assistant-ui] markdown export failed:`,e)}var kq=JK({Copy:()=>lq,Edit:()=>mq,ExportMarkdown:()=>Tq,FeedbackNegative:()=>Sq,FeedbackPositive:()=>yq,Reload:()=>pq,Root:()=>aq,Speak:()=>hq,StopSpeaking:()=>_q}),Aq=ul(),jq=e=>{let t=J(25),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({__scopeActionBarMore:n,open:i,onOpenChange:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=Aq(n),s=iq(),c=Y(null),l=i!==void 0,u;t[5]===s?u=t[6]:(u=e=>{if(e){if(c.current)return;c.current=s?.acquireInteractionLock()??null;return}c.current?.(),c.current=null},t[5]=s,t[6]=u);let d=u,f;t[7]!==l||t[8]!==r||t[9]!==d?(f=e=>{l||d(e),r?.(e)},t[7]=l,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p=f,m,h;t[11]!==l||t[12]!==i||t[13]!==d?(m=()=>{l&&d(!!i)},h=[l,i,d],t[11]=l,t[12]=i,t[13]=d,t[14]=m,t[15]=h):(m=t[14],h=t[15]),X(m,h);let g,_;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{c.current?.(),c.current=null},_=[],t[16]=g,t[17]=_):(g=t[16],_=t[17]),X(g,_);let v;t[18]===i?v=t[19]:(v=i===void 0?null:{open:i},t[18]=i,t[19]=v);let y;return t[20]!==p||t[21]!==a||t[22]!==o||t[23]!==v?(y=(0,b.jsx)(Ml,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};jq.displayName=`ActionBarMorePrimitive.Root`;var Mq=QK(Nl),Nq=QK(Fl),Pq=QK(Rl),Fq=QK(Ul),Iq=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Aq(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(Mq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});Iq.displayName=`ActionBarMorePrimitive.Trigger`;var Lq=Z((e,t)=>{let n=J(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({__scopeActionBarMore:r,portalProps:i,sideOffset:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?4:o,c=Aq(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,b.jsx)(Nq,{...c,...a,ref:t,sideOffset:s}),n[5]=t,n[6]=a,n[7]=c,n[8]=s,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==c||n[12]!==l?(u=(0,b.jsx)(Pl,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});Lq.displayName=`ActionBarMorePrimitive.Content`;var Rq=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Aq(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(Pq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});Rq.displayName=`ActionBarMorePrimitive.Item`;var zq=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Aq(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(Fq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});zq.displayName=`ActionBarMorePrimitive.Separator`;var Bq=JK({Content:()=>Lq,Item:()=>Rq,Root:()=>jq,Separator:()=>zq,Trigger:()=>Iq}),Vq=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,b.jsx)(eq.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});Vq.displayName=`AttachmentPrimitive.Root`;var Hq=Z((e,t)=>{let n=J(4),r=$(Uq),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,b.jsx)(eq.div,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});Hq.displayName=`AttachmentPrimitive.unstable_Thumb`;function Uq(e){let t=e.attachment.name,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?`.${t.slice(n+1)}`:e.attachment.type}var Wq=()=>{let e=J(2),t=$(Gq),n;return e[0]===t?n=e[1]:(n=(0,b.jsx)(b.Fragment,{children:t}),e[0]=t,e[1]=n),n};Wq.displayName=`AttachmentPrimitive.Name`;function Gq(e){return e.attachment.name}var Kq=fq(`AttachmentPrimitive.Remove`,()=>{let e=J(2),t=Q(),n;return e[0]===t.attachment?n=e[1]:(n=()=>{t.attachment.remove()},e[0]=t.attachment,e[1]=n),n}),qq=JK({Name:()=>Wq,Remove:()=>Kq,Root:()=>Vq,unstable_Thumb:()=>Hq}),Jq=fq(`BranchPickerPrimitive.Next`,()=>{let{disabled:e,next:t}=dK();return e?null:t}),Yq=fq(`BranchPickerPrimitive.Previous`,()=>{let{disabled:e,previous:t}=fK();return e?null:t}),Xq=()=>$(Qq),Zq=()=>{let e=J(2),t=Xq(),n;return e[0]===t?n=e[1]:(n=(0,b.jsx)(b.Fragment,{children:t}),e[0]=t,e[1]=n),n};Zq.displayName=`BranchPickerPrimitive.Count`;function Qq(e){return e.message.branchCount}var $q=()=>$(tJ),eJ=()=>{let e=J(2),t=$q(),n;return e[0]===t?n=e[1]:(n=(0,b.jsx)(b.Fragment,{children:t}),e[0]=t,e[1]=n),n};eJ.displayName=`BranchPickerPrimitive.Number`;function tJ(e){return e.message.branchNumber}var nJ=Z((e,t)=>{let n=J(11),r,i;n[0]===e?(r=n[1],i=n[2]):({hideWhenSingleBranch:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e=>!r||e.message.branchCount>=2,n[3]=r,n[4]=a);let o;n[5]!==t||n[6]!==i?(o=(0,b.jsx)(eq.div,{...i,ref:t}),n[5]=t,n[6]=i,n[7]=o):o=n[7];let s;return n[8]!==a||n[9]!==o?(s=(0,b.jsx)(XL,{condition:a,children:o}),n[8]=a,n[9]=o,n[10]=s):s=n[10],s});nJ.displayName=`BranchPickerPrimitive.Root`;var rJ=JK({Count:()=>Zq,Next:()=>Jq,Number:()=>eJ,Previous:()=>Yq,Root:()=>nJ}),iJ=HN(null),aJ=()=>WN(iJ),oJ=e=>{let t=J(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=Y(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(sJ),o.current=e.map(cJ)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,b.jsx)(iJ.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function sJ(e,t){return t[1]-e[1]}function cJ(e){let[t]=e;return t}var lJ=HN(null),uJ=HN(null),dJ=()=>{let e=WN(lJ);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},fJ=()=>WN(lJ),pJ=()=>{let e=WN(uJ);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},mJ=()=>{let e=dJ();return MN(e.subscribe,e.getTriggers,e.getTriggers)},hJ=new Map,gJ=()=>()=>{},_J=()=>hJ,vJ=()=>{let e=fJ();return MN(e?e.subscribe:gJ,e?e.getTriggers:_J,e?e.getTriggers:_J)},yJ=()=>null,bJ=()=>{let e=fJ();return MN(e?e.subscribeAria:gJ,e?e.getActiveAria:yJ,e?e.getActiveAria:yJ)};function xJ(){let e=J(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=Y(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var SJ=e=>{let t=J(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=Y(a),{notify:s,subscribe:c}=xJ(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return wJ;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=Y(null),g=Y(null),{notify:_,subscribe:v}=xJ(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let x=y,S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>h.current,t[8]=S):S=t[8];let C=S,w;t[9]!==u||t[10]!==c||t[11]!==v?(w={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:C,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=w):w=t[12];let T=w,E;t[13]===x?E=t[14]:(E={setActiveAria:x},t[13]=x,t[14]=E);let D=E,O;t[15]!==D||t[16]!==n?(O=(0,b.jsx)(uJ.Provider,{value:D,children:n}),t[15]=D,t[16]=n,t[17]=O):O=t[17];let k;return t[18]!==O||t[19]!==T?(k=(0,b.jsx)(lJ.Provider,{value:T,children:O}),t[18]=O,t[19]=T,t[20]=k):k=t[20],k},CJ=e=>{let t=J(4),{children:n}=e;if(aJ()){let e;return t[0]===n?e=t[1]:(e=(0,b.jsx)(SJ,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,b.jsx)(oJ,{children:(0,b.jsx)(SJ,{children:n})}),t[2]=n,t[3]=r),r};CJ.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function wJ(){}var TJ=/\s/u;function EJ(e,t,n,r){if(r===null)return null;let{query:i,offset:a,endOffset:o}=r;return a<0||a+t.length>n||!e.startsWith(t,a)||o<a+t.length||o>e.length?null:{query:i,offset:a,endOffset:o}}function DJ(e,t,n,r){if(r)return EJ(e,t,n,r(e,t,n));let i=e.slice(0,n);for(let e=i.length-1;e>=0;e--){let r=i[e];if(TJ.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!TJ.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var OJ=GN(e=>{let t=J(8),{text:n,triggerChar:r,matcher:i}=e,[a,o]=EN(n.length),s=Math.min(a,n.length),c;t[0]!==i||t[1]!==s||t[2]!==n||t[3]!==r?(c=DJ(n,r,s,i),t[0]=i,t[1]=s,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=c,u=l?.query??``,d;return t[5]!==u||t[6]!==l?(d={trigger:l,query:u,setCursorPosition:o},t[5]=u,t[6]=l,t[7]=d):d=t[7],d});function kJ(e){return`type`in e}var AJ=GN(e=>{let t=J(22),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=EN(0),m;t[0]!==i||t[1]!==r||t[2]!==n?(m={navigableList:n,isSearchMode:r,activeCategoryId:i},t[0]=i,t[1]=r,t[2]=n,t[3]=m):m=t[3];let[h,g]=EN(m);(h.navigableList!==n||h.isSearchMode!==r||h.activeCategoryId!==i)&&(g({navigableList:n,isSearchMode:r,activeCategoryId:i}),p(0));let _;t[4]!==f||t[5]!==n.length?(_=e=>{e<0||e>=n.length||e!==f&&p(e)},t[4]=f,t[5]=n.length,t[6]=_):_=t[6];let v=jN(_),y;t[7]!==i||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==n||t[12]!==s||t[13]!==a||t[14]!==l||t[15]!==c?(y=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(kJ(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[7]=i,t[8]=d,t[9]=u,t[10]=f,t[11]=n,t[12]=s,t[13]=a,t[14]=l,t[15]=c,t[16]=y):y=t[16];let b=jN(y),x=n[f],S=s&&x?`${o}-option-${x.id}`:void 0,C;return t[17]!==b||t[18]!==v||t[19]!==f||t[20]!==S?(C={highlightedIndex:f,highlightedItemId:S,highlightIndex:v,handleKeyDown:b},t[17]=b,t[18]=v,t[19]=f,t[20]=S,t[21]=C):C=t[21],C});function jJ(e,t){return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var MJ=GN(e=>{let t=J(35),{adapter:n,query:r,open:i}=e,[a,o]=EN(null),[s,c]=EN(i);s!==i&&(c(i),i||o(null));let l;bb0:{if(!i||!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],l=e;break bb0}let e;t[1]===n?e=t[2]:(e=n.categories(),t[1]=n,t[2]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],f=e;break bb1}let e;t[4]!==n||t[5]!==d?(e=n.categoryItems(d),t[4]=n,t[5]=d,t[6]=e):e=t[6],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[7]!==n||t[8]!==r?(e=n.search(r),t[7]=n,t[8]=r,t[9]=e):e=t[9],m=e;break bb2}let e;if(t[10]!==n||t[11]!==u||t[12]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))jJ(r,i)&&e.push(r);t[10]=n,t[11]=u,t[12]=r,t[13]=e}else e=t[13];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[14]=e):e=t[14],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[15]!==u||t[16]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[15]=u,t[16]=r,t[17]=e}else e=t[17];_=e}let v=_,y;bb4:{if(g){let e;t[18]===h?e=t[19]:(e=h??[],t[18]=h,t[19]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[20]!==p||t[21]!==r){let n=r.toLowerCase();e=p.filter(e=>jJ(e,n)),t[20]=p,t[21]=r,t[22]=e}else e=t[22];y=e}let b=y,x;bb5:{if(g){let e;t[23]===h?e=t[24]:(e=h??[],t[23]=h,t[24]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[25]=C):C=t[25];let w=jN(C),T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[26]=T):T=t[26];let E=jN(T),D;return t[27]!==d||t[28]!==v||t[29]!==b||t[30]!==E||t[31]!==g||t[32]!==S||t[33]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[27]=d,t[28]=v,t[29]=b,t[30]=E,t[31]=g,t[32]=S,t[33]=w,t[34]=D):D=t[34],D}),NJ=GN(e=>{let t=J(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=Y(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>(s.current=e,()=>{s.current===e&&(s.current=null)}),t[0]=c):c=t[0];let l=jN(c),u;t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==r?(u=e=>{if(!r||!n)return;if(s.current?.(e)){o();return}let t=i.composer.getState().text,c=t.slice(0,r.offset),l=t.slice(r.endOffset),u=()=>{let t=n.formatter.serialize(e);i.composer.setText(c+t+(l.startsWith(` `)?l:` ${l}`)),a(c.length+t.length+1)};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?(i.composer.setText(c+(l.startsWith(` `)?l.slice(1):l)),a(c.length)):u(),n.onExecute(e)),o()},t[1]=i,t[2]=n,t[3]=o,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=jN(u),f;t[7]!==o||t[8]!==a||t[9]!==r?(f=()=>{o(),r&&a(r.offset)},t[7]=o,t[8]=a,t[9]=r,t[10]=f):f=t[10];let p=jN(f),m;return t[11]!==p||t[12]!==l||t[13]!==d?(m={selectItem:d,close:p,registerSelectItemOverride:l},t[11]=p,t[12]=l,t[13]=d,t[14]=m):m=t[14],m}),PJ=GN(e=>{let t=J(47),{adapter:n,text:r,triggerChar:i,matcher:a,behavior:o,aui:s,popoverId:c,isLoading:l}=e,u;t[0]!==a||t[1]!==r||t[2]!==i?(u=OJ({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=NP(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=MJ({adapter:n,query:d.query,open:f}),t[4]=n,t[5]=d.query,t[6]=f,t[7]=p):p=t[7];let m=NP(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=jN(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=NJ({behavior:o,trigger:d.trigger,aui:s,triggerChar:i,setCursorPosition:d.setCursorPosition,onSelected:g}),t[10]=s,t[11]=o,t[12]=d.setCursorPosition,t[13]=d.trigger,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v=NP(_),y;t[17]!==d.query||t[18]!==m.activeCategoryId||t[19]!==m.goBack||t[20]!==m.isSearchMode||t[21]!==m.navigableList||t[22]!==m.selectCategory||t[23]!==f||t[24]!==c||t[25]!==v.close||t[26]!==v.selectItem?(y=AJ({navigableList:m.navigableList,isSearchMode:m.isSearchMode,activeCategoryId:m.activeCategoryId,query:d.query,popoverId:c,open:f,selectItem:v.selectItem,selectCategory:m.selectCategory,goBack:m.goBack,close:v.close}),t[17]=d.query,t[18]=m.activeCategoryId,t[19]=m.goBack,t[20]=m.isSearchMode,t[21]=m.navigableList,t[22]=m.selectCategory,t[23]=f,t[24]=c,t[25]=v.close,t[26]=v.selectItem,t[27]=y):y=t[27];let b=NP(y),x;return t[28]!==d.query||t[29]!==d.setCursorPosition||t[30]!==l||t[31]!==b.handleKeyDown||t[32]!==b.highlightIndex||t[33]!==b.highlightedIndex||t[34]!==b.highlightedItemId||t[35]!==m.activeCategoryId||t[36]!==m.categories||t[37]!==m.goBack||t[38]!==m.isSearchMode||t[39]!==m.items||t[40]!==m.selectCategory||t[41]!==f||t[42]!==c||t[43]!==v.close||t[44]!==v.registerSelectItemOverride||t[45]!==v.selectItem?(x={open:f,query:d.query,activeCategoryId:m.activeCategoryId,categories:m.categories,items:m.items,highlightedIndex:b.highlightedIndex,isSearchMode:m.isSearchMode,isLoading:l,popoverId:c,highlightedItemId:b.highlightedItemId,selectCategory:m.selectCategory,goBack:m.goBack,selectItem:v.selectItem,close:v.close,highlightIndex:b.highlightIndex,handleKeyDown:b.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:v.registerSelectItemOverride},t[28]=d.query,t[29]=d.setCursorPosition,t[30]=l,t[31]=b.handleKeyDown,t[32]=b.highlightIndex,t[33]=b.highlightedIndex,t[34]=b.highlightedItemId,t[35]=m.activeCategoryId,t[36]=m.categories,t[37]=m.goBack,t[38]=m.isSearchMode,t[39]=m.items,t[40]=m.selectCategory,t[41]=f,t[42]=c,t[43]=v.close,t[44]=v.registerSelectItemOverride,t[45]=v.selectItem,t[46]=x):x=t[46],x}),FJ=HN(null),IJ=()=>{let e=WN(FJ);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},LJ=()=>WN(FJ),RJ=HN(null),zJ=()=>{let e=WN(RJ);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},BJ=Z((e,t)=>{let n=J(69),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({char:a,matcher:s,adapter:r,isLoading:l,"aria-label":i,children:o,...c}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=l!==void 0&&l,d=Q(),f=$(VJ),p=FN(),m=Y(s),h;n[8]===s?h=n[9]:(h=()=>{m.current=s},n[8]=s,n[9]=h),X(h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>(e,t,n)=>m.current(e,t,n),n[10]=g):g=n[10];let[_]=EN(g),v=s!==void 0,y=Y(null),[x,S]=EN(null),C=Y(0),w;n[11]===a?w=n[12]:(w=e=>(C.current+=1,y.current=e,S(e),()=>{C.current=Math.max(0,C.current-1),y.current===e&&(y.current=null,S(null))}),n[11]=a,n[12]=w);let T=w,E;n[13]===T?E=n[14]:(E={register:T},n[13]=T,n[14]=E);let D=E,O=x??void 0,k;n[15]!==r||n[16]!==d||n[17]!==a||n[18]!==u||n[19]!==s||n[20]!==p||n[21]!==O||n[22]!==f?(k=PJ({adapter:r,text:f,triggerChar:a,matcher:s,behavior:O,aui:d,popoverId:p,isLoading:u}),n[15]=r,n[16]=d,n[17]=a,n[18]=u,n[19]=s,n[20]=p,n[21]=O,n[22]=f,n[23]=k):k=n[23];let A=NP(k),j;n[24]===A?j=n[25]:(j=()=>A,n[24]=A,n[25]=j);let M=jN(j),N=dJ(),ee;n[26]!==x||n[27]!==a||n[28]!==M||n[29]!==v||n[30]!==_||n[31]!==N?(ee=()=>N.register({char:a,...v?{matcher:_}:{},...x?{behavior:x}:{},resource:M()}),n[26]=x,n[27]=a,n[28]=M,n[29]=v,n[30]=_,n[31]=N,n[32]=ee):ee=n[32];let te;n[33]!==x||n[34]!==a||n[35]!==v||n[36]!==N?(te=[N,a,v,x],n[33]=x,n[34]=a,n[35]=v,n[36]=N,n[37]=te):te=n[37],X(ee,te);let ne=aJ(),re;n[38]!==M||n[39]!==ne?(re=()=>{if(ne)return ne.register(M())},n[38]=M,n[39]=ne,n[40]=re):re=n[40];let ie;n[41]===ne?ie=n[42]:(ie=[ne],n[41]=ne,n[42]=ie),X(re,ie);let ae=x!==null&&A.open,oe=pJ(),se,ce;n[43]!==oe||n[44]!==a||n[45]!==ae?(se=()=>{if(ae)return()=>{oe.setActiveAria(a,null)}},ce=[oe,a,ae],n[43]=oe,n[44]=a,n[45]=ae,n[46]=se,n[47]=ce):(se=n[46],ce=n[47]),X(se,ce);let le,ue;n[48]!==oe||n[49]!==a||n[50]!==ae||n[51]!==p||n[52]!==A.highlightedItemId?(le=()=>{ae&&oe.setActiveAria(a,{popoverId:p,highlightedItemId:A.highlightedItemId})},ue=[oe,a,p,ae,A.highlightedItemId],n[48]=oe,n[49]=a,n[50]=ae,n[51]=p,n[52]=A.highlightedItemId,n[53]=le,n[54]=ue):(le=n[53],ue=n[54]),X(le,ue);let de;n[55]!==i||n[56]!==o||n[57]!==t||n[58]!==ae||n[59]!==p||n[60]!==c||n[61]!==A.highlightedItemId?(de=ae?(0,b.jsx)(eq.div,{role:`listbox`,id:p,"aria-label":i??`Suggestions`,"aria-activedescendant":A.highlightedItemId,"data-state":`open`,...c,ref:t,children:o}):o,n[55]=i,n[56]=o,n[57]=t,n[58]=ae,n[59]=p,n[60]=c,n[61]=A.highlightedItemId,n[62]=de):de=n[62];let P;n[63]!==A||n[64]!==de?(P=(0,b.jsx)(FJ.Provider,{value:A,children:de}),n[63]=A,n[64]=de,n[65]=P):P=n[65];let fe;return n[66]!==D||n[67]!==P?(fe=(0,b.jsx)(RJ.Provider,{value:D,children:P}),n[66]=D,n[67]=P,n[68]=fe):fe=n[68],fe});BJ.displayName=`ComposerPrimitive.TriggerPopover`;function VJ(e){return e.composer.text}var HJ=()=>{let e=J(2),{disabled:t,send:n}=UG(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},UJ=fq(`ComposerPrimitive.Send`,HJ),WJ=HN(null),GJ=()=>WN(WJ),KJ=`[contenteditable]:not([contenteditable='false'])`,qJ=`textarea:not(:disabled), ${KJ}`,JJ=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,KJ,`[tabindex]`].join(`, `),YJ=Z((e,t)=>{let n=J(24),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({onSubmit:a,onMouseDown:i,compact:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=HJ(),[c,l]=EN(!1),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={setMultiline:l},n[5]=u):u=n[5];let d=u,f;n[6]===r?f=n[7]:(f=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
93
+ `):!1,n[6]=r,n[7]=f);let p=$(f)&&!c,m;n[8]===s?m=n[9]:(m=e=>{e.preventDefault(),s&&s()},n[8]=s,n[9]=m);let h=m,g=XJ,_=r?d:null,v=p?``:void 0,y;n[10]!==h||n[11]!==a?(y=P(a,h),n[10]=h,n[11]=a,n[12]=y):y=n[12];let x;n[13]===i?x=n[14]:(x=P(i,g),n[13]=i,n[14]=x);let S;n[15]!==t||n[16]!==o||n[17]!==v||n[18]!==y||n[19]!==x?(S=(0,b.jsx)(eq.form,{...o,"data-compact":v,ref:t,onSubmit:y,onMouseDown:x}),n[15]=t,n[16]=o,n[17]=v,n[18]=y,n[19]=x,n[20]=S):S=n[20];let C;return n[21]!==_||n[22]!==S?(C=(0,b.jsx)(WJ.Provider,{value:_,children:S}),n[21]=_,n[22]=S,n[23]=C):C=n[23],C});YJ.displayName=`ComposerPrimitive.Root`;function XJ(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(JJ);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(qJ);r&&(e.preventDefault(),r.focus())}var ZJ=e=>{let t=J(4),n=dt(e),r=EK(QJ),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)};function QJ(e){return e.onScrollToBottom}var $J=()=>!1,eY=()=>{},tY=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return eY;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),MN(r,i,$J)};function nY(){return $(rY)}function rY(e){return e.composer.isEditing?e.composer.text:``}function iY(e){return!!$(aY)||!!e}function aY(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function oY(){let e=J(4),t=bJ();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function sY(){return sY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sY.apply(null,arguments)}function cY(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var lY=y.useLayoutEffect,uY=function(e){var t=y.useRef(e);return lY(function(){t.current=e}),t},dY=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},fY=function(e,t){var n=y.useRef();return y.useCallback(function(r){e.current=r,n.current&&dY(n.current,null),n.current=t,t&&dY(t,r)},[t])},pY={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},mY=function(e){Object.keys(pY).forEach(function(t){e.style.setProperty(t,pY[t],`important`)})},hY=null,gY=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function _Y(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),hY||(hY=document.createElement(`textarea`),hY.setAttribute(`tabindex`,`-1`),hY.setAttribute(`aria-hidden`,`true`),mY(hY)),hY.parentNode===null&&document.body.appendChild(hY);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;hY.style[t]=o[t]}),mY(hY),hY.value=t;var c=gY(hY,e);hY.value=t,c=gY(hY,e),hY.value=`x`;var l=hY.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var vY=function(){},yY=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},bY=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],xY=!!document.documentElement.currentStyle,SY=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=yY(bY,t),r=n.boxSizing;return r===``?null:(xY&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function CY(e,t,n){var r=uY(n);y.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var wY=function(e,t){CY(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},TY=function(e){CY(window,`resize`,e)},EY=function(e){CY(document.fonts,`loadingdone`,e)},DY=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],OY=y.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?vY:a,s=e.onHeightChange,c=s===void 0?vY:s,l=cY(e,DY),u=l.value!==void 0,d=y.useRef(null),f=fY(d,t),p=y.useRef(0),m=y.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:SY(e);if(t){m.current=t;var a=_Y(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return y.useLayoutEffect(h),wY(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),TY(h),EY(h),y.createElement(`textarea`,sY({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),kY=`(pointer: coarse) and (not (any-pointer: fine))`,AY=Z(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:c,submitOnEnter:l,submitMode:d,cancelOnEscape:f=!0,unstable_focusOnRunStart:p=!0,unstable_focusOnScrollToBottom:m=!0,unstable_focusOnThreadSwitched:h=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:_=!0,onHeightChange:v,...y},x)=>{let S=Q(),C=aJ(),w=GJ(),T=d??(l===!1?`none`:`enter`),E=tY(g?kY:null),D=g&&E&&T===`enter`?`none`:T,O=nY(),k=iY(r),A=Y(null),j=u(x,A),M=Y(!1);GK(e=>{if(!A.current?.contains(e.target)||e.isComposing)return;if(C){for(let t of C.getPlugins())if(t.handleKeyDown(e))return}if(!f)return;let t=S.composer;t.getState().canCancel&&(t.cancel(),e.preventDefault())});let N=e=>{if(!k&&!e.nativeEvent.isComposing){if(C){for(let t of C.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=S.thread.getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&T!==`none`&&S.composer.getState().canSend){e.preventDefault(),S.composer.send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;D===`ctrlEnter`?r=e.ctrlKey||e.metaKey:D===`enter`&&(r=!0),r&&(e.preventDefault(),A.current?.closest(`form`)?.requestSubmit())}}},ee=async e=>{if(!_)return;let t=S.thread.getState().capabilities,n=Array.from(e.clipboardData?.files||[]);t.attachments&&n.length>0&&(e.preventDefault(),await Promise.all(n.map(async e=>{try{await S.composer.addAttachment(e)}catch{}})))},te=(e,t)=>{if(v?.(e,t),!w)return;let n=A.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&w.setMultiline(!0)},ne=e&&!k,re=kN(()=>{let e=A.current;e&&ne&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[ne]);X(()=>re(),[re]),ZJ(()=>{S.composer.getState().type===`thread`&&m&&re()}),X(()=>{if(S.composer.getState().type===`thread`&&p)return S.on(`thread.runStart`,re)},[p,re,S]),X(()=>{if(S.composer.getState().type===`thread`&&h)return S.on(`threads.selectionChanged`,re)},[h,re,S]),X(()=>{O===``&&w?.setMultiline(!1)},[O,w]);let ie=oY(),ae={name:`input`,value:O,...y,...ie,ref:j,disabled:k,onChange:P(i,e=>{if(!S.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;M.current&&!t&&(M.current=!1);let n=t||M.current;if(iP(()=>{S.composer.setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(C)for(let e of C.getPlugins())e.setCursorPosition(r)}),onKeyDown:P(a,N),onCompositionStart:P(y.onCompositionStart,()=>{M.current=!0}),onCompositionEnd:P(y.onCompositionEnd,e=>{if(M.current=!1,!S.composer.getState().isEditing)return;let t=e.target;iP(()=>{S.composer.setText(t.value)});let n=t.selectionStart??t.value.length;if(C)for(let e of C.getPlugins())e.setCursorPosition(n)}),onSelect:P(c,e=>{if(M.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(C)for(let e of C.getPlugins())e.setCursorPosition(n)}),onPaste:P(o,ee),...w?{onHeightChange:te}:v===void 0?{}:{onHeightChange:v}};if(n&&VN(n))return ZK(n,y.children,ae);let oe=t?s:OY;return(0,b.jsx)(oe,{...ae})});AY.displayName=`ComposerPrimitive.Input`;var jY=fq(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=WG();return e?null:t}),MY=fq(`ComposerPrimitive.AddAttachment`,e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=qG(),s=Q(),c;return t[2]!==o||t[3]!==s.composer||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer.getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=async t=>{let n=t.target.files;if(!n)return;let r=Array.from(n,async e=>{try{await o(e)}catch{}});document.body.removeChild(e),await Promise.all(r)},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s.composer,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),NY=Z(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,c]=EN(!1),l=Q(),u=kN(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}c(!0)}},[e,l]),d=kN(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}o||c(!0)}},[e,o,l]),f=kN(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||c(!1)},[e]),p=kN(async t=>{if(e||(c(!1),!t.dataTransfer.types.includes(`Files`)))return;t.preventDefault();let n=Array.from(t.dataTransfer.files);l.thread.getState().capabilities.attachments&&n.length!==0&&await Promise.all(n.map(async e=>{try{await l.composer.addAttachment(e)}catch{}}))},[e,l]),m={...o?{"data-dragging":`true`}:null,...i,onDragEnterCapture:P(i.onDragEnterCapture,u),onDragOverCapture:P(i.onDragOverCapture,d),onDragLeaveCapture:P(i.onDragLeaveCapture,f),onDropCapture:P(i.onDropCapture,p),ref:a};if(n&&VN(n))return ZK(n,r,m);let h=t?s:`div`;return(0,b.jsx)(h,{...m,children:r})});NY.displayName=`ComposerPrimitive.AttachmentDropzone`;var PY=fq(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=GG();return e?null:t}),FY=fq(`ComposerPrimitive.StopDictation`,()=>{let e=J(2),t=Q(),n=$(IY),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function IY(e){return e.composer.dictation!=null}var LY=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(RY);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,b.jsx)(eq.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});LY.displayName=`ComposerPrimitive.DictationTranscript`;function RY(e){return e.composer.dictation?.transcript}var zY=Z((e,t)=>{let n=J(3);if(!$(HY))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,b.jsx)(eq.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});zY.displayName=`ComposerPrimitive.Quote`;var BY=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(UY);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,b.jsx)(eq.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});BY.displayName=`ComposerPrimitive.QuoteText`;var VY=Z((e,t)=>{let n=J(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(),o;n[3]===a?o=n[4]:(o=()=>{a.composer.setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=P(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,b.jsx)(eq.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});VY.displayName=`ComposerPrimitive.QuoteDismiss`;function HY(e){return e.composer.quote}function UY(e){return e.composer.quote?.text}var WY=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=IJ();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,b.jsx)(eq.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});WY.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var GY=Z((e,t)=>{let n=J(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=IJ(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let x=y,S=`${p}-option-${r}`,C=v?``:void 0,w;n[16]!==h||n[17]!==i?(w=P(i,h),n[16]=h,n[17]=i,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==a?(T=P(a,x),n[19]=x,n[20]=a,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,b.jsx)(eq.button,{type:`button`,role:`option`,id:S,"aria-selected":v,"data-highlighted":C,...o,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=v,n[24]=o,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});GY.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var KY=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=IJ();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,b.jsx)(eq.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});KY.displayName=`ComposerPrimitive.TriggerPopoverItems`;var qY=Z((e,t)=>{let n=J(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=IJ(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,x;n[13]!==l||n[14]!==v?(x=()=>{l(v)},n[13]=l,n[14]=v,n[15]=x):x=n[15];let S=x,C=`${m}-option-${i.id}`,w=y?``:void 0,T;n[16]!==g||n[17]!==a?(T=P(a,g),n[16]=g,n[17]=a,n[18]=T):T=n[18];let E;n[19]!==S||n[20]!==o?(E=P(o,S),n[19]=S,n[20]=o,n[21]=E):E=n[21];let D;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==C||n[26]!==w||n[27]!==T||n[28]!==E?(D=(0,b.jsx)(eq.button,{type:`button`,role:`option`,id:C,"aria-selected":y,"data-highlighted":w,...s,ref:t,onClick:T,onMouseMove:E}),n[22]=t,n[23]=y,n[24]=s,n[25]=C,n[26]=w,n[27]=T,n[28]=E,n[29]=D):D=n[29],D});qY.displayName=`ComposerPrimitive.TriggerPopoverItem`;var JY=Z((e,t)=>{let n=J(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=IJ();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=P(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,b.jsx)(eq.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});JY.displayName=`ComposerPrimitive.TriggerPopoverBack`;var YY=e=>{let t=J(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=zJ(),o=Y(r),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{o.current=r},c=[r],t[0]=r,t[1]=s,t[2]=c),PN(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e={kind:`action`,formatter:n??HK,onExecute:e=>o.current(e),...i===void 0?{}:{removeOnExecute:i}};return a(e)},u=[a,n,i],t[3]=n,t[4]=a,t[5]=i,t[6]=l,t[7]=u):(l=t[6],u=t[7]),X(l,u),null};YY.displayName=`ComposerPrimitive.TriggerPopoverAction`;var XY=e=>{let t=J(7),{formatter:n,onInserted:r}=e,{register:i}=zJ(),a=Y(r),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{a.current=r},s=[r],t[0]=r,t[1]=o,t[2]=s),PN(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n??HK,onInserted:e=>a.current?.(e)}),l=[i,n],t[3]=n,t[4]=i,t[5]=c,t[6]=l):(c=t[5],l=t[6]),X(c,l),null};XY.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var ZY=Object.assign(BJ,{Directive:XY,Action:YY}),QY=JK({AddAttachment:()=>MY,AttachmentByIndex:()=>mG,AttachmentDropzone:()=>NY,Attachments:()=>gG,Cancel:()=>jY,Dictate:()=>PY,DictationTranscript:()=>LY,If:()=>MG,Input:()=>AY,Queue:()=>vG,Quote:()=>zY,QuoteDismiss:()=>VY,QuoteText:()=>BY,Root:()=>YJ,Send:()=>UJ,StopDictation:()=>FY,Unstable_TriggerPopover:()=>ZY,Unstable_TriggerPopoverBack:()=>JY,Unstable_TriggerPopoverCategories:()=>WY,Unstable_TriggerPopoverCategoryItem:()=>GY,Unstable_TriggerPopoverItem:()=>qY,Unstable_TriggerPopoverItems:()=>KY,Unstable_TriggerPopoverRoot:()=>CJ,unstable_useTriggerPopoverRootContext:()=>dJ,unstable_useTriggerPopoverRootContextOptional:()=>fJ,unstable_useTriggerPopoverScopeContext:()=>IJ,unstable_useTriggerPopoverScopeContextOptional:()=>LJ,unstable_useTriggerPopoverTriggers:()=>mJ,unstable_useTriggerPopoverTriggersOptional:()=>vJ}),$Y=Object.freeze({type:`complete`}),eX=Object.freeze({type:`text`,text:``,status:$Y}),tX=()=>$(nX);function nX(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?eX:e.part}var rX=HN(null),iX=e=>({useSmoothStatus:NK(()=>e)}),aX=e=>{let t=J(6),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={optional:!0},t[0]=r):r=t[0];let i=sX(r),a=Q(),o;t[1]===a.part?o=t[2]:(o=()=>iX(a.part.getState().status),t[1]=a.part,t[2]=o);let[s]=EN(o);if(i)return n;let c;return t[3]!==n||t[4]!==s?(c=(0,b.jsx)(rX.Provider,{value:s,children:n}),t[3]=n,t[4]=s,t[5]=c):c=t[5],c},oX=e=>{let t=Z((t,n)=>{let r=J(3),i=t,a;return r[0]!==n||r[1]!==i?(a=(0,b.jsx)(aX,{children:(0,b.jsx)(e,{...i,ref:n})}),r[0]=n,r[1]=i,r[2]=a):a=r[2],a});return t.displayName=e.displayName,t};function sX(e){let t=WN(rX);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:cX,useSmoothStatusStore:lX}=wK(sX,`useSmoothStatus`),uX=250,dX=5,fX=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=uX;maxCharIntervalMs=dX;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},pX=Object.freeze({type:`running`}),mX=(e,t)=>e!==void 0&&e>0?e:t,hX=(e,t=!1)=>{let{text:n}=e,r=tY(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=mX(i?.drainMs,uX),s=mX(i?.maxCharIntervalMs,dX),c=mX(i?.maxCharsPerFrame,1/0),l=mX(i?.minCommitMs,0),[u,d]=EN(e.status.type===`running`?``:n),f=Q(),p=$(()=>f.part),[m,h]=EN(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=lX({optional:!0}),_=dt(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?pX:e.status;IK(g).setState(n,!0)}});X(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?pX:e.status;IK(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=EN(new fX(u,_));X(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=Y(p);return X(()=>{if(!a){v.stop();return}let t=y.current!==p;if(y.current=p,t||!n.startsWith(v.targetText)){e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=0,v.start()):(v.currentText=n,v.targetText=n,v.stop(),_(n));return}if(v.targetText=n,e.status.type!==`running`){if(v.currentText===``){v.currentText=n,v.stop(),_(n);return}v.start();return}v.start()},[v,a,n,e.status.type,p,_]),X(()=>()=>{v.stop()},[v]),ON(()=>a?{...e,text:u,status:n===u?e.status:pX}:e,[a,u,e,n])},gX=Object.freeze({type:`complete`}),_X=Object.freeze({type:`image`,image:``,status:gX}),vX=()=>$(yX);function yX(e){return e.part.type===`image`?e.part:_X}var bX=Z(({smooth:e=!0,component:t=eq.span,render:n,...r},i)=>{let{text:a,status:o}=hX(tX(),e),s={"data-status":o.type,...r,ref:i};return n&&VN(n)?ZK(n,a,s):(0,b.jsx)(t,{...s,children:a})});bX.displayName=`MessagePartPrimitive.Text`;var xX=Z((e,t)=>{let n=J(4),{image:r}=vX(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,b.jsx)(eq.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});xX.displayName=`MessagePartPrimitive.Image`;var SX=Z((e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=(0,b.jsx)(eq.div,{role:`alert`,...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});SX.displayName=`ErrorPrimitive.Root`;var CX=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=xK();if(a===void 0)return null;let o=r??String(a),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,b.jsx)(eq.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});CX.displayName=`ErrorPrimitive.Message`;var wX=JK({Message:()=>CX,Root:()=>SX}),TX=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},EX=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},DX=e=>e.dataset.messageId,OX=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},kX=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},AX=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},jX=()=>{let e=J(4),t=Q(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=$(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),TX(i)},MX=()=>{let e=J(2),t=EK(zX),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},NX=()=>{let e=J(2),t=EK(BX),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},PX=(e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],TX(r)},FX=e=>{let t=J(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:EX(i.tallerThan,e),visibleHeight:EX(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],TX(i)},IX=e=>{let t=J(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=jX(),a=u(n,i),o=$(VX),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,b.jsx)(eq.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},LX=e=>{let t=J(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=jX(),o=MX(),s=NX(),c=PX(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let d=FX(l),f=u(n,a,c,d),p=$(HX),m=o?``:void 0,h=s?``:void 0,g;return t[7]!==p||t[8]!==r||t[9]!==f||t[10]!==m||t[11]!==h?(g=(0,b.jsx)(eq.div,{...r,ref:f,"data-message-id":p,"data-aui-top-anchor-user":m,"data-aui-top-anchor-target":h}),t[7]=p,t[8]=r,t[9]=f,t[10]=m,t[11]=h,t[12]=g):g=t[12],g},RX=Z((e,t)=>{let n=J(7),r=DK();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,b.jsx)(LX,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,b.jsx)(IX,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});RX.displayName=`MessagePrimitive.Root`;function zX(e){return e.topAnchorTurn?.anchorId}function BX(e){return e.topAnchorTurn?.targetId}function VX(e){return e.message.id}function HX(e){return e.message.id}var UX={..._W,Text:()=>(0,b.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,b.jsx)(bX,{}),(0,b.jsx)(SG,{children:(0,b.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,b.jsx)(xX,{})},WX=e=>{let t=J(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,b.jsx)(PW,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{...n,Text:n.Text??UX.Text,Image:n.Image??UX.Image}:UX,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,b.jsx)(PW,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};WX.displayName=`MessagePrimitive.Parts`;var GX=e=>{let t=J(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],$(n)},KX=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),GX(r)?n:null};KX.displayName=`MessagePrimitive.If`;var qX=e=>{let{children:t}=e;return xK()===void 0?null:t};qX.displayName=`MessagePrimitive.Error`;var JX=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??n,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=typeof e==`string`?e:void 0;n.push({groupKey:t,indices:r})}return n},YX=e=>{let t=J(4),n=$(oZ),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},XX=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},ZX=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,b.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},QX={Text:()=>(0,b.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,b.jsx)(bX,{}),(0,b.jsx)(SG,{children:(0,b.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,b.jsx)(xX,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},$X=e=>{let t=J(37),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?QX.Text:i,p=a===void 0?QX.Reasoning:a,m=o===void 0?QX.Image:o,h=s===void 0?QX.Source:s,g=c===void 0?QX.File:c,_=l===void 0?QX.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,x=Q(),S=$(sZ),C=S.type;if(C===`tool-call`){let e=x.part.addToolResult,n=x.part.resumeToolCall,r=x.part.respondToToolApproval;if(`Override`in y){let i;return t[4]!==e||t[5]!==S||t[6]!==r||t[7]!==n||t[8]!==y.Override?(i=(0,b.jsx)(y.Override,{...S,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=S,t[6]=r,t[7]=n,t[8]=y.Override,t[9]=i):i=t[9],i}let i=y.by_name?.[S.toolName]??y.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==S||t[13]!==r||t[14]!==n?(a=(0,b.jsx)(XX,{...S,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=S,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[16]!==f||t[17]!==S?(e=(0,b.jsx)(f,{...S}),t[16]=f,t[17]=S,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==p||t[20]!==S?(e=(0,b.jsx)(p,{...S}),t[19]=p,t[20]=S,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==h||t[23]!==S?(e=(0,b.jsx)(h,{...S}),t[22]=h,t[23]=S,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==m||t[26]!==S?(e=(0,b.jsx)(m,{...S}),t[25]=m,t[26]=S,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==g||t[29]!==S?(e=(0,b.jsx)(g,{...S}),t[28]=g,t[29]=S,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==_||t[32]!==S?(e=(0,b.jsx)(_,{...S}),t[31]=_,t[32]=S,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[34]!==e||t[35]!==S?(n=(0,b.jsx)(ZX,{...S,Fallback:e}),t[34]=e,t[35]=S,t[36]=n):n=t[36],n}default:return console.warn(`Unknown message part type: ${C}`),null}},eZ=LN(e=>{let t=J(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,b.jsx)($X,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,b.jsx)(dV,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),tZ=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,b.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,b.jsx)(pV,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},nZ=Object.freeze({type:`complete`}),rZ=LN(e=>{let t=J(6),{components:n}=e,r=$(cZ);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,b.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??QX.Text,a;return t[3]!==r||t[4]!==i?(a=(0,b.jsx)(tZ,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),iZ=e=>{let t=J(9),{groupingFunction:n,components:r}=e,i=$(lZ),a=YX(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,b.jsx)(rZ,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>{let n=r?.Group??QX.Group;return(0,b.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,b.jsx)(eZ,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`)},t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,b.jsx)(b.Fragment,{children:s}),t[7]=s,t[8]=c),c};iZ.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var aZ=e=>{let t=J(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,b.jsx)(iZ,{...r,components:n,groupingFunction:JX}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};aZ.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function oZ(e){return e.message.parts}function sZ(e){return e.part}function cZ(e){return e.message.status??nZ}function lZ(e){return e.message.parts.length}var uZ=JK({AttachmentByIndex:()=>cG,Attachments:()=>uG,Content:()=>WX,Error:()=>qX,GenerativeUI:()=>lW,GroupedParts:()=>iG,If:()=>KX,PartByIndex:()=>yW,Parts:()=>WX,Quote:()=>aG,Root:()=>RX,Unstable_PartsGrouped:()=>iZ,Unstable_PartsGroupedByParentId:()=>aZ}),dZ=e=>{let t=J(2),n=dt(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(fZ)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),TX(r)};function fZ(e){return e.type!==`attributes`||e.attributeName!==`style`}var pZ=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=Y(null),a=$(e=>e.thread.messages.length>0),o=$(e=>e.thread.isRunning),s=Y(!1),c=Y(null),l=DK();e===void 0&&(e=l.getState().turnAnchor!==`top`);let d=Y(0),f=Y(0),p=Y(0),m=Y(0),h=Y(null),g=Y(e),_=Y(e);AN(()=>{let t=_.current;if(_.current=e,t||!e)return;let n=i.current;g.current=n!==null&&jI(n)},[e]);let v=kN(e=>{let t=i.current;t&&(g.current=!0,h.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),y=kN(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),b=kN(e=>{h.current=e,y(),c.current=requestAnimationFrame(()=>{c.current=null,v(e)})},[y,v]);AN(()=>()=>y(),[y]);let x=kN(()=>{let e=l.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[l]),S=()=>{let t=i.current;if(!t)return;let n=l.getState().isAtBottom,r=jI(t);if(!(!r&&d.current<t.scrollTop)){let i=NI({scrollTop:d.current,scrollHeight:f.current},t);r?(MI(t)&&(h.current=null),e&&(g.current=!0)):i&&(y(),h.current=null,g.current=!1),(r||h.current===null)&&r!==n&&IK(l).setState({isAtBottom:r})}d.current=t.scrollTop,f.current=t.scrollHeight},C=dZ(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===p.current&&r===m.current)return;p.current=n,m.current=r;let a=h.current;a&&x()?h.current=null:a?v(a):e&&!(o&&x())&&g.current&&v(`instant`),S()}),w=TX(e=>{let t=()=>{h.current=null};return e.addEventListener(`scroll`,S),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,S),e.removeEventListener(`pointerdown`,t)}});return AN(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,h.current===null&&b(`instant`))}},[a,b,n]),ZJ(({behavior:e})=>{v(e)}),iR(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&b(`auto`)}),iR(`threads.selectionChanged`,()=>{r&&b(`instant`)}),u(C,w,i)},mZ=Z((e,t)=>{let n=J(6),r=Q(),i,a;n[0]===r?(i=n[1],a=n[2]):(i=()=>{let e=e=>{if(e.key===`Escape`&&!(e.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},a=[r],n[0]=r,n[1]=i,n[2]=a),X(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,b.jsx)(eq.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});mZ.displayName=`ThreadPrimitive.Root`;var hZ=e=>{let{children:t}=e;return $(gZ)?t:null};hZ.displayName=`ThreadPrimitive.Empty`;function gZ(e){return e.thread.isEmpty}var _Z=e=>{let t=J(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],$(n)},vZ=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),_Z(r)?n:null};vZ.displayName=`ThreadPrimitive.If`;var yZ=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],TX(r)},bZ=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},xZ=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:bZ(e)-bZ(t)},SZ=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=xZ(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},CZ=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=SZ(t)+n.clientHeight;return Math.max(0,r-e)},wZ=({viewport:e,reserve:t,...n})=>CZ({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),TZ=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},EZ=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},DZ=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o){a.disconnect(),t&&(kX(t,0),t.remove());return}if(!s&&!c&&!l&&r.topAnchorTurn){a.disconnect(),t?.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!s||!c||!l){a.disconnect(),t&&(kX(t,0),t.remove());return}if(t??=OX(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),kX(t,wZ({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=DX(s);if(u!==void 0&&n===u)return;let d=AX(SZ({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=EZ(r),a=TZ(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},OZ=e=>{let t=J(4),n=DK(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return DZ(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),AN(r,i)},kZ=(e,t)=>{if(!e)return!1;let n=t.findIndex(t=>t.id===e.targetId);return n<1?!1:t[n-1]?.id===e.anchorId&&t.slice(n+1).every(e=>e.role===`user`)},AZ=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},jZ=e=>AZ(e)?.anchorId,MZ=e=>AZ(e)?.targetId,NZ=()=>yZ(EK(RZ),zZ),PZ=()=>TX(EK(BZ)),FZ=e=>{let t=J(19),n=DK(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return jZ(t.thread)},t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return MZ(t.thread)},t[2]=e,t[3]=a);let o=$(a),s=EK(VZ),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&kZ(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=$(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{s&&!d&&n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),AN(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;(t?.anchorId!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),AN(m,h)},IZ=Z((e,t)=>{let n=J(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let d=pZ(l),f=NZ(),p=PZ(),m=DK(),h;n[12]===m?h=n[13]:(h=m.getState(),n[12]=m,n[13]=h);let g=h.turnAnchor===`top`;FZ(g),OZ(g);let _=u(t,d,f,p),v;return n[14]!==i||n[15]!==_||n[16]!==a?(v=(0,b.jsx)(eq.div,{...a,ref:_,children:i}),n[14]=i,n[15]=_,n[16]=a,n[17]=v):v=n[17],v});IZ.displayName=`ThreadPrimitive.ViewportScrollable`;var LZ=Z((e,t)=>{let n=J(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,b.jsx)(IZ,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,b.jsx)(RK,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});LZ.displayName=`ThreadPrimitive.Viewport`;function RZ(e){return e.registerViewport}function zZ(e){return e.clientHeight}function BZ(e){return e.registerViewportElement}function VZ(e){return e.topAnchorTurn}var HZ=Z((e,t)=>{let n=J(3),r=yZ(EK(UZ),WZ),i=u(t,r),a;return n[0]!==e||n[1]!==i?(a=(0,b.jsx)(eq.div,{...e,ref:i}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});HZ.displayName=`ThreadPrimitive.ViewportFooter`;function UZ(e){return e.registerContentInset}function WZ(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var GZ=fq(`ThreadPrimitive.ScrollToBottom`,e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=EK(KZ),a=DK(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function KZ(e){return e.isAtBottom}var qZ=fq(`ThreadPrimitive.Suggestion`,e=>{let t=J(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=pK(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),JZ=JK({Empty:()=>hZ,If:()=>vZ,MessageByIndex:()=>XU,Messages:()=>eW,Root:()=>mZ,ScrollToBottom:()=>GZ,Suggestion:()=>qZ,SuggestionByIndex:()=>DG,Suggestions:()=>AG,Unstable_MessageById:()=>ZU,Viewport:()=>LZ,ViewportFooter:()=>HZ,ViewportProvider:()=>RK}),YZ=Z((e,t)=>{let n=J(4),r=$(XZ),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,b.jsx)(eq.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});YZ.displayName=`SuggestionPrimitive.Title`;function XZ(e){return e.suggestion.title}var ZZ=Z((e,t)=>{let n=J(4),r=$(QZ),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,b.jsx)(eq.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});ZZ.displayName=`SuggestionPrimitive.Description`;function QZ(e){return e.suggestion.label}var $Z=fq(`SuggestionPrimitive.Trigger`,e=>{let t=J(4),{send:n,clearComposer:r}=e,i=$(eQ),a;t[0]!==r||t[1]!==i||t[2]!==n?(a={prompt:i,send:n,clearComposer:r},t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3];let{trigger:o,disabled:s}=pK(a);return s?null:o},[`send`,`clearComposer`]);function eQ(e){return e.suggestion.prompt}var tQ=JK({Description:()=>ZZ,Title:()=>YZ,Trigger:()=>$Z}),nQ=Z((e,t)=>{let n=J(15),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(rQ),{switchToNewThread:s}=yK(),c;n[4]===o?c=n[5]:(c=o?{"data-active":`true`,"aria-current":`true`}:null,n[4]=o,n[5]=c);let l;n[6]!==i||n[7]!==s?(l=P(i,s),n[6]=i,n[7]=s,n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==t||n[11]!==a||n[12]!==c||n[13]!==l?(u=(0,b.jsx)(eq.button,{type:`button`,...c,...a,ref:t,disabled:r,onClick:l}),n[9]=r,n[10]=t,n[11]=a,n[12]=c,n[13]=l,n[14]=u):u=n[14],u});nQ.displayName=`ThreadListPrimitive.New`;function rQ(e){return e.threads.newThreadId===e.threads.mainThreadId}var iQ=fq(`ThreadListPrimitive.LoadMore`,()=>{let{loadMore:e,disabled:t}=bK();return t?null:e}),[aQ,oQ]=M(`ThreadList`),sQ=aQ,cQ=HN(null),lQ=cQ.Provider,uQ=()=>WN(cQ),dQ=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,b.jsx)(sQ.Provider,{scope:void 0,children:(0,b.jsx)(sQ.Slot,{scope:void 0,children:(0,b.jsx)(eq.div,{...e,ref:t})})}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});dQ.displayName=`ThreadListPrimitive.Root`;var fQ=JK({ItemByIndex:()=>yG,Items:()=>xG,LoadMore:()=>iQ,New:()=>nQ,Root:()=>dQ}),pQ=Z((e,t)=>{let n=$(e=>e.threads.mainThreadId===e.threadListItem.id),r=Y(null),i=Y(null),a=ON(()=>({triggerRef:r,moreRef:i}),[]),o=oQ(void 0),s=ct(),c=e=>{let t=s===`rtl`?`ArrowLeft`:`ArrowRight`,n=s===`rtl`?`ArrowRight`:`ArrowLeft`,a=r.current,c=i.current;if(a&&e.target===a){if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=o().map(e=>e.ref.current).filter(e=>e!==null),n=t[t.indexOf(a)+(e.key===`ArrowDown`?1:-1)];n&&(n.focus(),e.preventDefault())}else e.key===t&&c&&(c.focus(),e.preventDefault())}else c&&e.target===c&&e.key===n&&(a?.focus(),e.preventDefault())};return(0,b.jsx)(lQ,{value:a,children:(0,b.jsx)(eq.div,{...n?{"data-active":`true`,"aria-current":`true`}:null,...e,onKeyDown:P(e.onKeyDown,c),ref:t})})});pQ.displayName=`ThreadListItemPrimitive.Root`;var mQ=fq(`ThreadListItemPrimitive.Archive`,()=>{let{archive:e}=hK();return e}),hQ=fq(`ThreadListItemPrimitive.Unarchive`,()=>{let{unarchive:e}=_K();return e}),gQ=fq(`ThreadListItemPrimitive.Delete`,()=>{let{delete:e}=gK();return e}),_Q=fq(`ThreadListItemPrimitive.Trigger`,()=>{let{switchTo:e}=vK();return e}),vQ=Z((e,t)=>{let n=J(3),r=uQ(),i=u(t,r?.triggerRef),a;return n[0]!==e||n[1]!==i?(a=(0,b.jsx)(sQ.ItemSlot,{scope:void 0,children:(0,b.jsx)(_Q,{...e,ref:i})}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});vQ.displayName=`ThreadListItemPrimitive.Trigger`;var yQ=JK({Archive:()=>mQ,Delete:()=>gQ,Root:()=>pQ,Title:()=>wG,Trigger:()=>vQ,Unarchive:()=>hQ}),bQ=ul(),xQ=HN(()=>{}),SQ=()=>WN(xQ),CQ=HN(!1),wQ=()=>WN(CQ),TQ=e=>{let t=J(26),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({__scopeThreadListItemMore:n,open:o,defaultOpen:r,onOpenChange:a,sharedFocusGroup:c,modal:i,...s}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c!==void 0&&c,u=l?!1:i??!0,d=bQ(n),f=r??!1,p;t[8]===a?p=t[9]:(p=a?{onChange:a}:{},t[8]=a,t[9]=p);let m;t[10]!==o||t[11]!==f||t[12]!==p?(m={prop:o,defaultProp:f,caller:`ThreadListItemMorePrimitive.Root`,...p},t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13];let[h,g]=Te(m),_;t[14]!==u||t[15]!==h||t[16]!==s||t[17]!==d||t[18]!==g?(_=(0,b.jsx)(Ml,{...d,...s,modal:u,open:h,onOpenChange:g}),t[14]=u,t[15]=h,t[16]=s,t[17]=d,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==g||t[21]!==_?(v=(0,b.jsx)(xQ.Provider,{value:g,children:_}),t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;return t[23]!==l||t[24]!==v?(y=(0,b.jsx)(CQ.Provider,{value:l,children:v}),t[23]=l,t[24]=v,t[25]=y):y=t[25],y};TQ.displayName=`ThreadListItemMorePrimitive.Root`;var EQ=Z((e,t)=>{let n=J(10),{__scopeThreadListItemMore:r,...i}=e,a=bQ(r),o=uQ(),s=SQ(),c=wQ(),l=u(t,o?.moreRef),d=ct()===`rtl`?`ArrowLeft`:`ArrowRight`,f=Mq,p;n[0]!==d||n[1]!==s||n[2]!==c?(p=e=>{c&&e.key===d&&(e.preventDefault(),s(!0))},n[0]=d,n[1]=s,n[2]=c,n[3]=p):p=n[3];let m=P(i.onKeyDown,p),h;return n[4]!==f||n[5]!==l||n[6]!==i||n[7]!==a||n[8]!==m?(h=(0,b.jsx)(f,{...a,...i,onKeyDown:m,ref:l}),n[4]=f,n[5]=l,n[6]=i,n[7]=a,n[8]=m,n[9]=h):h=n[9],h});EQ.displayName=`ThreadListItemMorePrimitive.Trigger`;var DQ=Z((e,t)=>{let n=J(21),{__scopeThreadListItemMore:r,portalProps:i,sideOffset:a,...o}=e,s=a===void 0?4:a,c=bQ(r),l=SQ(),u=uQ(),d=wQ(),f=ct()===`rtl`?`ArrowRight`:`ArrowLeft`,p=al,m=Nq,h;n[0]!==f||n[1]!==u?.moreRef||n[2]!==l||n[3]!==d?(h=e=>{d&&e.key===f&&(e.preventDefault(),l(!1),u?.moreRef.current?.focus())},n[0]=f,n[1]=u?.moreRef,n[2]=l,n[3]=d,n[4]=h):h=n[4];let g=P(o.onKeyDown,h),_;n[5]!==u?.moreRef||n[6]!==d?(_=()=>{d&&u?.moreRef.current?.focus()},n[5]=u?.moreRef,n[6]=d,n[7]=_):_=n[7];let v=P(o.onEscapeKeyDown,_),y;n[8]!==m||n[9]!==t||n[10]!==o||n[11]!==c||n[12]!==s||n[13]!==g||n[14]!==v?(y=(0,b.jsx)(m,{...c,...o,onKeyDown:g,onEscapeKeyDown:v,ref:t,sideOffset:s}),n[8]=m,n[9]=t,n[10]=o,n[11]=c,n[12]=s,n[13]=g,n[14]=v,n[15]=y):y=n[15];let x;return n[16]!==i||n[17]!==c||n[18]!==p.Portal||n[19]!==y?(x=(0,b.jsx)(p.Portal,{...c,...i,children:y}),n[16]=i,n[17]=c,n[18]=p.Portal,n[19]=y,n[20]=x):x=n[20],x});DQ.displayName=`ThreadListItemMorePrimitive.Content`;var OQ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=bQ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(Pq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});OQ.displayName=`ThreadListItemMorePrimitive.Item`;var kQ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=bQ(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,b.jsx)(Fq,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});kQ.displayName=`ThreadListItemMorePrimitive.Separator`;var AQ=JK({Content:()=>DQ,Item:()=>OQ,Root:()=>TQ,Separator:()=>kQ,Trigger:()=>EQ}),jQ=(e,t)=>{let n=J(5),r=Y(null),i=Y(null),a,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>()=>{i.current?.()},o=[],n[0]=a,n[1]=o):(a=n[0],o=n[1]),X(a,o);let s;return n[2]!==e||n[3]!==t?(s=()=>{i.current?.(),(function(){if(r.current||!e.current)return;let t=e.current;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`scroll`||e===`auto`){r.current=t;break}t=t.parentElement}})();let n=r.current;if(!n)return;let a=n.scrollTop,o=n.style.scrollbarWidth,s=getComputedStyle(n),c=s.direction===`rtl`?`paddingLeft`:`paddingRight`,l=n.style[c],u=n.offsetWidth-n.clientWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.borderRightWidth),d=n.ownerDocument,f=(n===d.documentElement||n===d.body)&&u<=0?(d.defaultView?.innerWidth??0)-d.documentElement.clientWidth:u;n.style.scrollbarWidth=`none`,f>0&&(n.style[c]=`${parseFloat(s[c])+f}px`);let p=()=>{n.style.scrollbarWidth=o,n.style[c]=l},m=()=>n.scrollTop=a;n.addEventListener(`scroll`,m);let h=setTimeout(()=>{n.removeEventListener(`scroll`,m),p(),i.current=null},t);i.current=()=>{clearTimeout(h),n.removeEventListener(`scroll`,m),p()}},n[2]=e,n[3]=t,n[4]=s):s=n[4],s},MQ=()=>{let e=J(3),t=$(NQ),n=$(PQ),r=t!==void 0&&t.completedAt===void 0&&n,[i,a]=EN(FQ),o,s;if(e[0]===r?(o=e[1],s=e[2]):(o=()=>{if(!r)return;a(Date.now());let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},s=[r],e[0]=r,e[1]=o,e[2]=s),X(o,s),t!==void 0){if(t.completedAt!==void 0)return Math.max(0,t.completedAt-t.startedAt);if(r)return Math.max(0,i-t.startedAt)}};function NQ(e){let t=e.optional.part;return t?.type===`tool-call`?t.timing:void 0}function PQ(e){let t=e.optional.part;return t?.type===`tool-call`&&t.status.type===`running`}function FQ(){return Date.now()}var IQ=JK({AssistantRuntimeImpl:()=>lH,BaseAssistantRuntimeCore:()=>mH,CompositeContextProvider:()=>GI,DefaultThreadComposerRuntimeCore:()=>LH,MessageRepository:()=>TH,ThreadRuntimeImpl:()=>$V,getAutoStatus:()=>VB,splitLocalRuntimeOptions:()=>SK,useComposerInputPluginRegistryOptional:()=>aJ,useSmooth:()=>hX,useSmoothStatus:()=>cX,withSmoothContextProvider:()=>oX}),LQ=(e,t)=>`${e}:${t}`,RQ=e=>({id:e,status:`idle`}),zQ=e=>({threadId:e,metadata:RQ(e),messages:[],streamingMessageIndex:void 0,toolExecutions:{},runStatus:`idle`,queue:{steering:[],followUp:[]},contextUsage:void 0,compaction:{active:!1},retry:{active:!1,attempt:0},hostUiRequests:[],readiness:void 0,lastError:void 0,loadState:`pending`,lastSeq:0}),BQ=e=>e?.role===`assistant`,VQ=(e,t)=>e.status===t?e:{...e,status:t},HQ=(e,t,n)=>e.compactionActive===t.active&&e.retryActive===n.active&&e.retryAttempt===n.attempt?e:{...e,compactionActive:t.active,retryActive:n.active,retryAttempt:n.attempt},UQ=(e,t)=>{let n=t.metadata.status===`running`?`running`:t.metadata.status===`failed`?`failed`:`idle`,r=n!==`running`,i=t.seq!==void 0&&t.seq<e.lastSeq,a=t.metadata.compactionActive??(!r&&e.compaction.active),o=t.metadata.retryActive??(!r&&e.retry.active),s=i?e.compaction:a?{...e.compaction,active:!0}:{active:!1},c=i?e.retry:o?{active:!0,attempt:t.metadata.retryAttempt??e.retry.attempt}:{active:!1,attempt:0};return{...e,metadata:HQ(t.metadata,s,c),messages:t.messages,streamingMessageIndex:void 0,toolExecutions:{},runStatus:n,compaction:s,retry:c,queue:{steering:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`steer`).map(e=>e.content),followUp:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`followUp`).map(e=>e.content)},contextUsage:t.metadata.contextUsage??e.contextUsage,hostUiRequests:t.hostUiRequests??[],readiness:t.readiness??e.readiness,lastError:t.lastError,loadState:`loaded`}},WQ=(e,t,n)=>{let r=e.slice();return r[t]=n,r},GQ=(e,t,n)=>({...e,toolExecutions:{...e.toolExecutions,[t]:{toolCallId:t,status:`running`,...e.toolExecutions[t],...n}}}),KQ=(e,t)=>e.hostUiRequests.some(e=>e.id===t)?{...e,hostUiRequests:e.hostUiRequests.filter(e=>e.id!==t)}:e,qQ=(e,t)=>{if(t.type!==`snapshot`&&t.type!==`error`&&t.seq<=e.lastSeq)return e;let n=n=>n===e&&t.seq<=e.lastSeq?n:{...n,lastSeq:Math.max(e.lastSeq,t.seq)};switch(t.type){case`snapshot`:return n(UQ(e,t.snapshot));case`agent_start`:return n({...e,runStatus:`running`,lastError:void 0,metadata:VQ(e.metadata,`running`)});case`agent_end`:{let r=t.willRetry===!0;return n({...e,runStatus:r?`running`:`idle`,streamingMessageIndex:void 0,metadata:VQ(e.metadata,r?`running`:`idle`)})}case`message_start`:{let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:BQ(t.message)?r.length-1:e.streamingMessageIndex})}case`message_update`:{if(e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length)return n({...e,messages:WQ(e.messages,e.streamingMessageIndex,t.message)});let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:r.length-1})}case`message_end`:return e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length?n({...e,messages:WQ(e.messages,e.streamingMessageIndex,t.message),streamingMessageIndex:void 0}):n({...e,streamingMessageIndex:void 0});case`tool_execution_start`:return n(GQ(e,t.toolCallId,{toolName:t.toolName,args:t.args,status:`running`}));case`tool_execution_update`:return n(GQ(e,t.toolCallId,{...t.toolName===void 0?{}:{toolName:t.toolName},partialResult:t.partialResult,status:`running`}));case`tool_execution_end`:return n(GQ(e,t.toolCallId,{partialResult:t.result,status:t.isError?`error`:`complete`}));case`queue_update`:return n({...e,queue:{steering:t.steering,followUp:t.followUp}});case`compaction_start`:{let r={active:!0,reason:t.reason};return n({...e,compaction:r,metadata:HQ(e.metadata,r,e.retry)})}case`compaction_end`:{let t={active:!1};return n({...e,compaction:t,metadata:HQ(e.metadata,t,e.retry)})}case`auto_retry_start`:{let r={active:!0,attempt:t.attempt};return n({...e,retry:r,metadata:HQ(e.metadata,e.compaction,r)})}case`auto_retry_end`:{let t={active:!1,attempt:0};return n({...e,retry:t,metadata:HQ(e.metadata,e.compaction,t)})}case`context_usage`:return n({...e,contextUsage:t.contextUsage});case`session_info_changed`:{let r={...e.metadata};return t.name===void 0?delete r.title:r.title=t.name,n({...e,metadata:r})}case`thinking_level_changed`:return n({...e,metadata:{...e.metadata,config:{...e.metadata.config,thinkingLevel:t.level}}});case`extension_ui_request`:return e.hostUiRequests.some(e=>e.id===t.request.id)?n(e):n({...e,hostUiRequests:[...e.hostUiRequests,t.request]});case`extension_ui_resolved`:return n(KQ(e,t.requestId));case`error`:return n({...e,lastError:t.error,runStatus:`failed`,metadata:VQ(e.metadata,`failed`)});case`agent_settled`:case`entry_appended`:return n(e);default:return n(e)}},JQ=e=>{let t=new Map,n=[];for(let r of e)r.toolCallId!==void 0&&XQ(r)?t.has(r.toolCallId)?n.push(r):t.set(r.toolCallId,r):n.push(r);return{toolAssociated:t,freeStanding:n}},YQ=(e,t)=>({requestId:e,confirmed:t}),XQ=e=>{switch(e.kind){case`confirm`:return{id:e.id,prompt:`${e.title}\n${e.message}`};case`select`:return e.options.length===0?void 0:{id:e.id,prompt:e.title,display:`select`,options:e.options.map((e,t)=>({id:String(t),kind:`_${t}`,label:e}))};case`input`:case`editor`:return{id:e.id,prompt:e.title,display:`text`}}},ZQ=(e,t)=>{if(e.kind===`confirm`)return YQ(e.id,t.approved);if(!t.approved)return{requestId:e.id,dismissed:!0};let n=e.kind===`select`?e.options.find((e,n)=>String(n)===t.optionId):t.text;if(n===void 0)throw Error(`Pi ${e.kind} request "${e.id}" was not answered with ${e.kind===`select`?`one of its options`:`text`}`);return{requestId:e.id,value:n}},QQ=e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(e.dismissed)return;if(typeof e.value==`string`)return e.value}},$Q=(e,t)=>{let n=QQ(t);return n===void 0?{requestId:e,dismissed:!0}:{requestId:e,value:n}};function e$(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}function t$(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var n$=e=>`pi-msg:${e}`,r$=e=>`pi-step:${e}`,i$=(e,t)=>/^data:/i.test(e)?e:`data:${t};base64,${e}`,a$=e=>new Date(typeof e.timestamp==`number`?e.timestamp:0),o$=e=>{if(!e)return{};let t=e.filter(e=>e.type===`text`).map(e=>e.text).join(``);return e.every(e=>e.type===`text`)?{result:t}:{result:t,modelContent:e.flatMap(e=>{if(e.type===`text`)return[{type:`text`,text:e.text}];let t=e$(e.data);return[{type:`file`,data:t?.data??e.data,mediaType:t?.mimeType??e.mimeType}]})}},s$=e=>{if(e==null)return;let t=e.content;if(Array.isArray(t))return t.filter(e=>typeof e==`object`&&!!e&&(e.type===`text`&&typeof e.text==`string`||e.type===`image`&&typeof e.data==`string`&&typeof e.mimeType==`string`))},c$=e=>typeof e==`string`?[{type:`text`,text:e}]:e.map(e=>e.type===`image`?{type:`image`,image:i$(e.data,e.mimeType)}:{type:`text`,text:e.text}),l$=(e,t)=>({type:`data`,name:e,data:t}),u$=e=>{let t=new Map;for(let n of e){if(n.role!==`toolResult`)continue;let e=n;t.set(e.toolCallId,{...o$(s$({content:e.content})),isError:e.isError,details:e.details})}return t},d$=(e,t,n,r,i,a)=>{let o=r$(n);e.lastAssistant=t,e.steps.push({messageId:o,usage:{inputTokens:t.usage?.input??0,outputTokens:t.usage?.output??0}});for(let n of t.content)if(n.type===`text`)e.parts.push({type:`text`,text:n.text,parentId:o});else if(n.type===`thinking`){let t=n.thinking||(n.redacted?`[reasoning redacted]`:``);e.parts.push({type:`reasoning`,text:t,parentId:o})}else if(n.type===`toolCall`){let t=i.get(n.id),s=r.toolExecutions[n.id],c=t??o$(s$(s?.partialResult)),l=t?.isError??s?.status===`error`,u=a.get(n.id),d=u&&XQ(u),f={type:`tool-call`,toolCallId:n.id,toolName:n.name,args:n.arguments??{},argsText:JSON.stringify(n.arguments??{}),parentId:o,...c.result===void 0?{}:{result:c.result},...c.modelContent===void 0?{}:{modelContent:c.modelContent},...l?{isError:!0}:{},...d?{approval:d}:{}};d&&(e.hasPendingHostUi=!0),e.parts.push(f)}},f$=(e,t,n)=>{let r=e.lastAssistant,i=p$(e,t,n);return{id:n$(e.firstIndex),role:`assistant`,createdAt:a$(r),content:e.parts,...i?{status:i}:{},metadata:{steps:e.steps,custom:{pi:{provider:r.provider,model:r.model,api:r.api,usage:r.usage,stopReason:r.stopReason,...r.errorMessage?{errorMessage:r.errorMessage}:{}}}}}},p$=(e,t,n)=>{if(e.hasPendingHostUi)return{type:`requires-action`,reason:`interrupt`};let r=e.lastAssistant;return t.runStatus===`running`&&n&&r.stopReason!==`error`&&r.stopReason!==`aborted`?{type:`running`}:r.stopReason===`error`?{type:`incomplete`,reason:`error`,...r.errorMessage?{error:r.errorMessage}:{}}:r.stopReason===`aborted`?{type:`incomplete`,reason:`cancelled`}:r.stopReason===`length`?{type:`incomplete`,reason:`length`}:{type:`complete`,reason:`stop`}},m$=e=>{let{messages:t}=e,n=u$(t),r=JQ(e.hostUiRequests).toolAssociated,i=[],a=null,o=t=>{a&&=(i.push(f$(a,e,t)),null)};return t.forEach((s,c)=>{let l=c===t.length-1;switch(s.role){case`assistant`:a||={firstIndex:c,parts:[],steps:[],lastAssistant:s,hasPendingHostUi:!1},d$(a,s,c,e,n,r),l&&o(!0);break;case`toolResult`:break;case`user`:o(!1),i.push({id:n$(c),role:`user`,createdAt:a$(s),content:c$(s.content)});break;case`bashExecution`:{o(!1);let e=s;i.push(h$(c,e,`pi-bash-execution`,{command:e.command,output:e.output,exitCode:e.exitCode,cancelled:e.cancelled,truncated:e.truncated,fullOutputPath:e.fullOutputPath}));break}case`custom`:{o(!1);let e=s;if(!e.display)break;i.push({id:n$(c),role:`assistant`,createdAt:a$(e),content:[l$(`pi-custom-message`,{customType:e.customType,details:e.details}),...c$(e.content)]});break}case`branchSummary`:{o(!1);let e=s;i.push(h$(c,e,`pi-branch-summary`,{summary:e.summary,fromId:e.fromId}));break}case`compactionSummary`:{o(!1);let e=s;i.push(h$(c,e,`pi-compaction-summary`,{summary:e.summary,tokensBefore:e.tokensBefore}));break}default:o(!1),i.push(h$(c,s,`pi-unsupported-message`,{role:s.role,message:s}))}}),o(!0),i},h$=(e,t,n,r)=>({id:n$(e),role:`assistant`,createdAt:a$(t),content:[l$(n,r)]}),g$=(e,t)=>e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():void 0,_$=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,v$=(e,t)=>{if(e===t)return!0;let n=g$(e,t);if(n!==void 0)return n;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!v$(e[n],t[n]))return!1;return!0}if(_$(e)||_$(t)){if(!_$(e)||!_$(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!v$(e[r],t[r]))return!1;return!0}return!1},y$=(e,t)=>e.id===t.id&&e.role===t.role&&v$(e.createdAt,t.createdAt)&&v$(e.content,t.content)&&v$(e.status,t.status)&&v$(e.metadata,t.metadata),b$=(e,t)=>{let n=e.length!==t.length,r=e.map((e,r)=>{let i=t[r];return i&&y$(e,i)?i:(n=!0,e)});return n?r:t},x$=(e,t)=>b$(m$(e),t),S$={snapshot:!0,agent_start:!0,agent_end:!0,agent_settled:!0,turn_start:!0,turn_end:!0,message_start:!0,message_update:!0,message_end:!0,tool_execution_start:!0,tool_execution_update:!0,tool_execution_end:!0,queue_update:!0,compaction_start:!0,compaction_end:!0,entry_appended:!0,auto_retry_start:!0,auto_retry_end:!0,session_info_changed:!0,thinking_level_changed:!0,context_usage:!0,extension_ui_request:!0,extension_ui_resolved:!0,error:!0},C$=e=>Object.prototype.hasOwnProperty.call(S$,e),w$=e=>e instanceof Error?e.message:String(e),T$=e=>{if(typeof globalThis.requestAnimationFrame==`function`){globalThis.requestAnimationFrame(()=>e());return}setTimeout(e,16)},E$=e=>{for(let t of e)try{t()}catch(e){console.error(`[react-pi] Listener threw an error`,e)}},D$=new Set([`snapshot`,`agent_start`,`agent_end`,`message_start`,`message_update`,`message_end`,`tool_execution_update`,`tool_execution_end`,`extension_ui_request`,`extension_ui_resolved`]),O$=new Set([`message_update`,`tool_execution_update`]),k$=new Set([`snapshot`,`agent_start`,`agent_end`,`queue_update`,`compaction_start`,`compaction_end`,`auto_retry_start`,`auto_retry_end`,`session_info_changed`,`thinking_level_changed`,`context_usage`,`extension_ui_request`,`extension_ui_resolved`,`error`]),A$=e=>{let t=/^data:([^;,]+)(?:;base64)?,(.*)$/is.exec(e);return t?{type:`image`,mimeType:t[1].toLowerCase(),data:t[2]}:{type:`image`,mimeType:`image/png`,data:e}},j$=e=>[...e.content,...e.attachments?.flatMap(e=>e.content??[])??[]],M$=(e,t)=>{let n=j$(e),r=[],i=[];for(let e of n)e.type===`text`?r.push(e.text):e.type===`image`&&i.push(A$(e.image));return{content:r.join(`
94
94
 
95
- `),...i.length>0?{attachments:i}:{},...t?{streamingBehavior:t}:{}}},S$=e=>{let t=e.runConfig?.custom?.streamingBehavior;return t===`followUp`||t===`steer`?t:void 0},C$=e=>({role:`user`,content:e.attachments&&e.attachments.length>0?[{type:`text`,text:e.content},...e.attachments]:e.content,timestamp:Date.now()}),w$=e=>{if(e.role!==`user`)return null;let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
96
- `):null},T$=e=>e.runStatus===`running`&&e.metadata.status===`running`?e:{...e,runStatus:`running`,lastError:void 0,metadata:e.metadata.status===`running`?e.metadata:{...e.metadata,status:`running`}},E$=class{state;stateSnapshot;projectedMessages=[];messageRepository=dH.fromArray([]);version=0;allListeners=new Set;metadataListeners=new Set;messageListeners=new Set;connectionRetainers=0;optimisticUserMessages=[];unsubscribeFromEvents=null;disconnectTimer=null;loadPromise=null;messageFlushScheduled=!1;localSnapshotSeq=0;client;threadId;options;constructor(e,t,n={}){this.client=e,this.threadId=t,this.options=n,this.state=OQ(t),this.stateSnapshot=this.state}getState(){return this.state}getStateSnapshot(){return this.stateSnapshot}getProjectedMessages(){return this.projectedMessages}getMessageRepository(){return this.messageRepository}getVersion(){return this.version}connect(){return this.connectionRetainers+=1,this.ensureEventSubscription({includeSnapshot:this.state.loadState!==`loaded`}),()=>{this.connectionRetainers=Math.max(0,this.connectionRetainers-1),this.maybeDisconnectFromEvents()}}subscribe(e){return this.allListeners.add(e),()=>{this.allListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMetadata(e){return this.metadataListeners.add(e),()=>{this.metadataListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMessages(e){return this.messageListeners.add(e),()=>{this.messageListeners.delete(e),this.maybeDisconnectFromEvents()}}dispose(){this.clearDisconnectTimer(),this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null,this.allListeners.clear(),this.metadataListeners.clear(),this.messageListeners.clear()}ensureEventSubscription(e){this.clearDisconnectTimer(),!this.unsubscribeFromEvents&&(this.unsubscribeFromEvents=this.client.subscribe(this.threadId,e=>{e.threadId===this.threadId&&this.dispatch(e)},e))}hasConsumers(){return this.connectionRetainers>0||this.allListeners.size>0||this.metadataListeners.size>0||this.messageListeners.size>0}maybeDisconnectFromEvents(){this.hasConsumers()||(this.disconnectTimer||=setTimeout(()=>{this.disconnectTimer=null,!this.hasConsumers()&&(this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null)},3e4))}clearDisconnectTimer(){this.disconnectTimer&&=(clearTimeout(this.disconnectTimer),null)}async load(e=!1){if(this.loadPromise&&!e)return this.loadPromise;this.setState({...this.state,loadState:`loading`});let t=this.client.getThread(this.threadId).then(e=>{this.loadPromise===t&&this.applySnapshot(e)}).catch(e=>{throw this.loadPromise===t&&this.setState({...this.state,loadState:`loaded`,lastError:p$(e)}),e}).finally(()=>{this.loadPromise===t&&(this.loadPromise=null)});return this.loadPromise=t,t}refresh(){return this.load(!0)}refreshInBackground(){this.loadPromise||this.refresh().catch(()=>{})}async sendMessage(e,t){if(e.role!==`user`)throw Error(`Pi only supports sending user messages`);let n=this.state.runStatus===`running`,r=t?.streamingBehavior??S$(e)??(n?`followUp`:void 0),i=x$(e,r);if(this.ensureEventSubscription({includeSnapshot:!1}),n)return this.sendQueued(i,r??`followUp`);let a=C$(i);this.optimisticUserMessages.push({message:a,baseMessageCount:this.state.messages.length}),this.setState(T$(this.state)),this.recomputeProjectedMessagesAndNotify();try{await this.client.sendMessage(this.threadId,i)}catch(e){let t=this.optimisticUserMessages.findIndex(e=>e.message===a);throw t!==-1&&this.optimisticUserMessages.splice(t,1),this.recomputeProjectedMessagesAndNotify(),this.setState({...this.state,lastError:p$(e),runStatus:`failed`,metadata:{...this.state.metadata,status:`failed`}}),e}}async sendQueued(e,t){let n=t===`steer`?`steering`:`followUp`,r={...this.state.queue,[n]:[...this.state.queue[n],e.content]};this.setState({...this.state,queue:r});try{await this.client.sendMessage(this.threadId,e)}catch(t){let i=this.state.queue!==r,a=this.state.queue[n],o=i?-1:a.lastIndexOf(e.content);throw this.setState({...this.state,lastError:p$(t),...o===-1?{}:{queue:{...this.state.queue,[n]:a.filter((e,t)=>t!==o)}}}),t}}async clearQueue(){let e=this.state.queue,t=await this.client.clearQueue(this.threadId);return this.state.queue===e&&(e.steering.length>0||e.followUp.length>0)&&this.setState({...this.state,queue:{steering:[],followUp:[]}}),t}async cancel(){try{await this.client.cancelRun(this.threadId)}catch(e){throw this.setState({...this.state,lastError:p$(e)}),e}}async setModel(e){try{await this.client.setModel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:p$(e)}),e}await this.refresh()}async setThinkingLevel(e){try{await this.client.setThinkingLevel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:p$(e)}),e}await this.refresh()}async respondToToolApproval(e,t){let n=this.state.hostUiRequests.find(t=>t.id===e);await this.respond(n?BQ(n,{approvalId:e,approved:t}):RQ(e,t))}async resumeToolCall(e,t){let n=this.state.hostUiRequests.find(t=>t.toolCallId===e);if(!n)throw Error(`No pending host-UI request for tool call "${e}"`);n.kind===`confirm`?await this.respond(RQ(n.id,t===!0)):await this.respond(HQ(n.id,t))}async respondToHostUiRequest(e){await this.respond(e)}async respond(e){try{await this.client.respondToHostUiRequest(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:p$(e)}),e}let t=FQ(this.state,e.requestId);t!==this.state&&(this.setState(t),this.recomputeProjectedMessagesAndNotify())}applySnapshot(e){this.dispatch({type:`snapshot`,snapshot:e,threadId:this.threadId,seq:this.localSnapshotSeq})}dispatch(e){let t=IQ(this.state,e),n=t!==this.state;n&&(this.state=t),this.reconcileOptimisticUserMessages(),n&&v$.has(e.type)&&this.notifyMetadataListeners(),n&&g$.has(e.type)&&(_$.has(e.type)?this.scheduleProjectedMessageFlush():this.recomputeProjectedMessagesAndNotify()),(!f$(e.type)||e.type===`entry_appended`&&e.entry?.type!==`custom`)&&this.refreshInBackground()}setState(e){e!==this.state&&(this.state=e,this.notifyMetadataListeners())}projectedInputMessages(){return[...this.state.messages,...this.optimisticUserMessages.map(e=>e.message)]}reconcileOptimisticUserMessages(){if(this.optimisticUserMessages.length===0)return;let e=[];for(let t of this.optimisticUserMessages){let n=w$(t.message);this.state.messages.slice(t.baseMessageCount).some(e=>w$(e)===n)||e.push(t)}e.length!==this.optimisticUserMessages.length&&(this.optimisticUserMessages.length=0,this.optimisticUserMessages.push(...e))}projectMessages(){return u$({messages:this.projectedInputMessages(),toolExecutions:this.state.toolExecutions,runStatus:this.state.runStatus,hostUiRequests:this.state.hostUiRequests},this.projectedMessages)}recomputeProjectedMessagesAndNotify(){let e=this.projectMessages();if(e===this.projectedMessages){this.state!==this.stateSnapshot&&this.publishState();return}this.projectedMessages=e,this.messageRepository=dH.fromArray(e),this.notifyMessageListeners()}scheduleProjectedMessageFlush(){this.messageFlushScheduled||(this.messageFlushScheduled=!0,(this.options.scheduleNotify??m$)(()=>{this.messageFlushScheduled=!1,this.recomputeProjectedMessagesAndNotify()}))}bumpVersion(){this.version+=1}publishState(){this.stateSnapshot=this.state,this.bumpVersion(),h$(this.allListeners)}notifyMetadataListeners(){this.stateSnapshot=this.state,this.bumpVersion(),h$(this.metadataListeners),h$(this.allListeners)}notifyMessageListeners(){this.stateSnapshot=this.state,this.bumpVersion(),h$(this.messageListeners),h$(this.allListeners)}},D$=e=>{let t=Symbol(`${e} extras`),n=e=>typeof e==`object`&&!!e&&t in e;return{provide:e=>(Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0}),e),is:n,tryGet:e=>n(e)?e:void 0,assert:t=>{if(!n(t))throw Error(`The current thread is not backed by the ${e} runtime.`);return t}}},O$=e=>{let{provide:t,is:n,tryGet:r,assert:i}=e,a=e=>i(e.thread.getState().extras);function o(e,...t){let r=t.length>0,a=t[0];return $(t=>{let o=t.thread.extras;return n(o)?e?e(o):o:r?a:i(o)})}return{provide:t,is:n,tryGet:r,get:a,use:o}},k$=(e=>O$(D$(e)))(`usePiRuntime`),A$=OQ(`__pending__`),j$=[],M$=dH.fromArray([]),N$=e=>{let t=new Map,n=!1;return{client:e,controllers:t,get disposed(){return n},activate(){n=!1},dispose(){n=!0;for(let e of t.values())e.dispose()}}},P$=(e,t)=>{let n=e.controllers.get(t);if(n)return n;let r=new E$(e.client,t);return e.controllers.set(t,r),r},F$={getState:()=>A$,getProjectedMessages:()=>j$,getMessageRepository:()=>M$,getVersion:()=>0,subscribe:()=>()=>{},subscribeMetadata:()=>()=>{},subscribeMessages:()=>()=>{},connect:()=>()=>{},load:async()=>{},refresh:async()=>{},sendMessage:async()=>{},cancel:async()=>{},clearQueue:async()=>({steering:[],followUp:[]}),setModel:async()=>{},setThinkingLevel:async()=>{},respondToToolApproval:async()=>{},resumeToolCall:async()=>{},respondToHostUiRequest:async()=>{},dispose:()=>{}},I$=(e,t)=>{WQ(`react-pi`,`onError`,e,t)},L$=(e,t)=>{let{freeStanding:n}=LQ(t.hostUiRequests);return k$.provide({controller:e,state:t,metadata:t.metadata,status:t.runStatus===`failed`?`failed`:t.runStatus,readiness:t.readiness,contextUsage:t.contextUsage,hostUiRequests:n,allHostUiRequests:t.hostUiRequests,queue:t.queue,compaction:t.compaction,retry:t.retry,lastError:t.lastError,cancel:()=>e.cancel(),refresh:()=>e.refresh(),clearQueue:()=>e.clearQueue(),setModel:t=>e.setModel(t),setThinkingLevel:t=>e.setThinkingLevel(t),respondToHostUiRequest:t=>e.respondToHostUiRequest(t),respondToToolApproval:(t,n)=>e.respondToToolApproval(t,n),resumeToolCall:(t,n)=>e.resumeToolCall(t,n)})},R$=L$(F$,A$),z$=e=>e.getStateSnapshot?.()??e.getState(),B$=e=>{let t=(0,y.useCallback)(()=>z$(e),[e]);return(0,y.useSyncExternalStore)((0,y.useCallback)(t=>e.subscribe(t),[e]),t,t)},V$=e=>{let t=(0,y.useCallback)(()=>e.getMessageRepository(),[e]);return(0,y.useSyncExternalStore)((0,y.useCallback)(t=>e.subscribeMessages(t),[e]),t,t)},H$=(e,t)=>{let n=(0,y.useMemo)(()=>{let n;return()=>{let r=z$(e);return(!n||n.state!==r)&&(n={state:r,selection:t(r)}),n.selection}},[e,t]);return(0,y.useSyncExternalStore)((0,y.useCallback)(t=>e.subscribe(t),[e]),n,n)},U$=e=>e.runStatus===`running`||e.compaction.active||e.retry.active,W$=(e,t)=>{let n=B$(e),r=V$(e),{adapters:i,isDisabled:a,isSendDisabled:o,onError:s,suggestions:c,unstable_capabilities:l}=t,u=n.loadState===`loading`,d=U$(n),f=(0,y.useEffectEvent)(e=>{I$(s,e)});(0,y.useEffect)(()=>{e!==F$&&e.load().catch(f)},[e]),(0,y.useEffect)(()=>{if(e!==F$&&d)return e.connect()},[e,d]);let p=(0,y.useMemo)(()=>L$(e,n),[e,n]),m=(0,y.useMemo)(()=>({items:n.queue.followUp.map((e,t)=>({id:EQ(`followUp`,t),prompt:e,parts:[{type:`text`,text:e}]})),steerItems:n.queue.steering.map((e,t)=>({id:EQ(`steer`,t),prompt:e,parts:[{type:`text`,text:e}]})),enqueue:t=>{e.sendMessage(t).catch(e=>I$(s,e))},steer:t=>{e.sendMessage(t,{streamingBehavior:`steer`}).catch(e=>I$(s,e))},move:()=>{},edit:()=>{},remove:()=>{}}),[e,n.queue,s]);return(0,y.useMemo)(()=>({isDisabled:a,isSendDisabled:o,unstable_capabilities:l,suggestions:c,isLoading:u,isRunning:d,messageRepository:r,extras:p,queue:m,...i?{adapters:i}:{},onNew:async t=>{try{await e.sendMessage(t)}catch(e){throw I$(s,e),e}},onCancel:async()=>{try{try{await e.clearQueue()}finally{await e.cancel()}}catch(e){throw I$(s,e),e}},onRespondToToolApproval:async t=>{try{let n=e.getState().hostUiRequests.find(e=>e.id===t.approvalId);if(!n)throw Error(`No pending host-UI request "${t.approvalId}"`);await e.respondToHostUiRequest(BQ(n,t))}catch(e){throw I$(s,e),e}},onResumeToolCall:({toolCallId:t,payload:n})=>{e.resumeToolCall(t,n).catch(e=>I$(s,e))}}),[e,p,r,m,i,a,u,d,o,s,c,l])},G$=(e,t)=>({id:`pi-new-user:${t}`,role:`user`,createdAt:new Date,content:b$(e)}),K$=(e,t)=>{let n=Q(),{adapters:r,isDisabled:i,isSendDisabled:a,onError:o,suggestions:s,unstable_capabilities:c}=t,[l,u]=(0,y.useState)([]),d=(0,y.useRef)(0),f=(0,y.useMemo)(()=>dH.fromArray(l),[l]);return(0,y.useMemo)(()=>({isDisabled:i??!1,isSendDisabled:a,unstable_capabilities:c,suggestions:s,isLoading:!1,isRunning:!1,messageRepository:f,extras:R$,...r?{adapters:r}:{},onNew:async t=>{let r=G$(t,d.current++);u(e=>[...e,r]);let i=()=>{u(e=>e.filter(e=>e!==r))};try{let{remoteId:r,externalId:a}=await n.threadListItem.initialize();if(e.disposed){i();return}await P$(e,a??r).sendMessage(t),i()}catch(e){throw i(),I$(o,e),e}}}),[n,f,e,r,i,a,o,s,c])},q$=(e,t)=>{let n=$(e=>e.threadListItem),r=$(e=>e.threads.mainThreadId===e.threadListItem.id),i=n.externalId??n.remoteId,a=i?P$(e,i):F$,o=W$(r?a:F$,t),s=K$(e,t);return VH(i?o:s)},J$=e=>({status:e.archived?`archived`:`regular`,remoteId:e.id,externalId:e.id,...e.title===void 0?{}:{title:e.title},custom:{status:e.status,...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.sessionFile===void 0?{}:{sessionFile:e.sessionFile},...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath}}}),Y$=e=>{let{client:t}=e,n=(0,y.useMemo)(()=>N$(t),[t]);return(0,y.useEffect)(()=>(n.activate(),()=>n.dispose()),[n]),jU({allowNesting:!0,adapter:(0,y.useMemo)(()=>({list:async()=>({threads:(await t.listThreads({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.includeArchived===void 0?{}:{includeArchived:e.includeArchived}})).map(J$)}),rename:async(e,n)=>{await t.renameThread(e,n)},archive:async e=>{await t.archiveThread?.(e)},unarchive:async e=>{await t.unarchiveThread?.(e)},delete:async e=>{await t.deleteThread?.(e)},initialize:async()=>{let n=await t.createThread({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath}});return{remoteId:n.metadata.id,externalId:n.metadata.id}},generateTitle:async()=>new ReadableStream({start(e){e.close()}}),fetch:async e=>J$((await t.getThread(e)).metadata)}),[t,e.workspacePath,e.includeArchived]),...e.initialThreadId===void 0?{}:{initialThreadId:e.initialThreadId},...e.threadId===void 0?{}:{threadId:e.threadId},...e.onThreadIdChange===void 0?{}:{onThreadIdChange:e.onThreadIdChange},runtimeHook:()=>q$(n,e)})},X$=()=>k$.use(e=>e,R$),Z$=()=>k$.use(e=>e.metadata,null);function Q$(e){return H$(k$.use(e=>e.controller,F$),e??(e=>e))}var $$=()=>{let e=k$.use(e=>e,void 0);return(0,y.useMemo)(()=>({requests:e?.hostUiRequests??[],respond:e?.respondToHostUiRequest??(async()=>{throw Error(`Pi runtime is not ready yet`)})}),[e])};function e1({delayDuration:e=0,...t}){return(0,b.jsx)(Du,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function t1({...e}){return(0,b.jsx)(Ou,{"data-slot":`tooltip`,...e})}function n1({...e}){return(0,b.jsx)(ku,{"data-slot":`tooltip-trigger`,...e})}function r1({className:e,sideOffset:t=0,children:n,...r}){return(0,b.jsx)(Au,{children:(0,b.jsxs)(ju,{"data-slot":`tooltip-content`,sideOffset:t,className:a(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,b.jsx)(Mu,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function i1({...e}){return(0,b.jsx)(wr,{"data-slot":`dialog`,...e})}function a1({...e}){return(0,b.jsx)(Er,{"data-slot":`dialog-trigger`,...e})}function o1({...e}){return(0,b.jsx)(Ar,{"data-slot":`dialog-portal`,...e})}function s1({className:e,...t}){return(0,b.jsx)(Mr,{"data-slot":`dialog-overlay`,className:a(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function c1({className:e,children:t,showCloseButton:n=!0,...r}){return(0,b.jsxs)(o1,{"data-slot":`dialog-portal`,children:[(0,b.jsx)(s1,{}),(0,b.jsxs)(Ir,{"data-slot":`dialog-content`,className:a(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,b.jsxs)(Gr,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,b.jsx)(mp,{}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function l1({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`dialog-header`,className:a(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function u1({className:e,showCloseButton:t=!1,children:n,...r}){return(0,b.jsxs)(`div`,{"data-slot":`dialog-footer`,className:a(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,b.jsx)(Gr,{asChild:!0,children:(0,b.jsx)(o,{variant:`outline`,children:`Close`})})]})}function d1({className:e,...t}){return(0,b.jsx)(Vr,{"data-slot":`dialog-title`,className:a(`text-lg leading-none font-semibold`,e),...t})}function f1({className:e,...t}){return(0,b.jsx)(Ur,{"data-slot":`dialog-description`,className:a(`text-sm text-muted-foreground`,e),...t})}function p1({className:e,size:t=`default`,...n}){return(0,b.jsx)(ti,{"data-slot":`avatar`,"data-size":t,className:a(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function m1({className:e,...t}){return(0,b.jsx)(ri,{"data-slot":`avatar-image`,className:a(`aspect-square size-full`,e),...t})}function h1({className:e,...t}){return(0,b.jsx)(ai,{"data-slot":`avatar-fallback`,className:a(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var g1=(0,y.forwardRef)(({children:e,tooltip:t,side:n=`bottom`,className:r,...i},s)=>(0,b.jsx)(e1,{delayDuration:0,children:(0,b.jsxs)(t1,{children:[(0,b.jsx)(n1,{asChild:!0,children:(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,...i,className:a(`aui-button-icon size-6 p-1 active:scale-90`,r),ref:s,children:[(0,b.jsx)(c,{children:e}),(0,b.jsx)(`span`,{className:`aui-sr-only sr-only`,children:t})]})}),(0,b.jsx)(r1,{side:n,children:t})]})}));g1.displayName=`TooltipIconButton`;var _1=e=>Symbol.iterator in e,v1=e=>`entries`in e,y1=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},b1=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function x1(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:_1(e)&&_1(t)?v1(e)&&v1(t)?y1(e,t):b1(e,t):y1({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function S1(e){let t=y.useRef(void 0);return n=>{let r=e(n);return x1(t.current,r)?t.current:t.current=r}}var C1=e=>{let[t,n]=(0,y.useState)(void 0);return(0,y.useEffect)(()=>{if(!e){n(void 0);return}let t=URL.createObjectURL(e);return n({file:e,url:t}),()=>{URL.revokeObjectURL(t)}},[e]),t!==void 0&&t.file===e?t.url:void 0},w1=()=>{let{file:e,src:t}=$(S1(e=>{if(e.attachment.type!==`image`)return{};if(e.attachment.file)return{file:e.attachment.file};let t=e.attachment.content?.filter(e=>e.type===`image`)[0]?.image;return t?{src:t}:{}}));return C1(e)??t},T1=({src:e})=>{let[t,n]=(0,y.useState)(!1);return(0,b.jsx)(`img`,{src:e,alt:`Attachment preview`,className:a(`block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none`,t?`aui-attachment-preview-image-loaded opacity-100`:`aui-attachment-preview-image-loading opacity-0`),onLoad:()=>n(!0)})},E1=({children:e})=>{let t=w1();return t?(0,b.jsxs)(i1,{children:[(0,b.jsx)(a1,{className:`aui-attachment-preview-trigger cursor-zoom-in`,asChild:!0,children:(0,y.isValidElement)(e)?e:(0,b.jsx)(`button`,{type:`button`,children:e})}),(0,b.jsxs)(c1,{className:`aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!`,children:[(0,b.jsx)(d1,{className:`aui-sr-only sr-only`,children:`Image Attachment Preview`}),(0,b.jsx)(`div`,{className:`aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm`,children:(0,b.jsx)(T1,{src:t})})]})]}):e},D1=()=>{let e=w1();return(0,b.jsxs)(p1,{className:`aui-attachment-tile-avatar h-full w-full rounded-none`,children:[(0,b.jsx)(m1,{src:e,alt:`Attachment preview`,className:`aui-attachment-tile-image rounded-none object-cover`}),(0,b.jsx)(h1,{children:(0,b.jsx)(Lf,{className:`aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]`})})]})},O1=()=>{let e=Q().attachment.source!==`message`,t=$(e=>e.attachment.type===`image`),n=$(e=>{let t=e.attachment.type;switch(t){case`image`:return`Image`;case`document`:return`Document`;case`file`:return`File`;default:return t}}),r=$(e=>e.attachment.status.type===`running`?`uploading`:e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?`error`:void 0),i=r===`uploading`,o=r===`error`,s=$(e=>e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?e.attachment.status.message??`Upload failed`:void 0);return(0,b.jsx)(e1,{children:(0,b.jsxs)(t1,{children:[(0,b.jsxs)(Iq.Root,{className:a(`aui-attachment-root relative`,e&&`animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none`,t&&!e&&`aui-attachment-root-message only:*:first:size-24`),children:[(0,b.jsx)(E1,{children:(0,b.jsx)(n1,{asChild:!0,children:(0,b.jsxs)(`div`,{className:a(`aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--composer-radius,1rem)-var(--composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10`,o&&`after:ring-destructive/60 dark:after:ring-destructive/60`),role:`button`,tabIndex:0,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},"aria-label":`${n} attachment${o?`, upload failed`:i?`, uploading`:``}`,children:[(0,b.jsx)(D1,{}),i&&(0,b.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,b.jsx)(Uf,{className:`text-muted-foreground size-4 animate-spin`})}),o&&(0,b.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,b.jsx)(Ef,{className:`text-destructive size-4`})})]})})}),e&&(0,b.jsx)(k1,{})]}),(0,b.jsxs)(r1,{side:`top`,children:[(0,b.jsx)(Iq.Name,{}),s&&(0,b.jsx)(`p`,{className:`aui-attachment-error-message`,children:s})]})]})})},k1=()=>(0,b.jsx)(Iq.Remove,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Remove file`,className:`aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none`,side:`top`,children:(0,b.jsx)(mp,{className:`aui-attachment-remove-icon size-3 stroke-[2.5]`})})}),A1=()=>(0,b.jsx)(`div`,{className:`aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2 empty:hidden`,children:(0,b.jsx)($X.Attachments,{children:()=>(0,b.jsx)(O1,{})})}),j1=()=>(0,b.jsx)(`div`,{className:`aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden`,children:(0,b.jsx)(VY.Attachments,{children:()=>(0,b.jsx)(O1,{})})}),M1=()=>(0,b.jsx)(VY.AddAttachment,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Add Attachment`,side:`bottom`,variant:`ghost`,size:`icon`,className:`aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none`,"aria-label":`Add Attachment`,children:(0,b.jsx)(Zf,{className:`aui-attachment-add-icon size-4`})})}),N1=v(`aui-file-root inline-flex items-center gap-3 rounded-lg transition-colors`,{variants:{variant:{outline:`border-border hover:bg-muted/50 border`,ghost:`hover:bg-muted/50`,muted:`bg-muted/50 hover:bg-muted/70`},size:{sm:`px-2.5 py-1.5 text-xs`,default:`px-3 py-2 text-sm`,lg:`px-4 py-3 text-base`}},defaultVariants:{variant:`outline`,size:`default`}});function P1(e){let t=e.toLowerCase();return t.startsWith(`image/`)?Bf:t===`application/pdf`?Lf:t===`application/json`?bf:t.startsWith(`text/`)?Lf:t.startsWith(`audio/`)?Kf:t.startsWith(`video/`)?fp:Rf}function F1(e,t){return t===`url`&&/^data:/i.test(e)?`data-uri`:t||(/^data:/i.test(e)?`data-uri`:/^https?:\/\//i.test(e)?`url`:`base64`)}function I1(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`),n=e.search(/[^A-Za-z\d+/]/);return n!==-1&&n!==e.length-t||e.length%4==1||t>0&&e.length%4!=0?0:Math.floor(e.length*3/4)-t}function L1(e){return I1(/[\t\n\f\r ]/.test(e)?e.replace(/[\t\n\f\r ]/g,``):e)}function R1(e){let t=e.indexOf(`#`),n=t<0?e.length:t,r=e.indexOf(`,`);if(r<0||r>=n)return 0;let i=e.slice(r+1,n);return/;base64$/i.test(e.slice(0,r))?(/[%\t\n\f\r ]/.test(i)&&(i=i.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16))).replace(/[\t\n\f\r ]/g,``)),I1(i)):new TextEncoder().encode(i.replace(/%[\da-f]{2}/gi,`_`)).byteLength}function z1(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function B1({className:e,variant:t,size:n,children:r,...i}){return(0,b.jsx)(`div`,{"data-slot":`file-root`,"data-variant":t,"data-size":n,className:a(N1({variant:t,size:n,className:e})),...i,children:r})}function V1({mimeType:e,className:t,children:n,...r}){let i=e?P1(e):Rf;return(0,b.jsx)(`span`,{"data-slot":`file-icon`,className:a(`text-muted-foreground shrink-0`,t),...r,children:n??(0,b.jsx)(i,{className:`size-5`})})}function H1({className:e,children:t,...n}){return(0,b.jsx)(`span`,{"data-slot":`file-name`,className:a(`min-w-0 flex-1 truncate font-medium`,e),...n,children:t||`Unnamed file`})}function U1({bytes:e,className:t,...n}){return(0,b.jsx)(`span`,{"data-slot":`file-size`,className:a(`text-muted-foreground shrink-0`,t),...n,children:z1(e)})}function W1({data:e,mimeType:t,filename:n,sourceType:r,className:i,children:o,...s}){if(typeof e!=`string`)return null;let c=F1(e,r);if(c===`id`||c===`url`&&!/^(https?:\/\/|blob:)/i.test(e))return null;let l=c===`base64`?`data:${t};base64,${e}`:e;return(0,b.jsx)(`a`,{"data-slot":`file-download`,href:l,download:n||`download`,...c===`url`&&{target:`_blank`,rel:`noopener noreferrer`},className:a(`text-muted-foreground hover:bg-accent hover:text-accent-foreground shrink-0 rounded-md p-1 transition-colors`,i),"aria-label":o?void 0:`Download ${n||`file`}`,...s,children:o||(0,b.jsx)(Pf,{className:`size-4`})})}var G1=(0,y.memo)(({filename:e,data:t,mimeType:n,sourceType:r})=>{let i=F1(t,r);return(0,b.jsxs)(B1,{children:[(0,b.jsx)(V1,{mimeType:n}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,b.jsx)(H1,{children:e}),typeof t==`string`&&(i===`base64`||i===`data-uri`)&&(0,b.jsx)(U1,{bytes:i===`data-uri`?R1(t):L1(t),className:`text-xs`})]}),(0,b.jsx)(W1,{data:t,mimeType:n,...e!==void 0&&{filename:e},...r!==void 0&&{sourceType:r}})]})});G1.displayName=`File`,G1.Root=B1,G1.Icon=V1,G1.Name=H1,G1.Size=U1,G1.Download=W1;var K1=()=>{let e=$(e=>e.thread.suggestions),t=(0,y.useRef)(null),n=(0,y.useRef)(null),[r,i]=(0,y.useState)({left:!1,right:!1}),a=(0,y.useCallback)(()=>{let e=t.current;if(!e)return;let r=e.scrollWidth-e.clientWidth,a=Math.abs(e.scrollLeft),[o,s]=(n.current??=getComputedStyle(e).direction===`rtl`)?[r-a,a]:[a,r-a];i(e=>{let t={left:o>1,right:s>1};return e.left===t.left&&e.right===t.right?e:t})},[]);(0,y.useEffect)(()=>{a();let e=t.current;if(!e?.firstElementChild)return;let n=new ResizeObserver(a);return n.observe(e),n.observe(e.firstElementChild),()=>n.disconnect()},[a]);let o=`linear-gradient(to right, ${r.left?`transparent, black 2rem`:`black`}, ${r.right?`black calc(100% - 2rem), transparent`:`black`})`;return(0,b.jsx)(`div`,{ref:t,onScroll:a,className:`aui-thread-followup-suggestions -my-1 w-full [scrollbar-width:none] overflow-x-auto py-1 [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,style:{maskImage:o,WebkitMaskImage:o},children:(0,b.jsx)(`div`,{className:`mx-auto flex min-h-8 w-max items-center gap-2 px-0.5`,children:e.map((e,t)=>(0,b.jsxs)(LZ.Suggestion,{className:`aui-thread-followup-suggestion border-foreground/10 hover:bg-foreground/[0.03] hover:border-foreground/25 rounded-md border px-2.5 py-1 text-sm whitespace-nowrap transition-colors ease-in motion-reduce:transition-none`,prompt:e.prompt,send:!0,children:[e.title??e.prompt,e.label&&(0,b.jsx)(`span`,{className:`aui-thread-followup-suggestion-label text-muted-foreground ms-1`,children:e.label})]},t))})})},q1=()=>(0,b.jsx)(zL,{condition:e=>!e.thread.isEmpty&&!e.thread.isRunning&&e.thread.suggestions.length>0,children:(0,b.jsx)(K1,{})}),J1=e=>{switch(e){case`image/png`:return`png`;case`image/jpeg`:case`image/jpg`:return`jpg`;case`image/webp`:return`webp`;case`image/gif`:return`gif`;case`image/svg+xml`:return`svg`;default:return`png`}},Y1=e=>{let t=e.indexOf(`,`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``,i=n.match(/data:([^;]+)/i)?.[1]?.toLowerCase()??`application/octet-stream`;if(!/;base64/i.test(n)){let e=r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURIComponent(e)}catch{return e}});return new Blob([e],{type:i})}let a;try{let e=r.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));a=atob(e)}catch{return null}let o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);return new Blob([o],{type:i})},X1=e=>e.match(/^data:([^;,]+)/i)?.[1]?.toLowerCase(),Z1=e=>{if(typeof document>`u`)return;let t=J1(X1(e.image)),n=e.filename??`image.${t}`,r=/^data:/i.test(e.image),i=r?Y1(e.image):null;if(r&&!i)return;let a=i?URL.createObjectURL(i):null,o=a??e.image,s=document.createElement(`a`);s.href=o,s.download=n,s.rel=`noopener`,document.body.appendChild(s),s.click(),document.body.removeChild(s),a&&setTimeout(()=>URL.revokeObjectURL(a),4e4)},Q1=async e=>{if(typeof navigator>`u`||!navigator.clipboard||typeof ClipboardItem>`u`)throw Error(`Clipboard API is not available in this environment.`);let t=/^data:/i.test(e.image)?Y1(e.image):await fetch(e.image).then(e=>e.blob());if(!t)return;let n=X1(e.image)??t.type??`image/png`;await navigator.clipboard.write([new ClipboardItem({[n]:t})])},$1=v(`aui-image-root relative overflow-hidden rounded-lg`,{variants:{variant:{outline:`border-border border`,ghost:``,muted:`bg-muted/50`},size:{sm:`max-w-64`,default:`max-w-96`,lg:`max-w-[512px]`,full:`w-full`}},defaultVariants:{variant:`outline`,size:`default`}});function e0({className:e,variant:t,size:n,children:r,...i}){return(0,b.jsx)(`div`,{"data-slot":`image-root`,"data-variant":t,"data-size":n,className:a($1({variant:t,size:n,className:e})),...i,children:r})}function t0({className:e,containerClassName:t,onLoad:n,onError:r,alt:i=`Image content`,src:o,...s}){let c=(0,y.useRef)(null),[l,u]=(0,y.useState)(void 0),[d,f]=(0,y.useState)(void 0),p=l===o,m=d===o;return(0,y.useEffect)(()=>{let e=c.current;typeof o==`string`&&e?.complete&&(e.naturalWidth>0?u(o):f(o))},[o]),(0,b.jsxs)(`div`,{"data-slot":`image-preview`,className:a(`relative min-h-32`,t),children:[!p&&!m&&(0,b.jsx)(`div`,{"data-slot":`image-preview-loading`,className:`bg-muted/50 absolute inset-0 flex items-center justify-center`,children:(0,b.jsx)(Bf,{className:`text-muted-foreground size-8 animate-pulse`})}),m?(0,b.jsx)(`div`,{"data-slot":`image-preview-error`,className:`bg-muted/50 flex min-h-32 items-center justify-center p-4`,children:(0,b.jsx)(zf,{className:`text-muted-foreground size-8`})}):(0,b.jsx)(`img`,{ref:c,src:o,alt:i,className:a(`block h-auto w-full object-contain`,!p&&`invisible`,e),onLoad:e=>{typeof o==`string`&&u(o),n?.(e)},onError:e=>{typeof o==`string`&&f(o),r?.(e)},...s})]})}function n0({className:e,children:t,...n}){return t?(0,b.jsx)(`span`,{"data-slot":`image-filename`,className:a(`text-muted-foreground block truncate px-2 py-1.5 text-xs`,e),...n,children:t}):null}function r0({src:e,alt:t=`Image preview`,children:n}){let[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(null),o=(0,y.useRef)(null),s=(0,y.useRef)(null),c=(0,y.useCallback)(()=>i(!0),[]),l=(0,y.useCallback)(()=>{i(!1),a.current?.focus()},[]);return(0,y.useEffect)(()=>{if(!r)return;let e=e=>{if(e.key===`Escape`){l();return}if(e.key!==`Tab`)return;let t=s.current?.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`),n=t?.[0],r=t?.[t.length-1];n&&r&&(e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r,l]),(0,y.useEffect)(()=>{if(!r)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[r]),(0,y.useEffect)(()=>{r&&o.current?.focus()},[r]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{ref:a,onClick:c,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},role:`button`,tabIndex:0,className:`aui-image-zoom-trigger cursor-zoom-in`,"aria-label":`Click to zoom image`,children:n}),r&&(0,Ut.createPortal)((0,b.jsxs)(`div`,{ref:s,"data-slot":`image-zoom-overlay`,role:`dialog`,"aria-modal":`true`,className:`aui-image-zoom-overlay fade-in animate-in fixed inset-0 z-50 flex items-center justify-center bg-black/80 duration-200`,onClick:l,"aria-label":`Zoomed image`,children:[(0,b.jsx)(`img`,{"data-slot":`image-zoom-content`,src:e,alt:t,className:`aui-image-zoom-content fade-in zoom-in-95 animate-in max-h-[90vh] max-w-[90vw] cursor-zoom-out object-contain duration-200`,onClick:e=>{e.stopPropagation(),l()}}),(0,b.jsx)(`button`,{ref:o,type:`button`,"aria-label":`Close zoomed image`,onClick:e=>{e.stopPropagation(),l()},className:`text-muted-foreground hover:text-foreground bg-background/80 absolute end-4 top-4 cursor-pointer rounded-md p-2`,children:(0,b.jsx)(mp,{className:`size-5`})})]}),document.body)]})}function i0({className:e}){return(0,b.jsxs)(`div`,{"data-slot":`image-generating`,className:a(`bg-muted/50 flex min-h-32 items-center justify-center p-4`,e),children:[(0,b.jsx)(Uf,{className:`text-muted-foreground size-8 animate-spin`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Generating image…`})]})}function a0({className:e,reason:t}){return(0,b.jsxs)(`div`,{"data-slot":`image-content-filter-error`,className:a(`bg-muted/50 flex min-h-32 flex-col items-center justify-center gap-2 p-4 text-center`,e),children:[(0,b.jsx)(tp,{className:`text-muted-foreground size-8`}),(0,b.jsx)(`p`,{className:`text-sm font-medium`,children:`Image could not be generated`}),t&&(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t})]})}function o0({onRegenerate:e}){let[t,n]=(0,y.useState)(!1);return(0,b.jsx)(`button`,{type:`button`,onClick:async()=>{n(!0);try{await e()}catch{}finally{n(!1)}},disabled:t,"data-slot":`image-regenerate`,"aria-label":`Regenerate image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded disabled:opacity-50`,children:(0,b.jsx)(Qf,{className:a(`size-4`,t&&`animate-spin`)})})}function s0({part:e,onRegenerate:t,className:n}){return(0,b.jsxs)(`div`,{"data-slot":`image-actions`,className:a(`flex items-center gap-1 p-1`,n),children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>Z1(e),"data-slot":`image-download`,"aria-label":`Download image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,b.jsx)(Pf,{className:`size-4`})}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{Q1(e).catch(()=>{})},"data-slot":`image-copy`,"aria-label":`Copy image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,b.jsx)(Mf,{className:`size-4`})}),t&&(0,b.jsx)(o0,{onRegenerate:t})]})}var c0=(0,y.memo)(e=>{let{image:t,filename:n,status:r}=e;return r?.type===`running`?(0,b.jsxs)(e0,{children:[(0,b.jsx)(i0,{}),(0,b.jsx)(n0,{children:n})]}):r?.type===`incomplete`&&r.reason===`content-filter`?(0,b.jsx)(e0,{children:(0,b.jsx)(a0,{reason:`The provider blocked this image.`})}):(0,b.jsxs)(e0,{children:[(0,b.jsx)(r0,{src:t,alt:n||`Image content`,children:(0,b.jsx)(t0,{src:t,alt:n||`Image content`})}),(0,b.jsx)(n0,{children:n})]})});c0.displayName=`Image`,c0.Root=e0,c0.Preview=t0,c0.Filename=n0,c0.Zoom=r0,c0.Actions=s0,c0.Generating=i0,c0.ContentFilterError=a0;var l0=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),u0=(e,t)=>{if(!e||!t)return!1;let n=e=>{let{position:t,data:n,...r}=e||{};return r};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&l0(e.children,t.children)},d0=(e,t)=>u0(e.node,t.node),f0=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,y.memo)(({node:e,...t})=>(0,b.jsx)(n,{...t}),d0)]})),p0=(0,y.createContext)(null),m0=()=>(0,y.useContext)(p0)!==null,h0=(0,y.memo)(({children:e,fallbackPre:t,...n})=>n.node?.children.some(e=>e.type===`element`&&e.tagName===`code`)??!0?(0,b.jsx)(p0.Provider,{value:n,children:e}):(0,b.jsx)(t,{...n,children:e}),(e,t)=>e.fallbackPre===t.fallbackPre&&d0(e,t)),g0=({node:e,...t})=>(0,b.jsx)(`pre`,{...t}),_0=({node:e,...t})=>(0,b.jsx)(`code`,{...t}),v0=({node:e,components:{Pre:t,Code:n},code:r})=>(0,b.jsx)(t,{children:(0,b.jsx)(n,{node:e,children:r})}),y0=()=>null,b0=e=>/language-([^\s]+)/.exec(e??``)?.[1]??``,x0=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,y.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i,{node:e,language:a,code:o}),(0,b.jsx)(r,{node:e,components:s,language:a,code:o})]})},S0=n(r(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),C0=({className:e,...t})=>({className:n,...r})=>({className:(0,S0.default)(e,n),...t,...r});function w0(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=``;for(let n of e)t+=w0(n);return t}return(0,y.isValidElement)(e)?w0(e.props.children):``}var T0=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=C0((0,y.useContext)(p0)),l=dt(e=>(0,b.jsx)(t,{...c(e)})),u=C0(s),d=dt(e=>(0,b.jsx)(n,{...u(e)})),f=b0(s.className),p=a[f]?.SyntaxHighlighter??r,m=a[f]?.CodeHeader??i;return o!=null&&typeof o!=`string`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(m,{node:e,language:f,code:w0(o)}),(0,b.jsx)(v0,{node:e,components:{Pre:l,Code:d},code:o})]}):(0,b.jsx)(x0,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:p,CodeHeader:m},language:f,code:o??``})},E0=({node:e,components:t,componentsByLanguage:n,...r})=>m0()?(0,b.jsx)(T0,{node:e,components:t,componentsByLanguage:n,...r}):(0,b.jsx)(t.Code,{...r}),D0=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let n=e[r],i=t[r];if(n!==i&&(!n||!i||n.SyntaxHighlighter!==i.SyntaxHighlighter||n.CodeHeader!==i.CodeHeader))return!1}return!0},O0=(0,y.memo)(E0,(e,t)=>e.components===t.components&&D0(e.componentsByLanguage,t.componentsByLanguage)&&d0(e,t)),{useSmooth:k0,useSmoothStatus:A0,withSmoothContextProvider:j0}=TQ,M0=(0,y.memo)(({text:e,overrideVersion:t,...n})=>(0,b.jsx)(NO,{...n,children:e}));M0.displayName=`MarkdownRenderer`;var N0=({text:e,...t})=>{let n=(0,y.useDeferredValue)(e);return(0,b.jsx)(M0,{text:n,...t})},P0=e=>typeof e==`object`&&!!e&&!Array.isArray(e),F0=(e,t,n=1)=>{if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!F0(e[r],t[r],n-1))return!1;return!0}if(P0(e)&&P0(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&F0(e[r],t[r],n-1))}return!1};function I0(e,t){let n=(0,y.useRef)(e);return F0(e,n.current,t)||(n.current=e),n.current}function L0(e){let t=(0,y.useRef)(e),n=(e,t)=>e[t],r=Object.keys(e),i=Object.keys(t.current);return r.length===i.length&&r.every(r=>Object.hasOwn(t.current,r)&&F0(n(e,r),n(t.current,r)))||(t.current=e),t.current}var R0=({components:e,componentsByLanguage:t,smooth:n=!0,defer:r=!1,preprocess:i,...a})=>{let{text:o}=k0(WY(),n),s=(0,y.useMemo)(()=>i?i(o):o,[i,o]),{pre:c=g0,code:l=_0,SyntaxHighlighter:u=v0,CodeHeader:d=y0}=e??{},f=(0,y.useMemo)(()=>({Pre:c,Code:l,SyntaxHighlighter:u,CodeHeader:d}),[c,l,u,d]),p=dt(e=>(0,b.jsx)(O0,{components:f,componentsByLanguage:t,...e})),m=dt(e=>(0,b.jsx)(h0,{fallbackPre:c,...e})),h=L0((0,y.useMemo)(()=>{let{pre:t,code:n,SyntaxHighlighter:r,CodeHeader:i,...a}=e??{};return{...a,pre:m,code:p}},[p,m,e])),g=I0((0,y.useMemo)(()=>({components:f,componentsByLanguage:t}),[f,t]),3),_=r?N0:M0,v=L0(a);return(0,b.jsx)(_,{text:s,components:h,overrideVersion:g,...v})},z0=(0,y.forwardRef)(({className:e,containerProps:t,containerComponent:n=`div`,...r},i)=>{let a=A0();return(0,b.jsx)(n,{"data-status":a.type,...t,className:(0,S0.default)(e,t?.className),ref:i,children:(0,b.jsx)(R0,{...r})})});z0.displayName=`MarkdownTextPrimitive`;var B0=j0(z0),V0=({copiedDuration:e=3e3}={})=>{let[t,n]=(0,y.useState)(!1),r=(0,y.useRef)(void 0),i=(0,y.useRef)(0);return(0,y.useEffect)(()=>()=>{i.current+=1,r.current!==void 0&&(clearTimeout(r.current),r.current=void 0,n(!1))},[]),{isCopied:t,copyToClipboard:t=>{if(!t||typeof navigator>`u`||!navigator.clipboard)return;let a=i.current;navigator.clipboard.writeText(t).then(()=>{a===i.current&&(r.current!==void 0&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{r.current=void 0,n(!1)},e))},()=>{})}}},H0=e=>{let t=(0,y.useRef)(e);if(e!==t.current){let n=t.current;e!==void 0&&n!==void 0&&Object.keys(n).length===Object.keys(e).length&&Object.keys(e).every(t=>n[t]===e[t])||(t.current=e)}return t.current},U0=(0,y.memo)(({components:e})=>{let t=H0(e),n=(0,y.useMemo)(()=>t?{...W0,...f0(t)}:W0,[t]);return(0,b.jsx)(B0,{remarkPlugins:[Lj],className:`aui-md`,components:n,defer:!0})}),W0=f0({h1:({className:e,...t})=>(0,b.jsx)(`h1`,{className:a(`aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0`,e),...t}),h2:({className:e,...t})=>(0,b.jsx)(`h2`,{className:a(`aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0`,e),...t}),h3:({className:e,...t})=>(0,b.jsx)(`h3`,{className:a(`aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0`,e),...t}),h4:({className:e,...t})=>(0,b.jsx)(`h4`,{className:a(`aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0`,e),...t}),h5:({className:e,...t})=>(0,b.jsx)(`h5`,{className:a(`aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0`,e),...t}),h6:({className:e,...t})=>(0,b.jsx)(`h6`,{className:a(`aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0`,e),...t}),p:({className:e,...t})=>(0,b.jsx)(`p`,{className:a(`aui-md-p my-3 leading-relaxed first:mt-0 last:mb-0`,e),...t}),a:({className:e,...t})=>(0,b.jsx)(`a`,{className:a(`aui-md-a text-primary hover:text-primary/80 underline underline-offset-2`,e),...t}),blockquote:({className:e,...t})=>(0,b.jsx)(`blockquote`,{className:a(`aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4`,e),...t}),ul:({className:e,...t})=>(0,b.jsx)(`ul`,{className:a(`aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1`,e),...t}),ol:({className:e,...t})=>(0,b.jsx)(`ol`,{className:a(`aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1`,e),...t}),hr:({className:e,...t})=>(0,b.jsx)(`hr`,{className:a(`aui-md-hr border-muted-foreground/20 my-3`,e),...t}),table:({className:e,...t})=>(0,b.jsx)(`div`,{className:`aui-md-table-wrapper my-3 overflow-x-auto`,children:(0,b.jsx)(`table`,{className:a(`aui-md-table w-full border-separate border-spacing-0`,e),...t})}),th:({className:e,...t})=>(0,b.jsx)(`th`,{className:a(`aui-md-th bg-muted px-3 py-1.5 text-start font-medium first:rounded-ss-lg last:rounded-se-lg [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),td:({className:e,...t})=>(0,b.jsx)(`td`,{className:a(`aui-md-td border-muted-foreground/20 border-s border-b px-3 py-1.5 text-start last:border-e [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),tr:({className:e,...t})=>(0,b.jsx)(`tr`,{className:a(`aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-es-lg [&:last-child>td:last-child]:rounded-ee-lg`,e),...t}),li:({className:e,...t})=>(0,b.jsx)(`li`,{className:a(`aui-md-li leading-relaxed`,e),...t}),strong:({className:e,...t})=>(0,b.jsx)(`strong`,{className:a(`aui-md-strong font-semibold`,e),...t}),sup:({className:e,...t})=>(0,b.jsx)(`sup`,{className:a(`aui-md-sup [&>a]:text-xs [&>a]:no-underline`,e),...t}),pre:({className:e,...t})=>(0,b.jsx)(`pre`,{className:a(`aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed`,e),...t}),code:function({className:e,...t}){let n=m0();return(0,b.jsx)(`code`,{className:a(!n&&`aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]`,e),...t})},CodeHeader:({language:e,code:t})=>{let{isCopied:n,copyToClipboard:r}=V0();return(0,b.jsxs)(`div`,{className:`aui-code-header-root border-border/50 bg-muted/50 mt-3 flex items-center justify-between rounded-t-xl border border-b-0 px-3.5 py-1.5 text-xs`,children:[(0,b.jsx)(`span`,{className:`aui-code-header-language text-muted-foreground font-medium lowercase`,children:e}),(0,b.jsxs)(g1,{tooltip:`Copy`,onClick:()=>{t&&!n&&r(t)},children:[!n&&(0,b.jsx)(Mf,{className:`animate-in zoom-in-75 fade-in duration-150`}),n&&(0,b.jsx)(Sf,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})]})]})}});function G0({...e}){return(0,b.jsx)(it,{"data-slot":`collapsible`,...e})}function K0({...e}){return(0,b.jsx)($e,{"data-slot":`collapsible-trigger`,...e})}function q0({...e}){return(0,b.jsx)(tt,{"data-slot":`collapsible-content`,...e})}var J0=(0,y.createContext)(!1),Y0=v(`aui-reasoning-root mb-4 w-full`,{variants:{variant:{outline:`rounded-lg border px-3 py-2`,ghost:``,muted:`bg-muted/50 rounded-lg px-3 py-2`}},defaultVariants:{variant:`outline`}});function X0({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,streaming:o,onAnimationStart:s,children:c,...l}){let[u]=(0,y.useState)(i),[d,f]=(0,y.useState)(null),p=n!==void 0,m=p?n:d??(o||u),h=o===!0&&m,g=(0,y.useRef)(o);(0,y.useLayoutEffect)(()=>{g.current!==o&&(g.current=o,!p&&d===null&&!u&&s?.())},[o,p,d,u,s]);let _=(0,y.useCallback)(e=>{s?.(),p||f(e),r?.(e)},[s,p,r]);return(0,b.jsx)(G0,{"data-slot":`reasoning-root`,"data-variant":t,open:m,onOpenChange:_,className:a(`group/reasoning-root`,Y0({variant:t,className:e})),style:{"--animation-duration":`200ms`},...l,children:(0,b.jsx)(J0.Provider,{value:h,children:c})})}function Z0({side:e=`bottom`,className:t,...n}){return e===`top`?(0,b.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-8`,`bg-[linear-gradient(to_bottom,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_bottom,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n}):(0,b.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8`,`bg-[linear-gradient(to_top,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_top,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n})}function Q0({active:e,duration:t,className:n,...r}){let i=t?` (${t}s)`:``;return(0,b.jsxs)(K0,{"data-slot":`reasoning-trigger`,className:a(`aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground flex max-w-[75%] origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,b.jsx)(xf,{"data-slot":`reasoning-trigger-icon`,className:`aui-reasoning-trigger-icon size-4 shrink-0`}),(0,b.jsxs)(`span`,{"data-slot":`reasoning-trigger-label`,className:a(`aui-reasoning-trigger-label-wrapper inline-block leading-none tabular-nums`,e&&`shimmer motion-reduce:animate-none`),children:[`Reasoning`,i]}),(0,b.jsx)(Cf,{"data-slot":`reasoning-trigger-chevron`,className:a(`aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function $0({className:e,children:t,...n}){let r=(0,y.useContext)(J0);return(0,b.jsxs)(q0,{"data-slot":`reasoning-content`,className:a(`aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:[(0,b.jsx)(Z0,{side:`top`}),t,r?(0,b.jsx)(Z0,{}):null]})}function e2({className:e,children:t,...n}){let r=(0,y.useContext)(J0),i=(0,y.useRef)(null),o=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!r)return;let e=i.current,t=o.current;if(!e||!t)return;let n=!0,a=e.scrollTop,s=e.scrollHeight,c=()=>Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight,l=()=>{n&&(e.scrollTop=e.scrollHeight)},u=()=>{c()?n=!0:e.scrollTop<a&&e.scrollHeight===s&&(n=!1),a=e.scrollTop,s=e.scrollHeight};l(),e.addEventListener(`scroll`,u);let d=new ResizeObserver(l);return d.observe(t),()=>{e.removeEventListener(`scroll`,u),d.disconnect()}},[r]),(0,b.jsx)(`div`,{ref:i,"data-slot":`reasoning-text`,className:a(`aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty`,`transform-gpu transition-[transform,opacity] ease-[cubic-bezier(0.32,0.72,0,1)]`,`motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in`,`group-data-closed/collapsible-content:animate-out`,`group-data-open/collapsible-content:fade-in-0`,`group-data-closed/collapsible-content:fade-out-0`,`group-data-open/collapsible-content:slide-in-from-top-4`,`group-data-closed/collapsible-content:slide-out-to-top-4`,`group-data-open/collapsible-content:blur-in-[2px]`,`group-data-closed/collapsible-content:blur-out-[2px]`,`group-data-open/collapsible-content:animation-duration-(--animation-duration)`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration)`,e),...n,children:(0,b.jsx)(`div`,{ref:o,className:`aui-reasoning-text-content space-y-4`,children:t})})}function t2({ref:e,onAnimationStart:t,...n}){let r=(0,y.useRef)(null),i=bQ(r,200),a=(0,y.useCallback)(()=>{i(),t?.()},[i,t]),o=(0,y.useCallback)(t=>{r.current=t,typeof e==`function`?e(t):e&&(e.current=t)},[e]);return(0,b.jsx)(X0,{ref:o,onAnimationStart:a,...n})}var n2=()=>(0,b.jsx)(U0,{}),r2=({children:e,startIndex:t,endIndex:n})=>{let r=$(e=>{if(e.message.status?.type!==`running`)return!1;for(let r=t;r<=n;r++)if(e.message.parts[r]?.status.type===`running`)return!0;return!1});return(0,b.jsxs)(t2,{streaming:r,children:[(0,b.jsx)(Q0,{active:r}),(0,b.jsx)($0,{"aria-busy":r,children:(0,b.jsx)(e2,{children:e})})]})},i2=(0,y.memo)(n2);i2.displayName=`Reasoning`,i2.Root=t2,i2.Trigger=Q0,i2.Content=$0,i2.Text=e2,i2.Fade=Z0;var a2=(0,y.memo)(r2);a2.displayName=`ReasoningGroup`;function o2({className:e,...t}){return(0,b.jsx)(`textarea`,{"data-slot":`textarea`,className:a(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var s2=200,c2=`active:scale-[0.98]`;function l2({className:e,open:t,onOpenChange:n,defaultOpen:r=!1,children:i,...o}){let s=(0,y.useRef)(null),[c,l]=(0,y.useState)(r),u=bQ(s,s2),d=t!==void 0,f=d?t:c,p=(0,y.useCallback)(e=>{u(),d||l(e),n?.(e)},[u,d,n]);return(0,b.jsx)(G0,{ref:s,"data-slot":`tool-fallback-root`,open:f,onOpenChange:p,className:a(`aui-tool-fallback-root group/tool-fallback-root w-full`,e),style:{"--animation-duration":`${s2}ms`},...o,children:i})}var u2={running:Wf,complete:Sf,incomplete:Of,"requires-action":Ef},d2=e=>{if(e<1e3)return`<1s`;let t=e/1e3;return t<10?`${(Math.floor(t*10)/10).toFixed(1)}s`:t<60?`${Math.floor(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60)}s`};function f2({className:e,...t}){let n=xQ();return n===void 0?null:(0,b.jsx)(`span`,{"data-slot":`tool-fallback-duration`,className:a(`aui-tool-fallback-duration text-muted-foreground text-xs tabular-nums`,e),...t,children:d2(n)})}function p2({toolName:e,status:t,className:n,...r}){let i=t?.type??`complete`,o=i===`running`,s=t?.type===`incomplete`&&t.reason===`cancelled`,c=u2[i],l=s?`Cancelled tool`:`Used tool`;return(0,b.jsxs)(K0,{"data-slot":`tool-fallback-trigger`,className:a(`aui-tool-fallback-trigger group/trigger text-muted-foreground hover:text-foreground flex w-fit origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,b.jsx)(c,{"data-slot":`tool-fallback-trigger-icon`,className:a(`aui-tool-fallback-trigger-icon size-4 shrink-0`,s&&`text-muted-foreground`,o&&`animate-spin [animation-duration:0.6s]`)}),(0,b.jsxs)(`span`,{"data-slot":`tool-fallback-trigger-label`,className:a(`aui-tool-fallback-trigger-label-wrapper inline-block text-start leading-none`,s&&`text-muted-foreground line-through`,o&&`shimmer motion-reduce:animate-none`),children:[l,`: `,(0,b.jsx)(`b`,{children:e})]}),(0,b.jsx)(f2,{}),(0,b.jsx)(Cf,{"data-slot":`tool-fallback-trigger-chevron`,className:a(`aui-tool-fallback-trigger-chevron size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function m2({className:e,children:t,...n}){return(0,b.jsx)(q0,{"data-slot":`tool-fallback-content`,className:a(`aui-tool-fallback-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,b.jsx)(`div`,{className:a(`flex flex-col gap-2 ps-6 pt-1 pb-2 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in group-data-open/collapsible-content:fade-in-0 group-data-open/collapsible-content:blur-in-[2px] group-data-open/collapsible-content:slide-in-from-top-1`,`group-data-closed/collapsible-content:animate-out group-data-closed/collapsible-content:fade-out-0 group-data-closed/collapsible-content:blur-out-[2px] group-data-closed/collapsible-content:slide-out-to-top-1`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration) group-data-open/collapsible-content:animation-duration-(--animation-duration)`),children:t})})}function h2({argsText:e,className:t,...n}){return e?(0,b.jsx)(`div`,{"data-slot":`tool-fallback-args`,className:a(`aui-tool-fallback-args`,t),...n,children:(0,b.jsx)(`pre`,{className:`aui-tool-fallback-args-value bg-muted/50 text-foreground/90 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:e})}):null}var g2=(e,t)=>{if(typeof e==`string`)return e;try{if(e instanceof Error)return String(e);let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return`[Unserializable value]`}};function _2({result:e,className:t,...n}){return e===void 0?null:(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-result`,className:a(`aui-tool-fallback-result`,t),...n,children:[(0,b.jsx)(`p`,{className:`aui-tool-fallback-result-header text-muted-foreground text-xs font-medium`,children:`Result:`}),(0,b.jsx)(`pre`,{className:`aui-tool-fallback-result-content bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:g2(e,2)})]})}function v2({status:e,className:t,...n}){if(e?.type!==`incomplete`)return null;let r=e.error,i=r==null?null:g2(r);if(!i)return null;let o=e.reason===`cancelled`?`Cancelled reason:`:`Error:`;return(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-error`,className:a(`aui-tool-fallback-error`,t),...n,children:[(0,b.jsx)(`p`,{className:`aui-tool-fallback-error-header text-muted-foreground font-semibold`,children:o}),(0,b.jsx)(`p`,{className:`aui-tool-fallback-error-reason text-muted-foreground whitespace-pre-line`,children:i})]})}var y2=`Approved by user`,b2=`User denied tool execution`,x2={"allow-once":`Allow`,"allow-always":`Always allow`,"reject-once":`Deny`,"reject-always":`Always deny`},S2=e=>Object.hasOwn(x2,e),C2=e=>e===`allow-once`||e===`allow-always`,w2=e=>e.label??(S2(e.kind)?x2[e.kind]:void 0)??e.id,T2=e=>e?.display===`select`||e?.display===`text`,E2=(e,t,n)=>e?.type!==`requires-action`||e.reason!==`interrupt`||t!=null||n!=null;function D2({className:e,addResult:t,resume:n,interrupt:r,approval:i,respondToApproval:s,status:c,...l}){let[u,d]=(0,y.useState)(!1),f=$(e=>e.thread.voice!==void 0),p=u||f,[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(``),[v,x]=(0,y.useState)(null);if(i!=null&&(i.approved!==void 0||i.resolution!==void 0)||!E2(c,i,r))return null;let S=s?i?.options:void 0,C=i!=null&&s!=null&&jV(i),w=e=>{d(!0),x(null),(async()=>{try{await e()}catch(e){d(!1),x(e instanceof Error?e.message:String(e))}})()},T=e=>{if(!p){if(i!=null&&i.approved===void 0&&s)w(()=>s({approved:e,...D()}));else if(r)w(()=>n?.({approved:e}));else if(c?.type===`requires-action`&&c.reason===`interrupt`)return;else w(()=>t?.(e?y2:b2))}},E=e=>{p||(h(null),w(()=>s?.(S2(e.kind)?{optionId:e.id,...D()}:{optionId:e.id,approved:!0,...D()})))},D=()=>g.trim()?{text:g}:{},O=()=>{p||w(()=>s?.({text:g}))},k=()=>{p||w(()=>s?.({approved:!1}))},A=e=>{e.confirm?h(e.id):E(e)},j=m==null?void 0:S?.find(e=>e.id===m),M=T2(i),N=M&&s!=null&&i?.dismissible===!0?(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:c2,onClick:k,disabled:p,children:`Dismiss`}):null,ee=i?.prompt?(0,b.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-foreground whitespace-pre-line`,children:i.prompt}):null,te=v?(0,b.jsx)(`p`,{role:`alert`,className:`aui-tool-fallback-approval-error text-destructive text-xs whitespace-pre-line`,children:v}):null,ne=C?(0,b.jsxs)(`div`,{className:`aui-tool-fallback-approval-answer flex flex-col items-start gap-2`,children:[(0,b.jsx)(o2,{value:g,onChange:e=>_(e.target.value),disabled:p,"aria-label":M?i?.prompt??`Answer`:`Note`,placeholder:M?`Type your answer`:`Add a note to your decision`}),M&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:c2,onClick:O,disabled:p,children:`Send`}),N]})]}):null;if(j){let t=typeof j.confirm==`object`?j.confirm:void 0,n=t?.description??j.description;return(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval-confirm`,className:a(`aui-tool-fallback-approval-confirm flex flex-col gap-2 pt-1`,e),...l,children:[(0,b.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-title font-semibold`,children:t?.title??`${w2(j)}?`}),n&&(0,b.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-description text-muted-foreground whitespace-pre-line`,children:n}),j.grants&&j.grants.length>0&&(0,b.jsx)(`ul`,{className:`aui-tool-fallback-approval-confirm-grants flex flex-col gap-1`,children:j.grants.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsx)(`code`,{className:`aui-tool-fallback-approval-confirm-grant bg-muted rounded px-1.5 py-0.5 text-xs`,children:e})},e))}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:c2,onClick:()=>E(j),disabled:p,children:`Confirm`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:c2,onClick:()=>h(null),disabled:p,children:`Back`})]})]})}if(S&&S.length>0){let t=S.filter(e=>C2(e.kind)),n=S.filter(e=>!S2(e.kind)),r=S.filter(e=>S2(e.kind)&&!C2(e.kind));return(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[ee,(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[...t,...n,...r].map(e=>(0,b.jsx)(o,{size:`sm`,variant:e===t[0]?`default`:`outline`,className:c2,onClick:()=>A(e),disabled:p,children:w2(e)},e.id)),r.length===0&&!M&&(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:c2,onClick:()=>T(!1),disabled:p,children:`Deny`}),!C&&N]}),ne,te]})}return M?(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[ee,ne,!C&&N&&(0,b.jsx)(`div`,{className:`flex items-center gap-2`,children:N}),te]}):(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[ee,(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:c2,onClick:()=>T(!0),disabled:p,children:`Allow`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:c2,onClick:()=>T(!1),disabled:p,children:`Deny`})]}),ne,te]})}var O2=(0,y.memo)(({toolName:e,argsText:t,result:n,status:r,addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l})=>{let u=r?.type===`incomplete`&&r.reason===`cancelled`,d=r?.type===`requires-action`,f=d&&E2(r,c,s),[p,m]=(0,y.useState)(d),[h,g]=(0,y.useState)(d);return d!==h&&(g(d),d&&m(!0)),(0,b.jsxs)(l2,{open:p,onOpenChange:m,children:[(0,b.jsx)(p2,{toolName:e,status:r}),(0,b.jsxs)(m2,{children:[(0,b.jsx)(v2,{status:r}),(0,b.jsx)(h2,{argsText:t,className:a(u&&`opacity-60`)}),f&&(0,b.jsx)(D2,{addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l,status:r}),(0,b.jsx)(_2,{result:n})]})]})});O2.displayName=`ToolFallback`,O2.Root=l2,O2.Trigger=p2,O2.Content=m2,O2.Args=h2,O2.Result=_2,O2.Error=v2,O2.Approval=D2;var k2=200,A2=v(`aui-tool-group-root group/tool-group w-full`,{variants:{variant:{outline:`rounded-lg border py-3`,ghost:``,muted:`border-muted-foreground/30 bg-muted/30 rounded-lg border py-3`}},defaultVariants:{variant:`outline`}});function j2({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,children:o,...s}){let c=(0,y.useRef)(null),[l,u]=(0,y.useState)(i),d=bQ(c,k2),f=n!==void 0,p=f?n:l,m=(0,y.useCallback)(e=>{d(),f||u(e),r?.(e)},[d,f,r]);return(0,b.jsx)(G0,{ref:c,"data-slot":`tool-group-root`,"data-variant":t??`outline`,open:p,onOpenChange:m,className:a(A2({variant:t}),`group/tool-group-root`,e),style:{"--animation-duration":`${k2}ms`},...s,children:o})}function M2({count:e,active:t=!1,className:n,...r}){let i=`${e} tool ${e===1?`call`:`calls`}`;return(0,b.jsxs)(K0,{"data-slot":`tool-group-trigger`,className:a(`aui-tool-group-trigger group/trigger flex origin-left items-center gap-2 text-sm transition-[color,scale] active:scale-[0.98]`,`group-data-[variant=ghost]/tool-group-root:text-muted-foreground group-data-[variant=ghost]/tool-group-root:hover:text-foreground group-data-[variant=ghost]/tool-group-root:py-1.5`,`group-data-[variant=outline]/tool-group-root:w-full group-data-[variant=outline]/tool-group-root:px-4`,`group-data-[variant=muted]/tool-group-root:w-full group-data-[variant=muted]/tool-group-root:px-4`,n),...r,children:[t&&(0,b.jsx)(Wf,{"data-slot":`tool-group-trigger-loader`,className:`aui-tool-group-trigger-loader size-3 shrink-0 animate-spin [animation-duration:0.6s]`}),(0,b.jsx)(`span`,{"data-slot":`tool-group-trigger-label`,className:a(`aui-tool-group-trigger-label-wrapper inline-block text-start text-xs leading-none font-medium`,`group-data-[variant=ghost]/tool-group-root:font-normal`,`group-data-[variant=outline]/tool-group-root:grow`,`group-data-[variant=muted]/tool-group-root:grow`,t&&`shimmer motion-reduce:animate-none`),children:i}),(0,b.jsx)(Cf,{"data-slot":`tool-group-trigger-chevron`,className:a(`aui-tool-group-trigger-chevron size-3 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function N2({className:e,children:t,...n}){return(0,b.jsx)(q0,{"data-slot":`tool-group-content`,className:a(`aui-tool-group-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,b.jsx)(`div`,{className:a(`mt-2 flex flex-col gap-2`,`group-data-[variant=ghost]/tool-group-root:mt-1 group-data-[variant=ghost]/tool-group-root:gap-1`,`group-data-[variant=outline]/tool-group-root:mt-3 group-data-[variant=outline]/tool-group-root:border-t group-data-[variant=outline]/tool-group-root:px-4 group-data-[variant=outline]/tool-group-root:pt-3`,`group-data-[variant=muted]/tool-group-root:mt-3 group-data-[variant=muted]/tool-group-root:border-t group-data-[variant=muted]/tool-group-root:px-4 group-data-[variant=muted]/tool-group-root:pt-3`,`[&>*]:animate-in [&>*]:fade-in-0 [&>*]:blur-in-[2px] [&>*]:slide-in-from-top-1 [&>*]:animation-duration-(--animation-duration) [&>*]:ease-[cubic-bezier(0.32,0.72,0,1)]`,`[&>*]:motion-reduce:animate-none`,`[&>*:nth-child(2)]:[animation-delay:40ms]`,`[&>*:nth-child(3)]:[animation-delay:80ms]`,`[&>*:nth-child(4)]:[animation-delay:120ms]`,`[&>*:nth-child(n+5)]:[animation-delay:160ms]`),children:t})})}var P2=(0,y.memo)(({children:e,startIndex:t,endIndex:n})=>{let r=n-t+1;return(0,b.jsxs)(j2,{children:[(0,b.jsx)(M2,{count:r}),(0,b.jsx)(N2,{children:e})]})});P2.displayName=`ToolGroup`,P2.Root=j2,P2.Trigger=M2,P2.Content=N2;function F2({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`skeleton`,className:a(`animate-pulse rounded-md bg-accent`,e),...t})}var I2=BW({reasoning:[`group-chainOfThought`,`group-reasoning`],"tool-call":[`group-chainOfThought`,`group-tool`],"standalone-tool-call":[]}),L2=[`group-chainOfThought`,`group-task`],R2=(e,t)=>{let n=I2(e,t);return e.type===`tool-call`&&e.messages!==void 0&&n.length>0&&!t?.toolUIs?.[e.toolName]?.length?L2:n},z2={},B2=(0,y.createContext)(z2),V2=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading),H2=e=>e.thread.messages.length===0&&e.thread.isLoading&&!e.thread.isDisabled&&!e.threads.isLoading,U2=()=>(0,b.jsxs)(`div`,{"data-slot":`aui_thread-history-skeleton`,role:`status`,className:`animate-in fade-in fill-mode-both flex flex-col gap-y-6 [animation-delay:150ms] [animation-duration:200ms]`,children:[(0,b.jsx)(`span`,{className:`sr-only`,children:`Loading conversation`}),(0,b.jsx)(F2,{className:`ml-auto h-9 w-2/5 rounded-xl motion-reduce:animate-none`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,b.jsx)(F2,{className:`h-4 w-11/12 motion-reduce:animate-none`}),(0,b.jsx)(F2,{className:`h-4 w-4/5 motion-reduce:animate-none`}),(0,b.jsx)(F2,{className:`h-4 w-3/5 motion-reduce:animate-none`})]}),(0,b.jsx)(F2,{className:`ml-auto h-9 w-1/3 rounded-xl motion-reduce:animate-none`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,b.jsx)(F2,{className:`h-4 w-10/12 motion-reduce:animate-none`}),(0,b.jsx)(F2,{className:`h-4 w-2/3 motion-reduce:animate-none`})]})]}),W2=({components:e=z2,autoFocus:t=!0})=>{let n=$(V2);return(0,b.jsx)(B2.Provider,{value:e,children:(0,b.jsx)(G2,{isEmpty:n,autoFocus:t})})},G2=({isEmpty:e,autoFocus:t})=>{let{Welcome:n=Q2}=(0,y.useContext)(B2);return(0,b.jsx)(LZ.Root,{className:`aui-root aui-thread-root bg-background @container flex h-full flex-col`,style:{"--thread-max-width":`44rem`,"--composer-bg":`color-mix(in oklab, var(--color-muted) 30%, transparent)`,"--composer-radius":`var(--radius-2xl)`,"--composer-padding":`8px`},children:(0,b.jsx)(LZ.Viewport,{turnAnchor:`top`,"data-slot":`aui_thread-viewport`,className:`relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth`,children:(0,b.jsxs)(`div`,{className:a(`mx-auto flex w-full max-w-(--thread-max-width) flex-1 flex-col px-4 pt-4`,e&&`justify-center`),children:[(0,b.jsx)(zL,{condition:V2,children:(0,b.jsx)(n,{})}),(0,b.jsx)(zL,{condition:H2,children:(0,b.jsx)(U2,{})}),(0,b.jsx)(`div`,{"data-slot":`aui_message-group`,className:`mb-14 flex flex-col gap-y-6 empty:hidden`,children:(0,b.jsx)(LZ.Messages,{children:()=>(0,b.jsx)(K2,{})})}),(0,b.jsxs)(LZ.ViewportFooter,{className:a(`aui-thread-viewport-footer bg-background flex flex-col gap-4 overflow-visible pb-4 md:pb-6`,!e&&`sticky bottom-0 mt-auto rounded-t-(--composer-radius)`),children:[(0,b.jsx)(Z2,{}),(0,b.jsx)(q1,{}),(0,b.jsx)(t4,{autoFocus:t}),(0,b.jsx)(zL,{condition:e=>V2(e)&&e.composer.isEmpty,children:(0,b.jsx)($2,{})})]})]})})})},K2=()=>{let{AssistantMessage:e=i4}=(0,y.useContext)(B2),t=$(e=>e.message.role),n=$(e=>e.message.composer.isEditing),r=$(e=>e.message.metadata.modality===`voice`);return n?(0,b.jsx)(u4,{}):r?(0,b.jsx)(Y2,{}):t===`user`?(0,b.jsx)(c4,{}):(0,b.jsx)(e,{})},q2=()=>$(e=>{let t=e.thread.messages[e.message.index-1]?.metadata.modality===`voice`,n=e.thread.messages[e.message.index+1]?.metadata.modality===`voice`;return t?n?`middle`:`end`:n?`start`:`single`}),J2=({text:e})=>(0,b.jsx)(`p`,{className:`aui-spoken-message-text m-0`,children:e}),Y2=()=>{let e=$(e=>e.message.role),t=q2(),n=$(e=>e.message.role===`assistant`&&e.message.status?.type===`running`),r=t===`start`||t===`single`;return(0,b.jsxs)($X.Root,{"data-slot":`aui_spoken-message-root`,"data-role":e,"data-voice-run":t,className:a(`aui-spoken-message bg-muted/40 mx-2 px-3 py-1.5 [contain-intrinsic-size:auto_48px] [content-visibility:auto]`,t===`single`&&`rounded-xl py-2`,t===`start`&&`rounded-t-xl pt-2`,t===`middle`&&`-mt-6`,t===`end`&&`-mt-6 rounded-b-xl pb-2`),children:[r&&(0,b.jsxs)(`div`,{"data-slot":`aui_spoken-exchange-header`,className:`text-muted-foreground mb-1.5 flex items-center gap-1.5 text-xs`,children:[(0,b.jsx)(Yf,{className:`size-3`,"aria-hidden":!0}),(0,b.jsx)(`span`,{children:`Voice conversation`})]}),(0,b.jsxs)(`div`,{"data-slot":`aui_spoken-message-content`,className:`text-foreground flex items-start gap-2 text-sm leading-relaxed`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground mt-1 shrink-0`,"aria-hidden":!0,children:e===`user`?(0,b.jsx)(Gf,{className:`size-3.5`}):(0,b.jsx)(yf,{className:`size-3.5`})}),(0,b.jsx)(`span`,{className:`sr-only`,children:e===`user`?`You said`:`Assistant said`}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1 wrap-break-word`,children:[(0,b.jsx)($X.Parts,{components:{Text:J2}}),n&&(0,b.jsx)(`span`,{"data-slot":`aui_spoken-message-indicator`,role:`status`,className:`text-muted-foreground ms-1 animate-pulse font-sans`,"aria-label":`Assistant is speaking`,children:`●`})]}),(0,b.jsx)(X2,{})]})]})},X2=()=>(0,b.jsx)(vq.Root,{hideWhenRunning:!0,autohide:`always`,className:`aui-spoken-action-bar text-muted-foreground flex shrink-0 gap-1`,children:(0,b.jsx)(vq.Copy,{asChild:!0,children:(0,b.jsxs)(g1,{tooltip:`Copy`,className:`size-6`,children:[(0,b.jsx)(zL,{condition:e=>e.message.isCopied,children:(0,b.jsx)(Sf,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,b.jsx)(zL,{condition:e=>!e.message.isCopied,children:(0,b.jsx)(Mf,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})})}),Z2=()=>(0,b.jsx)(LZ.ScrollToBottom,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Scroll to bottom`,variant:`outline`,className:`aui-thread-scroll-to-bottom dark:border-border dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible`,children:(0,b.jsx)(hf,{})})}),Q2=()=>(0,b.jsx)(`div`,{className:`aui-thread-welcome-root mb-6 flex flex-col px-2`,children:(0,b.jsx)(`p`,{className:`aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-medium tracking-tight duration-200`,children:`How can I help you today?`})}),$2=()=>(0,b.jsx)(`div`,{className:`aui-thread-welcome-suggestions flex w-full flex-col`,children:(0,b.jsx)(LZ.Suggestions,{children:()=>(0,b.jsx)(e4,{})})}),e4=()=>(0,b.jsx)(`div`,{className:`aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-2 animate-in fill-mode-both duration-200`,children:(0,b.jsx)(WZ.Trigger,{send:!0,asChild:!0,children:(0,b.jsxs)(`button`,{type:`button`,className:`aui-thread-welcome-suggestion group hover:bg-foreground/[0.03] focus-visible:ring-ring/50 flex w-full items-baseline gap-2.5 rounded-md px-2 py-2 text-start text-sm transition-colors outline-none focus-visible:ring-1 motion-reduce:transition-none`,children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 group-hover:text-foreground font-mono text-xs transition-colors motion-reduce:transition-none`,children:`>`}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,b.jsx)(WZ.Title,{className:`aui-thread-welcome-suggestion-text-1 text-foreground`}),` `,(0,b.jsx)(WZ.Description,{className:`aui-thread-welcome-suggestion-text-2 text-muted-foreground empty:hidden`})]})]})})}),t4=({autoFocus:e})=>(0,b.jsx)(VY.Root,{className:`aui-composer-root relative flex w-full flex-col`,children:(0,b.jsx)(VY.AttachmentDropzone,{asChild:!0,children:(0,b.jsxs)(`div`,{"data-slot":`aui_composer-shell`,className:`border-foreground/10 focus-within:border-foreground/25 data-[dragging=true]:border-ring flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]`,children:[(0,b.jsx)(j1,{}),(0,b.jsx)(VY.Input,{placeholder:`Send a message...`,className:`aui-composer-input caret-primary placeholder:text-muted-foreground/60 max-h-48 min-h-10 w-full resize-none bg-transparent px-2.5 py-1 text-base leading-6 outline-none`,rows:1,autoFocus:e,enterKeyHint:`send`,"aria-label":`Message input`}),(0,b.jsx)(n4,{})]})})}),n4=()=>(0,b.jsxs)(`div`,{className:`aui-composer-action-wrapper relative flex items-center justify-between`,children:[(0,b.jsx)(M1,{}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsxs)(zL,{condition:e=>e.thread.capabilities.dictation,children:[(0,b.jsx)(zL,{condition:e=>e.composer.dictation==null,children:(0,b.jsx)(VY.Dictate,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Voice input`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-dictate text-muted-foreground hover:text-foreground size-7 rounded-full`,"aria-label":`Start voice input`,children:(0,b.jsx)(Gf,{className:`aui-composer-dictate-icon size-4`})})})}),(0,b.jsx)(zL,{condition:e=>e.composer.dictation!=null,children:(0,b.jsx)(VY.StopDictation,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Stop dictation`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-stop-dictation text-destructive size-7 rounded-full`,"aria-label":`Stop voice input`,children:(0,b.jsx)(ip,{className:`aui-composer-stop-dictation-icon size-3.5 animate-pulse fill-current`})})})})]}),(0,b.jsx)(zL,{condition:e=>!e.thread.isRunning||e.thread.voice!==void 0,children:(0,b.jsx)(VY.Send,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Send message`,side:`bottom`,type:`button`,variant:`default`,size:`icon`,className:`aui-composer-send size-7 rounded-full`,"aria-label":`Send message`,children:(0,b.jsx)(vf,{className:`aui-composer-send-icon size-4`})})})}),(0,b.jsx)(zL,{condition:e=>e.thread.isRunning&&e.thread.voice===void 0,children:(0,b.jsx)(VY.Cancel,{asChild:!0,children:(0,b.jsx)(o,{type:`button`,variant:`default`,size:`icon`,className:`aui-composer-cancel size-7 rounded-full`,"aria-label":`Stop generating`,children:(0,b.jsx)(ip,{className:`aui-composer-cancel-icon size-3.5 fill-current`})})})})]})]}),r4=()=>(0,b.jsx)($X.Error,{children:(0,b.jsx)(pX.Root,{className:`aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200`,children:(0,b.jsx)(pX.Message,{className:`aui-message-error-message line-clamp-2`})})}),i4=()=>{let{ToolFallback:e=O2,ToolGroup:t,ReasoningGroup:n,TaskGroup:r}=(0,y.useContext)(B2),i=r?R2:I2;return(0,b.jsxs)($X.Root,{"data-slot":`aui_assistant-message-root`,"data-role":`assistant`,className:`fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:[(0,b.jsxs)(`div`,{"data-slot":`aui_assistant-message-content`,className:`text-foreground px-2 leading-relaxed wrap-break-word`,children:[(0,b.jsx)($X.GroupedParts,{groupBy:i,children:({part:i,children:a})=>{switch(i.type){case`group-chainOfThought`:return(0,b.jsx)(`div`,{"data-slot":`aui_chain-of-thought`,children:a});case`group-task`:return r?(0,b.jsx)(r,{group:i}):null;case`group-tool`:return t?(0,b.jsx)(t,{group:i,children:a}):(0,b.jsxs)(j2,{variant:`ghost`,children:[(0,b.jsx)(M2,{count:i.indices.length,active:i.status.type===`running`}),(0,b.jsx)(N2,{children:a})]});case`group-reasoning`:{if(n)return(0,b.jsx)(n,{group:i,children:a});let e=i.status.type===`running`;return(0,b.jsxs)(t2,{streaming:e,children:[(0,b.jsx)(Q0,{active:e}),(0,b.jsx)($0,{"aria-busy":e,children:(0,b.jsx)(e2,{children:a})})]})}case`text`:return(0,b.jsx)(U0,{});case`reasoning`:return(0,b.jsx)(i2,{...i});case`tool-call`:return i.toolUI??(0,b.jsx)(e,{...i});case`data`:return i.dataRendererUI;case`file`:return(0,b.jsx)(`div`,{"data-slot":`aui_assistant-message-file`,className:`py-1`,children:(0,b.jsx)(G1,{...i})});case`image`:return(0,b.jsx)(`div`,{"data-slot":`aui_assistant-message-image`,className:`py-1`,children:(0,b.jsx)(c0,{...i})});case`indicator`:return(0,b.jsx)(`span`,{"data-slot":`aui_assistant-message-indicator`,className:`animate-pulse font-sans`,"aria-label":`Assistant is working`,children:`●`});default:return null}}}),(0,b.jsx)(r4,{})]}),(0,b.jsxs)(`div`,{"data-slot":`aui_assistant-message-footer`,className:a(`ms-2 flex items-center`,`min-h-7.5 pt-1.5`),children:[(0,b.jsx)(d4,{}),(0,b.jsx)(a4,{})]})]})},a4=()=>(0,b.jsxs)(vq.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-assistant-action-bar-root text-muted-foreground animate-in fade-in col-start-3 row-start-2 -ms-1 flex gap-1 duration-200`,children:[(0,b.jsx)(vq.Copy,{asChild:!0,children:(0,b.jsxs)(g1,{tooltip:`Copy`,children:[(0,b.jsx)(zL,{condition:e=>e.message.isCopied,children:(0,b.jsx)(Sf,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,b.jsx)(zL,{condition:e=>!e.message.isCopied,children:(0,b.jsx)(Mf,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})}),(0,b.jsxs)(zL,{condition:e=>e.thread.capabilities.feedback,children:[(0,b.jsx)(vq.FeedbackPositive,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,b.jsx)(cp,{})})}),(0,b.jsx)(vq.FeedbackNegative,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Not helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,b.jsx)(sp,{})})})]}),(0,b.jsx)(vq.Reload,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Refresh`,children:(0,b.jsx)(Qf,{})})}),(0,b.jsxs)(kq.Root,{children:[(0,b.jsx)(kq.Trigger,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`More`,className:`data-[state=open]:bg-accent`,children:(0,b.jsx)(Ff,{})})}),(0,b.jsx)(kq.Content,{side:`bottom`,align:`start`,sideOffset:6,className:`aui-action-bar-more-content bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-[8rem] overflow-hidden rounded-xl border p-1.5`,children:(0,b.jsx)(vq.ExportMarkdown,{asChild:!0,children:(0,b.jsxs)(kq.Item,{className:`aui-action-bar-more-item hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(Pf,{className:`size-4`}),`Export as Markdown`]})})})]})]}),o4=e=>(0,b.jsx)(`div`,{"data-slot":`aui_user-message-file`,className:`py-1`,children:(0,b.jsx)(G1,{...e})}),s4=e=>(0,b.jsx)(`div`,{"data-slot":`aui_user-message-image`,className:`py-1`,children:(0,b.jsx)(c0,{...e})}),c4=()=>(0,b.jsxs)($X.Root,{"data-slot":`aui_user-message-root`,className:`fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto] [&:where(>*)]:col-start-2`,"data-role":`user`,children:[(0,b.jsx)(A1,{}),(0,b.jsxs)(`div`,{className:`aui-user-message-content-wrapper relative col-start-2 min-w-0`,children:[(0,b.jsx)(`div`,{className:`aui-user-message-content peer bg-muted text-foreground rounded-(--composer-radius) px-4 py-2 wrap-break-word empty:hidden`,children:(0,b.jsx)($X.Parts,{components:{File:o4,Image:s4}})}),(0,b.jsx)(`div`,{className:`aui-user-action-bar-wrapper absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-2 peer-empty:hidden rtl:translate-x-full`,children:(0,b.jsx)(l4,{})})]}),(0,b.jsx)(d4,{"data-slot":`aui_user-branch-picker`,className:`col-span-full col-start-1 -me-1 justify-end`})]}),l4=()=>(0,b.jsx)(vq.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-user-action-bar-root flex flex-col items-end`,children:(0,b.jsx)(vq.Edit,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Edit`,className:`aui-user-action-edit`,children:(0,b.jsx)(Jf,{})})})}),u4=()=>(0,b.jsx)($X.Root,{"data-slot":`aui_edit-composer-wrapper`,className:`flex flex-col px-2 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:(0,b.jsxs)(VY.Root,{className:`aui-edit-composer-root border-foreground/10 focus-within:border-foreground/25 ms-auto flex w-full max-w-[85%] cursor-text flex-col rounded-(--composer-radius) border bg-(--composer-bg) transition-[border-color]`,children:[(0,b.jsx)(VY.Input,{className:`aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none`,autoFocus:!0}),(0,b.jsxs)(`div`,{className:`aui-edit-composer-footer mx-2.5 mb-2.5 flex items-center gap-1.5 self-end`,children:[(0,b.jsx)(VY.Cancel,{asChild:!0,children:(0,b.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-8 px-3`,children:`Cancel`})}),(0,b.jsx)(VY.Send,{asChild:!0,children:(0,b.jsx)(o,{size:`sm`,className:`h-8 px-3`,children:`Update`})})]})]})}),d4=({className:e,...t})=>(0,b.jsxs)(Kq.Root,{hideWhenSingleBranch:!0,className:a(`aui-branch-picker-root text-muted-foreground -ms-2 me-2 inline-flex items-center text-xs`,e),...t,children:[(0,b.jsx)(Kq.Previous,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Previous`,children:(0,b.jsx)(wf,{})})}),(0,b.jsxs)(`span`,{className:`aui-branch-picker-state font-medium`,children:[(0,b.jsx)(Kq.Number,{}),` / `,(0,b.jsx)(Kq.Count,{})]}),(0,b.jsx)(Kq.Next,{asChild:!0,children:(0,b.jsx)(g1,{tooltip:`Next`,children:(0,b.jsx)(Tf,{})})})]}),f4=()=>{let[e,t]=(0,y.useState)(``),n=$(e=>e.threads.threadIds.length>0);return(0,b.jsxs)(m4,{children:[(0,b.jsx)(x4,{}),n&&(0,b.jsx)(p4,{value:e,onValueChange:t}),(0,b.jsx)(h4,{searchQuery:n?e:``})]})},p4=(0,y.forwardRef)(({className:e,value:t,onValueChange:n,...r},i)=>(0,b.jsxs)(`div`,{"data-slot":`aui_thread-list-search`,className:`relative px-0.5 py-1`,children:[(0,b.jsx)(ep,{"data-slot":`aui_thread-list-search-icon`,className:`text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2`}),(0,b.jsx)(p,{ref:i,type:`search`,value:t,onChange:e=>n(e.target.value),"aria-label":`Search threads`,placeholder:`Search threads`,className:a(`h-8 ps-8 text-sm`,e),...r})]}));p4.displayName=`ThreadListSearch`;var m4=({className:e,...t})=>(0,b.jsx)(tQ.Root,{"data-slot":`aui_thread-list-root`,className:a(`flex flex-col gap-0.5`,e),...t}),h4=({className:e,searchQuery:t=``,...n})=>(0,b.jsxs)(`div`,{"data-slot":`aui_thread-list-items`,className:a(`flex flex-col gap-0.5`,e),...n,children:[(0,b.jsx)(zL,{condition:e=>e.threads.isLoading,children:(0,b.jsx)(S4,{})}),(0,b.jsx)(zL,{condition:e=>!e.threads.isLoading,children:(0,b.jsx)(y4,{searchQuery:t})})]}),g4=864e5,_4=(e,t)=>!e||e.getTime()>=t?`Today`:e.getTime()>=t-g4?`Yesterday`:`Earlier`,v4=(e=``)=>{let t=$(e=>e.threads.threadIds),n=$(e=>e.threads.threadItems),r=e.trim().toLowerCase();return(0,y.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e])),i=t=>!r||(e.get(t)?.title||`New Chat`).toLowerCase().includes(r),a=t=>e.get(t)?.status===`archived`,o=t.map(t=>e.get(t)?.lastMessageAt),s=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&!a(e)).map(({index:e})=>e),c=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&a(e)).map(({index:e})=>e);if(!s.some(e=>o[e]))return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:null};let l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),d=e=>o[e]?.getTime()??2**53-1,f=[...s].sort((e,t)=>d(t)-d(e)),p=[];for(let e of f){let t=_4(o[e],u),n=p[p.length-1];n?.label===t?n.indices.push(e):p.push({label:t,indices:[e]})}return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:p}},[t,n,r])},y4=({searchQuery:e=``})=>{let{threadIds:t,filteredIndices:n,archivedIndices:r,groups:i}=v4(e);return e.trim()&&n.length===0&&r.length===0?(0,b.jsx)(`div`,{"data-slot":`aui_thread-list-empty`,className:`text-muted-foreground px-2.5 py-4 text-sm`,children:`No threads found`}):i?(0,b.jsxs)(b.Fragment,{children:[i.map(e=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:e.label}),e.indices.map(e=>(0,b.jsx)(tQ.ItemByIndex,{index:e,components:{ThreadListItem:C4}},t[e]))]},e.label)),(0,b.jsx)(b4,{threadIds:t,indices:r})]}):(0,b.jsxs)(b.Fragment,{children:[n.map(e=>(0,b.jsx)(tQ.ItemByIndex,{index:e,components:{ThreadListItem:C4}},t[e])),(0,b.jsx)(b4,{threadIds:t,indices:r})]})},b4=({threadIds:e,indices:t})=>t.length?(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:`Archived`}),t.map(t=>(0,b.jsx)(tQ.ItemByIndex,{index:t,components:{ThreadListItem:C4}},e[t]))]}):null,x4=(0,y.forwardRef)(({className:e,labelClassName:t,children:n,...r},i)=>(0,b.jsx)(tQ.New,{asChild:!0,children:(0,b.jsx)(o,{ref:i,variant:`ghost`,"data-slot":`aui_thread-list-new`,className:a(`hover:bg-muted data-active:bg-muted h-8 justify-start gap-2 rounded-md px-2.5 text-sm font-normal`,e),...r,children:n??(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Zf,{"data-slot":`aui_thread-list-new-icon`,className:`size-4 shrink-0`}),(0,b.jsx)(`span`,{"data-slot":`aui_thread-list-new-label`,className:a(`whitespace-nowrap`,t),children:`New Thread`})]})})}));x4.displayName=`ThreadListNew`;var S4=()=>(0,b.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:Array.from({length:5},(e,t)=>(0,b.jsx)(`div`,{role:`status`,"aria-label":`Loading threads`,"data-slot":`aui_thread-list-skeleton-wrapper`,className:`flex h-8 items-center px-2.5`,children:(0,b.jsx)(F2,{"data-slot":`aui_thread-list-skeleton`,className:`h-3.5 w-full`})},t))}),C4=()=>{let e=$(e=>e.threadListItem.isRunning),t=$(e=>e.threadListItem.status)===`archived`,[n,r]=(0,y.useState)(!1),i=(0,y.useRef)(null),o=(0,y.useRef)(!1);return(0,y.useEffect)(()=>{!n&&o.current&&(o.current=!1,i.current?.focus())},[n]),(0,b.jsxs)(cQ.Root,{"data-slot":`aui_thread-list-item`,"data-archived":t||void 0,className:a(`group hover:bg-muted focus-visible:bg-muted data-active:bg-muted has-focus-visible:bg-muted has-data-[state=open]:bg-muted relative flex h-8 items-center rounded-md transition-colors focus-visible:outline-none`,t&&`opacity-60`),children:[n?(0,b.jsx)(w4,{onDone:e=>{o.current=e,r(!1)}}):(0,b.jsxs)(cQ.Trigger,{ref:i,"data-slot":`aui_thread-list-item-trigger`,className:`focus-visible:ring-ring/50 flex h-full min-w-0 flex-1 items-center rounded-md px-2.5 text-start text-sm outline-none group-hover:pe-9 group-has-focus-visible:pe-9 group-has-data-[state=open]:pe-9 group-data-active:pe-9 focus-visible:ring-1`,children:[e&&(0,b.jsx)(Uf,{"aria-hidden":!0,"data-slot":`aui_thread-list-item-running`,className:`text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin`}),(0,b.jsx)(`span`,{"data-slot":`aui_thread-list-item-title`,className:`min-w-0 flex-1 truncate`,children:(0,b.jsx)(cQ.Title,{fallback:`New Chat`})}),e&&(0,b.jsx)(`span`,{className:`sr-only`,children:`Running`})]}),(0,b.jsx)(T4,{archived:t,onRename:()=>r(!0)})]})},w4=({onDone:e})=>{let t=Q(),n=$(e=>e.threadListItem.title)??``,[r,i]=(0,y.useState)(n),a=(0,y.useRef)(null),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0;let s=r.trim();if(!s||s===n){e(i);return}Promise.resolve().then(()=>t.threadListItem.rename(s)).then(()=>e(i),()=>{o.current=!1,i&&a.current?.focus()})},c=()=>{o.current||(o.current=!0,e(!0))};return(0,b.jsx)(p,{ref:a,autoFocus:!0,"data-slot":`aui_thread-list-item-rename`,"aria-label":`Rename thread`,value:r,className:`h-7 min-w-0 flex-1 ps-2.5 pe-9 text-sm`,onChange:e=>i(e.target.value),onBlur:()=>s(!1),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s(!0)):e.key===`Escape`&&(e.preventDefault(),c())}})},T4=({archived:e,onRename:t})=>(0,b.jsxs)(yQ.Root,{sharedFocusGroup:!0,children:[(0,b.jsx)(yQ.Trigger,{asChild:!0,children:(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,"data-slot":`aui_thread-list-item-more`,className:`data-[state=open]:bg-accent absolute end-1.5 top-1/2 size-6 -translate-y-1/2 p-0 opacity-0 group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 data-[state=open]:opacity-100`,children:[(0,b.jsx)(Ff,{className:`size-3.5`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`More options`})]})}),(0,b.jsxs)(yQ.Content,{side:`right`,align:`start`,sideOffset:6,"data-slot":`aui_thread-list-item-more-content`,className:`bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-32 overflow-hidden rounded-xl border p-1.5`,children:[(0,b.jsxs)(yQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,onSelect:t,children:[(0,b.jsx)(Jf,{className:`size-4`}),`Rename`]}),e?(0,b.jsx)(cQ.Unarchive,{asChild:!0,children:(0,b.jsxs)(yQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(pf,{className:`size-4`}),`Unarchive`]})}):(0,b.jsx)(cQ.Archive,{asChild:!0,children:(0,b.jsxs)(yQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(mf,{className:`size-4`}),`Archive`]})}),(0,b.jsx)(cQ.Delete,{asChild:!0,children:(0,b.jsxs)(yQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive focus:bg-destructive/10 focus:text-destructive flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(lp,{className:`size-4`}),`Delete`]})})]})]}),E4=`bg-background border border-border/60 dark:bg-popover`;function D4({phase:e,attempt:t,resumedTokens:n,onRetry:r,className:i,...o}){return e===`online`?null:(0,b.jsxs)(`div`,{"data-slot":`connection-state`,className:a(E4,`fade-in slide-in-from-top-1 animate-in flex w-full max-w-sm items-center gap-2.5 rounded-2xl px-3.5 py-2.5 duration-300`,i),...o,children:[e===`dropped`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(jf,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Connection lost. The run kept going on the server.`}),(0,b.jsx)(`button`,{type:`button`,onClick:r,className:`text-foreground/70 hover:bg-foreground/[0.06] hover:text-foreground/95 shrink-0 rounded-full px-2.5 py-1 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]`,children:`Reconnect`})]}),e===`reconnecting`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Uf,{className:`text-foreground/40 size-3.5 shrink-0 animate-spin motion-reduce:animate-none`}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Reconnecting`}),t!==void 0&&(0,b.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`attempt `,t]})]}),e===`resumed`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Sf,{className:`size-3.5 shrink-0 text-emerald-500`}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Picked the stream back up.`}),n!==void 0&&(0,b.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`+`,n,` tokens`]})]})]})}var O4=[`pending`,`testing`,`confirmed`,`rejected`,`blocked`],k4=H(O4),A4=V({tasks:B(V({id:R(),title:R(),status:k4.default(`pending`),note:R().optional()})),target:R().optional(),phase:R().optional()}),j4={tasks:[]};function M4(e){return typeof e==`string`&&O4.includes(e)}function N4(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[^a-z_-]/g,``);if(t===`pending`||t===`todo`||t===`hypothesis`||t===`planned`||t===`open`)return`pending`;if(t===`testing`||t===`in_progress`||t===`inprogress`||t===`active`||t===`probing`)return`testing`;if(t===`confirmed`||t===`verified`||t===`exploited`||t===`vulnerable`||t===`success`)return`confirmed`;if(t===`rejected`||t===`tested_safe`||t===`testedsafe`||t===`safe`||t===`clean`||t===`not_vulnerable`||t===`notvulnerable`||t===`invalid`)return`rejected`;if(t===`blocked`||t===`justified_blocked`||t===`justifiedblocked`||t===`needs_auth`||t===`needsauth`||t===`untestable`)return`blocked`}var P4=/https?:\/\/[^\s<>")']+/i,F4=/\b(?:[a-z0-9-]+\.)+[a-z]{2,}\b/i;function I4(e){if(!e||typeof e!=`string`)return null;let t=e.match(P4);if(t?.[0]){let e=t[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<512)return e}let n=e.match(F4);if(n?.[0]){let e=n[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<256&&!e.endsWith(`.ts`)&&!e.endsWith(`.js`)&&!e.endsWith(`.json`)&&!e.endsWith(`.md`)&&!e.endsWith(`.html`)&&!e.endsWith(`.txt`))return e}return null}function L4(e){let t=0;for(let n of e){let e=n.id.match(/^T-(\d+)$/i);e&&(t=Math.max(t,Number.parseInt(e[1],10)))}return`T-${t+1}`}function R4(e,t){let n=new Map;for(let t of e)n.set(t.id,{...t});for(let e of t){let t=n.get(e.id);t?n.set(e.id,{id:e.id,title:e.title||t.title,status:e.status||t.status,note:e.note===void 0?t.note:e.note}):n.set(e.id,{...e})}return Array.from(n.values())}var z4=/-\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([A-Za-z0-9_-]+):\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,B4=/Task\s+([A-Za-z0-9_-]+)\s+(?:added|updated):\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,V4=/<kifaru_dossier\s+target="([^"]+)"(?:\s+phase="([^"]+)")?/i;function H4(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=e.split(/\r?\n/);for(let e of i){let t=e.trim();if(!t.startsWith(`|`)||!t.endsWith(`|`))continue;let i=t.split(`|`).map(e=>e.trim()),a=i.filter((e,t)=>t>0&&t<i.length-1);if(a.length<2||a.every(e=>/^[-:=|\s]+$/.test(e)))continue;let o=N4(a[1]),s=a[0],c=a[2];if(o||(o=N4(a[0]),o&&(s=a[1],c=a[2])),!o||!s||(s=s.replace(/^[`*_\s]+|[`*_\s]+$/g,``).trim(),!s||s.toLowerCase()===`cell`||s.toLowerCase()===`task`))continue;let l,u=s.match(/^(T-\d+)[:\s—-]+(.*)$/i);u?.[1]&&(l=u[1].toUpperCase(),s=u[2].trim());let d=s.toLowerCase(),f=r.get(d);if(f)f.status=o,c&&(f.note=c.trim());else{let e={id:l||L4(n),title:s,status:o,note:c?c.trim():void 0};n.push(e),r.set(d,e)}}return n}function U4(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=/^\s*[-*]\s*\[([ xX/!?-])\]\s*(?:([A-Za-z0-9_-]+):)?\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gm,a;for(;(a=i.exec(e))!==null;){let[,e,t,i,o]=a;if(!i)continue;let s=`pending`;e===`x`||e===`X`?s=`confirmed`:e===`/`?s=`testing`:e===`!`?s=`blocked`:(e===`-`||e===`?`)&&(s=`rejected`);let c=i.trim(),l=c.toLowerCase(),u=r.get(l);if(u)u.status=s,o&&(u.note=o.trim());else{let e={id:t?.startsWith(`T-`)?t.toUpperCase():L4(n),title:c,status:s,note:o?o.trim():void 0};n.push(e),r.set(l,e)}}return n}function W4(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);for(let t of e){let e=typeof t==`string`?t:typeof t==`object`&&t&&`note`in t?String(t.note??``):``;if(!e)continue;let i,a,o;if(/^CONFIRMED(\([^)]+\))?:/i.test(e)){i=`confirmed`;let t=e.replace(/^CONFIRMED(\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`.`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():void 0}else if(/BLOCKED/i.test(e)&&(/coverage gap/i.test(e)||/needs auth/i.test(e))){i=`blocked`;let t=e.replace(/^Coverage gap(\s*\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`—`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():t}if(i&&a){let e=a.toLowerCase(),t=r.get(e);if(t)t.status=i,o&&(t.note=o);else{let t={id:L4(n),title:a,status:i,note:o};n.push(t),r.set(e,t)}}}return n}function G4(e){let t=[],n,r;for(let i of e){if(i.role===`user`){let e=``;if(typeof i.content==`string`)e=i.content;else if(Array.isArray(i.content))for(let t of i.content)typeof t==`object`&&t&&`type`in t&&t.type===`text`&&(e+=` ${t.text??``}`);let t=I4(e);t&&(n=t)}if(i.role===`custom`&&i.customType===`kifaru-dossier`){let e=typeof i.content==`string`?i.content:``,a=e.match(/Bound target:\s*([^\n\r]+)/i)||e.match(/Session bound to target\s*([^\n\r.]+)/i);a?.[1]&&(n=a[1].trim());let o=e.match(/Phase:\s*([a-zA-Z0-9_-]+)/i);o?.[1]&&(r=o[1].trim());let s;for(z4.lastIndex=0;(s=z4.exec(e))!==null;){let[,e,n,r,i]=s;n&&r&&M4(e)&&(t=R4(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}if(i.role===`assistant`&&Array.isArray(i.content)){for(let e of i.content)if(typeof e==`object`&&e&&`type`in e){if(e.type===`text`&&typeof e.text==`string`){let i=e.text,a=I4(i);a&&!n&&(n=a);let o=i.match(V4);o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),t=H4(i,t),t=U4(i,t)}if(e.type===`tool-call`||e.type===`toolCall`){let i=e,a=i.name??i.toolName,o=i.args??i.arguments;if(a===`kifaru_dossier`&&o&&(typeof o.target==`string`&&o.target.trim()&&(n=o.target.trim()),typeof o.phase==`string`&&o.phase.trim()&&(r=o.phase.trim()),o.action===`task`)){let e=typeof o.taskId==`string`?o.taskId.trim():void 0,n=typeof o.title==`string`?o.title.trim():void 0,r=typeof o.note==`string`?o.note.trim():void 0;e&&(t=R4(t,[{id:e,title:n||e,status:M4(o.status)?o.status:`pending`,note:r}]))}}}}if(i.role===`toolResult`){let e=i;for(let i of e.content??[])if(i.type===`text`&&i.text){let e=i.text.trim();if(e.startsWith(`{`)&&e.endsWith(`}`))try{let i=JSON.parse(e);if(typeof i.target==`string`&&(n=i.target),typeof i.phase==`string`&&(r=i.phase),Array.isArray(i.tasks)){let e=[];for(let t of i.tasks)typeof t.id==`string`&&typeof t.title==`string`&&e.push({id:t.id,title:t.title,status:M4(t.status)?t.status:`pending`,note:typeof t.note==`string`?t.note:void 0});t=R4(t,e)}Array.isArray(i.observations)&&(t=W4(i.observations,t))}catch{}t=H4(e,t),t=U4(e,t);let a;for(B4.lastIndex=0;(a=B4.exec(e))!==null;){let[,e,n,r,i]=a;e&&r&&M4(n)&&(t=R4(t,[{id:e.trim(),title:r.trim(),status:n,note:i?i.trim():void 0}]))}let o=e.match(V4);for(o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),z4.lastIndex=0;(a=z4.exec(e))!==null;){let[,e,n,r,i]=a;n&&r&&M4(e)&&(t=R4(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}}}return{tasks:t,target:n,phase:r}}var K4={pending:Af,testing:Uf,confirmed:Sf,rejected:Of,blocked:Ef},q4={pending:{badge:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,text:`text-muted-foreground`,ring:`border-border`},testing:{badge:`bg-blue-500/10 text-blue-500 border-blue-500/30 hover:bg-blue-500/20`,text:`text-blue-500`,ring:`border-blue-500/40 bg-blue-500/10`},confirmed:{badge:`bg-emerald-500/10 text-emerald-500 border-emerald-500/30 hover:bg-emerald-500/20`,text:`text-emerald-500`,ring:`border-emerald-500/50 bg-emerald-500/20`},rejected:{badge:`bg-rose-500/10 text-rose-500 border-rose-500/30 hover:bg-rose-500/20`,text:`text-rose-500`,ring:`border-rose-500/40 bg-rose-500/10`},blocked:{badge:`bg-amber-500/10 text-amber-500 border-amber-500/30 hover:bg-amber-500/20`,text:`text-amber-500`,ring:`border-amber-500/40 bg-amber-500/10`}};function J4({className:e=``,onClose:t}){let[n,{setState:r}]=iB(`taskBoard`,{description:`A task board panel for the target dossier tracking hunt theses, tests, and findings. Use update_taskBoard with tasks.add/update/remove/clear to manage tasks. Tasks have id (e.g. T-1), title, status (pending|testing|confirmed|rejected|blocked), and optional note.`,stateSchema:A4,initialState:j4}),i=Q$(e=>e.messages),[a,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(`all`),[u,d]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(!i||i.length===0)return;let e=G4(i);(e.tasks.length!==0||e.target||e.phase)&&r(t=>{let n=R4(t?.tasks??[],e.tasks),r=e.target&&e.target!==t?.target,i=e.phase&&e.phase!==t?.phase,a=n.length!==(t?.tasks?.length??0)||n.some((e,n)=>{let r=t?.tasks?.[n];return!r||r.id!==e.id||r.status!==e.status||r.title!==e.title||r.note!==e.note});return!r&&!i&&!a?t:{...t,tasks:n,target:e.target??t?.target,phase:e.phase??t?.phase}})},[i,r]);let f=n?.target;(0,y.useEffect)(()=>{if(!f)return;let e=!1;return fetch(`/api/v1/workbench/dossier?target=${encodeURIComponent(f)}`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&Array.isArray(t.tasks)&&t.tasks.length!==0&&r(e=>{let n=R4(e?.tasks??[],t.tasks??[]),r=t.target&&!e?.target,i=t.phase&&!e?.phase,a=n.length!==(e?.tasks?.length??0)||n.some((t,n)=>{let r=e?.tasks?.[n];return!r||r.id!==t.id||r.status!==t.status||r.title!==t.title});return!r&&!i&&!a?e:{...e,tasks:n,target:e?.target??t.target,phase:e?.phase??t.phase}})}).catch(()=>{}),()=>{e=!0}},[f,r]);let m=n?.tasks??[],h=n?.target,g=n?.phase,_=(0,y.useMemo)(()=>{let e={all:m.length};for(let t of O4)e[t]=0;for(let t of m)e[t.status]=(e[t.status]??0)+1;return e},[m]),v=(0,y.useMemo)(()=>c===`all`?m:m.filter(e=>e.status===c),[m,c]),x=(e,t,n)=>{let r=t||h;r&&fetch(`/api/v1/workbench/dossier`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:r,tasks:e,phase:n||g})}).catch(()=>{})},S=e=>{let t=`pending`;e.status===`pending`?t=`testing`:e.status===`testing`?t=`confirmed`:e.status===`confirmed`?t=`pending`:e.status===`blocked`?t=`testing`:e.status===`rejected`&&(t=`pending`);let n=m.map(n=>n.id===e.id?{...n,status:t}:n);r(e=>({...e,tasks:n})),x(n)},C=(e,t)=>{let n=m.map(n=>n.id===e?{...n,status:t}:n);r(e=>({...e,tasks:n})),x(n)},w=e=>{let t=m.filter(t=>t.id!==e);r(e=>({...e,tasks:t})),x(t)},T=()=>{let e=a.trim();if(!e)return;let t={id:L4(m),title:e,status:`pending`},n=[...m,t];r(e=>({...e,tasks:n})),x(n),s(``),d(!1)};return(0,b.jsxs)(`div`,{className:`flex h-full flex-col bg-card text-card-foreground ${e}`,children:[(0,b.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border px-3.5 py-2.5`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(Hf,{className:`size-4.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,b.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-foreground truncate`,children:`Task Board`}),m.length>0?(0,b.jsx)(Yx,{variant:`secondary`,className:`px-1.5 py-0 text-[11px] font-mono font-medium`,children:m.length}):null]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[h?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground bg-muted/60 px-2 py-0.5 rounded-md font-mono truncate max-w-32`,title:`Bound target: ${h}`,children:[(0,b.jsx)(ap,{className:`size-3 text-primary shrink-0`}),(0,b.jsx)(`span`,{className:`truncate`,children:h})]}):null,g?(0,b.jsx)(Yx,{variant:`outline`,className:`text-[10px] uppercase font-mono tracking-wider px-1.5 py-0`,children:g}):null,(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground`,onClick:()=>d(e=>!e),title:`Add task`,children:[(0,b.jsx)(Zf,{className:`size-4`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Add task`})]}),t?(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground md:hidden`,onClick:t,title:`Close panel`,children:[(0,b.jsx)(Of,{className:`size-4`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Close panel`})]}):null]})]}),m.length>0?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/60 px-3 py-1.5 text-xs`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>l(`all`),className:`rounded-md px-2 py-0.5 text-xs font-medium transition-colors ${c===`all`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[`All (`,_.all,`)`]}),O4.map(e=>{let t=_[e]??0;return t===0&&c!==e?null:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-xs capitalize font-medium transition-colors ${c===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,b.jsx)(`span`,{children:e}),(0,b.jsxs)(`span`,{className:`font-mono text-[10px] opacity-70`,children:[`(`,t,`)`]})]},e)})]}):null,u?(0,b.jsxs)(`div`,{className:`border-b border-border/80 bg-muted/30 p-2.5 flex items-center gap-2`,children:[(0,b.jsx)(p,{autoFocus:!0,value:a,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&d(!1)},placeholder:`New task thesis (e.g. Test IDOR on /api/user)...`,className:`h-8 text-xs bg-background`}),(0,b.jsx)(o,{size:`sm`,className:`h-8 px-2.5 text-xs shrink-0`,onClick:T,children:`Add`})]}):null,(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-3`,children:m.length===0?(0,b.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center text-center px-4`,children:[(0,b.jsx)(`div`,{className:`flex size-14 items-center justify-center rounded-2xl bg-muted/40 mb-3 border border-border/40`,children:(0,b.jsx)(Hf,{className:`size-8 text-muted-foreground/50`,"aria-hidden":`true`})}),(0,b.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:h?`No tasks yet for ${h}`:`No tasks yet.`}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground max-w-56 leading-relaxed`,children:h?`Analyzing target surface and recording hunt theses...`:`Ask the assistant to add some!`}),(0,b.jsxs)(o,{variant:`outline`,size:`sm`,className:`mt-4 h-7 text-xs gap-1.5 text-muted-foreground hover:text-foreground`,onClick:()=>d(!0),children:[(0,b.jsx)(Zf,{className:`size-3.5`}),`Add task`]})]}):v.length===0?(0,b.jsxs)(`div`,{className:`flex h-full min-h-36 flex-col items-center justify-center text-center text-muted-foreground text-xs py-8`,children:[(0,b.jsxs)(`p`,{children:[`No tasks with status "`,c,`".`]}),(0,b.jsx)(o,{variant:`link`,size:`sm`,className:`text-xs mt-1`,onClick:()=>l(`all`),children:`Show all tasks`})]}):(0,b.jsx)(`ul`,{className:`flex flex-col gap-2`,children:v.map(e=>{let t=K4[e.status]??Af,n=q4[e.status]??q4.pending,r=e.status===`confirmed`;return(0,b.jsx)(`li`,{className:`group relative flex flex-col gap-1.5 rounded-lg border border-border/70 bg-card p-2.5 transition-all hover:border-border hover:shadow-xs`,children:(0,b.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>S(e),title:`Status: ${e.status}. Click to cycle.`,"aria-label":`Toggle task status for ${e.title}`,className:`mt-0.5 flex size-4.5 shrink-0 items-center justify-center rounded-md border transition-all ${r?`border-emerald-500 bg-emerald-500 text-white dark:text-black`:n.ring}`,children:r?(0,b.jsx)(Sf,{className:`size-3 stroke-[3]`}):e.status===`testing`?(0,b.jsx)(Uf,{className:`size-2.5 animate-spin text-blue-500`}):(0,b.jsx)(`span`,{className:`size-1.5 rounded-full bg-transparent group-hover:bg-muted-foreground/30`})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[10px] font-semibold text-muted-foreground/80 tracking-wider`,children:e.id}),(0,b.jsxs)(`div`,{className:`relative inline-flex items-center`,children:[(0,b.jsx)(t,{className:`pointer-events-none absolute left-1.5 size-2.5 opacity-70`}),(0,b.jsx)(`select`,{value:e.status,onChange:t=>C(e.id,t.target.value),"aria-label":`Change status for task ${e.id}`,className:`h-4.5 appearance-none rounded border pl-4.5 pr-4 text-[10px] font-medium transition-colors cursor-pointer outline-none ${n.badge}`,children:O4.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))}),(0,b.jsx)(Cf,{className:`pointer-events-none absolute right-1 size-2.5 opacity-60`})]})]}),(0,b.jsx)(`p`,{className:`text-xs leading-snug break-words ${r?`text-muted-foreground line-through`:`text-foreground`}`,children:e.title}),e.note?(0,b.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground/90 bg-muted/40 rounded px-1.5 py-0.5 border border-border/40 font-mono`,children:e.note}):null]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>w(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded-sm`,title:`Delete task`,"aria-label":`Delete task`,children:(0,b.jsx)(up,{className:`size-3.5`})})]})},e.id)})})}),m.length>0?(0,b.jsxs)(`footer`,{className:`border-t border-border px-3 py-2 flex items-center justify-between text-[11px] text-muted-foreground bg-muted/20`,children:[(0,b.jsxs)(`span`,{children:[_.confirmed??0,` of `,m.length,` confirmed`]}),(0,b.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-[11px] text-muted-foreground hover:text-destructive`,onClick:()=>r(e=>({...e,tasks:[]})),children:`Clear all`})]}):null]})}function Y4({request:e,respond:t}){let[n,r]=(0,y.useState)(e.kind===`editor`?e.prefill??``:``),i=e=>void t(e);return(0,b.jsxs)(`div`,{className:`bg-card grid gap-2 rounded-md border border-l-[3px] border-l-primary p-3`,role:`group`,"aria-label":`The agent is asking for approval`,children:[(0,b.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,b.jsx)(rp,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),e.title]}),e.kind===`confirm`?(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs break-words whitespace-pre-wrap`,children:e.message}):null,e.timeoutMs?(0,b.jsxs)(`p`,{className:`text-muted-foreground text-[0.7rem] tabular-nums`,children:[`Auto-dismisses after `,Math.round(e.timeoutMs/1e3),`s`]}):null,e.kind===`confirm`?(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(o,{size:`sm`,onClick:()=>i({requestId:e.id,confirmed:!0}),children:`Allow`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,confirmed:!1}),children:`Deny`})]}):null,e.kind===`select`?(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.options.map(t=>(0,b.jsx)(o,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,value:t}),children:t},t)),(0,b.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]}):null,e.kind===`input`||e.kind===`editor`?(0,b.jsxs)(`form`,{className:`grid gap-2`,onSubmit:t=>{t.preventDefault(),i({requestId:e.id,value:n})},children:[e.kind===`editor`?(0,b.jsx)(o2,{rows:6,value:n,onChange:e=>r(e.target.value)}):(0,b.jsx)(p,{value:n,placeholder:e.placeholder??``,onChange:e=>r(e.target.value)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(o,{size:`sm`,type:`submit`,children:`Submit`}),(0,b.jsx)(o,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]})]}):null]})}function X4(){let{requests:e,respond:t}=$$();return e.length===0?null:(0,b.jsx)(`div`,{className:`grid gap-2 border-b px-3 py-2`,children:e.map(e=>(0,b.jsx)(Y4,{request:e,respond:t},e.id))})}function Z4({className:e,...t}){return(0,b.jsx)(`select`,{"data-slot":`native-select`,className:a(`border-input bg-background text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive h-9 w-full min-w-0 cursor-pointer rounded-md border px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}function Q4({title:e,detail:t,action:n,compact:r}){return(0,b.jsxs)(h,{className:`state ${r?`state-compact`:``}`,"aria-live":`polite`,children:[(0,b.jsx)(`div`,{className:`mb-1 grid size-9 place-items-center rounded-full border bg-[var(--accent-soft)] text-primary [&_svg]:size-[18px]`,children:(0,b.jsx)(np,{"aria-hidden":`true`})}),(0,b.jsx)(`h2`,{children:e}),(0,b.jsx)(`p`,{children:t}),n]})}var $4=`session`,e3=`kifaru:session`,t3={kind:`latest`},n3={kind:`all`};function r3(e){return e.kind===`pinned`?e.id:e.kind===`all`?`all`:null}function i3(e){return e?e===`all`?n3:e===`latest`?t3:{kind:`pinned`,id:e}:t3}function a3(e,t){return i3(new URLSearchParams(e).get($4)||t)}function o3(e,t){if(e.kind!==`all`)return e.kind===`pinned`?e.id:t?.[0]?.id}function s3(e,t){if(e.kind!==`latest`)return null;let n=t?.[0]?.id;return n?{kind:`pinned`,id:n}:null}function c3(e){return e?.source===`web`}function l3(e,t){if(e.kind===`all`)return{kind:`fresh`};if(e.kind===`pinned`){let n=t?.find(t=>t.id===e.id);return n&&!c3(n)?{kind:`external`,session:n}:{kind:`thread`,threadId:e.id}}if(!t)return{kind:`loading`};let n=t[0];return n?c3(n)?{kind:`thread`,threadId:n.id}:{kind:`external`,session:n}:{kind:`fresh`}}function u3(e,t){return!(!t||e.kind===`all`||e.kind===`pinned`&&e.id===t)}function d3(){if(typeof window>`u`)return t3;let e=null;try{e=window.localStorage.getItem(e3)}catch{}return a3(window.location.search,e)}function f3(e){if(typeof window>`u`)return;let t=r3(e);try{t?window.localStorage.setItem(e3,t):window.localStorage.removeItem(e3)}catch{}let n=new URL(window.location.href);t?n.searchParams.set($4,t):n.searchParams.delete($4),n.toString()!==window.location.href&&window.history.replaceState({},``,n.toString())}var p3=SK((e,t)=>({selection:d3(),select:t=>{f3(t),e({selection:t})},resolveLatest:n=>{let r=s3(t().selection,n);r&&(f3(r),e({selection:r}))}}));if(typeof window<`u`){let e=()=>f3(p3.getState().selection);e(),document.addEventListener(`astro:page-load`,e)}var m3=6e4,h3=500,g3=1e4,_3=100,v3=new Set([`listThreads`,`getThread`,`getAvailableModels`]),y3=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchTransportError`}},b3=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchRpcError`}};function x3(){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/api/v1/workbench/ws`}function S3(e={}){let t=e.url??x3(),n=new Map,r=new Map,i=null,a=0,o,s=!1,c=!1,l=0;function u(t){e.onStatusChange?.(t)}function d(t){e.onError?.(t instanceof Error?t:Error(String(t)))}function f(e,t){let r=n.get(e);r&&(n.delete(e),clearTimeout(r.timer),r.reject(t))}function p(e,t=!1){return e.phase===`sent`?new y3(`OUTCOME_UNKNOWN`,`Confirmation for ${e.frame.method} was lost. The request may have been accepted. Reconnect and check the thread before retrying.`):new y3(t?`TIMEOUT_NOT_SENT`:`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`)}function m(e){if(i&&i.readyState===WebSocket.OPEN&&n.has(e.frame.id))try{i.send(JSON.stringify(e.frame)),e.phase=`sent`}catch{f(e.frame.id,new y3(`SEND_FAILED`,`The request could not be sent.`))}}function h(e){if(i&&i.readyState===WebSocket.OPEN)try{i.send(JSON.stringify(e))}catch(e){d(e),i.close()}}function g(){if(s||o!==void 0)return;let t=Math.min((e.reconnectBaseMs??h3)*2**a,g3);a+=1,o=setTimeout(()=>{o=void 0,_()},t)}function _(){if(s||i)return;u(`connecting`);let o;try{o=e.createSocket?.(t)??new WebSocket(t)}catch(e){d(e),u(`closed`),g();return}i=o,o.onopen=()=>{if(!(s||i!==o)){a=0;for(let[e,t]of r)h({kind:`subscribe`,threadId:e,includeSnapshot:c||t.includeSnapshot});c=!0;for(let e of n.values())e.phase===`queued`&&m(e);u(`open`)}},o.onmessage=e=>{if(s||i!==o)return;let t;try{t=E3(JSON.parse(String(e.data)))}catch{d(new y3(`INVALID_SERVER_FRAME`,`The workspace sent an invalid response. Reconnecting.`)),o.close();return}if(t.kind===`event`){let e=t.event,n=r.get(e.threadId)?.listeners;for(let t of[...n??[]])try{t(e)}catch(e){d(e)}return}let a=n.get(t.id);if(a){if(t.kind===`rpc_error`){f(t.id,new b3(t.code,t.message));return}if(!D3(a.frame.method,t.result)){f(t.id,new y3(`INVALID_SERVER_FRAME`,`The workspace returned an invalid result.`));return}n.delete(t.id),clearTimeout(a.timer),a.resolve(t.result===null?void 0:t.result)}},o.onerror=()=>{},o.onclose=()=>{if(!(s||i!==o)){i=null;for(let[e,t]of n)f(e,p(t));u(`closed`),g()}}}function v(t,r){if(s)return Promise.reject(new y3(`DISPOSED`,`The workspace connection was closed.`));if(!v3.has(t)&&i?.readyState!==WebSocket.OPEN)return Promise.reject(new y3(`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`));if(n.size>=_3)return Promise.reject(new y3(`TOO_MANY_REQUESTS`,`Too many workspace requests are pending.`));let a=`rpc-${l++}`;return new Promise((i,o)=>{let s=setTimeout(()=>{let e=n.get(a);e&&f(a,p(e,!0))},e.requestTimeoutMs??m3),c={frame:{kind:`rpc`,id:a,method:t,params:r},phase:`queued`,resolve:i,reject:o,timer:s};n.set(a,c),m(c)})}return _(),{dispose(){if(!s){s=!0,o&&clearTimeout(o),o=void 0,r.clear();for(let e of n.keys())f(e,new y3(`DISPOSED`,`The workspace connection was closed.`));i&&(i.onopen=null,i.onmessage=null,i.onclose=null,i.onerror=null,i.close()),i=null}},listThreads:e=>v(`listThreads`,e?[e]:[]),createThread:e=>v(`createThread`,e?[e]:[]),getThread:e=>v(`getThread`,[e]),sendMessage:(e,t)=>v(`sendMessage`,[e,t]),cancelRun:e=>v(`cancelRun`,[e]),clearQueue:e=>v(`clearQueue`,[e]),getAvailableModels:e=>v(`getAvailableModels`,e?[e]:[]),setModel:(e,t)=>v(`setModel`,[e,t]),setThinkingLevel:(e,t)=>v(`setThinkingLevel`,[e,t]),renameThread:(e,t)=>v(`renameThread`,[e,t]),archiveThread:e=>v(`archiveThread`,[e]),unarchiveThread:e=>v(`unarchiveThread`,[e]),deleteThread:e=>v(`deleteThread`,[e]),respondToHostUiRequest:(e,t)=>v(`respondToHostUiRequest`,[e,t]),subscribe(e,t,n){if(s)return()=>{};let a=e=>t(e),o=r.get(e);return o?(o.listeners.add(a),n?.includeSnapshot!==!1&&(o.includeSnapshot=!0,i?.readyState===WebSocket.OPEN&&h({kind:`subscribe`,threadId:e,includeSnapshot:!0}))):(o={listeners:new Set,includeSnapshot:n?.includeSnapshot!==!1},r.set(e,o),o.listeners.add(a),h({kind:`subscribe`,threadId:e,includeSnapshot:o.includeSnapshot})),()=>{let t=r.get(e);t&&t.listeners.delete(a)&&t.listeners.size===0&&(r.delete(e),h({kind:`unsubscribe`,threadId:e}))}}}}function C3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function w3(e){return C3(e)&&typeof e.id==`string`&&[`idle`,`running`,`failed`].includes(String(e.status))}function T3(e){return C3(e)&&w3(e.metadata)&&Array.isArray(e.messages)}function E3(e){if(!C3(e))throw Error(`Invalid frame`);if(e.kind===`event`){let t=e.event;if(C3(t)&&typeof t.type==`string`&&typeof t.threadId==`string`&&Number.isSafeInteger(t.seq)&&Number(t.seq)>=0&&(t.type!==`snapshot`||T3(t.snapshot)))return e}else if(typeof e.id==`string`&&(e.kind===`rpc_ok`&&`result`in e||e.kind===`rpc_error`&&typeof e.message==`string`&&typeof e.code==`string`))return e;throw Error(`Invalid frame`)}function D3(e,t){switch(e){case`listThreads`:return Array.isArray(t)&&t.every(w3);case`getThread`:case`createThread`:return T3(t);case`getAvailableModels`:return Array.isArray(t)&&t.every(e=>C3(e)&&typeof e.provider==`string`&&typeof e.modelId==`string`);case`clearQueue`:return C3(t)&&Array.isArray(t.steering)&&t.steering.every(e=>typeof e==`string`)&&Array.isArray(t.followUp)&&t.followUp.every(e=>typeof e==`string`);default:return t===null}}async function O3(){try{let e=await fetch(`/api/v1/workbench/status`,{credentials:`same-origin`});return e.status===401||e.status===403?`unauthenticated`:e.ok?(await e.json()).enabled?`up`:`unconfigured`:`down`}catch{return`down`}}var k3={connecting:`reconnecting`,open:`online`,closed:`dropped`};function A3(){let{compaction:e,retry:t,contextUsage:n,readiness:r}=X$(),i=r&&r.state!==`ready`?r:null;return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?(0,b.jsx)(Yx,{variant:`high`,children:i.message}):null,e.active?(0,b.jsx)(Yx,{variant:`secondary`,children:`Compacting context…`}):null,t.active?(0,b.jsxs)(Yx,{variant:`high`,children:[`Retrying (attempt `,t.attempt,`)`]}):null,n?.percent==null?null:(0,b.jsxs)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,title:`${n.tokens??`?`} / ${n.contextWindow} tokens`,children:[Math.round(n.percent),`% context`]})]})}var j3=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function M3({client:e}){let t=Z$(),n=$(e=>e.threadListItem),r=n?n.externalId??n.remoteId??n.id:null,[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)(null);(0,y.useEffect)(()=>{let t=!1;return e.getAvailableModels().then(e=>{t||a(e)},()=>{}),()=>{t=!0}},[e]);let c=t?.status===`running`,l=t?.config,u=l?.provider&&l.modelId?`${l.provider}/${l.modelId}`:``,d=l?.thinkingLevel??``,f=async e=>{s(null);try{await e()}catch(e){s(e instanceof Error?e.message:String(e))}};return r?(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.length>0?(0,b.jsxs)(Z4,{"aria-label":`Model`,title:`Model for this conversation`,value:u,disabled:c,onChange:t=>{let[n,...i]=t.target.value.split(`/`),a=i.join(`/`);n&&a&&f(()=>e.setModel(r,{provider:n,modelId:a}))},className:`h-7 w-auto max-w-44 text-xs`,children:[!u||i.every(e=>`${e.provider}/${e.modelId}`!==u)?(0,b.jsx)(`option`,{value:u,children:u||`Select a model`}):null,i.map(e=>(0,b.jsx)(`option`,{value:`${e.provider}/${e.modelId}`,children:e.name},`${e.provider}/${e.modelId}`))]}):null,(0,b.jsxs)(Z4,{"aria-label":`Thinking level`,title:`Thinking level for this conversation`,value:d,disabled:c,onChange:t=>{let n=t.target.value;f(()=>e.setThinkingLevel(r,n))},className:`h-7 w-auto text-xs`,children:[(0,b.jsx)(`option`,{value:``,children:`Thinking…`}),j3.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}),o?(0,b.jsx)(`span`,{className:`text-destructive max-w-64 truncate text-xs`,title:o,children:o}):null]}):null}function N3({status:e,client:t,showTaskBoard:n,onToggleTaskBoard:r}){let i=Z$();return(0,b.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`strong`,{className:`truncate text-sm font-semibold`,children:i?.title??`Live Workspace`}),i?.status===`running`?(0,b.jsx)(Yx,{variant:`low`,children:`streaming`}):null]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(A3,{}),(0,b.jsx)(M3,{client:t}),e===`open`?null:(0,b.jsx)(D4,{phase:k3[e]}),(0,b.jsxs)(o,{variant:n?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:r,title:`Toggle Dossier Task Board`,"aria-label":`Toggle Dossier Task Board`,children:[(0,b.jsx)(Hf,{className:`size-3.5`}),(0,b.jsx)(`span`,{className:`hidden sm:inline`,children:`Tasks`})]})]})]})}function P3({initialThreadId:e}){let[t,n]=(0,y.useState)(`connecting`),[r,i]=(0,y.useState)(!0),o=(0,y.useMemo)(()=>S3({onStatusChange:n}),[]);(0,y.useEffect)(()=>()=>o.dispose(),[o]);let s=Y$({client:o,includeArchived:!0,...e===void 0?{}:{initialThreadId:e},onThreadIdChange:e=>{let{selection:t,select:n}=p3.getState();e&&u3(t,e)&&n({kind:`pinned`,id:e})}}),c=(0,y.useMemo)(()=>PP({unstable_interactables:YB()}),[]);return(0,b.jsx)(kK,{runtime:s,config:c,children:(0,b.jsxs)(`div`,{className:a(`grid h-[var(--workspace-height)] min-h-120 grid-cols-1 gap-4`,r?`xl:grid-cols-[minmax(0,16rem)_minmax(0,1fr)_minmax(0,21rem)] md:grid-cols-[minmax(0,1fr)_minmax(0,20rem)]`:`md:grid-cols-[minmax(0,17rem)_minmax(0,1fr)]`),children:[(0,b.jsx)(h,{className:a(`min-h-0 overflow-hidden p-0`,r?`hidden xl:flex`:`hidden md:flex`),children:(0,b.jsx)(f4,{})}),(0,b.jsxs)(h,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:[(0,b.jsx)(N3,{status:t,client:o,showTaskBoard:r,onToggleTaskBoard:()=>i(e=>!e)}),(0,b.jsx)(X4,{}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,b.jsx)(W2,{})})]}),r?(0,b.jsx)(h,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:(0,b.jsx)(J4,{onClose:()=>i(!1)})}):null]})})}function F3({session:e,onStartChat:t}){return(0,b.jsxs)(h,{className:`mx-auto max-w-lg items-start gap-3 p-6`,children:[(0,b.jsx)(`h2`,{className:`text-base font-semibold`,children:`This session ran outside the live workspace`}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`Session `,(0,b.jsx)(`span`,{className:`font-mono text-xs`,children:e.id}),` came from`,` `,(0,b.jsx)(`span`,{className:`font-mono text-xs`,children:e.source}),`. Its findings, runs and evidence are all here — the transcript is not, because the conversation happened in the TUI rather than over the workbench socket.`]}),(0,b.jsx)(o,{onClick:t,children:`Start a chat for this session`})]})}function I3(){let e=p3(e=>e.selection),t=tf({queryKey:[`agent-sessions`],queryFn:_x.agentSessions}),[n,r]=(0,y.useState)(null),i=l3(e,t.data?.items),a=i.kind===`external`&&n===i.session.id;if(i.kind===`loading`)return(0,b.jsx)(Q4,{compact:!0,title:`Opening the live workspace…`,detail:`Resolving the current session.`});if(i.kind===`external`&&!a)return(0,b.jsx)(F3,{session:i.session,onStartChat:()=>r(i.session.id)});let o=i.kind===`thread`?i.threadId:void 0;return(0,b.jsx)(P3,{initialThreadId:o},o??`new`)}function L3({state:e}){return(0,b.jsxs)(h,{className:`mx-auto max-w-lg items-start gap-3 p-6`,children:[(0,b.jsx)(`h2`,{className:`text-base font-semibold`,children:e===`unauthenticated`?`Sign in required`:e===`unconfigured`?`Live workspace not configured`:`Live workspace unreachable`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e===`unauthenticated`?`The live workspace is available to authenticated platform users.`:e===`unconfigured`?`Set WORKBENCH_CWD on the platform server to enable the hosted agent runtime (see docs/infra/workbench-integration.md).`:`The platform server did not answer. Check that it is running.`}),e===`unauthenticated`?(0,b.jsx)(o,{variant:`outline`,asChild:!0,children:(0,b.jsx)(`a`,{href:`/login`,children:`Sign in`})}):null]})}function R3({workflow:e}){let t=Bd(),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),[m,_]=(0,y.useState)([]),v=[...new Set(e.stages.flatMap(e=>e.skillRefs))],x=e.stages.filter(e=>e.optional),S=nf({mutationFn:()=>_x.startLocalRun({workflowKey:e.key,target:s.trim(),permissionMode:d?`yolo`:`scoped`,selectedStageKeys:m,allowedActions:[`read_files`,`command_execution`]}),onSuccess:()=>void t.invalidateQueries({queryKey:[`local-runs`]})});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(h,{className:`cursor-pointer transition-colors hover:border-primary focus-visible:outline-2 focus-visible:outline-primary`,role:`button`,tabIndex:0,onClick:()=>r(!0),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(!0))},"aria-label":`Run ${e.name} headlessly`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(Yx,{variant:Jx(W3(e)),children:[`Highest risk `,W3(e)]}),(0,b.jsxs)(`span`,{className:`font-mono`,children:[`v`,e.version]})]}),(0,b.jsx)(`h2`,{children:e.name}),(0,b.jsx)(`p`,{children:e.description}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,b.jsx)(`span`,{children:e},e))}),(0,b.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3`,children:[(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm font-medium text-primary`,children:[`Run headless `,(0,b.jsx)(_f,{size:16})]}),(0,b.jsxs)(o,{type:`button`,size:`sm`,variant:`outline`,onClick:e=>{e.stopPropagation(),a(!0)},children:[(0,b.jsx)(Jf,{size:14}),` Edit skill`]})]})]}),(0,b.jsx)(z3,{workflow:e,open:i,onOpenChange:a}),(0,b.jsx)(i1,{open:n,onOpenChange:e=>{r(e),e||(c(``),u(!1),f(!1),_([]),S.reset())},children:(0,b.jsxs)(c1,{className:`max-h-[90vh] overflow-y-auto`,children:[(0,b.jsxs)(l1,{children:[(0,b.jsxs)(d1,{children:[`Run `,e.name]}),(0,b.jsx)(f1,{children:`Start a local headless run. Each stage loads its workflow skill pack and the report appears under Audits and Reports when the run completes.`})]}),S.data?(0,b.jsx)(`div`,{className:`grid gap-3 text-sm`,children:(0,b.jsx)(V3,{runId:S.data.runId})}):(0,b.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&l&&!S.isPending&&S.mutate()},children:[(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(g,{htmlFor:`workflow-target-${e.key}`,children:`Target or scope`}),(0,b.jsx)(p,{id:`workflow-target-${e.key}`,value:s,onChange:e=>c(e.target.value),placeholder:`https://example.com or an authorized asset`,required:!0})]}),(0,b.jsxs)(`div`,{className:`grid gap-1 text-sm`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:`Skill pack`}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:v.length?v.join(`, `):`No skill refs configured`})]}),x.length>0?(0,b.jsxs)(`fieldset`,{className:`grid gap-2 text-sm`,children:[(0,b.jsx)(`legend`,{className:`font-medium`,children:`Optional stages`}),x.map(e=>(0,b.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:m.includes(e.key),onChange:t=>_(n=>t.target.checked?[...n,e.key]:n.filter(t=>t!==e.key))}),(0,b.jsxs)(`span`,{children:[e.name,` `,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.risk,` risk)`]})]})]},e.key))]}):null,(0,b.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),required:!0}),(0,b.jsx)(`span`,{children:`I am authorized to assess this target. The local agent may execute commands on the gateway host.`})]}),(0,b.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-destructive/50 bg-destructive/5 p-3 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`strong`,{children:`YOLO mode — no per-command approval.`}),` The agent can run arbitrary shell commands and read or change local files on the gateway host until the run ends. Commands are not sandboxed; only use this on a trusted local machine and an authorized target. Explicit prohibitions and run time/cost limits still apply.`]})]}),S.isError?(0,b.jsx)(`p`,{role:`alert`,className:`text-destructive text-sm`,children:S.error.message}):null,(0,b.jsx)(u1,{children:(0,b.jsxs)(o,{type:`submit`,disabled:!s.trim()||!l||S.isPending,children:[(0,b.jsx)(Xf,{size:16}),` `,S.isPending?`Starting…`:`Start headless run`]})})]})]})})]})}function z3({workflow:e,open:t,onOpenChange:n}){let r=tf({queryKey:[`workflow-skill`,e.key],queryFn:()=>_x.workflowSkill(e.key),enabled:t,staleTime:0}),i=r.error instanceof hx?r.error.status===404?`The local gateway does not serve skill editing yet. Restart it and try again.`:r.error.status===403?`Skill editing requires an admin session with local runs enabled on this gateway.`:`Could not load this skill (${r.error.code}).`:`Could not load this skill. Check the gateway connection and try again.`,[a,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1);(0,y.useEffect)(()=>{t&&r.data&&s(r.data.item.markdown)},[t,r.data?.item.revision]);let u=nf({mutationFn:()=>_x.saveWorkflowSkill(e.key,a,r.data.item.revision),onSuccess:e=>{l(!0),r.refetch(),s(e.item.markdown)}});return(0,b.jsx)(i1,{open:t,onOpenChange:e=>{n(e),e||(u.reset(),l(!1))},children:(0,b.jsxs)(c1,{className:`max-h-[90vh] max-w-4xl overflow-y-auto`,children:[(0,b.jsxs)(l1,{children:[(0,b.jsxs)(d1,{children:[`Edit `,e.name,` skill`]}),(0,b.jsx)(f1,{children:`Edit the Markdown instructions the agent loads during this workflow. Saved changes apply to runs when they start; runs already in progress keep their original copy.`})]}),r.isLoading?(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading skill…`}):r.isError?(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:i}),(0,b.jsx)(o,{type:`button`,variant:`outline`,onClick:()=>void r.refetch(),children:`Retry`})]}):r.data?(0,b.jsxs)(`div`,{className:`grid gap-3`,children:[(0,b.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.data.item.skillName,` · `,r.data.item.customized?`Local override`:`Bundled default`]}),(0,b.jsx)(g,{htmlFor:`workflow-skill-${e.key}`,children:`Markdown`}),(0,b.jsx)(o2,{id:`workflow-skill-${e.key}`,value:a,onChange:e=>{s(e.target.value),l(!1)},className:`min-h-[45vh] font-mono text-sm`,spellCheck:!1}),u.isError?(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u.error.message}):null,c?(0,b.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saved. The next run will use this version.`}):null,(0,b.jsxs)(u1,{children:[(0,b.jsx)(o,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:`Close`}),(0,b.jsx)(o,{type:`button`,disabled:u.isPending||!a.trim()||a.trim()===r.data.item.markdown.trim(),onClick:()=>u.mutate(),children:u.isPending?`Saving…`:`Save skill`})]})]}):null]})})}function B3(){let e=tf({queryKey:[`local-runs`],queryFn:_x.localRuns,refetchInterval:2e3,retry:!1}),[t,n]=(0,y.useState)(null);if(e.isLoading)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Headless run activity`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading run history…`})]});if(e.isError)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Headless run activity`}),(0,b.jsx)(`p`,{className:`text-destructive text-sm`,children:`Could not load local run status. Local runs require an admin session on this gateway.`})]});let r=e.data?.items??[];if(!r.length)return(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:`Headless run activity`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No headless runs yet. Select a workflow above to start one.`})]});let i=r.find(e=>e.runId===t)??r[0];return(0,b.jsxs)(h,{className:`grid gap-4`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{children:`Headless run activity`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Live stage progress, retained after you close the launch dialog.`})]}),(0,b.jsx)(`select`,{className:`max-w-full rounded-md border bg-transparent px-2 py-1 text-sm`,value:i.runId,onChange:e=>n(e.target.value),children:r.map(e=>(0,b.jsxs)(`option`,{value:e.runId,children:[e.workflowKey,` · `,e.target,` · `,e.status]},e.runId))})]}),(0,b.jsx)(H3,{run:i})]})}function V3({runId:e}){let t=tf({queryKey:[`local-run`,e],queryFn:()=>_x.localRun(e),refetchInterval:e=>![`completed`,`partial`,`failed`,`cancelled`].includes(e.state.data?.item.status??``)&&2e3,retry:2});return t.isError?(0,b.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:`Could not load run progress.`}):t.data?(0,b.jsx)(H3,{run:t.data.item}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Starting run and loading its stages…`})}function H3({run:e}){let t=e.stages.filter(e=>![`pending`,`running`].includes(e.status)).length;return(0,b.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(U3,{status:e.status}),(0,b.jsx)(`strong`,{children:e.workflowKey}),e.permissionMode===`yolo`?(0,b.jsx)(Yx,{variant:`high`,children:`YOLO mode`}):null,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.status,` · `,t,`/`,e.stages.length,` stages · `,e.runId.slice(0,8)]})]}),(0,b.jsxs)(`p`,{className:`break-all text-muted-foreground`,children:[`Target: `,e.target]}),(0,b.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted`,role:`progressbar`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":e.stages.length,children:(0,b.jsx)(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${e.stages.length?t/e.stages.length*100:0}%`}})}),(0,b.jsx)(`ol`,{className:`grid gap-0 border-l pl-4`,children:e.stages.map(e=>(0,b.jsxs)(`li`,{className:`relative flex items-start gap-3 border-b py-2 last:border-b-0`,children:[(0,b.jsx)(`span`,{className:`absolute -left-[1.43rem] bg-card`,children:(0,b.jsx)(U3,{status:e.status})}),(0,b.jsxs)(`span`,{className:`min-w-0`,children:[(0,b.jsx)(`strong`,{children:e.name}),(0,b.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:e.status}),e.summary?(0,b.jsx)(`span`,{className:`mt-1 block text-muted-foreground`,children:e.summary}):null]})]},e.key))}),e.error?(0,b.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:e.error}):null,e.reportAvailable?(0,b.jsx)(o,{asChild:!0,size:`sm`,variant:`outline`,children:(0,b.jsxs)(`a`,{href:`/reports`,children:[`View report `,(0,b.jsx)(_f,{size:16})]})}):e.status===`running`?(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`This view updates every two seconds. The report appears after completion.`}):null]})}function U3({status:e}){return e===`running`?(0,b.jsx)(Uf,{size:17,className:`animate-spin text-primary`,"aria-label":`Running`}):e===`completed`||e===`succeeded`?(0,b.jsx)(Df,{size:17,className:`text-green-600`,"aria-label":`Succeeded`}):[`failed`,`blocked`,`interrupted`,`partial`,`cancelled`].includes(e)?(0,b.jsx)(Of,{size:17,className:`text-destructive`,"aria-label":e}):(0,b.jsx)(kf,{size:17,className:`text-muted-foreground`,"aria-label":e})}function W3(e){return e.stages.some(e=>e.risk===`R2`)?`R2`:e.stages.some(e=>e.risk===`R1`)?`R1`:`R0`}function G3({eyebrow:e,title:t,description:n,actions:r,className:i}){return(0,b.jsxs)(`header`,{className:a(`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,i),children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[e?(0,b.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-2 text-2xs font-semibold tracking-[0.12em] uppercase`,children:e}):null,t?(0,b.jsx)(`h1`,{children:t}):null,n?(0,b.jsx)(`p`,{className:`mt-2 mb-0 max-w-[72ch]`,children:n}):null]}),r?(0,b.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r}):null]})}function K3({sessions:e,value:t,onChange:n,className:r,id:i=`agent-session`}){let o=e[0];return(0,b.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,r),children:[(0,b.jsx)(`label`,{className:`text-muted-foreground shrink-0 text-[13px]`,htmlFor:i,children:`Session`}),(0,b.jsxs)(Z4,{"aria-label":`Agent session`,className:`w-auto min-w-0 max-w-[22rem] text-[13px]`,id:i,onChange:e=>n(e.target.value),value:t??`latest`,children:[(0,b.jsx)(`option`,{value:`latest`,children:o?`Latest — ${o.title||`Session`}`:`Latest session`}),(0,b.jsx)(`option`,{value:`all`,children:`All workspace sessions`}),e.map(e=>(0,b.jsxs)(`option`,{value:e.id,children:[e.title||`Session`,` · `,e.findingCount??0,` findings · `,e.runCount??0,` runs`]},e.id))]})]})}var q3=[{id:`azure-openai`,label:`Azure OpenAI`},{id:`openai-compatible`,label:`OpenAI compatible endpoint`},{id:`anthropic`,label:`Anthropic`}];function J3(){let e=tf({queryKey:[`model-credentials`],queryFn:_x.modelCredentials}),t=tf({queryKey:[`my-role`],queryFn:_x.myRole}),[n,r]=(0,y.useState)(`anthropic`),[i,a]=(0,y.useState)(`user`),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(``),m=t.data?.role===`owner`||t.data?.role===`admin`;async function h(e){e.preventDefault(),u(!0),f(``);try{await _x.saveModelCredential(i,n,s),c(``),f(`Key saved. Future model requests will use it according to its scope.`),await vx.invalidateQueries({queryKey:[`model-credentials`]})}catch(e){f(e instanceof Error?e.message:`Could not save the key.`)}finally{u(!1)}}async function _(e){if(confirm(`Remove the ${e.scope} ${e.provider} key?`)){u(!0),f(``);try{await _x.deleteModelCredential(e.scope,e.provider),await vx.invalidateQueries({queryKey:[`model-credentials`]})}catch(e){f(e instanceof Error?e.message:`Could not remove the key.`)}finally{u(!1)}}}return(0,b.jsxs)(`section`,{className:`rounded-xl border bg-card p-5`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Model API keys`}),(0,b.jsx)(`p`,{className:`text-muted-foreground mt-1 text-sm`,children:`Your private key applies to your own model requests. Workspace keys are shared with members and can be managed by an owner or admin. A private key takes priority when both are available.`}),(0,b.jsxs)(`form`,{onSubmit:h,className:`mt-5 grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,b.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,b.jsx)(g,{htmlFor:`model-provider`,children:`Provider`}),(0,b.jsx)(Z4,{id:`model-provider`,value:n,onChange:e=>r(e.target.value),children:q3.map(e=>(0,b.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,b.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,b.jsx)(g,{htmlFor:`model-key-scope`,children:`Who can use it`}),(0,b.jsxs)(Z4,{id:`model-key-scope`,value:i,onChange:e=>a(e.target.value),children:[(0,b.jsx)(`option`,{value:`user`,children:`Only me`}),m?(0,b.jsx)(`option`,{value:`workspace`,children:`Workspace members`}):null]})]}),(0,b.jsxs)(`div`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,b.jsx)(g,{htmlFor:`model-api-key`,children:`API key`}),(0,b.jsx)(p,{id:`model-api-key`,type:`password`,autoComplete:`off`,value:s,onChange:e=>c(e.target.value),minLength:8,required:!0})]}),(0,b.jsx)(o,{type:`submit`,disabled:l||!s.trim(),className:`w-fit`,children:`Save key`})]}),d?(0,b.jsx)(`p`,{className:`mt-3 text-sm`,role:`status`,children:d}):null,(0,b.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[e.data?.items.map(e=>(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3 text-sm`,children:[(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`strong`,{children:q3.find(t=>t.id===e.provider)?.label}),` · `,e.scope===`user`?`Only me`:`Workspace`,` · ending `,e.lastFour]}),e.scope===`user`||m?(0,b.jsx)(o,{type:`button`,variant:`destructive`,size:`sm`,disabled:l,onClick:()=>_(e),children:`Remove`}):null]},`${e.scope}:${e.provider}`)),e.data&&e.data.items.length===0?(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No saved model keys.`}):null,e.isError?(0,b.jsx)(`p`,{className:`text-destructive text-sm`,children:`Could not load model keys.`}):null]})]})}function Y3(){let e=tf({queryKey:[`my-role`],queryFn:_x.myRole}),[t,n]=(0,y.useState)(``),[r,i]=(0,y.useState)(``),[a,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1);if(e.data&&e.data.role!==`owner`&&e.data.role!==`admin`)return null;async function u(e){e.preventDefault(),l(!0),s(``),i(``);try{let e=await _x.createInvitation(t);i(`${window.location.origin}/login#invite=${encodeURIComponent(e.token)}`),n(``)}catch(e){s(e instanceof Error?e.message:`Could not create the invitation.`)}finally{l(!1)}}return(0,b.jsxs)(`section`,{className:`rounded-xl border bg-card p-5`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Invite a member`}),(0,b.jsx)(`p`,{className:`text-muted-foreground mt-1 text-sm`,children:`Create a one-time link. The member sets their own password and can then save a private model key.`}),(0,b.jsxs)(`form`,{onSubmit:u,className:`mt-4 flex flex-wrap items-end gap-3`,children:[(0,b.jsxs)(`div`,{className:`grid min-w-56 flex-1 gap-1.5`,children:[(0,b.jsx)(g,{htmlFor:`invite-email`,children:`Email`}),(0,b.jsx)(p,{id:`invite-email`,type:`email`,value:t,onChange:e=>n(e.target.value),required:!0})]}),(0,b.jsx)(o,{type:`submit`,disabled:c,children:c?`Creating…`:`Create invite link`})]}),a?(0,b.jsx)(`p`,{className:`text-destructive mt-3 text-sm`,role:`alert`,children:a}):null,r?(0,b.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,b.jsx)(g,{htmlFor:`invite-link`,children:`Copy and share this link. It expires in 7 days and is shown only once.`}),(0,b.jsx)(p,{id:`invite-link`,readOnly:!0,value:r,onFocus:e=>e.currentTarget.select()}),(0,b.jsx)(o,{type:`button`,variant:`outline`,className:`w-fit`,onClick:()=>navigator.clipboard.writeText(r),children:`Copy link`})]}):null]})}function X3({section:e}){return(0,b.jsx)(Vd,{client:vx,children:(0,b.jsx)($3,{section:e})})}function Z3(){let e=tf({queryKey:[`workbench-status`],queryFn:O3,retry:1,staleTime:15e3});return e.isLoading?(0,b.jsx)(Q4,{compact:!0,title:`Connecting to the live workspace…`,detail:`Checking the platform agent runtime.`}):e.data&&e.data!==`up`?(0,b.jsx)(L3,{state:e.data}):(0,b.jsx)(I3,{})}function Q3(){return(0,b.jsx)(Vd,{client:vx,children:(0,b.jsx)(Z3,{})})}function $3({section:e}){let t=p3(e=>e.selection),n=p3(e=>e.select),r=p3(e=>e.resolveLatest),i=r3(t),a=e=>n(i3(e)),[s,c]=(0,y.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`finding`):null),l=e=>{if(c(e),typeof window<`u`){let t=new URL(window.location.href);e?t.searchParams.set(`finding`,e):t.searchParams.delete(`finding`),window.history.replaceState({},``,t.toString())}},u=tf({queryKey:[`agent-sessions`],queryFn:_x.agentSessions,enabled:e===`runs`||e===`agent`||e===`findings`||e===`dashboard`||e===`lifecycle`,refetchInterval:2e3});(0,y.useEffect)(()=>{u.data?.items&&r(u.data.items)},[u.data?.items,r]);let d=o3(t,u.data?.items),f=tf({queryKey:[`workflows`],queryFn:_x.workflows,enabled:e===`workflows`||e===`assessments`}),m=tf({queryKey:[`overview`,d],queryFn:()=>_x.overview(d),enabled:e===`dashboard`||e===`assessments`||e===`lifecycle`,refetchInterval:2e3}),_=tf({queryKey:[`runs`,d],queryFn:()=>_x.runs({sessionId:d}),enabled:e===`runs`,refetchInterval:2e3}),v=tf({queryKey:[`projects`],queryFn:_x.projects,enabled:e===`assessments`}),x=tf({queryKey:[`assessment-profiles`],queryFn:_x.assessmentProfiles,enabled:e===`assessments`}),S=tf({queryKey:[`findings`,d],queryFn:()=>_x.findings({sessionId:d}),enabled:e===`findings`||e===`dashboard`||e===`lifecycle`||e===`reports`,refetchInterval:6e3}),C=tf({queryKey:[`agent-session`,d],queryFn:()=>_x.agentSession(d),enabled:e===`runs`&&!!d,refetchInterval:2e3}),w=tf({queryKey:[`governance-events`],queryFn:_x.governanceEvents,enabled:e===`reports`}),T=tf({queryKey:[`workers`],queryFn:_x.workers,enabled:e===`administration`}),E=tf({queryKey:[`tokens`],queryFn:_x.tokens,enabled:e===`administration`}),[D,O]=(0,y.useState)(``),[k,A]=(0,y.useState)(30),[j,M]=(0,y.useState)(!1),[N,ee]=(0,y.useState)(null),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(null),[se,ce]=(0,y.useState)(null);async function le(e){e.preventDefault(),M(!0),oe(null);try{let e=await _x.mintToken({label:D.trim()||`CLI Token`,expiresInDays:k});ee(e),O(``),vx.invalidateQueries({queryKey:[`tokens`]})}catch(e){oe(e instanceof Error?e.message:`Failed to mint token`)}finally{M(!1)}}async function ue(e){if(confirm(`Are you sure you want to revoke this token? Any CLI session or automation using it will immediately lose access.`)){ce(e);try{await _x.revokeToken(e),vx.invalidateQueries({queryKey:[`tokens`]})}catch(e){alert(e instanceof Error?e.message:`Failed to revoke token`)}finally{ce(null)}}}let de=[...e===`workflows`||e===`assessments`?[f]:[],...e===`dashboard`?[m,S]:[],...e===`lifecycle`?[m,S]:[],...e===`runs`?[_,u]:[],...e===`runs`&&d?[C]:[],...e===`assessments`?[m,v,x]:[],...e===`findings`?[S,u]:[],...e===`reports`?[w,S]:[],...e===`administration`?[T,E]:[]];if(de.some(e=>e.isLoading))return(0,b.jsx)(Q4,{title:`Loading workspace`,detail:`Reading durable platform state…`});let P=de.find(e=>e.isError);if(P){let e=P.error,t=e&&typeof e==`object`&&`status`in e&&e.status===401;return(0,b.jsx)(Q4,{title:`Platform unavailable`,detail:e instanceof Error?e.message:`The platform could not be reached.`,action:t?(0,b.jsx)(o,{asChild:!0,children:(0,b.jsx)(`a`,{href:`/login`,children:`Sign in`})}):(0,b.jsxs)(o,{onClick:()=>void P.refetch(),children:[(0,b.jsx)(Qf,{}),` Retry`]})})}let fe=Nx(S.data?.findings??[]),pe=fe.filter(Ax);if(e===`dashboard`){let e=Object.fromEntries(Cx.map(e=>[e,pe.filter(t=>t.severity===e).length])),t=m.data?.runs??{},n=Object.values(t).reduce((e,t)=>e+t,0),r=(t.queued??0)+(t.running??0),s=Px(fe),c=fe.filter(e=>e.status===`confirmed`||e.status===`verified`);return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{actions:(0,b.jsx)(K3,{onChange:a,sessions:u.data?.items??[],value:i})}),(0,b.jsxs)(Ix,{children:[(0,b.jsx)(Lx,{hero:!0,tone:s??void 0,label:`Client posture`,value:s?Ex[s].toUpperCase():`NO CONFIRMED RISK`,meta:s?`Worst confirmed finding across ${c.length} confirmed finding${c.length===1?``:`s`}.`:`No finding has been confirmed yet.`}),(0,b.jsx)(Lx,{label:`Open findings`,value:pe.length,meta:`${fe.length-pe.length} resolved`}),(0,b.jsx)(Lx,{label:`Critical / High`,value:`${e.critical} / ${e.high}`,meta:`${c.length} confirmed overall`}),(0,b.jsx)(Lx,{label:`Assessments`,value:n,meta:`${r} in flight`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,b.jsx)(Fx,{title:`Open findings by severity`,sub:`${pe.length} active`,children:(0,b.jsx)(Rx,{counts:e})}),(0,b.jsx)(Fx,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,b.jsx)(zx,{findings:pe})})]}),(0,b.jsx)(Fx,{title:`Highest-priority open findings`,sub:(0,b.jsx)(`a`,{className:`link-more`,href:`/findings`,children:`View all`}),children:(0,b.jsx)(Bx,{findings:kx(pe).slice(0,5),onSelect:e=>{window.location.href=`/findings?finding=${encodeURIComponent(e.id)}`},emptyLabel:`No open findings. Agent runs report findings through the report_finding tool; none have been ingested yet.`})}),(0,b.jsxs)(`section`,{"aria-labelledby":`active-runs`,children:[(0,b.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-1 text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Operations`}),(0,b.jsx)(`h2`,{id:`active-runs`,children:`Active runs`})]}),(0,b.jsxs)(`a`,{className:`link-more`,href:`/runs`,children:[`View all `,(0,b.jsx)(_f,{"aria-hidden":`true`})]})]}),m.data?.recentRuns.filter(e=>e.status===`queued`||e.status===`running`).length?(0,b.jsx)(a6,{runs:m.data.recentRuns.filter(e=>e.status===`queued`||e.status===`running`)}):(0,b.jsx)(Q4,{compact:!0,title:`No active runs`,detail:`Select a target endpoint to initialize a governed assessment.`,action:(0,b.jsx)(o,{asChild:!0,children:(0,b.jsx)(`a`,{href:`/assessments`,children:`New assessment`})})})]})]})}if(e===`lifecycle`)return(0,b.jsx)(r6,{findings:pe});if(e===`workflows`)return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{title:`Workflows`}),(0,b.jsx)(B3,{}),(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:f.data?.items.map(e=>(0,b.jsx)(R3,{workflow:e},e.key))})]});if(e===`runs`){if(d&&C.data){let e=C.data,t=e.operations.filter(e=>e.status!==`completed`).length;return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:`Session`}),(0,b.jsx)(`h1`,{children:e.session.title}),(0,b.jsx)(`p`,{children:`Recorded tool calls and findings for this agent session, newest run last.`})]}),(0,b.jsx)(o,{variant:`outline`,onClick:()=>n(n3),children:`All sessions`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,b.jsx)(n6,{label:`Status`,value:c6(e.session.status),detail:`${e.session.runCount} run${e.session.runCount===1?``:`s`} in this session`}),(0,b.jsx)(n6,{label:`Tool calls`,value:String(e.session.operationCount),detail:t?`${t} did not complete`:`All completed`}),(0,b.jsx)(n6,{label:`Findings`,value:String(e.session.findingCount),detail:e.session.findingCount?`Ingested through report_finding`:`None reported in this session`})]}),(0,b.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.65fr)]`,"aria-live":`polite`,children:[(0,b.jsxs)(`section`,{"aria-labelledby":`agent-transcript`,children:[(0,b.jsx)(`h2`,{id:`agent-transcript`,children:`Transcript`}),e.operations.length?(0,b.jsx)(`div`,{className:`grid gap-2.5`,children:e.operations.map(e=>(0,b.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground [&_p.font-mono]:max-h-28 [&_p.font-mono]:overflow-auto [&_p.font-mono]:rounded-sm [&_p.font-mono]:bg-[var(--plane)] [&_p.font-mono]:px-2.5 [&_p.font-mono]:py-2 [&_p.font-mono]:text-xs [&_p.font-mono]:whitespace-pre-wrap`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(`strong`,{children:e.tool}),(0,b.jsx)(Yx,{variant:Jx(e.status),children:c6(e.outcome)})]}),(0,b.jsxs)(`p`,{children:[e.runtime,` · `,new Date(e.startedAt).toLocaleTimeString(),e.completedAt?` · ${e.completedAt-e.startedAt}ms`:``]}),e.outputPreview?(0,b.jsx)(`p`,{className:`font-mono`,children:e.outputPreview.slice(0,400)}):null]},e.id))}):(0,b.jsx)(Q4,{compact:!0,title:`Waiting for agent output`,detail:`Tool calls appear here as the runtime records them.`})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`agent-runs`,children:[(0,b.jsx)(`h2`,{id:`agent-runs`,children:`Runs`}),(0,b.jsx)(`div`,{className:`grid gap-2.5`,children:e.runs.map(e=>(0,b.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(Yx,{variant:Jx(e.status),children:c6(e.status)}),(0,b.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,12)})]}),(0,b.jsxs)(`p`,{children:[e.kind,` · `,new Date(e.createdAt).toLocaleString()]})]},e.id))})]})]}),e.findings.length?(0,b.jsxs)(`section`,{"aria-labelledby":`agent-findings`,children:[(0,b.jsx)(`h2`,{id:`agent-findings`,children:`Findings from this session`}),(0,b.jsx)(o6,{findings:e.findings})]}):null]})}return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{title:`Runs`}),(0,b.jsxs)(`section`,{"aria-labelledby":`all-runs`,children:[(0,b.jsx)(`h2`,{id:`all-runs`,className:`mb-3`,children:`Runs`}),_.data?.runs.length?(0,b.jsx)(a6,{runs:_.data.runs}):(0,b.jsx)(Q4,{compact:!0,title:`No runs yet`,detail:`Initialize an assessment to start the first governed run.`})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`all-sessions`,children:[(0,b.jsx)(`h2`,{id:`all-sessions`,className:`mb-3`,children:`Sessions`}),u.data?.items.length?(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:u.data.items.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(Yx,{variant:Jx(e.status),children:c6(e.status)}),(0,b.jsx)(`span`,{className:`font-mono`,children:e.source})]}),(0,b.jsx)(`h2`,{children:e.title}),(0,b.jsxs)(`p`,{children:[e.runCount,` run`,e.runCount===1?``:`s`,` · `,e.operationCount,` tool call`,e.operationCount===1?``:`s`,` · `,e.findingCount,` finding`,e.findingCount===1?``:`s`]}),(0,b.jsxs)(`p`,{children:[`Last active `,new Date(e.lastActivityAt).toLocaleString()]}),(0,b.jsx)(o,{variant:`outline`,onClick:()=>n({kind:`pinned`,id:e.id}),children:`Open session`})]},e.id))}):(0,b.jsx)(Q4,{compact:!0,title:`No agent sessions`,detail:`Sessions appear here once an agent run reaches the platform.`})]})]})}if(e===`assessments`)return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{title:`Assessments`}),(0,b.jsx)(Uj,{}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,b.jsx)(n6,{label:`Projects`,value:String(v.data?.items.length??0),detail:`Active workspace project boundaries`}),(0,b.jsx)(n6,{label:`Target bindings`,value:String(x.data?.items.length??0),detail:`Bound endpoints and infrastructure`}),(0,b.jsx)(n6,{label:`Recent runs`,value:String(m.data?.recentRuns.length??0),detail:`Assessment runs recorded in this workspace`})]}),x.data?.items.length?(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:x.data.items.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(Yx,{variant:Jx(e.allowedRisk),children:e.allowedRisk}),(0,b.jsxs)(`span`,{className:`font-mono`,children:[`rev `,e.revision]})]}),(0,b.jsx)(`h2`,{children:e.targets[0]?.displayName??e.targets[0]?.locator??`Bound target`}),(0,b.jsxs)(`p`,{children:[e.requiredWorkerClass,` worker · immutable launch policy`]}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,b.jsx)(`span`,{children:e},e))})]},e.id))}):(0,b.jsx)(Q4,{compact:!0,title:`No targets yet`,detail:`Configure a new target endpoint from the dashboard to initialize assessment tracking.`})]});if(e===`findings`){if(s)return(0,b.jsx)(`div`,{className:`grid gap-6`,children:(0,b.jsx)(Xj,{findingId:s,onBack:()=>l(null)})});let e=Object.fromEntries(Cx.map(e=>[e,pe.filter(t=>t.severity===e).length])),r=s6(pe),c=fe.filter(e=>!Ax(e)),f=u.data?.items??[],p=f.find(e=>e.id===d),m=t.kind===`all`&&f.length>0;return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{actions:(0,b.jsx)(K3,{id:`findings-session`,onChange:a,sessions:u.data?.items??[],value:i}),title:`Findings`}),m?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Choose an agent session to review its findings. Local headless runs are listed separately below.`}),(0,b.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:f.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{children:e.title||`Agent session`}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[e.findingCount,` finding`,e.findingCount===1?``:`s`,` · `,e.runCount,` run`,e.runCount===1?``:`s`,` · `,e.source]})]}),(0,b.jsx)(Yx,{variant:Jx(e.status),children:c6(e.status)})]}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,onClick:()=>n({kind:`pinned`,id:e.id}),children:`View session findings`})]},e.id))}),fe.length?(0,b.jsxs)(`details`,{className:`rounded-xl border bg-card p-4`,children:[(0,b.jsxs)(`summary`,{className:`cursor-pointer font-medium`,children:[`Workspace-wide findings · `,fe.length,` total`]}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This combined view can include findings associated with more than one session.`}),(0,b.jsx)(Bx,{findings:kx(fe),onSelect:e=>l(e.id)})]}):null]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(h,{children:[(0,b.jsx)(`h2`,{children:p?.title||(d?`Selected agent session`:`Workspace findings`)}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[fe.length,` total · `,pe.length,` open · `,c.length,` resolved`,p?` · ${p.runCount} run${p.runCount===1?``:`s`}`:null]})]}),pe.length?(0,b.jsx)(b.Fragment,{children:r.map(({asset:e,items:t})=>(0,b.jsx)(Fx,{title:e,sub:`${t.length} finding${t.length===1?``:`s`}`,children:(0,b.jsx)(Bx,{findings:kx(t),onSelect:e=>l(e.id)})},e))}):(0,b.jsx)(Q4,{compact:!0,title:c.length?`No open findings`:`No findings in this session`,detail:c.length?`Resolved findings are available below.`:`Findings reported by this agent session will appear here. Local headless runs are listed separately below.`}),c.length?(0,b.jsxs)(`details`,{className:`rounded-xl border bg-card p-4`,children:[(0,b.jsxs)(`summary`,{className:`cursor-pointer font-medium`,children:[`Resolved findings · `,c.length]}),(0,b.jsx)(Bx,{findings:kx(c),onSelect:e=>l(e.id)})]}):null,fe.length?(0,b.jsxs)(`details`,{className:`rounded-xl border bg-card p-4`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:`Analysis views · severity, lifecycle and control matrix`}),(0,b.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,b.jsx)(Fx,{title:`Open findings by severity`,sub:`${pe.length} active`,children:(0,b.jsx)(Rx,{counts:e})}),(0,b.jsx)(Fx,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,b.jsx)(zx,{findings:pe})})]}),(0,b.jsx)(`div`,{className:`mt-4`,children:(0,b.jsx)(Fx,{title:`Control coverage`,sub:`pillar × lifecycle stage — worst open severity per cell`,children:(0,b.jsx)(Hx,{findings:pe,onSelectStage:()=>{}})})})]}):null]}),(0,b.jsx)(Wj,{})]})}return e===`agent`?(0,b.jsx)(G3,{actions:(0,b.jsx)(K3,{id:`console-session`,onChange:a,sessions:u.data?.items??[],value:i}),title:`Console`}):e===`reports`?(0,b.jsxs)(`div`,{className:`grid gap-8`,children:[(0,b.jsx)(G3,{title:`Reports`}),(0,b.jsx)(Hj,{}),(0,b.jsx)(i6,{events:w.data?.items??[],findings:fe})]}):e===`administration`?(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{title:`Administration & Access`}),(0,b.jsx)(J3,{}),(0,b.jsx)(Y3,{}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,b.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.5rem`},children:[(0,b.jsx)(Vf,{size:18}),(0,b.jsx)(`h2`,{children:`Personal Access Tokens & CLI Sign-In`})]})}),(0,b.jsx)(`p`,{style:{marginTop:`0.25rem`,marginBottom:`1rem`},children:`Mint tokens to authenticate the Kifaru CLI or automated CI/CD pipelines without passwords.`}),N&&(0,b.jsxs)(`div`,{style:{background:`rgba(16, 185, 129, 0.12)`,border:`1px solid rgba(16, 185, 129, 0.4)`,borderRadius:`var(--radius-xl)`,padding:`1rem`,marginBottom:`1.25rem`},children:[(0,b.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`0.5rem`},children:[(0,b.jsxs)(`strong`,{style:{color:`var(--good)`,display:`flex`,alignItems:`center`,gap:`0.4rem`},children:[(0,b.jsx)(Sf,{size:16}),` Token Minted: `,N.label]}),(0,b.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>ee(null),children:`Dismiss`})]}),(0,b.jsx)(`p`,{style:{fontSize:`0.85rem`,color:`var(--ink-2)`,marginBottom:`0.75rem`},children:`Make sure to copy your Personal Access Token now. You will not be able to see it again!`}),(0,b.jsxs)(`div`,{style:{display:`grid`,gap:`0.75rem`},children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{className:`text-muted-foreground mb-1 block text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Token Value`}),(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,b.jsx)(p,{type:`text`,readOnly:!0,value:N.token,className:`flex-1 font-mono`}),(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(N.token),ne(!0),setTimeout(()=>ne(!1),2e3)},children:[te?(0,b.jsx)(Sf,{size:14}):(0,b.jsx)(Mf,{size:14}),te?`Copied`:`Copy Token`]})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,style:{display:`block`,marginBottom:`0.25rem`},children:`CLI Sign-In Command`}),(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,b.jsxs)(`code`,{className:`font-mono`,style:{flex:1,borderRadius:`var(--radius-lg)`,padding:`0.45rem 0.65rem`,fontSize:`0.82rem`,color:`var(--primary)`},children:[`kifaru session login --token `,N.token]}),(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(`kifaru session login --token `+N.token),ie(!0),setTimeout(()=>ie(!1),2e3)},children:[re?(0,b.jsx)(Sf,{size:14}):(0,b.jsx)(Mf,{size:14}),re?`Copied`:`Copy Command`]})]})]})]})]}),(0,b.jsxs)(`form`,{onSubmit:le,style:{display:`flex`,flexWrap:`wrap`,alignItems:`flex-end`,gap:`0.75rem`,background:`var(--surface-2)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-xl)`,padding:`0.85rem`,marginBottom:`1.25rem`},children:[(0,b.jsxs)(`div`,{style:{flex:`1 1 220px`},children:[(0,b.jsx)(g,{htmlFor:`mint-label`,className:`mb-1.5 block text-sm`,children:`Token Label`}),(0,b.jsx)(p,{id:`mint-label`,type:`text`,placeholder:`e.g. Workstation CLI, CI Runner`,value:D,onChange:e=>O(e.target.value)})]}),(0,b.jsxs)(`div`,{style:{width:`160px`},children:[(0,b.jsx)(g,{htmlFor:`mint-expiry`,className:`mb-1.5 block text-sm`,children:`Expiration`}),(0,b.jsxs)(Z4,{id:`mint-expiry`,value:k,onChange:e=>A(Number(e.target.value)),children:[(0,b.jsx)(`option`,{value:30,children:`30 days`}),(0,b.jsx)(`option`,{value:60,children:`60 days`}),(0,b.jsx)(`option`,{value:90,children:`90 days`}),(0,b.jsx)(`option`,{value:365,children:`1 year`}),(0,b.jsx)(`option`,{value:0,children:`Never expires`})]})]}),(0,b.jsxs)(o,{type:`submit`,disabled:j,size:`sm`,children:[(0,b.jsx)(Zf,{size:15}),j?`Minting…`:`Mint Token`]})]}),ae&&(0,b.jsx)(`p`,{className:`text-destructive text-sm`,style:{marginBottom:`1rem`},children:ae}),(0,b.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,b.jsx)(`h3`,{style:{fontSize:`0.95rem`,fontWeight:600,marginBottom:`0.5rem`},children:`Active Tokens`}),E.data?.items.length?(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Label`}),(0,b.jsx)(`th`,{children:`Token Prefix`}),(0,b.jsx)(`th`,{children:`Role`}),(0,b.jsx)(`th`,{children:`Created`}),(0,b.jsx)(`th`,{children:`Expires`}),(0,b.jsx)(`th`,{children:`Action`})]})}),(0,b.jsx)(`tbody`,{children:E.data.items.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{style:{fontWeight:600,color:`var(--ink)`},children:e.label}),(0,b.jsxs)(`td`,{className:`font-mono`,children:[e.prefix,`…`]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:Jx(`confirmed`),children:e.role})}),(0,b.jsx)(`td`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,b.jsx)(`td`,{children:e.expiresAt?new Date(e.expiresAt).toLocaleDateString():`Never`}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(o,{variant:`destructive`,size:`sm`,disabled:se===e.id,onClick:()=>ue(e.id),children:[(0,b.jsx)(up,{size:13}),se===e.id?`Revoking…`:`Revoke`]})})]},e.id))})]})}):(0,b.jsx)(`p`,{style:{color:`var(--ink-3)`,fontSize:`0.85rem`,fontStyle:`italic`},children:`No personal access tokens minted yet. Use the form above to create one.`})]}),(0,b.jsxs)(`div`,{style:{marginTop:`1.25rem`,background:`var(--surface-2)`,border:`1px dashed var(--border)`,borderRadius:`var(--radius-xl)`,padding:`0.85rem 1rem`,display:`flex`,alignItems:`center`,gap:`0.75rem`},children:[(0,b.jsx)(op,{size:20}),(0,b.jsxs)(`div`,{style:{fontSize:`0.82rem`,color:`var(--ink-3)`},children:[(0,b.jsx)(`strong`,{style:{color:`var(--ink)`},children:`Interactive Browser Sign-in:`}),` You can also run`,` `,(0,b.jsx)(`code`,{className:`font-mono`,style:{color:`var(--primary)`},children:`kifaru session login`}),` `,`in your terminal to authenticate interactively through your browser.`]})]})]}),(0,b.jsxs)(`div`,{style:{marginTop:`1rem`},children:[(0,b.jsx)(`h2`,{style:{fontSize:`1.15rem`,marginBottom:`0.75rem`},children:`Execution Workers`}),T.data?.items.length?(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:T.data.items.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(Yx,{variant:Jx(e.status),children:c6(e.status)}),(0,b.jsx)(`span`,{className:`font-mono`,children:e.status})]}),(0,b.jsx)(`h2`,{children:e.name}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,b.jsx)(`span`,{children:e},e))})]},e.id))}):(0,b.jsx)(Q4,{compact:!0,title:`No workers registered`,detail:`Connect an execution worker before launching capability-bound workflows.`})]})]}):e===`billing`?(0,b.jsx)(e6,{}):e===`team`?(0,b.jsx)(t6,{}):(0,b.jsx)(Q4,{title:`Not found`,detail:`This view does not exist.`})}function e6(){return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{title:`Billing & Subscription`}),(0,b.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,b.jsxs)(h,{className:`p-6`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,b.jsxs)(`span`,{className:`text-2xs font-semibold uppercase tracking-[0.12em] text-muted-foreground flex items-center gap-1.5`,children:[(0,b.jsx)(Nf,{className:`size-3.5`}),` Current Plan`]}),(0,b.jsx)(Yx,{variant:`success`,children:`Active`})]}),(0,b.jsx)(`div`,{className:`text-2xl font-bold mb-1`,children:`Developer Pro`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mb-6`,children:`Continuous assurance scans with dedicated runtime concurrency.`}),(0,b.jsxs)(`div`,{className:`space-y-2 border-t pt-4 text-xs text-muted-foreground`,children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{children:`Parallel agent jobs`}),(0,b.jsx)(`span`,{className:`font-semibold text-foreground`,children:`8 concurrent`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{children:`Finding retention`}),(0,b.jsx)(`span`,{className:`font-semibold text-foreground`,children:`365 days`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{children:`Next renewal`}),(0,b.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Oct 1, 2026`})]})]})]}),(0,b.jsxs)(h,{className:`p-6 flex flex-col justify-between`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,b.jsx)(`span`,{className:`text-2xs font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Scan Credits`}),(0,b.jsx)(`span`,{className:`text-xs font-mono text-[var(--good)] font-semibold`,children:`Active Balance`})]}),(0,b.jsx)(`div`,{className:`text-2xl font-bold font-mono mb-1`,children:`$240.00`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`Prepaid compute balance for high-concurrency automated audits.`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:`flex-1`,children:`Add Balance`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,children:`Change Plan`})]})]})]}),(0,b.jsxs)(h,{className:`p-6`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold mb-4`,children:`Recent Invoices`}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,b.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,b.jsx)(`thead`,{className:`bg-muted/50 border-b`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`p-3`,children:`Invoice`}),(0,b.jsx)(`th`,{className:`p-3`,children:`Date`}),(0,b.jsx)(`th`,{className:`p-3`,children:`Amount`}),(0,b.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,b.jsx)(`th`,{className:`p-3 text-right`,children:`Receipt`})]})}),(0,b.jsxs)(`tbody`,{className:`divide-y`,children:[(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{className:`p-3 font-mono font-medium`,children:`INV-2026-009`}),(0,b.jsx)(`td`,{className:`p-3 text-muted-foreground`,children:`Sep 1, 2026`}),(0,b.jsx)(`td`,{className:`p-3 font-mono`,children:`$120.00`}),(0,b.jsx)(`td`,{className:`p-3`,children:(0,b.jsx)(Yx,{variant:`success`,children:`Paid`})}),(0,b.jsx)(`td`,{className:`p-3 text-right`,children:(0,b.jsx)(`span`,{className:`text-primary hover:underline cursor-pointer`,children:`PDF`})})]}),(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{className:`p-3 font-mono font-medium`,children:`INV-2026-008`}),(0,b.jsx)(`td`,{className:`p-3 text-muted-foreground`,children:`Aug 1, 2026`}),(0,b.jsx)(`td`,{className:`p-3 font-mono`,children:`$120.00`}),(0,b.jsx)(`td`,{className:`p-3`,children:(0,b.jsx)(Yx,{variant:`success`,children:`Paid`})}),(0,b.jsx)(`td`,{className:`p-3 text-right`,children:(0,b.jsx)(`span`,{className:`text-primary hover:underline cursor-pointer`,children:`PDF`})})]})]})]})})]})]})}function t6(){return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{title:`Team & Permissions`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,b.jsx)(dp,{size:18}),` Workspace Members`]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Manage organization access and security verification roles.`})]}),(0,b.jsxs)(o,{size:`sm`,children:[(0,b.jsx)(Zf,{size:14}),` Invite Member`]})]}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Member`}),(0,b.jsx)(`th`,{children:`Role`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Last Active`})]})}),(0,b.jsxs)(`tbody`,{children:[(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Daniel Bast`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`daniel@bastsec.com`})]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:`default`,children:`Owner / Admin`})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`text-xs text-[var(--good)] font-medium`,children:`Active`})}),(0,b.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:`Just now`})]}),(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Kifaru Security Bot`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`bot@kifaru.internal`})]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:`secondary`,children:`Automated Worker`})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`text-xs text-[var(--good)] font-medium`,children:`Active`})}),(0,b.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:`Running scans`})]})]})]})})]})}function n6({label:e,value:t,detail:n}){return(0,b.jsxs)(h,{children:[(0,b.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:e}),(0,b.jsx)(`strong`,{className:`my-1 block text-[28px] font-bold tracking-[-0.02em]`,children:t}),(0,b.jsx)(`p`,{children:n})]})}function r6({findings:e}){let[t,n]=(0,y.useState)(4),r=bx(t),i=kx(e.filter(e=>e.stage===t));return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(G3,{title:`Finding → data-lifecycle stage`}),(0,b.jsx)(Vx,{findings:e,selected:t,onSelect:n}),(0,b.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,b.jsx)(Fx,{title:`Stage ${r.n} · ${r.name}`,sub:`${i.length} finding${i.length===1?``:`s`}`,children:(0,b.jsx)(Bx,{findings:i,emptyLabel:`No open findings at this stage.`})}),(0,b.jsxs)(Fx,{title:`Control pillar × lifecycle stage`,sub:`cell = open findings`,children:[(0,b.jsx)(Hx,{findings:e,onSelectStage:n}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-4 text-xs font-medium`,style:{marginTop:12},children:[`critical`,`high`,`medium`,`low`].map(e=>(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`i`,{className:`mcap`,style:{background:`var(${Tx[e]})`}}),`worst: `,Ex[e]]},e))})]})]})]})}function i6({events:e,findings:t}){let n=kx(t.filter(e=>e.status===`confirmed`||e.status===`unverified`)),[r,i]=(0,y.useState)(null),a=n.find(e=>e.id===r)??n[0]??null,o=tf({queryKey:[`finding`,a?.id],queryFn:()=>_x.finding(a.id),enabled:!!a});return(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`mb-0`,children:`Findings & evidence`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every finding carries the evidence chain that produced it; every platform mutation is recorded below.`})]}),(0,b.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[300px_minmax(0,1fr)]`,children:[(0,b.jsxs)(`div`,{className:`bg-card overflow-hidden rounded-xl border [&_.ph]:text-muted-foreground [&_.ph]:border-b [&_.ph]:border-[var(--hair)] [&_.ph]:px-3.5 [&_.ph]:py-3 [&_.ph]:text-xs [&_.ph]:font-semibold`,children:[(0,b.jsx)(`div`,{className:`ph`,children:`Findings with evidence`}),n.length?n.map(e=>(0,b.jsxs)(`button`,{className:`block w-full border-0 border-b border-l-[3px] border-[var(--hair)] border-l-transparent bg-transparent px-3.5 py-2.5 text-left last:border-b-0 aria-pressed:border-l-primary aria-pressed:bg-[var(--accent-soft)] [&_.pt]:text-[13px] [&_.pt]:font-semibold`,type:`button`,"aria-pressed":e.id===a?.id,onClick:()=>i(e.id),children:[(0,b.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Ex[e.severity]}),(0,b.jsx)(`div`,{className:`pt`,children:e.title})]},e.id)):(0,b.jsx)(`div`,{style:{padding:`14px`},children:(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No findings have been ingested yet, so there is no evidence to audit.`})})]}),(0,b.jsx)(`div`,{children:a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mb-4 flex justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:`sevtag sev-${a.severity}`,children:Ex[a.severity]}),(0,b.jsx)(`span`,{className:`font-mono text-muted-foreground text-xs`,style:{marginLeft:8},children:a.id}),(0,b.jsx)(`h2`,{style:{marginTop:9},children:a.title})]}),(0,b.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:a.status.replaceAll(`_`,` `)})]}),(0,b.jsx)(`p`,{children:a.description}),(0,b.jsx)(Ux,{items:[{k:`CVSS`,v:o.data?.finding.cvssScore??`—`},{k:`Weakness`,v:o.data?.finding.cwe??`—`,mono:!0},{k:`Category`,v:a.displayCategory},{k:`Lifecycle stage`,v:(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] [&_.d]:size-2 [&_.d]:rounded-[2px]`,children:[(0,b.jsx)(`span`,{className:`d`,style:{background:`var(${bx(a.stage).v})`}}),a.stage,` · `,xx(bx(a.stage))]})}]}),(0,b.jsx)(Wx,{title:`Evidence chain — provenance`,children:o.data?.finding.evidence.length?o.data.finding.evidence.map(e=>(0,b.jsx)(Gx,{title:e.kind,detail:e.reason??`No reason recorded.`,verdict:e.verdict},e.id)):(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No evidence records attached to this finding.`})}),o.data?.finding.remediation?(0,b.jsx)(Wx,{title:`Remediation`,children:(0,b.jsx)(`p`,{children:o.data.finding.remediation})}):null]}):(0,b.jsx)(Q4,{compact:!0,title:`Nothing to audit yet`,detail:`Evidence appears once an agent reports a finding through report_finding.`})})]}),(0,b.jsx)(Fx,{surface:!1,title:`Governance ledger`,sub:`${e.length} recent event${e.length===1?``:`s`}`,children:e.length?(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`#`}),(0,b.jsx)(`th`,{children:`Action`}),(0,b.jsx)(`th`,{children:`Object`}),(0,b.jsx)(`th`,{children:`Actor`}),(0,b.jsx)(`th`,{children:`Outcome`}),(0,b.jsx)(`th`,{children:`Occurred`})]})}),(0,b.jsx)(`tbody`,{children:e.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{className:`font-mono`,children:e.sequence}),(0,b.jsx)(`td`,{children:e.action}),(0,b.jsxs)(`td`,{children:[e.objectType,` · `,(0,b.jsx)(`span`,{className:`font-mono`,children:e.objectID.slice(0,16)})]}),(0,b.jsx)(`td`,{className:`font-mono`,children:e.actorID??`—`}),(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:Jx(e.outcome),children:e.outcome})}),(0,b.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()})]},e.id))})]})}):(0,b.jsx)(Q4,{compact:!0,title:`No governance events`,detail:`Run creation, state transitions, tool calls and finding ingestion are all recorded here.`})})]})}function a6({runs:e}){return(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Assessment`}),(0,b.jsx)(`th`,{children:`Kind`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Updated`})]})}),(0,b.jsx)(`tbody`,{children:e.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`span`,{children:e.title}),(0,b.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.id})]}),(0,b.jsx)(`td`,{children:c6(e.kind)}),(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:Jx(e.status),children:c6(e.status)})}),(0,b.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function o6({findings:e}){return(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Finding`}),(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Asset`}),(0,b.jsx)(`th`,{children:`Updated`})]})}),(0,b.jsx)(`tbody`,{children:e.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`a`,{href:`/findings`,children:e.title}),(0,b.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.description??e.id})]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:Jx(e.severity),children:c6(e.severity)})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(Yx,{variant:Jx(e.status),children:c6(e.status)})}),(0,b.jsx)(`td`,{children:e.path??`—`}),(0,b.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function s6(e){let t=new Map;for(let n of e){let e=n.path?.trim()||`Unscoped`,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()].map(([e,t])=>({asset:e,items:t})).sort((e,t)=>t.items.length-e.items.length)}function c6(e){return e.replaceAll(`_`,` `).replaceAll(`-`,` `).replace(/\b\w/g,e=>e.toUpperCase())}export{Q3 as LiveWorkspaceIsland,X3 as PlatformRoute};
95
+ `),...i.length>0?{attachments:i}:{},...t?{streamingBehavior:t}:{}}},N$=e=>{let t=e.runConfig?.custom?.streamingBehavior;return t===`followUp`||t===`steer`?t:void 0},P$=e=>({role:`user`,content:e.attachments&&e.attachments.length>0?[{type:`text`,text:e.content},...e.attachments]:e.content,timestamp:Date.now()}),F$=e=>{if(e.role!==`user`)return null;let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
96
+ `):null},I$=e=>e.runStatus===`running`&&e.metadata.status===`running`?e:{...e,runStatus:`running`,lastError:void 0,metadata:e.metadata.status===`running`?e.metadata:{...e.metadata,status:`running`}},L$=class{state;stateSnapshot;projectedMessages=[];messageRepository=SH.fromArray([]);version=0;allListeners=new Set;metadataListeners=new Set;messageListeners=new Set;connectionRetainers=0;optimisticUserMessages=[];unsubscribeFromEvents=null;disconnectTimer=null;loadPromise=null;messageFlushScheduled=!1;localSnapshotSeq=0;client;threadId;options;constructor(e,t,n={}){this.client=e,this.threadId=t,this.options=n,this.state=zQ(t),this.stateSnapshot=this.state}getState(){return this.state}getStateSnapshot(){return this.stateSnapshot}getProjectedMessages(){return this.projectedMessages}getMessageRepository(){return this.messageRepository}getVersion(){return this.version}connect(){return this.connectionRetainers+=1,this.ensureEventSubscription({includeSnapshot:this.state.loadState!==`loaded`}),()=>{this.connectionRetainers=Math.max(0,this.connectionRetainers-1),this.maybeDisconnectFromEvents()}}subscribe(e){return this.allListeners.add(e),()=>{this.allListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMetadata(e){return this.metadataListeners.add(e),()=>{this.metadataListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMessages(e){return this.messageListeners.add(e),()=>{this.messageListeners.delete(e),this.maybeDisconnectFromEvents()}}dispose(){this.clearDisconnectTimer(),this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null,this.allListeners.clear(),this.metadataListeners.clear(),this.messageListeners.clear()}ensureEventSubscription(e){this.clearDisconnectTimer(),!this.unsubscribeFromEvents&&(this.unsubscribeFromEvents=this.client.subscribe(this.threadId,e=>{e.threadId===this.threadId&&this.dispatch(e)},e))}hasConsumers(){return this.connectionRetainers>0||this.allListeners.size>0||this.metadataListeners.size>0||this.messageListeners.size>0}maybeDisconnectFromEvents(){this.hasConsumers()||(this.disconnectTimer||=setTimeout(()=>{this.disconnectTimer=null,!this.hasConsumers()&&(this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null)},3e4))}clearDisconnectTimer(){this.disconnectTimer&&=(clearTimeout(this.disconnectTimer),null)}async load(e=!1){if(this.loadPromise&&!e)return this.loadPromise;this.setState({...this.state,loadState:`loading`});let t=this.client.getThread(this.threadId).then(e=>{this.loadPromise===t&&this.applySnapshot(e)}).catch(e=>{throw this.loadPromise===t&&this.setState({...this.state,loadState:`loaded`,lastError:w$(e)}),e}).finally(()=>{this.loadPromise===t&&(this.loadPromise=null)});return this.loadPromise=t,t}refresh(){return this.load(!0)}refreshInBackground(){this.loadPromise||this.refresh().catch(()=>{})}async sendMessage(e,t){if(e.role!==`user`)throw Error(`Pi only supports sending user messages`);let n=this.state.runStatus===`running`,r=t?.streamingBehavior??N$(e)??(n?`followUp`:void 0),i=M$(e,r);if(this.ensureEventSubscription({includeSnapshot:!1}),n)return this.sendQueued(i,r??`followUp`);let a=P$(i);this.optimisticUserMessages.push({message:a,baseMessageCount:this.state.messages.length}),this.setState(I$(this.state)),this.recomputeProjectedMessagesAndNotify();try{await this.client.sendMessage(this.threadId,i)}catch(e){let t=this.optimisticUserMessages.findIndex(e=>e.message===a);throw t!==-1&&this.optimisticUserMessages.splice(t,1),this.recomputeProjectedMessagesAndNotify(),this.setState({...this.state,lastError:w$(e),runStatus:`failed`,metadata:{...this.state.metadata,status:`failed`}}),e}}async sendQueued(e,t){let n=t===`steer`?`steering`:`followUp`,r={...this.state.queue,[n]:[...this.state.queue[n],e.content]};this.setState({...this.state,queue:r});try{await this.client.sendMessage(this.threadId,e)}catch(t){let i=this.state.queue!==r,a=this.state.queue[n],o=i?-1:a.lastIndexOf(e.content);throw this.setState({...this.state,lastError:w$(t),...o===-1?{}:{queue:{...this.state.queue,[n]:a.filter((e,t)=>t!==o)}}}),t}}async clearQueue(){let e=this.state.queue,t=await this.client.clearQueue(this.threadId);return this.state.queue===e&&(e.steering.length>0||e.followUp.length>0)&&this.setState({...this.state,queue:{steering:[],followUp:[]}}),t}async cancel(){try{await this.client.cancelRun(this.threadId)}catch(e){throw this.setState({...this.state,lastError:w$(e)}),e}}async setModel(e){try{await this.client.setModel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:w$(e)}),e}await this.refresh()}async setThinkingLevel(e){try{await this.client.setThinkingLevel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:w$(e)}),e}await this.refresh()}async respondToToolApproval(e,t){let n=this.state.hostUiRequests.find(t=>t.id===e);await this.respond(n?ZQ(n,{approvalId:e,approved:t}):YQ(e,t))}async resumeToolCall(e,t){let n=this.state.hostUiRequests.find(t=>t.toolCallId===e);if(!n)throw Error(`No pending host-UI request for tool call "${e}"`);n.kind===`confirm`?await this.respond(YQ(n.id,t===!0)):await this.respond($Q(n.id,t))}async respondToHostUiRequest(e){await this.respond(e)}async respond(e){try{await this.client.respondToHostUiRequest(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:w$(e)}),e}let t=KQ(this.state,e.requestId);t!==this.state&&(this.setState(t),this.recomputeProjectedMessagesAndNotify())}applySnapshot(e){this.dispatch({type:`snapshot`,snapshot:e,threadId:this.threadId,seq:this.localSnapshotSeq})}dispatch(e){let t=qQ(this.state,e),n=t!==this.state;n&&(this.state=t),this.reconcileOptimisticUserMessages(),n&&k$.has(e.type)&&this.notifyMetadataListeners(),n&&D$.has(e.type)&&(O$.has(e.type)?this.scheduleProjectedMessageFlush():this.recomputeProjectedMessagesAndNotify()),(!C$(e.type)||e.type===`entry_appended`&&e.entry?.type!==`custom`)&&this.refreshInBackground()}setState(e){e!==this.state&&(this.state=e,this.notifyMetadataListeners())}projectedInputMessages(){return[...this.state.messages,...this.optimisticUserMessages.map(e=>e.message)]}reconcileOptimisticUserMessages(){if(this.optimisticUserMessages.length===0)return;let e=[];for(let t of this.optimisticUserMessages){let n=F$(t.message);this.state.messages.slice(t.baseMessageCount).some(e=>F$(e)===n)||e.push(t)}e.length!==this.optimisticUserMessages.length&&(this.optimisticUserMessages.length=0,this.optimisticUserMessages.push(...e))}projectMessages(){return x$({messages:this.projectedInputMessages(),toolExecutions:this.state.toolExecutions,runStatus:this.state.runStatus,hostUiRequests:this.state.hostUiRequests},this.projectedMessages)}recomputeProjectedMessagesAndNotify(){let e=this.projectMessages();if(e===this.projectedMessages){this.state!==this.stateSnapshot&&this.publishState();return}this.projectedMessages=e,this.messageRepository=SH.fromArray(e),this.notifyMessageListeners()}scheduleProjectedMessageFlush(){this.messageFlushScheduled||(this.messageFlushScheduled=!0,(this.options.scheduleNotify??T$)(()=>{this.messageFlushScheduled=!1,this.recomputeProjectedMessagesAndNotify()}))}bumpVersion(){this.version+=1}publishState(){this.stateSnapshot=this.state,this.bumpVersion(),E$(this.allListeners)}notifyMetadataListeners(){this.stateSnapshot=this.state,this.bumpVersion(),E$(this.metadataListeners),E$(this.allListeners)}notifyMessageListeners(){this.stateSnapshot=this.state,this.bumpVersion(),E$(this.messageListeners),E$(this.allListeners)}},R$=e=>{let t=Symbol(`${e} extras`),n=e=>typeof e==`object`&&!!e&&t in e;return{provide:e=>(Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0}),e),is:n,tryGet:e=>n(e)?e:void 0,assert:t=>{if(!n(t))throw Error(`The current thread is not backed by the ${e} runtime.`);return t}}},z$=e=>{let{provide:t,is:n,tryGet:r,assert:i}=e,a=e=>i(e.thread.getState().extras);function o(e,...t){let r=t.length>0,a=t[0];return $(t=>{let o=t.thread.extras;return n(o)?e?e(o):o:r?a:i(o)})}return{provide:t,is:n,tryGet:r,get:a,use:o}},B$=(e=>z$(R$(e)))(`usePiRuntime`),V$=zQ(`__pending__`),H$=[],U$=SH.fromArray([]),W$=e=>{let t=new Map,n=!1;return{client:e,controllers:t,get disposed(){return n},activate(){n=!1},dispose(){n=!0;for(let e of t.values())e.dispose()}}},G$=(e,t)=>{let n=e.controllers.get(t);if(n)return n;let r=new L$(e.client,t);return e.controllers.set(t,r),r},K$={getState:()=>V$,getProjectedMessages:()=>H$,getMessageRepository:()=>U$,getVersion:()=>0,subscribe:()=>()=>{},subscribeMetadata:()=>()=>{},subscribeMessages:()=>()=>{},connect:()=>()=>{},load:async()=>{},refresh:async()=>{},sendMessage:async()=>{},cancel:async()=>{},clearQueue:async()=>({steering:[],followUp:[]}),setModel:async()=>{},setThinkingLevel:async()=>{},respondToToolApproval:async()=>{},resumeToolCall:async()=>{},respondToHostUiRequest:async()=>{},dispose:()=>{}},q$=(e,t)=>{t$(`react-pi`,`onError`,e,t)},J$=(e,t)=>{let{freeStanding:n}=JQ(t.hostUiRequests);return B$.provide({controller:e,state:t,metadata:t.metadata,status:t.runStatus===`failed`?`failed`:t.runStatus,readiness:t.readiness,contextUsage:t.contextUsage,hostUiRequests:n,allHostUiRequests:t.hostUiRequests,queue:t.queue,compaction:t.compaction,retry:t.retry,lastError:t.lastError,cancel:()=>e.cancel(),refresh:()=>e.refresh(),clearQueue:()=>e.clearQueue(),setModel:t=>e.setModel(t),setThinkingLevel:t=>e.setThinkingLevel(t),respondToHostUiRequest:t=>e.respondToHostUiRequest(t),respondToToolApproval:(t,n)=>e.respondToToolApproval(t,n),resumeToolCall:(t,n)=>e.resumeToolCall(t,n)})},Y$=J$(K$,V$),X$=e=>e.getStateSnapshot?.()??e.getState(),Z$=e=>{let t=(0,y.useCallback)(()=>X$(e),[e]);return(0,y.useSyncExternalStore)((0,y.useCallback)(t=>e.subscribe(t),[e]),t,t)},Q$=e=>{let t=(0,y.useCallback)(()=>e.getMessageRepository(),[e]);return(0,y.useSyncExternalStore)((0,y.useCallback)(t=>e.subscribeMessages(t),[e]),t,t)},$$=(e,t)=>{let n=(0,y.useMemo)(()=>{let n;return()=>{let r=X$(e);return(!n||n.state!==r)&&(n={state:r,selection:t(r)}),n.selection}},[e,t]);return(0,y.useSyncExternalStore)((0,y.useCallback)(t=>e.subscribe(t),[e]),n,n)},e1=e=>e.runStatus===`running`||e.compaction.active||e.retry.active,t1=(e,t)=>{let n=Z$(e),r=Q$(e),{adapters:i,isDisabled:a,isSendDisabled:o,onError:s,suggestions:c,unstable_capabilities:l}=t,u=n.loadState===`loading`,d=e1(n),f=(0,y.useEffectEvent)(e=>{q$(s,e)});(0,y.useEffect)(()=>{e!==K$&&e.load().catch(f)},[e]),(0,y.useEffect)(()=>{if(e!==K$&&d)return e.connect()},[e,d]);let p=(0,y.useMemo)(()=>J$(e,n),[e,n]),m=(0,y.useMemo)(()=>({items:n.queue.followUp.map((e,t)=>({id:LQ(`followUp`,t),prompt:e,parts:[{type:`text`,text:e}]})),steerItems:n.queue.steering.map((e,t)=>({id:LQ(`steer`,t),prompt:e,parts:[{type:`text`,text:e}]})),enqueue:t=>{e.sendMessage(t).catch(e=>q$(s,e))},steer:t=>{e.sendMessage(t,{streamingBehavior:`steer`}).catch(e=>q$(s,e))},move:()=>{},edit:()=>{},remove:()=>{}}),[e,n.queue,s]);return(0,y.useMemo)(()=>({isDisabled:a,isSendDisabled:o,unstable_capabilities:l,suggestions:c,isLoading:u,isRunning:d,messageRepository:r,extras:p,queue:m,...i?{adapters:i}:{},onNew:async t=>{try{await e.sendMessage(t)}catch(e){throw q$(s,e),e}},onCancel:async()=>{try{try{await e.clearQueue()}finally{await e.cancel()}}catch(e){throw q$(s,e),e}},onRespondToToolApproval:async t=>{try{let n=e.getState().hostUiRequests.find(e=>e.id===t.approvalId);if(!n)throw Error(`No pending host-UI request "${t.approvalId}"`);await e.respondToHostUiRequest(ZQ(n,t))}catch(e){throw q$(s,e),e}},onResumeToolCall:({toolCallId:t,payload:n})=>{e.resumeToolCall(t,n).catch(e=>q$(s,e))}}),[e,p,r,m,i,a,u,d,o,s,c,l])},n1=(e,t)=>({id:`pi-new-user:${t}`,role:`user`,createdAt:new Date,content:j$(e)}),r1=(e,t)=>{let n=Q(),{adapters:r,isDisabled:i,isSendDisabled:a,onError:o,suggestions:s,unstable_capabilities:c}=t,[l,u]=(0,y.useState)([]),d=(0,y.useRef)(0),f=(0,y.useMemo)(()=>SH.fromArray(l),[l]);return(0,y.useMemo)(()=>({isDisabled:i??!1,isSendDisabled:a,unstable_capabilities:c,suggestions:s,isLoading:!1,isRunning:!1,messageRepository:f,extras:Y$,...r?{adapters:r}:{},onNew:async t=>{let r=n1(t,d.current++);u(e=>[...e,r]);let i=()=>{u(e=>e.filter(e=>e!==r))};try{let{remoteId:r,externalId:a}=await n.threadListItem.initialize();if(e.disposed){i();return}await G$(e,a??r).sendMessage(t),i()}catch(e){throw i(),q$(o,e),e}}}),[n,f,e,r,i,a,o,s,c])},i1=(e,t)=>{let n=$(e=>e.threadListItem),r=$(e=>e.threads.mainThreadId===e.threadListItem.id),i=n.externalId??n.remoteId,a=i?G$(e,i):K$,o=t1(r?a:K$,t),s=r1(e,t);return QH(i?o:s)},a1=e=>({status:e.archived?`archived`:`regular`,remoteId:e.id,externalId:e.id,...e.title===void 0?{}:{title:e.title},custom:{status:e.status,...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.sessionFile===void 0?{}:{sessionFile:e.sessionFile},...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath}}}),o1=e=>{let{client:t}=e,n=(0,y.useMemo)(()=>W$(t),[t]);return(0,y.useEffect)(()=>(n.activate(),()=>n.dispose()),[n]),HU({allowNesting:!0,adapter:(0,y.useMemo)(()=>({list:async()=>({threads:(await t.listThreads({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.includeArchived===void 0?{}:{includeArchived:e.includeArchived}})).map(a1)}),rename:async(e,n)=>{await t.renameThread(e,n)},archive:async e=>{await t.archiveThread?.(e)},unarchive:async e=>{await t.unarchiveThread?.(e)},delete:async e=>{await t.deleteThread?.(e)},initialize:async()=>{let n=await t.createThread({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath}});return{remoteId:n.metadata.id,externalId:n.metadata.id}},generateTitle:async()=>new ReadableStream({start(e){e.close()}}),fetch:async e=>a1((await t.getThread(e)).metadata)}),[t,e.workspacePath,e.includeArchived]),...e.initialThreadId===void 0?{}:{initialThreadId:e.initialThreadId},...e.threadId===void 0?{}:{threadId:e.threadId},...e.onThreadIdChange===void 0?{}:{onThreadIdChange:e.onThreadIdChange},runtimeHook:()=>i1(n,e)})},s1=()=>B$.use(e=>e,Y$),c1=()=>B$.use(e=>e.metadata,null);function l1(e){return $$(B$.use(e=>e.controller,K$),e??(e=>e))}var u1=()=>{let e=B$.use(e=>e,void 0);return(0,y.useMemo)(()=>({requests:e?.hostUiRequests??[],respond:e?.respondToHostUiRequest??(async()=>{throw Error(`Pi runtime is not ready yet`)})}),[e])};function d1({delayDuration:e=0,...t}){return(0,b.jsx)(Du,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function f1({...e}){return(0,b.jsx)(Ou,{"data-slot":`tooltip`,...e})}function p1({...e}){return(0,b.jsx)(ku,{"data-slot":`tooltip-trigger`,...e})}function m1({className:e,sideOffset:t=0,children:n,...r}){return(0,b.jsx)(Au,{children:(0,b.jsxs)(ju,{"data-slot":`tooltip-content`,sideOffset:t,className:a(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,b.jsx)(Mu,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function h1({...e}){return(0,b.jsx)(wr,{"data-slot":`dialog`,...e})}function g1({...e}){return(0,b.jsx)(Er,{"data-slot":`dialog-trigger`,...e})}function _1({...e}){return(0,b.jsx)(Ar,{"data-slot":`dialog-portal`,...e})}function v1({className:e,...t}){return(0,b.jsx)(Mr,{"data-slot":`dialog-overlay`,className:a(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function y1({className:e,children:t,showCloseButton:n=!0,...r}){return(0,b.jsxs)(_1,{"data-slot":`dialog-portal`,children:[(0,b.jsx)(v1,{}),(0,b.jsxs)(Ir,{"data-slot":`dialog-content`,className:a(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,b.jsxs)(Gr,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,b.jsx)(bp,{}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function b1({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`dialog-header`,className:a(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function x1({className:e,showCloseButton:t=!1,children:n,...r}){return(0,b.jsxs)(`div`,{"data-slot":`dialog-footer`,className:a(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,b.jsx)(Gr,{asChild:!0,children:(0,b.jsx)(o,{variant:`outline`,children:`Close`})})]})}function S1({className:e,...t}){return(0,b.jsx)(Vr,{"data-slot":`dialog-title`,className:a(`text-lg leading-none font-semibold`,e),...t})}function C1({className:e,...t}){return(0,b.jsx)(Ur,{"data-slot":`dialog-description`,className:a(`text-sm text-muted-foreground`,e),...t})}function w1({className:e,size:t=`default`,...n}){return(0,b.jsx)(ti,{"data-slot":`avatar`,"data-size":t,className:a(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function T1({className:e,...t}){return(0,b.jsx)(ri,{"data-slot":`avatar-image`,className:a(`aspect-square size-full`,e),...t})}function E1({className:e,...t}){return(0,b.jsx)(ai,{"data-slot":`avatar-fallback`,className:a(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var D1=(0,y.forwardRef)(({children:e,tooltip:t,side:n=`bottom`,className:r,...i},s)=>(0,b.jsx)(d1,{delayDuration:0,children:(0,b.jsxs)(f1,{children:[(0,b.jsx)(p1,{asChild:!0,children:(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,...i,className:a(`aui-button-icon size-6 p-1 active:scale-90`,r),ref:s,children:[(0,b.jsx)(c,{children:e}),(0,b.jsx)(`span`,{className:`aui-sr-only sr-only`,children:t})]})}),(0,b.jsx)(m1,{side:n,children:t})]})}));D1.displayName=`TooltipIconButton`;var O1=e=>Symbol.iterator in e,k1=e=>`entries`in e,A1=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},j1=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function M1(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:O1(e)&&O1(t)?k1(e)&&k1(t)?A1(e,t):j1(e,t):A1({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function N1(e){let t=y.useRef(void 0);return n=>{let r=e(n);return M1(t.current,r)?t.current:t.current=r}}var P1=e=>{let[t,n]=(0,y.useState)(void 0);return(0,y.useEffect)(()=>{if(!e){n(void 0);return}let t=URL.createObjectURL(e);return n({file:e,url:t}),()=>{URL.revokeObjectURL(t)}},[e]),t!==void 0&&t.file===e?t.url:void 0},F1=()=>{let{file:e,src:t}=$(N1(e=>{if(e.attachment.type!==`image`)return{};if(e.attachment.file)return{file:e.attachment.file};let t=e.attachment.content?.filter(e=>e.type===`image`)[0]?.image;return t?{src:t}:{}}));return P1(e)??t},I1=({src:e})=>{let[t,n]=(0,y.useState)(!1);return(0,b.jsx)(`img`,{src:e,alt:`Attachment preview`,className:a(`block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none`,t?`aui-attachment-preview-image-loaded opacity-100`:`aui-attachment-preview-image-loading opacity-0`),onLoad:()=>n(!0)})},L1=({children:e})=>{let t=F1();return t?(0,b.jsxs)(h1,{children:[(0,b.jsx)(g1,{className:`aui-attachment-preview-trigger cursor-zoom-in`,asChild:!0,children:(0,y.isValidElement)(e)?e:(0,b.jsx)(`button`,{type:`button`,children:e})}),(0,b.jsxs)(y1,{className:`aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!`,children:[(0,b.jsx)(S1,{className:`aui-sr-only sr-only`,children:`Image Attachment Preview`}),(0,b.jsx)(`div`,{className:`aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm`,children:(0,b.jsx)(I1,{src:t})})]})]}):e},R1=()=>{let e=F1();return(0,b.jsxs)(w1,{className:`aui-attachment-tile-avatar h-full w-full rounded-none`,children:[(0,b.jsx)(T1,{src:e,alt:`Attachment preview`,className:`aui-attachment-tile-image rounded-none object-cover`}),(0,b.jsx)(E1,{children:(0,b.jsx)(Rf,{className:`aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]`})})]})},z1=()=>{let e=Q().attachment.source!==`message`,t=$(e=>e.attachment.type===`image`),n=$(e=>{let t=e.attachment.type;switch(t){case`image`:return`Image`;case`document`:return`Document`;case`file`:return`File`;default:return t}}),r=$(e=>e.attachment.status.type===`running`?`uploading`:e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?`error`:void 0),i=r===`uploading`,o=r===`error`,s=$(e=>e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?e.attachment.status.message??`Upload failed`:void 0);return(0,b.jsx)(d1,{children:(0,b.jsxs)(f1,{children:[(0,b.jsxs)(qq.Root,{className:a(`aui-attachment-root relative`,e&&`animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none`,t&&!e&&`aui-attachment-root-message only:*:first:size-24`),children:[(0,b.jsx)(L1,{children:(0,b.jsx)(p1,{asChild:!0,children:(0,b.jsxs)(`div`,{className:a(`aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--composer-radius,1rem)-var(--composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10`,o&&`after:ring-destructive/60 dark:after:ring-destructive/60`),role:`button`,tabIndex:0,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},"aria-label":`${n} attachment${o?`, upload failed`:i?`, uploading`:``}`,children:[(0,b.jsx)(R1,{}),i&&(0,b.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,b.jsx)(qf,{className:`text-muted-foreground size-4 animate-spin`})}),o&&(0,b.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,b.jsx)(Df,{className:`text-destructive size-4`})})]})})}),e&&(0,b.jsx)(B1,{})]}),(0,b.jsxs)(m1,{side:`top`,children:[(0,b.jsx)(qq.Name,{}),s&&(0,b.jsx)(`p`,{className:`aui-attachment-error-message`,children:s})]})]})})},B1=()=>(0,b.jsx)(qq.Remove,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Remove file`,className:`aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none`,side:`top`,children:(0,b.jsx)(bp,{className:`aui-attachment-remove-icon size-3 stroke-[2.5]`})})}),V1=()=>(0,b.jsx)(`div`,{className:`aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2 empty:hidden`,children:(0,b.jsx)(uZ.Attachments,{children:()=>(0,b.jsx)(z1,{})})}),H1=()=>(0,b.jsx)(`div`,{className:`aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden`,children:(0,b.jsx)(QY.Attachments,{children:()=>(0,b.jsx)(z1,{})})}),U1=()=>(0,b.jsx)(QY.AddAttachment,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Add Attachment`,side:`bottom`,variant:`ghost`,size:`icon`,className:`aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none`,"aria-label":`Add Attachment`,children:(0,b.jsx)(tp,{className:`aui-attachment-add-icon size-4`})})}),W1=v(`aui-file-root inline-flex items-center gap-3 rounded-lg transition-colors`,{variants:{variant:{outline:`border-border hover:bg-muted/50 border`,ghost:`hover:bg-muted/50`,muted:`bg-muted/50 hover:bg-muted/70`},size:{sm:`px-2.5 py-1.5 text-xs`,default:`px-3 py-2 text-sm`,lg:`px-4 py-3 text-base`}},defaultVariants:{variant:`outline`,size:`default`}});function G1(e){let t=e.toLowerCase();return t.startsWith(`image/`)?Uf:t===`application/pdf`?Rf:t===`application/json`?xf:t.startsWith(`text/`)?Rf:t.startsWith(`audio/`)?Xf:t.startsWith(`video/`)?vp:zf}function K1(e,t){return t===`url`&&/^data:/i.test(e)?`data-uri`:t||(/^data:/i.test(e)?`data-uri`:/^https?:\/\//i.test(e)?`url`:`base64`)}function q1(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`),n=e.search(/[^A-Za-z\d+/]/);return n!==-1&&n!==e.length-t||e.length%4==1||t>0&&e.length%4!=0?0:Math.floor(e.length*3/4)-t}function J1(e){return q1(/[\t\n\f\r ]/.test(e)?e.replace(/[\t\n\f\r ]/g,``):e)}function Y1(e){let t=e.indexOf(`#`),n=t<0?e.length:t,r=e.indexOf(`,`);if(r<0||r>=n)return 0;let i=e.slice(r+1,n);return/;base64$/i.test(e.slice(0,r))?(/[%\t\n\f\r ]/.test(i)&&(i=i.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16))).replace(/[\t\n\f\r ]/g,``)),q1(i)):new TextEncoder().encode(i.replace(/%[\da-f]{2}/gi,`_`)).byteLength}function X1(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Z1({className:e,variant:t,size:n,children:r,...i}){return(0,b.jsx)(`div`,{"data-slot":`file-root`,"data-variant":t,"data-size":n,className:a(W1({variant:t,size:n,className:e})),...i,children:r})}function Q1({mimeType:e,className:t,children:n,...r}){let i=e?G1(e):zf;return(0,b.jsx)(`span`,{"data-slot":`file-icon`,className:a(`text-muted-foreground shrink-0`,t),...r,children:n??(0,b.jsx)(i,{className:`size-5`})})}function $1({className:e,children:t,...n}){return(0,b.jsx)(`span`,{"data-slot":`file-name`,className:a(`min-w-0 flex-1 truncate font-medium`,e),...n,children:t||`Unnamed file`})}function e0({bytes:e,className:t,...n}){return(0,b.jsx)(`span`,{"data-slot":`file-size`,className:a(`text-muted-foreground shrink-0`,t),...n,children:X1(e)})}function t0({data:e,mimeType:t,filename:n,sourceType:r,className:i,children:o,...s}){if(typeof e!=`string`)return null;let c=K1(e,r);if(c===`id`||c===`url`&&!/^(https?:\/\/|blob:)/i.test(e))return null;let l=c===`base64`?`data:${t};base64,${e}`:e;return(0,b.jsx)(`a`,{"data-slot":`file-download`,href:l,download:n||`download`,...c===`url`&&{target:`_blank`,rel:`noopener noreferrer`},className:a(`text-muted-foreground hover:bg-accent hover:text-accent-foreground shrink-0 rounded-md p-1 transition-colors`,i),"aria-label":o?void 0:`Download ${n||`file`}`,...s,children:o||(0,b.jsx)(Ff,{className:`size-4`})})}var n0=(0,y.memo)(({filename:e,data:t,mimeType:n,sourceType:r})=>{let i=K1(t,r);return(0,b.jsxs)(Z1,{children:[(0,b.jsx)(Q1,{mimeType:n}),(0,b.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,b.jsx)($1,{children:e}),typeof t==`string`&&(i===`base64`||i===`data-uri`)&&(0,b.jsx)(e0,{bytes:i===`data-uri`?Y1(t):J1(t),className:`text-xs`})]}),(0,b.jsx)(t0,{data:t,mimeType:n,...e!==void 0&&{filename:e},...r!==void 0&&{sourceType:r}})]})});n0.displayName=`File`,n0.Root=Z1,n0.Icon=Q1,n0.Name=$1,n0.Size=e0,n0.Download=t0;var r0=()=>{let e=$(e=>e.thread.suggestions),t=(0,y.useRef)(null),n=(0,y.useRef)(null),[r,i]=(0,y.useState)({left:!1,right:!1}),a=(0,y.useCallback)(()=>{let e=t.current;if(!e)return;let r=e.scrollWidth-e.clientWidth,a=Math.abs(e.scrollLeft),[o,s]=(n.current??=getComputedStyle(e).direction===`rtl`)?[r-a,a]:[a,r-a];i(e=>{let t={left:o>1,right:s>1};return e.left===t.left&&e.right===t.right?e:t})},[]);(0,y.useEffect)(()=>{a();let e=t.current;if(!e?.firstElementChild)return;let n=new ResizeObserver(a);return n.observe(e),n.observe(e.firstElementChild),()=>n.disconnect()},[a]);let o=`linear-gradient(to right, ${r.left?`transparent, black 2rem`:`black`}, ${r.right?`black calc(100% - 2rem), transparent`:`black`})`;return(0,b.jsx)(`div`,{ref:t,onScroll:a,className:`aui-thread-followup-suggestions -my-1 w-full [scrollbar-width:none] overflow-x-auto py-1 [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,style:{maskImage:o,WebkitMaskImage:o},children:(0,b.jsx)(`div`,{className:`mx-auto flex min-h-8 w-max items-center gap-2 px-0.5`,children:e.map((e,t)=>(0,b.jsxs)(JZ.Suggestion,{className:`aui-thread-followup-suggestion border-foreground/10 hover:bg-foreground/[0.03] hover:border-foreground/25 rounded-md border px-2.5 py-1 text-sm whitespace-nowrap transition-colors ease-in motion-reduce:transition-none`,prompt:e.prompt,send:!0,children:[e.title??e.prompt,e.label&&(0,b.jsx)(`span`,{className:`aui-thread-followup-suggestion-label text-muted-foreground ms-1`,children:e.label})]},t))})})},i0=()=>(0,b.jsx)(XL,{condition:e=>!e.thread.isEmpty&&!e.thread.isRunning&&e.thread.suggestions.length>0,children:(0,b.jsx)(r0,{})}),a0=e=>{switch(e){case`image/png`:return`png`;case`image/jpeg`:case`image/jpg`:return`jpg`;case`image/webp`:return`webp`;case`image/gif`:return`gif`;case`image/svg+xml`:return`svg`;default:return`png`}},o0=e=>{let t=e.indexOf(`,`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``,i=n.match(/data:([^;]+)/i)?.[1]?.toLowerCase()??`application/octet-stream`;if(!/;base64/i.test(n)){let e=r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURIComponent(e)}catch{return e}});return new Blob([e],{type:i})}let a;try{let e=r.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));a=atob(e)}catch{return null}let o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);return new Blob([o],{type:i})},s0=e=>e.match(/^data:([^;,]+)/i)?.[1]?.toLowerCase(),c0=e=>{if(typeof document>`u`)return;let t=a0(s0(e.image)),n=e.filename??`image.${t}`,r=/^data:/i.test(e.image),i=r?o0(e.image):null;if(r&&!i)return;let a=i?URL.createObjectURL(i):null,o=a??e.image,s=document.createElement(`a`);s.href=o,s.download=n,s.rel=`noopener`,document.body.appendChild(s),s.click(),document.body.removeChild(s),a&&setTimeout(()=>URL.revokeObjectURL(a),4e4)},l0=async e=>{if(typeof navigator>`u`||!navigator.clipboard||typeof ClipboardItem>`u`)throw Error(`Clipboard API is not available in this environment.`);let t=/^data:/i.test(e.image)?o0(e.image):await fetch(e.image).then(e=>e.blob());if(!t)return;let n=s0(e.image)??t.type??`image/png`;await navigator.clipboard.write([new ClipboardItem({[n]:t})])},u0=v(`aui-image-root relative overflow-hidden rounded-lg`,{variants:{variant:{outline:`border-border border`,ghost:``,muted:`bg-muted/50`},size:{sm:`max-w-64`,default:`max-w-96`,lg:`max-w-[512px]`,full:`w-full`}},defaultVariants:{variant:`outline`,size:`default`}});function d0({className:e,variant:t,size:n,children:r,...i}){return(0,b.jsx)(`div`,{"data-slot":`image-root`,"data-variant":t,"data-size":n,className:a(u0({variant:t,size:n,className:e})),...i,children:r})}function f0({className:e,containerClassName:t,onLoad:n,onError:r,alt:i=`Image content`,src:o,...s}){let c=(0,y.useRef)(null),[l,u]=(0,y.useState)(void 0),[d,f]=(0,y.useState)(void 0),p=l===o,m=d===o;return(0,y.useEffect)(()=>{let e=c.current;typeof o==`string`&&e?.complete&&(e.naturalWidth>0?u(o):f(o))},[o]),(0,b.jsxs)(`div`,{"data-slot":`image-preview`,className:a(`relative min-h-32`,t),children:[!p&&!m&&(0,b.jsx)(`div`,{"data-slot":`image-preview-loading`,className:`bg-muted/50 absolute inset-0 flex items-center justify-center`,children:(0,b.jsx)(Uf,{className:`text-muted-foreground size-8 animate-pulse`})}),m?(0,b.jsx)(`div`,{"data-slot":`image-preview-error`,className:`bg-muted/50 flex min-h-32 items-center justify-center p-4`,children:(0,b.jsx)(Hf,{className:`text-muted-foreground size-8`})}):(0,b.jsx)(`img`,{ref:c,src:o,alt:i,className:a(`block h-auto w-full object-contain`,!p&&`invisible`,e),onLoad:e=>{typeof o==`string`&&u(o),n?.(e)},onError:e=>{typeof o==`string`&&f(o),r?.(e)},...s})]})}function p0({className:e,children:t,...n}){return t?(0,b.jsx)(`span`,{"data-slot":`image-filename`,className:a(`text-muted-foreground block truncate px-2 py-1.5 text-xs`,e),...n,children:t}):null}function m0({src:e,alt:t=`Image preview`,children:n}){let[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(null),o=(0,y.useRef)(null),s=(0,y.useRef)(null),c=(0,y.useCallback)(()=>i(!0),[]),l=(0,y.useCallback)(()=>{i(!1),a.current?.focus()},[]);return(0,y.useEffect)(()=>{if(!r)return;let e=e=>{if(e.key===`Escape`){l();return}if(e.key!==`Tab`)return;let t=s.current?.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`),n=t?.[0],r=t?.[t.length-1];n&&r&&(e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r,l]),(0,y.useEffect)(()=>{if(!r)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[r]),(0,y.useEffect)(()=>{r&&o.current?.focus()},[r]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{ref:a,onClick:c,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},role:`button`,tabIndex:0,className:`aui-image-zoom-trigger cursor-zoom-in`,"aria-label":`Click to zoom image`,children:n}),r&&(0,Ut.createPortal)((0,b.jsxs)(`div`,{ref:s,"data-slot":`image-zoom-overlay`,role:`dialog`,"aria-modal":`true`,className:`aui-image-zoom-overlay fade-in animate-in fixed inset-0 z-50 flex items-center justify-center bg-black/80 duration-200`,onClick:l,"aria-label":`Zoomed image`,children:[(0,b.jsx)(`img`,{"data-slot":`image-zoom-content`,src:e,alt:t,className:`aui-image-zoom-content fade-in zoom-in-95 animate-in max-h-[90vh] max-w-[90vw] cursor-zoom-out object-contain duration-200`,onClick:e=>{e.stopPropagation(),l()}}),(0,b.jsx)(`button`,{ref:o,type:`button`,"aria-label":`Close zoomed image`,onClick:e=>{e.stopPropagation(),l()},className:`text-muted-foreground hover:text-foreground bg-background/80 absolute end-4 top-4 cursor-pointer rounded-md p-2`,children:(0,b.jsx)(bp,{className:`size-5`})})]}),document.body)]})}function h0({className:e}){return(0,b.jsxs)(`div`,{"data-slot":`image-generating`,className:a(`bg-muted/50 flex min-h-32 items-center justify-center p-4`,e),children:[(0,b.jsx)(qf,{className:`text-muted-foreground size-8 animate-spin`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Generating image…`})]})}function g0({className:e,reason:t}){return(0,b.jsxs)(`div`,{"data-slot":`image-content-filter-error`,className:a(`bg-muted/50 flex min-h-32 flex-col items-center justify-center gap-2 p-4 text-center`,e),children:[(0,b.jsx)(op,{className:`text-muted-foreground size-8`}),(0,b.jsx)(`p`,{className:`text-sm font-medium`,children:`Image could not be generated`}),t&&(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t})]})}function _0({onRegenerate:e}){let[t,n]=(0,y.useState)(!1);return(0,b.jsx)(`button`,{type:`button`,onClick:async()=>{n(!0);try{await e()}catch{}finally{n(!1)}},disabled:t,"data-slot":`image-regenerate`,"aria-label":`Regenerate image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded disabled:opacity-50`,children:(0,b.jsx)(np,{className:a(`size-4`,t&&`animate-spin`)})})}function v0({part:e,onRegenerate:t,className:n}){return(0,b.jsxs)(`div`,{"data-slot":`image-actions`,className:a(`flex items-center gap-1 p-1`,n),children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>c0(e),"data-slot":`image-download`,"aria-label":`Download image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,b.jsx)(Ff,{className:`size-4`})}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{l0(e).catch(()=>{})},"data-slot":`image-copy`,"aria-label":`Copy image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,b.jsx)(Nf,{className:`size-4`})}),t&&(0,b.jsx)(_0,{onRegenerate:t})]})}var y0=(0,y.memo)(e=>{let{image:t,filename:n,status:r}=e;return r?.type===`running`?(0,b.jsxs)(d0,{children:[(0,b.jsx)(h0,{}),(0,b.jsx)(p0,{children:n})]}):r?.type===`incomplete`&&r.reason===`content-filter`?(0,b.jsx)(d0,{children:(0,b.jsx)(g0,{reason:`The provider blocked this image.`})}):(0,b.jsxs)(d0,{children:[(0,b.jsx)(m0,{src:t,alt:n||`Image content`,children:(0,b.jsx)(f0,{src:t,alt:n||`Image content`})}),(0,b.jsx)(p0,{children:n})]})});y0.displayName=`Image`,y0.Root=d0,y0.Preview=f0,y0.Filename=p0,y0.Zoom=m0,y0.Actions=v0,y0.Generating=h0,y0.ContentFilterError=g0;var b0=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),x0=(e,t)=>{if(!e||!t)return!1;let n=e=>{let{position:t,data:n,...r}=e||{};return r};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&b0(e.children,t.children)},S0=(e,t)=>x0(e.node,t.node),C0=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,y.memo)(({node:e,...t})=>(0,b.jsx)(n,{...t}),S0)]})),w0=(0,y.createContext)(null),T0=()=>(0,y.useContext)(w0)!==null,E0=(0,y.memo)(({children:e,fallbackPre:t,...n})=>n.node?.children.some(e=>e.type===`element`&&e.tagName===`code`)??!0?(0,b.jsx)(w0.Provider,{value:n,children:e}):(0,b.jsx)(t,{...n,children:e}),(e,t)=>e.fallbackPre===t.fallbackPre&&S0(e,t)),D0=({node:e,...t})=>(0,b.jsx)(`pre`,{...t}),O0=({node:e,...t})=>(0,b.jsx)(`code`,{...t}),k0=({node:e,components:{Pre:t,Code:n},code:r})=>(0,b.jsx)(t,{children:(0,b.jsx)(n,{node:e,children:r})}),A0=()=>null,j0=e=>/language-([^\s]+)/.exec(e??``)?.[1]??``,M0=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,y.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i,{node:e,language:a,code:o}),(0,b.jsx)(r,{node:e,components:s,language:a,code:o})]})},N0=n(r(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),P0=({className:e,...t})=>({className:n,...r})=>({className:(0,N0.default)(e,n),...t,...r});function F0(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=``;for(let n of e)t+=F0(n);return t}return(0,y.isValidElement)(e)?F0(e.props.children):``}var I0=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=P0((0,y.useContext)(w0)),l=dt(e=>(0,b.jsx)(t,{...c(e)})),u=P0(s),d=dt(e=>(0,b.jsx)(n,{...u(e)})),f=j0(s.className),p=a[f]?.SyntaxHighlighter??r,m=a[f]?.CodeHeader??i;return o!=null&&typeof o!=`string`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(m,{node:e,language:f,code:F0(o)}),(0,b.jsx)(k0,{node:e,components:{Pre:l,Code:d},code:o})]}):(0,b.jsx)(M0,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:p,CodeHeader:m},language:f,code:o??``})},L0=({node:e,components:t,componentsByLanguage:n,...r})=>T0()?(0,b.jsx)(I0,{node:e,components:t,componentsByLanguage:n,...r}):(0,b.jsx)(t.Code,{...r}),R0=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let n=e[r],i=t[r];if(n!==i&&(!n||!i||n.SyntaxHighlighter!==i.SyntaxHighlighter||n.CodeHeader!==i.CodeHeader))return!1}return!0},z0=(0,y.memo)(L0,(e,t)=>e.components===t.components&&R0(e.componentsByLanguage,t.componentsByLanguage)&&S0(e,t)),{useSmooth:B0,useSmoothStatus:V0,withSmoothContextProvider:H0}=IQ,U0=(0,y.memo)(({text:e,overrideVersion:t,...n})=>(0,b.jsx)(WO,{...n,children:e}));U0.displayName=`MarkdownRenderer`;var W0=({text:e,...t})=>{let n=(0,y.useDeferredValue)(e);return(0,b.jsx)(U0,{text:n,...t})},G0=e=>typeof e==`object`&&!!e&&!Array.isArray(e),K0=(e,t,n=1)=>{if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!K0(e[r],t[r],n-1))return!1;return!0}if(G0(e)&&G0(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&K0(e[r],t[r],n-1))}return!1};function q0(e,t){let n=(0,y.useRef)(e);return K0(e,n.current,t)||(n.current=e),n.current}function J0(e){let t=(0,y.useRef)(e),n=(e,t)=>e[t],r=Object.keys(e),i=Object.keys(t.current);return r.length===i.length&&r.every(r=>Object.hasOwn(t.current,r)&&K0(n(e,r),n(t.current,r)))||(t.current=e),t.current}var Y0=({components:e,componentsByLanguage:t,smooth:n=!0,defer:r=!1,preprocess:i,...a})=>{let{text:o}=B0(tX(),n),s=(0,y.useMemo)(()=>i?i(o):o,[i,o]),{pre:c=D0,code:l=O0,SyntaxHighlighter:u=k0,CodeHeader:d=A0}=e??{},f=(0,y.useMemo)(()=>({Pre:c,Code:l,SyntaxHighlighter:u,CodeHeader:d}),[c,l,u,d]),p=dt(e=>(0,b.jsx)(z0,{components:f,componentsByLanguage:t,...e})),m=dt(e=>(0,b.jsx)(E0,{fallbackPre:c,...e})),h=J0((0,y.useMemo)(()=>{let{pre:t,code:n,SyntaxHighlighter:r,CodeHeader:i,...a}=e??{};return{...a,pre:m,code:p}},[p,m,e])),g=q0((0,y.useMemo)(()=>({components:f,componentsByLanguage:t}),[f,t]),3),_=r?W0:U0,v=J0(a);return(0,b.jsx)(_,{text:s,components:h,overrideVersion:g,...v})},X0=(0,y.forwardRef)(({className:e,containerProps:t,containerComponent:n=`div`,...r},i)=>{let a=V0();return(0,b.jsx)(n,{"data-status":a.type,...t,className:(0,N0.default)(e,t?.className),ref:i,children:(0,b.jsx)(Y0,{...r})})});X0.displayName=`MarkdownTextPrimitive`;var Z0=H0(X0),Q0=({copiedDuration:e=3e3}={})=>{let[t,n]=(0,y.useState)(!1),r=(0,y.useRef)(void 0),i=(0,y.useRef)(0);return(0,y.useEffect)(()=>()=>{i.current+=1,r.current!==void 0&&(clearTimeout(r.current),r.current=void 0,n(!1))},[]),{isCopied:t,copyToClipboard:t=>{if(!t||typeof navigator>`u`||!navigator.clipboard)return;let a=i.current;navigator.clipboard.writeText(t).then(()=>{a===i.current&&(r.current!==void 0&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{r.current=void 0,n(!1)},e))},()=>{})}}},$0=e=>{let t=(0,y.useRef)(e);if(e!==t.current){let n=t.current;e!==void 0&&n!==void 0&&Object.keys(n).length===Object.keys(e).length&&Object.keys(e).every(t=>n[t]===e[t])||(t.current=e)}return t.current},e2=(0,y.memo)(({components:e})=>{let t=$0(e),n=(0,y.useMemo)(()=>t?{...t2,...C0(t)}:t2,[t]);return(0,b.jsx)(Z0,{remarkPlugins:[Jj],className:`aui-md`,components:n,defer:!0})}),t2=C0({h1:({className:e,...t})=>(0,b.jsx)(`h1`,{className:a(`aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0`,e),...t}),h2:({className:e,...t})=>(0,b.jsx)(`h2`,{className:a(`aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0`,e),...t}),h3:({className:e,...t})=>(0,b.jsx)(`h3`,{className:a(`aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0`,e),...t}),h4:({className:e,...t})=>(0,b.jsx)(`h4`,{className:a(`aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0`,e),...t}),h5:({className:e,...t})=>(0,b.jsx)(`h5`,{className:a(`aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0`,e),...t}),h6:({className:e,...t})=>(0,b.jsx)(`h6`,{className:a(`aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0`,e),...t}),p:({className:e,...t})=>(0,b.jsx)(`p`,{className:a(`aui-md-p my-3 leading-relaxed first:mt-0 last:mb-0`,e),...t}),a:({className:e,...t})=>(0,b.jsx)(`a`,{className:a(`aui-md-a text-primary hover:text-primary/80 underline underline-offset-2`,e),...t}),blockquote:({className:e,...t})=>(0,b.jsx)(`blockquote`,{className:a(`aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4`,e),...t}),ul:({className:e,...t})=>(0,b.jsx)(`ul`,{className:a(`aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1`,e),...t}),ol:({className:e,...t})=>(0,b.jsx)(`ol`,{className:a(`aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1`,e),...t}),hr:({className:e,...t})=>(0,b.jsx)(`hr`,{className:a(`aui-md-hr border-muted-foreground/20 my-3`,e),...t}),table:({className:e,...t})=>(0,b.jsx)(`div`,{className:`aui-md-table-wrapper my-3 overflow-x-auto`,children:(0,b.jsx)(`table`,{className:a(`aui-md-table w-full border-separate border-spacing-0`,e),...t})}),th:({className:e,...t})=>(0,b.jsx)(`th`,{className:a(`aui-md-th bg-muted px-3 py-1.5 text-start font-medium first:rounded-ss-lg last:rounded-se-lg [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),td:({className:e,...t})=>(0,b.jsx)(`td`,{className:a(`aui-md-td border-muted-foreground/20 border-s border-b px-3 py-1.5 text-start last:border-e [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),tr:({className:e,...t})=>(0,b.jsx)(`tr`,{className:a(`aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-es-lg [&:last-child>td:last-child]:rounded-ee-lg`,e),...t}),li:({className:e,...t})=>(0,b.jsx)(`li`,{className:a(`aui-md-li leading-relaxed`,e),...t}),strong:({className:e,...t})=>(0,b.jsx)(`strong`,{className:a(`aui-md-strong font-semibold`,e),...t}),sup:({className:e,...t})=>(0,b.jsx)(`sup`,{className:a(`aui-md-sup [&>a]:text-xs [&>a]:no-underline`,e),...t}),pre:({className:e,...t})=>(0,b.jsx)(`pre`,{className:a(`aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed`,e),...t}),code:function({className:e,...t}){let n=T0();return(0,b.jsx)(`code`,{className:a(!n&&`aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]`,e),...t})},CodeHeader:({language:e,code:t})=>{let{isCopied:n,copyToClipboard:r}=Q0();return(0,b.jsxs)(`div`,{className:`aui-code-header-root border-border/50 bg-muted/50 mt-3 flex items-center justify-between rounded-t-xl border border-b-0 px-3.5 py-1.5 text-xs`,children:[(0,b.jsx)(`span`,{className:`aui-code-header-language text-muted-foreground font-medium lowercase`,children:e}),(0,b.jsxs)(D1,{tooltip:`Copy`,onClick:()=>{t&&!n&&r(t)},children:[!n&&(0,b.jsx)(Nf,{className:`animate-in zoom-in-75 fade-in duration-150`}),n&&(0,b.jsx)(Cf,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})]})]})}});function n2({...e}){return(0,b.jsx)(it,{"data-slot":`collapsible`,...e})}function r2({...e}){return(0,b.jsx)($e,{"data-slot":`collapsible-trigger`,...e})}function i2({...e}){return(0,b.jsx)(tt,{"data-slot":`collapsible-content`,...e})}var a2=(0,y.createContext)(!1),o2=v(`aui-reasoning-root mb-4 w-full`,{variants:{variant:{outline:`rounded-lg border px-3 py-2`,ghost:``,muted:`bg-muted/50 rounded-lg px-3 py-2`}},defaultVariants:{variant:`outline`}});function s2({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,streaming:o,onAnimationStart:s,children:c,...l}){let[u]=(0,y.useState)(i),[d,f]=(0,y.useState)(null),p=n!==void 0,m=p?n:d??(o||u),h=o===!0&&m,g=(0,y.useRef)(o);(0,y.useLayoutEffect)(()=>{g.current!==o&&(g.current=o,!p&&d===null&&!u&&s?.())},[o,p,d,u,s]);let _=(0,y.useCallback)(e=>{s?.(),p||f(e),r?.(e)},[s,p,r]);return(0,b.jsx)(n2,{"data-slot":`reasoning-root`,"data-variant":t,open:m,onOpenChange:_,className:a(`group/reasoning-root`,o2({variant:t,className:e})),style:{"--animation-duration":`200ms`},...l,children:(0,b.jsx)(a2.Provider,{value:h,children:c})})}function c2({side:e=`bottom`,className:t,...n}){return e===`top`?(0,b.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-8`,`bg-[linear-gradient(to_bottom,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_bottom,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n}):(0,b.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8`,`bg-[linear-gradient(to_top,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_top,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n})}function l2({active:e,duration:t,className:n,...r}){let i=t?` (${t}s)`:``;return(0,b.jsxs)(r2,{"data-slot":`reasoning-trigger`,className:a(`aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground flex max-w-[75%] origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,b.jsx)(Sf,{"data-slot":`reasoning-trigger-icon`,className:`aui-reasoning-trigger-icon size-4 shrink-0`}),(0,b.jsxs)(`span`,{"data-slot":`reasoning-trigger-label`,className:a(`aui-reasoning-trigger-label-wrapper inline-block leading-none tabular-nums`,e&&`shimmer motion-reduce:animate-none`),children:[`Reasoning`,i]}),(0,b.jsx)(wf,{"data-slot":`reasoning-trigger-chevron`,className:a(`aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function u2({className:e,children:t,...n}){let r=(0,y.useContext)(a2);return(0,b.jsxs)(i2,{"data-slot":`reasoning-content`,className:a(`aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:[(0,b.jsx)(c2,{side:`top`}),t,r?(0,b.jsx)(c2,{}):null]})}function d2({className:e,children:t,...n}){let r=(0,y.useContext)(a2),i=(0,y.useRef)(null),o=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!r)return;let e=i.current,t=o.current;if(!e||!t)return;let n=!0,a=e.scrollTop,s=e.scrollHeight,c=()=>Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight,l=()=>{n&&(e.scrollTop=e.scrollHeight)},u=()=>{c()?n=!0:e.scrollTop<a&&e.scrollHeight===s&&(n=!1),a=e.scrollTop,s=e.scrollHeight};l(),e.addEventListener(`scroll`,u);let d=new ResizeObserver(l);return d.observe(t),()=>{e.removeEventListener(`scroll`,u),d.disconnect()}},[r]),(0,b.jsx)(`div`,{ref:i,"data-slot":`reasoning-text`,className:a(`aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty`,`transform-gpu transition-[transform,opacity] ease-[cubic-bezier(0.32,0.72,0,1)]`,`motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in`,`group-data-closed/collapsible-content:animate-out`,`group-data-open/collapsible-content:fade-in-0`,`group-data-closed/collapsible-content:fade-out-0`,`group-data-open/collapsible-content:slide-in-from-top-4`,`group-data-closed/collapsible-content:slide-out-to-top-4`,`group-data-open/collapsible-content:blur-in-[2px]`,`group-data-closed/collapsible-content:blur-out-[2px]`,`group-data-open/collapsible-content:animation-duration-(--animation-duration)`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration)`,e),...n,children:(0,b.jsx)(`div`,{ref:o,className:`aui-reasoning-text-content space-y-4`,children:t})})}function f2({ref:e,onAnimationStart:t,...n}){let r=(0,y.useRef)(null),i=jQ(r,200),a=(0,y.useCallback)(()=>{i(),t?.()},[i,t]),o=(0,y.useCallback)(t=>{r.current=t,typeof e==`function`?e(t):e&&(e.current=t)},[e]);return(0,b.jsx)(s2,{ref:o,onAnimationStart:a,...n})}var p2=()=>(0,b.jsx)(e2,{}),m2=({children:e,startIndex:t,endIndex:n})=>{let r=$(e=>{if(e.message.status?.type!==`running`)return!1;for(let r=t;r<=n;r++)if(e.message.parts[r]?.status.type===`running`)return!0;return!1});return(0,b.jsxs)(f2,{streaming:r,children:[(0,b.jsx)(l2,{active:r}),(0,b.jsx)(u2,{"aria-busy":r,children:(0,b.jsx)(d2,{children:e})})]})},h2=(0,y.memo)(p2);h2.displayName=`Reasoning`,h2.Root=f2,h2.Trigger=l2,h2.Content=u2,h2.Text=d2,h2.Fade=c2;var g2=(0,y.memo)(m2);g2.displayName=`ReasoningGroup`;function _2({className:e,...t}){return(0,b.jsx)(`textarea`,{"data-slot":`textarea`,className:a(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var v2=200,y2=`active:scale-[0.98]`;function b2({className:e,open:t,onOpenChange:n,defaultOpen:r=!1,children:i,...o}){let s=(0,y.useRef)(null),[c,l]=(0,y.useState)(r),u=jQ(s,v2),d=t!==void 0,f=d?t:c,p=(0,y.useCallback)(e=>{u(),d||l(e),n?.(e)},[u,d,n]);return(0,b.jsx)(n2,{ref:s,"data-slot":`tool-fallback-root`,open:f,onOpenChange:p,className:a(`aui-tool-fallback-root group/tool-fallback-root w-full`,e),style:{"--animation-duration":`${v2}ms`},...o,children:i})}var x2={running:Jf,complete:Cf,incomplete:kf,"requires-action":Df},S2=e=>{if(e<1e3)return`<1s`;let t=e/1e3;return t<10?`${(Math.floor(t*10)/10).toFixed(1)}s`:t<60?`${Math.floor(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60)}s`};function C2({className:e,...t}){let n=MQ();return n===void 0?null:(0,b.jsx)(`span`,{"data-slot":`tool-fallback-duration`,className:a(`aui-tool-fallback-duration text-muted-foreground text-xs tabular-nums`,e),...t,children:S2(n)})}function w2({toolName:e,status:t,className:n,...r}){let i=t?.type??`complete`,o=i===`running`,s=t?.type===`incomplete`&&t.reason===`cancelled`,c=x2[i],l=s?`Cancelled tool`:`Used tool`;return(0,b.jsxs)(r2,{"data-slot":`tool-fallback-trigger`,className:a(`aui-tool-fallback-trigger group/trigger text-muted-foreground hover:text-foreground flex w-fit origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,b.jsx)(c,{"data-slot":`tool-fallback-trigger-icon`,className:a(`aui-tool-fallback-trigger-icon size-4 shrink-0`,s&&`text-muted-foreground`,o&&`animate-spin [animation-duration:0.6s]`)}),(0,b.jsxs)(`span`,{"data-slot":`tool-fallback-trigger-label`,className:a(`aui-tool-fallback-trigger-label-wrapper inline-block text-start leading-none`,s&&`text-muted-foreground line-through`,o&&`shimmer motion-reduce:animate-none`),children:[l,`: `,(0,b.jsx)(`b`,{children:e})]}),(0,b.jsx)(C2,{}),(0,b.jsx)(wf,{"data-slot":`tool-fallback-trigger-chevron`,className:a(`aui-tool-fallback-trigger-chevron size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function T2({className:e,children:t,...n}){return(0,b.jsx)(i2,{"data-slot":`tool-fallback-content`,className:a(`aui-tool-fallback-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,b.jsx)(`div`,{className:a(`flex flex-col gap-2 ps-6 pt-1 pb-2 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in group-data-open/collapsible-content:fade-in-0 group-data-open/collapsible-content:blur-in-[2px] group-data-open/collapsible-content:slide-in-from-top-1`,`group-data-closed/collapsible-content:animate-out group-data-closed/collapsible-content:fade-out-0 group-data-closed/collapsible-content:blur-out-[2px] group-data-closed/collapsible-content:slide-out-to-top-1`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration) group-data-open/collapsible-content:animation-duration-(--animation-duration)`),children:t})})}function E2({argsText:e,className:t,...n}){return e?(0,b.jsx)(`div`,{"data-slot":`tool-fallback-args`,className:a(`aui-tool-fallback-args`,t),...n,children:(0,b.jsx)(`pre`,{className:`aui-tool-fallback-args-value bg-muted/50 text-foreground/90 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:e})}):null}var D2=(e,t)=>{if(typeof e==`string`)return e;try{if(e instanceof Error)return String(e);let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return`[Unserializable value]`}};function O2({result:e,className:t,...n}){return e===void 0?null:(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-result`,className:a(`aui-tool-fallback-result`,t),...n,children:[(0,b.jsx)(`p`,{className:`aui-tool-fallback-result-header text-muted-foreground text-xs font-medium`,children:`Result:`}),(0,b.jsx)(`pre`,{className:`aui-tool-fallback-result-content bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:D2(e,2)})]})}function k2({status:e,className:t,...n}){if(e?.type!==`incomplete`)return null;let r=e.error,i=r==null?null:D2(r);if(!i)return null;let o=e.reason===`cancelled`?`Cancelled reason:`:`Error:`;return(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-error`,className:a(`aui-tool-fallback-error`,t),...n,children:[(0,b.jsx)(`p`,{className:`aui-tool-fallback-error-header text-muted-foreground font-semibold`,children:o}),(0,b.jsx)(`p`,{className:`aui-tool-fallback-error-reason text-muted-foreground whitespace-pre-line`,children:i})]})}var A2=`Approved by user`,j2=`User denied tool execution`,M2={"allow-once":`Allow`,"allow-always":`Always allow`,"reject-once":`Deny`,"reject-always":`Always deny`},N2=e=>Object.hasOwn(M2,e),P2=e=>e===`allow-once`||e===`allow-always`,F2=e=>e.label??(N2(e.kind)?M2[e.kind]:void 0)??e.id,I2=e=>e?.display===`select`||e?.display===`text`,L2=(e,t,n)=>e?.type!==`requires-action`||e.reason!==`interrupt`||t!=null||n!=null;function R2({className:e,addResult:t,resume:n,interrupt:r,approval:i,respondToApproval:s,status:c,...l}){let[u,d]=(0,y.useState)(!1),f=$(e=>e.thread.voice!==void 0),p=u||f,[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(``),[v,x]=(0,y.useState)(null);if(i!=null&&(i.approved!==void 0||i.resolution!==void 0)||!L2(c,i,r))return null;let S=s?i?.options:void 0,C=i!=null&&s!=null&&HV(i),w=e=>{d(!0),x(null),(async()=>{try{await e()}catch(e){d(!1),x(e instanceof Error?e.message:String(e))}})()},T=e=>{if(!p){if(i!=null&&i.approved===void 0&&s)w(()=>s({approved:e,...D()}));else if(r)w(()=>n?.({approved:e}));else if(c?.type===`requires-action`&&c.reason===`interrupt`)return;else w(()=>t?.(e?A2:j2))}},E=e=>{p||(h(null),w(()=>s?.(N2(e.kind)?{optionId:e.id,...D()}:{optionId:e.id,approved:!0,...D()})))},D=()=>g.trim()?{text:g}:{},O=()=>{p||w(()=>s?.({text:g}))},k=()=>{p||w(()=>s?.({approved:!1}))},A=e=>{e.confirm?h(e.id):E(e)},j=m==null?void 0:S?.find(e=>e.id===m),M=I2(i),N=M&&s!=null&&i?.dismissible===!0?(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:y2,onClick:k,disabled:p,children:`Dismiss`}):null,ee=i?.prompt?(0,b.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-foreground whitespace-pre-line`,children:i.prompt}):null,te=v?(0,b.jsx)(`p`,{role:`alert`,className:`aui-tool-fallback-approval-error text-destructive text-xs whitespace-pre-line`,children:v}):null,ne=C?(0,b.jsxs)(`div`,{className:`aui-tool-fallback-approval-answer flex flex-col items-start gap-2`,children:[(0,b.jsx)(_2,{value:g,onChange:e=>_(e.target.value),disabled:p,"aria-label":M?i?.prompt??`Answer`:`Note`,placeholder:M?`Type your answer`:`Add a note to your decision`}),M&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:y2,onClick:O,disabled:p,children:`Send`}),N]})]}):null;if(j){let t=typeof j.confirm==`object`?j.confirm:void 0,n=t?.description??j.description;return(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval-confirm`,className:a(`aui-tool-fallback-approval-confirm flex flex-col gap-2 pt-1`,e),...l,children:[(0,b.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-title font-semibold`,children:t?.title??`${F2(j)}?`}),n&&(0,b.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-description text-muted-foreground whitespace-pre-line`,children:n}),j.grants&&j.grants.length>0&&(0,b.jsx)(`ul`,{className:`aui-tool-fallback-approval-confirm-grants flex flex-col gap-1`,children:j.grants.map(e=>(0,b.jsx)(`li`,{children:(0,b.jsx)(`code`,{className:`aui-tool-fallback-approval-confirm-grant bg-muted rounded px-1.5 py-0.5 text-xs`,children:e})},e))}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:y2,onClick:()=>E(j),disabled:p,children:`Confirm`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:y2,onClick:()=>h(null),disabled:p,children:`Back`})]})]})}if(S&&S.length>0){let t=S.filter(e=>P2(e.kind)),n=S.filter(e=>!N2(e.kind)),r=S.filter(e=>N2(e.kind)&&!P2(e.kind));return(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[ee,(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[...t,...n,...r].map(e=>(0,b.jsx)(o,{size:`sm`,variant:e===t[0]?`default`:`outline`,className:y2,onClick:()=>A(e),disabled:p,children:F2(e)},e.id)),r.length===0&&!M&&(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:y2,onClick:()=>T(!1),disabled:p,children:`Deny`}),!C&&N]}),ne,te]})}return M?(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[ee,ne,!C&&N&&(0,b.jsx)(`div`,{className:`flex items-center gap-2`,children:N}),te]}):(0,b.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[ee,(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:y2,onClick:()=>T(!0),disabled:p,children:`Allow`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,className:y2,onClick:()=>T(!1),disabled:p,children:`Deny`})]}),ne,te]})}var z2=(0,y.memo)(({toolName:e,argsText:t,result:n,status:r,addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l})=>{let u=r?.type===`incomplete`&&r.reason===`cancelled`,d=r?.type===`requires-action`,f=d&&L2(r,c,s),[p,m]=(0,y.useState)(d),[h,g]=(0,y.useState)(d);return d!==h&&(g(d),d&&m(!0)),(0,b.jsxs)(b2,{open:p,onOpenChange:m,children:[(0,b.jsx)(w2,{toolName:e,status:r}),(0,b.jsxs)(T2,{children:[(0,b.jsx)(k2,{status:r}),(0,b.jsx)(E2,{argsText:t,className:a(u&&`opacity-60`)}),f&&(0,b.jsx)(R2,{addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l,status:r}),(0,b.jsx)(O2,{result:n})]})]})});z2.displayName=`ToolFallback`,z2.Root=b2,z2.Trigger=w2,z2.Content=T2,z2.Args=E2,z2.Result=O2,z2.Error=k2,z2.Approval=R2;var B2=200,V2=v(`aui-tool-group-root group/tool-group w-full`,{variants:{variant:{outline:`rounded-lg border py-3`,ghost:``,muted:`border-muted-foreground/30 bg-muted/30 rounded-lg border py-3`}},defaultVariants:{variant:`outline`}});function H2({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,children:o,...s}){let c=(0,y.useRef)(null),[l,u]=(0,y.useState)(i),d=jQ(c,B2),f=n!==void 0,p=f?n:l,m=(0,y.useCallback)(e=>{d(),f||u(e),r?.(e)},[d,f,r]);return(0,b.jsx)(n2,{ref:c,"data-slot":`tool-group-root`,"data-variant":t??`outline`,open:p,onOpenChange:m,className:a(V2({variant:t}),`group/tool-group-root`,e),style:{"--animation-duration":`${B2}ms`},...s,children:o})}function U2({count:e,active:t=!1,className:n,...r}){let i=`${e} tool ${e===1?`call`:`calls`}`;return(0,b.jsxs)(r2,{"data-slot":`tool-group-trigger`,className:a(`aui-tool-group-trigger group/trigger flex origin-left items-center gap-2 text-sm transition-[color,scale] active:scale-[0.98]`,`group-data-[variant=ghost]/tool-group-root:text-muted-foreground group-data-[variant=ghost]/tool-group-root:hover:text-foreground group-data-[variant=ghost]/tool-group-root:py-1.5`,`group-data-[variant=outline]/tool-group-root:w-full group-data-[variant=outline]/tool-group-root:px-4`,`group-data-[variant=muted]/tool-group-root:w-full group-data-[variant=muted]/tool-group-root:px-4`,n),...r,children:[t&&(0,b.jsx)(Jf,{"data-slot":`tool-group-trigger-loader`,className:`aui-tool-group-trigger-loader size-3 shrink-0 animate-spin [animation-duration:0.6s]`}),(0,b.jsx)(`span`,{"data-slot":`tool-group-trigger-label`,className:a(`aui-tool-group-trigger-label-wrapper inline-block text-start text-xs leading-none font-medium`,`group-data-[variant=ghost]/tool-group-root:font-normal`,`group-data-[variant=outline]/tool-group-root:grow`,`group-data-[variant=muted]/tool-group-root:grow`,t&&`shimmer motion-reduce:animate-none`),children:i}),(0,b.jsx)(wf,{"data-slot":`tool-group-trigger-chevron`,className:a(`aui-tool-group-trigger-chevron size-3 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function W2({className:e,children:t,...n}){return(0,b.jsx)(i2,{"data-slot":`tool-group-content`,className:a(`aui-tool-group-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,b.jsx)(`div`,{className:a(`mt-2 flex flex-col gap-2`,`group-data-[variant=ghost]/tool-group-root:mt-1 group-data-[variant=ghost]/tool-group-root:gap-1`,`group-data-[variant=outline]/tool-group-root:mt-3 group-data-[variant=outline]/tool-group-root:border-t group-data-[variant=outline]/tool-group-root:px-4 group-data-[variant=outline]/tool-group-root:pt-3`,`group-data-[variant=muted]/tool-group-root:mt-3 group-data-[variant=muted]/tool-group-root:border-t group-data-[variant=muted]/tool-group-root:px-4 group-data-[variant=muted]/tool-group-root:pt-3`,`[&>*]:animate-in [&>*]:fade-in-0 [&>*]:blur-in-[2px] [&>*]:slide-in-from-top-1 [&>*]:animation-duration-(--animation-duration) [&>*]:ease-[cubic-bezier(0.32,0.72,0,1)]`,`[&>*]:motion-reduce:animate-none`,`[&>*:nth-child(2)]:[animation-delay:40ms]`,`[&>*:nth-child(3)]:[animation-delay:80ms]`,`[&>*:nth-child(4)]:[animation-delay:120ms]`,`[&>*:nth-child(n+5)]:[animation-delay:160ms]`),children:t})})}var G2=(0,y.memo)(({children:e,startIndex:t,endIndex:n})=>{let r=n-t+1;return(0,b.jsxs)(H2,{children:[(0,b.jsx)(U2,{count:r}),(0,b.jsx)(W2,{children:e})]})});G2.displayName=`ToolGroup`,G2.Root=H2,G2.Trigger=U2,G2.Content=W2;function K2({className:e,...t}){return(0,b.jsx)(`div`,{"data-slot":`skeleton`,className:a(`animate-pulse rounded-md bg-accent`,e),...t})}var q2=ZW({reasoning:[`group-chainOfThought`,`group-reasoning`],"tool-call":[`group-chainOfThought`,`group-tool`],"standalone-tool-call":[]}),J2=[`group-chainOfThought`,`group-task`],Y2=(e,t)=>{let n=q2(e,t);return e.type===`tool-call`&&e.messages!==void 0&&n.length>0&&!t?.toolUIs?.[e.toolName]?.length?J2:n},X2={},Z2=(0,y.createContext)(X2),Q2=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading),$2=e=>e.thread.messages.length===0&&e.thread.isLoading&&!e.thread.isDisabled&&!e.threads.isLoading,e4=()=>(0,b.jsxs)(`div`,{"data-slot":`aui_thread-history-skeleton`,role:`status`,className:`animate-in fade-in fill-mode-both flex flex-col gap-y-6 [animation-delay:150ms] [animation-duration:200ms]`,children:[(0,b.jsx)(`span`,{className:`sr-only`,children:`Loading conversation`}),(0,b.jsx)(K2,{className:`ml-auto h-9 w-2/5 rounded-xl motion-reduce:animate-none`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,b.jsx)(K2,{className:`h-4 w-11/12 motion-reduce:animate-none`}),(0,b.jsx)(K2,{className:`h-4 w-4/5 motion-reduce:animate-none`}),(0,b.jsx)(K2,{className:`h-4 w-3/5 motion-reduce:animate-none`})]}),(0,b.jsx)(K2,{className:`ml-auto h-9 w-1/3 rounded-xl motion-reduce:animate-none`}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,b.jsx)(K2,{className:`h-4 w-10/12 motion-reduce:animate-none`}),(0,b.jsx)(K2,{className:`h-4 w-2/3 motion-reduce:animate-none`})]})]}),t4=({components:e=X2,autoFocus:t=!0})=>{let n=$(Q2);return(0,b.jsx)(Z2.Provider,{value:e,children:(0,b.jsx)(n4,{isEmpty:n,autoFocus:t})})},n4=({isEmpty:e,autoFocus:t})=>{let{Welcome:n=l4}=(0,y.useContext)(Z2);return(0,b.jsx)(JZ.Root,{className:`aui-root aui-thread-root bg-background @container flex h-full flex-col`,style:{"--thread-max-width":`44rem`,"--composer-bg":`color-mix(in oklab, var(--color-muted) 30%, transparent)`,"--composer-radius":`var(--radius-2xl)`,"--composer-padding":`8px`},children:(0,b.jsx)(JZ.Viewport,{turnAnchor:`top`,"data-slot":`aui_thread-viewport`,className:`relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth`,children:(0,b.jsxs)(`div`,{className:a(`mx-auto flex w-full max-w-(--thread-max-width) flex-1 flex-col px-4 pt-4`,e&&`justify-center`),children:[(0,b.jsx)(XL,{condition:Q2,children:(0,b.jsx)(n,{})}),(0,b.jsx)(XL,{condition:$2,children:(0,b.jsx)(e4,{})}),(0,b.jsx)(`div`,{"data-slot":`aui_message-group`,className:`mb-14 flex flex-col gap-y-6 empty:hidden`,children:(0,b.jsx)(JZ.Messages,{children:()=>(0,b.jsx)(r4,{})})}),(0,b.jsxs)(JZ.ViewportFooter,{className:a(`aui-thread-viewport-footer bg-background flex flex-col gap-4 overflow-visible pb-4 md:pb-6`,!e&&`sticky bottom-0 mt-auto rounded-t-(--composer-radius)`),children:[(0,b.jsx)(c4,{}),(0,b.jsx)(i0,{}),(0,b.jsx)(f4,{autoFocus:t}),(0,b.jsx)(XL,{condition:e=>Q2(e)&&e.composer.isEmpty,children:(0,b.jsx)(u4,{})})]})]})})})},r4=()=>{let{AssistantMessage:e=h4}=(0,y.useContext)(Z2),t=$(e=>e.message.role),n=$(e=>e.message.composer.isEditing),r=$(e=>e.message.metadata.modality===`voice`);return n?(0,b.jsx)(x4,{}):r?(0,b.jsx)(o4,{}):t===`user`?(0,b.jsx)(y4,{}):(0,b.jsx)(e,{})},i4=()=>$(e=>{let t=e.thread.messages[e.message.index-1]?.metadata.modality===`voice`,n=e.thread.messages[e.message.index+1]?.metadata.modality===`voice`;return t?n?`middle`:`end`:n?`start`:`single`}),a4=({text:e})=>(0,b.jsx)(`p`,{className:`aui-spoken-message-text m-0`,children:e}),o4=()=>{let e=$(e=>e.message.role),t=i4(),n=$(e=>e.message.role===`assistant`&&e.message.status?.type===`running`),r=t===`start`||t===`single`;return(0,b.jsxs)(uZ.Root,{"data-slot":`aui_spoken-message-root`,"data-role":e,"data-voice-run":t,className:a(`aui-spoken-message bg-muted/40 mx-2 px-3 py-1.5 [contain-intrinsic-size:auto_48px] [content-visibility:auto]`,t===`single`&&`rounded-xl py-2`,t===`start`&&`rounded-t-xl pt-2`,t===`middle`&&`-mt-6`,t===`end`&&`-mt-6 rounded-b-xl pb-2`),children:[r&&(0,b.jsxs)(`div`,{"data-slot":`aui_spoken-exchange-header`,className:`text-muted-foreground mb-1.5 flex items-center gap-1.5 text-xs`,children:[(0,b.jsx)($f,{className:`size-3`,"aria-hidden":!0}),(0,b.jsx)(`span`,{children:`Voice conversation`})]}),(0,b.jsxs)(`div`,{"data-slot":`aui_spoken-message-content`,className:`text-foreground flex items-start gap-2 text-sm leading-relaxed`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground mt-1 shrink-0`,"aria-hidden":!0,children:e===`user`?(0,b.jsx)(Yf,{className:`size-3.5`}):(0,b.jsx)(bf,{className:`size-3.5`})}),(0,b.jsx)(`span`,{className:`sr-only`,children:e===`user`?`You said`:`Assistant said`}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1 wrap-break-word`,children:[(0,b.jsx)(uZ.Parts,{components:{Text:a4}}),n&&(0,b.jsx)(`span`,{"data-slot":`aui_spoken-message-indicator`,role:`status`,className:`text-muted-foreground ms-1 animate-pulse font-sans`,"aria-label":`Assistant is speaking`,children:`●`})]}),(0,b.jsx)(s4,{})]})]})},s4=()=>(0,b.jsx)(kq.Root,{hideWhenRunning:!0,autohide:`always`,className:`aui-spoken-action-bar text-muted-foreground flex shrink-0 gap-1`,children:(0,b.jsx)(kq.Copy,{asChild:!0,children:(0,b.jsxs)(D1,{tooltip:`Copy`,className:`size-6`,children:[(0,b.jsx)(XL,{condition:e=>e.message.isCopied,children:(0,b.jsx)(Cf,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,b.jsx)(XL,{condition:e=>!e.message.isCopied,children:(0,b.jsx)(Nf,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})})}),c4=()=>(0,b.jsx)(JZ.ScrollToBottom,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Scroll to bottom`,variant:`outline`,className:`aui-thread-scroll-to-bottom dark:border-border dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible`,children:(0,b.jsx)(gf,{})})}),l4=()=>(0,b.jsx)(`div`,{className:`aui-thread-welcome-root mb-6 flex flex-col px-2`,children:(0,b.jsx)(`p`,{className:`aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-medium tracking-tight duration-200`,children:`How can I help you today?`})}),u4=()=>(0,b.jsx)(`div`,{className:`aui-thread-welcome-suggestions flex w-full flex-col`,children:(0,b.jsx)(JZ.Suggestions,{children:()=>(0,b.jsx)(d4,{})})}),d4=()=>(0,b.jsx)(`div`,{className:`aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-2 animate-in fill-mode-both duration-200`,children:(0,b.jsx)(tQ.Trigger,{send:!0,asChild:!0,children:(0,b.jsxs)(`button`,{type:`button`,className:`aui-thread-welcome-suggestion group hover:bg-foreground/[0.03] focus-visible:ring-ring/50 flex w-full items-baseline gap-2.5 rounded-md px-2 py-2 text-start text-sm transition-colors outline-none focus-visible:ring-1 motion-reduce:transition-none`,children:[(0,b.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 group-hover:text-foreground font-mono text-xs transition-colors motion-reduce:transition-none`,children:`>`}),(0,b.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,b.jsx)(tQ.Title,{className:`aui-thread-welcome-suggestion-text-1 text-foreground`}),` `,(0,b.jsx)(tQ.Description,{className:`aui-thread-welcome-suggestion-text-2 text-muted-foreground empty:hidden`})]})]})})}),f4=({autoFocus:e})=>(0,b.jsx)(QY.Root,{className:`aui-composer-root relative flex w-full flex-col`,children:(0,b.jsx)(QY.AttachmentDropzone,{asChild:!0,children:(0,b.jsxs)(`div`,{"data-slot":`aui_composer-shell`,className:`border-foreground/10 focus-within:border-foreground/25 data-[dragging=true]:border-ring flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]`,children:[(0,b.jsx)(H1,{}),(0,b.jsx)(QY.Input,{placeholder:`Send a message...`,className:`aui-composer-input caret-primary placeholder:text-muted-foreground/60 max-h-48 min-h-10 w-full resize-none bg-transparent px-2.5 py-1 text-base leading-6 outline-none`,rows:1,autoFocus:e,enterKeyHint:`send`,"aria-label":`Message input`}),(0,b.jsx)(p4,{})]})})}),p4=()=>(0,b.jsxs)(`div`,{className:`aui-composer-action-wrapper relative flex items-center justify-between`,children:[(0,b.jsx)(U1,{}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,b.jsxs)(XL,{condition:e=>e.thread.capabilities.dictation,children:[(0,b.jsx)(XL,{condition:e=>e.composer.dictation==null,children:(0,b.jsx)(QY.Dictate,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Voice input`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-dictate text-muted-foreground hover:text-foreground size-7 rounded-full`,"aria-label":`Start voice input`,children:(0,b.jsx)(Yf,{className:`aui-composer-dictate-icon size-4`})})})}),(0,b.jsx)(XL,{condition:e=>e.composer.dictation!=null,children:(0,b.jsx)(QY.StopDictation,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Stop dictation`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-stop-dictation text-destructive size-7 rounded-full`,"aria-label":`Stop voice input`,children:(0,b.jsx)(up,{className:`aui-composer-stop-dictation-icon size-3.5 animate-pulse fill-current`})})})})]}),(0,b.jsx)(XL,{condition:e=>!e.thread.isRunning||e.thread.voice!==void 0,children:(0,b.jsx)(QY.Send,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Send message`,side:`bottom`,type:`button`,variant:`default`,size:`icon`,className:`aui-composer-send size-7 rounded-full`,"aria-label":`Send message`,children:(0,b.jsx)(yf,{className:`aui-composer-send-icon size-4`})})})}),(0,b.jsx)(XL,{condition:e=>e.thread.isRunning&&e.thread.voice===void 0,children:(0,b.jsx)(QY.Cancel,{asChild:!0,children:(0,b.jsx)(o,{type:`button`,variant:`default`,size:`icon`,className:`aui-composer-cancel size-7 rounded-full`,"aria-label":`Stop generating`,children:(0,b.jsx)(up,{className:`aui-composer-cancel-icon size-3.5 fill-current`})})})})]})]}),m4=()=>(0,b.jsx)(uZ.Error,{children:(0,b.jsx)(wX.Root,{className:`aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200`,children:(0,b.jsx)(wX.Message,{className:`aui-message-error-message line-clamp-2`})})}),h4=()=>{let{ToolFallback:e=z2,ToolGroup:t,ReasoningGroup:n,TaskGroup:r}=(0,y.useContext)(Z2),i=r?Y2:q2;return(0,b.jsxs)(uZ.Root,{"data-slot":`aui_assistant-message-root`,"data-role":`assistant`,className:`fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:[(0,b.jsxs)(`div`,{"data-slot":`aui_assistant-message-content`,className:`text-foreground px-2 leading-relaxed wrap-break-word`,children:[(0,b.jsx)(uZ.GroupedParts,{groupBy:i,children:({part:i,children:a})=>{switch(i.type){case`group-chainOfThought`:return(0,b.jsx)(`div`,{"data-slot":`aui_chain-of-thought`,children:a});case`group-task`:return r?(0,b.jsx)(r,{group:i}):null;case`group-tool`:return t?(0,b.jsx)(t,{group:i,children:a}):(0,b.jsxs)(H2,{variant:`ghost`,children:[(0,b.jsx)(U2,{count:i.indices.length,active:i.status.type===`running`}),(0,b.jsx)(W2,{children:a})]});case`group-reasoning`:{if(n)return(0,b.jsx)(n,{group:i,children:a});let e=i.status.type===`running`;return(0,b.jsxs)(f2,{streaming:e,children:[(0,b.jsx)(l2,{active:e}),(0,b.jsx)(u2,{"aria-busy":e,children:(0,b.jsx)(d2,{children:a})})]})}case`text`:return(0,b.jsx)(e2,{});case`reasoning`:return(0,b.jsx)(h2,{...i});case`tool-call`:return i.toolUI??(0,b.jsx)(e,{...i});case`data`:return i.dataRendererUI;case`file`:return(0,b.jsx)(`div`,{"data-slot":`aui_assistant-message-file`,className:`py-1`,children:(0,b.jsx)(n0,{...i})});case`image`:return(0,b.jsx)(`div`,{"data-slot":`aui_assistant-message-image`,className:`py-1`,children:(0,b.jsx)(y0,{...i})});case`indicator`:return(0,b.jsx)(`span`,{"data-slot":`aui_assistant-message-indicator`,className:`animate-pulse font-sans`,"aria-label":`Assistant is working`,children:`●`});default:return null}}}),(0,b.jsx)(m4,{})]}),(0,b.jsxs)(`div`,{"data-slot":`aui_assistant-message-footer`,className:a(`ms-2 flex items-center`,`min-h-7.5 pt-1.5`),children:[(0,b.jsx)(S4,{}),(0,b.jsx)(g4,{})]})]})},g4=()=>(0,b.jsxs)(kq.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-assistant-action-bar-root text-muted-foreground animate-in fade-in col-start-3 row-start-2 -ms-1 flex gap-1 duration-200`,children:[(0,b.jsx)(kq.Copy,{asChild:!0,children:(0,b.jsxs)(D1,{tooltip:`Copy`,children:[(0,b.jsx)(XL,{condition:e=>e.message.isCopied,children:(0,b.jsx)(Cf,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,b.jsx)(XL,{condition:e=>!e.message.isCopied,children:(0,b.jsx)(Nf,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})}),(0,b.jsxs)(XL,{condition:e=>e.thread.capabilities.feedback,children:[(0,b.jsx)(kq.FeedbackPositive,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,b.jsx)(mp,{})})}),(0,b.jsx)(kq.FeedbackNegative,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Not helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,b.jsx)(pp,{})})})]}),(0,b.jsx)(kq.Reload,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Refresh`,children:(0,b.jsx)(np,{})})}),(0,b.jsxs)(Bq.Root,{children:[(0,b.jsx)(Bq.Trigger,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`More`,className:`data-[state=open]:bg-accent`,children:(0,b.jsx)(If,{})})}),(0,b.jsx)(Bq.Content,{side:`bottom`,align:`start`,sideOffset:6,className:`aui-action-bar-more-content bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-[8rem] overflow-hidden rounded-xl border p-1.5`,children:(0,b.jsx)(kq.ExportMarkdown,{asChild:!0,children:(0,b.jsxs)(Bq.Item,{className:`aui-action-bar-more-item hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(Ff,{className:`size-4`}),`Export as Markdown`]})})})]})]}),_4=e=>(0,b.jsx)(`div`,{"data-slot":`aui_user-message-file`,className:`py-1`,children:(0,b.jsx)(n0,{...e})}),v4=e=>(0,b.jsx)(`div`,{"data-slot":`aui_user-message-image`,className:`py-1`,children:(0,b.jsx)(y0,{...e})}),y4=()=>(0,b.jsxs)(uZ.Root,{"data-slot":`aui_user-message-root`,className:`fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto] [&:where(>*)]:col-start-2`,"data-role":`user`,children:[(0,b.jsx)(V1,{}),(0,b.jsxs)(`div`,{className:`aui-user-message-content-wrapper relative col-start-2 min-w-0`,children:[(0,b.jsx)(`div`,{className:`aui-user-message-content peer bg-muted text-foreground rounded-(--composer-radius) px-4 py-2 wrap-break-word empty:hidden`,children:(0,b.jsx)(uZ.Parts,{components:{File:_4,Image:v4}})}),(0,b.jsx)(`div`,{className:`aui-user-action-bar-wrapper absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-2 peer-empty:hidden rtl:translate-x-full`,children:(0,b.jsx)(b4,{})})]}),(0,b.jsx)(S4,{"data-slot":`aui_user-branch-picker`,className:`col-span-full col-start-1 -me-1 justify-end`})]}),b4=()=>(0,b.jsx)(kq.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-user-action-bar-root flex flex-col items-end`,children:(0,b.jsx)(kq.Edit,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Edit`,className:`aui-user-action-edit`,children:(0,b.jsx)(Qf,{})})})}),x4=()=>(0,b.jsx)(uZ.Root,{"data-slot":`aui_edit-composer-wrapper`,className:`flex flex-col px-2 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:(0,b.jsxs)(QY.Root,{className:`aui-edit-composer-root border-foreground/10 focus-within:border-foreground/25 ms-auto flex w-full max-w-[85%] cursor-text flex-col rounded-(--composer-radius) border bg-(--composer-bg) transition-[border-color]`,children:[(0,b.jsx)(QY.Input,{className:`aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none`,autoFocus:!0}),(0,b.jsxs)(`div`,{className:`aui-edit-composer-footer mx-2.5 mb-2.5 flex items-center gap-1.5 self-end`,children:[(0,b.jsx)(QY.Cancel,{asChild:!0,children:(0,b.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-8 px-3`,children:`Cancel`})}),(0,b.jsx)(QY.Send,{asChild:!0,children:(0,b.jsx)(o,{size:`sm`,className:`h-8 px-3`,children:`Update`})})]})]})}),S4=({className:e,...t})=>(0,b.jsxs)(rJ.Root,{hideWhenSingleBranch:!0,className:a(`aui-branch-picker-root text-muted-foreground -ms-2 me-2 inline-flex items-center text-xs`,e),...t,children:[(0,b.jsx)(rJ.Previous,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Previous`,children:(0,b.jsx)(Tf,{})})}),(0,b.jsxs)(`span`,{className:`aui-branch-picker-state font-medium`,children:[(0,b.jsx)(rJ.Number,{}),` / `,(0,b.jsx)(rJ.Count,{})]}),(0,b.jsx)(rJ.Next,{asChild:!0,children:(0,b.jsx)(D1,{tooltip:`Next`,children:(0,b.jsx)(Ef,{})})})]}),C4=()=>{let[e,t]=(0,y.useState)(``),n=$(e=>e.threads.threadIds.length>0);return(0,b.jsxs)(T4,{children:[(0,b.jsx)(M4,{}),n&&(0,b.jsx)(w4,{value:e,onValueChange:t}),(0,b.jsx)(E4,{searchQuery:n?e:``})]})},w4=(0,y.forwardRef)(({className:e,value:t,onValueChange:n,...r},i)=>(0,b.jsxs)(`div`,{"data-slot":`aui_thread-list-search`,className:`relative px-0.5 py-1`,children:[(0,b.jsx)(ip,{"data-slot":`aui_thread-list-search-icon`,className:`text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2`}),(0,b.jsx)(p,{ref:i,type:`search`,value:t,onChange:e=>n(e.target.value),"aria-label":`Search threads`,placeholder:`Search threads`,className:a(`h-8 ps-8 text-sm`,e),...r})]}));w4.displayName=`ThreadListSearch`;var T4=({className:e,...t})=>(0,b.jsx)(fQ.Root,{"data-slot":`aui_thread-list-root`,className:a(`flex flex-col gap-0.5`,e),...t}),E4=({className:e,searchQuery:t=``,...n})=>(0,b.jsxs)(`div`,{"data-slot":`aui_thread-list-items`,className:a(`flex flex-col gap-0.5`,e),...n,children:[(0,b.jsx)(XL,{condition:e=>e.threads.isLoading,children:(0,b.jsx)(N4,{})}),(0,b.jsx)(XL,{condition:e=>!e.threads.isLoading,children:(0,b.jsx)(A4,{searchQuery:t})})]}),D4=864e5,O4=(e,t)=>!e||e.getTime()>=t?`Today`:e.getTime()>=t-D4?`Yesterday`:`Earlier`,k4=(e=``)=>{let t=$(e=>e.threads.threadIds),n=$(e=>e.threads.threadItems),r=e.trim().toLowerCase();return(0,y.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e])),i=t=>!r||(e.get(t)?.title||`New Chat`).toLowerCase().includes(r),a=t=>e.get(t)?.status===`archived`,o=t.map(t=>e.get(t)?.lastMessageAt),s=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&!a(e)).map(({index:e})=>e),c=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&a(e)).map(({index:e})=>e);if(!s.some(e=>o[e]))return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:null};let l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),d=e=>o[e]?.getTime()??2**53-1,f=[...s].sort((e,t)=>d(t)-d(e)),p=[];for(let e of f){let t=O4(o[e],u),n=p[p.length-1];n?.label===t?n.indices.push(e):p.push({label:t,indices:[e]})}return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:p}},[t,n,r])},A4=({searchQuery:e=``})=>{let{threadIds:t,filteredIndices:n,archivedIndices:r,groups:i}=k4(e);return e.trim()&&n.length===0&&r.length===0?(0,b.jsx)(`div`,{"data-slot":`aui_thread-list-empty`,className:`text-muted-foreground px-2.5 py-4 text-sm`,children:`No threads found`}):i?(0,b.jsxs)(b.Fragment,{children:[i.map(e=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:e.label}),e.indices.map(e=>(0,b.jsx)(fQ.ItemByIndex,{index:e,components:{ThreadListItem:P4}},t[e]))]},e.label)),(0,b.jsx)(j4,{threadIds:t,indices:r})]}):(0,b.jsxs)(b.Fragment,{children:[n.map(e=>(0,b.jsx)(fQ.ItemByIndex,{index:e,components:{ThreadListItem:P4}},t[e])),(0,b.jsx)(j4,{threadIds:t,indices:r})]})},j4=({threadIds:e,indices:t})=>t.length?(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:`Archived`}),t.map(t=>(0,b.jsx)(fQ.ItemByIndex,{index:t,components:{ThreadListItem:P4}},e[t]))]}):null,M4=(0,y.forwardRef)(({className:e,labelClassName:t,children:n,...r},i)=>(0,b.jsx)(fQ.New,{asChild:!0,children:(0,b.jsx)(o,{ref:i,variant:`ghost`,"data-slot":`aui_thread-list-new`,className:a(`hover:bg-muted data-active:bg-muted h-8 justify-start gap-2 rounded-md px-2.5 text-sm font-normal`,e),...r,children:n??(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(tp,{"data-slot":`aui_thread-list-new-icon`,className:`size-4 shrink-0`}),(0,b.jsx)(`span`,{"data-slot":`aui_thread-list-new-label`,className:a(`whitespace-nowrap`,t),children:`New Thread`})]})})}));M4.displayName=`ThreadListNew`;var N4=()=>(0,b.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:Array.from({length:5},(e,t)=>(0,b.jsx)(`div`,{role:`status`,"aria-label":`Loading threads`,"data-slot":`aui_thread-list-skeleton-wrapper`,className:`flex h-8 items-center px-2.5`,children:(0,b.jsx)(K2,{"data-slot":`aui_thread-list-skeleton`,className:`h-3.5 w-full`})},t))}),P4=()=>{let e=$(e=>e.threadListItem.isRunning),t=$(e=>e.threadListItem.status)===`archived`,[n,r]=(0,y.useState)(!1),i=(0,y.useRef)(null),o=(0,y.useRef)(!1);return(0,y.useEffect)(()=>{!n&&o.current&&(o.current=!1,i.current?.focus())},[n]),(0,b.jsxs)(yQ.Root,{"data-slot":`aui_thread-list-item`,"data-archived":t||void 0,className:a(`group hover:bg-muted focus-visible:bg-muted data-active:bg-muted has-focus-visible:bg-muted has-data-[state=open]:bg-muted relative flex h-8 items-center rounded-md transition-colors focus-visible:outline-none`,t&&`opacity-60`),children:[n?(0,b.jsx)(F4,{onDone:e=>{o.current=e,r(!1)}}):(0,b.jsxs)(yQ.Trigger,{ref:i,"data-slot":`aui_thread-list-item-trigger`,className:`focus-visible:ring-ring/50 flex h-full min-w-0 flex-1 items-center rounded-md px-2.5 text-start text-sm outline-none group-hover:pe-9 group-has-focus-visible:pe-9 group-has-data-[state=open]:pe-9 group-data-active:pe-9 focus-visible:ring-1`,children:[e&&(0,b.jsx)(qf,{"aria-hidden":!0,"data-slot":`aui_thread-list-item-running`,className:`text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin`}),(0,b.jsx)(`span`,{"data-slot":`aui_thread-list-item-title`,className:`min-w-0 flex-1 truncate`,children:(0,b.jsx)(yQ.Title,{fallback:`New Chat`})}),e&&(0,b.jsx)(`span`,{className:`sr-only`,children:`Running`})]}),(0,b.jsx)(I4,{archived:t,onRename:()=>r(!0)})]})},F4=({onDone:e})=>{let t=Q(),n=$(e=>e.threadListItem.title)??``,[r,i]=(0,y.useState)(n),a=(0,y.useRef)(null),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0;let s=r.trim();if(!s||s===n){e(i);return}Promise.resolve().then(()=>t.threadListItem.rename(s)).then(()=>e(i),()=>{o.current=!1,i&&a.current?.focus()})},c=()=>{o.current||(o.current=!0,e(!0))};return(0,b.jsx)(p,{ref:a,autoFocus:!0,"data-slot":`aui_thread-list-item-rename`,"aria-label":`Rename thread`,value:r,className:`h-7 min-w-0 flex-1 ps-2.5 pe-9 text-sm`,onChange:e=>i(e.target.value),onBlur:()=>s(!1),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s(!0)):e.key===`Escape`&&(e.preventDefault(),c())}})},I4=({archived:e,onRename:t})=>(0,b.jsxs)(AQ.Root,{sharedFocusGroup:!0,children:[(0,b.jsx)(AQ.Trigger,{asChild:!0,children:(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,"data-slot":`aui_thread-list-item-more`,className:`data-[state=open]:bg-accent absolute end-1.5 top-1/2 size-6 -translate-y-1/2 p-0 opacity-0 group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 data-[state=open]:opacity-100`,children:[(0,b.jsx)(If,{className:`size-3.5`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`More options`})]})}),(0,b.jsxs)(AQ.Content,{side:`right`,align:`start`,sideOffset:6,"data-slot":`aui_thread-list-item-more-content`,className:`bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out 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 min-w-32 overflow-hidden rounded-xl border p-1.5`,children:[(0,b.jsxs)(AQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,onSelect:t,children:[(0,b.jsx)(Qf,{className:`size-4`}),`Rename`]}),e?(0,b.jsx)(yQ.Unarchive,{asChild:!0,children:(0,b.jsxs)(AQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(mf,{className:`size-4`}),`Unarchive`]})}):(0,b.jsx)(yQ.Archive,{asChild:!0,children:(0,b.jsxs)(AQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(hf,{className:`size-4`}),`Archive`]})}),(0,b.jsx)(yQ.Delete,{asChild:!0,children:(0,b.jsxs)(AQ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive focus:bg-destructive/10 focus:text-destructive flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,b.jsx)(hp,{className:`size-4`}),`Delete`]})})]})]}),L4=`bg-background border border-border/60 dark:bg-popover`;function R4({phase:e,attempt:t,resumedTokens:n,onRetry:r,className:i,...o}){return e===`online`?null:(0,b.jsxs)(`div`,{"data-slot":`connection-state`,className:a(L4,`fade-in slide-in-from-top-1 animate-in flex w-full max-w-sm items-center gap-2.5 rounded-2xl px-3.5 py-2.5 duration-300`,i),...o,children:[e===`dropped`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Mf,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Connection lost. The run kept going on the server.`}),(0,b.jsx)(`button`,{type:`button`,onClick:r,className:`text-foreground/70 hover:bg-foreground/[0.06] hover:text-foreground/95 shrink-0 rounded-full px-2.5 py-1 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]`,children:`Reconnect`})]}),e===`reconnecting`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(qf,{className:`text-foreground/40 size-3.5 shrink-0 animate-spin motion-reduce:animate-none`}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Reconnecting`}),t!==void 0&&(0,b.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`attempt `,t]})]}),e===`resumed`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Cf,{className:`size-3.5 shrink-0 text-emerald-500`}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Picked the stream back up.`}),n!==void 0&&(0,b.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`+`,n,` tokens`]})]})]})}var z4=[`pending`,`testing`,`confirmed`,`rejected`,`blocked`],B4=H(z4),V4=V({tasks:B(V({id:R(),title:R(),status:B4.default(`pending`),note:R().optional()})),target:R().optional(),phase:R().optional()}),H4={tasks:[]};function U4(e){return typeof e==`string`&&z4.includes(e)}function W4(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[^a-z_-]/g,``);if(t===`pending`||t===`todo`||t===`hypothesis`||t===`planned`||t===`open`)return`pending`;if(t===`testing`||t===`in_progress`||t===`inprogress`||t===`active`||t===`probing`)return`testing`;if(t===`confirmed`||t===`verified`||t===`exploited`||t===`vulnerable`||t===`success`)return`confirmed`;if(t===`rejected`||t===`tested_safe`||t===`testedsafe`||t===`safe`||t===`clean`||t===`not_vulnerable`||t===`notvulnerable`||t===`invalid`)return`rejected`;if(t===`blocked`||t===`justified_blocked`||t===`justifiedblocked`||t===`needs_auth`||t===`needsauth`||t===`untestable`)return`blocked`}var G4=/https?:\/\/[^\s<>")']+/i,K4=/\b(?:[a-z0-9-]+\.)+[a-z]{2,}\b/i;function q4(e){if(!e||typeof e!=`string`)return null;let t=e.match(G4);if(t?.[0]){let e=t[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<512)return e}let n=e.match(K4);if(n?.[0]){let e=n[0].trim().replace(/[),.!?;:]$/,``);if(e.length>0&&e.length<256&&!e.endsWith(`.ts`)&&!e.endsWith(`.js`)&&!e.endsWith(`.json`)&&!e.endsWith(`.md`)&&!e.endsWith(`.html`)&&!e.endsWith(`.txt`))return e}return null}function J4(e){let t=0;for(let n of e){let e=n.id.match(/^T-(\d+)$/i);e&&(t=Math.max(t,Number.parseInt(e[1],10)))}return`T-${t+1}`}function Y4(e,t){let n=new Map;for(let t of e)n.set(t.id,{...t});for(let e of t){let t=n.get(e.id);t?n.set(e.id,{id:e.id,title:e.title||t.title,status:e.status||t.status,note:e.note===void 0?t.note:e.note}):n.set(e.id,{...e})}return Array.from(n.values())}var X4=/-\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([A-Za-z0-9_-]+):\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,Z4=/Task\s+([A-Za-z0-9_-]+)\s+(?:added|updated):\s*\[(pending|testing|confirmed|rejected|blocked)\]\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gim,Q4=/<kifaru_dossier\s+target="([^"]+)"(?:\s+phase="([^"]+)")?/i;function $4(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=e.split(/\r?\n/);for(let e of i){let t=e.trim();if(!t.startsWith(`|`)||!t.endsWith(`|`))continue;let i=t.split(`|`).map(e=>e.trim()),a=i.filter((e,t)=>t>0&&t<i.length-1);if(a.length<2||a.every(e=>/^[-:=|\s]+$/.test(e)))continue;let o=W4(a[1]),s=a[0],c=a[2];if(o||(o=W4(a[0]),o&&(s=a[1],c=a[2])),!o||!s||(s=s.replace(/^[`*_\s]+|[`*_\s]+$/g,``).trim(),!s||s.toLowerCase()===`cell`||s.toLowerCase()===`task`))continue;let l,u=s.match(/^(T-\d+)[:\s—-]+(.*)$/i);u?.[1]&&(l=u[1].toUpperCase(),s=u[2].trim());let d=s.toLowerCase(),f=r.get(d);if(f)f.status=o,c&&(f.note=c.trim());else{let e={id:l||J4(n),title:s,status:o,note:c?c.trim():void 0};n.push(e),r.set(d,e)}}return n}function e3(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);let i=/^\s*[-*]\s*\[([ xX/!?-])\]\s*(?:([A-Za-z0-9_-]+):)?\s*([^—\n\r]+?)(?:\s*—\s*([^\n\r]+))?$/gm,a;for(;(a=i.exec(e))!==null;){let[,e,t,i,o]=a;if(!i)continue;let s=`pending`;e===`x`||e===`X`?s=`confirmed`:e===`/`?s=`testing`:e===`!`?s=`blocked`:(e===`-`||e===`?`)&&(s=`rejected`);let c=i.trim(),l=c.toLowerCase(),u=r.get(l);if(u)u.status=s,o&&(u.note=o.trim());else{let e={id:t?.startsWith(`T-`)?t.toUpperCase():J4(n),title:c,status:s,note:o?o.trim():void 0};n.push(e),r.set(l,e)}}return n}function t3(e,t=[]){let n=[...t],r=new Map;for(let e of n)r.set(e.title.trim().toLowerCase(),e);for(let t of e){let e=typeof t==`string`?t:typeof t==`object`&&t&&`note`in t?String(t.note??``):``;if(!e)continue;let i,a,o;if(/^CONFIRMED(\([^)]+\))?:/i.test(e)){i=`confirmed`;let t=e.replace(/^CONFIRMED(\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`.`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():void 0}else if(/BLOCKED/i.test(e)&&(/coverage gap/i.test(e)||/needs auth/i.test(e))){i=`blocked`;let t=e.replace(/^Coverage gap(\s*\([^)]+\))?:\s*/i,``).trim(),n=t.indexOf(`—`);a=(n>0&&n<120?t.slice(0,n):t.slice(0,120)).trim(),o=n>0?t.slice(n+1).trim():t}if(i&&a){let e=a.toLowerCase(),t=r.get(e);if(t)t.status=i,o&&(t.note=o);else{let t={id:J4(n),title:a,status:i,note:o};n.push(t),r.set(e,t)}}}return n}function n3(e){let t=[],n,r;for(let i of e){if(i.role===`user`){let e=``;if(typeof i.content==`string`)e=i.content;else if(Array.isArray(i.content))for(let t of i.content)typeof t==`object`&&t&&`type`in t&&t.type===`text`&&(e+=` ${t.text??``}`);let t=q4(e);t&&(n=t)}if(i.role===`custom`&&i.customType===`kifaru-dossier`){let e=typeof i.content==`string`?i.content:``,a=e.match(/Bound target:\s*([^\n\r]+)/i)||e.match(/Session bound to target\s*([^\n\r.]+)/i);a?.[1]&&(n=a[1].trim());let o=e.match(/Phase:\s*([a-zA-Z0-9_-]+)/i);o?.[1]&&(r=o[1].trim());let s;for(X4.lastIndex=0;(s=X4.exec(e))!==null;){let[,e,n,r,i]=s;n&&r&&U4(e)&&(t=Y4(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}if(i.role===`assistant`&&Array.isArray(i.content)){for(let e of i.content)if(typeof e==`object`&&e&&`type`in e){if(e.type===`text`&&typeof e.text==`string`){let i=e.text,a=q4(i);a&&!n&&(n=a);let o=i.match(Q4);o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),t=$4(i,t),t=e3(i,t)}if(e.type===`tool-call`||e.type===`toolCall`){let i=e,a=i.name??i.toolName,o=i.args??i.arguments;if(a===`kifaru_dossier`&&o&&(typeof o.target==`string`&&o.target.trim()&&(n=o.target.trim()),typeof o.phase==`string`&&o.phase.trim()&&(r=o.phase.trim()),o.action===`task`)){let e=typeof o.taskId==`string`?o.taskId.trim():void 0,n=typeof o.title==`string`?o.title.trim():void 0,r=typeof o.note==`string`?o.note.trim():void 0;e&&(t=Y4(t,[{id:e,title:n||e,status:U4(o.status)?o.status:`pending`,note:r}]))}}}}if(i.role===`toolResult`){let e=i;for(let i of e.content??[])if(i.type===`text`&&i.text){let e=i.text.trim();if(e.startsWith(`{`)&&e.endsWith(`}`))try{let i=JSON.parse(e);if(typeof i.target==`string`&&(n=i.target),typeof i.phase==`string`&&(r=i.phase),Array.isArray(i.tasks)){let e=[];for(let t of i.tasks)typeof t.id==`string`&&typeof t.title==`string`&&e.push({id:t.id,title:t.title,status:U4(t.status)?t.status:`pending`,note:typeof t.note==`string`?t.note:void 0});t=Y4(t,e)}Array.isArray(i.observations)&&(t=t3(i.observations,t))}catch{}t=$4(e,t),t=e3(e,t);let a;for(Z4.lastIndex=0;(a=Z4.exec(e))!==null;){let[,e,n,r,i]=a;e&&r&&U4(n)&&(t=Y4(t,[{id:e.trim(),title:r.trim(),status:n,note:i?i.trim():void 0}]))}let o=e.match(Q4);for(o?.[1]&&(n=o[1].trim()),o?.[2]&&(r=o[2].trim()),X4.lastIndex=0;(a=X4.exec(e))!==null;){let[,e,n,r,i]=a;n&&r&&U4(e)&&(t=Y4(t,[{id:n.trim(),title:r.trim(),status:e,note:i?i.trim():void 0}]))}}}}return{tasks:t,target:n,phase:r}}var r3={pending:jf,testing:qf,confirmed:Cf,rejected:kf,blocked:Df},i3={pending:{badge:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,text:`text-muted-foreground`,ring:`border-border`},testing:{badge:`bg-blue-500/10 text-blue-500 border-blue-500/30 hover:bg-blue-500/20`,text:`text-blue-500`,ring:`border-blue-500/40 bg-blue-500/10`},confirmed:{badge:`bg-emerald-500/10 text-emerald-500 border-emerald-500/30 hover:bg-emerald-500/20`,text:`text-emerald-500`,ring:`border-emerald-500/50 bg-emerald-500/20`},rejected:{badge:`bg-rose-500/10 text-rose-500 border-rose-500/30 hover:bg-rose-500/20`,text:`text-rose-500`,ring:`border-rose-500/40 bg-rose-500/10`},blocked:{badge:`bg-amber-500/10 text-amber-500 border-amber-500/30 hover:bg-amber-500/20`,text:`text-amber-500`,ring:`border-amber-500/40 bg-amber-500/10`}};function a3({className:e=``,onClose:t}){let[n,{setState:r}]=hB(`taskBoard`,{description:`A task board panel for the target dossier tracking hunt theses, tests, and findings. Use update_taskBoard with tasks.add/update/remove/clear to manage tasks. Tasks have id (e.g. T-1), title, status (pending|testing|confirmed|rejected|blocked), and optional note.`,stateSchema:V4,initialState:H4}),i=l1(e=>e.messages),[a,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(`all`),[u,d]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(!i||i.length===0)return;let e=n3(i);(e.tasks.length!==0||e.target||e.phase)&&r(t=>{let n=Y4(t?.tasks??[],e.tasks),r=e.target&&e.target!==t?.target,i=e.phase&&e.phase!==t?.phase,a=n.length!==(t?.tasks?.length??0)||n.some((e,n)=>{let r=t?.tasks?.[n];return!r||r.id!==e.id||r.status!==e.status||r.title!==e.title||r.note!==e.note});return!r&&!i&&!a?t:{...t,tasks:n,target:e.target??t?.target,phase:e.phase??t?.phase}})},[i,r]);let f=n?.target;(0,y.useEffect)(()=>{if(!f)return;let e=!1;return fetch(`/api/v1/workbench/dossier?target=${encodeURIComponent(f)}`).then(e=>e.ok?e.json():null).then(t=>{!e&&t&&Array.isArray(t.tasks)&&t.tasks.length!==0&&r(e=>{let n=Y4(e?.tasks??[],t.tasks??[]),r=t.target&&!e?.target,i=t.phase&&!e?.phase,a=n.length!==(e?.tasks?.length??0)||n.some((t,n)=>{let r=e?.tasks?.[n];return!r||r.id!==t.id||r.status!==t.status||r.title!==t.title});return!r&&!i&&!a?e:{...e,tasks:n,target:e?.target??t.target,phase:e?.phase??t.phase}})}).catch(()=>{}),()=>{e=!0}},[f,r]);let m=n?.tasks??[],h=n?.target,g=n?.phase,_=(0,y.useMemo)(()=>{let e={all:m.length};for(let t of z4)e[t]=0;for(let t of m)e[t.status]=(e[t.status]??0)+1;return e},[m]),v=(0,y.useMemo)(()=>c===`all`?m:m.filter(e=>e.status===c),[m,c]),x=(e,t,n)=>{let r=t||h;r&&fetch(`/api/v1/workbench/dossier`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:r,tasks:e,phase:n||g})}).catch(()=>{})},S=e=>{let t=`pending`;e.status===`pending`?t=`testing`:e.status===`testing`?t=`confirmed`:e.status===`confirmed`?t=`pending`:e.status===`blocked`?t=`testing`:e.status===`rejected`&&(t=`pending`);let n=m.map(n=>n.id===e.id?{...n,status:t}:n);r(e=>({...e,tasks:n})),x(n)},C=(e,t)=>{let n=m.map(n=>n.id===e?{...n,status:t}:n);r(e=>({...e,tasks:n})),x(n)},w=e=>{let t=m.filter(t=>t.id!==e);r(e=>({...e,tasks:t})),x(t)},T=()=>{let e=a.trim();if(!e)return;let t={id:J4(m),title:e,status:`pending`},n=[...m,t];r(e=>({...e,tasks:n})),x(n),s(``),d(!1)};return(0,b.jsxs)(`div`,{className:`flex h-full flex-col bg-card text-card-foreground ${e}`,children:[(0,b.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border px-3.5 py-2.5`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(Kf,{className:`size-4.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,b.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-foreground truncate`,children:`Task Board`}),m.length>0?(0,b.jsx)(oS,{variant:`secondary`,className:`px-1.5 py-0 text-[11px] font-mono font-medium`,children:m.length}):null]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[h?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground bg-muted/60 px-2 py-0.5 rounded-md font-mono truncate max-w-32`,title:`Bound target: ${h}`,children:[(0,b.jsx)(dp,{className:`size-3 text-primary shrink-0`}),(0,b.jsx)(`span`,{className:`truncate`,children:h})]}):null,g?(0,b.jsx)(oS,{variant:`outline`,className:`text-[10px] uppercase font-mono tracking-wider px-1.5 py-0`,children:g}):null,(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground`,onClick:()=>d(e=>!e),title:`Add task`,children:[(0,b.jsx)(tp,{className:`size-4`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Add task`})]}),t?(0,b.jsxs)(o,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground md:hidden`,onClick:t,title:`Close panel`,children:[(0,b.jsx)(kf,{className:`size-4`}),(0,b.jsx)(`span`,{className:`sr-only`,children:`Close panel`})]}):null]})]}),m.length>0?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/60 px-3 py-1.5 text-xs`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>l(`all`),className:`rounded-md px-2 py-0.5 text-xs font-medium transition-colors ${c===`all`?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[`All (`,_.all,`)`]}),z4.map(e=>{let t=_[e]??0;return t===0&&c!==e?null:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-xs capitalize font-medium transition-colors ${c===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,b.jsx)(`span`,{children:e}),(0,b.jsxs)(`span`,{className:`font-mono text-[10px] opacity-70`,children:[`(`,t,`)`]})]},e)})]}):null,u?(0,b.jsxs)(`div`,{className:`border-b border-border/80 bg-muted/30 p-2.5 flex items-center gap-2`,children:[(0,b.jsx)(p,{autoFocus:!0,value:a,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),T()):e.key===`Escape`&&d(!1)},placeholder:`New task thesis (e.g. Test IDOR on /api/user)...`,className:`h-8 text-xs bg-background`}),(0,b.jsx)(o,{size:`sm`,className:`h-8 px-2.5 text-xs shrink-0`,onClick:T,children:`Add`})]}):null,(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-3`,children:m.length===0?(0,b.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center text-center px-4`,children:[(0,b.jsx)(`div`,{className:`flex size-14 items-center justify-center rounded-2xl bg-muted/40 mb-3 border border-border/40`,children:(0,b.jsx)(Kf,{className:`size-8 text-muted-foreground/50`,"aria-hidden":`true`})}),(0,b.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:h?`No tasks yet for ${h}`:`No tasks yet.`}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground max-w-56 leading-relaxed`,children:h?`Analyzing target surface and recording hunt theses...`:`Ask the assistant to add some!`}),(0,b.jsxs)(o,{variant:`outline`,size:`sm`,className:`mt-4 h-7 text-xs gap-1.5 text-muted-foreground hover:text-foreground`,onClick:()=>d(!0),children:[(0,b.jsx)(tp,{className:`size-3.5`}),`Add task`]})]}):v.length===0?(0,b.jsxs)(`div`,{className:`flex h-full min-h-36 flex-col items-center justify-center text-center text-muted-foreground text-xs py-8`,children:[(0,b.jsxs)(`p`,{children:[`No tasks with status "`,c,`".`]}),(0,b.jsx)(o,{variant:`link`,size:`sm`,className:`text-xs mt-1`,onClick:()=>l(`all`),children:`Show all tasks`})]}):(0,b.jsx)(`ul`,{className:`flex flex-col gap-2`,children:v.map(e=>{let t=r3[e.status]??jf,n=i3[e.status]??i3.pending,r=e.status===`confirmed`;return(0,b.jsx)(`li`,{className:`group relative flex flex-col gap-1.5 rounded-lg border border-border/70 bg-card p-2.5 transition-all hover:border-border hover:shadow-xs`,children:(0,b.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>S(e),title:`Status: ${e.status}. Click to cycle.`,"aria-label":`Toggle task status for ${e.title}`,className:`mt-0.5 flex size-4.5 shrink-0 items-center justify-center rounded-md border transition-all ${r?`border-emerald-500 bg-emerald-500 text-white dark:text-black`:n.ring}`,children:r?(0,b.jsx)(Cf,{className:`size-3 stroke-[3]`}):e.status===`testing`?(0,b.jsx)(qf,{className:`size-2.5 animate-spin text-blue-500`}):(0,b.jsx)(`span`,{className:`size-1.5 rounded-full bg-transparent group-hover:bg-muted-foreground/30`})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,b.jsx)(`span`,{className:`font-mono text-[10px] font-semibold text-muted-foreground/80 tracking-wider`,children:e.id}),(0,b.jsxs)(`div`,{className:`relative inline-flex items-center`,children:[(0,b.jsx)(t,{className:`pointer-events-none absolute left-1.5 size-2.5 opacity-70`}),(0,b.jsx)(`select`,{value:e.status,onChange:t=>C(e.id,t.target.value),"aria-label":`Change status for task ${e.id}`,className:`h-4.5 appearance-none rounded border pl-4.5 pr-4 text-[10px] font-medium transition-colors cursor-pointer outline-none ${n.badge}`,children:z4.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))}),(0,b.jsx)(wf,{className:`pointer-events-none absolute right-1 size-2.5 opacity-60`})]})]}),(0,b.jsx)(`p`,{className:`text-xs leading-snug break-words ${r?`text-muted-foreground line-through`:`text-foreground`}`,children:e.title}),e.note?(0,b.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground/90 bg-muted/40 rounded px-1.5 py-0.5 border border-border/40 font-mono`,children:e.note}):null]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>w(e.id),className:`opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded-sm`,title:`Delete task`,"aria-label":`Delete task`,children:(0,b.jsx)(gp,{className:`size-3.5`})})]})},e.id)})})}),m.length>0?(0,b.jsxs)(`footer`,{className:`border-t border-border px-3 py-2 flex items-center justify-between text-[11px] text-muted-foreground bg-muted/20`,children:[(0,b.jsxs)(`span`,{children:[_.confirmed??0,` of `,m.length,` confirmed`]}),(0,b.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-[11px] text-muted-foreground hover:text-destructive`,onClick:()=>r(e=>({...e,tasks:[]})),children:`Clear all`})]}):null]})}function o3({request:e,respond:t}){let[n,r]=(0,y.useState)(e.kind===`editor`?e.prefill??``:``),i=e=>void t(e);return(0,b.jsxs)(`div`,{className:`bg-card grid gap-2 rounded-md border border-l-[3px] border-l-primary p-3`,role:`group`,"aria-label":`The agent is asking for approval`,children:[(0,b.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,b.jsx)(cp,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),e.title]}),e.kind===`confirm`?(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs break-words whitespace-pre-wrap`,children:e.message}):null,e.timeoutMs?(0,b.jsxs)(`p`,{className:`text-muted-foreground text-[0.7rem] tabular-nums`,children:[`Auto-dismisses after `,Math.round(e.timeoutMs/1e3),`s`]}):null,e.kind===`confirm`?(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(o,{size:`sm`,onClick:()=>i({requestId:e.id,confirmed:!0}),children:`Allow`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,confirmed:!1}),children:`Deny`})]}):null,e.kind===`select`?(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.options.map(t=>(0,b.jsx)(o,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,value:t}),children:t},t)),(0,b.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]}):null,e.kind===`input`||e.kind===`editor`?(0,b.jsxs)(`form`,{className:`grid gap-2`,onSubmit:t=>{t.preventDefault(),i({requestId:e.id,value:n})},children:[e.kind===`editor`?(0,b.jsx)(_2,{rows:6,value:n,onChange:e=>r(e.target.value)}):(0,b.jsx)(p,{value:n,placeholder:e.placeholder??``,onChange:e=>r(e.target.value)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,b.jsx)(o,{size:`sm`,type:`submit`,children:`Submit`}),(0,b.jsx)(o,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]})]}):null]})}function s3(){let{requests:e,respond:t}=u1();return e.length===0?null:(0,b.jsx)(`div`,{className:`grid gap-2 border-b px-3 py-2`,children:e.map(e=>(0,b.jsx)(o3,{request:e,respond:t},e.id))})}function c3({className:e,...t}){return(0,b.jsx)(`select`,{"data-slot":`native-select`,className:a(`border-input bg-background text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive h-9 w-full min-w-0 cursor-pointer rounded-md border px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}function l3({title:e,detail:t,action:n,compact:r}){return(0,b.jsxs)(h,{className:`state ${r?`state-compact`:``}`,"aria-live":`polite`,children:[(0,b.jsx)(`div`,{className:`mb-1 grid size-9 place-items-center rounded-full border bg-[var(--accent-soft)] text-primary [&_svg]:size-[18px]`,children:(0,b.jsx)(sp,{"aria-hidden":`true`})}),(0,b.jsx)(`h2`,{children:e}),(0,b.jsx)(`p`,{children:t}),n]})}var u3=`session`,d3=`kifaru:session`,f3={kind:`latest`},p3={kind:`all`};function m3(e){return e.kind===`pinned`?e.id:e.kind===`all`?`all`:null}function h3(e){return e?e===`all`?p3:e===`latest`?f3:{kind:`pinned`,id:e}:f3}function g3(e,t){return h3(new URLSearchParams(e).get(u3)||t)}function _3(e,t){if(e.kind!==`all`)return e.kind===`pinned`?e.id:t?.[0]?.id}function v3(e,t){if(e.kind!==`latest`)return null;let n=t?.[0]?.id;return n?{kind:`pinned`,id:n}:null}function y3(e){return e?.source===`web`}function b3(e,t){if(e.kind===`all`)return{kind:`fresh`};if(e.kind===`pinned`){let n=t?.find(t=>t.id===e.id);return n&&!y3(n)?{kind:`external`,session:n}:{kind:`thread`,threadId:e.id}}if(!t)return{kind:`loading`};let n=t[0];return n?y3(n)?{kind:`thread`,threadId:n.id}:{kind:`external`,session:n}:{kind:`fresh`}}function x3(e,t){return!(!t||e.kind===`all`||e.kind===`pinned`&&e.id===t)}function S3(){if(typeof window>`u`)return f3;let e=null;try{e=window.localStorage.getItem(d3)}catch{}return g3(window.location.search,e)}function C3(e){if(typeof window>`u`)return;let t=m3(e);try{t?window.localStorage.setItem(d3,t):window.localStorage.removeItem(d3)}catch{}let n=new URL(window.location.href);t?n.searchParams.set(u3,t):n.searchParams.delete(u3),n.toString()!==window.location.href&&window.history.replaceState({},``,n.toString())}var w3=NK((e,t)=>({selection:S3(),select:t=>{C3(t),e({selection:t})},resolveLatest:n=>{let r=v3(t().selection,n);r&&(C3(r),e({selection:r}))}}));if(typeof window<`u`){let e=()=>C3(w3.getState().selection);e(),document.addEventListener(`astro:page-load`,e)}var T3=6e4,E3=500,D3=1e4,O3=100,k3=new Set([`listThreads`,`getThread`,`getAvailableModels`]),A3=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchTransportError`}},j3=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchRpcError`}};function M3(){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/api/v1/workbench/ws`}function N3(e={}){let t=e.url??M3(),n=new Map,r=new Map,i=null,a=0,o,s=!1,c=!1,l=0;function u(t){e.onStatusChange?.(t)}function d(t){e.onError?.(t instanceof Error?t:Error(String(t)))}function f(e,t){let r=n.get(e);r&&(n.delete(e),clearTimeout(r.timer),r.reject(t))}function p(e,t=!1){return e.phase===`sent`?new A3(`OUTCOME_UNKNOWN`,`Confirmation for ${e.frame.method} was lost. The request may have been accepted. Reconnect and check the thread before retrying.`):new A3(t?`TIMEOUT_NOT_SENT`:`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`)}function m(e){if(i&&i.readyState===WebSocket.OPEN&&n.has(e.frame.id))try{i.send(JSON.stringify(e.frame)),e.phase=`sent`}catch{f(e.frame.id,new A3(`SEND_FAILED`,`The request could not be sent.`))}}function h(e){if(i&&i.readyState===WebSocket.OPEN)try{i.send(JSON.stringify(e))}catch(e){d(e),i.close()}}function g(){if(s||o!==void 0)return;let t=Math.min((e.reconnectBaseMs??E3)*2**a,D3);a+=1,o=setTimeout(()=>{o=void 0,_()},t)}function _(){if(s||i)return;u(`connecting`);let o;try{o=e.createSocket?.(t)??new WebSocket(t)}catch(e){d(e),u(`closed`),g();return}i=o,o.onopen=()=>{if(!(s||i!==o)){a=0;for(let[e,t]of r)h({kind:`subscribe`,threadId:e,includeSnapshot:c||t.includeSnapshot});c=!0;for(let e of n.values())e.phase===`queued`&&m(e);u(`open`)}},o.onmessage=e=>{if(s||i!==o)return;let t;try{t=L3(JSON.parse(String(e.data)))}catch{d(new A3(`INVALID_SERVER_FRAME`,`The workspace sent an invalid response. Reconnecting.`)),o.close();return}if(t.kind===`event`){let e=t.event,n=r.get(e.threadId)?.listeners;for(let t of[...n??[]])try{t(e)}catch(e){d(e)}return}let a=n.get(t.id);if(a){if(t.kind===`rpc_error`){f(t.id,new j3(t.code,t.message));return}if(!R3(a.frame.method,t.result)){f(t.id,new A3(`INVALID_SERVER_FRAME`,`The workspace returned an invalid result.`));return}n.delete(t.id),clearTimeout(a.timer),a.resolve(t.result===null?void 0:t.result)}},o.onerror=()=>{},o.onclose=()=>{if(!(s||i!==o)){i=null;for(let[e,t]of n)f(e,p(t));u(`closed`),g()}}}function v(t,r){if(s)return Promise.reject(new A3(`DISPOSED`,`The workspace connection was closed.`));if(!k3.has(t)&&i?.readyState!==WebSocket.OPEN)return Promise.reject(new A3(`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`));if(n.size>=O3)return Promise.reject(new A3(`TOO_MANY_REQUESTS`,`Too many workspace requests are pending.`));let a=`rpc-${l++}`;return new Promise((i,o)=>{let s=setTimeout(()=>{let e=n.get(a);e&&f(a,p(e,!0))},e.requestTimeoutMs??T3),c={frame:{kind:`rpc`,id:a,method:t,params:r},phase:`queued`,resolve:i,reject:o,timer:s};n.set(a,c),m(c)})}return _(),{dispose(){if(!s){s=!0,o&&clearTimeout(o),o=void 0,r.clear();for(let e of n.keys())f(e,new A3(`DISPOSED`,`The workspace connection was closed.`));i&&(i.onopen=null,i.onmessage=null,i.onclose=null,i.onerror=null,i.close()),i=null}},listThreads:e=>v(`listThreads`,e?[e]:[]),createThread:e=>v(`createThread`,e?[e]:[]),getThread:e=>v(`getThread`,[e]),sendMessage:(e,t)=>v(`sendMessage`,[e,t]),cancelRun:e=>v(`cancelRun`,[e]),clearQueue:e=>v(`clearQueue`,[e]),getAvailableModels:e=>v(`getAvailableModels`,e?[e]:[]),setModel:(e,t)=>v(`setModel`,[e,t]),setThinkingLevel:(e,t)=>v(`setThinkingLevel`,[e,t]),renameThread:(e,t)=>v(`renameThread`,[e,t]),archiveThread:e=>v(`archiveThread`,[e]),unarchiveThread:e=>v(`unarchiveThread`,[e]),deleteThread:e=>v(`deleteThread`,[e]),respondToHostUiRequest:(e,t)=>v(`respondToHostUiRequest`,[e,t]),subscribe(e,t,n){if(s)return()=>{};let a=e=>t(e),o=r.get(e);return o?(o.listeners.add(a),n?.includeSnapshot!==!1&&(o.includeSnapshot=!0,i?.readyState===WebSocket.OPEN&&h({kind:`subscribe`,threadId:e,includeSnapshot:!0}))):(o={listeners:new Set,includeSnapshot:n?.includeSnapshot!==!1},r.set(e,o),o.listeners.add(a),h({kind:`subscribe`,threadId:e,includeSnapshot:o.includeSnapshot})),()=>{let t=r.get(e);t&&t.listeners.delete(a)&&t.listeners.size===0&&(r.delete(e),h({kind:`unsubscribe`,threadId:e}))}}}}function P3(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F3(e){return P3(e)&&typeof e.id==`string`&&[`idle`,`running`,`failed`].includes(String(e.status))}function I3(e){return P3(e)&&F3(e.metadata)&&Array.isArray(e.messages)}function L3(e){if(!P3(e))throw Error(`Invalid frame`);if(e.kind===`event`){let t=e.event;if(P3(t)&&typeof t.type==`string`&&typeof t.threadId==`string`&&Number.isSafeInteger(t.seq)&&Number(t.seq)>=0&&(t.type!==`snapshot`||I3(t.snapshot)))return e}else if(typeof e.id==`string`&&(e.kind===`rpc_ok`&&`result`in e||e.kind===`rpc_error`&&typeof e.message==`string`&&typeof e.code==`string`))return e;throw Error(`Invalid frame`)}function R3(e,t){switch(e){case`listThreads`:return Array.isArray(t)&&t.every(F3);case`getThread`:case`createThread`:return I3(t);case`getAvailableModels`:return Array.isArray(t)&&t.every(e=>P3(e)&&typeof e.provider==`string`&&typeof e.modelId==`string`);case`clearQueue`:return P3(t)&&Array.isArray(t.steering)&&t.steering.every(e=>typeof e==`string`)&&Array.isArray(t.followUp)&&t.followUp.every(e=>typeof e==`string`);default:return t===null}}async function z3(){try{let e=await fetch(`/api/v1/workbench/status`,{credentials:`same-origin`});return e.status===401||e.status===403?`unauthenticated`:e.ok?(await e.json()).enabled?`up`:`unconfigured`:`down`}catch{return`down`}}var B3={connecting:`reconnecting`,open:`online`,closed:`dropped`};function V3(){let{compaction:e,retry:t,contextUsage:n,readiness:r}=s1(),i=r&&r.state!==`ready`?r:null;return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?(0,b.jsx)(oS,{variant:`high`,children:i.message}):null,e.active?(0,b.jsx)(oS,{variant:`secondary`,children:`Compacting context…`}):null,t.active?(0,b.jsxs)(oS,{variant:`high`,children:[`Retrying (attempt `,t.attempt,`)`]}):null,n?.percent==null?null:(0,b.jsxs)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,title:`${n.tokens??`?`} / ${n.contextWindow} tokens`,children:[Math.round(n.percent),`% context`]})]})}var H3=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function U3({client:e}){let t=c1(),n=$(e=>e.threadListItem),r=n?n.externalId??n.remoteId??n.id:null,[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)(null);(0,y.useEffect)(()=>{let t=!1;return e.getAvailableModels().then(e=>{t||a(e)},()=>{}),()=>{t=!0}},[e]);let c=t?.status===`running`,l=t?.config,u=l?.provider&&l.modelId?`${l.provider}/${l.modelId}`:``,d=l?.thinkingLevel??``,f=async e=>{s(null);try{await e()}catch(e){s(e instanceof Error?e.message:String(e))}};return r?(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.length>0?(0,b.jsxs)(c3,{"aria-label":`Model`,title:`Model for this conversation`,value:u,disabled:c,onChange:t=>{let[n,...i]=t.target.value.split(`/`),a=i.join(`/`);n&&a&&f(()=>e.setModel(r,{provider:n,modelId:a}))},className:`h-7 w-auto max-w-44 text-xs`,children:[!u||i.every(e=>`${e.provider}/${e.modelId}`!==u)?(0,b.jsx)(`option`,{value:u,children:u||`Select a model`}):null,i.map(e=>(0,b.jsx)(`option`,{value:`${e.provider}/${e.modelId}`,children:e.name},`${e.provider}/${e.modelId}`))]}):null,(0,b.jsxs)(c3,{"aria-label":`Thinking level`,title:`Thinking level for this conversation`,value:d,disabled:c,onChange:t=>{let n=t.target.value;f(()=>e.setThinkingLevel(r,n))},className:`h-7 w-auto text-xs`,children:[(0,b.jsx)(`option`,{value:``,children:`Thinking…`}),H3.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}),o?(0,b.jsx)(`span`,{className:`text-destructive max-w-64 truncate text-xs`,title:o,children:o}):null]}):null}function W3({status:e,client:t,showTaskBoard:n,onToggleTaskBoard:r}){let i=c1();return(0,b.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`strong`,{className:`truncate text-sm font-semibold`,children:i?.title??`Live Workspace`}),i?.status===`running`?(0,b.jsx)(oS,{variant:`low`,children:`streaming`}):null]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(V3,{}),(0,b.jsx)(U3,{client:t}),e===`open`?null:(0,b.jsx)(R4,{phase:B3[e]}),(0,b.jsxs)(o,{variant:n?`secondary`:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:r,title:`Toggle Dossier Task Board`,"aria-label":`Toggle Dossier Task Board`,children:[(0,b.jsx)(Kf,{className:`size-3.5`}),(0,b.jsx)(`span`,{className:`hidden sm:inline`,children:`Tasks`})]})]})]})}function G3({initialThreadId:e}){let[t,n]=(0,y.useState)(`connecting`),[r,i]=(0,y.useState)(!0),o=(0,y.useMemo)(()=>N3({onStatusChange:n}),[]);(0,y.useEffect)(()=>()=>o.dispose(),[o]);let s=o1({client:o,includeArchived:!0,...e===void 0?{}:{initialThreadId:e},onThreadIdChange:e=>{let{selection:t,select:n}=w3.getState();e&&x3(t,e)&&n({kind:`pinned`,id:e})}}),c=(0,y.useMemo)(()=>GP({unstable_interactables:oV()}),[]);return(0,b.jsx)(BK,{runtime:s,config:c,children:(0,b.jsxs)(`div`,{className:a(`grid h-[var(--workspace-height)] min-h-120 grid-cols-1 gap-4`,r?`xl:grid-cols-[minmax(0,16rem)_minmax(0,1fr)_minmax(0,21rem)] md:grid-cols-[minmax(0,1fr)_minmax(0,20rem)]`:`md:grid-cols-[minmax(0,17rem)_minmax(0,1fr)]`),children:[(0,b.jsx)(h,{className:a(`min-h-0 overflow-hidden p-0`,r?`hidden xl:flex`:`hidden md:flex`),children:(0,b.jsx)(C4,{})}),(0,b.jsxs)(h,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:[(0,b.jsx)(W3,{status:t,client:o,showTaskBoard:r,onToggleTaskBoard:()=>i(e=>!e)}),(0,b.jsx)(s3,{}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,b.jsx)(t4,{})})]}),r?(0,b.jsx)(h,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:(0,b.jsx)(a3,{onClose:()=>i(!1)})}):null]})})}function K3({session:e,onStartChat:t}){return(0,b.jsxs)(h,{className:`mx-auto max-w-lg items-start gap-3 p-6`,children:[(0,b.jsx)(`h2`,{className:`text-base font-semibold`,children:`This session ran outside the live workspace`}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`Session `,(0,b.jsx)(`span`,{className:`font-mono text-xs`,children:e.id}),` came from`,` `,(0,b.jsx)(`span`,{className:`font-mono text-xs`,children:e.source}),`. Its findings, runs and evidence are all here — the transcript is not, because the conversation happened in the TUI rather than over the workbench socket.`]}),(0,b.jsx)(o,{onClick:t,children:`Start a chat for this session`})]})}function q3(){let e=w3(e=>e.selection),t=tf({queryKey:[`agent-sessions`],queryFn:Cx.agentSessions}),[n,r]=(0,y.useState)(null),i=b3(e,t.data?.items),a=i.kind===`external`&&n===i.session.id;if(i.kind===`loading`)return(0,b.jsx)(l3,{compact:!0,title:`Opening the live workspace…`,detail:`Resolving the current session.`});if(i.kind===`external`&&!a)return(0,b.jsx)(K3,{session:i.session,onStartChat:()=>r(i.session.id)});let o=i.kind===`thread`?i.threadId:void 0;return(0,b.jsx)(G3,{initialThreadId:o},o??`new`)}function J3({state:e}){return(0,b.jsxs)(h,{className:`mx-auto max-w-lg items-start gap-3 p-6`,children:[(0,b.jsx)(`h2`,{className:`text-base font-semibold`,children:e===`unauthenticated`?`Sign in required`:e===`unconfigured`?`Live workspace not configured`:`Live workspace unreachable`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e===`unauthenticated`?`The live workspace is available to authenticated platform users.`:e===`unconfigured`?`Set WORKBENCH_CWD on the platform server to enable the hosted agent runtime (see docs/infra/workbench-integration.md).`:`The platform server did not answer. Check that it is running.`}),e===`unauthenticated`?(0,b.jsx)(o,{variant:`outline`,asChild:!0,children:(0,b.jsx)(`a`,{href:`/login`,children:`Sign in`})}):null]})}function Y3({eyebrow:e,title:t,description:n,actions:r,className:i}){return(0,b.jsxs)(`header`,{className:a(`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,i),children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[e?(0,b.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-2 text-2xs font-semibold tracking-[0.12em] uppercase`,children:e}):null,t?(0,b.jsx)(`h1`,{children:t}):null,n?(0,b.jsx)(`p`,{className:`mt-2 mb-0 max-w-[72ch]`,children:n}):null]}),r?(0,b.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r}):null]})}function X3(e){switch(e){case`internal-infrastructure-assessment`:return(0,b.jsx)(ap,{className:`size-4.5 text-indigo-500 dark:text-indigo-400`});case`external-infrastructure-assessment`:return(0,b.jsx)(Vf,{className:`size-4.5 text-cyan-500 dark:text-cyan-400`});case`web-application-assessment`:return(0,b.jsx)(pf,{className:`size-4.5 text-sky-500 dark:text-sky-400`});case`api-security-assessment`:return(0,b.jsx)(xf,{className:`size-4.5 text-violet-500 dark:text-violet-400`});case`android-and-ios-assessment`:return(0,b.jsx)(lp,{className:`size-4.5 text-pink-500 dark:text-pink-400`});case`red-team-campaign`:return(0,b.jsx)(Bf,{className:`size-4.5 text-rose-500 dark:text-rose-400`});default:return(0,b.jsx)(sp,{className:`size-4.5 text-primary`})}}function Z3({risk:e}){return e===`R2`?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-semibold tracking-wide border border-rose-500/30 text-rose-600 dark:text-rose-400 bg-rose-500/10 shrink-0`,children:[(0,b.jsx)(`span`,{className:`size-1.5 rounded-full bg-rose-500 animate-pulse`}),`Tier R2 · Production Risk`]}):e===`R1`?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-semibold tracking-wide border border-amber-500/30 text-amber-600 dark:text-amber-400 bg-amber-500/10 shrink-0`,children:[(0,b.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`}),`Tier R1 · Standard Scope`]}):(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-2xs font-semibold tracking-wide border border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 shrink-0`,children:[(0,b.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-500`}),`Tier R0 · Read Only`]})}function Q3({workflow:e}){let t=Bd(),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),[m,h]=(0,y.useState)([]),_=[...new Set(e.stages.flatMap(e=>e.skillRefs))],v=e.stages.filter(e=>e.optional),x=nf({mutationFn:()=>Cx.startLocalRun({workflowKey:e.key,target:s.trim(),permissionMode:d?`yolo`:`scoped`,selectedStageKeys:m,allowedActions:[`read_files`,`command_execution`]}),onSuccess:()=>void t.invalidateQueries({queryKey:[`local-runs`]})});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`group relative flex flex-col justify-between rounded-xl border border-border/50 bg-card hover:border-primary/60 hover:bg-card/90 hover:shadow-xs transition-all duration-200 p-5 text-left`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3 mb-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,b.jsx)(`div`,{className:`size-10 rounded-xl bg-muted/40 border border-border/60 flex items-center justify-center shrink-0 shadow-2xs group-hover:scale-105 transition-transform`,children:X3(e.key)}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-foreground group-hover:text-primary transition-colors truncate`,children:e.name}),(0,b.jsxs)(`span`,{className:`font-mono text-2xs text-muted-foreground/75`,children:[`v`,e.version,` · `,e.stages.length,` `,e.stages.length===1?`stage`:`stages`]})]})]}),(0,b.jsx)(Z3,{risk:i6(e)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2 mb-3`,children:e.description}),(0,b.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3.5`,children:e.requiredCapabilities.map(e=>(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[10.5px] font-mono font-medium bg-muted/40 text-muted-foreground border border-border/40 group-hover:border-border/80 transition-colors`,children:[(0,b.jsx)(yp,{className:`size-2.5 opacity-50`}),e]},e))}),(0,b.jsxs)(`div`,{className:`pt-2.5 border-t border-border/30 flex items-center gap-2 text-2xs text-muted-foreground`,children:[(0,b.jsx)(Gf,{className:`size-3.5 shrink-0 opacity-60 text-primary`}),(0,b.jsx)(`span`,{className:`font-medium text-foreground/80 shrink-0`,children:`Pipeline:`}),(0,b.jsx)(`span`,{className:`truncate`,children:e.stages.map(e=>e.name).join(` → `)})]})]}),(0,b.jsxs)(`div`,{className:`mt-4 pt-3.5 border-t border-border/30 flex items-center justify-between gap-3`,children:[(0,b.jsxs)(o,{type:`button`,size:`sm`,className:`gap-2 font-medium shadow-2xs cursor-pointer`,onClick:()=>r(!0),children:[(0,b.jsx)(ep,{className:`size-3.5 fill-current`}),` Run Playbook`]}),(0,b.jsxs)(o,{type:`button`,size:`sm`,variant:`outline`,className:`gap-1.5 text-xs text-muted-foreground hover:text-foreground cursor-pointer`,onClick:()=>a(!0),children:[(0,b.jsx)(Qf,{className:`size-3`}),` Edit skill`]})]})]}),(0,b.jsx)($3,{workflow:e,open:i,onOpenChange:a}),(0,b.jsx)(h1,{open:n,onOpenChange:e=>{r(e),e||(c(``),u(!1),f(!1),h([]),x.reset())},children:(0,b.jsxs)(y1,{className:`max-h-[90vh] overflow-y-auto`,children:[(0,b.jsxs)(b1,{children:[(0,b.jsxs)(S1,{children:[`Run `,e.name]}),(0,b.jsx)(C1,{children:`Start a local headless run. Each stage loads its workflow skill pack and the report appears under Audits and Reports when the run completes.`})]}),x.data?(0,b.jsx)(`div`,{className:`grid gap-3 text-sm`,children:(0,b.jsx)(t6,{runId:x.data.runId})}):(0,b.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),s.trim()&&l&&!x.isPending&&x.mutate()},children:[(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(g,{htmlFor:`workflow-target-${e.key}`,children:`Target or scope`}),(0,b.jsx)(p,{id:`workflow-target-${e.key}`,value:s,onChange:e=>c(e.target.value),placeholder:`https://example.com or an authorized asset`,required:!0})]}),(0,b.jsxs)(`div`,{className:`grid gap-1 text-sm`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:`Skill pack`}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:_.length?_.join(`, `):`No skill refs configured`})]}),v.length>0?(0,b.jsxs)(`fieldset`,{className:`grid gap-2 text-sm`,children:[(0,b.jsx)(`legend`,{className:`font-medium`,children:`Optional stages`}),v.map(e=>(0,b.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:m.includes(e.key),onChange:t=>h(n=>t.target.checked?[...n,e.key]:n.filter(t=>t!==e.key))}),(0,b.jsxs)(`span`,{children:[e.name,` `,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.risk,` risk)`]})]})]},e.key))]}):null,(0,b.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),required:!0}),(0,b.jsx)(`span`,{children:`I am authorized to assess this target. The local agent may execute commands on the gateway host.`})]}),(0,b.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-destructive/50 bg-destructive/5 p-3 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`strong`,{children:`YOLO mode — no per-command approval.`}),` The agent can run arbitrary shell commands and read or change local files on the gateway host until the run ends. Commands are not sandboxed; only use this on a trusted local machine and an authorized target. Explicit prohibitions and run time/cost limits still apply.`]})]}),x.isError?(0,b.jsx)(`p`,{role:`alert`,className:`text-destructive text-sm`,children:x.error.message}):null,(0,b.jsx)(x1,{children:(0,b.jsxs)(o,{type:`submit`,disabled:!s.trim()||!l||x.isPending,children:[(0,b.jsx)(ep,{size:16}),` `,x.isPending?`Starting…`:`Start headless run`]})})]})]})})]})}function $3({workflow:e,open:t,onOpenChange:n}){let r=tf({queryKey:[`workflow-skill`,e.key],queryFn:()=>Cx.workflowSkill(e.key),enabled:t,staleTime:0}),i=r.error instanceof xx?r.error.status===404?`The local gateway does not serve skill editing yet. Restart it and try again.`:r.error.status===403?`Skill editing requires an admin session with local runs enabled on this gateway.`:`Could not load this skill (${r.error.code}).`:`Could not load this skill. Check the gateway connection and try again.`,[a,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1);(0,y.useEffect)(()=>{t&&r.data&&s(r.data.item.markdown)},[t,r.data?.item.revision]);let u=nf({mutationFn:()=>Cx.saveWorkflowSkill(e.key,a,r.data.item.revision),onSuccess:e=>{l(!0),r.refetch(),s(e.item.markdown)}});return(0,b.jsx)(h1,{open:t,onOpenChange:e=>{n(e),e||(u.reset(),l(!1))},children:(0,b.jsxs)(y1,{className:`max-h-[90vh] max-w-4xl overflow-y-auto`,children:[(0,b.jsxs)(b1,{children:[(0,b.jsxs)(S1,{children:[`Edit `,e.name,` skill`]}),(0,b.jsx)(C1,{children:`Edit the Markdown instructions the agent loads during this workflow. Saved changes apply to runs when they start; runs already in progress keep their original copy.`})]}),r.isLoading?(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading skill…`}):r.isError?(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:i}),(0,b.jsx)(o,{type:`button`,variant:`outline`,onClick:()=>void r.refetch(),children:`Retry`})]}):r.data?(0,b.jsxs)(`div`,{className:`grid gap-3`,children:[(0,b.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.data.item.skillName,` · `,r.data.item.customized?`Local override`:`Bundled default`]}),(0,b.jsx)(g,{htmlFor:`workflow-skill-${e.key}`,children:`Markdown`}),(0,b.jsx)(_2,{id:`workflow-skill-${e.key}`,value:a,onChange:e=>{s(e.target.value),l(!1)},className:`min-h-[45vh] font-mono text-sm`,spellCheck:!1}),u.isError?(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:u.error.message}):null,c?(0,b.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saved. The next run will use this version.`}):null,(0,b.jsxs)(x1,{children:[(0,b.jsx)(o,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:`Close`}),(0,b.jsx)(o,{type:`button`,disabled:u.isPending||!a.trim()||a.trim()===r.data.item.markdown.trim(),onClick:()=>u.mutate(),children:u.isPending?`Saving…`:`Save skill`})]})]}):null]})})}function e6(){let e=tf({queryKey:[`local-runs`],queryFn:Cx.localRuns,refetchInterval:2e3,retry:!1}),[t,n]=(0,y.useState)(null);if(e.isLoading||e.isError)return null;let r=e.data?.items??[];if(!r.length)return null;let i=r.find(e=>e.runId===t)??r[0];return(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/60 bg-card p-5 grid gap-4 shadow-2xs`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight`,children:`Active Headless Execution`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Live stage progress retained across sessions.`})]}),(0,b.jsx)(`select`,{className:`rounded-lg border border-border/60 bg-background/50 px-2.5 py-1 text-xs font-mono`,value:i.runId,onChange:e=>n(e.target.value),children:r.map(e=>(0,b.jsxs)(`option`,{value:e.runId,children:[e.workflowKey,` · `,e.target,` · `,e.status]},e.runId))})]}),(0,b.jsx)(n6,{run:i})]})}function t6({runId:e}){let t=tf({queryKey:[`local-run`,e],queryFn:()=>Cx.localRun(e),refetchInterval:e=>![`completed`,`partial`,`failed`,`cancelled`].includes(e.state.data?.item.status??``)&&2e3,retry:2});return t.isError?(0,b.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:`Could not load run progress.`}):t.data?(0,b.jsx)(n6,{run:t.data.item}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`Starting run and loading its stages…`})}function n6({run:e}){let t=e.stages.filter(e=>![`pending`,`running`].includes(e.status)).length;return(0,b.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,b.jsx)(r6,{status:e.status}),(0,b.jsx)(`strong`,{children:e.workflowKey}),e.permissionMode===`yolo`?(0,b.jsx)(oS,{variant:`high`,children:`YOLO mode`}):null,(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.status,` · `,t,`/`,e.stages.length,` stages · `,e.runId.slice(0,8)]})]}),(0,b.jsxs)(`p`,{className:`break-all text-muted-foreground`,children:[`Target: `,e.target]}),(0,b.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted`,role:`progressbar`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":e.stages.length,children:(0,b.jsx)(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${e.stages.length?t/e.stages.length*100:0}%`}})}),(0,b.jsx)(`ol`,{className:`grid gap-0 border-l pl-4`,children:e.stages.map(e=>(0,b.jsxs)(`li`,{className:`relative flex items-start gap-3 border-b py-2 last:border-b-0`,children:[(0,b.jsx)(`span`,{className:`absolute -left-[1.43rem] bg-card`,children:(0,b.jsx)(r6,{status:e.status})}),(0,b.jsxs)(`span`,{className:`min-w-0`,children:[(0,b.jsx)(`strong`,{children:e.name}),(0,b.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:e.status}),e.summary?(0,b.jsx)(`span`,{className:`mt-1 block text-muted-foreground`,children:e.summary}):null]})]},e.key))}),e.error?(0,b.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:e.error}):null,e.reportAvailable?(0,b.jsx)(o,{asChild:!0,size:`sm`,variant:`outline`,children:(0,b.jsxs)(`a`,{href:`/reports`,children:[`View report `,(0,b.jsx)(vf,{size:16})]})}):e.status===`running`?(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:`This view updates every two seconds. The report appears after completion.`}):null]})}function r6({status:e}){return e===`running`?(0,b.jsx)(qf,{size:17,className:`animate-spin text-primary`,"aria-label":`Running`}):e===`completed`||e===`succeeded`?(0,b.jsx)(Of,{size:17,className:`text-green-600`,"aria-label":`Succeeded`}):[`failed`,`blocked`,`interrupted`,`partial`,`cancelled`].includes(e)?(0,b.jsx)(kf,{size:17,className:`text-destructive`,"aria-label":e}):(0,b.jsx)(Af,{size:17,className:`text-muted-foreground`,"aria-label":e})}function i6(e){return e.stages.some(e=>e.risk===`R2`)?`R2`:e.stages.some(e=>e.risk===`R1`)?`R1`:`R0`}function a6({workflows:e}){let[t,n]=(0,y.useState)(``),[r,i]=(0,y.useState)(`all`),a=(0,y.useMemo)(()=>e.filter(e=>{let n=e.stages.some(e=>e.risk===`R2`)?`R2`:`R1`;if(r!==`all`&&n!==r)return!1;if(!t.trim())return!0;let i=t.toLowerCase();return e.name.toLowerCase().includes(i)||e.description.toLowerCase().includes(i)||e.requiredCapabilities.some(e=>e.toLowerCase().includes(i))}),[e,t,r]),o=e.filter(e=>!e.stages.some(e=>e.risk===`R2`)).length,s=e.filter(e=>e.stages.some(e=>e.risk===`R2`)).length;return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{title:`Workflows`}),(0,b.jsxs)(Hx,{children:[(0,b.jsx)(Ux,{label:`Automated Playbooks`,value:e.length,meta:`Version-pinned skill packs`}),(0,b.jsx)(Ux,{label:`Surface Risk Ceiling`,value:`R2 Production`,meta:`Strict authorization gates`}),(0,b.jsx)(Ux,{label:`Execution Engine`,value:`Pi Runtime`,meta:`Headless autonomous workers`}),(0,b.jsx)(Ux,{label:`Evidence Audit`,value:`Deterministic`,meta:`Cryptographic finding trails`})]}),(0,b.jsx)(e6,{}),(0,b.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3 p-0.5`,children:[(0,b.jsxs)(`div`,{className:`inline-flex items-center gap-1 p-1 rounded-xl border border-border/50 bg-muted/20`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:()=>i(`all`),className:`px-3 py-1 rounded-lg text-xs font-medium transition-all cursor-pointer ${r===`all`?`bg-card text-foreground shadow-2xs font-semibold`:`text-muted-foreground hover:text-foreground`}`,children:[`All Workflows (`,e.length,`)`]}),(0,b.jsxs)(`button`,{type:`button`,onClick:()=>i(`R1`),className:`px-3 py-1 rounded-lg text-xs font-medium transition-all cursor-pointer ${r===`R1`?`bg-card text-amber-600 dark:text-amber-400 shadow-2xs font-semibold`:`text-muted-foreground hover:text-foreground`}`,children:[`Tier R1 Scope (`,o,`)`]}),(0,b.jsxs)(`button`,{type:`button`,onClick:()=>i(`R2`),className:`px-3 py-1 rounded-lg text-xs font-medium transition-all cursor-pointer ${r===`R2`?`bg-card text-rose-600 dark:text-rose-400 shadow-2xs font-semibold`:`text-muted-foreground hover:text-foreground`}`,children:[`Tier R2 Elevated (`,s,`)`]})]}),(0,b.jsxs)(`div`,{className:`relative max-w-xs w-full`,children:[(0,b.jsx)(ip,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground/60`}),(0,b.jsx)(p,{value:t,onChange:e=>n(e.target.value),placeholder:`Filter workflows or capabilities...`,className:`pl-8.5 h-8.5 text-xs bg-card/60 border-border/50 rounded-lg`})]})]}),a.length>0?(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:a.map(e=>(0,b.jsx)(Q3,{workflow:e},e.key))}):(0,b.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border/70 p-12 text-center bg-card/30`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No matching workflows found`}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Try adjusting your search query or risk filters.`})]})]})}function o6({sessions:e,value:t,onChange:n,className:r,id:i=`agent-session`}){let o=e[0];return(0,b.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,r),children:[(0,b.jsx)(`label`,{className:`text-muted-foreground shrink-0 text-[13px]`,htmlFor:i,children:`Session`}),(0,b.jsxs)(c3,{"aria-label":`Agent session`,className:`w-auto min-w-0 max-w-[22rem] text-[13px]`,id:i,onChange:e=>n(e.target.value),value:t??`latest`,children:[(0,b.jsx)(`option`,{value:`latest`,children:o?`Latest — ${o.title||`Session`}`:`Latest session`}),(0,b.jsx)(`option`,{value:`all`,children:`All workspace sessions`}),e.map(e=>(0,b.jsxs)(`option`,{value:e.id,children:[e.title||`Session`,` · `,e.findingCount??0,` findings · `,e.runCount??0,` runs`]},e.id))]})]})}var s6=[{id:`azure-openai`,label:`Azure OpenAI`},{id:`openai-compatible`,label:`OpenAI compatible endpoint`},{id:`anthropic`,label:`Anthropic`}];function c6(){let e=tf({queryKey:[`model-credentials`],queryFn:Cx.modelCredentials}),t=tf({queryKey:[`my-role`],queryFn:Cx.myRole}),[n,r]=(0,y.useState)(`anthropic`),[i,a]=(0,y.useState)(`user`),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(``),m=t.data?.role===`owner`||t.data?.role===`admin`;async function h(e){e.preventDefault(),u(!0),f(``);try{await Cx.saveModelCredential(i,n,s),c(``),f(`Key saved. Future model requests will use it according to its scope.`),await wx.invalidateQueries({queryKey:[`model-credentials`]})}catch(e){f(e instanceof Error?e.message:`Could not save the key.`)}finally{u(!1)}}async function _(e){if(confirm(`Remove the ${e.scope} ${e.provider} key?`)){u(!0),f(``);try{await Cx.deleteModelCredential(e.scope,e.provider),await wx.invalidateQueries({queryKey:[`model-credentials`]})}catch(e){f(e instanceof Error?e.message:`Could not remove the key.`)}finally{u(!1)}}}return(0,b.jsxs)(`section`,{className:`rounded-xl border bg-card p-5`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Model API keys`}),(0,b.jsx)(`p`,{className:`text-muted-foreground mt-1 text-sm`,children:`Your private key applies to your own model requests. Workspace keys are shared with members and can be managed by an owner or admin. A private key takes priority when both are available.`}),(0,b.jsxs)(`form`,{onSubmit:h,className:`mt-5 grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,b.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,b.jsx)(g,{htmlFor:`model-provider`,children:`Provider`}),(0,b.jsx)(c3,{id:`model-provider`,value:n,onChange:e=>r(e.target.value),children:s6.map(e=>(0,b.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,b.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,b.jsx)(g,{htmlFor:`model-key-scope`,children:`Who can use it`}),(0,b.jsxs)(c3,{id:`model-key-scope`,value:i,onChange:e=>a(e.target.value),children:[(0,b.jsx)(`option`,{value:`user`,children:`Only me`}),m?(0,b.jsx)(`option`,{value:`workspace`,children:`Workspace members`}):null]})]}),(0,b.jsxs)(`div`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,b.jsx)(g,{htmlFor:`model-api-key`,children:`API key`}),(0,b.jsx)(p,{id:`model-api-key`,type:`password`,autoComplete:`off`,value:s,onChange:e=>c(e.target.value),minLength:8,required:!0})]}),(0,b.jsx)(o,{type:`submit`,disabled:l||!s.trim(),className:`w-fit`,children:`Save key`})]}),d?(0,b.jsx)(`p`,{className:`mt-3 text-sm`,role:`status`,children:d}):null,(0,b.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[e.data?.items.map(e=>(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border p-3 text-sm`,children:[(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`strong`,{children:s6.find(t=>t.id===e.provider)?.label}),` · `,e.scope===`user`?`Only me`:`Workspace`,` · ending `,e.lastFour]}),e.scope===`user`||m?(0,b.jsx)(o,{type:`button`,variant:`destructive`,size:`sm`,disabled:l,onClick:()=>_(e),children:`Remove`}):null]},`${e.scope}:${e.provider}`)),e.data&&e.data.items.length===0?(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No saved model keys.`}):null,e.isError?(0,b.jsx)(`p`,{className:`text-destructive text-sm`,children:`Could not load model keys.`}):null]})]})}function l6(){let e=tf({queryKey:[`my-role`],queryFn:Cx.myRole}),[t,n]=(0,y.useState)(``),[r,i]=(0,y.useState)(``),[a,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1);if(e.data&&e.data.role!==`owner`&&e.data.role!==`admin`)return null;async function u(e){e.preventDefault(),l(!0),s(``),i(``);try{let e=await Cx.createInvitation(t);i(`${window.location.origin}/login#invite=${encodeURIComponent(e.token)}`),n(``)}catch(e){s(e instanceof Error?e.message:`Could not create the invitation.`)}finally{l(!1)}}return(0,b.jsxs)(`section`,{className:`rounded-xl border bg-card p-5`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Invite a member`}),(0,b.jsx)(`p`,{className:`text-muted-foreground mt-1 text-sm`,children:`Create a one-time link. The member sets their own password and can then save a private model key.`}),(0,b.jsxs)(`form`,{onSubmit:u,className:`mt-4 flex flex-wrap items-end gap-3`,children:[(0,b.jsxs)(`div`,{className:`grid min-w-56 flex-1 gap-1.5`,children:[(0,b.jsx)(g,{htmlFor:`invite-email`,children:`Email`}),(0,b.jsx)(p,{id:`invite-email`,type:`email`,value:t,onChange:e=>n(e.target.value),required:!0})]}),(0,b.jsx)(o,{type:`submit`,disabled:c,children:c?`Creating…`:`Create invite link`})]}),a?(0,b.jsx)(`p`,{className:`text-destructive mt-3 text-sm`,role:`alert`,children:a}):null,r?(0,b.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,b.jsx)(g,{htmlFor:`invite-link`,children:`Copy and share this link. It expires in 7 days and is shown only once.`}),(0,b.jsx)(p,{id:`invite-link`,readOnly:!0,value:r,onFocus:e=>e.currentTarget.select()}),(0,b.jsx)(o,{type:`button`,variant:`outline`,className:`w-fit`,onClick:()=>navigator.clipboard.writeText(r),children:`Copy link`})]}):null]})}function u6({section:e}){return(0,b.jsx)(Vd,{client:wx,children:(0,b.jsx)(p6,{section:e})})}function d6(){let e=tf({queryKey:[`workbench-status`],queryFn:z3,retry:1,staleTime:15e3});return e.isLoading?(0,b.jsx)(l3,{compact:!0,title:`Connecting to the live workspace…`,detail:`Checking the platform agent runtime.`}):e.data&&e.data!==`up`?(0,b.jsx)(J3,{state:e.data}):(0,b.jsx)(q3,{})}function f6(){return(0,b.jsx)(Vd,{client:wx,children:(0,b.jsx)(d6,{})})}function p6({section:e}){let t=w3(e=>e.selection),n=w3(e=>e.select),r=w3(e=>e.resolveLatest),i=m3(t),a=e=>n(h3(e)),[s,c]=(0,y.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`finding`):null),l=e=>{if(c(e),typeof window<`u`){let t=new URL(window.location.href);e?t.searchParams.set(`finding`,e):t.searchParams.delete(`finding`),window.history.replaceState({},``,t.toString())}},u=tf({queryKey:[`agent-sessions`],queryFn:Cx.agentSessions,enabled:e===`runs`||e===`agent`||e===`findings`||e===`dashboard`||e===`lifecycle`,refetchInterval:2e3});(0,y.useEffect)(()=>{u.data?.items&&r(u.data.items)},[u.data?.items,r]);let d=_3(t,u.data?.items),f=tf({queryKey:[`workflows`],queryFn:Cx.workflows,enabled:e===`workflows`||e===`assessments`}),m=tf({queryKey:[`overview`,d],queryFn:()=>Cx.overview(d),enabled:e===`dashboard`||e===`assessments`||e===`lifecycle`,refetchInterval:2e3}),_=tf({queryKey:[`runs`,d],queryFn:()=>Cx.runs({sessionId:d}),enabled:e===`runs`,refetchInterval:2e3}),v=tf({queryKey:[`projects`],queryFn:Cx.projects,enabled:e===`assessments`}),x=tf({queryKey:[`assessment-profiles`],queryFn:Cx.assessmentProfiles,enabled:e===`assessments`}),S=tf({queryKey:[`findings`,d],queryFn:()=>Cx.findings({sessionId:d}),enabled:e===`findings`||e===`dashboard`||e===`lifecycle`||e===`reports`,refetchInterval:6e3}),C=tf({queryKey:[`agent-session`,d],queryFn:()=>Cx.agentSession(d),enabled:e===`runs`&&!!d,refetchInterval:2e3}),w=tf({queryKey:[`governance-events`],queryFn:Cx.governanceEvents,enabled:e===`reports`}),T=tf({queryKey:[`workers`],queryFn:Cx.workers,enabled:e===`administration`}),E=tf({queryKey:[`tokens`],queryFn:Cx.tokens,enabled:e===`administration`}),[D,O]=(0,y.useState)(``),[k,A]=(0,y.useState)(30),[j,M]=(0,y.useState)(!1),[N,ee]=(0,y.useState)(null),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(null),[se,ce]=(0,y.useState)(null);async function le(e){e.preventDefault(),M(!0),oe(null);try{let e=await Cx.mintToken({label:D.trim()||`CLI Token`,expiresInDays:k});ee(e),O(``),wx.invalidateQueries({queryKey:[`tokens`]})}catch(e){oe(e instanceof Error?e.message:`Failed to mint token`)}finally{M(!1)}}async function ue(e){if(confirm(`Are you sure you want to revoke this token? Any CLI session or automation using it will immediately lose access.`)){ce(e);try{await Cx.revokeToken(e),wx.invalidateQueries({queryKey:[`tokens`]})}catch(e){alert(e instanceof Error?e.message:`Failed to revoke token`)}finally{ce(null)}}}let de=[...e===`workflows`||e===`assessments`?[f]:[],...e===`dashboard`?[m,S]:[],...e===`lifecycle`?[m,S]:[],...e===`runs`?[_,u]:[],...e===`runs`&&d?[C]:[],...e===`assessments`?[m,v,x]:[],...e===`findings`?[S,u]:[],...e===`reports`?[w,S]:[],...e===`administration`?[T,E]:[]];if(de.some(e=>e.isLoading))return(0,b.jsx)(l3,{title:`Loading workspace`,detail:`Reading durable platform state…`});let P=de.find(e=>e.isError);if(P){let e=P.error,t=e&&typeof e==`object`&&`status`in e&&e.status===401;return(0,b.jsx)(l3,{title:`Platform unavailable`,detail:e instanceof Error?e.message:`The platform could not be reached.`,action:t?(0,b.jsx)(o,{asChild:!0,children:(0,b.jsx)(`a`,{href:`/login`,children:`Sign in`})}):(0,b.jsxs)(o,{onClick:()=>void P.refetch(),children:[(0,b.jsx)(np,{}),` Retry`]})})}let fe=zx(S.data?.findings??[]),pe=fe.filter(Ix);if(e===`dashboard`){let e=Object.fromEntries(kx.map(e=>[e,pe.filter(t=>t.severity===e).length])),t=m.data?.runs??{},n=Object.values(t).reduce((e,t)=>e+t,0),r=(t.queued??0)+(t.running??0),s=Bx(fe),c=fe.filter(e=>e.status===`confirmed`||e.status===`verified`);return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{actions:(0,b.jsx)(o6,{onChange:a,sessions:u.data?.items??[],value:i})}),(0,b.jsxs)(Hx,{children:[(0,b.jsx)(Ux,{hero:!0,tone:s??void 0,label:`Client posture`,value:s?Mx[s].toUpperCase():`NO CONFIRMED RISK`,meta:s?`Worst confirmed finding across ${c.length} confirmed finding${c.length===1?``:`s`}.`:`No finding has been confirmed yet.`}),(0,b.jsx)(Ux,{label:`Open findings`,value:pe.length,meta:`${fe.length-pe.length} resolved`}),(0,b.jsx)(Ux,{label:`Critical / High`,value:`${e.critical} / ${e.high}`,meta:`${c.length} confirmed overall`}),(0,b.jsx)(Ux,{label:`Assessments`,value:n,meta:`${r} in flight`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,b.jsx)(Vx,{title:`Open findings by severity`,sub:`${pe.length} active`,children:(0,b.jsx)(Wx,{counts:e})}),(0,b.jsx)(Vx,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,b.jsx)(Gx,{findings:pe})})]}),(0,b.jsx)(Vx,{title:`Highest-priority open findings`,sub:(0,b.jsx)(`a`,{className:`link-more`,href:`/findings`,children:`View all`}),children:(0,b.jsx)(Zx,{findings:Fx(pe).slice(0,5),onSelect:e=>{window.location.href=`/findings?finding=${encodeURIComponent(e.id)}`},emptyLabel:`No open findings. Agent runs report findings through the report_finding tool; none have been ingested yet.`})}),(0,b.jsxs)(`section`,{"aria-labelledby":`active-runs`,children:[(0,b.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-1 text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Operations`}),(0,b.jsx)(`h2`,{id:`active-runs`,children:`Active runs`})]}),(0,b.jsxs)(`a`,{className:`link-more`,href:`/runs`,children:[`View all `,(0,b.jsx)(vf,{"aria-hidden":`true`})]})]}),m.data?.recentRuns.filter(e=>e.status===`queued`||e.status===`running`).length?(0,b.jsx)(y6,{runs:m.data.recentRuns.filter(e=>e.status===`queued`||e.status===`running`)}):(0,b.jsx)(l3,{compact:!0,title:`No active runs`,detail:`Select a target endpoint to initialize a governed assessment.`,action:(0,b.jsx)(o,{asChild:!0,children:(0,b.jsx)(`a`,{href:`/assessments`,children:`New assessment`})})})]})]})}if(e===`lifecycle`)return(0,b.jsx)(_6,{findings:pe});if(e===`workflows`)return(0,b.jsx)(a6,{workflows:f.data?.items??[]});if(e===`runs`){if(d&&C.data){let e=C.data,t=e.operations.filter(e=>e.status!==`completed`).length;return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:`Session`}),(0,b.jsx)(`h1`,{children:e.session.title}),(0,b.jsx)(`p`,{children:`Recorded tool calls and findings for this agent session, newest run last.`})]}),(0,b.jsx)(o,{variant:`outline`,onClick:()=>n(p3),children:`All sessions`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,b.jsx)(g6,{label:`Status`,value:S6(e.session.status),detail:`${e.session.runCount} run${e.session.runCount===1?``:`s`} in this session`}),(0,b.jsx)(g6,{label:`Tool calls`,value:String(e.session.operationCount),detail:t?`${t} did not complete`:`All completed`}),(0,b.jsx)(g6,{label:`Findings`,value:String(e.session.findingCount),detail:e.session.findingCount?`Ingested through report_finding`:`None reported in this session`})]}),(0,b.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.65fr)]`,"aria-live":`polite`,children:[(0,b.jsxs)(`section`,{"aria-labelledby":`agent-transcript`,children:[(0,b.jsx)(`h2`,{id:`agent-transcript`,children:`Transcript`}),e.operations.length?(0,b.jsx)(`div`,{className:`grid gap-2.5`,children:e.operations.map(e=>(0,b.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground [&_p.font-mono]:max-h-28 [&_p.font-mono]:overflow-auto [&_p.font-mono]:rounded-sm [&_p.font-mono]:bg-[var(--plane)] [&_p.font-mono]:px-2.5 [&_p.font-mono]:py-2 [&_p.font-mono]:text-xs [&_p.font-mono]:whitespace-pre-wrap`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(`strong`,{children:e.tool}),(0,b.jsx)(oS,{variant:aS(e.status),children:S6(e.outcome)})]}),(0,b.jsxs)(`p`,{children:[e.runtime,` · `,new Date(e.startedAt).toLocaleTimeString(),e.completedAt?` · ${e.completedAt-e.startedAt}ms`:``]}),e.outputPreview?(0,b.jsx)(`p`,{className:`font-mono`,children:e.outputPreview.slice(0,400)}):null]},e.id))}):(0,b.jsx)(l3,{compact:!0,title:`Waiting for agent output`,detail:`Tool calls appear here as the runtime records them.`})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`agent-runs`,children:[(0,b.jsx)(`h2`,{id:`agent-runs`,children:`Runs`}),(0,b.jsx)(`div`,{className:`grid gap-2.5`,children:e.runs.map(e=>(0,b.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(oS,{variant:aS(e.status),children:S6(e.status)}),(0,b.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,12)})]}),(0,b.jsxs)(`p`,{children:[e.kind,` · `,new Date(e.createdAt).toLocaleString()]})]},e.id))})]})]}),e.findings.length?(0,b.jsxs)(`section`,{"aria-labelledby":`agent-findings`,children:[(0,b.jsx)(`h2`,{id:`agent-findings`,children:`Findings from this session`}),(0,b.jsx)(b6,{findings:e.findings})]}):null]})}return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{title:`Runs`}),(0,b.jsxs)(`section`,{"aria-labelledby":`all-runs`,children:[(0,b.jsx)(`h2`,{id:`all-runs`,className:`mb-3`,children:`Runs`}),_.data?.runs.length?(0,b.jsx)(y6,{runs:_.data.runs}):(0,b.jsx)(l3,{compact:!0,title:`No runs yet`,detail:`Initialize an assessment to start the first governed run.`})]}),(0,b.jsxs)(`section`,{"aria-labelledby":`all-sessions`,children:[(0,b.jsx)(`h2`,{id:`all-sessions`,className:`mb-3`,children:`Sessions`}),u.data?.items.length?(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:u.data.items.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(oS,{variant:aS(e.status),children:S6(e.status)}),(0,b.jsx)(`span`,{className:`font-mono`,children:e.source})]}),(0,b.jsx)(`h2`,{children:e.title}),(0,b.jsxs)(`p`,{children:[e.runCount,` run`,e.runCount===1?``:`s`,` · `,e.operationCount,` tool call`,e.operationCount===1?``:`s`,` · `,e.findingCount,` finding`,e.findingCount===1?``:`s`]}),(0,b.jsxs)(`p`,{children:[`Last active `,new Date(e.lastActivityAt).toLocaleString()]}),(0,b.jsx)(o,{variant:`outline`,onClick:()=>n({kind:`pinned`,id:e.id}),children:`Open session`})]},e.id))}):(0,b.jsx)(l3,{compact:!0,title:`No agent sessions`,detail:`Sessions appear here once an agent run reaches the platform.`})]})]})}if(e===`assessments`)return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{title:`Assessments`}),(0,b.jsx)(eM,{}),(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,b.jsx)(g6,{label:`Projects`,value:String(v.data?.items.length??0),detail:`Active workspace project boundaries`}),(0,b.jsx)(g6,{label:`Target bindings`,value:String(x.data?.items.length??0),detail:`Bound endpoints and infrastructure`}),(0,b.jsx)(g6,{label:`Recent runs`,value:String(m.data?.recentRuns.length??0),detail:`Assessment runs recorded in this workspace`})]}),x.data?.items.length?(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:x.data.items.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(oS,{variant:aS(e.allowedRisk),children:e.allowedRisk}),(0,b.jsxs)(`span`,{className:`font-mono`,children:[`rev `,e.revision]})]}),(0,b.jsx)(`h2`,{children:e.targets[0]?.displayName??e.targets[0]?.locator??`Bound target`}),(0,b.jsxs)(`p`,{children:[e.requiredWorkerClass,` worker · immutable launch policy`]}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,b.jsx)(`span`,{children:e},e))})]},e.id))}):(0,b.jsx)(l3,{compact:!0,title:`No targets yet`,detail:`Configure a new target endpoint from the dashboard to initialize assessment tracking.`})]});if(e===`findings`){if(s)return(0,b.jsx)(`div`,{className:`grid gap-6`,children:(0,b.jsx)(sM,{findingId:s,onBack:()=>l(null)})});let e=Object.fromEntries(kx.map(e=>[e,pe.filter(t=>t.severity===e).length])),r=x6(pe),c=fe.filter(e=>!Ix(e)),f=u.data?.items??[],p=f.find(e=>e.id===d),m=t.kind===`all`&&f.length>0;return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{actions:(0,b.jsx)(o6,{id:`findings-session`,onChange:a,sessions:u.data?.items??[],value:i}),title:`Findings`}),m?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Choose an agent session to review its findings. Local headless runs are listed separately below.`}),(0,b.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:f.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{children:e.title||`Agent session`}),(0,b.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[e.findingCount,` finding`,e.findingCount===1?``:`s`,` · `,e.runCount,` run`,e.runCount===1?``:`s`,` · `,e.source]})]}),(0,b.jsx)(oS,{variant:aS(e.status),children:S6(e.status)})]}),(0,b.jsx)(o,{variant:`outline`,size:`sm`,onClick:()=>n({kind:`pinned`,id:e.id}),children:`View session findings`})]},e.id))}),fe.length?(0,b.jsxs)(`details`,{className:`rounded-xl border bg-card p-4`,children:[(0,b.jsxs)(`summary`,{className:`cursor-pointer font-medium`,children:[`Workspace-wide findings · `,fe.length,` total`]}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This combined view can include findings associated with more than one session.`}),(0,b.jsx)(Zx,{findings:Fx(fe),onSelect:e=>l(e.id)})]}):null]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`bg-card border rounded-xl p-4 sm:p-5 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 shadow-2xs`,children:(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(`h2`,{className:`text-base sm:text-lg font-semibold tracking-tight text-foreground`,children:p?.title||(d?`Selected agent session`:`Workspace findings`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,b.jsxs)(`span`,{className:`font-mono text-foreground/80 font-medium`,children:[fe.length,` total`]}),(0,b.jsx)(`span`,{children:`·`}),(0,b.jsxs)(`span`,{className:`text-amber-600 dark:text-amber-400 font-medium`,children:[pe.length,` open`]}),(0,b.jsx)(`span`,{children:`·`}),(0,b.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400 font-medium`,children:[c.length,` resolved`]}),p?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{children:`·`}),(0,b.jsxs)(`span`,{className:`font-mono text-foreground/70`,children:[p.runCount,` `,p.runCount===1?`run`:`runs`]})]}):null]})]})}),pe.length?(0,b.jsx)(b.Fragment,{children:r.map(({asset:e,items:t})=>(0,b.jsx)(Vx,{title:e,sub:`${t.length} finding${t.length===1?``:`s`}`,children:(0,b.jsx)(Zx,{findings:Fx(t),onSelect:e=>l(e.id)})},e))}):(0,b.jsx)(l3,{compact:!0,title:c.length?`No open findings`:`No findings in this session`,detail:c.length?`Resolved findings are available below.`:`Findings reported by this agent session will appear here. Local headless runs are listed separately below.`}),c.length?(0,b.jsxs)(`details`,{className:`rounded-xl border bg-card p-4`,children:[(0,b.jsxs)(`summary`,{className:`cursor-pointer font-medium`,children:[`Resolved findings · `,c.length]}),(0,b.jsx)(Zx,{findings:Fx(c),onSelect:e=>l(e.id)})]}):null,fe.length?(0,b.jsxs)(`details`,{className:`rounded-xl border bg-card p-4`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:`Analysis views · severity, lifecycle and control matrix`}),(0,b.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,b.jsx)(Vx,{title:`Open findings by severity`,sub:`${pe.length} active`,children:(0,b.jsx)(Wx,{counts:e})}),(0,b.jsx)(Vx,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,b.jsx)(Gx,{findings:pe})})]}),(0,b.jsx)(`div`,{className:`mt-4`,children:(0,b.jsx)(Vx,{title:`Control coverage`,sub:`pillar × lifecycle stage — worst open severity per cell`,children:(0,b.jsx)($x,{findings:pe,onSelectStage:()=>{}})})})]}):null]}),(0,b.jsx)(tM,{})]})}return e===`agent`?(0,b.jsx)(Y3,{actions:(0,b.jsx)(o6,{id:`console-session`,onChange:a,sessions:u.data?.items??[],value:i}),title:`Console`}):e===`reports`?(0,b.jsxs)(`div`,{className:`grid gap-8`,children:[(0,b.jsx)(Y3,{title:`Reports`}),(0,b.jsx)($j,{}),(0,b.jsx)(v6,{events:w.data?.items??[],findings:fe})]}):e===`administration`?(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{title:`Administration & Access`}),(0,b.jsx)(c6,{}),(0,b.jsx)(l6,{}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,b.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.5rem`},children:[(0,b.jsx)(Wf,{size:18}),(0,b.jsx)(`h2`,{children:`Personal Access Tokens & CLI Sign-In`})]})}),(0,b.jsx)(`p`,{style:{marginTop:`0.25rem`,marginBottom:`1rem`},children:`Mint tokens to authenticate the Kifaru CLI or automated CI/CD pipelines without passwords.`}),N&&(0,b.jsxs)(`div`,{style:{background:`rgba(16, 185, 129, 0.12)`,border:`1px solid rgba(16, 185, 129, 0.4)`,borderRadius:`var(--radius-xl)`,padding:`1rem`,marginBottom:`1.25rem`},children:[(0,b.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`0.5rem`},children:[(0,b.jsxs)(`strong`,{style:{color:`var(--good)`,display:`flex`,alignItems:`center`,gap:`0.4rem`},children:[(0,b.jsx)(Cf,{size:16}),` Token Minted: `,N.label]}),(0,b.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>ee(null),children:`Dismiss`})]}),(0,b.jsx)(`p`,{style:{fontSize:`0.85rem`,color:`var(--ink-2)`,marginBottom:`0.75rem`},children:`Make sure to copy your Personal Access Token now. You will not be able to see it again!`}),(0,b.jsxs)(`div`,{style:{display:`grid`,gap:`0.75rem`},children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{className:`text-muted-foreground mb-1 block text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Token Value`}),(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,b.jsx)(p,{type:`text`,readOnly:!0,value:N.token,className:`flex-1 font-mono`}),(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(N.token),ne(!0),setTimeout(()=>ne(!1),2e3)},children:[te?(0,b.jsx)(Cf,{size:14}):(0,b.jsx)(Nf,{size:14}),te?`Copied`:`Copy Token`]})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,style:{display:`block`,marginBottom:`0.25rem`},children:`CLI Sign-In Command`}),(0,b.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,b.jsxs)(`code`,{className:`font-mono`,style:{flex:1,borderRadius:`var(--radius-lg)`,padding:`0.45rem 0.65rem`,fontSize:`0.82rem`,color:`var(--primary)`},children:[`kifaru session login --token `,N.token]}),(0,b.jsxs)(o,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(`kifaru session login --token `+N.token),ie(!0),setTimeout(()=>ie(!1),2e3)},children:[re?(0,b.jsx)(Cf,{size:14}):(0,b.jsx)(Nf,{size:14}),re?`Copied`:`Copy Command`]})]})]})]})]}),(0,b.jsxs)(`form`,{onSubmit:le,style:{display:`flex`,flexWrap:`wrap`,alignItems:`flex-end`,gap:`0.75rem`,background:`var(--surface-2)`,border:`1px solid var(--border)`,borderRadius:`var(--radius-xl)`,padding:`0.85rem`,marginBottom:`1.25rem`},children:[(0,b.jsxs)(`div`,{style:{flex:`1 1 220px`},children:[(0,b.jsx)(g,{htmlFor:`mint-label`,className:`mb-1.5 block text-sm`,children:`Token Label`}),(0,b.jsx)(p,{id:`mint-label`,type:`text`,placeholder:`e.g. Workstation CLI, CI Runner`,value:D,onChange:e=>O(e.target.value)})]}),(0,b.jsxs)(`div`,{style:{width:`160px`},children:[(0,b.jsx)(g,{htmlFor:`mint-expiry`,className:`mb-1.5 block text-sm`,children:`Expiration`}),(0,b.jsxs)(c3,{id:`mint-expiry`,value:k,onChange:e=>A(Number(e.target.value)),children:[(0,b.jsx)(`option`,{value:30,children:`30 days`}),(0,b.jsx)(`option`,{value:60,children:`60 days`}),(0,b.jsx)(`option`,{value:90,children:`90 days`}),(0,b.jsx)(`option`,{value:365,children:`1 year`}),(0,b.jsx)(`option`,{value:0,children:`Never expires`})]})]}),(0,b.jsxs)(o,{type:`submit`,disabled:j,size:`sm`,children:[(0,b.jsx)(tp,{size:15}),j?`Minting…`:`Mint Token`]})]}),ae&&(0,b.jsx)(`p`,{className:`text-destructive text-sm`,style:{marginBottom:`1rem`},children:ae}),(0,b.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,b.jsx)(`h3`,{style:{fontSize:`0.95rem`,fontWeight:600,marginBottom:`0.5rem`},children:`Active Tokens`}),E.data?.items.length?(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Label`}),(0,b.jsx)(`th`,{children:`Token Prefix`}),(0,b.jsx)(`th`,{children:`Role`}),(0,b.jsx)(`th`,{children:`Created`}),(0,b.jsx)(`th`,{children:`Expires`}),(0,b.jsx)(`th`,{children:`Action`})]})}),(0,b.jsx)(`tbody`,{children:E.data.items.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{style:{fontWeight:600,color:`var(--ink)`},children:e.label}),(0,b.jsxs)(`td`,{className:`font-mono`,children:[e.prefix,`…`]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:aS(`confirmed`),children:e.role})}),(0,b.jsx)(`td`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,b.jsx)(`td`,{children:e.expiresAt?new Date(e.expiresAt).toLocaleDateString():`Never`}),(0,b.jsx)(`td`,{children:(0,b.jsxs)(o,{variant:`destructive`,size:`sm`,disabled:se===e.id,onClick:()=>ue(e.id),children:[(0,b.jsx)(gp,{size:13}),se===e.id?`Revoking…`:`Revoke`]})})]},e.id))})]})}):(0,b.jsx)(`p`,{style:{color:`var(--ink-3)`,fontSize:`0.85rem`,fontStyle:`italic`},children:`No personal access tokens minted yet. Use the form above to create one.`})]}),(0,b.jsxs)(`div`,{style:{marginTop:`1.25rem`,background:`var(--surface-2)`,border:`1px dashed var(--border)`,borderRadius:`var(--radius-xl)`,padding:`0.85rem 1rem`,display:`flex`,alignItems:`center`,gap:`0.75rem`},children:[(0,b.jsx)(fp,{size:20}),(0,b.jsxs)(`div`,{style:{fontSize:`0.82rem`,color:`var(--ink-3)`},children:[(0,b.jsx)(`strong`,{style:{color:`var(--ink)`},children:`Interactive Browser Sign-in:`}),` You can also run`,` `,(0,b.jsx)(`code`,{className:`font-mono`,style:{color:`var(--primary)`},children:`kifaru session login`}),` `,`in your terminal to authenticate interactively through your browser.`]})]})]}),(0,b.jsxs)(`div`,{style:{marginTop:`1rem`},children:[(0,b.jsx)(`h2`,{style:{fontSize:`1.15rem`,marginBottom:`0.75rem`},children:`Execution Workers`}),T.data?.items.length?(0,b.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:T.data.items.map(e=>(0,b.jsxs)(h,{children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsx)(oS,{variant:aS(e.status),children:S6(e.status)}),(0,b.jsx)(`span`,{className:`font-mono`,children:e.status})]}),(0,b.jsx)(`h2`,{children:e.name}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,b.jsx)(`span`,{children:e},e))})]},e.id))}):(0,b.jsx)(l3,{compact:!0,title:`No workers registered`,detail:`Connect an execution worker before launching capability-bound workflows.`})]})]}):e===`billing`?(0,b.jsx)(m6,{}):e===`team`?(0,b.jsx)(h6,{}):(0,b.jsx)(l3,{title:`Not found`,detail:`This view does not exist.`})}function m6(){return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{title:`Billing & Subscription`}),(0,b.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,b.jsxs)(h,{className:`p-6`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,b.jsxs)(`span`,{className:`text-2xs font-semibold uppercase tracking-[0.12em] text-muted-foreground flex items-center gap-1.5`,children:[(0,b.jsx)(Pf,{className:`size-3.5`}),` Current Plan`]}),(0,b.jsx)(oS,{variant:`success`,children:`Active`})]}),(0,b.jsx)(`div`,{className:`text-2xl font-bold mb-1`,children:`Developer Pro`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mb-6`,children:`Continuous assurance scans with dedicated runtime concurrency.`}),(0,b.jsxs)(`div`,{className:`space-y-2 border-t pt-4 text-xs text-muted-foreground`,children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{children:`Parallel agent jobs`}),(0,b.jsx)(`span`,{className:`font-semibold text-foreground`,children:`8 concurrent`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{children:`Finding retention`}),(0,b.jsx)(`span`,{className:`font-semibold text-foreground`,children:`365 days`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{children:`Next renewal`}),(0,b.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Oct 1, 2026`})]})]})]}),(0,b.jsxs)(h,{className:`p-6 flex flex-col justify-between`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,b.jsx)(`span`,{className:`text-2xs font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Scan Credits`}),(0,b.jsx)(`span`,{className:`text-xs font-mono text-[var(--good)] font-semibold`,children:`Active Balance`})]}),(0,b.jsx)(`div`,{className:`text-2xl font-bold font-mono mb-1`,children:`$240.00`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`Prepaid compute balance for high-concurrency automated audits.`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(o,{size:`sm`,className:`flex-1`,children:`Add Balance`}),(0,b.jsx)(o,{size:`sm`,variant:`outline`,children:`Change Plan`})]})]})]}),(0,b.jsxs)(h,{className:`p-6`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-semibold mb-4`,children:`Recent Invoices`}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-lg border`,children:(0,b.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,b.jsx)(`thead`,{className:`bg-muted/50 border-b`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`p-3`,children:`Invoice`}),(0,b.jsx)(`th`,{className:`p-3`,children:`Date`}),(0,b.jsx)(`th`,{className:`p-3`,children:`Amount`}),(0,b.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,b.jsx)(`th`,{className:`p-3 text-right`,children:`Receipt`})]})}),(0,b.jsxs)(`tbody`,{className:`divide-y`,children:[(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{className:`p-3 font-mono font-medium`,children:`INV-2026-009`}),(0,b.jsx)(`td`,{className:`p-3 text-muted-foreground`,children:`Sep 1, 2026`}),(0,b.jsx)(`td`,{className:`p-3 font-mono`,children:`$120.00`}),(0,b.jsx)(`td`,{className:`p-3`,children:(0,b.jsx)(oS,{variant:`success`,children:`Paid`})}),(0,b.jsx)(`td`,{className:`p-3 text-right`,children:(0,b.jsx)(`span`,{className:`text-primary hover:underline cursor-pointer`,children:`PDF`})})]}),(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{className:`p-3 font-mono font-medium`,children:`INV-2026-008`}),(0,b.jsx)(`td`,{className:`p-3 text-muted-foreground`,children:`Aug 1, 2026`}),(0,b.jsx)(`td`,{className:`p-3 font-mono`,children:`$120.00`}),(0,b.jsx)(`td`,{className:`p-3`,children:(0,b.jsx)(oS,{variant:`success`,children:`Paid`})}),(0,b.jsx)(`td`,{className:`p-3 text-right`,children:(0,b.jsx)(`span`,{className:`text-primary hover:underline cursor-pointer`,children:`PDF`})})]})]})]})})]})]})}function h6(){return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{title:`Team & Permissions`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,b.jsx)(_p,{size:18}),` Workspace Members`]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Manage organization access and security verification roles.`})]}),(0,b.jsxs)(o,{size:`sm`,children:[(0,b.jsx)(tp,{size:14}),` Invite Member`]})]}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Member`}),(0,b.jsx)(`th`,{children:`Role`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Last Active`})]})}),(0,b.jsxs)(`tbody`,{children:[(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Daniel Bast`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`daniel@bastsec.com`})]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:`default`,children:`Owner / Admin`})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`text-xs text-[var(--good)] font-medium`,children:`Active`})}),(0,b.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:`Just now`})]}),(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`div`,{className:`font-semibold text-foreground`,children:`Kifaru Security Bot`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`bot@kifaru.internal`})]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:`secondary`,children:`Automated Worker`})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(`span`,{className:`text-xs text-[var(--good)] font-medium`,children:`Active`})}),(0,b.jsx)(`td`,{className:`text-xs text-muted-foreground`,children:`Running scans`})]})]})]})})]})}function g6({label:e,value:t,detail:n}){return(0,b.jsxs)(h,{children:[(0,b.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:e}),(0,b.jsx)(`strong`,{className:`my-1 block text-[28px] font-bold tracking-[-0.02em]`,children:t}),(0,b.jsx)(`p`,{children:n})]})}function _6({findings:e}){let[t,n]=(0,y.useState)(4),r=Ex(t),i=Fx(e.filter(e=>e.stage===t));return(0,b.jsxs)(`div`,{className:`grid gap-6`,children:[(0,b.jsx)(Y3,{title:`Finding → data-lifecycle stage`}),(0,b.jsx)(Qx,{findings:e,selected:t,onSelect:n}),(0,b.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,b.jsx)(Vx,{title:`Stage ${r.n} · ${r.name}`,sub:`${i.length} finding${i.length===1?``:`s`}`,children:(0,b.jsx)(Zx,{findings:i,emptyLabel:`No open findings at this stage.`})}),(0,b.jsxs)(Vx,{title:`Control pillar × lifecycle stage`,sub:`cell = open findings`,children:[(0,b.jsx)($x,{findings:e,onSelectStage:n}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-4 text-xs font-medium`,style:{marginTop:12},children:[`critical`,`high`,`medium`,`low`].map(e=>(0,b.jsxs)(`span`,{children:[(0,b.jsx)(`i`,{className:`mcap`,style:{background:`var(${jx[e]})`}}),`worst: `,Mx[e]]},e))})]})]})]})}function v6({events:e,findings:t}){let n=Fx(t.filter(e=>e.status===`confirmed`||e.status===`unverified`)),[r,i]=(0,y.useState)(null),a=n.find(e=>e.id===r)??n[0]??null,o=tf({queryKey:[`finding`,a?.id],queryFn:()=>Cx.finding(a.id),enabled:!!a});return(0,b.jsxs)(`div`,{className:`grid gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`mb-0`,children:`Findings & evidence`}),(0,b.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every finding carries the evidence chain that produced it; every platform mutation is recorded below.`})]}),(0,b.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[300px_minmax(0,1fr)]`,children:[(0,b.jsxs)(`div`,{className:`bg-card overflow-hidden rounded-xl border [&_.ph]:text-muted-foreground [&_.ph]:border-b [&_.ph]:border-[var(--hair)] [&_.ph]:px-3.5 [&_.ph]:py-3 [&_.ph]:text-xs [&_.ph]:font-semibold`,children:[(0,b.jsx)(`div`,{className:`ph`,children:`Findings with evidence`}),n.length?n.map(e=>(0,b.jsxs)(`button`,{className:`block w-full border-0 border-b border-l-[3px] border-[var(--hair)] border-l-transparent bg-transparent px-3.5 py-2.5 text-left last:border-b-0 aria-pressed:border-l-primary aria-pressed:bg-[var(--accent-soft)] [&_.pt]:text-[13px] [&_.pt]:font-semibold`,type:`button`,"aria-pressed":e.id===a?.id,onClick:()=>i(e.id),children:[(0,b.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Mx[e.severity]}),(0,b.jsx)(`div`,{className:`pt`,children:e.title})]},e.id)):(0,b.jsx)(`div`,{style:{padding:`14px`},children:(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No findings have been ingested yet, so there is no evidence to audit.`})})]}),(0,b.jsx)(`div`,{children:a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mb-4 flex justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:`sevtag sev-${a.severity}`,children:Mx[a.severity]}),(0,b.jsx)(`span`,{className:`font-mono text-muted-foreground text-xs`,style:{marginLeft:8},children:a.id}),(0,b.jsx)(`h2`,{style:{marginTop:9},children:a.title})]}),(0,b.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:a.status.replaceAll(`_`,` `)})]}),(0,b.jsx)(`p`,{children:a.description}),(0,b.jsx)(eS,{items:[{k:`CVSS`,v:o.data?.finding.cvssScore??`—`},{k:`Weakness`,v:o.data?.finding.cwe??`—`,mono:!0},{k:`Category`,v:a.displayCategory},{k:`Lifecycle stage`,v:(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] [&_.d]:size-2 [&_.d]:rounded-[2px]`,children:[(0,b.jsx)(`span`,{className:`d`,style:{background:`var(${Ex(a.stage).v})`}}),a.stage,` · `,Dx(Ex(a.stage))]})}]}),(0,b.jsx)(tS,{title:`Evidence chain — provenance`,children:o.data?.finding.evidence.length?o.data.finding.evidence.map(e=>(0,b.jsx)(nS,{title:e.kind,detail:e.reason??`No reason recorded.`,verdict:e.verdict},e.id)):(0,b.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No evidence records attached to this finding.`})}),o.data?.finding.remediation?(0,b.jsx)(tS,{title:`Remediation`,children:(0,b.jsx)(`p`,{children:o.data.finding.remediation})}):null]}):(0,b.jsx)(l3,{compact:!0,title:`Nothing to audit yet`,detail:`Evidence appears once an agent reports a finding through report_finding.`})})]}),(0,b.jsx)(Vx,{surface:!1,title:`Governance ledger`,sub:`${e.length} recent event${e.length===1?``:`s`}`,children:e.length?(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`#`}),(0,b.jsx)(`th`,{children:`Action`}),(0,b.jsx)(`th`,{children:`Object`}),(0,b.jsx)(`th`,{children:`Actor`}),(0,b.jsx)(`th`,{children:`Outcome`}),(0,b.jsx)(`th`,{children:`Occurred`})]})}),(0,b.jsx)(`tbody`,{children:e.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`td`,{className:`font-mono`,children:e.sequence}),(0,b.jsx)(`td`,{children:e.action}),(0,b.jsxs)(`td`,{children:[e.objectType,` · `,(0,b.jsx)(`span`,{className:`font-mono`,children:e.objectID.slice(0,16)})]}),(0,b.jsx)(`td`,{className:`font-mono`,children:e.actorID??`—`}),(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:aS(e.outcome),children:e.outcome})}),(0,b.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()})]},e.id))})]})}):(0,b.jsx)(l3,{compact:!0,title:`No governance events`,detail:`Run creation, state transitions, tool calls and finding ingestion are all recorded here.`})})]})}function y6({runs:e}){return(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Assessment`}),(0,b.jsx)(`th`,{children:`Kind`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Updated`})]})}),(0,b.jsx)(`tbody`,{children:e.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`span`,{children:e.title}),(0,b.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.id})]}),(0,b.jsx)(`td`,{children:S6(e.kind)}),(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:aS(e.status),children:S6(e.status)})}),(0,b.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function b6({findings:e}){return(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,b.jsxs)(`table`,{children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{children:`Finding`}),(0,b.jsx)(`th`,{children:`Severity`}),(0,b.jsx)(`th`,{children:`Status`}),(0,b.jsx)(`th`,{children:`Asset`}),(0,b.jsx)(`th`,{children:`Updated`})]})}),(0,b.jsx)(`tbody`,{children:e.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{children:[(0,b.jsx)(`a`,{href:`/findings`,children:e.title}),(0,b.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.description??e.id})]}),(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:aS(e.severity),children:S6(e.severity)})}),(0,b.jsx)(`td`,{children:(0,b.jsx)(oS,{variant:aS(e.status),children:S6(e.status)})}),(0,b.jsx)(`td`,{children:e.path??`—`}),(0,b.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function x6(e){let t=new Map;for(let n of e){let e=n.path?.trim()||`Unscoped`,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()].map(([e,t])=>({asset:e,items:t})).sort((e,t)=>t.items.length-e.items.length)}function S6(e){return e.replaceAll(`_`,` `).replaceAll(`-`,` `).replace(/\b\w/g,e=>e.toUpperCase())}export{f6 as LiveWorkspaceIsland,u6 as PlatformRoute};