@njuptlzf/agent-chat-web 0.3.0 → 0.4.1

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.
@@ -1,50 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Dviy7gnB.js","assets/_commonjs-dynamic-modules-TDtrdbi3.js","assets/exceljs.min-jlEt4kSc.js"])))=>i.map(i=>d[i]);
2
- function lM(t,e){for(var n=0;n<e.length;n++){const i=e[n];if(typeof i!="string"&&!Array.isArray(i)){for(const a in i)if(a!=="default"&&!(a in t)){const o=Object.getOwnPropertyDescriptor(i,a);o&&Object.defineProperty(t,a,o.get?o:{enumerable:!0,get:()=>i[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const u of o.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var VV=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function $V(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function i(){var a=!1;try{a=this instanceof i}catch{}return a?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var a=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,a.get?a:{enumerable:!0,get:function(){return t[i]}})}),n}var Qh={exports:{}},Xo={};var O0;function uM(){if(O0)return Xo;O0=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(i,a,o){var u=null;if(o!==void 0&&(u=""+o),a.key!==void 0&&(u=""+a.key),"key"in a){o={};for(var d in a)d!=="key"&&(o[d]=a[d])}else o=a;return a=o.ref,{$$typeof:t,type:i,key:u,ref:a!==void 0?a:null,props:o}}return Xo.Fragment=e,Xo.jsx=n,Xo.jsxs=n,Xo}var D0;function cM(){return D0||(D0=1,Qh.exports=uM()),Qh.exports}var _=cM(),Kh={exports:{}},Jo={},Xh={exports:{}},Jh={};var j0;function dM(){return j0||(j0=1,(function(t){function e(ee,oe){var he=ee.length;ee.push(oe);e:for(;0<he;){var ye=he-1>>>1,D=ee[ye];if(0<a(D,oe))ee[ye]=oe,ee[he]=D,he=ye;else break e}}function n(ee){return ee.length===0?null:ee[0]}function i(ee){if(ee.length===0)return null;var oe=ee[0],he=ee.pop();if(he!==oe){ee[0]=he;e:for(var ye=0,D=ee.length,$=D>>>1;ye<$;){var re=2*(ye+1)-1,M=ee[re],N=re+1,te=ee[N];if(0>a(M,he))N<D&&0>a(te,M)?(ee[ye]=te,ee[N]=he,ye=N):(ee[ye]=M,ee[re]=he,ye=re);else if(N<D&&0>a(te,he))ee[ye]=te,ee[N]=he,ye=N;else break e}}return oe}function a(ee,oe){var he=ee.sortIndex-oe.sortIndex;return he!==0?he:ee.id-oe.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var u=Date,d=u.now();t.unstable_now=function(){return u.now()-d}}var f=[],p=[],m=1,y=null,v=3,b=!1,T=!1,w=!1,x=!1,E=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function O(ee){for(var oe=n(p);oe!==null;){if(oe.callback===null)i(p);else if(oe.startTime<=ee)i(p),oe.sortIndex=oe.expirationTime,e(f,oe);else break;oe=n(p)}}function L(ee){if(w=!1,O(ee),!T)if(n(f)!==null)T=!0,I||(I=!0,q());else{var oe=n(p);oe!==null&&Z(L,oe.startTime-ee)}}var I=!1,P=-1,k=5,H=-1;function V(){return x?!0:!(t.unstable_now()-H<k)}function z(){if(x=!1,I){var ee=t.unstable_now();H=ee;var oe=!0;try{e:{T=!1,w&&(w=!1,C(P),P=-1),b=!0;var he=v;try{t:{for(O(ee),y=n(f);y!==null&&!(y.expirationTime>ee&&V());){var ye=y.callback;if(typeof ye=="function"){y.callback=null,v=y.priorityLevel;var D=ye(y.expirationTime<=ee);if(ee=t.unstable_now(),typeof D=="function"){y.callback=D,O(ee),oe=!0;break t}y===n(f)&&i(f),O(ee)}else i(f);y=n(f)}if(y!==null)oe=!0;else{var $=n(p);$!==null&&Z(L,$.startTime-ee),oe=!1}}break e}finally{y=null,v=he,b=!1}oe=void 0}}finally{oe?q():I=!1}}}var q;if(typeof R=="function")q=function(){R(z)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,X=W.port2;W.port1.onmessage=z,q=function(){X.postMessage(null)}}else q=function(){E(z,0)};function Z(ee,oe){P=E(function(){ee(t.unstable_now())},oe)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(ee){ee.callback=null},t.unstable_forceFrameRate=function(ee){0>ee||125<ee?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):k=0<ee?Math.floor(1e3/ee):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(ee){switch(v){case 1:case 2:case 3:var oe=3;break;default:oe=v}var he=v;v=oe;try{return ee()}finally{v=he}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(ee,oe){switch(ee){case 1:case 2:case 3:case 4:case 5:break;default:ee=3}var he=v;v=ee;try{return oe()}finally{v=he}},t.unstable_scheduleCallback=function(ee,oe,he){var ye=t.unstable_now();switch(typeof he=="object"&&he!==null?(he=he.delay,he=typeof he=="number"&&0<he?ye+he:ye):he=ye,ee){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=he+D,ee={id:m++,callback:oe,priorityLevel:ee,startTime:he,expirationTime:D,sortIndex:-1},he>ye?(ee.sortIndex=he,e(p,ee),n(f)===null&&ee===n(p)&&(w?(C(P),P=-1):w=!0,Z(L,he-ye))):(ee.sortIndex=D,e(f,ee),T||b||(T=!0,I||(I=!0,q()))),ee},t.unstable_shouldYield=V,t.unstable_wrapCallback=function(ee){var oe=v;return function(){var he=v;v=oe;try{return ee.apply(this,arguments)}finally{v=he}}}})(Jh)),Jh}var z0;function fM(){return z0||(z0=1,Xh.exports=dM()),Xh.exports}var Zh={exports:{}},De={};var P0;function hM(){if(P0)return De;P0=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),v=Symbol.for("react.view_transition"),b=Symbol.iterator;function T(N){return N===null||typeof N!="object"?null:(N=b&&N[b]||N["@@iterator"],typeof N=="function"?N:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,E={};function C(N,te,ie){this.props=N,this.context=te,this.refs=E,this.updater=ie||w}C.prototype.isReactComponent={},C.prototype.setState=function(N,te){if(typeof N!="object"&&typeof N!="function"&&N!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,N,te,"setState")},C.prototype.forceUpdate=function(N){this.updater.enqueueForceUpdate(this,N,"forceUpdate")};function R(){}R.prototype=C.prototype;function O(N,te,ie){this.props=N,this.context=te,this.refs=E,this.updater=ie||w}var L=O.prototype=new R;L.constructor=O,x(L,C.prototype),L.isPureReactComponent=!0;var I=Array.isArray;function P(){}var k={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function V(N,te,ie){var pe=ie.ref;return{$$typeof:t,type:N,key:te,ref:pe!==void 0?pe:null,props:ie}}function z(N,te){return V(N.type,te,N.props)}function q(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function W(N){var te={"=":"=0",":":"=2"};return"$"+N.replace(/[=:]/g,function(ie){return te[ie]})}var X=/\/+/g;function Z(N,te){return typeof N=="object"&&N!==null&&N.key!=null?W(""+N.key):te.toString(36)}function ee(N){switch(N.status){case"fulfilled":return N.value;case"rejected":throw N.reason;default:switch(typeof N.status=="string"?N.then(P,P):(N.status="pending",N.then(function(te){N.status==="pending"&&(N.status="fulfilled",N.value=te)},function(te){N.status==="pending"&&(N.status="rejected",N.reason=te)})),N.status){case"fulfilled":return N.value;case"rejected":throw N.reason}}throw N}function oe(N,te,ie,pe,de){var B=typeof N;(B==="undefined"||B==="boolean")&&(N=null);var ce=!1;if(N===null)ce=!0;else switch(B){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(N.$$typeof){case t:case e:ce=!0;break;case m:return ce=N._init,oe(ce(N._payload),te,ie,pe,de)}}if(ce)return de=de(N),ce=pe===""?"."+Z(N,0):pe,I(de)?(ie="",ce!=null&&(ie=ce.replace(X,"$&/")+"/"),oe(de,te,ie,"",function(Oe){return Oe})):de!=null&&(q(de)&&(de=z(de,ie+(de.key==null||N&&N.key===de.key?"":(""+de.key).replace(X,"$&/")+"/")+ce)),te.push(de)),1;ce=0;var fe=pe===""?".":pe+":";if(I(N))for(var ge=0;ge<N.length;ge++)pe=N[ge],B=fe+Z(pe,ge),ce+=oe(pe,te,ie,B,de);else if(ge=T(N),typeof ge=="function")for(N=ge.call(N),ge=0;!(pe=N.next()).done;)pe=pe.value,B=fe+Z(pe,ge++),ce+=oe(pe,te,ie,B,de);else if(B==="object"){if(typeof N.then=="function")return oe(ee(N),te,ie,pe,de);throw te=String(N),Error("Objects are not valid as a React child (found: "+(te==="[object Object]"?"object with keys {"+Object.keys(N).join(", ")+"}":te)+"). If you meant to render a collection of children, use an array instead.")}return ce}function he(N,te,ie){if(N==null)return N;var pe=[],de=0;return oe(N,pe,"","",function(B){return te.call(ie,B,de++)}),pe}function ye(N){if(N._status===-1){var te=N._result,ie=te();ie.then(function(pe){(N._status===0||N._status===-1)&&(N._status=1,N._result=pe,ie.status===void 0&&(ie.status="fulfilled",ie.value=pe))},function(pe){(N._status===0||N._status===-1)&&(N._status=2,N._result=pe,ie.status===void 0&&(ie.status="rejected",ie.reason=pe))}),N._status===-1&&(N._status=0,N._result=ie)}if(N._status===1)return N._result.default;throw N._result}var D=typeof reportError=="function"?reportError:function(N){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var te=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof N=="object"&&N!==null&&typeof N.message=="string"?String(N.message):String(N),error:N});if(!window.dispatchEvent(te))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",N);return}console.error(N)};function $(N){var te=k.T,ie={};ie.types=te!==null?te.types:null,k.T=ie;try{var pe=N(),de=k.S;de!==null&&de(ie,pe),typeof pe=="object"&&pe!==null&&typeof pe.then=="function"&&pe.then(P,D)}catch(B){D(B)}finally{te!==null&&ie.types!==null&&(te.types=ie.types),k.T=te}}function re(N){var te=k.T;if(te!==null){var ie=te.types;ie===null?te.types=[N]:ie.indexOf(N)===-1&&ie.push(N)}else $(re.bind(null,N))}var M={map:he,forEach:function(N,te,ie){he(N,function(){te.apply(this,arguments)},ie)},count:function(N){var te=0;return he(N,function(){te++}),te},toArray:function(N){return he(N,function(te){return te})||[]},only:function(N){if(!q(N))throw Error("React.Children.only expected to receive a single React element child.");return N}};return De.Activity=y,De.Children=M,De.Component=C,De.Fragment=n,De.Profiler=a,De.PureComponent=O,De.StrictMode=i,De.Suspense=f,De.ViewTransition=v,De.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,De.__COMPILER_RUNTIME={__proto__:null,c:function(N){return k.H.useMemoCache(N)}},De.addTransitionType=re,De.cache=function(N){return function(){return N.apply(null,arguments)}},De.cacheSignal=function(){return null},De.cloneElement=function(N,te,ie){if(N==null)throw Error("The argument must be a React element, but you passed "+N+".");var pe=x({},N.props),de=N.key;if(te!=null)for(B in te.key!==void 0&&(de=""+te.key),te)!H.call(te,B)||B==="key"||B==="__self"||B==="__source"||B==="ref"&&te.ref===void 0||(pe[B]=te[B]);var B=arguments.length-2;if(B===1)pe.children=ie;else if(1<B){for(var ce=Array(B),fe=0;fe<B;fe++)ce[fe]=arguments[fe+2];pe.children=ce}return V(N.type,de,pe)},De.createContext=function(N){return N={$$typeof:u,_currentValue:N,_currentValue2:N,_threadCount:0,Provider:null,Consumer:null},N.Provider=N,N.Consumer={$$typeof:o,_context:N},N},De.createElement=function(N,te,ie){var pe,de={},B=null;if(te!=null)for(pe in te.key!==void 0&&(B=""+te.key),te)H.call(te,pe)&&pe!=="key"&&pe!=="__self"&&pe!=="__source"&&(de[pe]=te[pe]);var ce=arguments.length-2;if(ce===1)de.children=ie;else if(1<ce){for(var fe=Array(ce),ge=0;ge<ce;ge++)fe[ge]=arguments[ge+2];de.children=fe}if(N&&N.defaultProps)for(pe in ce=N.defaultProps,ce)de[pe]===void 0&&(de[pe]=ce[pe]);return V(N,B,de)},De.createRef=function(){return{current:null}},De.forwardRef=function(N){return{$$typeof:d,render:N}},De.isValidElement=q,De.lazy=function(N){return{$$typeof:m,_payload:{_status:-1,_result:N},_init:ye}},De.memo=function(N,te){return{$$typeof:p,type:N,compare:te===void 0?null:te}},De.startTransition=$,De.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},De.use=function(N){return k.H.use(N)},De.useActionState=function(N,te,ie){return k.H.useActionState(N,te,ie)},De.useCallback=function(N,te){return k.H.useCallback(N,te)},De.useContext=function(N){return k.H.useContext(N)},De.useDebugValue=function(){},De.useDeferredValue=function(N,te){return k.H.useDeferredValue(N,te)},De.useEffect=function(N,te){return k.H.useEffect(N,te)},De.useEffectEvent=function(N){return k.H.useEffectEvent(N)},De.useId=function(){return k.H.useId()},De.useImperativeHandle=function(N,te,ie){return k.H.useImperativeHandle(N,te,ie)},De.useInsertionEffect=function(N,te){return k.H.useInsertionEffect(N,te)},De.useLayoutEffect=function(N,te){return k.H.useLayoutEffect(N,te)},De.useMemo=function(N,te){return k.H.useMemo(N,te)},De.useOptimistic=function(N,te){return k.H.useOptimistic(N,te)},De.useReducer=function(N,te,ie){return k.H.useReducer(N,te,ie)},De.useRef=function(N){return k.H.useRef(N)},De.useState=function(N){return k.H.useState(N)},De.useSyncExternalStore=function(N,te,ie){return k.H.useSyncExternalStore(N,te,ie)},De.useTransition=function(){return k.H.useTransition()},De.version="19.3.1",De}var B0;function Qm(){return B0||(B0=1,Zh.exports=hM()),Zh.exports}var Wh={exports:{}},Yt={};var U0;function pM(){if(U0)return Yt;U0=1;var t=Qm();function e(m){var y="https://react.dev/errors/"+m;if(1<arguments.length){y+="?args[]="+encodeURIComponent(arguments[1]);for(var v=2;v<arguments.length;v++)y+="&args[]="+encodeURIComponent(arguments[v])}return"Minified React error #"+m+"; visit "+y+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var i={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal"),o=Symbol.for("react.recoverable"),u=Symbol.for("react.optimistic_key");function d(m,y,v){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:b==null?null:b===u?u:""+b,children:m,containerInfo:y,implementation:v}}var f=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(m,y){if(m==="font")return"";if(typeof y=="string")return y==="use-credentials"?y:""}return Yt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Yt.browser=function(m){return{$$typeof:o,_reason:m}},Yt.createPortal=function(m,y){var v=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!y||y.nodeType!==1&&y.nodeType!==9&&y.nodeType!==11)throw Error(e(299));return d(m,y,null,v)},Yt.flushSync=function(m){var y=f.T,v=i.p;try{if(f.T=null,i.p=2,m)return m()}finally{f.T=y,i.p=v,i.d.f()}},Yt.preconnect=function(m,y){typeof m=="string"&&(y?(y=y.crossOrigin,y=typeof y=="string"?y==="use-credentials"?y:"":void 0):y=null,i.d.C(m,y))},Yt.prefetchDNS=function(m){typeof m=="string"&&i.d.D(m)},Yt.preinit=function(m,y){if(typeof m=="string"&&y&&typeof y.as=="string"){var v=y.as,b=p(v,y.crossOrigin),T=typeof y.integrity=="string"?y.integrity:void 0,w=typeof y.fetchPriority=="string"?y.fetchPriority:void 0;v==="style"?i.d.S(m,typeof y.precedence=="string"?y.precedence:void 0,{crossOrigin:b,integrity:T,fetchPriority:w}):v==="script"&&i.d.X(m,{crossOrigin:b,integrity:T,fetchPriority:w,nonce:typeof y.nonce=="string"?y.nonce:void 0})}},Yt.preinitModule=function(m,y){if(typeof m=="string")if(typeof y=="object"&&y!==null){if(y.as==null||y.as==="script"){var v=p(y.as,y.crossOrigin);i.d.M(m,{crossOrigin:v,integrity:typeof y.integrity=="string"?y.integrity:void 0,nonce:typeof y.nonce=="string"?y.nonce:void 0,fetchPriority:typeof y.fetchPriority=="string"?y.fetchPriority:void 0})}}else y==null&&i.d.M(m)},Yt.preload=function(m,y){if(typeof m=="string"&&typeof y=="object"&&y!==null&&typeof y.as=="string"){var v=y.as,b=p(v,y.crossOrigin);i.d.L(m,v,{crossOrigin:b,integrity:typeof y.integrity=="string"?y.integrity:void 0,nonce:typeof y.nonce=="string"?y.nonce:void 0,type:typeof y.type=="string"?y.type:void 0,fetchPriority:typeof y.fetchPriority=="string"?y.fetchPriority:void 0,referrerPolicy:typeof y.referrerPolicy=="string"?y.referrerPolicy:void 0,imageSrcSet:typeof y.imageSrcSet=="string"?y.imageSrcSet:void 0,imageSizes:typeof y.imageSizes=="string"?y.imageSizes:void 0,media:typeof y.media=="string"?y.media:void 0})}},Yt.preloadModule=function(m,y){if(typeof m=="string")if(y){var v=p(y.as,y.crossOrigin);i.d.m(m,{as:typeof y.as=="string"&&y.as!=="script"?y.as:void 0,crossOrigin:v,integrity:typeof y.integrity=="string"?y.integrity:void 0,nonce:typeof y.nonce=="string"?y.nonce:void 0,fetchPriority:typeof y.fetchPriority=="string"?y.fetchPriority:void 0})}else i.d.m(m)},Yt.requestFormReset=function(m){i.d.r(m)},Yt.unstable_batchedUpdates=function(m,y){return m(y)},Yt.useFormState=function(m,y,v){return f.H.useFormState(m,y,v)},Yt.useFormStatus=function(){return f.H.useHostTransitionStatus()},Yt.version="19.3.1",Yt}var L0;function YT(){if(L0)return Wh.exports;L0=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Wh.exports=pM(),Wh.exports}var q0;function mM(){if(q0)return Jo;q0=1;var t=fM(),e=Qm(),n=YT();function i(s){var r="https://react.dev/errors/"+s;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+s+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function o(s){for(var r=s,l=r;l&&!l.alternate;)r=l,(r.flags&4098)!==0&&(s=r.return),l=r.return;for(;r.return;)r=r.return;return r.tag===3?s:null}function u(s){if(s.tag===13){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function d(s){if(s.tag===31){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function f(s){if(o(s)!==s)throw Error(i(188))}function p(s){var r=s.alternate;if(!r){if(r=o(s),r===null)throw Error(i(188));return r!==s?null:s}for(var l=s,c=r;;){var h=l.return;if(h===null)break;var g=h.alternate;if(g===null){if(c=h.return,c!==null){l=c;continue}break}if(h.child===g.child){for(g=h.child;g;){if(g===l)return f(h),s;if(g===c)return f(h),r;g=g.sibling}throw Error(i(188))}if(l.return!==c.return)l=h,c=g;else{for(var S=!1,A=h.child;A;){if(A===l){S=!0,l=h,c=g;break}if(A===c){S=!0,c=h,l=g;break}A=A.sibling}if(!S){for(A=g.child;A;){if(A===l){S=!0,l=g,c=h;break}if(A===c){S=!0,c=g,l=h;break}A=A.sibling}if(!S)throw Error(i(189))}}if(l.alternate!==c)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?s:r}function m(s){var r=s.tag;if(r===5||r===26||r===27||r===6)return s;for(s=s.child;s!==null;){if(r=m(s),r!==null)return r;s=s.sibling}return null}function y(s,r,l,c,h,g){for(;s!==null;){if((s.tag===5||s.tag===27||s.tag===6)&&l(s,c,h,g)||(s.tag!==22||s.memoizedState===null)&&(r||s.tag!==5&&s.tag!==27)&&y(s.child,r,l,c,h,g))return!0;s=s.sibling}return!1}function v(s){for(s=s.return;s!==null;){if(s.tag===3||s.tag===5||s.tag===27)return s;s=s.return}return null}function b(s){var r=!1;for(s=s.return;s!==null&&(s.tag===4&&(r=!0),!(s.tag===3||s.tag===5||s.tag===27));)s=s.return;return r}function T(s){var r=[null,null],l=v(s);return l===null||w(r,s,l.child,{foundSelf:!1}),r}function w(s,r,l,c){for(;l!==null;){if(l===r)c.foundSelf=!0;else if(l.tag===5||l.tag===27||l.tag===6){if(c.foundSelf)return s[1]=l,!0;s[0]=l}else if((l.tag!==22||l.memoizedState===null)&&w(s,r,l.child,c))return!0;l=l.sibling}return!1}function x(s){switch(s.tag){case 5:case 27:case 6:return s.stateNode;case 3:return s.stateNode.containerInfo;default:throw Error(i(559))}}var E=null,C=null;function R(s,r,l){return s===l?!0:s===r?(E=s,!0):!1}function O(s,r,l){return s===l?(C=s,!1):s===r?(C!==null&&(E=s),!0):!1}function L(s){if(s===null)return null;do s=s===null?null:s.return;while(s&&s.tag!==5&&s.tag!==27&&s.tag!==3);return s||null}function I(s,r,l){for(var c=0,h=s;h;h=l(h))c++;h=0;for(var g=r;g;g=l(g))h++;for(;0<c-h;)s=l(s),c--;for(;0<h-c;)r=l(r),h--;for(;c--;){if(s===r||r!==null&&s===r.alternate)return s;s=l(s),r=l(r)}return null}var P=Object.assign,k=Symbol.for("react.element"),H=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),z=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),X=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),he=Symbol.for("react.suspense_list"),ye=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),$=Symbol.for("react.activity"),re=Symbol.for("react.legacy_hidden"),M=Symbol.for("react.memo_cache_sentinel"),N=Symbol.for("react.view_transition"),te=Symbol.for("react.recoverable"),ie=Symbol.iterator;function pe(s){return s===null||typeof s!="object"?null:(s=ie&&s[ie]||s["@@iterator"],typeof s=="function"?s:null)}var de=Symbol.for("react.client.reference");function B(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===de?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case z:return"Fragment";case W:return"Profiler";case q:return"StrictMode";case oe:return"Suspense";case he:return"SuspenseList";case $:return"Activity";case N:return"ViewTransition"}if(typeof s=="object")switch(s.$$typeof){case V:return"Portal";case Z:return s.displayName||"Context";case X:return(s._context.displayName||"Context")+".Consumer";case ee:var r=s.render;return s=s.displayName,s||(s=r.displayName||r.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ye:return r=s.displayName||null,r!==null?r:B(s.type)||"Memo";case D:r=s._payload,s=s._init;try{return B(s(r))}catch{}}return null}var ce=Array.isArray,fe=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Oe={pending:!1,data:null,method:null,action:null},Pe=[],$e=-1;function ve(s){return{current:s}}function Ae(s){0>$e||(s.current=Pe[$e],Pe[$e]=null,$e--)}function Ie(s,r){$e++,Pe[$e]=s.current,s.current=r}var ct=ve(null),Wt=ve(null),Ot=ve(null),Pr=ve(null);function Br(s,r){switch(Ie(Ot,r),Ie(Wt,s),Ie(ct,null),r.nodeType){case 9:case 11:s=(s=r.documentElement)&&(s=s.namespaceURI)?H_(s):0;break;default:if(s=r.tagName,r=r.namespaceURI)r=H_(r),s=V_(r,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}Ae(ct),Ie(ct,s)}function oi(){Ae(ct),Ae(Wt),Ae(Ot)}function to(s){var r=s.memoizedState;r!==null&&(Ea._currentValue=r.memoizedState,Ie(Pr,s)),r=ct.current;var l=V_(r,s.type);r!==l&&(Ie(Wt,s),Ie(ct,l))}function Ur(s){Wt.current===s&&(Ae(ct),Ae(Wt)),Pr.current===s&&(Ae(Pr),Ea._currentValue=Oe)}var ae,_e;function Re(s){if(ae===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ae=r&&r[1]||"",_e=-1<l.stack.indexOf(`
3
- at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
4
- `+ae+s+_e}var Be=!1;function Dt(s,r){if(!s||Be)return"";Be=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(Se){var G=Se}Reflect.construct(s,[],ue)}else{try{ue.call()}catch(Se){G=Se}ue=!1;try{var J=Object.getOwnPropertyDescriptor(s.prototype,"props");Object.defineProperty(s.prototype,"props",{configurable:!0,set:function(){throw Error()}}),ue=!0,new s}finally{ue&&(J!==void 0?Object.defineProperty(s.prototype,"props",J):delete s.prototype.props)}}}else{try{throw Error()}catch(Se){G=Se}(ue=s())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(Se){if(Se&&G&&typeof Se.stack=="string")return[Se.stack,G.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var h=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");h&&h.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),S=g[0],A=g[1];if(S&&A){var j=S.split(`
5
- `),Y=A.split(`
6
- `);for(h=c=0;c<j.length&&!j[c].includes("DetermineComponentFrameRoot");)c++;for(;h<Y.length&&!Y[h].includes("DetermineComponentFrameRoot");)h++;if(c===j.length||h===Y.length)for(c=j.length-1,h=Y.length-1;1<=c&&0<=h&&j[c]!==Y[h];)h--;for(;1<=c&&0<=h;c--,h--)if(j[c]!==Y[h]){if(c!==1||h!==1)do if(c--,h--,0>h||j[c]!==Y[h]){var ne=`
7
- `+j[c].replace(" at new "," at ");return s.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",s.displayName)),ne}while(1<=c&&0<=h);break}}}finally{Be=!1,Error.prepareStackTrace=l}return(l=s?s.displayName||s.name:"")?Re(l):""}function rt(s,r){switch(s.tag){case 26:case 27:case 5:return Re(s.type);case 16:return Re("Lazy");case 13:return s.child!==r&&r!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("SuspenseList");case 0:case 15:return Dt(s.type,!1);case 11:return Dt(s.type.render,!1);case 1:return Dt(s.type,!0);case 31:return Re("Activity");case 30:return Re("ViewTransition");default:return""}}function Ut(s){try{var r="",l=null;do r+=rt(s,l),l=s,s=s.return;while(s);return r}catch(c){return`
8
- Error generating stack: `+c.message+`
9
- `+c.stack}}var dn=Object.prototype.hasOwnProperty,Ds=t.unstable_scheduleCallback,js=t.unstable_cancelCallback,Gi=t.unstable_shouldYield,jl=t.unstable_requestPaint,Lt=t.unstable_now,en=t.unstable_getCurrentPriorityLevel,zs=t.unstable_ImmediatePriority,Un=t.unstable_UserBlockingPriority,zl=t.unstable_NormalPriority,g2=t.unstable_LowPriority,hy=t.unstable_IdlePriority,y2=t.log,v2=t.unstable_setDisableYieldValue,no=null,wn=null;function li(s){if(typeof y2=="function"&&v2(s),wn&&typeof wn.setStrictMode=="function")try{wn.setStrictMode(no,s)}catch{}}var xn=Math.clz32?Math.clz32:S2,b2=Math.log,_2=Math.LN2;function S2(s){return s>>>=0,s===0?32:31-(b2(s)/_2|0)|0}var Pl=256,Bl=262144,Ul=4194304;function Fi(s){var r=s&42;if(r!==0)return r;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&-s;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ll(s,r,l){var c=s.pendingLanes;if(c===0)return 0;var h=0,g=s.suspendedLanes,S=s.pingedLanes;s=s.warmLanes;var A=c&134217727;return A!==0?(c=A&~g,c!==0?h=Fi(c):(S&=A,S!==0?h=Fi(S):l||(l=A&~s,l!==0&&(h=Fi(l))))):(A=c&~g,A!==0?h=Fi(A):S!==0?h=Fi(S):l||(l=c&~s,l!==0&&(h=Fi(l)))),h===0?0:r!==0&&r!==h&&(r&g)===0&&(g=h&-h,l=r&-r,g>=l||g===32&&(l&4194048)!==0)?r:h}function so(s,r){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&r)===0}function py(s,r){(r&8)!==0&&(r|=r&32);var l=s.entangledLanes;if(l!==0)for(s=s.entanglements,l&=r;0<l;){var c=31-xn(l),h=1<<c;r|=s[c],l&=~h}return r}function T2(s,r){switch(s){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function my(){var s=Ul;return Ul<<=1,(Ul&62914560)===0&&(Ul=4194304),s}function _d(s){for(var r=[],l=0;31>l;l++)r.push(s);return r}function io(s,r){s.pendingLanes|=r,r!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function w2(s,r,l,c,h,g){var S=s.pendingLanes;s.pendingLanes=l,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=l,s.entangledLanes&=l,s.errorRecoveryDisabledLanes&=l,s.shellSuspendCounter=0;var A=s.entanglements,j=s.expirationTimes,Y=s.hiddenUpdates;for(l=S&~l;0<l;){var ne=31-xn(l),ue=1<<ne;A[ne]=0,j[ne]=-1;var G=Y[ne];if(G!==null)for(Y[ne]=null,ne=0;ne<G.length;ne++){var J=G[ne];J!==null&&(J.lane&=-536870913)}l&=~ue}c!==0&&gy(s,c,0),g!==0&&h===0&&s.tag!==0&&(s.suspendedLanes|=g&~(S&~r))}function gy(s,r,l){s.pendingLanes|=r,s.suspendedLanes&=~r;var c=31-xn(r);s.entangledLanes|=r,s.entanglements[c]=s.entanglements[c]|1073741824|l&261930}function yy(s,r){var l=s.entangledLanes|=r;for(s=s.entanglements;l;){var c=31-xn(l),h=1<<c;h&r|s[c]&r&&(s[c]|=r),l&=~h}}function vy(s,r){var l=r&-r;return l=(l&42)!==0?1:Sd(l),(l&(s.suspendedLanes|r))!==0?0:l}function Sd(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function Td(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function by(){var s=ge.p;return s!==0?s:(s=window.event,s===void 0?32:E0(s.type))}function _y(s,r){var l=ge.p;try{return ge.p=s,r()}finally{ge.p=l}}var Ps=Math.random().toString(36).slice(2),qt="__reactFiber$"+Ps,fn="__reactProps$"+Ps,Lr="__reactContainer$"+Ps,Sy="__reactEvents$"+Ps,x2="__reactListeners$"+Ps,C2="__reactHandles$"+Ps,Ty="__reactResources$"+Ps,ro="__reactMarker$"+Ps,ql="__reactLoad$"+Ps;function Hl(s){delete s[qt],delete s[fn],delete s[x2],delete s[C2]}function Yi(s){var r;if(r=s[qt])return r;for(var l=s.parentNode;l;){if(r=l[Lr]||l[qt]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(s=a0(s);s!==null;){if(l=s[qt])return l;s=a0(s)}return r}s=l,l=s.parentNode}return null}function qr(s){if(s=s[qt]||s[Lr]){var r=s.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return s}return null}function ao(s){var r=s.tag;if(r===5||r===26||r===27||r===6)return s.stateNode;throw Error(i(33))}function Hr(s){var r=s[Ty];return r||(r=s[Ty]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function jt(s){s[ro]=!0}function wy(s){s[ql]=void 0}var xy=new Set,Cy={};function Qi(s,r){Vr(s,r),Vr(s+"Capture",r)}function Vr(s,r){for(Cy[s]=r,s=0;s<r.length;s++)xy.add(r[s])}var E2=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ey={},Ay={};function A2(s){return dn.call(Ay,s)?!0:dn.call(Ey,s)?!1:E2.test(s)?Ay[s]=!0:(Ey[s]=!0,!1)}var Xe=!1;function Iy(){var s=Xe;return Xe=!1,s}function Vl(s,r,l){if(A2(r))if(l===null)s.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":s.removeAttribute(r);return;case"boolean":var c=r.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){s.removeAttribute(r);return}}s.setAttribute(r,l)}}function $l(s,r,l){if(l===null)s.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(r);return}s.setAttribute(r,l)}}function Bs(s,r,l,c){if(c===null)s.removeAttribute(l);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(l);return}s.setAttributeNS(r,l,c)}}function Cn(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Ry(s){var r=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function I2(s,r,l){var c=Object.getOwnPropertyDescriptor(s.constructor.prototype,r);if(!s.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var h=c.get,g=c.set;return Object.defineProperty(s,r,{configurable:!0,get:function(){return h.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(s,r,{enumerable:c.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){s._valueTracker=null,delete s[r]}}}}function wd(s){if(!s._valueTracker){var r=Ry(s)?"checked":"value";s._valueTracker=I2(s,r,""+s[r])}}function My(s){if(!s)return!1;var r=s._valueTracker;if(!r)return!0;var l=r.getValue(),c="";return s&&(c=Ry(s)?s.checked?"true":"false":s.value),s=c,s!==l?(r.setValue(s),!0):!1}var R2=/[\n"\\]/g;function Ln(s){return s.replace(R2,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function xd(s,r,l,c,h,g,S,A){s.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?s.type=S:s.removeAttribute("type"),r!=null?S==="number"?(r===0&&s.value===""||s.value!=r)&&(s.value=""+Cn(r)):s.value!==""+Cn(r)&&(s.value=""+Cn(r)):S!=="submit"&&S!=="reset"||s.removeAttribute("value"),r!=null?S==="number"&&s.value==r?Cd(s,Cn(s.value)):Cd(s,Cn(r)):l!=null?Cd(s,Cn(l)):c!=null&&s.removeAttribute("value"),h==null&&g!=null&&(s.defaultChecked=!!g),h!=null&&(s.checked=h&&typeof h!="function"&&typeof h!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?s.name=""+Cn(A):s.removeAttribute("name")}function ky(s,r,l,c,h,g,S,A){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(s.type=g),r!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){wd(s);return}l=l!=null?""+Cn(l):"",r=r!=null?""+Cn(r):l,A||r===s.value||(s.value=r),s.defaultValue=r}c=c??h,c=typeof c!="function"&&typeof c!="symbol"&&!!c,s.checked=A?s.checked:!!c,s.defaultChecked=!!c,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(s.name=S),wd(s)}function Cd(s,r){s.defaultValue!==""+r&&(s.defaultValue=""+r)}function $r(s,r,l,c){if(s=s.options,r){r={};for(var h=0;h<l.length;h++)r["$"+l[h]]=!0;for(l=0;l<s.length;l++)h=r.hasOwnProperty("$"+s[l].value),s[l].selected!==h&&(s[l].selected=h),h&&c&&(s[l].defaultSelected=!0)}else{for(l=""+Cn(l),r=null,h=0;h<s.length;h++){if(s[h].value===l){s[h].selected=!0,c&&(s[h].defaultSelected=!0);return}r!==null||s[h].disabled||(r=s[h])}r!==null&&(r.selected=!0)}}function Ny(s,r,l){if(r!=null&&(r=""+Cn(r),r!==s.value&&(s.value=r),l==null)){s.defaultValue!==r&&(s.defaultValue=r);return}s.defaultValue=l!=null?""+Cn(l):""}function Oy(s,r,l,c){if(r==null){if(c!=null){if(l!=null)throw Error(i(92));if(ce(c)){if(1<c.length)throw Error(i(93));c=c[0]}l=c}l==null&&(l=""),r=l}l=Cn(r),s.defaultValue=l,c=s.textContent,c===l&&c!==""&&c!==null&&(s.value=c),wd(s)}function Gr(s,r){if(r){var l=s.firstChild;if(l&&l===s.lastChild&&l.nodeType===3){l.nodeValue=r;return}}s.textContent=r}var M2=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Dy(s,r,l){var c=r.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?c?s.setProperty(r,""):r==="float"?s.cssFloat="":s[r]="":c?s.setProperty(r,l):typeof l!="number"||l===0||M2.has(r)?r==="float"?s.cssFloat=l:s[r]=(""+l).trim():s[r]=l+"px"}function jy(s,r,l){if(r!=null&&typeof r!="object")throw Error(i(62));if(s=s.style,l!=null){for(var c in l)!l.hasOwnProperty(c)||r!=null&&r.hasOwnProperty(c)||(c.indexOf("--")===0?s.setProperty(c,""):c==="float"?s.cssFloat="":s[c]="",Xe=!0);for(var h in r)c=r[h],r.hasOwnProperty(h)&&l[h]!==c&&(Dy(s,h,c),Xe=!0)}else for(var g in r)r.hasOwnProperty(g)&&Dy(s,g,r[g])}function Ed(s){if(s.indexOf("-")===-1)return!1;switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var k2=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["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"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["maskType","mask-type"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["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"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["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"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),N2=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Gl(s){return N2.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function ms(){}var Ad=null;function Id(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Fr=null,Yr=null;function zy(s){var r=qr(s);if(r&&(s=r.stateNode)){var l=s[fn]||null;e:switch(s=r.stateNode,r.type){case"input":if(xd(s,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),r=l.name,l.type==="radio"&&r!=null){for(l=s;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Ln(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var c=l[r];if(c!==s&&c.form===s.form){var h=c[fn]||null;if(!h)throw Error(i(90));xd(c,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(r=0;r<l.length;r++)c=l[r],c.form===s.form&&My(c)}break e;case"textarea":Ny(s,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&$r(s,!!l.multiple,r,!1)}}}var Rd=!1;function Py(s,r,l){if(Rd)return s(r,l);Rd=!0;try{var c=s(r);return c}finally{if(Rd=!1,(Fr!==null||Yr!==null)&&(Gu(),Fr&&(r=Fr,s=Yr,Yr=Fr=null,zy(r),s)))for(r=0;r<s.length;r++)zy(s[r])}}function oo(s,r){var l=s.stateNode;if(l===null)return null;var c=l[fn]||null;if(c===null)return null;l=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(s=s.type,c=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!c;break e;default:s=!1}if(s)return null;if(l&&typeof l!="function")throw Error(i(231,r,typeof l));return l}var Us=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Md=!1;if(Us)try{var lo={};Object.defineProperty(lo,"passive",{get:function(){Md=!0}}),window.addEventListener("test",lo,lo),window.removeEventListener("test",lo,lo)}catch{Md=!1}var ui=null,kd=null,Fl=null;function By(){if(Fl)return Fl;var s,r=kd,l=r.length,c,h="value"in ui?ui.value:ui.textContent,g=h.length;for(s=0;s<l&&r[s]===h[s];s++);var S=l-s;for(c=1;c<=S&&r[l-c]===h[g-c];c++);return Fl=h.slice(s,1<c?1-c:void 0)}function Yl(s){var r=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&r===13&&(s=13)):s=r,s===10&&(s=13),32<=s||s===13?s:0}function Ql(){return!0}function Uy(){return!1}function tn(s){function r(l,c,h,g,S){this._reactName=l,this._targetInst=h,this.type=c,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var A in s)s.hasOwnProperty(A)&&(l=s[A],this[A]=l?l(g):g[A]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Ql:Uy,this.isPropagationStopped=Uy,this}return P(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Ql)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Ql)},persist:function(){},isPersistent:Ql}),r}var ci={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Kl=tn(ci),uo=P({},ci,{view:0,detail:0}),O2=tn(uo),Nd,Od,co,Xl=P({},uo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jd,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==co&&(co&&s.type==="mousemove"?(Nd=s.screenX-co.screenX,Od=s.screenY-co.screenY):Od=Nd=0,co=s),Nd)},movementY:function(s){return"movementY"in s?s.movementY:Od}}),Ly=tn(Xl),D2=P({},Xl,{dataTransfer:0}),j2=tn(D2),z2=P({},uo,{relatedTarget:0}),Dd=tn(z2),P2=P({},ci,{animationName:0,elapsedTime:0,pseudoElement:0}),B2=tn(P2),U2=P({},ci,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),L2=tn(U2),q2=P({},ci,{data:0}),qy=tn(q2),H2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},V2={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},$2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function G2(s){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(s):(s=$2[s])?!!r[s]:!1}function jd(){return G2}var F2=P({},uo,{key:function(s){if(s.key){var r=H2[s.key]||s.key;if(r!=="Unidentified")return r}return s.type==="keypress"?(s=Yl(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?V2[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jd,charCode:function(s){return s.type==="keypress"?Yl(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Yl(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Y2=tn(F2),Q2=P({},Xl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hy=tn(Q2),K2=P({},ci,{submitter:0}),X2=tn(K2),J2=P({},uo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jd}),Z2=tn(J2),W2=P({},ci,{propertyName:0,elapsedTime:0,pseudoElement:0}),eI=tn(W2),tI=P({},Xl,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),nI=tn(tI),sI=P({},ci,{newState:0,oldState:0,source:0}),iI=tn(sI),rI=[9,13,27,32],zd=Us&&"CompositionEvent"in window,fo=null;Us&&"documentMode"in document&&(fo=document.documentMode);var aI=Us&&"TextEvent"in window&&!fo,Vy=Us&&(!zd||fo&&8<fo&&11>=fo),$y=" ",Gy=!1;function Fy(s,r){switch(s){case"keyup":return rI.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yy(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Qr=!1;function oI(s,r){switch(s){case"compositionend":return Yy(r);case"keypress":return r.which!==32?null:(Gy=!0,$y);case"textInput":return s=r.data,s===$y&&Gy?null:s;default:return null}}function lI(s,r){if(Qr)return s==="compositionend"||!zd&&Fy(s,r)?(s=By(),Fl=kd=ui=null,Qr=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Vy&&r.locale!=="ko"?null:r.data;default:return null}}var uI={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Qy(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r==="input"?!!uI[s.type]:r==="textarea"}function Ky(s,r,l,c){Fr?Yr?Yr.push(c):Yr=[c]:Fr=c,r=Ju(r,"onChange"),0<r.length&&(l=new Kl("onChange","change",null,l,c),s.push({event:l,listeners:r}))}var ho=null,po=null;function cI(s){z_(s,0)}function Jl(s){var r=ao(s);if(My(r))return s}function Xy(s,r){if(s==="change")return r}var Jy=!1;if(Us){var Pd;if(Us){var Bd="oninput"in document;if(!Bd){var Zy=document.createElement("div");Zy.setAttribute("oninput","return;"),Bd=typeof Zy.oninput=="function"}Pd=Bd}else Pd=!1;Jy=Pd&&(!document.documentMode||9<document.documentMode)}function Wy(){ho&&(ho.detachEvent("onpropertychange",ev),po=ho=null)}function ev(s){if(s.propertyName==="value"&&Jl(po)){var r=[];Ky(r,po,s,Id(s)),Py(cI,r)}}function dI(s,r,l){s==="focusin"?(Wy(),ho=r,po=l,ho.attachEvent("onpropertychange",ev)):s==="focusout"&&Wy()}function fI(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Jl(po)}function hI(s,r){if(s==="click")return Jl(r)}function pI(s,r){if(s==="input"||s==="change")return Jl(r)}function mI(s,r){return s===r&&(s!==0||1/s===1/r)||s!==s&&r!==r}var En=typeof Object.is=="function"?Object.is:mI;function mo(s,r){if(En(s,r))return!0;if(typeof s!="object"||s===null||typeof r!="object"||r===null)return!1;var l=Object.keys(s),c=Object.keys(r);if(l.length!==c.length)return!1;for(c=0;c<l.length;c++){var h=l[c];if(!dn.call(r,h)||!En(s[h],r[h]))return!1}return!0}function Ud(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function tv(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function nv(s,r){var l=tv(s);s=0;for(var c;l;){if(l.nodeType===3){if(c=s+l.textContent.length,s<=r&&c>=r)return{node:l,offset:r-s};s=c}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=tv(l)}}function sv(s,r){return s&&r?s===r?!0:s&&s.nodeType===3?!1:r&&r.nodeType===3?sv(s,r.parentNode):"contains"in s?s.contains(r):s.compareDocumentPosition?!!(s.compareDocumentPosition(r)&16):!1:!1}function iv(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var r=Ud(s.document);r instanceof s.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)s=r.contentWindow;else break;r=Ud(s.document)}return r}function Ld(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r&&(r==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||r==="textarea"||s.contentEditable==="true")}var gI=Us&&"documentMode"in document&&11>=document.documentMode,Kr=null,qd=null,go=null,Hd=!1;function rv(s,r,l){var c=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Hd||Kr==null||Kr!==Ud(c)||(c=Kr,"selectionStart"in c&&Ld(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),go&&mo(go,c)||(go=c,c=Ju(qd,"onSelect"),0<c.length&&(r=new Kl("onSelect","select",null,r,l),s.push({event:r,listeners:c}),r.target=Kr)))}function Ki(s,r){var l={};return l[s.toLowerCase()]=r.toLowerCase(),l["Webkit"+s]="webkit"+r,l["Moz"+s]="moz"+r,l}var Xr={animationend:Ki("Animation","AnimationEnd"),animationiteration:Ki("Animation","AnimationIteration"),animationstart:Ki("Animation","AnimationStart"),transitionrun:Ki("Transition","TransitionRun"),transitionstart:Ki("Transition","TransitionStart"),transitioncancel:Ki("Transition","TransitionCancel"),transitionend:Ki("Transition","TransitionEnd")},Vd={},av={};Us&&(av=document.createElement("div").style,"AnimationEvent"in window||(delete Xr.animationend.animation,delete Xr.animationiteration.animation,delete Xr.animationstart.animation),"TransitionEvent"in window||delete Xr.transitionend.transition);function Xi(s){if(Vd[s])return Vd[s];if(!Xr[s])return s;var r=Xr[s],l;for(l in r)if(r.hasOwnProperty(l)&&l in av)return Vd[s]=r[l];return s}var ov=Xi("animationend"),lv=Xi("animationiteration"),uv=Xi("animationstart"),yI=Xi("transitionrun"),vI=Xi("transitionstart"),bI=Xi("transitioncancel"),cv=Xi("transitionend"),dv=new Map,$d="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");$d.push("scrollEnd");function ss(s,r){dv.set(s,r),Qi(r,[s])}var _I=0;function Ls(s,r){if(s.name!=null&&s.name!=="auto")return s.name;if(r.autoName!==null)return r.autoName;s=os.identifierPrefix;var l=_I++;return s="_"+s+"t_"+l.toString(32)+"_",r.autoName=s}function fv(s){if(s==null||typeof s=="string")return s;var r=null,l=ga;if(l!==null)for(var c=0;c<l.length;c++){var h=s[l[c]];if(h!=null){if(h==="none")return"none";r=r==null?h:r+(" "+h)}}return r??s.default}function qs(s,r){return s=fv(s),r=fv(r),r==null?s==="auto"?null:s:r==="auto"?null:r}var Zl=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},qn=[],Jr=0,Gd=0;function Wl(){for(var s=Jr,r=Gd=Jr=0;r<s;){var l=qn[r];qn[r++]=null;var c=qn[r];qn[r++]=null;var h=qn[r];qn[r++]=null;var g=qn[r];if(qn[r++]=null,c!==null&&h!==null){var S=c.pending;S===null?h.next=h:(h.next=S.next,S.next=h),c.pending=h}g!==0&&hv(l,h,g)}}function eu(s,r,l,c){qn[Jr++]=s,qn[Jr++]=r,qn[Jr++]=l,qn[Jr++]=c,Gd|=c,s.lanes|=c,s=s.alternate,s!==null&&(s.lanes|=c)}function Fd(s,r,l,c){return eu(s,r,l,c),tu(s)}function Ji(s,r){return eu(s,null,null,r),tu(s)}function hv(s,r,l){s.lanes|=l;var c=s.alternate;c!==null&&(c.lanes|=l);for(var h=!1,g=s.return;g!==null;)g.childLanes|=l,c=g.alternate,c!==null&&(c.childLanes|=l),g.tag===22&&(s=g.stateNode,s===null||s._visibility&1||(h=!0)),s=g,g=g.return;return s.tag===3?(g=s.stateNode,h&&r!==null&&(h=31-xn(l),s=g.hiddenUpdates,c=s[h],c===null?s[h]=[r]:c.push(r),r.lane=l|536870912),g):null}function tu(s){if(50<Bo)throw Bo=0,$u=null,Error(i(185));for(var r=s.return;r!==null;)s=r,r=s.return;return s.tag===3?s.stateNode:null}var Zr={};function SI(s,r,l,c){this.tag=s,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hn(s,r,l,c){return new SI(s,r,l,c)}function Yd(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Hs(s,r){var l=s.alternate;return l===null?(l=hn(s.tag,r,s.key,s.mode),l.elementType=s.elementType,l.type=s.type,l.stateNode=s.stateNode,l.alternate=s,s.alternate=l):(l.pendingProps=r,l.type=s.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=s.flags&1206910976,l.childLanes=s.childLanes,l.lanes=s.lanes,l.child=s.child,l.memoizedProps=s.memoizedProps,l.memoizedState=s.memoizedState,l.updateQueue=s.updateQueue,r=s.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=s.sibling,l.index=s.index,l.ref=s.ref,l.refCleanup=s.refCleanup,l}function pv(s,r){s.flags&=1206910978;var l=s.alternate;return l===null?(s.childLanes=0,s.lanes=r,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=l.childLanes,s.lanes=l.lanes,s.child=l.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=l.memoizedProps,s.memoizedState=l.memoizedState,s.updateQueue=l.updateQueue,s.type=l.type,r=l.dependencies,s.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),s}function nu(s,r,l,c,h,g){var S=0;if(c=s,typeof c=="function")Yd(c)&&(S=1);else if(typeof c=="string")S=KR(s,l,ct.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(c){case $:return s=hn(31,l,r,h),s.elementType=$,s.lanes=g,s;case z:return Zi(l.children,h,g,r);case q:S=8,h|=24;break;case W:return s=hn(12,l,r,h|2),s.elementType=W,s.lanes=g,s;case oe:return s=hn(13,l,r,h),s.elementType=oe,s.lanes=g,s;case he:return s=hn(19,l,r,h),s.elementType=he,s.lanes=g,s;case re:case N:return s=h|32,s=hn(30,l,r,s),s.elementType=N,s.lanes=g,s.stateNode={autoName:null,paired:null,clones:null,ref:null},s;default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case Z:S=10;break e;case X:S=9;break e;case ee:S=11;break e;case ye:S=14;break e;case D:S=16,c=null;break e}S=29,l=Error(i(130,s===null?"null":typeof s,"")),c=null}return r=hn(S,l,r,h),r.elementType=s,r.type=c,r.lanes=g,r}function Zi(s,r,l,c){return s=hn(7,s,c,r),s.lanes=l,s}function Qd(s,r,l){return s=hn(6,s,null,r),s.lanes=l,s}function mv(s){var r=hn(18,null,null,0);return r.stateNode=s,r}function Kd(s,r,l){return r=hn(4,s.children!==null?s.children:[],s.key,r),r.lanes=l,r.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},r}var gv=new WeakMap;function Hn(s,r){if(typeof s=="object"&&s!==null){var l=gv.get(s);return l!==void 0?l:(r={value:s,source:r,stack:Ut(r)},gv.set(s,r),r)}return{value:s,source:r,stack:Ut(r)}}var Wr=[],ea=0,su=null,yo=0,Vn=[],$n=0,di=null,gs=1,ys="";function Vs(s,r){Wr[ea++]=yo,Wr[ea++]=su,su=s,yo=r}function yv(s,r,l){Vn[$n++]=gs,Vn[$n++]=ys,Vn[$n++]=di,di=s;var c=gs;s=ys;var h=32-xn(c)-1;c&=~(1<<h),l+=1;var g=32-xn(r)+h;if(30<g){var S=h-h%5;g=(c&(1<<S)-1).toString(32),c>>=S,h-=S,gs=1<<32-xn(r)+h|l<<h|c,ys=g+s}else gs=1<<g|l<<h|c,ys=s}function iu(s){s.return!==null&&(Vs(s,1),yv(s,1,0))}function Xd(s){for(;s===su;)su=Wr[--ea],Wr[ea]=null,yo=Wr[--ea],Wr[ea]=null;for(;s===di;)di=Vn[--$n],Vn[$n]=null,ys=Vn[--$n],Vn[$n]=null,gs=Vn[--$n],Vn[$n]=null}function vv(s,r){Vn[$n++]=gs,Vn[$n++]=ys,Vn[$n++]=di,gs=r.id,ys=r.overflow,di=s}var zt=null,lt=null,qe=!1,fi=null,Gn=!1,Jd=Error(i(519));function hi(s){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw vo(Hn(r,s)),Jd}function bv(s){var r=s.stateNode,l=s.type,c=s.memoizedProps;switch(r[qt]=s,r[fn]=c,l){case"dialog":Ve("cancel",r),Ve("close",r);break;case"iframe":case"object":case"embed":Ve("load",r);break;case"video":case"audio":for(l=0;l<Lo.length;l++)Ve(Lo[l],r);break;case"source":Ve("error",r);break;case"img":case"image":case"link":Ve("error",r),Ve("load",r);break;case"details":Ve("toggle",r);break;case"input":Ve("invalid",r),ky(r,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0);break;case"select":Ve("invalid",r);break;case"textarea":Ve("invalid",r),Oy(r,c.value,c.defaultValue,c.children)}l=c.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||r.textContent===""+l||c.suppressHydrationWarning===!0||L_(r.textContent,l)?(c.popover!=null&&(Ve("beforetoggle",r),Ve("toggle",r)),c.onScroll!=null&&Ve("scroll",r),c.onScrollEnd!=null&&Ve("scrollend",r),c.onClick!=null&&(r.onclick=ms),r=!0):r=!1,r||hi(s,!0)}function ru(s){for(zt=s.return;zt;)switch(zt.tag){case 5:case 31:case 13:Gn=!1;return;case 27:case 3:Gn=!0;return;default:zt=zt.return}}function ta(s){if(s!==zt)return!1;if(!qe)return ru(s),qe=!0,!1;var r=s.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=s.type,l=!(l!=="form"&&l!=="button")||Ih(s.type,s.memoizedProps)),l=!l),l&&lt&&hi(s),ru(s),r===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(i(317));lt=r0(s)}else if(r===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(i(317));lt=r0(s)}else r===27?(r=lt,Ri(s.type)?(s=Ph,Ph=null,lt=s):lt=r):lt=zt?Yn(s.stateNode.nextSibling):null;return!0}function Wi(){lt=zt=null,qe=!1}function Zd(){var s=fi;return s!==null&&(gn===null?gn=s:gn.push.apply(gn,s),fi=null),s}function vo(s){fi===null?fi=[s]:fi.push(s)}var Wd=ve(null),er=null,$s=null;function pi(s,r,l){Ie(Wd,r._currentValue),r._currentValue=l}function Gs(s){s._currentValue=Wd.current,Ae(Wd)}function au(s,r,l){for(;s!==null;){var c=s.alternate;if((s.childLanes&r)!==r?(s.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),s===l)break;s=s.return}}function ef(s,r,l,c){var h=s.child;for(h!==null&&(h.return=s);h!==null;){var g=h.dependencies;if(g!==null){var S=h.child;g=g.firstContext;e:for(;g!==null;){var A=g;g=h;for(var j=0;j<r.length;j++)if(A.context===r[j]){g.lanes|=l,A=g.alternate,A!==null&&(A.lanes|=l),au(g.return,l,s),c||(S=null);break e}g=A.next}}else if(h.tag===18){if(S=h.return,S===null)throw Error(i(341));S.lanes|=l,g=S.alternate,g!==null&&(g.lanes|=l),au(S,l,s),S=null}else h.tag===13&&h.memoizedState!==null&&h.memoizedState.dehydrated===null?(h.lanes|=l,S=h.alternate,S!==null&&(S.lanes|=l),au(h.return,l,s),S=h.child,S=S!==null?S.sibling:null):S=h.child;if(S!==null)S.return=h;else for(S=h;S!==null;){if(S===s){S=null;break}if(h=S.sibling,h!==null){h.return=S.return,S=h;break}S=S.return}h=S}}function tr(s,r,l,c){s=null;for(var h=r,g=!1;h!==null;){if(!g){if((h.flags&524288)!==0)g=!0;else if((h.flags&262144)!==0)break}if(h.tag===10){var S=h.alternate;if(S===null)throw Error(i(387));if(S=S.memoizedProps,S!==null){var A=h.type;En(h.pendingProps.value,S.value)||(s!==null?s.push(A):s=[A])}}else if(h===Pr.current){if(S=h.alternate,S===null)throw Error(i(387));S.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(s!==null?s.push(Ea):s=[Ea])}h=h.return}return s!==null&&ef(r,s,l,c),r.flags|=262144,s!==null}function ou(s){for(s=s.firstContext;s!==null;){if(!En(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function nr(s){er=s,$s=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Ht(s){return _v(er,s)}function lu(s,r){return er===null&&nr(s),_v(s,r)}function _v(s,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},$s===null){if(s===null)throw Error(i(308));$s=r,s.dependencies={lanes:0,firstContext:r},s.flags|=524288}else $s=$s.next=r;return l}var TI=typeof AbortController<"u"?AbortController:function(){var s=[],r=this.signal={aborted:!1,addEventListener:function(l,c){s.push(c)}};this.abort=function(){r.aborted=!0,s.forEach(function(l){return l()})}},wI=t.unstable_scheduleCallback,xI=t.unstable_NormalPriority,Ct={$$typeof:Z,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function tf(){return{controller:new TI,data:new Map,refCount:0}}function bo(s){s.refCount--,s.refCount===0&&wI(xI,function(){s.controller.abort()})}function Sv(s,r){if((s.pendingLanes&4194048)!==0){var l=s.transitionTypes;for(l===null&&(l=s.transitionTypes=[]),s=0;s<r.length;s++){var c=r[s];l.indexOf(c)===-1&&l.push(c)}}}var _o=null;function CI(s){var r=s.transitionTypes;return s.transitionTypes=null,r}var So=null,nf=0,sr=0,na=null;function EI(s,r){if(So===null){var l=So=[];nf=0,sr=bh(),na={status:"pending",value:void 0,then:function(c){l.push(c)}}}return nf++,r.then(Tv,Tv),r}function Tv(){if(--nf===0&&(_o=null,So!==null)){na!==null&&(na.status="fulfilled");var s=So;So=null,sr=0,na=null;for(var r=0;r<s.length;r++)(0,s[r])()}}function AI(s,r){var l=[],c={status:"pending",value:null,reason:null,then:function(h){l.push(h)}};return s.then(function(){c.status="fulfilled",c.value=r;for(var h=0;h<l.length;h++)(0,l[h])(r)},function(h){for(c.status="rejected",c.reason=h,h=0;h<l.length;h++)(0,l[h])(void 0)}),c}var wv=fe.S;fe.S=function(s,r){if(m_=Lt(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&EI(s,r),_o!==null)for(var l=_a;l!==null;)Sv(l,_o),l=l.next;if(l=s.types,l!==null){for(var c=_a;c!==null;)Sv(c,l),c=c.next;if(sr!==0){c=_o,c===null&&(c=_o=[]);for(var h=0;h<l.length;h++){var g=l[h];c.indexOf(g)===-1&&c.push(g)}}}wv!==null&&wv(s,r)};var ir=ve(null);function sf(){var s=ir.current;return s!==null?s:at.pooledCache}function uu(s,r){r===null?Ie(ir,ir.current):Ie(ir,r.pool)}function xv(){var s=sf();return s===null?null:{parent:Ct._currentValue,pool:s}}var sa=Error(i(460)),rf=Error(i(474)),cu=Error(i(542)),du={then:function(){}};function Cv(s){return s=s.status,s==="fulfilled"||s==="rejected"}function Ev(s,r,l){switch(l=s[l],l===void 0?s.push(r):l!==r&&(r.then(ms,ms),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw s=r.reason,Iv(s),s===void 0&&!("reason"in r)?Error(i(600)):s;default:if(typeof r.status=="string")r.then(ms,ms);else{if(s=at,s!==null&&100<s.shellSuspendCounter)throw Error(i(482));s=r,s.status="pending",s.then(function(c){if(r.status==="pending"){var h=r;h.status="fulfilled",h.value=c}},function(c){if(r.status==="pending"){var h=r;h.status="rejected",h.reason=c}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw s=r.reason,Iv(s),s}throw ar=r,sa}}function rr(s){try{var r=s._init;return r(s._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(ar=l,sa):l}}var ar=null;function Av(){if(ar===null)throw Error(i(459));var s=ar;return ar=null,s}function Iv(s){if(s===sa||s===cu)throw Error(i(483))}var ia=null,To=0;function fu(s){var r=To;return To+=1,ia===null&&(ia=[]),Ev(ia,s,r)}function mi(s,r){r=r.props.ref,s.ref=r!==void 0?r:null}function hu(s,r){throw r.$$typeof===k?Error(i(525)):(s=Object.prototype.toString.call(r),Error(i(31,s==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":s)))}function Rv(s){function r(F,U){if(s){var K=F.deletions;K===null?(F.deletions=[U],F.flags|=16):K.push(U)}}function l(F,U){if(!s)return null;for(;U!==null;)r(F,U),U=U.sibling;return null}function c(F){for(var U=new Map;F!==null;)F.key===null?U.set(F.index,F):U.set(F.key,F),F=F.sibling;return U}function h(F,U){return F=Hs(F,U),F.index=0,F.sibling=null,F}function g(F,U,K){return F.index=K,s?(K=F.alternate,K!==null?(K=K.index,K<U?(F.flags|=2,U):K):(F.flags|=134217730,U)):(F.flags|=1048576,U)}function S(F){return s&&F.alternate===null&&(F.flags|=134217730),F}function A(F,U,K,le){return U===null||U.tag!==6?(U=Qd(K,F.mode,le),U.return=F,U):(U=h(U,K),U.return=F,U)}function j(F,U,K,le){var Te=K.type;return Te===z?(F=ne(F,U,K.props.children,le,K.key),mi(F,K),F):U!==null&&(U.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===D&&rr(Te)===U.type)?(U=h(U,K.props),mi(U,K),U.return=F,U):(U=nu(K.type,K.key,K.props,null,F.mode,le),mi(U,K),U.return=F,U)}function Y(F,U,K,le){return U===null||U.tag!==4||U.stateNode.containerInfo!==K.containerInfo||U.stateNode.implementation!==K.implementation?(U=Kd(K,F.mode,le),U.return=F,U):(U=h(U,K.children||[]),U.return=F,U)}function ne(F,U,K,le,Te){return U===null||U.tag!==7?(U=Zi(K,F.mode,le,Te),U.return=F,U):(U=h(U,K),U.return=F,U)}function ue(F,U,K){if(typeof U=="string"&&U!==""||typeof U=="number"||typeof U=="bigint")return U=Qd(""+U,F.mode,K),U.return=F,U;if(typeof U=="object"&&U!==null){switch(U.$$typeof){case H:return K=nu(U.type,U.key,U.props,null,F.mode,K),mi(K,U),K.return=F,K;case V:return U=Kd(U,F.mode,K),U.return=F,U;case D:return U=rr(U),ue(F,U,K)}if(ce(U)||pe(U))return U=Zi(U,F.mode,K,null),U.return=F,U;if(typeof U.then=="function")return ue(F,fu(U),K);if(U.$$typeof===Z)return ue(F,lu(F,U),K);hu(F,U)}return null}function G(F,U,K,le){var Te=U!==null?U.key:null;if(typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint")return Te!==null?null:A(F,U,""+K,le);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case H:return K.key===Te?j(F,U,K,le):null;case V:return K.key===Te?Y(F,U,K,le):null;case D:return K=rr(K),G(F,U,K,le)}if(ce(K)||pe(K))return Te!==null?null:ne(F,U,K,le,null);if(typeof K.then=="function")return G(F,U,fu(K),le);if(K.$$typeof===Z)return G(F,U,lu(F,K),le);hu(F,K)}return null}function J(F,U,K,le,Te){if(typeof le=="string"&&le!==""||typeof le=="number"||typeof le=="bigint")return F=F.get(K)||null,A(U,F,""+le,Te);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case H:return F=F.get(le.key===null?K:le.key)||null,j(U,F,le,Te);case V:return F=F.get(le.key===null?K:le.key)||null,Y(U,F,le,Te);case D:return le=rr(le),J(F,U,K,le,Te)}if(ce(le)||pe(le))return F=F.get(K)||null,ne(U,F,le,Te,null);if(typeof le.then=="function")return J(F,U,K,fu(le),Te);if(le.$$typeof===Z)return J(F,U,K,lu(U,le),Te);hu(U,le)}return null}function Se(F,U,K,le){for(var Te=null,Fe=null,Ee=U,Me=U=0,It=null;Ee!==null&&Me<K.length;Me++){Ee.index>Me?(It=Ee,Ee=null):It=Ee.sibling;var Qe=G(F,Ee,K[Me],le);if(Qe===null){Ee===null&&(Ee=It);break}s&&Ee&&Qe.alternate===null&&r(F,Ee),U=g(Qe,U,Me),Fe===null?Te=Qe:Fe.sibling=Qe,Fe=Qe,Ee=It}if(Me===K.length)return l(F,Ee),qe&&Vs(F,Me),Te;if(Ee===null){for(;Me<K.length;Me++)Ee=ue(F,K[Me],le),Ee!==null&&(U=g(Ee,U,Me),Fe===null?Te=Ee:Fe.sibling=Ee,Fe=Ee);return qe&&Vs(F,Me),Te}for(Ee=c(Ee);Me<K.length;Me++)It=J(Ee,F,Me,K[Me],le),It!==null&&(s&&(Qe=It.alternate,Qe!==null&&Ee.delete(Qe.key===null?Me:Qe.key)),U=g(It,U,Me),Fe===null?Te=It:Fe.sibling=It,Fe=It);return s&&Ee.forEach(function(Di){return r(F,Di)}),qe&&Vs(F,Me),Te}function xe(F,U,K,le){if(K==null)throw Error(i(151));for(var Te=null,Fe=null,Ee=U,Me=U=0,It=null,Qe=K.next();Ee!==null&&!Qe.done;Me++,Qe=K.next()){Ee.index>Me?(It=Ee,Ee=null):It=Ee.sibling;var Di=G(F,Ee,Qe.value,le);if(Di===null){Ee===null&&(Ee=It);break}s&&Ee&&Di.alternate===null&&r(F,Ee),U=g(Di,U,Me),Fe===null?Te=Di:Fe.sibling=Di,Fe=Di,Ee=It}if(Qe.done)return l(F,Ee),qe&&Vs(F,Me),Te;if(Ee===null){for(;!Qe.done;Me++,Qe=K.next())Qe=ue(F,Qe.value,le),Qe!==null&&(U=g(Qe,U,Me),Fe===null?Te=Qe:Fe.sibling=Qe,Fe=Qe);return qe&&Vs(F,Me),Te}for(Ee=c(Ee);!Qe.done;Me++,Qe=K.next())Qe=J(Ee,F,Me,Qe.value,le),Qe!==null&&(s&&(It=Qe.alternate,It!==null&&Ee.delete(It.key===null?Me:It.key)),U=g(Qe,U,Me),Fe===null?Te=Qe:Fe.sibling=Qe,Fe=Qe);return s&&Ee.forEach(function(oM){return r(F,oM)}),qe&&Vs(F,Me),Te}function Le(F,U,K,le){if(typeof K=="object"&&K!==null&&K.type===z&&K.key===null&&K.props.ref===void 0&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case H:e:{for(var Te=K.key;U!==null;){if(U.key===Te){if(Te=K.type,Te===z){if(U.tag===7){l(F,U.sibling),le=h(U,K.props.children),mi(le,K),le.return=F,F=le;break e}}else if(U.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===D&&rr(Te)===U.type){l(F,U.sibling),le=h(U,K.props),mi(le,K),le.return=F,F=le;break e}l(F,U);break}else r(F,U);U=U.sibling}K.type===z?(le=Zi(K.props.children,F.mode,le,K.key),mi(le,K),le.return=F,F=le):(le=nu(K.type,K.key,K.props,null,F.mode,le),mi(le,K),le.return=F,F=le)}return S(F);case V:e:{for(Te=K.key;U!==null;){if(U.key===Te)if(U.tag===4&&U.stateNode.containerInfo===K.containerInfo&&U.stateNode.implementation===K.implementation){l(F,U.sibling),le=h(U,K.children||[]),le.return=F,F=le;break e}else{l(F,U);break}else r(F,U);U=U.sibling}le=Kd(K,F.mode,le),le.return=F,F=le}return S(F);case D:return K=rr(K),Le(F,U,K,le)}if(ce(K))return Se(F,U,K,le);if(pe(K)){if(Te=pe(K),typeof Te!="function")throw Error(i(150));return K=Te.call(K),xe(F,U,K,le)}if(typeof K.then=="function")return Le(F,U,fu(K),le);if(K.$$typeof===Z)return Le(F,U,lu(F,K),le);hu(F,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,U!==null&&U.tag===6?(l(F,U.sibling),le=h(U,K),le.return=F,F=le):(l(F,U),le=Qd(K,F.mode,le),le.return=F,F=le),S(F)):l(F,U)}return function(F,U,K,le){try{To=0;var Te=Le(F,U,K,le);return ia=null,Te}catch(Ee){if(Ee===sa||Ee===cu)throw Ee;var Fe=hn(29,Ee,null,F.mode);return Fe.lanes=le,Fe.return=F,Fe}}}var or=Rv(!0),Mv=Rv(!1),gi=!1;function af(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function of(s,r){s=s.updateQueue,r.updateQueue===s&&(r.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function yi(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function vi(s,r,l){var c=s.updateQueue;if(c===null)return null;if(c=c.shared,(Je&2)!==0){var h=c.pending;return h===null?r.next=r:(r.next=h.next,h.next=r),c.pending=r,r=tu(s),hv(s,null,l),r}return eu(s,c,r,l),tu(s)}function wo(s,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var c=r.lanes;c&=s.pendingLanes,l|=c,r.lanes=l,yy(s,l)}}function lf(s,r){var l=s.updateQueue,c=s.alternate;if(c!==null&&(c=c.updateQueue,l===c)){var h=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var S={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?h=g=S:g=g.next=S,l=l.next}while(l!==null);g===null?h=g=r:g=g.next=r}else h=g=r;l={baseState:c.baseState,firstBaseUpdate:h,lastBaseUpdate:g,shared:c.shared,callbacks:c.callbacks},s.updateQueue=l;return}s=l.lastBaseUpdate,s===null?l.firstBaseUpdate=r:s.next=r,l.lastBaseUpdate=r}var uf=!1;function xo(){if(uf){var s=na;if(s!==null)throw s}}function Co(s,r,l,c){uf=!1;var h=s.updateQueue;gi=!1;var g=h.firstBaseUpdate,S=h.lastBaseUpdate,A=h.shared.pending;if(A!==null){h.shared.pending=null;var j=A,Y=j.next;j.next=null,S===null?g=Y:S.next=Y,S=j;var ne=s.alternate;ne!==null&&(ne=ne.updateQueue,A=ne.lastBaseUpdate,A!==S&&(A===null?ne.firstBaseUpdate=Y:A.next=Y,ne.lastBaseUpdate=j))}if(g!==null){var ue=h.baseState;S=0,ne=Y=j=null,A=g;do{var G=A.lane&-536870913,J=G!==A.lane;if(J?(Ge&G)===G:(c&G)===G){G!==0&&G===sr&&(uf=!0),ne!==null&&(ne=ne.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var Se=s,xe=A;G=r;var Le=l;switch(xe.tag){case 1:if(Se=xe.payload,typeof Se=="function"){ue=Se.call(Le,ue,G);break e}ue=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=xe.payload,G=typeof Se=="function"?Se.call(Le,ue,G):Se,G==null)break e;ue=P({},ue,G);break e;case 2:gi=!0}}G=A.callback,G!==null&&(s.flags|=64,J&&(s.flags|=8192),J=h.callbacks,J===null?h.callbacks=[G]:J.push(G))}else J={lane:G,tag:A.tag,payload:A.payload,callback:A.callback,next:null},ne===null?(Y=ne=J,j=ue):ne=ne.next=J,S|=G;if(A=A.next,A===null){if(A=h.shared.pending,A===null)break;J=A,A=J.next,J.next=null,h.lastBaseUpdate=J,h.shared.pending=null}}while(!0);ne===null&&(j=ue),h.baseState=j,h.firstBaseUpdate=Y,h.lastBaseUpdate=ne,g===null&&(h.shared.lanes=0),Ci|=S,s.lanes=S,s.memoizedState=ue}}function kv(s,r){if(typeof s!="function")throw Error(i(191,s));s.call(r)}function Nv(s,r){var l=s.callbacks;if(l!==null)for(s.callbacks=null,s=0;s<l.length;s++)kv(l[s],r)}var bi=ve(null),pu=ve(0);function Ov(s,r){s=Xs,Ie(pu,s),Ie(bi,r),Xs=s|r.baseLanes}function cf(){Ie(pu,Xs),Ie(bi,bi.current)}function df(){Xs=pu.current,Ae(bi),Ae(pu)}var Vt=ve(null),Kt=null;function _i(s){var r=s.alternate;Ie($t,$t.current&1),Ie(Vt,s),Kt===null&&(r===null||bi.current!==null||r.memoizedState!==null)&&(Kt=s)}function ff(s){Ie($t,$t.current),Ie(Vt,s),Kt===null&&(Kt=s)}function Dv(s){s.tag===22?(Ie($t,$t.current),Ie(Vt,s),Kt===null&&(Kt=s)):Si()}function Si(){Ie($t,$t.current),Ie(Vt,Vt.current)}function An(s){Ae(Vt),Kt===s&&(Kt=null),Ae($t)}var $t=ve(0);function Eo(s,r){Ie(Vt,Vt.current),Ie($t,r)}function hf(s){Ae($t),Ae(Vt),Kt===s&&(Kt=null)}function mu(s){for(var r=s;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||jh(l)||zh(l)))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!=="independent"){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Fs=0,Ue=null,it=null,Et=null,gu=!1,ra=!1,lr=!1,yu=0,Ao=0,aa=null,II=0;function _t(){throw Error(i(321))}function pf(s,r){if(r===null)return!1;for(var l=0;l<r.length&&l<s.length;l++)if(!En(s[l],r[l]))return!1;return!0}function mf(s,r,l,c,h,g){return Fs=g,Ue=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,fe.H=s===null||s.memoizedState===null?yb:vb,lr=!1,g=l(c,h),lr=!1,ra&&(g=zv(r,l,c,h)),jv(s),g}function jv(s){fe.H=xu;var r=it!==null&&it.next!==null;if(Fs=0,Et=it=Ue=null,gu=!1,Ao=0,aa=null,r)throw Error(i(300));s===null||At||(s=s.dependencies,s!==null&&ou(s)&&(At=!0))}function zv(s,r,l,c){Ue=s;var h=0;do{if(ra&&(aa=null),Ao=0,ra=!1,25<=h)throw Error(i(301));if(h+=1,Et=it=null,s.updateQueue!=null){var g=s.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}fe.H=zI,g=r(l,c)}while(ra);return g}function RI(){var s=fe.H,r=s.useState()[0];return r=typeof r.then=="function"?Io(r):r,s=s.useState()[0],(it!==null?it.memoizedState:null)!==s&&(Ue.flags|=1024),r}function gf(){var s=yu!==0;return yu=0,s}function yf(s,r,l){r.updateQueue=s.updateQueue,r.flags&=-2053,s.lanes&=~l}function vf(s){if(gu){for(s=s.memoizedState;s!==null;){var r=s.queue;r!==null&&(r.pending=null),s=s.next}gu=!1}Fs=0,Et=it=Ue=null,ra=!1,Ao=yu=0,aa=null}function nn(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Et===null?Ue.memoizedState=Et=s:Et=Et.next=s,Et}function xt(){if(it===null){var s=Ue.alternate;s=s!==null?s.memoizedState:null}else s=it.next;var r=Et===null?Ue.memoizedState:Et.next;if(r!==null)Et=r,it=s;else{if(s===null)throw Ue.alternate===null?Error(i(467)):Error(i(310));it=s,s={memoizedState:it.memoizedState,baseState:it.baseState,baseQueue:it.baseQueue,queue:it.queue,next:null},Et===null?Ue.memoizedState=Et=s:Et=Et.next=s}return Et}function vu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Io(s){var r=Ao;return Ao+=1,aa===null&&(aa=[]),s=Ev(aa,s,r),r=Ue,(Et===null?r.memoizedState:Et.next)===null&&(r=r.alternate,fe.H=r===null||r.memoizedState===null?yb:vb),s}function bu(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return Io(s);if(s.$$typeof===te)return;if(s.$$typeof===Z)return Ht(s)}throw Error(i(438,String(s)))}function bf(s){var r=null,l=Ue.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var c=Ue.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(r={data:c.data.map(function(h){return h.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=vu(),Ue.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(s),c=0;c<s;c++)l[c]=M;return r.index++,l}function Ys(s,r){return typeof r=="function"?r(s):r}function _u(s){var r=xt();return _f(r,it,s)}function _f(s,r,l){var c=s.queue;if(c===null)throw Error(i(311));c.lastRenderedReducer=l;var h=s.baseQueue,g=c.pending;if(g!==null){if(h!==null){var S=h.next;h.next=g.next,g.next=S}r.baseQueue=h=g,c.pending=null}if(g=s.baseState,h===null)s.memoizedState=g;else{r=h.next;var A=S=null,j=null,Y=r,ne=!1;do{var ue=Y.lane&-536870913;if(ue!==Y.lane?(Ge&ue)===ue:(Fs&ue)===ue){var G=Y.revertLane;if(G===0)j!==null&&(j=j.next={lane:0,revertLane:0,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null}),ue===sr&&(ne=!0);else if((Fs&G)===G){Y=Y.next,G===sr&&(ne=!0);continue}else ue={lane:0,revertLane:Y.revertLane,gesture:null,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},j===null?(A=j=ue,S=g):j=j.next=ue,Ue.lanes|=G,Ci|=G;ue=Y.action,lr&&l(g,ue),g=Y.hasEagerState?Y.eagerState:l(g,ue)}else G={lane:ue,revertLane:Y.revertLane,gesture:Y.gesture,action:Y.action,hasEagerState:Y.hasEagerState,eagerState:Y.eagerState,next:null},j===null?(A=j=G,S=g):j=j.next=G,Ue.lanes|=ue,Ci|=ue;Y=Y.next}while(Y!==null&&Y!==r);if(j===null?S=g:j.next=A,!En(g,s.memoizedState)&&(At=!0,ne&&(l=na,l!==null)))throw l;s.memoizedState=g,s.baseState=S,s.baseQueue=j,c.lastRenderedState=g}return h===null&&(c.lanes=0),[s.memoizedState,c.dispatch]}function Sf(s){var r=xt(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=s;var c=l.dispatch,h=l.pending,g=r.memoizedState;if(h!==null){l.pending=null;var S=h=h.next;do g=s(g,S.action),S=S.next;while(S!==h);En(g,r.memoizedState)||(At=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,c]}function Pv(s,r,l){var c=Ue,h=xt(),g=qe;if(g){if(l===void 0)throw Error(i(407));l=l()}else l=r();var S=!En((it||h).memoizedState,l);if(S&&(h.memoizedState=l,At=!0),h=h.queue,xf(Lv.bind(null,c,h,s),[s]),s=h.getSnapshot!==r||S||Et!==null&&(Et.memoizedState.tag&1)!==0,oa(s?9:8,{destroy:void 0},Uv.bind(null,c,h,l,r),null),s){if(c.flags|=2048,at===null)throw Error(i(349));g||(Fs&127)!==0||Bv(c,r,l)}return l}function Bv(s,r,l){s.flags|=16384,s={getSnapshot:r,value:l},r=Ue.updateQueue,r===null?(r=vu(),Ue.updateQueue=r,r.stores=[s]):(l=r.stores,l===null?r.stores=[s]:l.push(s))}function Uv(s,r,l,c){r.value=l,r.getSnapshot=c,qv(r)&&Hv(s)}function Lv(s,r,l){return l(function(){qv(r)&&Hv(s)})}function qv(s){var r=s.getSnapshot;s=s.value;try{var l=r();return!En(s,l)}catch{return!0}}function Hv(s){var r=Ji(s,2);r!==null&&yn(r,s,2)}function Tf(s){var r=nn();if(typeof s=="function"){var l=s;if(s=l(),lr){li(!0);try{l()}finally{li(!1)}}}return r.memoizedState=r.baseState=s,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ys,lastRenderedState:s},r}function Vv(s,r,l,c){return s.baseState=l,_f(s,it,typeof c=="function"?c:Ys)}function MI(s,r,l,c,h){if(wu(s))throw Error(i(485));if(s=r.action,s!==null){var g={payload:h,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};fe.T!==null?l(!0):g.isTransition=!1,c(g),l=r.pending,l===null?(g.next=r.pending=g,$v(r,g)):(g.next=l.next,r.pending=l.next=g)}}function $v(s,r){var l=r.action,c=r.payload,h=s.state;if(r.isTransition){var g=fe.T,S={};S.types=g!==null?g.types:null,fe.T=S;try{var A=l(h,c),j=fe.S;j!==null&&j(S,A),Gv(s,r,A)}catch(Y){wf(s,r,Y)}finally{g!==null&&S.types!==null&&(g.types=S.types),fe.T=g}}else try{g=l(h,c),Gv(s,r,g)}catch(Y){wf(s,r,Y)}}function Gv(s,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(c){Fv(s,r,c)},function(c){return wf(s,r,c)}):Fv(s,r,l)}function Fv(s,r,l){r.status="fulfilled",r.value=l,Yv(r),s.state=l,r=s.pending,r!==null&&(l=r.next,l===r?s.pending=null:(l=l.next,r.next=l,$v(s,l)))}function wf(s,r,l){var c=s.pending;if(s.pending=null,c!==null){c=c.next;do r.status="rejected",r.reason=l,Yv(r),r=r.next;while(r!==c)}s.action=null}function Yv(s){s=s.listeners;for(var r=0;r<s.length;r++)(0,s[r])()}function Qv(s,r){return r}function Kv(s,r){if(qe){var l=at.formState;if(l!==null){e:{var c=Ue;if(qe){if(lt){t:{for(var h=lt,g=Gn;h.nodeType!==8;){if(!g){h=null;break t}if(h=Yn(h.nextSibling),h===null){h=null;break t}}g=h.data,h=g==="F!"||g==="F"?h:null}if(h){lt=Yn(h.nextSibling),c=h.data==="F!";break e}}hi(c)}c=!1}c&&(r=l[0])}}return l=nn(),l.memoizedState=l.baseState=r,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qv,lastRenderedState:r},l.queue=c,l=pb.bind(null,Ue,c),c.dispatch=l,c=Tf(!1),g=Rf.bind(null,Ue,!1,c.queue),c=nn(),h={state:r,dispatch:null,action:s,pending:null},c.queue=h,l=MI.bind(null,Ue,h,g,l),h.dispatch=l,c.memoizedState=s,[r,l,!1]}function Xv(s){var r=xt();return Jv(r,it,s)}function Jv(s,r,l){if(r=_f(s,r,Qv)[0],s=_u(Ys)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var c=Io(r)}catch(S){throw S===sa?cu:S}else c=r;r=xt();var h=r.queue,g=h.dispatch;return l!==r.memoizedState&&(Ue.flags|=2048,oa(9,{destroy:void 0},kI.bind(null,h,l),null)),[c,g,s]}function kI(s,r){s.action=r}function Zv(s){var r=xt(),l=it;if(l!==null)return Jv(r,l,s);xt(),r=r.memoizedState,l=xt();var c=l.queue.dispatch;return l.memoizedState=s,[r,c,!1]}function oa(s,r,l,c){return s={tag:s,create:l,deps:c,inst:r,next:null},r=Ue.updateQueue,r===null&&(r=vu(),Ue.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=s.next=s:(c=l.next,l.next=s,s.next=c,r.lastEffect=s),s}function Wv(){return xt().memoizedState}function Su(s,r,l,c){var h=nn();Ue.flags|=s,h.memoizedState=oa(1|r,{destroy:void 0},l,c===void 0?null:c)}function Tu(s,r,l,c){var h=xt();c=c===void 0?null:c;var g=h.memoizedState.inst;it!==null&&c!==null&&pf(c,it.memoizedState.deps)?h.memoizedState=oa(r,g,l,c):(Ue.flags|=s,h.memoizedState=oa(1|r,g,l,c))}function eb(s,r){Su(8390656,8,s,r)}function xf(s,r){Tu(2048,8,s,r)}function NI(s){Ue.flags|=4;var r=Ue.updateQueue;if(r===null)r=vu(),Ue.updateQueue=r,r.events=[s];else{var l=r.events;l===null?r.events=[s]:l.push(s)}}function tb(s){var r=xt().memoizedState;return NI({ref:r,nextImpl:s}),function(){if((Je&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function nb(s,r){return Tu(4,2,s,r)}function sb(s,r){return Tu(4,4,s,r)}function ib(s,r){if(typeof r=="function"){s=s();var l=r(s);return function(){typeof l=="function"?l():r(null)}}if(r!=null)return s=s(),r.current=s,function(){r.current=null}}function rb(s,r,l){l=l!=null?l.concat([s]):null,Tu(4,4,ib.bind(null,r,s),l)}function Cf(){}function ab(s,r){var l=xt();r=r===void 0?null:r;var c=l.memoizedState;return r!==null&&pf(r,c[1])?c[0]:(l.memoizedState=[s,r],s)}function ob(s,r){var l=xt();r=r===void 0?null:r;var c=l.memoizedState;if(r!==null&&pf(r,c[1]))return c[0];if(c=s(),lr){li(!0);try{s()}finally{li(!1)}}return l.memoizedState=[c,r],c}function Ef(s,r,l){return l===void 0||(Fs&1073741824)!==0&&(Ge&261930)===0?s.memoizedState=r:(s.memoizedState=l,s=y_(),Ue.lanes|=s,Ci|=s,l)}function lb(s,r,l,c){return En(l,r)?l:bi.current!==null?(s=Ef(s,l,c),En(s,r)||(At=!0),s):(Fs&106)===0||(Fs&1073741824)!==0&&(Ge&261930)===0?(At=!0,s.memoizedState=l):(s=y_(),Ue.lanes|=s,Ci|=s,r)}function ub(s,r,l,c,h){var g=ge.p;ge.p=g!==0&&8>g?g:8;var S=fe.T,A={};A.types=S!==null?S.types:null,fe.T=A,Rf(s,!1,r,l);try{var j=h(),Y=fe.S;if(Y!==null&&Y(A,j),j!==null&&typeof j=="object"&&typeof j.then=="function"){var ne=AI(j,c);Ro(s,r,ne,kn(s))}else Ro(s,r,c,kn(s))}catch(ue){Ro(s,r,{then:function(){},status:"rejected",reason:ue},kn())}finally{ge.p=g,S!==null&&A.types!==null&&(S.types=A.types),fe.T=S}}function OI(){}function Af(s,r,l,c){if(s.tag!==5)throw Error(i(476));var h=cb(s).queue;ub(s,h,r,Oe,l===null?OI:function(){return db(s),l(c)})}function cb(s){var r=s.memoizedState;if(r!==null)return r;r={memoizedState:Oe,baseState:Oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ys,lastRenderedState:Oe},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ys,lastRenderedState:l},next:null},s.memoizedState=r,s=s.alternate,s!==null&&(s.memoizedState=r),r}function db(s){var r=cb(s);r.next===null&&(r=s.alternate.memoizedState),Ro(s,r.next.queue,{},kn())}function If(){return Ht(Ea)}function fb(){return xt().memoizedState}function hb(){return xt().memoizedState}function DI(s){for(var r=s.return;r!==null;){switch(r.tag){case 24:case 3:var l=kn();s=yi(l);var c=vi(r,s,l);c!==null&&(yn(c,r,l),wo(c,r,l)),r={cache:tf()},s.payload=r;return}r=r.return}}function jI(s,r,l){var c=kn();l={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},wu(s)?mb(r,l):(l=Fd(s,r,l,c),l!==null&&(yn(l,s,c),gb(l,r,c)))}function pb(s,r,l){var c=kn();Ro(s,r,l,c)}function Ro(s,r,l,c){var h={lane:c,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(wu(s))mb(r,h);else{var g=s.alternate;if(s.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var S=r.lastRenderedState,A=g(S,l);if(h.hasEagerState=!0,h.eagerState=A,En(A,S))return eu(s,r,h,0),at===null&&Wl(),!1}catch{}if(l=Fd(s,r,h,c),l!==null)return yn(l,s,c),gb(l,r,c),!0}return!1}function Rf(s,r,l,c){if(c={lane:2,revertLane:bh(),gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},wu(s)){if(r)throw Error(i(479))}else r=Fd(s,l,c,2),r!==null&&yn(r,s,2)}function wu(s){var r=s.alternate;return s===Ue||r!==null&&r===Ue}function mb(s,r){ra=gu=!0;var l=s.pending;l===null?r.next=r:(r.next=l.next,l.next=r),s.pending=r}function gb(s,r,l){if((l&4194048)!==0){var c=r.lanes;c&=s.pendingLanes,l|=c,r.lanes=l,yy(s,l)}}var xu={readContext:Ht,use:bu,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useLayoutEffect:_t,useInsertionEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useSyncExternalStore:_t,useId:_t,useHostTransitionStatus:_t,useFormState:_t,useActionState:_t,useOptimistic:_t,useMemoCache:_t,useCacheRefresh:_t,useEffectEvent:_t},yb={readContext:Ht,use:bu,useCallback:function(s,r){return nn().memoizedState=[s,r===void 0?null:r],s},useContext:Ht,useEffect:eb,useImperativeHandle:function(s,r,l){l=l!=null?l.concat([s]):null,Su(4194308,4,ib.bind(null,r,s),l)},useLayoutEffect:function(s,r){return Su(4194308,4,s,r)},useInsertionEffect:function(s,r){Su(4,2,s,r)},useMemo:function(s,r){var l=nn();r=r===void 0?null:r;var c=s();if(lr){li(!0);try{s()}finally{li(!1)}}return l.memoizedState=[c,r],c},useReducer:function(s,r,l){var c=nn();if(l!==void 0){var h=l(r);if(lr){li(!0);try{l(r)}finally{li(!1)}}}else h=r;return c.memoizedState=c.baseState=h,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:h},c.queue=s,s=s.dispatch=jI.bind(null,Ue,s),[c.memoizedState,s]},useRef:function(s){var r=nn();return s={current:s},r.memoizedState=s},useState:function(s){s=Tf(s);var r=s.queue,l=pb.bind(null,Ue,r);return r.dispatch=l,[s.memoizedState,l]},useDebugValue:Cf,useDeferredValue:function(s,r){var l=nn();return Ef(l,s,r)},useTransition:function(){var s=Tf(!1);return s=ub.bind(null,Ue,s.queue,!0,!1),nn().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,r,l){var c=Ue,h=nn();if(qe){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),at===null)throw Error(i(349));(Ge&127)!==0||Bv(c,r,l)}h.memoizedState=l;var g={value:l,getSnapshot:r};return h.queue=g,eb(Lv.bind(null,c,g,s),[s]),c.flags|=2048,oa(9,{destroy:void 0},Uv.bind(null,c,g,l,r),null),l},useId:function(){var s=nn(),r=at.identifierPrefix;if(qe){var l=ys,c=gs;l=(c&~(1<<32-xn(c)-1)).toString(32)+l,r="_"+r+"R_"+l,l=yu++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=II++,r="_"+r+"r_"+l.toString(32)+"_";return s.memoizedState=r},useHostTransitionStatus:If,useFormState:Kv,useActionState:Kv,useOptimistic:function(s){var r=nn();r.memoizedState=r.baseState=s;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=Rf.bind(null,Ue,!0,l),l.dispatch=r,[s,r]},useMemoCache:bf,useCacheRefresh:function(){return nn().memoizedState=DI.bind(null,Ue)},useEffectEvent:function(s){var r=nn(),l={impl:s};return r.memoizedState=l,function(){if((Je&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},vb={readContext:Ht,use:bu,useCallback:ab,useContext:Ht,useEffect:xf,useImperativeHandle:rb,useInsertionEffect:nb,useLayoutEffect:sb,useMemo:ob,useReducer:_u,useRef:Wv,useState:function(){return _u(Ys)},useDebugValue:Cf,useDeferredValue:function(s,r){var l=xt();return lb(l,it.memoizedState,s,r)},useTransition:function(){var s=_u(Ys)[0],r=xt().memoizedState;return[typeof s=="boolean"?s:Io(s),r]},useSyncExternalStore:Pv,useId:fb,useHostTransitionStatus:If,useFormState:Xv,useActionState:Xv,useOptimistic:function(s,r){var l=xt();return Vv(l,it,s,r)},useMemoCache:bf,useCacheRefresh:hb,useEffectEvent:tb},zI={readContext:Ht,use:bu,useCallback:ab,useContext:Ht,useEffect:xf,useImperativeHandle:rb,useInsertionEffect:nb,useLayoutEffect:sb,useMemo:ob,useReducer:Sf,useRef:Wv,useState:function(){return Sf(Ys)},useDebugValue:Cf,useDeferredValue:function(s,r){var l=xt();return it===null?Ef(l,s,r):lb(l,it.memoizedState,s,r)},useTransition:function(){var s=Sf(Ys)[0],r=xt().memoizedState;return[typeof s=="boolean"?s:Io(s),r]},useSyncExternalStore:Pv,useId:fb,useHostTransitionStatus:If,useFormState:Zv,useActionState:Zv,useOptimistic:function(s,r){var l=xt();return it!==null?Vv(l,it,s,r):(l.baseState=s,[s,l.queue.dispatch])},useMemoCache:bf,useCacheRefresh:hb,useEffectEvent:tb};function Mf(s,r,l,c){r=s.memoizedState,l=l(c,r),l=l==null?r:P({},r,l),s.memoizedState=l,s.lanes===0&&(s.updateQueue.baseState=l)}var kf={enqueueSetState:function(s,r,l){s=s._reactInternals;var c=kn(),h=yi(c);h.payload=r,l!=null&&(h.callback=l),r=vi(s,h,c),r!==null&&(yn(r,s,c),wo(r,s,c))},enqueueReplaceState:function(s,r,l){s=s._reactInternals;var c=kn(),h=yi(c);h.tag=1,h.payload=r,l!=null&&(h.callback=l),r=vi(s,h,c),r!==null&&(yn(r,s,c),wo(r,s,c))},enqueueForceUpdate:function(s,r){s=s._reactInternals;var l=kn(),c=yi(l);c.tag=2,r!=null&&(c.callback=r),r=vi(s,c,l),r!==null&&(yn(r,s,l),wo(r,s,l))}};function bb(s,r,l,c,h,g,S){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(c,g,S):r.prototype&&r.prototype.isPureReactComponent?!mo(l,c)||!mo(h,g):!0}function _b(s,r,l,c){s=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,c),r.state!==s&&kf.enqueueReplaceState(r,r.state,null)}function ur(s,r){var l=r;if("ref"in r){l={};for(var c in r)c!=="ref"&&(l[c]=r[c])}if(s=s.defaultProps){l===r&&(l=P({},l));for(var h in s)l[h]===void 0&&(l[h]=s[h])}return l}function Sb(s){Zl(s)}function Tb(s){console.error(s)}function wb(s){Zl(s)}function Cu(s,r){try{var l=s.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(c){setTimeout(function(){throw c})}}function xb(s,r,l){try{var c=s.onCaughtError;c(l.value,{componentStack:l.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function Nf(s,r,l){return l=yi(l),l.tag=3,l.payload={element:null},l.callback=function(){Cu(s,r)},l}function Cb(s){return s=yi(s),s.tag=3,s}function Eb(s,r,l,c){var h=l.type.getDerivedStateFromError;if(typeof h=="function"){var g=c.value;s.payload=function(){return h(g)},s.callback=function(){xb(r,l,c)}}var S=l.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(s.callback=function(){xb(r,l,c),typeof h!="function"&&(Ei===null?Ei=new Set([this]):Ei.add(this));var A=c.stack;this.componentDidCatch(c.value,{componentStack:A!==null?A:""})})}function PI(s,r,l,c,h){if(l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(r=l.alternate,r!==null&&tr(r,l,h,!0),l=Vt.current,l!==null){switch(l.tag){case 31:case 13:case 19:return Kt===null?Fu():l.alternate===null&&St===0&&(St=3),l.flags&=-257,l.flags|=65536,l.lanes=h,c===du?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([c]):r.add(c),gh(s,c,h)),!1;case 22:return l.flags|=65536,c===du?l.flags|=16384:(r=l.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([c])},l.updateQueue=r):(l=r.retryQueue,l===null?r.retryQueue=new Set([c]):l.add(c)),gh(s,c,h)),!1}throw Error(i(435,l.tag))}return gh(s,c,h),Fu(),!1}if(qe)return r=Vt.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=h,c!==Jd&&(s=Error(i(422),{cause:c}),vo(Hn(s,l)))):(c!==Jd&&(r=Error(i(423),{cause:c}),vo(Hn(r,l))),s=s.current.alternate,s.flags|=65536,h&=-h,s.lanes|=h,c=Hn(c,l),h=Nf(s.stateNode,c,h),lf(s,h),St!==4&&(St=2)),!1;var g=Error(i(520),{cause:c});if(g=Hn(g,l),Po===null?Po=[g]:Po.push(g),St!==4&&(St=2),r===null)return!0;c=Hn(c,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,s=h&-h,l.lanes|=s,s=Nf(l.stateNode,c,s),lf(l,s),!1;case 1:if(r=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Ei===null||!Ei.has(g))))return l.flags|=65536,h&=-h,l.lanes|=h,h=Cb(h),Eb(h,s,l,c),lf(l,h),!1;break;case 22:if(l.memoizedState!==null)return l.flags|=65536,!1}l=l.return}while(l!==null);return!1}var Of=Error(i(461)),At=!1;function kt(s,r,l,c){r.child=s===null?Mv(r,null,l,c):or(r,s.child,l,c)}function Ab(s,r,l,c,h){l=l.render;var g=r.ref;if("ref"in c){var S={};for(var A in c)A!=="ref"&&(S[A]=c[A])}else S=c;return nr(r),c=mf(s,r,l,S,g,h),A=gf(),s!==null&&!At?(yf(s,r,h),Qs(s,r,h)):(qe&&A&&iu(r),r.flags|=1,kt(s,r,c,h),r.child)}function Ib(s,r,l,c,h){if(s===null){var g=l.type;return typeof g=="function"&&!Yd(g)&&g.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=g,Rb(s,r,g,c,h)):(s=nu(l.type,null,c,r,r.mode,h),s.ref=r.ref,s.return=r,r.child=s)}if(g=s.child,!qf(s,h)){var S=g.memoizedProps;if(l=l.compare,l=l!==null?l:mo,l(S,c)&&s.ref===r.ref)return Qs(s,r,h)}return r.flags|=1,s=Hs(g,c),s.ref=r.ref,s.return=r,r.child=s}function Rb(s,r,l,c,h){if(s!==null){var g=s.memoizedProps;if(mo(g,c)&&s.ref===r.ref)if(At=!1,r.pendingProps=c=g,qf(s,h))(s.flags&131072)!==0&&(At=!0);else return r.lanes=s.lanes,Qs(s,r,h)}return Df(s,r,l,c,h)}function Mb(s,r,l,c){var h=c.children,g=s!==null?s.memoizedState:null;if(s===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.mode==="hidden"){if((r.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,s!==null){for(c=r.child=s.child,h=0;c!==null;)h=h|c.lanes|c.childLanes,c=c.sibling;c=h&~g}else c=0,r.child=null;return kb(s,r,g,l,c)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},s!==null&&uu(r,g!==null?g.cachePool:null),g!==null?Ov(r,g):cf(),Dv(r);else return c=r.lanes=536870912,kb(s,r,g!==null?g.baseLanes|l:l,l,c)}else g!==null?(uu(r,g.cachePool),Ov(r,g),Si(),r.memoizedState=null):(s!==null&&uu(r,null),cf(),Si());return kt(s,r,h,l),r.child}function Mo(s,r){return s!==null&&s.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function kb(s,r,l,c,h){var g=sf();return g=g===null?null:{parent:Ct._currentValue,pool:g},r.memoizedState={baseLanes:l,cachePool:g},s!==null&&uu(r,null),cf(),Dv(r),s!==null&&tr(s,r,c,!0),r.childLanes=h,null}function Eu(s,r){return r=Au({mode:r.mode,children:r.children},s.mode),r.ref=s.ref,s.child=r,r.return=s,r}function Nb(s,r,l){return or(r,s.child,null,l),s=Eu(r,r.pendingProps),s.flags|=2,An(r),r.memoizedState=null,s}function BI(s,r,l){var c=r.pendingProps,h=(r.flags&128)!==0;if(r.flags&=-129,s===null){if(qe){if(c.mode==="hidden")return s=Eu(r,c),r.lanes=536870912,s.memoizedState={baseLanes:0,cachePool:null},Mo(null,s);if(ff(r),(s=lt)?(s=i0(s,Gn),s=s!==null&&s.data==="&"?s:null,s!==null&&(r.memoizedState={dehydrated:s,treeContext:di!==null?{id:gs,overflow:ys}:null,retryLane:536870912,hydrationErrors:null},l=mv(s),l.return=r,r.child=l,zt=r,lt=null)):s=null,s===null)throw hi(r);return r.lanes=536870912,null}return Eu(r,c)}var g=s.memoizedState;if(g!==null){var S=g.dehydrated;if(ff(r),h)if(r.flags&256)r.flags&=-257,r=Nb(s,r,l);else if(r.memoizedState!==null)r.child=s.child,r.flags|=128,r=null;else throw Error(i(558));else if(At||tr(s,r,l,!1),h=(l&s.childLanes)!==0,At||h){if(bi.current===null){if(c=at,c!==null&&(S=vy(c,l),S!==0&&S!==g.retryLane))throw g.retryLane=S,Ji(s,S),yn(c,s,S),Of;Fu()}r=Nb(s,r,l)}else s=g.treeContext,lt=Yn(S.nextSibling),zt=r,qe=!0,fi=null,Gn=!1,s!==null&&vv(r,s),r=Eu(r,c),r.flags|=134221824;return r}return s=Hs(s.child,{mode:c.mode,children:c.children}),s.ref=r.ref,r.child=s,s.return=r,s}function la(s,r){var l=r.ref;if(l===null)s!==null&&s.ref!==null&&(r.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(i(284));(s===null||s.ref!==l)&&(r.flags|=4194816)}}function Df(s,r,l,c,h){return nr(r),l=mf(s,r,l,c,void 0,h),c=gf(),s!==null&&!At?(yf(s,r,h),Qs(s,r,h)):(qe&&c&&iu(r),r.flags|=1,kt(s,r,l,h),r.child)}function Ob(s,r,l,c,h,g){return nr(r),r.updateQueue=null,l=zv(r,c,l,h),jv(s),c=gf(),s!==null&&!At?(yf(s,r,g),Qs(s,r,g)):(qe&&c&&iu(r),r.flags|=1,kt(s,r,l,g),r.child)}function Db(s,r,l,c,h){if(nr(r),r.stateNode===null){var g=Zr,S=l.contextType;typeof S=="object"&&S!==null&&(g=Ht(S)),g=new l(c,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=kf,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=c,g.state=r.memoizedState,g.refs={},af(r),S=l.contextType,g.context=typeof S=="object"&&S!==null?Ht(S):Zr,g.state=r.memoizedState,S=l.getDerivedStateFromProps,typeof S=="function"&&(Mf(r,l,S,c),g.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&kf.enqueueReplaceState(g,g.state,null),Co(r,c,g,h),xo(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!0}else if(s===null){g=r.stateNode;var A=r.memoizedProps,j=ur(l,A);g.props=j;var Y=g.context,ne=l.contextType;S=Zr,typeof ne=="object"&&ne!==null&&(S=Ht(ne));var ue=l.getDerivedStateFromProps;ne=typeof ue=="function"||typeof g.getSnapshotBeforeUpdate=="function",A=r.pendingProps!==A,ne||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(A||Y!==S)&&_b(r,g,c,S),gi=!1;var G=r.memoizedState;g.state=G,Co(r,c,g,h),xo(),Y=r.memoizedState,A||G!==Y||gi?(typeof ue=="function"&&(Mf(r,l,ue,c),Y=r.memoizedState),(j=gi||bb(r,l,j,c,G,Y,S))?(ne||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=Y),g.props=c,g.state=Y,g.context=S,c=j):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{g=r.stateNode,of(s,r),S=r.memoizedProps,ne=ur(l,S),g.props=ne,ue=r.pendingProps,G=g.context,Y=l.contextType,j=Zr,typeof Y=="object"&&Y!==null&&(j=Ht(Y)),A=l.getDerivedStateFromProps,(Y=typeof A=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==ue||G!==j)&&_b(r,g,c,j),gi=!1,G=r.memoizedState,g.state=G,Co(r,c,g,h),xo();var J=r.memoizedState;S!==ue||G!==J||gi||s!==null&&s.dependencies!==null&&ou(s.dependencies)?(typeof A=="function"&&(Mf(r,l,A,c),J=r.memoizedState),(ne=gi||bb(r,l,ne,c,G,J,j)||s!==null&&s.dependencies!==null&&ou(s.dependencies))?(Y||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,J,j),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,J,j)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===s.memoizedProps&&G===s.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===s.memoizedProps&&G===s.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=J),g.props=c,g.state=J,g.context=j,c=ne):(typeof g.componentDidUpdate!="function"||S===s.memoizedProps&&G===s.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===s.memoizedProps&&G===s.memoizedState||(r.flags|=1024),c=!1)}return g=c,la(s,r),c=(r.flags&128)!==0,g||c?(g=r.stateNode,l=c&&typeof l.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,s!==null&&c?(r.child=or(r,s.child,null,h),r.child=or(r,null,l,h)):kt(s,r,l,h),r.memoizedState=g.state,s=r.child):s=Qs(s,r,h),s}function jb(s,r,l,c){return Wi(),r.flags|=256,kt(s,r,l,c),r.child}var jf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function zf(s){return{baseLanes:s,cachePool:xv()}}function Pf(s,r,l){return s=s!==null?s.childLanes&~l:0,r&&(s|=Mn),s}function zb(s,r,l){var c=r.pendingProps,h=!1,g=(r.flags&128)!==0,S;if((S=g)||(S=s!==null&&s.memoizedState===null?!1:($t.current&2)!==0),S&&(h=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,s===null){if(qe){if(h?_i(r):Si(),(s=lt)?(s=i0(s,Gn),s=s!==null&&s.data!=="&"?s:null,s!==null&&(r.memoizedState={dehydrated:s,treeContext:di!==null?{id:gs,overflow:ys}:null,retryLane:536870912,hydrationErrors:null},l=mv(s),l.return=r,r.child=l,zt=r,lt=null)):s=null,s===null)throw hi(r);return zh(s)?r.lanes=32:r.lanes=536870912,null}return g=c.children,c=c.fallback,h?(Si(),h=r.mode,g=Au({mode:"hidden",children:g},h),c=Zi(c,h,l,null),g.return=r,c.return=r,g.sibling=c,r.child=g,c=r.child,c.memoizedState=zf(l),c.childLanes=Pf(s,S,l),r.memoizedState=jf,Mo(null,c)):(_i(r),Bf(r,g))}var A=s.memoizedState;if(A!==null){var j=A.dehydrated;if(j!==null)return UI(s,r,g,S,c,j,A,l)}return h?(Si(),h=c.fallback,g=r.mode,A=s.child,j=A.sibling,c=Hs(A,{mode:"hidden",children:c.children}),c.subtreeFlags=A.subtreeFlags&1206910976,j!==null?h=Hs(j,h):(h=Zi(h,g,l,null),h.flags|=2),h.return=r,c.return=r,c.sibling=h,r.child=c,Mo(null,c),c=r.child,h=s.child.memoizedState,h===null?h=zf(l):(g=h.cachePool,g!==null?(A=Ct._currentValue,g=g.parent!==A?{parent:A,pool:A}:g):g=xv(),h={baseLanes:h.baseLanes|l,cachePool:g}),c.memoizedState=h,c.childLanes=Pf(s,S,l),r.memoizedState=jf,Mo(s.child,c)):(_i(r),l=s.child,s=l.sibling,l=Hs(l,{mode:"visible",children:c.children}),l.return=r,l.sibling=null,s!==null&&(S=r.deletions,S===null?(r.deletions=[s],r.flags|=16):S.push(s)),r.child=l,r.memoizedState=null,l)}function Bf(s,r){return r=Au({mode:"visible",children:r},s.mode),r.return=s,s.child=r}function Au(s,r){return s=hn(22,s,null,r),s.lanes=0,s}function Iu(s,r,l){return or(r,s.child,null,l),s=Bf(r,r.pendingProps.children),s.flags|=2,r.memoizedState=null,s}function UI(s,r,l,c,h,g,S,A){if(l)return r.flags&256?(_i(r),r.flags&=-257,Iu(s,r,A)):r.memoizedState!==null?(Si(),r.child=s.child,r.flags|=128,null):(Si(),g=h.fallback,S=r.mode,h=Au({mode:"visible",children:h.children},S),g=Zi(g,S,A,null),g.flags|=2,h.return=r,g.return=r,h.sibling=g,r.child=h,or(r,s.child,null,A),h=r.child,h.memoizedState=zf(A),h.childLanes=Pf(s,c,A),r.memoizedState=jf,Mo(null,h));if(_i(r),zh(g)){if(c=g.nextSibling&&g.nextSibling.dataset,c)var j=c.dgst;return c=j,c!==""&&(h=Error(i(419)),h.stack="",h.digest=c,vo({value:h,source:null,stack:null})),Iu(s,r,A)}if(At||tr(s,r,A,!1),c=(A&s.childLanes)!==0,At||c){if(bi.current!==null)return Iu(s,r,A);if(c=at,c!==null&&(h=vy(c,A),h!==0&&h!==S.retryLane))throw S.retryLane=h,Ji(s,h),yn(c,s,h),Of;return jh(g)||Fu(),Iu(s,r,A)}return jh(g)?(r.flags|=192,r.child=s.child,null):(s=S.treeContext,lt=Yn(g.nextSibling),zt=r,qe=!0,fi=null,Gn=!1,s!==null&&vv(r,s),r=Bf(r,h.children),r.flags|=134221824,r)}function Pb(s,r,l){s.lanes|=r;var c=s.alternate;c!==null&&(c.lanes|=r),au(s.return,r,l)}function Bb(s){for(var r=null;s!==null;){var l=s.alternate;l!==null&&mu(l)===null&&(r=s),s=s.sibling}return r}function Ru(s,r,l,c,h,g){var S=s.memoizedState;S===null?s.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:l,tailMode:h,treeForkCount:g}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=c,S.tail=l,S.tailMode=h,S.treeForkCount=g)}function Uf(s){var r=s.child;for(s.child=null;r!==null;){var l=r.sibling;r.sibling=s.child,s.child=r,r=l}}function Lf(s,r,l){var c=r.pendingProps,h=c.revealOrder,g=c.tail;c=c.children;var S=$t.current;if(r.flags&128)return Eo(r,S),null;var A=(S&2)!==0;if(A?(S=S&1|2,r.flags|=128):S&=1,Eo(r,S),h==="backwards"&&s!==null?(Uf(s),kt(s,r,c,l),Uf(s)):kt(s,r,c,l),c=qe?yo:0,!A&&s!==null&&(s.flags&128)!==0)e:for(s=r.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Pb(s,l,r);else if(s.tag===19)Pb(s,l,r);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break e;for(;s.sibling===null;){if(s.return===null||s.return===r)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(h){case"backwards":l=Bb(r.child),l===null?(h=r.child,r.child=null):(h=l.sibling,l.sibling=null,Uf(r)),Ru(r,!0,h,null,g,c);break;case"unstable_legacy-backwards":for(l=null,h=r.child,r.child=null;h!==null;){if(s=h.alternate,s!==null&&mu(s)===null){r.child=h;break}s=h.sibling,h.sibling=l,l=h,h=s}Ru(r,!0,l,null,g,c);break;case"together":Ru(r,!1,null,null,void 0,c);break;case"independent":r.memoizedState=null;break;default:l=Bb(r.child),l===null?(h=r.child,r.child=null):(h=l.sibling,l.sibling=null),Ru(r,!1,h,l,g,c)}return r.child}function Ub(s,r,l){var c=r.pendingProps;return pi(r,r.type,c.value),kt(s,r,c.children,l),r.child}function Qs(s,r,l){if(s!==null&&(r.dependencies=s.dependencies),Ci|=r.lanes,(l&r.childLanes)===0)if(s!==null){if(tr(s,r,l,!1),(l&r.childLanes)===0)return null}else return null;if(s!==null&&r.child!==s.child)throw Error(i(153));if(r.child!==null){for(s=r.child,l=Hs(s,s.pendingProps),r.child=l,l.return=r;s.sibling!==null;)s=s.sibling,l=l.sibling=Hs(s,s.pendingProps),l.return=r;l.sibling=null}return r.child}function qf(s,r){return(s.lanes&r)!==0?!0:(s=s.dependencies,!!(s!==null&&ou(s)))}function LI(s,r,l){switch(r.tag){case 3:Br(r,r.stateNode.containerInfo),pi(r,Ct,s.memoizedState.cache),Wi();break;case 27:case 5:to(r);break;case 4:Br(r,r.stateNode.containerInfo);break;case 10:pi(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,ff(r),null;break;case 13:var c=r.memoizedState;if(c!==null){if(c.dehydrated!==null)return _i(r),r.flags|=128,null;c=tr(s,r,l,!1);var h=r.child.childLanes;return c||(l&h)!==0?zb(s,r,l):(_i(r),s=Qs(s,r,l),s!==null?s.sibling:null)}_i(r);break;case 19:if(r.flags&128)return Lf(s,r,l);if(h=(s.flags&128)!==0,c=(l&r.childLanes)!==0,c||(tr(s,r,l,!1),c=(l&r.childLanes)!==0),h){if(c)return Lf(s,r,l);r.flags|=128}if(h=r.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),Eo(r,$t.current),c)break;return null;case 22:return r.lanes=0,Mb(s,r,l,r.pendingProps);case 24:pi(r,Ct,s.memoizedState.cache)}return Qs(s,r,l)}function Lb(s,r,l){if(s!==null)if(s.memoizedProps!==r.pendingProps)At=!0;else{if(!qf(s,l)&&(r.flags&128)===0)return At=!1,LI(s,r,l);At=(s.flags&131072)!==0}else At=!1,qe&&(r.flags&1048576)!==0&&yv(r,yo,r.index);switch(r.lanes=0,r.tag){case 16:e:{var c=r.pendingProps;if(s=rr(r.elementType),r.type=s,typeof s=="function")Yd(s)?(c=ur(s,c),r.tag=1,r=Db(null,r,s,c,l)):(r.tag=0,r=Df(null,r,s,c,l));else{if(s!=null){var h=s.$$typeof;if(h===ee){r.tag=11,r=Ab(null,r,s,c,l);break e}else if(h===ye){r.tag=14,r=Ib(null,r,s,c,l);break e}else if(h===Z){r.tag=10,r.type=s,r=Ub(null,r,l);break e}}throw r=B(s)||s,Error(i(306,r,""))}}return r;case 0:return Df(s,r,r.type,r.pendingProps,l);case 1:return c=r.type,h=ur(c,r.pendingProps),Db(s,r,c,h,l);case 3:e:{if(Br(r,r.stateNode.containerInfo),s===null)throw Error(i(387));c=r.pendingProps;var g=r.memoizedState;h=g.element,of(s,r),Co(r,c,null,l);var S=r.memoizedState;if(c=S.cache,pi(r,Ct,c),c!==g.cache&&ef(r,[Ct],l,!0),xo(),c=S.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=jb(s,r,c,l);break e}else if(c!==h){h=Hn(Error(i(424)),r),vo(h),r=jb(s,r,c,l);break e}else for(s=r.stateNode.containerInfo,s.nodeType===9?s=s.body:s=s.nodeName==="HTML"?s.ownerDocument.body:s,lt=Yn(s.firstChild),zt=r,qe=!0,fi=null,Gn=!0,l=Mv(r,null,c,l),r.child=l;l;)l.flags=l.flags&-3|134221824,l=l.sibling;else{if(Wi(),c===h){r=Qs(s,r,l);break e}kt(s,r,c,l)}r=r.child}return r;case 26:return la(s,r),s===null?(l=d0(r.type,null,r.pendingProps,null))?r.memoizedState=l:qe||(r.stateNode=$_(r.type,r.pendingProps,Ot.current,r)):r.memoizedState=d0(r.type,s.memoizedProps,r.pendingProps,s.memoizedState),null;case 27:return to(r),s===null&&qe&&(c=r.stateNode=o0(r.type,r.pendingProps,Ot.current),zt=r,Gn=!0,h=lt,Ri(r.type)?(Ph=h,lt=Yn(c.firstChild)):lt=h),kt(s,r,r.pendingProps.children,l),la(s,r),s===null&&(r.flags|=4194304),r.child;case 5:return s===null&&qe&&((h=c=lt)&&(c=DR(c,r.type,r.pendingProps,Gn),c!==null?(r.stateNode=c,zt=r,lt=Yn(c.firstChild),Gn=!1,h=!0):h=!1),h||hi(r)),to(r),h=r.type,g=r.pendingProps,S=s!==null?s.memoizedProps:null,c=g.children,Ih(h,g)?c=null:S!==null&&Ih(h,S)&&(r.flags|=32),r.memoizedState!==null&&(h=mf(s,r,RI,null,null,l),Ea._currentValue=h),la(s,r),kt(s,r,c,l),r.child;case 6:return s===null&&qe&&((s=l=lt)&&(l=jR(l,r.pendingProps,Gn),l!==null?(r.stateNode=l,zt=r,lt=null,s=!0):s=!1),s||hi(r)),null;case 13:return zb(s,r,l);case 4:return Br(r,r.stateNode.containerInfo),c=r.pendingProps,s===null?r.child=or(r,null,c,l):kt(s,r,c,l),r.child;case 11:return Ab(s,r,r.type,r.pendingProps,l);case 7:return c=r.pendingProps,la(s,r),kt(s,r,c,l),r.child;case 8:return kt(s,r,r.pendingProps.children,l),r.child;case 12:return kt(s,r,r.pendingProps.children,l),r.child;case 10:return Ub(s,r,l);case 9:return h=r.type._context,c=r.pendingProps.children,nr(r),h=Ht(h),c=c(h),r.flags|=1,kt(s,r,c,l),r.child;case 14:return Ib(s,r,r.type,r.pendingProps,l);case 15:return Rb(s,r,r.type,r.pendingProps,l);case 19:return Lf(s,r,l);case 31:return BI(s,r,l);case 22:return Mb(s,r,l,r.pendingProps);case 24:return nr(r),c=Ht(Ct),s===null?(h=sf(),h===null&&(h=at,g=tf(),h.pooledCache=g,g.refCount++,g!==null&&(h.pooledCacheLanes|=l),h=g),r.memoizedState={parent:c,cache:h},af(r),pi(r,Ct,h)):((s.lanes&l)!==0&&(of(s,r),Co(r,null,null,l),xo()),h=s.memoizedState,g=r.memoizedState,h.parent!==c?(h={parent:c,cache:c},r.memoizedState=h,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=h),pi(r,Ct,c)):(c=g.cache,pi(r,Ct,c),c!==h.cache&&ef(r,[Ct],l,!0))),kt(s,r,r.pendingProps.children,l),r.child;case 30:return r.stateNode===null&&(r.stateNode={autoName:null,paired:null,clones:null,ref:null}),c=r.pendingProps,c.name!=null&&c.name!=="auto"?r.flags|=s===null?18882560:18874368:qe&&iu(r),s!==null&&s.memoizedProps.name!==c.name?r.flags|=4194816:la(s,r),kt(s,r,c.children,l),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function Ks(s){s.flags|=4}function Hf(s,r,l,c,h){var g;if((g=(s.mode&32)!==0)&&(g=l===null?m0(r,c):m0(r,c)&&(c.src!==l.src||c.srcSet!==l.srcSet)),g){if(s.flags|=16777216,(h&335544128)===h)if(s.stateNode.complete)s.flags|=8192;else if(S_())s.flags|=8192;else throw ar=du,rf}else s.flags&=-16777217}function qb(s,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!g0(r))if(S_())s.flags|=8192;else throw ar=du,rf}function Mu(s,r){r!==null&&(s.flags|=4),s.flags&16384&&(r=s.tag!==22?my():536870912,s.lanes|=r,ha|=r)}function ko(s,r){if(!qe)switch(s.tailMode){case"visible":break;case"collapsed":for(var l=s.tail,c=null;l!==null;)l.alternate!==null&&(c=l),l=l.sibling;c===null?r||s.tail===null?s.tail=null:s.tail.sibling=null:c.sibling=null;break;default:for(r=s.tail,l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?s.tail=null:l.sibling=null}}function ut(s){var r=s.alternate!==null&&s.alternate.child===s.child,l=0,c=0;if(r)for(var h=s.child;h!==null;)l|=h.lanes|h.childLanes,c|=h.subtreeFlags&1206910976,c|=h.flags&1206910976,h.return=s,h=h.sibling;else for(h=s.child;h!==null;)l|=h.lanes|h.childLanes,c|=h.subtreeFlags,c|=h.flags,h.return=s,h=h.sibling;return s.subtreeFlags|=c,s.childLanes=l,r}function qI(s,r,l){var c=r.pendingProps;switch(Xd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ut(r),null;case 1:return ut(r),null;case 3:return l=r.stateNode,c=null,s!==null&&(c=s.memoizedState.cache),r.memoizedState.cache!==c&&(r.flags|=2048),Gs(Ct),oi(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(s===null||s.child===null)&&(ta(r)?Ks(r):s===null||s.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Zd())),ut(r),null;case 26:var h=r.type,g=r.memoizedState;return s===null?(Ks(r),g!==null?(ut(r),qb(r,g)):(ut(r),Hf(r,h,null,c,l))):g?g!==s.memoizedState?(Ks(r),ut(r),qb(r,g)):(ut(r),r.flags&=-16777217):(s=s.memoizedProps,s!==c&&Ks(r),ut(r),Hf(r,h,s,c,l)),null;case 27:if(Ur(r),l=Ot.current,h=r.type,s!==null&&r.stateNode!=null)s.memoizedProps!==c&&Ks(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return ut(r),r.subtreeFlags&=-33554433,null}s=ct.current,ta(r)?bv(r):(s=o0(h,c,l),r.stateNode=s,Ks(r))}return ut(r),r.subtreeFlags&=-33554433,null;case 5:if(Ur(r),h=r.type,s!==null&&r.stateNode!=null)s.memoizedProps!==c&&Ks(r);else{if(!c){if(r.stateNode===null)throw Error(i(166));return ut(r),r.subtreeFlags&=-33554433,null}if(g=ct.current,ta(r))bv(r);else{var S=Ho(Ot.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof c.is=="string"?S.createElement("select",{is:c.is}):S.createElement("select"),c.multiple?g.multiple=!0:c.size&&(g.size=c.size);break;default:g=typeof c.is=="string"?S.createElement(h,{is:c.is}):S.createElement(h)}}g[qt]=r,g[fn]=c;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=g;e:switch(Ft(g,h,c),h){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}c&&Ks(r)}}return ut(r),r.subtreeFlags&=-33554433,Hf(r,r.type,s===null?null:s.memoizedProps,r.pendingProps,l),null;case 6:if(s&&r.stateNode!=null)s.memoizedProps!==c&&Ks(r);else{if(typeof c!="string"&&r.stateNode===null)throw Error(i(166));if(s=Ot.current,ta(r)){if(s=r.stateNode,l=r.memoizedProps,c=null,h=zt,h!==null)switch(h.tag){case 27:case 5:c=h.memoizedProps}s[qt]=r,s=!!(s.nodeValue===l||c!==null&&c.suppressHydrationWarning===!0||L_(s.nodeValue,l)),s||hi(r,!0)}else s=Ho(s).createTextNode(c),s[qt]=r,r.stateNode=s}return ut(r),null;case 31:if(l=r.memoizedState,s===null||s.memoizedState!==null){if(c=ta(r),l!==null){if(s===null){if(!c)throw Error(i(318));if(s=r.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(i(557));s[qt]=r}else Wi(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),s=!1}else l=Zd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=l),s=!0;if(!s)return r.flags&256?(An(r),r):(An(r),null);if((r.flags&128)!==0)throw Error(i(558))}return ut(r),null;case 13:if(c=r.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(h=ta(r),c!==null&&c.dehydrated!==null){if(s===null){if(!h)throw Error(i(318));if(h=r.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(i(317));h[qt]=r}else Wi(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ut(r),h=!1}else h=Zd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=h),h=!0;if(!h)return r.flags&256?(An(r),r):(An(r),null)}return An(r),(r.flags&128)!==0?(r.lanes=l,r):(l=c!==null,s=s!==null&&s.memoizedState!==null,l&&(c=r.child,h=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(h=c.alternate.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==h&&(c.flags|=2048)),l!==s&&l&&(r.child.flags|=8192),Mu(r,r.updateQueue),ut(r),null);case 4:return oi(),s===null&&wh(r.stateNode.containerInfo),r.flags|=67108864,ut(r),null;case 10:return Gs(r.type),ut(r),null;case 19:if(hf(r),c=r.memoizedState,c===null)return ut(r),null;if(h=(r.flags&128)!==0,g=c.rendering,g===null)if(h)ko(c,!1);else{if(St!==0||s!==null&&(s.flags&128)!==0)for(s=r.child;s!==null;){if(g=mu(s),g!==null){for(r.flags|=128,ko(c,!1),s=g.updateQueue,r.updateQueue=s,Mu(r,s),r.subtreeFlags=0,s=l,l=r.child;l!==null;)pv(l,s),l=l.sibling;return Eo(r,$t.current&1|2),qe&&Vs(r,c.treeForkCount),r.child}s=s.sibling}c.tail!==null&&Lt()>Hu&&(r.flags|=128,h=!0,ko(c,!1),r.lanes=4194304)}else{if(!h)if(s=mu(g),s!==null){if(r.flags|=128,h=!0,s=s.updateQueue,r.updateQueue=s,Mu(r,s),ko(c,!0),c.tail===null&&c.tailMode!=="collapsed"&&c.tailMode!=="visible"&&!g.alternate&&!qe)return ut(r),null}else 2*Lt()-c.renderingStartTime>Hu&&l!==536870912&&(r.flags|=128,h=!0,ko(c,!1),r.lanes=4194304);c.isBackwards?(g.sibling=r.child,r.child=g):(s=c.last,s!==null?s.sibling=g:r.child=g,c.last=g)}if(c.tail!==null){s=c.tail;e:{for(l=s;l!==null;){if(l.alternate!==null){l=!1;break e}l=l.sibling}l=!0}return c.rendering=s,c.tail=s.sibling,c.renderingStartTime=Lt(),s.sibling=null,g=$t.current,g=h?g&1|2:g&1,c.tailMode==="visible"||c.tailMode==="collapsed"||!l||qe?Eo(r,g):(l=g,Ie(Vt,r),Ie($t,l),Kt===null&&(Kt=r)),qe&&Vs(r,c.treeForkCount),s}return ut(r),null;case 22:case 23:return An(r),df(),c=r.memoizedState!==null,s!==null?s.memoizedState!==null!==c&&(r.flags|=8192):c&&(r.flags|=8192),c?(l&536870912)!==0&&(r.flags&128)===0&&(ut(r),r.subtreeFlags&6&&(r.flags|=8192)):ut(r),l=r.updateQueue,l!==null&&Mu(r,l.retryQueue),l=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),c=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),c!==l&&(r.flags|=2048),s!==null&&Ae(ir),null;case 24:return l=null,s!==null&&(l=s.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),Gs(Ct),ut(r),null;case 25:return null;case 30:return r.flags|=33554432,ut(r),null}throw Error(i(156,r.tag))}function HI(s,r){switch(Xd(r),r.tag){case 1:return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 3:return Gs(Ct),oi(),s=r.flags,(s&65536)!==0&&(s&128)===0?(r.flags=s&-65537|128,r):null;case 26:case 27:case 5:return Ur(r),null;case 31:if(r.memoizedState!==null){if(An(r),r.alternate===null)throw Error(i(340));Wi()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 13:if(An(r),s=r.memoizedState,s!==null&&s.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Wi()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 19:return hf(r),s=r.flags,s&65536?(r.flags=s&-65537|128,s=r.memoizedState,s!==null&&(s.rendering=null,s.tail=null),r.flags|=4,r):null;case 4:return oi(),null;case 10:return Gs(r.type),null;case 22:case 23:return An(r),df(),s!==null&&Ae(ir),s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 24:return Gs(Ct),null;case 25:return null;default:return null}}function Hb(s,r){switch(Xd(r),r.tag){case 3:Gs(Ct),oi();break;case 26:case 27:case 5:Ur(r);break;case 4:oi();break;case 31:r.memoizedState!==null&&An(r);break;case 13:An(r);break;case 19:hf(r);break;case 10:Gs(r.type);break;case 22:case 23:An(r),df(),s!==null&&Ae(ir);break;case 24:Gs(Ct)}}function No(s,r){try{var l=r.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var h=c.next;l=h;do{if((l.tag&s)===s){c=void 0;var g=l.create,S=l.inst;c=g(),S.destroy=c}l=l.next}while(l!==h)}}catch(A){nt(r,r.return,A)}}function Ti(s,r,l){try{var c=r.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var g=h.next;c=g;do{if((c.tag&s)===s){var S=c.inst,A=S.destroy;if(A!==void 0){S.destroy=void 0,h=r;var j=l,Y=A;try{Y()}catch(ne){nt(h,j,ne)}}}c=c.next}while(c!==g)}}catch(ne){nt(r,r.return,ne)}}function Vb(s){var r=s.updateQueue;if(r!==null){var l=s.stateNode;try{Nv(r,l)}catch(c){nt(s,s.return,c)}}}function $b(s,r,l){l.props=ur(s.type,s.memoizedProps),l.state=s.memoizedState;try{l.componentWillUnmount()}catch(c){nt(s,r,c)}}function vs(s,r){try{var l=s.ref;if(l!==null){switch(s.tag){case 26:case 27:case 5:var c=s.stateNode;break;case 30:var h=s.stateNode,g=Ls(s.memoizedProps,h);(h.ref===null||h.ref.name!==g)&&(h.ref=J_(g)),c=h.ref;break;case 7:if(s.stateNode===null){var S=new Nn(s);y(s.child,!1,NR,S,void 0,void 0),s.stateNode=S}c=s.stateNode;break;default:c=s.stateNode}typeof l=="function"?s.refCleanup=l(c):l.current=c}}catch(A){nt(s,r,A)}}function Gt(s,r){var l=s.ref,c=s.refCleanup;if(l!==null)if(typeof c=="function")try{c()}catch(h){nt(s,r,h)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(h){nt(s,r,h)}else l.current=null}function ku(s,r){if((s.tag===5||s.tag===27||s.tag===6)&&s.alternate===null&&r!==null)for(var l=0;l<r.length;l++)s0(s.stateNode,r[l])}function Gb(s){for(var r=s.return;r!==null&&($f(r)&&s0(s.stateNode,r.stateNode),!Vf(r));)r=r.return}function Oo(s){for(var r=s.return;r!==null&&($f(r)&&OR(s.stateNode,r.stateNode),!Vf(r));)r=r.return}function Vf(s){return s.tag===5||s.tag===3||s.tag===27}function $f(s){return s&&s.tag===7&&s.stateNode!==null}function Gf(s){var r=s.type,l=s.memoizedProps,c=s.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&c.focus();break e;case"img":l.src?c.src=l.src:l.srcSet&&(c.srcset=l.srcSet)}}catch(h){nt(s,s.return,h)}}function Ff(s,r,l){try{var c=s.stateNode;pR(c,s.type,l,r),c[fn]=r}catch(h){nt(s,s.return,h)}}function Fb(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Ri(s.type)||s.tag===4}function Yf(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Fb(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Ri(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Qf(s,r,l,c){var h=s.tag;if(h===5||h===6)h=s.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(h,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(h),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=ms)),ku(s,c),Xe=!0;else if(h!==4&&(h===27&&(ku(s,c),c=null,Ri(s.type)&&(l=s.stateNode,r=null)),s=s.child,s!==null))for(Qf(s,r,l,c),s=s.sibling;s!==null;)Qf(s,r,l,c),s=s.sibling}function Nu(s,r,l,c){var h=s.tag;if(h===5||h===6)h=s.stateNode,r?l.insertBefore(h,r):l.appendChild(h),ku(s,c),Xe=!0;else if(h!==4&&(h===27&&(ku(s,c),c=null,Ri(s.type)&&(l=s.stateNode)),s=s.child,s!==null))for(Nu(s,r,l,c),s=s.sibling;s!==null;)Nu(s,r,l,c),s=s.sibling}function Yb(s){var r=s.stateNode,l=s.memoizedProps;try{for(var c=s.type,h=r.attributes;h.length;)r.removeAttributeNode(h[0]);Ft(r,c,l),r[qt]=s,r[fn]=l}catch(g){nt(s,s.return,g)}}var Ou=!1,In=null;function Qb(s){(s.tag===30||(s.subtreeFlags&33554432)!==0)&&(Ou=!0)}var bs=null;function Kb(){var s=bs;return bs=null,s}var pn=0;function ua(s,r,l,c,h){return pn=0,Xb(s.child,r,l,c,h)}function Xb(s,r,l,c,h){for(var g=!1;s!==null;){if(s.tag===5){var S=s.stateNode;if(c!==null){var A=kh(S);c.push(A),A.view&&(g=!0)}else g||kh(S).view&&(g=!0);Ou=!0,K_(S,pn===0?r:r+"_"+pn,l),pn++}else(s.tag!==22||s.memoizedState===null)&&(s.tag===30&&h||Xb(s.child,r,l,c,h)&&(g=!0));s=s.sibling}return g}function _s(s,r){for(;s!==null;)s.tag===5?X_(s.stateNode,s.memoizedProps):(s.tag!==22||s.memoizedState===null)&&(s.tag===30&&r||_s(s.child,r)),s=s.sibling}function Du(s){if((s.subtreeFlags&18874368)!==0)for(s=s.child;s!==null;){if((s.tag!==22||s.memoizedState===null)&&(Du(s),s.tag===30&&(s.flags&18874368)!==0&&s.stateNode.paired)){var r=s.memoizedProps;if(r.name==null||r.name==="auto")throw Error(i(544));var l=r.name;r=qs(r.default,r.share),r!=="none"&&(ua(s,l,r,null,!1)||_s(s.child,!1))}s=s.sibling}}function Kf(s,r){if(s.tag===30){var l=s.stateNode,c=s.memoizedProps,h=Ls(c,l),g=qs(c.default,l.paired?c.share:c.enter);g!=="none"?ua(s,h,g,null,!1)?(Du(s),l.paired||r||ya(s,c.onEnter)):_s(s.child,!1):Du(s)}else if((s.subtreeFlags&33554432)!==0)for(s=s.child;s!==null;)Kf(s,r),s=s.sibling;else Du(s)}function Xf(s){if(In!==null&&In.size!==0){var r=In;if((s.subtreeFlags&18874368)!==0)for(s=s.child;s!==null;){if(s.tag!==22||s.memoizedState===null){if(s.tag===30&&(s.flags&18874368)!==0){var l=s.memoizedProps,c=l.name;if(c!=null&&c!=="auto"){var h=r.get(c);if(h!==void 0){var g=qs(l.default,l.share);if(g!=="none"&&(ua(s,c,g,null,!1)?(g=s.stateNode,h.paired=g,g.paired=h,ya(s,l.onShare)):_s(s.child,!1)),r.delete(c),r.size===0)break}}}Xf(s)}s=s.sibling}}}function Jf(s){if(s.tag===30){var r=s.memoizedProps,l=Ls(r,s.stateNode),c=In!==null?In.get(l):void 0,h=qs(r.default,c!==void 0?r.share:r.exit);h!=="none"&&(ua(s,l,h,null,!1)?c!==void 0?(h=s.stateNode,c.paired=h,h.paired=c,In.delete(l),ya(s,r.onShare)):ya(s,r.onExit):_s(s.child,!1)),In!==null&&Xf(s)}else if((s.subtreeFlags&33554432)!==0)for(s=s.child;s!==null;)Jf(s),s=s.sibling;else In!==null&&Xf(s)}function Jb(s){for(s=s.child;s!==null;){if(s.tag===30){var r=s.memoizedProps,l=Ls(r,s.stateNode);r=qs(r.default,r.update),s.flags&=-5,r!=="none"&&ua(s,l,r,s.memoizedState=[],!1)}else(s.subtreeFlags&33554432)!==0&&Jb(s);s=s.sibling}}function Zf(s){if((s.subtreeFlags&18874368)!==0)for(s=s.child;s!==null;){if(s.tag!==22||s.memoizedState===null){if(s.tag===30&&(s.flags&18874368)!==0){var r=s.stateNode;r.paired!==null&&(r.paired=null,_s(s.child,!1))}Zf(s)}s=s.sibling}}function ju(s){if(s.tag===30)s.stateNode.paired=null,_s(s.child,!1),Zf(s);else if((s.subtreeFlags&33554432)!==0)for(s=s.child;s!==null;)ju(s),s=s.sibling;else Zf(s)}function Zb(s){for(s=s.child;s!==null;)s.tag===30?_s(s.child,!1):(s.subtreeFlags&33554432)!==0&&Zb(s),s=s.sibling}function Wf(s,r,l,c,h,g,S){for(var A=!1;r!==null;){if(r.tag===5){var j=r.stateNode;if(g!==null&&pn<g.length){var Y=g[pn],ne=kh(j);(Y.view||ne.view)&&(A=!0);var ue;if(ue=(s.flags&4)===0)if(ne.clip)ue=!0;else{ue=Y.rect;var G=ne.rect;ue=ue.y!==G.y||ue.x!==G.x||ue.height!==G.height||ue.width!==G.width}ue&&(s.flags|=4),ne.abs?ne=!Y.abs:(Y=Y.rect,ne=ne.rect,ne=Y.height!==ne.height||Y.width!==ne.width),ne&&(s.flags|=32)}else s.flags|=32;(s.flags&4)!==0&&K_(j,pn===0?l:l+"_"+pn,h),A&&(s.flags&4)!==0||(bs===null&&(bs=[]),bs.push(j,pn===0?c:c+"_"+pn,r.memoizedProps)),pn++}else(r.tag!==22||r.memoizedState===null)&&(r.tag===30&&S?s.flags|=r.flags&32:Wf(s,r.child,l,c,h,g,S)&&(A=!0));r=r.sibling}return A}function Wb(s,r){for(s=s.child;s!==null;){if(s.tag===30){var l=s.memoizedProps,c=s.stateNode,h=Ls(l,c),g=qs(l.default,l.update),S;S=s.memoizedState,s.memoizedState=null,c=s;var A=s.child;pn=0,h=Wf(c,A,h,h,g,S,!1),(s.flags&4)!==0&&h&&ya(s,l.onUpdate)}else(s.subtreeFlags&33554432)!==0&&Wb(s);s=s.sibling}}var Pt=!1,We=!1,Ss=!1,eh=!1,e_=typeof WeakSet=="function"?WeakSet:Set,Bt=null,Ts=!1,Do=!1,zu=!1,th=!1;function VI(s,r,l){if(s=s.containerInfo,Eh=Aa,s=iv(s),Ld(s)){if("selectionStart"in s)var c={start:s.selectionStart,end:s.selectionEnd};else e:{c=(c=s.ownerDocument)&&c.defaultView||window;var h=c.getSelection&&c.getSelection();if(h&&h.rangeCount!==0){c=h.anchorNode;var g=h.anchorOffset,S=h.focusNode;h=h.focusOffset;try{c.nodeType,S.nodeType}catch{c=null;break e}var A=0,j=-1,Y=-1,ne=0,ue=0,G=s,J=null;t:for(;;){for(var Se;G!==c||g!==0&&G.nodeType!==3||(j=A+g),G!==S||h!==0&&G.nodeType!==3||(Y=A+h),G.nodeType===3&&(A+=G.nodeValue.length),(Se=G.firstChild)!==null;)J=G,G=Se;for(;;){if(G===s)break t;if(J===c&&++ne===g&&(j=A),J===S&&++ue===h&&(Y=A),(Se=G.nextSibling)!==null)break;G=J,J=G.parentNode}G=Se}c=j===-1||Y===-1?null:{start:j,end:Y}}else c=null}c=c||{start:0,end:0}}else c=null;for(Ah={focusedElem:s,selectionRange:c},Aa=!1,l=(l&335544064)===l,Bt=r,r=l?9270:1024;Bt!==null;){if(s=Bt,l&&(c=s.deletions,c!==null))for(g=0;g<c.length;g++)l&&Jf(c[g]);if(s.alternate===null&&(s.flags&2)!==0)l&&Qb(s),Pu(l);else{if(s.tag===22){if(c=s.alternate,s.memoizedState!==null){c!==null&&c.memoizedState===null&&l&&Jf(c),Pu(l);continue}else if(c!==null&&c.memoizedState!==null){l&&Qb(s),Pu(l);continue}}c=s.child,(s.subtreeFlags&r)!==0&&c!==null?(c.return=s,Bt=c):(l&&Jb(s),Pu(l))}}In=null}function Pu(s){for(;Bt!==null;){var r=Bt,l=s,c=r.alternate,h=r.flags;switch(r.tag){case 0:case 11:case 15:break;case 1:if((h&1024)!==0&&c!==null){l=void 0,h=c.memoizedProps,c=c.memoizedState;var g=r.stateNode;try{var S=ur(r.type,h);l=g.getSnapshotBeforeUpdate(S,c),g.__reactInternalSnapshotBeforeUpdate=l}catch(A){nt(r,r.return,A)}}break;case 3:if((h&1024)!==0){if(c=r.stateNode.containerInfo,l=c.nodeType,l===9)Dh(c);else if(l===1)switch(c.nodeName){case"HEAD":case"HTML":case"BODY":Dh(c);break;default:c.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:l&&c!==null&&(l=Ls(c.memoizedProps,c.stateNode),h=r.memoizedProps,h=qs(h.default,h.update),h!=="none"&&ua(c,l,h,c.memoizedState=[],!0));break;default:if((h&1024)!==0)throw Error(i(163))}if(c=r.sibling,c!==null){c.return=r.return,Bt=c;break}Bt=r.return}}function t_(s,r,l){var c=l.flags;switch(l.tag){case 0:case 11:case 15:ws(s,l),c&4&&No(5,l);break;case 1:if(ws(s,l),c&4)if(s=l.stateNode,r===null)try{s.componentDidMount()}catch(S){nt(l,l.return,S)}else{var h=ur(l.type,r.memoizedProps);r=r.memoizedState;try{s.componentDidUpdate(h,r,s.__reactInternalSnapshotBeforeUpdate)}catch(S){nt(l,l.return,S)}}c&64&&Vb(l),c&512&&vs(l,l.return);break;case 3:if(ws(s,l),c&64&&(s=l.updateQueue,s!==null)){if(r=null,l.child!==null)switch(l.child.tag){case 27:case 5:r=l.child.stateNode;break;case 1:r=l.child.stateNode}try{Nv(s,r)}catch(S){nt(l,l.return,S)}}break;case 27:r===null&&c&4&&Yb(l);case 26:case 5:ws(s,l),r===null&&c&4&&Gf(l),c&512&&vs(l,l.return);break;case 12:ws(s,l);break;case 31:ws(s,l),c&4&&r_(s,l);break;case 13:ws(s,l),c&4&&a_(s,l),c&64&&(s=l.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(l=tR.bind(null,l),zR(s,l))));break;case 22:if(c=l.memoizedState!==null||Pt,!c){var g=r!==null&&r.memoizedState!==null||We;r=Pt,h=We,Pt=c,(We=g)&&!h?(c=2,(l.subtreeFlags&8772)!==0&&(c|=1),as(s,l,c)):ws(s,l),Pt=r,We=h}break;case 30:ws(s,l),c&512&&vs(l,l.return);break;case 7:c&512&&vs(l,l.return);default:ws(s,l)}}function nh(s,r){for(s=s.child;s!==null;)n_(s,r),s=s.sibling}function n_(s,r){switch(s.tag){case 5:case 26:try{var l=s.stateNode;if(r){var c=l.style;typeof c.setProperty=="function"?c.setProperty("display","none","important"):c.display="none"}else{var h=s.stateNode,g=s.memoizedProps.style,S=g!=null&&g.hasOwnProperty("display")?g.display:null;h.style.display=S==null||typeof S=="boolean"?"":(""+S).trim()}}catch(j){nt(s,s.return,j)}sh(s,r);break;case 6:try{s.stateNode.nodeValue=r?"":s.memoizedProps,Xe=!0}catch(j){nt(s,s.return,j)}break;case 18:try{var A=s.stateNode;r?Q_(A,!0):Q_(s.stateNode,!1)}catch(j){nt(s,s.return,j)}break;case 22:case 23:s.memoizedState===null&&nh(s,r);break;default:nh(s,r)}}function sh(s,r){if(s.subtreeFlags&67108864)for(s=s.child;s!==null;){e:{var l=s,c=r;switch(l.tag){case 4:n_(l,c);break e;case 22:l.memoizedState===null&&sh(l,c);break e;default:sh(l,c)}}s=s.sibling}}function s_(s){var r=s.alternate;r!==null&&(s.alternate=null,s_(r)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(r=s.stateNode,r!==null&&Hl(r)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var pt=null,mn=!1;function is(s,r,l){for(l=l.child;l!==null;)i_(s,r,l),l=l.sibling}function i_(s,r,l){if(wn&&typeof wn.onCommitFiberUnmount=="function")try{wn.onCommitFiberUnmount(no,l)}catch{}switch(l.tag){case 26:We||Gt(l,r),is(s,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&!We&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:We||Gt(l,r),Oo(l);var c=pt,h=mn;Ri(l.type)&&(pt=l.stateNode,mn=!1),is(s,r,l),l0(l.stateNode,l.type,l.memoizedProps),pt=c,mn=h;break;case 5:We||Gt(l,r),Oo(l);case 6:if(l.tag===6&&Oo(l),c=pt,h=mn,pt=null,is(s,r,l),pt=c,mn=h,pt!==null)if(mn)try{(pt.nodeType===9?pt.body:pt.nodeName==="HTML"?pt.ownerDocument.body:pt).removeChild(l.stateNode),Xe=!0}catch(g){nt(l,r,g)}else try{pt.removeChild(l.stateNode),Xe=!0}catch(g){nt(l,r,g)}break;case 18:pt!==null&&(mn?(s=pt,Y_(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,l.stateNode),Ia(s)):Y_(pt,l.stateNode));break;case 4:c=pt,h=mn,pt=l.stateNode.containerInfo,mn=!0,is(s,r,l),pt=c,mn=h;break;case 0:case 11:case 14:case 15:Ti(2,l,r),We||Ti(4,l,r),is(s,r,l);break;case 1:We||(Gt(l,r),c=l.stateNode,typeof c.componentWillUnmount=="function"&&$b(l,r,c)),is(s,r,l);break;case 21:is(s,r,l);break;case 22:We=(c=We)||l.memoizedState!==null,is(s,r,l),We=c;break;case 30:Gt(l,r),is(s,r,l);break;case 7:We||Gt(l,r),is(s,r,l);break;default:is(s,r,l)}}function r_(s,r){if(r.memoizedState===null&&(s=r.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Ia(s)}catch(l){nt(r,r.return,l)}}}function a_(s,r){if(r.memoizedState===null&&(s=r.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Ia(s)}catch(l){nt(r,r.return,l)}}function $I(s){switch(s.tag){case 31:case 13:case 19:var r=s.stateNode;return r===null&&(r=s.stateNode=new e_),r;case 22:return s=s.stateNode,r=s._retryCache,r===null&&(r=s._retryCache=new e_),r;default:throw Error(i(435,s.tag))}}function Bu(s,r){var l=$I(s);r.forEach(function(c){if(!l.has(c)){l.add(c);var h=nR.bind(null,s,c);c.then(h,h)}})}function sn(s,r,l){var c=r.deletions;if(c!==null)for(var h=0;h<c.length;h++){var g=c[h],S=s,A=r,j=A;e:for(;j!==null;){switch(j.tag){case 27:if(Ri(j.type)){pt=j.stateNode,mn=!1;break e}break;case 5:pt=j.stateNode,mn=!1;break e;case 3:case 4:pt=j.stateNode.containerInfo,mn=!0;break e}j=j.return}if(pt===null)throw Error(i(160));i_(S,A,g),pt=null,mn=!1,S=g.alternate,S!==null&&(S.return=null),g.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)o_(r,s,l),r=r.sibling}var rs=null;function o_(s,r,l){var c=s.alternate,h=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(h&4&&(c=s.updateQueue,c=c!==null?c.events:null,c!==null))for(var g=0;g<c.length;g++){var S=c[g];S.ref.impl=S.nextImpl}sn(r,s,l),rn(s),h&4&&(Ti(3,s,s.return),No(3,s),Ti(5,s,s.return));break;case 1:sn(r,s,l),rn(s),h&512&&(We||c===null||Gt(c,c.return)),h&64&&Pt&&(s=s.updateQueue,s!==null&&(r=s.callbacks,r!==null&&(l=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=l===null?r:l.concat(r))));break;case 26:if(g=rs,sn(r,s,l),rn(s),h&512&&(We||c===null||Gt(c,c.return)),h&4)if(h=c!==null?c.memoizedState:null,l=s.memoizedState,c===null)if(l===null)if(s.stateNode===null)if(Pt)s.stateNode=$_(s.type,s.memoizedProps,r.containerInfo,s);else{e:{r=s.type,l=s.memoizedProps,h=g.ownerDocument||g;t:switch(r){case"title":c=h.getElementsByTagName("title")[0],(!c||c[ro]||c[qt]||c.namespaceURI==="http://www.w3.org/2000/svg"||c.hasAttribute("itemprop"))&&(c=h.createElement(r),h.head.insertBefore(c,h.querySelector("head > title"))),Ft(c,r,l),c[qt]=s,jt(c),r=c;break e;case"link":if(g=p0("link","href",h).get(r+(l.href||""))){for(S=0;S<g.length;S++)if(c=g[S],c.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&c.getAttribute("rel")===(l.rel==null?null:l.rel)&&c.getAttribute("title")===(l.title==null?null:l.title)&&c.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){g.splice(S,1);break t}}c=h.createElement(r),Ft(c,r,l),h.head.appendChild(c);break;case"meta":if(g=p0("meta","content",h).get(r+(l.content||""))){for(S=0;S<g.length;S++)if(c=g[S],c.getAttribute("content")===(l.content==null?null:""+l.content)&&c.getAttribute("name")===(l.name==null?null:l.name)&&c.getAttribute("property")===(l.property==null?null:l.property)&&c.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&c.getAttribute("charset")===(l.charSet==null?null:l.charSet)){g.splice(S,1);break t}}c=h.createElement(r),Ft(c,r,l),h.head.appendChild(c);break;default:throw Error(i(468,r))}c[qt]=s,jt(c),r=c}s.stateNode=r}else Pt||qh(g,s.type,s.stateNode);else s.stateNode=h0(g,l,s.memoizedProps);else h!==l?(h===null?(r=c.stateNode,r===null||We||r.parentNode.removeChild(r)):h.count--,l===null?Pt||qh(g,s.type,s.stateNode):h0(g,l,s.memoizedProps)):l===null&&s.stateNode!==null&&Ff(s,s.memoizedProps,c.memoizedProps);break;case 27:sn(r,s,l),rn(s),h&512&&(We||c===null||Gt(c,c.return)),c!==null&&h&4&&Ff(s,s.memoizedProps,c.memoizedProps);break;case 5:if(g=Ss,Ss=!1,sn(r,s,l),Ss=g,rn(s),h&512&&(We||c===null||Gt(c,c.return)),s.flags&32){r=s.stateNode;try{Gr(r,""),Xe=!0}catch(ne){nt(s,s.return,ne)}}h&4&&s.stateNode!=null&&(r=s.memoizedProps,Ff(s,r,c!==null?c.memoizedProps:r)),h&1024&&(eh=!0);break;case 6:if(sn(r,s,l),rn(s),h&4){if(s.stateNode===null)throw Error(i(162));r=s.memoizedProps,l=s.stateNode;try{l.nodeValue=r,Xe=!0}catch(ne){nt(s,s.return,ne)}}break;case 3:if(Xe=!1,Wu=null,g=rs,rs=Vo(r.containerInfo),sn(r,s,l),rs=g,rn(s),h&4&&c!==null&&c.memoizedState.isDehydrated)try{Ia(r.containerInfo)}catch(ne){nt(s,s.return,ne)}eh&&(eh=!1,l_(s)),Xe=!1;break;case 4:h=Ss,Ss=Pt,c=Iy(),g=rs,rs=Vo(s.stateNode.containerInfo),sn(r,s,l),rn(s),rs=g,Xe&&Do&&(zu=!0),Xe=c,Ss=h;break;case 12:sn(r,s,l),rn(s);break;case 31:sn(r,s,l),rn(s),h&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,Bu(s,r)));break;case 13:sn(r,s,l),rn(s),s.child.flags&8192&&s.memoizedState!==null!=(c!==null&&c.memoizedState!==null)&&(qu=Lt()),h&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,Bu(s,r)));break;case 22:g=s.memoizedState!==null,S=c!==null&&c.memoizedState!==null;var A=Pt,j=We,Y=Ss;Pt=A||g,Ss=Y||g,We=j||S,sn(r,s,l),We=j,Ss=Y,Pt=A,rn(s),h&8192&&(r=s.stateNode,r._visibility=g?r._visibility&-2:r._visibility|1,!g||c===null||S||Pt||We||(r=S||We,l=Pt,c=We,Pt=g||Pt,We=r,wi(s,2),Pt=l,We=c),!g&&Ss||nh(s,g)),h&4&&(r=s.updateQueue,r!==null&&(l=r.retryQueue,l!==null&&(r.retryQueue=null,Bu(s,l))));break;case 19:sn(r,s,l),rn(s),h&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,Bu(s,r)));break;case 30:h&512&&(We||c===null||Gt(c,c.return)),h=Iy(),g=Do,S=(l&335544064)===l,A=s.memoizedProps,Do=S&&qs(A.default,A.update)!=="none",sn(r,s,l),rn(s),S&&c!==null&&Xe&&(s.flags|=4),Do=g,Xe=h;break;case 21:break;case 7:h&512&&(We||c===null||Gt(c,c.return)),c&&c.stateNode!==null&&(c.stateNode._fragmentFiber=s);default:sn(r,s,l),rn(s)}}function rn(s){var r=s.flags;if(r&2){try{for(var l,c=s.return;c!==null;){if(Fb(c)){l=c;break}c=c.return}c=null;for(var h=s.return;h!==null;){if($f(h)){var g=h.stateNode;c===null?c=[g]:c.push(g)}if(Vf(h))break;h=h.return}var S=c;if(l==null)throw Error(i(160));switch(l.tag){case 27:var A=l.stateNode,j=Yf(s);Nu(s,j,A,S);break;case 5:var Y=l.stateNode;l.flags&32&&(Gr(Y,""),l.flags&=-33);var ne=Yf(s);Nu(s,ne,Y,S);break;case 3:case 4:var ue=l.stateNode.containerInfo,G=Yf(s);Qf(s,G,ue,S);break;default:throw Error(i(161))}}catch(J){nt(s,s.return,J)}s.flags&=-3}r&4096&&(s.flags&=-4097)}function l_(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var r=s;l_(r),r.tag===5&&r.flags&1024&&(r=r.stateNode,Aa=!0,r.reset(),Aa=!1),s=s.sibling}}function ca(s,r){if(r.subtreeFlags&9270)for(r=r.child;r!==null;)u_(r,s),r=r.sibling;else Wb(r)}function u_(s,r){var l=s.alternate;if(l===null)Kf(s,!1);else switch(s.tag){case 3:if(th=Ts=!1,Kb(),ca(r,s),!Ts&&!zu){if(s=bs,s!==null)for(var c=0;c<s.length;c+=3){l=s[c];var h=s[c+1];X_(l,s[c+2]),l=l.ownerDocument.documentElement,l!==null&&l.animate({opacity:[0,0],pointerEvents:["none","none"]},{duration:0,fill:"forwards",pseudoElement:"::view-transition-group("+h+")"})}s=r.containerInfo,s=s.nodeType===9?s.documentElement:s.ownerDocument.documentElement,s!==null&&s.style.viewTransitionName===""&&(s.style.viewTransitionName="none",s.animate({opacity:[0,0],pointerEvents:["none","none"]},{duration:0,fill:"forwards",pseudoElement:"::view-transition-group(root)"}),s.animate({width:[0,0],height:[0,0]},{duration:0,fill:"forwards",pseudoElement:"::view-transition"})),th=!0}bs=null;break;case 5:ca(r,s);break;case 4:c=Ts,Ts=!1,ca(r,s),Ts&&(zu=!0),Ts=c;break;case 22:s.memoizedState===null&&(l.memoizedState!==null?Kf(s,!1):ca(r,s));break;case 30:c=Ts,h=Kb(),Ts=!1,ca(r,s),Ts&&(s.flags|=4);var g=s.memoizedProps,S=s.stateNode;r=Ls(g,S),S=Ls(l.memoizedProps,S);var A=qs(g.default,g.update);A==="none"?r=!1:(g=l.memoizedState,l.memoizedState=null,l=s.child,pn=0,r=Wf(s,l,r,S,A,g,!0),pn!==(g===null?0:g.length)&&(s.flags|=32)),(s.flags&4)!==0&&r?(ya(s,s.memoizedProps.onUpdate),bs=h):h!==null&&(h.push.apply(h,bs),bs=h),Ts=(s.flags&32)!==0?!0:c;break;default:ca(r,s)}}function ws(s,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)t_(s,r.alternate,r),r=r.sibling}function wi(s,r){for(s=s.child;s!==null;){var l=s,c=r;switch(l.tag){case 0:case 11:case 14:case 15:Ti(4,l,l.return),wi(l,c);break;case 1:Gt(l,l.return);var h=l.stateNode;typeof h.componentWillUnmount=="function"&&$b(l,l.return,h),wi(l,c);break;case 27:(c&2)!==0&&l0(l.stateNode,l.type,l.memoizedProps);case 5:Gt(l,l.return),l.tag!==5&&l.tag!==27||Oo(l),wi(l,c);break;case 6:Oo(l);break;case 26:Gt(l,l.return),h=l.stateNode,l.memoizedState!==null||h===null||We||h.parentNode.removeChild(h),wi(l,c);break;case 22:l.memoizedState===null&&wi(l,c);break;case 30:Gt(l,l.return),wi(l,c);break;case 7:Gt(l,l.return);default:wi(l,c)}s=s.sibling}}function as(s,r,l){for(l=(r.subtreeFlags&8772)!==0?l:l&-2,r=r.child;r!==null;){var c=r.alternate,h=s,g=r,S=g.flags,A=(l&1)!==0;switch(g.tag){case 0:case 11:case 15:as(h,g,l),No(4,g);break;case 1:if(as(h,g,l),c=g,h=c.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(ne){nt(c,c.return,ne)}if(c=g,h=c.updateQueue,h!==null){var j=c.stateNode;try{var Y=h.shared.hiddenCallbacks;if(Y!==null)for(h.shared.hiddenCallbacks=null,h=0;h<Y.length;h++)kv(Y[h],j)}catch(ne){nt(c,c.return,ne)}}A&&S&64&&Vb(g),vs(g,g.return);break;case 27:(l&2)!==0&&Yb(g);case 5:g.tag!==5&&g.tag!==27||Gb(g),as(h,g,l),A&&c===null&&S&4&&Gf(g),vs(g,g.return);break;case 6:Gb(g);break;case 26:j=g.stateNode,g.memoizedState!==null||j===null||Pt||qh(Vo(j.ownerDocument),g.type,j),as(h,g,l),A&&c===null&&S&4&&Gf(g),vs(g,g.return);break;case 12:as(h,g,l);break;case 31:as(h,g,l),A&&S&4&&r_(h,g);break;case 13:as(h,g,l),A&&S&4&&a_(h,g);break;case 22:g.memoizedState===null&&as(h,g,l),vs(g,g.return);break;case 30:as(h,g,l),vs(g,g.return);break;case 7:vs(g,g.return);default:as(h,g,l)}r=r.sibling}}function ih(s,r){var l=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),s=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(s=r.memoizedState.cachePool.pool),s!==l&&(s!=null&&s.refCount++,l!=null&&bo(l))}function rh(s,r){s=null,r.alternate!==null&&(s=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==s&&(r.refCount++,s!=null&&bo(s))}function Fn(s,r,l,c){var h=(l&335544064)===l;if(r.subtreeFlags&(h?10262:10256))for(r=r.child;r!==null;)c_(s,r,l,c),r=r.sibling;else h&&Zb(r)}function c_(s,r,l,c){var h=(l&335544064)===l;h&&r.alternate===null&&r.return!==null&&r.return.alternate!==null&&ju(r);var g=r.flags;switch(r.tag){case 0:case 11:case 15:Fn(s,r,l,c),g&2048&&No(9,r);break;case 1:Fn(s,r,l,c);break;case 3:Fn(s,r,l,c),h&&th&&(s=s.containerInfo,s=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,s.style.viewTransitionName==="root"&&(s.style.viewTransitionName=""),s=s.ownerDocument.documentElement,s!==null&&s.style.viewTransitionName==="none"&&(s.style.viewTransitionName="")),g&2048&&(g=null,r.alternate!==null&&(g=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==g&&(r.refCount++,g!=null&&bo(g)));break;case 12:if(g&2048){Fn(s,r,l,c),g=r.stateNode;try{var S=r.memoizedProps,A=S.id,j=S.onPostCommit;typeof j=="function"&&j(A,r.alternate===null?"mount":"update",g.passiveEffectDuration,-0)}catch(Y){nt(r,r.return,Y)}}else Fn(s,r,l,c);break;case 31:Fn(s,r,l,c);break;case 13:Fn(s,r,l,c);break;case 23:break;case 22:S=r.stateNode,A=r.alternate,r.memoizedState!==null?(h&&A!==null&&A.memoizedState===null&&ju(A),S._visibility&2?Fn(s,r,l,c):jo(s,r)):(h&&A!==null&&A.memoizedState!==null&&ju(r),S._visibility&2?Fn(s,r,l,c):(S._visibility|=2,da(s,r,l,c,(r.subtreeFlags&10256)!==0||!1))),g&2048&&ih(A,r);break;case 24:Fn(s,r,l,c),g&2048&&rh(r.alternate,r);break;case 30:h&&(g=r.alternate,g!==null&&(_s(g.child,!0),_s(r.child,!0))),Fn(s,r,l,c);break;default:Fn(s,r,l,c)}}function da(s,r,l,c,h){for(h=h&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=s,S=r,A=l,j=c,Y=S.flags;switch(S.tag){case 0:case 11:case 15:da(g,S,A,j,h),No(8,S);break;case 23:break;case 22:var ne=S.stateNode;S.memoizedState!==null?ne._visibility&2?da(g,S,A,j,h):jo(g,S):(ne._visibility|=2,da(g,S,A,j,h)),h&&Y&2048&&ih(S.alternate,S);break;case 24:da(g,S,A,j,h),h&&Y&2048&&rh(S.alternate,S);break;default:da(g,S,A,j,h)}r=r.sibling}}function jo(s,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var l=s,c=r,h=c.flags;switch(c.tag){case 22:jo(l,c),h&2048&&ih(c.alternate,c);break;case 24:jo(l,c),h&2048&&rh(c.alternate,c);break;default:jo(l,c)}r=r.sibling}}var cr=8192;function dr(s,r,l){if(s.subtreeFlags&cr)for(s=s.child;s!==null;)d_(s,r,l),s=s.sibling}function d_(s,r,l){switch(s.tag){case 26:dr(s,r,l),s.flags&cr&&(s.memoizedState!==null?XR(l,rs,s.memoizedState,s.memoizedProps):(s=s.stateNode,(r&335544128)===r&&v0(l,s)));break;case 5:dr(s,r,l),s.flags&cr&&(s=s.stateNode,(r&335544128)===r&&v0(l,s));break;case 3:case 4:var c=rs;rs=Vo(s.stateNode.containerInfo),dr(s,r,l),rs=c;break;case 22:s.memoizedState===null&&(c=s.alternate,c!==null&&c.memoizedState!==null?(c=cr,cr=16777216,dr(s,r,l),cr=c):dr(s,r,l));break;case 30:if((s.flags&cr)!==0&&(c=s.memoizedProps.name,c!=null&&c!=="auto")){var h=s.stateNode;h.paired=null,In===null&&(In=new Map),In.set(c,h)}dr(s,r,l);break;default:dr(s,r,l)}}function f_(s){var r=s.alternate;if(r!==null&&(s=r.child,s!==null)){r.child=null;do r=s.sibling,s.sibling=null,s=r;while(s!==null)}}function zo(s){var r=s.deletions;if((s.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var c=r[l];Bt=c,p_(c,s)}f_(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)h_(s),s=s.sibling}function h_(s){switch(s.tag){case 0:case 11:case 15:zo(s),s.flags&2048&&Ti(9,s,s.return);break;case 3:zo(s);break;case 12:zo(s);break;case 22:var r=s.stateNode;s.memoizedState!==null&&r._visibility&2&&(s.return===null||s.return.tag!==13)?(r._visibility&=-3,Uu(s)):zo(s);break;default:zo(s)}}function Uu(s){var r=s.deletions;if((s.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var c=r[l];Bt=c,p_(c,s)}f_(s)}for(s=s.child;s!==null;){switch(r=s,r.tag){case 0:case 11:case 15:Ti(8,r,r.return),Uu(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,Uu(r));break;default:Uu(r)}s=s.sibling}}function p_(s,r){for(;Bt!==null;){var l=Bt;switch(l.tag){case 0:case 11:case 15:Ti(8,l,r);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var c=l.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:bo(l.memoizedState.cache)}if(c=l.child,c!==null)c.return=l,Bt=c;else e:for(l=s;Bt!==null;){c=Bt;var h=c.sibling,g=c.return;if(s_(c),c===l){Bt=null;break e}if(h!==null){h.return=g,Bt=h;break e}Bt=g}}}var GI={getCacheForType:function(s){var r=Ht(Ct),l=r.data.get(s);return l===void 0&&(l=s(),r.data.set(s,l)),l},cacheSignal:function(){return Ht(Ct).controller.signal}},FI=typeof WeakMap=="function"?WeakMap:Map,Je=0,at=null,He=null,Ge=0,tt=0,Rn=null,xi=!1,fa=!1,ah=!1,Xs=0,St=0,Ci=0,fr=0,Lu=0,Mn=0,ha=0,Po=null,gn=null,oh=!1,qu=0,m_=0,Hu=1/0,Vu=null,Ei=null,vt=0,os=null,hr=null,xs=0,lh=0,uh=null,g_=null,pa=null,ma=null,ga=null,Bo=0,$u=null;function kn(){return(Je&2)!==0&&Ge!==0?Ge&-Ge:fe.T!==null?bh():by()}function y_(){if(Mn===0)if((Ge&536870912)===0||qe){var s=Bl;Bl<<=1,(Bl&3932160)===0&&(Bl=262144),Mn=s}else Mn=536870912;return s=Vt.current,s!==null&&(s.flags|=32),Mn}function ya(s,r){if(r!=null){var l=s.stateNode,c=l.ref;c===null&&(c=l.ref=J_(Ls(s.memoizedProps,l))),ma===null&&(ma=[]),ma.push(r.bind(null,c))}}function yn(s,r,l){(s===at&&(tt===2||tt===9)||s.cancelPendingCommit!==null)&&(va(s,0),Ai(s,Ge,Mn,!1)),io(s,l),((Je&2)===0||s!==at)&&(s===at&&((Je&2)===0&&(fr|=l),St===4&&Ai(s,Ge,Mn,!1)),Cs(s))}function v_(s,r,l){if((Je&6)!==0)throw Error(i(327));var c=!l&&(r&127)===0&&(r&s.expiredLanes)===0||so(s,r),h=c?KI(s,r):dh(s,r,!0),g=c;do{if(h===0){fa&&!c&&Ai(s,r,0,!1);break}else{if(l=s.current.alternate,g&&!YI(l)){h=dh(s,r,!1),g=!1;continue}if(h===2){if(g=r,s.errorRecoveryDisabledLanes&g)var S=0;else S=s.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){r=S;e:{var A=s;h=Po;var j=A.current.memoizedState.isDehydrated;if(j&&(va(A,S).flags|=256),S=dh(A,S,!1),S!==2&&S!==6){if(ah&&!j){A.errorRecoveryDisabledLanes|=g,fr|=g,h=4;break e}g=gn,gn=h,g!==null&&(gn===null?gn=g:gn.push.apply(gn,g))}h=S}if(g=!1,h!==2)continue}}if(h===1){va(s,0),Ai(s,r,0,!0);break}e:{switch(c=s,g=h,g){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r&&(r&62914560)!==r)break;case 6:Ai(c,r,Mn,!xi);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(h=qu+300-Lt(),10<h)){if(Ai(c,r,Mn,!xi),Ll(c,0,!0)!==0)break e;xs=r,c.timeoutHandle=Mh(b_.bind(null,c,l,gn,Vu,oh,r,Mn,fr,ha,xi,g,"Throttled",-0,0),h);break e}b_(c,l,gn,Vu,oh,r,Mn,fr,ha,xi,g,null,-0,0)}}break}while(!0);Cs(s)}function b_(s,r,l,c,h,g,S,A,j,Y,ne,ue,G,J){s.timeoutHandle=-1;var Se=r.subtreeFlags,xe=(g&335544064)===g;if(ue=null,(xe||Se&8192||(Se&16785408)===16785408)&&(ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ms},In=null,d_(r,g,ue),xe&&(Se=ue,xe=s.containerInfo,xe=(xe.nodeType===9?xe:xe.ownerDocument).__reactViewTransition,xe!=null&&(Se.count++,Se.waitingForViewTransition=!0,Se=Fo.bind(Se),xe.finished.then(Se,Se))),Se=(g&62914560)===g?qu-Lt():(g&4194048)===g?m_-Lt():0,Se=JR(ue,Se),Se!==null)){xs=g,s.cancelPendingCommit=Se(A_.bind(null,s,r,g,l,c,h,S,A,j,Y,ne,ue,null,G,J)),Ai(s,g,S,!Y);return}A_(s,r,g,l,c,h,S,A,j,Y,ne,ue)}function YI(s){for(var r=s;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var c=0;c<l.length;c++){var h=l[c],g=h.getSnapshot;h=h.value;try{if(!En(g(),h))return!1}catch{return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Ai(s,r,l,c){r=py(s,r),r&=~Lu,r&=~fr,s.suspendedLanes|=r,s.pingedLanes&=~r,c&&(s.warmLanes|=r),c=s.expirationTimes;for(var h=r;0<h;){var g=31-xn(h),S=1<<g;c[g]=-1,h&=~S}l!==0&&gy(s,l,r)}function Gu(){return(Je&6)===0?(Uo(0),!1):!0}function ch(){if(He!==null){if(tt===0)var s=He.return;else s=He,$s=er=null,vf(s),ia=null,To=0,s=He;for(;s!==null;)Hb(s.alternate,s),s=s.return;He=null}}function va(s,r){var l=s.timeoutHandle;return l!==-1&&(s.timeoutHandle=-1,yR(l)),l=s.cancelPendingCommit,l!==null&&(s.cancelPendingCommit=null,l()),xs=0,ch(),at=s,He=l=Hs(s.current,null),Ge=r,tt=0,Rn=null,xi=!1,fa=so(s,r),ah=!1,ha=Mn=Lu=fr=Ci=St=0,gn=Po=null,oh=!1,Xs=py(s,r),Wl(),l}function __(s,r){Ue=null,fe.H=xu,r===sa||r===cu?(r=Av(),tt=3):r===rf?(r=Av(),tt=4):tt=r===Of?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Rn=r,He===null&&(St=1,Cu(s,Hn(r,s.current)))}function S_(){var s=Vt.current;return s===null?!0:(Ge&4194048)===Ge?Kt===null:(Ge&62914560)===Ge||(Ge&536870912)!==0?s===Kt:!1}function T_(){var s=fe.H;return fe.H=xu,s===null?xu:s}function w_(){var s=fe.A;return fe.A=GI,s}function Fu(){St=4,xi||(Ge&4194048)!==Ge&&Vt.current!==null||(fa=!0),(Ci&134217727)===0&&(fr&134217727)===0||at===null||Ai(at,Ge,Mn,!1)}function dh(s,r,l){var c=Je;Je|=2;var h=T_(),g=w_();(at!==s||Ge!==r)&&(Vu=null,va(s,r)),r=!1;var S=St;e:do try{if(tt!==0&&He!==null){var A=He,j=Rn;switch(tt){case 8:ch(),S=6;break e;case 3:case 2:case 9:case 6:Vt.current===null&&(r=!0);var Y=tt;if(tt=0,Rn=null,ba(s,A,j,Y),l&&fa){S=0;break e}break;default:Y=tt,tt=0,Rn=null,ba(s,A,j,Y)}}QI(),S=St;break}catch(ne){__(s,ne)}while(!0);return r&&s.shellSuspendCounter++,$s=er=null,Je=c,fe.H=h,fe.A=g,He===null&&(at=null,Ge=0,Wl()),S}function QI(){for(;He!==null;)x_(He)}function KI(s,r){var l=Je;Je|=2;var c=T_(),h=w_();at!==s||Ge!==r?(Vu=null,Hu=Lt()+500,va(s,r)):fa=so(s,r);e:do try{if(tt!==0&&He!==null){r=He;var g=Rn;t:switch(tt){case 1:tt=0,Rn=null,ba(s,r,g,1);break;case 2:case 9:if(Cv(g)){tt=0,Rn=null,C_(r);break}r=function(){tt!==2&&tt!==9||at!==s||(tt=7),Cs(s)},g.then(r,r);break e;case 3:tt=7;break e;case 4:tt=5;break e;case 7:Cv(g)?(tt=0,Rn=null,C_(r)):(tt=0,Rn=null,ba(s,r,g,7));break;case 5:var S=null;switch(He.tag){case 26:S=He.memoizedState;case 5:case 27:var A=He;if(S?g0(S):A.stateNode.complete){tt=0,Rn=null;var j=A.sibling;if(j!==null)He=j;else{var Y=A.return;Y!==null?(He=Y,Yu(Y)):He=null}break t}}tt=0,Rn=null,ba(s,r,g,5);break;case 6:tt=0,Rn=null,ba(s,r,g,6);break;case 8:ch(),St=6;break e;default:throw Error(i(462))}}XI();break}catch(ne){__(s,ne)}while(!0);return $s=er=null,fe.H=c,fe.A=h,Je=l,He!==null?0:(at=null,Ge=0,Wl(),St)}function XI(){for(;He!==null&&!Gi();)x_(He)}function x_(s){var r=Lb(s.alternate,s,Xs);s.memoizedProps=s.pendingProps,r===null?Yu(s):He=r}function C_(s){var r=s,l=r.alternate;switch(r.tag){case 15:case 0:r=Ob(l,r,r.pendingProps,r.type,void 0,Ge);break;case 11:r=Ob(l,r,r.pendingProps,r.type.render,r.ref,Ge);break;case 5:vf(r);var c=r;c===zt&&(qe?(ru(c),c.tag===5&&c.stateNode!=null&&(lt=c.stateNode)):(ru(c),qe=!0));default:Hb(l,r),r=He=pv(r,Xs),r=Lb(l,r,Xs)}s.memoizedProps=s.pendingProps,r===null?Yu(s):He=r}function ba(s,r,l,c){$s=er=null,vf(r),ia=null,To=0;var h=r.return;try{if(PI(s,h,r,l,Ge)){St=1,Cu(s,Hn(l,s.current)),He=null;return}}catch(g){if(h!==null)throw He=h,g;St=1,Cu(s,Hn(l,s.current)),He=null;return}r.flags&32768?(qe||c===1?s=!0:fa||(Ge&536870912)!==0?s=!1:(xi=s=!0,(c===2||c===9||c===3||c===6)&&(c=Vt.current,c!==null&&c.tag===13&&(c.flags|=16384))),E_(r,s)):Yu(r)}function Yu(s){var r=s;do{if((r.flags&32768)!==0){E_(r,xi);return}s=r.return;var l=qI(r.alternate,r,Xs);if(l!==null){He=l;return}if(r=r.sibling,r!==null){He=r;return}He=r=s}while(r!==null);St===0&&(St=5)}function E_(s,r){do{var l=HI(s.alternate,s);if(l!==null){l.flags&=32767,He=l;return}if(l=s.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(s=s.sibling,s!==null)){He=s;return}He=s=l}while(s!==null);St=6,He=null}function A_(s,r,l,c,h,g,S,A,j,Y,ne,ue){s.cancelPendingCommit=null;do Qu();while(vt!==0);if((Je&6)!==0)throw Error(i(327));if(r!==null){if(r===s.current)throw Error(i(177));s===at&&(He=at=null,Ge=0),hr=r,os=s,xs=l,uh=h,g_=c,JI(s,r,l,S,A,j,ue)}}function JI(s,r,l,c,h,g,S){var A=r.lanes|r.childLanes;if(lh=A,A|=Gd,w2(s,l,A,c,h,g),ma=null,(l&335544064)===l?(ga=CI(s),c=10262):(ga=null,c=10256),(r.subtreeFlags&c)!==0||(r.flags&c)!==0?(s.callbackNode=null,s.callbackPriority=0,sR(zl,function(){return mh(),null})):(s.callbackNode=null,s.callbackPriority=0),Ou=!1,c=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||c){c=fe.T,fe.T=null,h=ge.p,ge.p=2,g=Je,Je|=4;try{VI(s,r,l)}finally{Je=g,ge.p=h,fe.T=c}}vt=1,Ou?pa=wR(S,s.containerInfo,ga,fh,hh,WI,ph,mh,ZI):(fh(),hh(),ph())}function ZI(s){if(vt!==0){var r=os.onRecoverableError;r(s,{componentStack:null})}}function WI(){vt===3&&(vt=0,u_(hr,os),vt=4)}function fh(){if(vt===1){vt=0;var s=os,r=hr,l=xs,c=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||c){c=fe.T,fe.T=null;var h=ge.p;ge.p=2;var g=Je;Je|=4;try{Do=zu=!1,o_(r,s,l),l=Ah;var S=iv(s.containerInfo),A=l.focusedElem,j=l.selectionRange;if(S!==A&&A&&A.ownerDocument&&sv(A.ownerDocument.documentElement,A)){if(j!==null&&Ld(A)){var Y=j.start,ne=j.end;if(ne===void 0&&(ne=Y),"selectionStart"in A)A.selectionStart=Y,A.selectionEnd=Math.min(ne,A.value.length);else{var ue=A.ownerDocument||document,G=ue&&ue.defaultView||window;if(G.getSelection){var J=G.getSelection(),Se=A.textContent.length,xe=Math.min(j.start,Se),Le=j.end===void 0?xe:Math.min(j.end,Se);!J.extend&&xe>Le&&(S=Le,Le=xe,xe=S);var F=nv(A,xe),U=nv(A,Le);if(F&&U&&(J.rangeCount!==1||J.anchorNode!==F.node||J.anchorOffset!==F.offset||J.focusNode!==U.node||J.focusOffset!==U.offset)){var K=ue.createRange();K.setStart(F.node,F.offset),J.removeAllRanges(),xe>Le?(J.addRange(K),J.extend(U.node,U.offset)):(K.setEnd(U.node,U.offset),J.addRange(K))}}}}for(ue=[],J=A;J=J.parentNode;)J.nodeType===1&&ue.push({element:J,left:J.scrollLeft,top:J.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<ue.length;A++){var le=ue[A];le.element.scrollLeft=le.left,le.element.scrollTop=le.top}}Aa=!!Eh,Ah=Eh=null}finally{Je=g,ge.p=h,fe.T=c}}s.current=r,vt=2}}function hh(){if(vt===2){vt=0;var s=os,r=hr,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=fe.T,fe.T=null;var c=ge.p;ge.p=2;var h=Je;Je|=4;try{t_(s,r.alternate,r)}finally{Je=h,ge.p=c,fe.T=l}}vt=3}}function ph(){if(vt===4||vt===3){vt=0;var s=pa;pa=null,jl();var r=os,l=hr,c=xs,h=g_,g=(c&335544064)===c?10262:10256;if((l.subtreeFlags&g)!==0||(l.flags&g)!==0?vt=5:(vt=0,hr=os=null,I_(r,r.pendingLanes)),g=r.pendingLanes,g===0&&(Ei=null),Td(c),l=l.stateNode,wn&&typeof wn.onCommitFiberRoot=="function")try{wn.onCommitFiberRoot(no,l,void 0,(l.current.flags&128)===128)}catch{}if(h!==null){l=fe.T,g=ge.p,ge.p=2,fe.T=null;try{for(var S=r.onRecoverableError,A=0;A<h.length;A++){var j=h[A];S(j.value,{componentStack:j.stack})}}finally{fe.T=l,ge.p=g}}if(h=ma,S=ga,ga=null,h!==null&&(ma=null,S===null&&(S=[]),s!==null))for(j=0;j<h.length;j++)l=(0,h[j])(S),l!==void 0&&s.finished.finally(l);(xs&3)!==0&&Qu(),Cs(r),g=r.pendingLanes,(c&261930)!==0&&(g&42)!==0?r===$u?Bo++:(Bo=0,$u=r):(Bo=0,$u=null),Uo(0)}}function I_(s,r){(s.pooledCacheLanes&=r)===0&&(r=s.pooledCache,r!=null&&(s.pooledCache=null,bo(r)))}function Qu(){return pa!==null&&(pa.skipTransition(),pa=null),fh(),hh(),ph(),mh()}function mh(){if(vt!==5)return!1;var s=os,r=lh;lh=0;var l=Td(xs),c=fe.T,h=ge.p;try{ge.p=32>l?32:l,fe.T=null,l=uh,uh=null;var g=os,S=xs;if(vt=0,hr=os=null,xs=0,(Je&6)!==0)throw Error(i(331));var A=Je;if(Je|=4,h_(g.current),c_(g,g.current,S,l),Je=A,Uo(0,!1),wn&&typeof wn.onPostCommitFiberRoot=="function")try{wn.onPostCommitFiberRoot(no,g)}catch{}return!0}finally{ge.p=h,fe.T=c,I_(s,r)}}function R_(s,r,l){r=Hn(l,r),r=Nf(s.stateNode,r,2),s=vi(s,r,2),s!==null&&(io(s,2),Cs(s))}function nt(s,r,l){if(s.tag===3)R_(s,s,l);else for(;r!==null;){if(r.tag===3){R_(r,s,l);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ei===null||!Ei.has(c))){s=Hn(l,s),l=Cb(2),c=vi(r,l,2),c!==null&&(Eb(l,c,r,s),io(c,2),Cs(c));break}}r=r.return}}function gh(s,r,l){var c=s.pingCache;if(c===null){c=s.pingCache=new FI;var h=new Set;c.set(r,h)}else h=c.get(r),h===void 0&&(h=new Set,c.set(r,h));h.has(l)||(ah=!0,h.add(l),s=eR.bind(null,s,r,l),r.then(s,s))}function eR(s,r,l){var c=s.pingCache;c!==null&&c.delete(r),s.pingedLanes|=s.suspendedLanes&l,s.warmLanes&=~l,at===s&&(Ge&l)===l&&((St===4||St===3&&(Ge&62914560)===Ge&&300>Lt()-qu)&&(Je&2)===0?va(s,0):Lu|=l,ha===Ge&&(ha=0)),Cs(s)}function M_(s,r){r===0&&(r=my()),s=Ji(s,r),s!==null&&(io(s,r),Cs(s))}function tR(s){var r=s.memoizedState,l=0;r!==null&&(l=r.retryLane),M_(s,l)}function nR(s,r){var l=0;switch(s.tag){case 31:case 13:var c=s.stateNode,h=s.memoizedState;h!==null&&(l=h.retryLane);break;case 19:c=s.stateNode;break;case 22:c=s.stateNode._retryCache;break;default:throw Error(i(314))}c!==null&&c.delete(r),M_(s,l)}function sR(s,r){return Ds(s,r)}var _a=null,Sa=null,yh=!1,Ku=!1,vh=!1,Ii=0;function Cs(s){s!==Sa&&s.next===null&&(Sa===null?_a=Sa=s:Sa=Sa.next=s),Ku=!0,yh||(yh=!0,rR())}function Uo(s,r){if(!vh&&Ku){vh=!0;do for(var l=!1,c=_a;c!==null;){if(s!==0){var h=c.pendingLanes;if(h===0)var g=0;else{var S=c.suspendedLanes,A=c.pingedLanes;g=(1<<31-xn(42|s)+1)-1,g&=h&~(S&~A),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,D_(c,g))}else g=Ge,g=Ll(c,c===at?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||so(c,g)||(l=!0,D_(c,g));c=c.next}while(l);vh=!1}}function iR(){k_()}function k_(){Ku=yh=!1;var s=0;Ii!==0&&gR()&&(s=Ii);for(var r=Lt(),l=null,c=_a;c!==null;){var h=c.next,g=N_(c,r);g===0?(c.next=null,l===null?_a=h:l.next=h,h===null&&(Sa=l)):(l=c,(s!==0||(g&3)!==0)&&(Ku=!0)),c=h}vt!==0&&vt!==5||Uo(s),Ii!==0&&(Ii=0)}function N_(s,r){for(var l=s.suspendedLanes,c=s.pingedLanes,h=s.expirationTimes,g=s.pendingLanes&-62914561;0<g;){var S=31-xn(g),A=1<<S,j=h[S];j===-1?((A&l)===0||(A&c)!==0)&&(h[S]=T2(A,r)):j<=r&&(s.expiredLanes|=A),g&=~A}if(r=at,l=Ge,l=Ll(s,s===r?l:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),c=s.callbackNode,l===0||s===r&&(tt===2||tt===9)||s.cancelPendingCommit!==null)return c!==null&&c!==null&&js(c),s.callbackNode=null,s.callbackPriority=0;if((l&3)===0||so(s,l)){if(r=l&-l,r===s.callbackPriority)return r;switch(c!==null&&js(c),Td(l)){case 2:case 8:l=Un;break;case 32:l=zl;break;case 268435456:l=hy;break;default:l=zl}return c=O_.bind(null,s),l=Ds(l,c),s.callbackPriority=r,s.callbackNode=l,r}return c!==null&&c!==null&&js(c),s.callbackPriority=2,s.callbackNode=null,2}function O_(s,r){if(vt!==0&&vt!==5)return s.callbackNode=null,s.callbackPriority=0,null;var l=s.callbackNode;if(Qu()&&s.callbackNode!==l)return null;var c=Ge;return c=Ll(s,s===at?c:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),c===0?null:(v_(s,c,r),N_(s,Lt()),s.callbackNode!=null&&s.callbackNode===l?O_.bind(null,s):null)}function D_(s,r){if(Qu())return null;v_(s,r,!0)}function rR(){vR(function(){(Je&6)!==0?Ds(zs,iR):k_()})}function bh(){if(Ii===0){var s=sr;s===0&&(s=Pl,Pl<<=1,(Pl&261888)===0&&(Pl=256)),Ii=s}return Ii}function j_(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:Gl(s)}function aR(s,r,l,c,h){if(r==="submit"&&l&&l.stateNode===h){var g=j_((h[fn]||null).action),S=c.submitter;S&&(r=(r=S[fn]||null)?j_(r.formAction):S.getAttribute("formAction"),r!==null&&(g=r,S=null));var A=new Kl("action","action",null,c,h);s.push({event:A,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(Ii!==0){var j=new FormData(h,S);Af(l,{pending:!0,data:j,method:h.method,action:g},null,j)}}else typeof g=="function"&&(A.preventDefault(),j=new FormData(h,S),Af(l,{pending:!0,data:j,method:h.method,action:g},g,j))},currentTarget:h}]})}}for(var _h=0;_h<$d.length;_h++){var Sh=$d[_h],oR=Sh.toLowerCase(),lR=Sh[0].toUpperCase()+Sh.slice(1);ss(oR,"on"+lR)}ss(ov,"onAnimationEnd"),ss(lv,"onAnimationIteration"),ss(uv,"onAnimationStart"),ss("dblclick","onDoubleClick"),ss("focusin","onFocus"),ss("focusout","onBlur"),ss(yI,"onTransitionRun"),ss(vI,"onTransitionStart"),ss(bI,"onTransitionCancel"),ss(cv,"onTransitionEnd"),Vr("onMouseEnter",["mouseout","mouseover"]),Vr("onMouseLeave",["mouseout","mouseover"]),Vr("onPointerEnter",["pointerout","pointerover"]),Vr("onPointerLeave",["pointerout","pointerover"]),Qi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Qi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Qi("onBeforeInput",["compositionend","keypress","textInput","paste"]),Qi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Qi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Qi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Lo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),uR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Lo));function z_(s,r){r=(r&4)!==0;for(var l=0;l<s.length;l++){var c=s[l],h=c.event;c=c.listeners;e:{var g=void 0;if(r)for(var S=c.length-1;0<=S;S--){var A=c[S],j=A.instance,Y=A.currentTarget;if(A=A.listener,j!==g&&h.isPropagationStopped())break e;g=A,h.currentTarget=Y;try{g(h)}catch(ne){Zl(ne)}h.currentTarget=null,g=j}else for(S=0;S<c.length;S++){if(A=c[S],j=A.instance,Y=A.currentTarget,A=A.listener,j!==g&&h.isPropagationStopped())break e;g=A,h.currentTarget=Y;try{g(h)}catch(ne){Zl(ne)}h.currentTarget=null,g=j}}}}function Ve(s,r){var l=r[Sy];l===void 0&&(l=r[Sy]=new Set);var c=s+"__bubble";l.has(c)||(P_(r,s,2,!1),l.add(c))}function Th(s,r,l){var c=0;r&&(c|=4),P_(l,s,c,r)}var Xu="_reactListening"+Math.random().toString(36).slice(2);function wh(s){if(!s[Xu]){s[Xu]=!0,xy.forEach(function(l){l!=="selectionchange"&&(uR.has(l)||Th(l,!1,s),Th(l,!0,s))});var r=s.nodeType===9?s:s.ownerDocument;r===null||r[Xu]||(r[Xu]=!0,Th("selectionchange",!1,r))}}function P_(s,r,l,c){switch(E0(r)){case 2:var h=tM;break;case 8:h=nM;break;default:h=Vh}l=h.bind(null,r,l,s),h=void 0,!Md||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(h=!0),c?h!==void 0?s.addEventListener(r,l,{capture:!0,passive:h}):s.addEventListener(r,l,!0):h!==void 0?s.addEventListener(r,l,{passive:h}):s.addEventListener(r,l,!1)}function xh(s,r,l,c,h){var g=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var S=c.tag;if(S===3||S===4){var A=c.stateNode.containerInfo;if(A===h)break;if(S===4)for(S=c.return;S!==null;){var j=S.tag;if((j===3||j===4)&&S.stateNode.containerInfo===h)return;S=S.return}for(;A!==null;){if(S=Yi(A),S===null)return;if(j=S.tag,j===5||j===6||j===26||j===27){c=g=S;continue e}A=A.parentNode}}c=c.return}Py(function(){var Y=g,ne=Id(l),ue=[];e:{var G=dv.get(s);if(G!==void 0){var J=Kl,Se=s;switch(s){case"keypress":if(Yl(l)===0)break e;case"keydown":case"keyup":J=Y2;break;case"focusin":Se="focus",J=Dd;break;case"focusout":Se="blur",J=Dd;break;case"beforeblur":case"afterblur":J=Dd;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":J=Ly;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":J=j2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":J=Z2;break;case ov:case lv:case uv:J=B2;break;case cv:J=eI;break;case"scroll":case"scrollend":J=O2;break;case"wheel":J=nI;break;case"copy":case"cut":case"paste":J=L2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":J=Hy;break;case"submit":J=X2;break;case"toggle":case"beforetoggle":J=iI}var xe=(r&4)!==0,Le=!xe&&(s==="scroll"||s==="scrollend"),F=xe?G!==null?G+"Capture":null:G;xe=[];for(var U=Y,K;U!==null;){var le=U;if(K=le.stateNode,le=le.tag,le!==5&&le!==26&&le!==27||K===null||F===null||(le=oo(U,F),le!=null&&xe.push(qo(U,le,K))),Le)break;U=U.return}0<xe.length&&(G=new J(G,Se,null,l,ne),ue.push({event:G,listeners:xe}))}}if((r&7)===0){e:{if(J=s==="mouseover"||s==="pointerover",G=s==="mouseout"||s==="pointerout",J&&l!==Ad&&(Se=l.relatedTarget||l.fromElement)&&(Yi(Se)||Se[Lr]))break e;(G||J)&&(Se=ne.window===ne?ne:(J=ne.ownerDocument)?J.defaultView||J.parentWindow:window,G?(J=l.relatedTarget||l.toElement,G=Y,J=J?Yi(J):null,J!==null&&(Le=o(J),xe=J.tag,J!==Le||xe!==5&&xe!==27&&xe!==6)&&(J=null)):(G=null,J=Y),G!==J&&(xe=Ly,le="onMouseLeave",F="onMouseEnter",U="mouse",(s==="pointerout"||s==="pointerover")&&(xe=Hy,le="onPointerLeave",F="onPointerEnter",U="pointer"),Le=G==null?Se:ao(G),K=J==null?Se:ao(J),Se=new xe(le,U+"leave",G,l,ne),Se.target=Le,Se.relatedTarget=K,le=null,Yi(ne)===Y&&(xe=new xe(F,U+"enter",J,l,ne),xe.target=K,xe.relatedTarget=Le,le=xe),Le=le,xe=G&&J?I(G,J,cR):null,G!==null&&B_(ue,Se,G,xe,!1),J!==null&&Le!==null&&B_(ue,Le,J,xe,!0)))}e:{if(G=Y?ao(Y):window,J=G.nodeName&&G.nodeName.toLowerCase(),J==="select"||J==="input"&&G.type==="file")var Te=Xy;else if(Qy(G))if(Jy)Te=pI;else{Te=fI;var Fe=dI}else J=G.nodeName,!J||J.toLowerCase()!=="input"||G.type!=="checkbox"&&G.type!=="radio"?Y&&Ed(Y.elementType)&&(Te=Xy):Te=hI;if(Te&&(Te=Te(s,Y))){Ky(ue,Te,l,ne);break e}Fe&&Fe(s,G,Y)}switch(Fe=Y?ao(Y):window,s){case"focusin":(Qy(Fe)||Fe.contentEditable==="true")&&(Kr=Fe,qd=Y,go=null);break;case"focusout":go=qd=Kr=null;break;case"mousedown":Hd=!0;break;case"contextmenu":case"mouseup":case"dragend":Hd=!1,rv(ue,l,ne);break;case"selectionchange":if(gI)break;case"keydown":case"keyup":rv(ue,l,ne)}var Ee;if(zd)e:{switch(s){case"compositionstart":var Me="onCompositionStart";break e;case"compositionend":Me="onCompositionEnd";break e;case"compositionupdate":Me="onCompositionUpdate";break e}Me=void 0}else Qr?Fy(s,l)&&(Me="onCompositionEnd"):s==="keydown"&&l.keyCode===229&&(Me="onCompositionStart");Me&&(Vy&&l.locale!=="ko"&&(Qr||Me!=="onCompositionStart"?Me==="onCompositionEnd"&&Qr&&(Ee=By()):(ui=ne,kd="value"in ui?ui.value:ui.textContent,Qr=!0)),Fe=Ju(Y,Me),0<Fe.length&&(Me=new qy(Me,s,null,l,ne),ue.push({event:Me,listeners:Fe}),Ee?Me.data=Ee:(Ee=Yy(l),Ee!==null&&(Me.data=Ee)))),(Ee=aI?oI(s,l):lI(s,l))&&(Me=Ju(Y,"onBeforeInput"),0<Me.length&&(Fe=new qy("onBeforeInput","beforeinput",null,l,ne),ue.push({event:Fe,listeners:Me}),Fe.data=Ee)),aR(ue,s,Y,l,ne)}z_(ue,r)})}function qo(s,r,l){return{instance:s,listener:r,currentTarget:l}}function Ju(s,r){for(var l=r+"Capture",c=[];s!==null;){var h=s,g=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||g===null||(h=oo(s,l),h!=null&&c.unshift(qo(s,h,g)),h=oo(s,r),h!=null&&c.push(qo(s,h,g))),s.tag===3)return c;s=s.return}return[]}function cR(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function B_(s,r,l,c,h){for(var g=r._reactName,S=[];l!==null&&l!==c;){var A=l,j=A.alternate,Y=A.stateNode;if(A=A.tag,j!==null&&j===c)break;A!==5&&A!==26&&A!==27||Y===null||(j=Y,h?(Y=oo(l,g),Y!=null&&S.unshift(qo(l,Y,j))):h||(Y=oo(l,g),Y!=null&&S.push(qo(l,Y,j)))),l=l.return}S.length!==0&&s.push({event:r,listeners:S})}var dR=/\r\n?/g,fR=/\u0000|\uFFFD/g;function U_(s){return(typeof s=="string"?s:""+s).replace(dR,`
10
- `).replace(fR,"")}function L_(s,r){return r=U_(r),U_(s)===r}function st(s,r,l,c,h,g){switch(l){case"children":if(typeof c=="string")r==="body"||r==="textarea"&&c===""||Gr(s,c);else if(typeof c=="number"||typeof c=="bigint")r!=="body"&&Gr(s,""+c);else return;break;case"className":$l(s,"class",c);break;case"tabIndex":$l(s,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":$l(s,l,c);break;case"style":jy(s,c,g);return;case"data":if(r!=="object"){$l(s,"data",c);break}case"src":case"href":if(c===""&&(r!=="a"||l!=="href")){s.removeAttribute(l);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){s.removeAttribute(l);break}c=Gl(c),s.setAttribute(l,c);break;case"action":case"formAction":if(typeof c=="function"){s.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(l==="formAction"?(r!=="input"&&st(s,r,"name",h.name,h,null),st(s,r,"formEncType",h.formEncType,h,null),st(s,r,"formMethod",h.formMethod,h,null),st(s,r,"formTarget",h.formTarget,h,null)):(st(s,r,"encType",h.encType,h,null),st(s,r,"method",h.method,h,null),st(s,r,"target",h.target,h,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){s.removeAttribute(l);break}c=Gl(c),s.setAttribute(l,c);break;case"onClick":c!=null&&(s.onclick=ms);return;case"onScroll":c!=null&&Ve("scroll",s);return;case"onScrollEnd":c!=null&&Ve("scrollend",s);return;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(l=c.__html,l!=null){if(h.children!=null)throw Error(i(60));g?.__html!==l&&(s.innerHTML=l)}}break;case"multiple":s.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":s.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){s.removeAttribute("xlink:href");break}l=Gl(c),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?s.setAttribute(l,c):s.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"credentialless":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":c&&typeof c!="function"&&typeof c!="symbol"?s.setAttribute(l,""):s.removeAttribute(l);break;case"capture":case"download":c===!0?s.setAttribute(l,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?s.setAttribute(l,c):s.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?s.setAttribute(l,c):s.removeAttribute(l);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?s.removeAttribute(l):s.setAttribute(l,c);break;case"popover":Ve("beforetoggle",s),Ve("toggle",s),Vl(s,"popover",c);break;case"xlinkActuate":Bs(s,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Bs(s,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Bs(s,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Bs(s,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Bs(s,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Bs(s,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Bs(s,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Bs(s,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Bs(s,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Vl(s,"is",c);break;case"innerText":case"textContent":return;default:if(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")l=k2.get(l)||l,Vl(s,l,c);else return}Xe=!0}function Ch(s,r,l,c,h,g){switch(l){case"style":jy(s,c,g);return;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(l=c.__html,l!=null){if(h.children!=null)throw Error(i(60));g?.__html!==l&&(s.innerHTML=l)}}break;case"children":if(typeof c=="string")Gr(s,c);else if(typeof c=="number"||typeof c=="bigint")Gr(s,""+c);else return;break;case"onScroll":c!=null&&Ve("scroll",s);return;case"onScrollEnd":c!=null&&Ve("scrollend",s);return;case"onClick":c!=null&&(s.onclick=ms);return;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":return;case"innerText":case"textContent":return;default:if(!Cy.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(h=l.endsWith("Capture"),g=l.slice(2,h?l.length-7:void 0),r=s[fn]||null,r=r!=null?r[l]:null,typeof r=="function"&&s.removeEventListener(g,r,h),typeof c=="function")){typeof r!="function"&&r!==null&&(l in s?s[l]=null:s.hasAttribute(l)&&s.removeAttribute(l)),s.addEventListener(g,c,h);break e}Xe=!0,l in s?s[l]=c:c===!0?s.setAttribute(l,""):Vl(s,l,c)}return}Xe=!0}function Ft(s,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ve("error",s),Ve("load",s);var c=!1,h=!1,g;for(g in l)if(l.hasOwnProperty(g)){var S=l[g];if(S!=null)switch(g){case"src":c=!0;break;case"srcSet":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:st(s,r,g,S,l,null)}}h&&st(s,r,"srcSet",l.srcSet,l,null),c&&st(s,r,"src",l.src,l,null);return;case"input":Ve("invalid",s);var A=g=S=h=null,j=null,Y=null;for(c in l)if(l.hasOwnProperty(c)){var ne=l[c];if(ne!=null)switch(c){case"name":h=ne;break;case"type":S=ne;break;case"checked":j=ne;break;case"defaultChecked":Y=ne;break;case"value":g=ne;break;case"defaultValue":A=ne;break;case"children":case"dangerouslySetInnerHTML":if(ne!=null)throw Error(i(137,r));break;default:st(s,r,c,ne,l,null)}}ky(s,g,A,j,Y,S,h,!1);return;case"select":Ve("invalid",s),c=S=g=null;for(h in l)if(l.hasOwnProperty(h)&&(A=l[h],A!=null))switch(h){case"value":g=A;break;case"defaultValue":S=A;break;case"multiple":c=A;default:st(s,r,h,A,l,null)}r=g,l=S,s.multiple=!!c,r!=null?$r(s,!!c,r,!1):l!=null&&$r(s,!!c,l,!0);return;case"textarea":Ve("invalid",s),g=h=c=null;for(S in l)if(l.hasOwnProperty(S)&&(A=l[S],A!=null))switch(S){case"value":c=A;break;case"defaultValue":h=A;break;case"children":g=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(i(91));break;default:st(s,r,S,A,l,null)}Oy(s,c,h,g);return;case"option":for(j in l)l.hasOwnProperty(j)&&(c=l[j],c!=null)&&(j==="selected"?s.selected=c&&typeof c!="function"&&typeof c!="symbol":st(s,r,j,c,l,null));return;case"dialog":Ve("beforetoggle",s),Ve("toggle",s),Ve("cancel",s),Ve("close",s);break;case"iframe":case"object":Ve("load",s);break;case"video":case"audio":for(c=0;c<Lo.length;c++)Ve(Lo[c],s);break;case"image":Ve("error",s),Ve("load",s);break;case"details":Ve("toggle",s);break;case"embed":case"source":case"link":Ve("error",s),Ve("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Y in l)if(l.hasOwnProperty(Y)&&(c=l[Y],c!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:st(s,r,Y,c,l,null)}return;default:if(Ed(r)){for(ne in l)l.hasOwnProperty(ne)&&(c=l[ne],c!==void 0&&Ch(s,r,ne,c,l,void 0));return}}for(A in l)l.hasOwnProperty(A)&&(c=l[A],c!=null&&st(s,r,A,c,l,null))}var hR={};function pR(s,r,l,c){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,g=null,S=null,A=null,j=null,Y=null,ne=null;for(J in l){var ue=l[J];if(l.hasOwnProperty(J)&&ue!=null)switch(J){case"checked":break;case"value":break;case"defaultValue":j=ue;default:c.hasOwnProperty(J)||st(s,r,J,null,c,ue)}}for(var G in c){var J=c[G];if(ue=l[G],c.hasOwnProperty(G)&&(J!=null||ue!=null))switch(G){case"type":J!==ue&&(Xe=!0),g=J;break;case"name":J!==ue&&(Xe=!0),h=J;break;case"checked":J!==ue&&(Xe=!0),Y=J;break;case"defaultChecked":J!==ue&&(Xe=!0),ne=J;break;case"value":J!==ue&&(Xe=!0),S=J;break;case"defaultValue":J!==ue&&(Xe=!0),A=J;break;case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(i(137,r));break;default:J!==ue&&st(s,r,G,J,c,ue)}}xd(s,S,A,j,Y,ne,g,h);return;case"select":J=S=A=G=null;for(g in l)if(j=l[g],l.hasOwnProperty(g)&&j!=null)switch(g){case"value":break;case"multiple":J=j;default:c.hasOwnProperty(g)||st(s,r,g,null,c,j)}for(h in c)if(g=c[h],j=l[h],c.hasOwnProperty(h)&&(g!=null||j!=null))switch(h){case"value":g!==j&&(Xe=!0),G=g;break;case"defaultValue":g!==j&&(Xe=!0),A=g;break;case"multiple":g!==j&&(Xe=!0),S=g;default:g!==j&&st(s,r,h,g,c,j)}r=A,l=S,c=J,G!=null?$r(s,!!l,G,!1):!!c!=!!l&&(r!=null?$r(s,!!l,r,!0):$r(s,!!l,l?[]:"",!1));return;case"textarea":J=G=null;for(A in l)if(h=l[A],l.hasOwnProperty(A)&&h!=null&&!c.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:st(s,r,A,null,c,h)}for(S in c)if(h=c[S],g=l[S],c.hasOwnProperty(S)&&(h!=null||g!=null))switch(S){case"value":h!==g&&(Xe=!0),G=h;break;case"defaultValue":h!==g&&(Xe=!0),J=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(i(91));break;default:h!==g&&st(s,r,S,h,c,g)}Ny(s,G,J);return;case"option":for(var Se in l)G=l[Se],l.hasOwnProperty(Se)&&G!=null&&!c.hasOwnProperty(Se)&&(Se==="selected"?s.selected=!1:st(s,r,Se,null,c,G));for(j in c)G=c[j],J=l[j],c.hasOwnProperty(j)&&G!==J&&(G!=null||J!=null)&&(j==="selected"?(G!==J&&(Xe=!0),s.selected=G&&typeof G!="function"&&typeof G!="symbol"):st(s,r,j,G,c,J));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var xe in l)G=l[xe],l.hasOwnProperty(xe)&&G!=null&&!c.hasOwnProperty(xe)&&st(s,r,xe,null,c,G);for(Y in c)if(G=c[Y],J=l[Y],c.hasOwnProperty(Y)&&G!==J&&(G!=null||J!=null))switch(Y){case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(i(137,r));break;default:st(s,r,Y,G,c,J)}return;default:if(Ed(r)){for(var Le in l)G=l[Le],l.hasOwnProperty(Le)&&G!==void 0&&!c.hasOwnProperty(Le)&&Ch(s,r,Le,void 0,c,G);for(ne in c)G=c[ne],J=l[ne],!c.hasOwnProperty(ne)||G===J||G===void 0&&J===void 0||Ch(s,r,ne,G,c,J);return}}for(var F in l)G=l[F],l.hasOwnProperty(F)&&G!=null&&!c.hasOwnProperty(F)&&st(s,r,F,null,c,G);for(ue in c)G=c[ue],J=l[ue],!c.hasOwnProperty(ue)||G===J||G==null&&J==null||st(s,r,ue,G,c,J)}function q_(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function mR(){if(typeof performance.getEntriesByType=="function"){for(var s=0,r=0,l=performance.getEntriesByType("resource"),c=0;c<l.length;c++){var h=l[c],g=h.transferSize,S=h.initiatorType,A=h.duration;if(g&&A&&q_(S)){for(S=0,A=h.responseEnd,c+=1;c<l.length;c++){var j=l[c],Y=j.startTime;if(Y>A)break;var ne=j.transferSize,ue=j.initiatorType;ne&&q_(ue)&&(j=j.responseEnd,S+=ne*(j<A?1:(A-Y)/(j-Y)))}if(--c,r+=8*(g+S)/(h.duration/1e3),s++,10<s)break}}if(0<s)return r/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var Eh=null,Ah=null;function Ho(s){return s.nodeType===9?s:s.ownerDocument}function H_(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function V_(s,r){if(s===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&r==="foreignObject"?0:s}function $_(s,r,l,c){return l=Ho(l).createElement(s),l[qt]=c,l[fn]=r,Ft(l,s,r),jt(l),l}function Ih(s,r){return s==="textarea"||s==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Rh=null;function gR(){var s=window.event;return s&&s.type==="popstate"?s===Rh?!1:(Rh=s,!0):(Rh=null,!1)}var Mh=typeof setTimeout=="function"?setTimeout:void 0,yR=typeof clearTimeout=="function"?clearTimeout:void 0,G_=typeof Promise=="function"?Promise:void 0,F_=typeof requestAnimationFrame=="function"?requestAnimationFrame:Mh,vR=typeof queueMicrotask=="function"?queueMicrotask:typeof G_<"u"?function(s){return G_.resolve(null).then(s).catch(bR)}:Mh;function bR(s){setTimeout(function(){throw s})}function Ri(s){return s==="head"}function Y_(s,r){var l=r,c=0;do{var h=l.nextSibling;if(s.removeChild(l),h&&h.nodeType===8)if(l=h.data,l==="/$"||l==="/&"){if(c===0){s.removeChild(h),Ia(r);return}c--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")c++;else if(l==="html")Bh(s.ownerDocument.documentElement);else if(l==="head"){l=s.ownerDocument.head,Bh(l);for(var g=l.firstChild;g;){var S=g.nextSibling,A=g.nodeName;g[ro]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=S}}else l==="body"&&Bh(s.ownerDocument.body);l=h}while(l);Ia(r)}function Q_(s,r){var l=s;s=0;do{var c=l.nextSibling;if(l.nodeType===1?r?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(r?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),c&&c.nodeType===8)if(l=c.data,l==="/$"){if(s===0)break;s--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||s++;l=c}while(l)}function K_(s,r,l){if(r=CSS.escape(r)!==r?"r-"+btoa(r).replace(/=/g,""):r,s.style.viewTransitionName=r,l!=null&&(s.style.viewTransitionClass=l),l=getComputedStyle(s),l.display==="inline"){if(r=s.getClientRects(),r.length===1)var c=1;else for(var h=c=0;h<r.length;h++){var g=r[h];0<g.width&&0<g.height&&c++}c===1&&(s=s.style,s.display=r.length===1?"inline-block":"block",s.marginTop="-"+l.paddingTop,s.marginBottom="-"+l.paddingBottom)}}function X_(s,r){s=s.style,r=r.style;var l=r!=null?r.hasOwnProperty("viewTransitionName")?r.viewTransitionName:r.hasOwnProperty("view-transition-name")?r["view-transition-name"]:null:null;s.viewTransitionName=l==null||typeof l=="boolean"?"":(""+l).trim(),l=r!=null?r.hasOwnProperty("viewTransitionClass")?r.viewTransitionClass:r.hasOwnProperty("view-transition-class")?r["view-transition-class"]:null:null,s.viewTransitionClass=l==null||typeof l=="boolean"?"":(""+l).trim(),s.display==="inline-block"&&(r==null?s.display=s.margin="":(l=r.display,s.display=l==null||typeof l=="boolean"?"":l,l=r.margin,l!=null?s.margin=l:(l=r.hasOwnProperty("marginTop")?r.marginTop:r["margin-top"],s.marginTop=l==null||typeof l=="boolean"?"":l,r=r.hasOwnProperty("marginBottom")?r.marginBottom:r["margin-bottom"],s.marginBottom=r==null||typeof r=="boolean"?"":r)))}function _R(s,r,l){return l=l.ownerDocument.defaultView,{rect:s,abs:r.position==="absolute"||r.position==="fixed",clip:r.clipPath!=="none"||r.overflow!=="visible"||r.filter!=="none"||r.mask!=="none"||r.mask!=="none"||r.borderRadius!=="0px",view:0<=s.bottom&&0<=s.right&&s.top<=l.innerHeight&&s.left<=l.innerWidth}}function kh(s){var r=s.getBoundingClientRect(),l=getComputedStyle(s);return _R(r,l,s)}function SR(s){return s.documentElement.clientHeight}function TR(s){this.addEventListener("load",s),this.addEventListener("error",s)}function wR(s,r,l,c,h,g,S,A,j){var Y=r.nodeType===9?r:r.ownerDocument;try{var ne=Y.startViewTransition({update:function(){var G=Y.defaultView,J=G.navigation&&G.navigation.transition,Se=Y.fonts.status;c();var xe=[];if(Se==="loaded"&&(SR(Y),Y.fonts.status==="loading"&&xe.push(Y.fonts.ready)),Se=xe.length,s!==null)for(var Le=s.suspenseyImages,F=0,U=0;U<Le.length;U++){var K=Le[U];if(!K.complete){var le=K.getBoundingClientRect();if(0<le.bottom&&0<le.right&&le.top<G.innerHeight&&le.left<G.innerWidth){if(F+=y0(K),F>ec){xe.length=Se;break}K=new Promise(TR.bind(K)),xe.push(K)}}}if(0<xe.length)return G=Promise.race([Promise.all(xe),new Promise(function(Te){return setTimeout(Te,500)})]).then(h,h),(J?Promise.allSettled([J.finished,G]):G).then(g,g);if(h(),J)return J.finished.then(g,g);g()},types:l});Y.__reactViewTransition=ne;var ue=[];return ne.ready.then(function(){for(var G=Y.documentElement.getAnimations({subtree:!0}),J=0;J<G.length;J++){var Se=G[J],xe=Se.effect,Le=xe.pseudoElement;if(Le!=null&&Le.startsWith("::view-transition")){ue.push(Se),Se=xe.getKeyframes();for(var F=Le=void 0,U=!0,K=0;K<Se.length;K++){var le=Se[K],Te=le.width;if(Le===void 0)Le=Te;else if(Le!==Te){U=!1;break}if(Te=le.height,F===void 0)F=Te;else if(F!==Te){U=!1;break}delete le.width,delete le.height,le.transform==="none"&&delete le.transform}U&&Le!==void 0&&F!==void 0&&(xe.setKeyframes(Se),U=getComputedStyle(xe.target,xe.pseudoElement),U.width!==Le||U.height!==F)&&(U=Se[0],U.width=Le,U.height=F,U=Se[Se.length-1],U.width=Le,U.height=F,xe.setKeyframes(Se))}}S()},function(G){Y.__reactViewTransition===ne&&(Y.__reactViewTransition=null);try{typeof G=="object"&&G!==null&&G.name==="InvalidStateError"&&(G.message==="View transition was skipped because document visibility state is hidden."||G.message==="Skipping view transition because document visibility state has become hidden."||G.message==="Skipping view transition because viewport size changed."||G.message==="Transition was aborted because of invalid state")&&(G=null),G!==null&&j(G)}finally{c(),h(),S()}}),ne.finished.finally(function(){for(var G=0;G<ue.length;G++)ue[G].cancel();Y.__reactViewTransition===ne&&(Y.__reactViewTransition=null),A()}),ne}catch{return c(),h(),S(),null}}function pr(s,r){this._scope=document.documentElement,this._selector="::view-transition-"+s+"("+r+")"}pr.prototype.animate=function(s,r){return r=typeof r=="number"?{duration:r}:P({},r),r.pseudoElement=this._selector,this._scope.animate(s,r)},pr.prototype.getAnimations=function(){for(var s=this._scope,r=this._selector,l=s.getAnimations({subtree:!0}),c=[],h=0;h<l.length;h++){var g=l[h].effect;g!==null&&g.target===s&&g.pseudoElement===r&&c.push(l[h])}return c},pr.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function J_(s){return{name:s,group:new pr("group",s),imagePair:new pr("image-pair",s),old:new pr("old",s),new:new pr("new",s)}}function Nn(s){this._fragmentFiber=s,this._observers=this._eventListeners=null}Nn.prototype.addEventListener=function(s,r,l){var c=null,h=null;if(!(l!=null&&typeof l!="boolean"&&(c=l.signal||null,c!==null&&c.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var g=this._eventListeners;if(W_(g,s,r,l)===-1){var S=this,A=r;l!=null&&typeof l!="boolean"&&l.once===!0&&(A=function(j){S.removeEventListener(s,r,l),typeof r=="function"?r.call(this,j):r.handleEvent(j)}),c!==null&&(h=S.removeEventListener.bind(S,s,r,l),c.addEventListener("abort",h,{once:!0}),h=c.removeEventListener.bind(c,"abort",h)),c=Ta(l),g.push({type:s,listener:r,optionsOrUseCapture:l,attachedListener:A,cleanup:h}),y(this._fragmentFiber.child,!1,xR,s,A,c)}this._eventListeners=g}};function xR(s,r,l,c){return x(s).addEventListener(r,l,c),!1}Nn.prototype.removeEventListener=function(s,r,l){var c=this._eventListeners;if(c!==null&&(r=W_(c,s,r,l),r!==-1)){var h=c[r];l=h.attachedListener;var g=h.cleanup;h=Ta(h.optionsOrUseCapture),y(this._fragmentFiber.child,!1,CR,s,l,h),c.splice(r,1),g!==null&&g()}};function CR(s,r,l,c){return x(s).removeEventListener(r,l,c),!1}function Ta(s){return s!=null&&typeof s!="boolean"&&(s.once===!0||s.signal instanceof AbortSignal)?{capture:s.capture,passive:s.passive}:s}function Z_(s){return s==null?"c=0":typeof s=="boolean"?"c="+(s?"1":"0"):"c="+(s.capture?"1":"0")}function W_(s,r,l,c){if(s.length===0)return-1;c=Z_(c);for(var h=0;h<s.length;h++){var g=s[h];if(g.type===r&&g.listener===l&&Z_(g.optionsOrUseCapture)===c)return h}return-1}Nn.prototype.dispatchEvent=function(s){var r=v(this._fragmentFiber);if(r===null)return!0;r=x(r);var l=this._eventListeners;if(l!==null&&0<l.length||!s.bubbles){var c=r.nodeType===9?r.createComment(""):document.createTextNode("");if(l)for(var h=0;h<l.length;h++){var g=l[h];c.addEventListener(g.type,g.attachedListener,Ta(g.optionsOrUseCapture))}if(r.appendChild(c),s=c.dispatchEvent(s),l)for(h=0;h<l.length;h++)g=l[h],c.removeEventListener(g.type,g.attachedListener,Ta(g.optionsOrUseCapture));return r.removeChild(c),s}return r.dispatchEvent(s)},Nn.prototype.focus=function(s){y(this._fragmentFiber.child,!0,e0,s,void 0,void 0)};function e0(s,r){return s.tag===6?!1:(s=x(s),PR(s,r))}Nn.prototype.focusLast=function(s){var r=[];y(this._fragmentFiber.child,!0,Nh,r,void 0,void 0);for(var l=r.length-1;0<=l&&!e0(r[l],s);l--);};function Nh(s,r){return r.push(s),!1}Nn.prototype.blur=function(){var s=v(this._fragmentFiber);s!==null&&(s=x(s),s=Ho(s).activeElement,s!==null&&y(this._fragmentFiber.child,!1,ER,s,void 0,void 0))};function ER(s,r){return s.tag===6?!1:(s=x(s),s===r||s.contains(r)?(r.blur(),!0):!1)}Nn.prototype.observeUsing=function(s){this._observers===null&&(this._observers=new Set),this._observers.add(s),y(this._fragmentFiber.child,!1,AR,s,void 0,void 0)};function AR(s,r){return s.tag===6||(s=x(s),r.observe(s)),!1}Nn.prototype.unobserveUsing=function(s){var r=this._observers;if(r!==null&&r.has(s)){r.delete(s),y(this._fragmentFiber.child,!1,IR,s,void 0,void 0);for(var l=r=0;l<ls.length;l++){var c=ls[l];c.fragmentInstance===this&&c.observer===s?s.unobserve(c.instance):ls[r++]=c}ls.length=r}};function IR(s,r){return s.tag===6||(s=x(s),r.unobserve(s)),!1}var ls=[],Oh=!1;function RR(s,r,l){ls.push({fragmentInstance:s,observer:r,instance:l}),Oh||(Oh=!0,BR(function(){Oh=!1;var c=ls;ls=[];for(var h=0;h<c.length;h++){var g=c[h];g.observer.unobserve(g.instance)}}))}Nn.prototype.getClientRects=function(){var s=[];return y(this._fragmentFiber.child,!1,MR,s,void 0,void 0),s};function MR(s,r){if(s.tag===6){s=s.stateNode;var l=s.ownerDocument.createRange();l.selectNodeContents(s),r.push.apply(r,l.getClientRects())}else s=x(s),r.push.apply(r,s.getClientRects());return!1}Nn.prototype.getRootNode=function(s){var r=v(this._fragmentFiber);return r===null?this:x(r).getRootNode(s)},Nn.prototype.compareDocumentPosition=function(s){var r=v(this._fragmentFiber);if(r===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var l=[];y(this._fragmentFiber.child,!1,Nh,l,void 0,void 0);var c=x(r);if(l.length===0){if(l=c,b(this._fragmentFiber)){e:{for(r=this._fragmentFiber.return;r!==null;){if(r.tag===4){r=r.stateNode.containerInfo;break e}if(r.tag===3||r.tag===5||r.tag===27)break;r=r.return}r=null}r!=null&&(l=r)}r=this._fragmentFiber;var h=c=l.compareDocumentPosition(s);return l===s?h=Node.DOCUMENT_POSITION_CONTAINS:c&Node.DOCUMENT_POSITION_CONTAINED_BY&&(l=T(r)[1],l===null?h=Node.DOCUMENT_POSITION_PRECEDING:(s=x(l).compareDocumentPosition(s),h=s===0||s&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),h|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}r=x(l[0]),h=x(l[l.length-1]);var g=b(this._fragmentFiber)?r.parentElement:c;if(g==null)return Node.DOCUMENT_POSITION_DISCONNECTED;c=g.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_CONTAINED_BY,g=g.compareDocumentPosition(h)&Node.DOCUMENT_POSITION_CONTAINED_BY;var S=r.compareDocumentPosition(s),A=h.compareDocumentPosition(s),j=S&Node.DOCUMENT_POSITION_CONTAINED_BY||A&Node.DOCUMENT_POSITION_CONTAINED_BY;return A=c&&g&&S&Node.DOCUMENT_POSITION_FOLLOWING&&A&Node.DOCUMENT_POSITION_PRECEDING,r=c&&r===s||g&&h===s||j||A?Node.DOCUMENT_POSITION_CONTAINED_BY:!c&&r===s||!g&&h===s?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:S,r&Node.DOCUMENT_POSITION_DISCONNECTED||r&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||kR(r,this._fragmentFiber,l[0],l[l.length-1],s)?r:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function kR(s,r,l,c,h){var g=Yi(h);if(s&Node.DOCUMENT_POSITION_CONTAINED_BY){if(l=!!g)e:{for(;g!==null;){if(g.tag===7&&(g===r||g.alternate===r)){l=!0;break e}g=g.return}l=!1}return l}if(s&Node.DOCUMENT_POSITION_CONTAINS){if(g===null)return g=h.ownerDocument,h===g||h===g.documentElement||h===g.body;e:{for(g=r,r=v(r);g!==null;){if(!(g.tag!==5&&g.tag!==3&&g.tag!==27||g!==r&&g.alternate!==r)){g=!0;break e}g=g.return}g=!1}return g}return s&Node.DOCUMENT_POSITION_PRECEDING?((r=!!g)&&!(r=g===l)&&(r=I(l,g,L),r===null?r=!1:(y(r,!0,R,g,l),g=E,E=null,r=g!==null)),r):s&Node.DOCUMENT_POSITION_FOLLOWING?((r=!!g)&&!(r=g===c)&&(r=I(c,g,L),r===null?r=!1:(y(r,!0,O,g,c),g=E,C=E=null,r=g!==null)),r):!1}function t0(s,r){var l=s.ownerDocument.createRange();l.selectNodeContents(s),s=l.getBoundingClientRect(),window.scrollTo(window.scrollX+s.left,r?window.scrollY+s.top:window.scrollY+s.bottom-window.innerHeight)}Nn.prototype.scrollIntoView=function(s){if(typeof s=="object")throw Error(i(566));var r=[];y(this._fragmentFiber.child,!1,Nh,r,void 0,void 0);var l=s!==!1;if(r.length===0){var c=T(this._fragmentFiber);if(c=l?c[1]||c[0]||v(this._fragmentFiber):c[0]||c[1],c===null)return;if(c.tag===6){s=x(c),t0(s,l);return}if(c=x(c),c.nodeType!==9){if(c.nodeType===11){l="host"in c?c.host:null,l!==null&&l.scrollIntoView(s);return}c.scrollIntoView(s)}}for(c=l?r.length-1:0;c!==(l?-1:r.length);){var h=r[c];h.tag===6?(h=x(h),t0(h,l)):x(h).scrollIntoView(s),c+=l?-1:1}};function NR(s,r){return s=x(s),n0(s,r),!1}function n0(s,r){s.reactFragments==null&&(s.reactFragments=new Set),s.reactFragments.add(r)}function s0(s,r){var l=r._eventListeners;if(l!==null)for(var c=0;c<l.length;c++){var h=l[c];s.addEventListener(h.type,h.attachedListener,Ta(h.optionsOrUseCapture))}s.nodeType!==3&&(l=r._observers,l!==null&&l.forEach(function(g){for(var S=0,A=0;A<ls.length;A++){var j=ls[A];(j.fragmentInstance!==r||j.observer!==g||j.instance!==s)&&(ls[S++]=j)}ls.length=S,g.observe(s)}),n0(s,r))}function OR(s,r){var l=r._eventListeners;if(l!==null)for(var c=0;c<l.length;c++){var h=l[c];s.removeEventListener(h.type,h.attachedListener,Ta(h.optionsOrUseCapture))}s.nodeType!==3&&(l=r._observers,l!==null&&l.forEach(function(g){typeof g.rootMargin=="string"?RR(r,g,s):g.unobserve(s)}),s.reactFragments!=null&&s.reactFragments.delete(r))}function Dh(s){var r=s.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var l=r;switch(r=r.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Dh(l),Hl(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}s.removeChild(l)}}function DR(s,r,l,c){for(;s.nodeType===1;){var h=l;if(s.nodeName.toLowerCase()!==r.toLowerCase()){if(!c&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(c){if(!s[ro])switch(r){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(g=s.getAttribute("rel"),g==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(g!==h.rel||s.getAttribute("href")!==(h.href==null||h.href===""?null:h.href)||s.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin)||s.getAttribute("title")!==(h.title==null?null:h.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(g=s.getAttribute("src"),(g!==(h.src==null?null:h.src)||s.getAttribute("type")!==(h.type==null?null:h.type)||s.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&g&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(r==="input"&&s.type==="hidden"){var g=h.name==null?null:""+h.name;if(h.type==="hidden"&&s.getAttribute("name")===g)return s}else return s;if(s=Yn(s.nextSibling),s===null)break}return null}function jR(s,r,l){if(r==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!l||(s=Yn(s.nextSibling),s===null))return null;return s}function i0(s,r){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!r||(s=Yn(s.nextSibling),s===null))return null;return s}function jh(s){return s.data==="$?"||s.data==="$~"}function zh(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function zR(s,r){var l=s.ownerDocument;if(s.data==="$~")s._reactRetry=r;else if(s.data!=="$?"||l.readyState!=="loading")r();else{var c=function(){r(),l.removeEventListener("DOMContentLoaded",c)};l.addEventListener("DOMContentLoaded",c),s._reactRetry=c}}function Yn(s){for(;s!=null;s=s.nextSibling){var r=s.nodeType;if(r===1||r===3)break;if(r===8){if(r=s.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return s}var Ph=null;function r0(s){s=s.nextSibling;for(var r=0;s;){if(s.nodeType===8){var l=s.data;if(l==="/$"||l==="/&"){if(r===0)return Yn(s.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}s=s.nextSibling}return null}function a0(s){s=s.previousSibling;for(var r=0;s;){if(s.nodeType===8){var l=s.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(r===0)return s;r--}else l!=="/$"&&l!=="/&"||r++}s=s.previousSibling}return null}function PR(s,r){function l(){c=!0}if(s.ownerDocument.activeElement===s)return!0;var c=!1;try{s.ownerDocument.addEventListener("focus",l,!0),(s.focus||HTMLElement.prototype.focus).call(s,r)}finally{s.ownerDocument.removeEventListener("focus",l,!0)}return c}function BR(s){F_(function(){F_(function(r){return s(r)})})}function o0(s,r,l){switch(r=Ho(l),s){case"html":if(s=r.documentElement,!s)throw Error(i(452));return s;case"head":if(s=r.head,!s)throw Error(i(453));return s;case"body":if(s=r.body,!s)throw Error(i(454));return s;default:throw Error(i(451))}}function l0(s,r,l){for(var c in l){var h=l[c];l.hasOwnProperty(c)&&h!=null&&st(s,r,c,null,hR,h)}l.dangerouslySetInnerHTML!=null&&(s.textContent=""),s.onclick===ms&&(s.onclick=null),Hl(s)}function Bh(s){for(var r=s.attributes;r.length;)s.removeAttributeNode(r[0]);Hl(s)}var Qn=new Map,u0=new Set;function Vo(s){if(typeof s.getRootNode=="function"){var r=s.getRootNode();if(r.nodeType===9||r.nodeType===11)return r}return s.nodeType===9?s:s.ownerDocument}var Js=ge.d;ge.d={f:UR,r:LR,D:qR,C:HR,L:VR,m:$R,X:FR,S:GR,M:YR};function UR(){var s=Js.f(),r=Gu();return s||r}function LR(s){var r=qr(s);r!==null&&r.tag===5&&r.type==="form"?db(r):Js.r(s)}var wa=typeof document>"u"?null:document;function c0(s,r,l){var c=wa;if(c&&typeof r=="string"&&r){var h=Ln(r);h='link[rel="'+s+'"][href="'+h+'"]',typeof l=="string"&&(h+='[crossorigin="'+l+'"]'),u0.has(h)||(u0.add(h),s={rel:s,crossOrigin:l,href:r},c.querySelector(h)===null&&(r=c.createElement("link"),Ft(r,"link",s),jt(r),c.head.appendChild(r)))}}function qR(s){Js.D(s),c0("dns-prefetch",s,null)}function HR(s,r){Js.C(s,r),c0("preconnect",s,r)}function VR(s,r,l){Js.L(s,r,l);var c=wa;if(c&&s&&r){var h='link[rel="preload"][as="'+Ln(r)+'"]';r==="image"&&l&&l.imageSrcSet?(h+='[imagesrcset="'+Ln(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(h+='[imagesizes="'+Ln(l.imageSizes)+'"]')):h+='[href="'+Ln(s)+'"]';var g=h;switch(r){case"style":g=xa(s);break;case"script":g=Ca(s)}if(!(Qn.has(g)||(s=P({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:s,as:r},l),Qn.set(g,s),c.querySelector(h)!==null||r==="style"&&c.querySelector($o(g))||r==="script"&&c.querySelector(Go(g))))){var S=c.createElement("link");Ft(S,"link",s),r==="style"&&(S[ql]=!0,S.onload=S.onerror=function(){wy(S)}),jt(S),c.head.appendChild(S)}}}function $R(s,r){Js.m(s,r);var l=wa;if(l&&s){var c=r&&typeof r.as=="string"?r.as:"script",h='link[rel="modulepreload"][as="'+Ln(c)+'"][href="'+Ln(s)+'"]',g=h;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Ca(s)}if(!Qn.has(g)&&(s=P({rel:"modulepreload",href:s},r),Qn.set(g,s),l.querySelector(h)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Go(g)))return}c=l.createElement("link"),Ft(c,"link",s),jt(c),l.head.appendChild(c)}}}function GR(s,r,l){Js.S(s,r,l);var c=wa;if(c&&s){var h=Hr(c).hoistableStyles,g=xa(s);r=r||"default";var S=h.get(g);if(!S){var A={loading:0,preload:null};if(S=c.querySelector($o(g)))A.loading=5;else{s=P({rel:"stylesheet",href:s,"data-precedence":r},l),(l=Qn.get(g))&&Uh(s,l);var j=S=c.createElement("link");jt(j),Ft(j,"link",s),j._p=new Promise(function(Y,ne){j.onload=Y,j.onerror=ne}),j.addEventListener("load",function(){A.loading|=1}),j.addEventListener("error",function(){A.loading|=2}),A.loading|=4,Zu(S,r,c)}S={type:"stylesheet",instance:S,count:1,state:A},h.set(g,S)}}}function FR(s,r){Js.X(s,r);var l=wa;if(l&&s){var c=Hr(l).hoistableScripts,h=Ca(s),g=c.get(h);g||(g=l.querySelector(Go(h)),g||(s=P({src:s,async:!0},r),(r=Qn.get(h))&&Lh(s,r),g=l.createElement("script"),jt(g),Ft(g,"link",s),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function YR(s,r){Js.M(s,r);var l=wa;if(l&&s){var c=Hr(l).hoistableScripts,h=Ca(s),g=c.get(h);g||(g=l.querySelector(Go(h)),g||(s=P({src:s,async:!0,type:"module"},r),(r=Qn.get(h))&&Lh(s,r),g=l.createElement("script"),jt(g),Ft(g,"link",s),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(h,g))}}function d0(s,r,l,c){var h=(h=Ot.current)?Vo(h):null;if(!h)throw Error(i(446));switch(s){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(l=xa(l.href),r=Hr(h).hoistableStyles,c=r.get(l),c||(c={type:"style",instance:null,count:0,state:null},r.set(l,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){s=xa(l.href);var g=Hr(h).hoistableStyles,S=g.get(s);if(S||(h=h.ownerDocument||h,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(s,S),(g=h.querySelector($o(s)))?g._p||(S.instance=g,S.state.loading=5):(g=Qn.get(s),g||(g={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Qn.set(s,g)),QR(h,s,g,S.state))),r&&c===null)throw Error(i(528,""));return S}if(r&&c!==null)throw Error(i(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(l=Ca(l),r=Hr(h).hoistableScripts,c=r.get(l),c||(c={type:"script",instance:null,count:0,state:null},r.set(l,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,s))}}function xa(s){return'href="'+Ln(s)+'"'}function $o(s){return'link[rel="stylesheet"]['+s+"]"}function f0(s){return P({},s,{"data-precedence":s.precedence,precedence:null})}function QR(s,r,l,c){if(r=s.querySelector('link[rel="preload"][as="style"]['+r+"]")){if(r[ql]!==!0){c.loading=1;return}}else r=s.createElement("link"),r[ql]=!0,r.onload=r.onerror=wy.bind(null,r),Ft(r,"link",l),jt(r),s.head.appendChild(r);c.preload=r,r.addEventListener("load",function(){return c.loading|=1}),r.addEventListener("error",function(){return c.loading|=2})}function Ca(s){return'[src="'+Ln(s)+'"]'}function Go(s){return"script[async]"+s}function h0(s,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var c=s.querySelector('style[data-href~="'+Ln(l.href)+'"]');if(c)return r.instance=c,jt(c),c;var h=P({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return c=(s.ownerDocument||s).createElement("style"),jt(c),Ft(c,"style",h),Zu(c,l.precedence,s),r.instance=c;case"stylesheet":h=xa(l.href);var g=s.querySelector($o(h));if(g)return r.state.loading|=4,r.instance=g,jt(g),g;c=f0(l),(h=Qn.get(h))&&Uh(c,h),g=(s.ownerDocument||s).createElement("link"),jt(g);var S=g;return S._p=new Promise(function(A,j){S.onload=A,S.onerror=j}),Ft(g,"link",c),r.state.loading|=4,Zu(g,l.precedence,s),r.instance=g;case"script":return g=Ca(l.src),(h=s.querySelector(Go(g)))?(r.instance=h,jt(h),h):(c=l,(h=Qn.get(g))&&(c=P({},l),Lh(c,h)),s=s.ownerDocument||s,h=s.createElement("script"),jt(h),Ft(h,"link",c),s.head.appendChild(h),r.instance=h);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(c=r.instance,r.state.loading|=4,Zu(c,l.precedence,s));return r.instance}function Zu(s,r,l){for(var c=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=c.length?c[c.length-1]:null,g=h,S=0;S<c.length;S++){var A=c[S];if(A.dataset.precedence===r)g=A;else if(g!==h)break}g?g.parentNode.insertBefore(s,g.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(s,r.firstChild))}function Uh(s,r){s.crossOrigin==null&&(s.crossOrigin=r.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=r.referrerPolicy),s.title==null&&(s.title=r.title)}function Lh(s,r){s.crossOrigin==null&&(s.crossOrigin=r.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=r.referrerPolicy),s.integrity==null&&(s.integrity=r.integrity)}var Wu=null;function p0(s,r,l){if(Wu===null){var c=new Map,h=Wu=new Map;h.set(l,c)}else h=Wu,c=h.get(l),c||(c=new Map,h.set(l,c));if(c.has(s))return c;for(c.set(s,null),l=l.getElementsByTagName(s),h=0;h<l.length;h++){var g=l[h];if(!(g[ro]||g[qt]||s==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(r)||"";S=s+S;var A=c.get(S);A?A.push(g):c.set(S,[g])}}return c}function qh(s,r,l){s=s.ownerDocument||s,s.head.insertBefore(l,r==="title"?s.querySelector("head > title"):null)}function KR(s,r,l){if(l===1||r.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(s=r.disabled,typeof r.precedence=="string"&&s==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function m0(s,r){return s==="img"&&r.src!=null&&r.src!==""&&r.onLoad==null&&r.loading!=="lazy"}function g0(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function y0(s){return(s.width||100)*(s.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function v0(s,r){typeof r.decode=="function"&&(s.imgCount++,r.complete||(s.imgBytes+=y0(r),s.suspenseyImages.push(r)),s=ZR.bind(s),r.decode().then(s,s))}function XR(s,r,l,c){if(l.type==="stylesheet"&&(typeof c.media!="string"||matchMedia(c.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var h=xa(c.href),g=r.querySelector($o(h));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(s.count++,s=Fo.bind(s),r.then(s,s)),l.state.loading|=4,l.instance=g,jt(g);return}g=r.ownerDocument||r,c=f0(c),(h=Qn.get(h))&&Uh(c,h),g=g.createElement("link"),jt(g);var S=g;S._p=new Promise(function(A,j){S.onload=A,S.onerror=j}),Ft(g,"link",c),l.instance=g}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(s.count++,l=Fo.bind(s),r.addEventListener("load",l),r.addEventListener("error",l))}}var ec=0;function JR(s,r){return s.stylesheets&&s.count===0&&nc(s,s.stylesheets),0<s.count||0<s.imgCount?function(l){var c=setTimeout(function(){if(s.stylesheets&&nc(s,s.stylesheets),s.unsuspend){var g=s.unsuspend;s.unsuspend=null,g()}},6e4+r);0<s.imgBytes&&ec===0&&(ec=62500*mR());var h=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&nc(s,s.stylesheets),s.unsuspend)){var g=s.unsuspend;s.unsuspend=null,g()}},(s.imgBytes>ec?50:800)+r);return s.unsuspend=l,function(){s.unsuspend=null,clearTimeout(c),clearTimeout(h)}}:null}function b0(s){if(s.count===0&&(s.imgCount===0||!s.waitingForImages)){if(s.stylesheets)nc(s,s.stylesheets);else if(s.unsuspend){var r=s.unsuspend;s.unsuspend=null,r()}}}function Fo(){this.count--,b0(this)}function ZR(){this.imgCount--,b0(this)}var tc=null;function nc(s,r){s.stylesheets=null,s.unsuspend!==null&&(s.count++,tc=new Map,r.forEach(WR,s),tc=null,Fo.call(s))}function WR(s,r){if(!(r.state.loading&4)){var l=tc.get(s);if(l)var c=l.get(null);else{l=new Map,tc.set(s,l);for(var h=s.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<h.length;g++){var S=h[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(l.set(S.dataset.precedence,S),c=S)}c&&l.set(null,c)}h=r.instance,S=h.getAttribute("data-precedence"),g=l.get(S)||c,g===c&&l.set(null,h),l.set(S,h),this.count++,c=Fo.bind(this),h.addEventListener("load",c),h.addEventListener("error",c),g?g.parentNode.insertBefore(h,g.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(h,s.firstChild)),r.state.loading|=4}}var Ea={$$typeof:Z,Provider:null,Consumer:null,_currentValue:Oe,_currentValue2:Oe,_threadCount:0};function eM(s,r,l,c,h,g,S,A,j){this.tag=1,this.containerInfo=s,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=_d(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_d(0),this.hiddenUpdates=_d(null),this.identifierPrefix=c,this.onUncaughtError=h,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=j,this.transitionTypes=null,this.incompleteTransitions=new Map}function _0(s,r,l,c,h,g,S,A,j,Y,ne,ue){return s=new eM(s,r,l,S,j,Y,ne,ue,A),r=1,g===!0&&(r|=24),g=hn(3,null,null,r),s.current=g,g.stateNode=s,r=tf(),r.refCount++,s.pooledCache=r,r.refCount++,g.memoizedState={element:c,isDehydrated:l,cache:r},af(g),s}function S0(s){return s?(s=Zr,s):Zr}function T0(s,r,l,c,h,g){h=S0(h),c.context===null?c.context=h:c.pendingContext=h,c=yi(r),c.payload={element:l},g=g===void 0?null:g,g!==null&&(c.callback=g),l=vi(s,c,r),l!==null&&(yn(l,s,r),wo(l,s,r))}function w0(s,r){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var l=s.retryLane;s.retryLane=l!==0&&l<r?l:r}}function Hh(s,r){w0(s,r),(s=s.alternate)&&w0(s,r)}function x0(s){if(s.tag===13||s.tag===31){var r=Ji(s,67108864);r!==null&&yn(r,s,67108864),Hh(s,67108864)}}function C0(s){if(s.tag===13||s.tag===31){var r=kn();r=Sd(r);var l=Ji(s,r);l!==null&&yn(l,s,r),Hh(s,r)}}var Aa=!0;function tM(s,r,l,c){var h=fe.T;fe.T=null;var g=ge.p;try{ge.p=2,Vh(s,r,l,c)}finally{ge.p=g,fe.T=h}}function nM(s,r,l,c){var h=fe.T;fe.T=null;var g=ge.p;try{ge.p=8,Vh(s,r,l,c)}finally{ge.p=g,fe.T=h}}function Vh(s,r,l,c){if(Aa){var h=$h(c);if(h===null)xh(s,r,c,sc,l),A0(s,c);else if(iM(h,s,r,l,c))c.stopPropagation();else if(A0(s,c),r&4&&-1<sM.indexOf(s)){for(;h!==null;){var g=qr(h);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=Fi(g.pendingLanes);if(S!==0){var A=g;for(A.pendingLanes|=2,A.entangledLanes|=2;S;){var j=1<<31-xn(S);A.entanglements[1]|=j,S&=~j}Cs(g),(Je&6)===0&&(Hu=Lt()+500,Uo(0))}}break;case 31:case 13:A=Ji(g,2),A!==null&&yn(A,g,2),Gu(),Hh(g,2)}if(g=$h(c),g===null&&xh(s,r,c,sc,l),g===h)break;h=g}h!==null&&c.stopPropagation()}else xh(s,r,c,null,l)}}function $h(s){return s=Id(s),Gh(s)}var sc=null;function Gh(s){if(sc=null,s=Yi(s),s!==null){var r=o(s);if(r===null)s=null;else{var l=r.tag;if(l===13){if(s=u(r),s!==null)return s;s=null}else if(l===31){if(s=d(r),s!==null)return s;s=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;s=null}else r!==s&&(s=null)}}return sc=s,null}function E0(s){switch(s){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"fullscreenerror":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"resize":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(en()){case zs:return 2;case Un:return 8;case zl:case g2:return 32;case hy:return 268435456;default:return 32}default:return 32}}var Fh=!1,Mi=null,ki=null,Ni=null,Yo=new Map,Qo=new Map,Oi=[],sM="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function A0(s,r){switch(s){case"focusin":case"focusout":Mi=null;break;case"dragenter":case"dragleave":ki=null;break;case"mouseover":case"mouseout":Ni=null;break;case"pointerover":case"pointerout":Yo.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Qo.delete(r.pointerId)}}function Ko(s,r,l,c,h,g){return s===null||s.nativeEvent!==g?(s={blockedOn:r,domEventName:l,eventSystemFlags:c,nativeEvent:g,targetContainers:[h]},r!==null&&(r=qr(r),r!==null&&x0(r)),s):(s.eventSystemFlags|=c,r=s.targetContainers,h!==null&&r.indexOf(h)===-1&&r.push(h),s)}function iM(s,r,l,c,h){switch(r){case"focusin":return Mi=Ko(Mi,s,r,l,c,h),!0;case"dragenter":return ki=Ko(ki,s,r,l,c,h),!0;case"mouseover":return Ni=Ko(Ni,s,r,l,c,h),!0;case"pointerover":var g=h.pointerId;return Yo.set(g,Ko(Yo.get(g)||null,s,r,l,c,h)),!0;case"gotpointercapture":return g=h.pointerId,Qo.set(g,Ko(Qo.get(g)||null,s,r,l,c,h)),!0}return!1}function I0(s){var r=Yi(s.target);if(r!==null){var l=o(r);if(l!==null){if(r=l.tag,r===13){if(r=u(l),r!==null){s.blockedOn=r,_y(s.priority,function(){C0(l)});return}}else if(r===31){if(r=d(l),r!==null){s.blockedOn=r,_y(s.priority,function(){C0(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){s.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}s.blockedOn=null}function ic(s){if(s.blockedOn!==null)return!1;for(var r=s.targetContainers;0<r.length;){var l=$h(s.nativeEvent);if(l===null){l=s.nativeEvent;var c=new l.constructor(l.type,l);Ad=c,l.target.dispatchEvent(c),Ad=null}else return r=qr(l),r!==null&&x0(r),s.blockedOn=l,!1;r.shift()}return!0}function R0(s,r,l){ic(s)&&l.delete(r)}function rM(){Fh=!1,Mi!==null&&ic(Mi)&&(Mi=null),ki!==null&&ic(ki)&&(ki=null),Ni!==null&&ic(Ni)&&(Ni=null),Yo.forEach(R0),Qo.forEach(R0)}function rc(s,r){s.blockedOn===r&&(s.blockedOn=null,Fh||(Fh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,rM)))}var ac=null;function M0(s){ac!==s&&(ac=s,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ac===s&&(ac=null);for(var r=0;r<s.length;r+=3){var l=s[r],c=s[r+1],h=s[r+2];if(typeof c!="function"){if(Gh(c||l)===null)continue;break}var g=qr(l);g!==null&&(s.splice(r,3),r-=3,Af(g,{pending:!0,data:h,method:l.method,action:c},c,h))}}))}function Ia(s){function r(j){return rc(j,s)}Mi!==null&&rc(Mi,s),ki!==null&&rc(ki,s),Ni!==null&&rc(Ni,s),Yo.forEach(r),Qo.forEach(r);for(var l=0;l<Oi.length;l++){var c=Oi[l];c.blockedOn===s&&(c.blockedOn=null)}for(;0<Oi.length&&(l=Oi[0],l.blockedOn===null);)I0(l),l.blockedOn===null&&Oi.shift();if(l=(s.ownerDocument||s).$$reactFormReplay,l!=null)for(c=0;c<l.length;c+=3){var h=l[c],g=l[c+1],S=h[fn]||null;if(typeof g=="function")S||M0(l);else if(S){var A=null;if(g&&g.hasAttribute("formAction")){if(h=g,S=g[fn]||null)A=S.formAction;else if(Gh(h)!==null)continue}else A=S.action;typeof A=="function"?l[c+1]=A:(l.splice(c,3),c-=3),M0(l)}}}function k0(){function s(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return h=S})},focusReset:"manual",scroll:"manual"})}function r(){h!==null&&(h(),h=null),c||setTimeout(l,20)}function l(){if(!c&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var c=!1,h=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){c=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),h!==null&&(h(),h=null)}}}function Yh(s){this._internalRoot=s}oc.prototype.render=Yh.prototype.render=function(s){var r=this._internalRoot;if(r===null)throw Error(i(409));var l=r.current,c=kn();T0(l,c,s,r,null,null)},oc.prototype.unmount=Yh.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var r=s.containerInfo;T0(s.current,2,null,s,null,null),Gu(),r[Lr]=null}};function oc(s){this._internalRoot=s}oc.prototype.unstable_scheduleHydration=function(s){if(s){var r=by();s={blockedOn:null,target:s,priority:r};for(var l=0;l<Oi.length&&r!==0&&r<Oi[l].priority;l++);Oi.splice(l,0,s),l===0&&I0(s)}};var N0=e.version;if(N0!=="19.3.1")throw Error(i(527,N0,"19.3.1"));ge.findDOMNode=function(s){var r=s._reactInternals;if(r===void 0)throw typeof s.render=="function"?Error(i(188)):(s=Object.keys(s).join(","),Error(i(268,s)));return s=p(r),s=s!==null?m(s):null,s=s===null?null:s.stateNode,s};var aM={bundleType:0,version:"19.3.1",rendererPackageName:"react-dom",currentDispatcherRef:fe,reconcilerVersion:"19.3.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var lc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lc.isDisabled&&lc.supportsFiber)try{no=lc.inject(aM),wn=lc}catch{}}return Jo.createRoot=function(s,r){if(!a(s))throw Error(i(299));var l=!1,c="",h=Sb,g=Tb,S=wb;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onUncaughtError!==void 0&&(h=r.onUncaughtError),r.onCaughtError!==void 0&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=_0(s,1,!1,null,null,l,c,null,h,g,S,k0),s[Lr]=r.current,wh(s),new Yh(r)},Jo.hydrateRoot=function(s,r,l){if(!a(s))throw Error(i(299));var c=!1,h="",g=Sb,S=Tb,A=wb,j=null;return l!=null&&(l.unstable_strictMode===!0&&(c=!0),l.identifierPrefix!==void 0&&(h=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(S=l.onCaughtError),l.onRecoverableError!==void 0&&(A=l.onRecoverableError),l.formState!==void 0&&(j=l.formState)),r=_0(s,1,!0,r,l??null,c,h,j,g,S,A,k0),r.context=S0(null),l=r.current,c=kn(),c=Sd(c),h=yi(c),h.callback=null,vi(l,h,c),l=c,r.current.lanes=l,io(r,l),Cs(r),s[Lr]=r.current,wh(s),new oc(r)},Jo.version="19.3.1",Jo}var H0;function gM(){if(H0)return Kh.exports;H0=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Kh.exports=mM(),Kh.exports}var yM=gM(),se=Qm();const Jn=xl(se),QT=lM({__proto__:null,default:Jn},[se]);let Da=null;function vM(t,e){t.currentIndex=0,t.wipContextDeps=null,t.wipCommitCallbacks=[];const n=Da;Da=t;try{if(e(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{Da=n}}function ts(){if(!Da)throw new Error("No resource fiber available");return Da}function Ns(){return Da}const bM=t=>({version:0,committedVersion:0,dispatchUpdate:t,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),KT=t=>{t.committedVersion=t.version;for(const e of t.changelog)e.logged=!1,e.settled||(e.settled=!0,t.unsettledCount--),t.committedLog.push(e);t.changelog.length=0,t.unsettledCount===0&&(t.committedLog.length=0),t.rollbackCallbacks.length=0},V0=(t,e)=>{const n=t.version>e;if(t.version=e,n){for(let i=0;i<t.rollbackCallbacks.length;i++)t.rollbackCallbacks[i]();if(t.rollbackCallbacks.length=0,e<=t.committedVersion){const i=[];for(;t.committedVersion-i.length>e;){const a=t.committedLog.pop();if(a===void 0)break;Km(a.fiber,a.cell),a.cell.workInProgress=a.prevState,i.push({record:a,prevState:a.prevState,eagerState:a.eagerState,hasEagerState:a.hasEagerState})}if(i.length>0){const a=t.committedVersion;rd(t,()=>{for(let o=i.length-1;o>=0;o--){const u=i[o];u.record.prevState=u.prevState,u.record.eagerState=u.eagerState,u.record.hasEagerState=u.hasEagerState,t.committedLog.push(u.record)}t.committedVersion=a})}t.committedVersion=e;for(const a of t.changelog)a.logged=!1;t.changelog.length=0}else{for(;t.committedVersion+t.changelog.length>e;)t.changelog.pop().logged=!1;for(let i=0;i<t.changelog.length;i++)XT(t.changelog[i]);KT(t)}}},XT=t=>{Km(t.fiber,t.cell),t.queued||(t.queued=!0,(t.cell.queue??=[]).push(t))},Cl=(t,e)=>{t.wipCommitCallbacks.push(e)},rd=(t,e)=>{t.rollbackCallbacks.push(e)},Km=(t,e)=>{e.isDirty||(e.isDirty=!0,t.markDirty?.(),rd(t.root,()=>{if(e.queue!==null){for(const n of e.queue)n.queued=!1;e.queue=null}e.workInProgress=e.current,e.isDirty=!1}))},JT=Symbol.for("react.memo_cache_sentinel"),Hp=t=>new Array(t).fill(JT),_M=(t,e)=>{const n=t.memoCache;let i=n.workInProgress;if(i===null){const u=n.current;i=u===null?[]:u.map(d=>d.slice()),n.workInProgress=i,rd(t.root,()=>{n.workInProgress=null,n.refreshedIndices=null})}const a=n.index++;let o=i[a];return n.refreshedIndices?.has(a)&&!t.isRefreshing&&(n.refreshedIndices.delete(a),o=n.current?.[a]?.slice()??Hp(e),i[a]=o),(o===void 0||t.isRefreshing)&&(o=Hp(e),i[a]=o,t.isRefreshing&&(n.refreshedIndices??=new Set).add(a)),o},ZT=t=>_M(ts(),t),SM=Jn,TM=t=>se.useMemo(()=>{const e=Hp(t);return e[JT]=!0,e},[]),wM=SM.__COMPILER_RUNTIME?.c??TM,xM=()=>Ns()!==null,Q=t=>xM()?ZT(t):wM(t),wt=(t,...e)=>Object.assign(Object.create(null),t,...e),El=()=>{throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.")},Al=()=>{throw new Error("Hook order changed between renders")},CM=t=>({type:t,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function WT(t,e,n){const i=ts(),a=i.currentIndex++,o=i.cells[a],u=o===void 0?CM(n):o.type===n?o:Al();if(o===void 0&&(i.isFirstRender||El(),i.cells[a]=u,n==="insertion"?(i.insertionCells??=[]).push(u):i.effectCells.push(u)),u.deps!==null&&!!e!=!!u.deps)throw new Error("useEffect called with and without dependencies across re-renders");const d=i.isRefreshing;Cl(i,()=>{u.setup=t,u.setupDeps=e,d&&(u.deps=null),u.generation++})}function ni(t,e){WT(t,e,"effect")}function Er(t){const e=ts(),n=e.currentIndex++,i=e.cells[n];if(i===void 0){e.isFirstRender||El();const a={current:t};return e.cells[n]={type:"ref",ref:a},a}return i.type!=="ref"?Al():i.ref}const Xm=Symbol("tap.Context.defaultValue"),EM=t=>t;let Na=new Map;const vr=new Set,ew=(t,e)=>{t[Xm]=e},tw=t=>typeof t=="object"&&t!==null&&Xm in t,nw=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===Symbol.for("react.context"),Vp=t=>tw(t)||nw(t),sw=t=>{if(!tw(t)){if(nw(t)){ew(t,t._currentValue??t._currentValue2);return}throw new Error("A tap resource's `use()` only accepts a tap context.")}},Fa=(t,e,n)=>{if(typeof t!="object"||t===null)throw new Error("useContextProvider only accepts a React context.");sw(t);const i=t,a=ts(),o=Er(void 0),u=o.current===void 0||!Object.is(o.current.value,e);ni(()=>{o.current={value:e}},[e]);const d=Na.get(i),f=d!==void 0||Na.has(i);Na.set(i,{value:e,source:a});try{return AM(i,u,n)}finally{f?Na.set(i,d):Na.delete(i)}},AM=(t,e,n)=>{const i=vr.has(t);e?vr.add(t):vr.delete(t);try{return n()}finally{i?vr.add(t):vr.delete(t)}},iw=t=>{sw(t);const e=t,n=IM(e,t),i=ts();return(i.wipContextDeps??=new Map).set(e,n.source),n.value},IM=(t,e)=>Na.get(t)??{value:EM(e)[Xm],source:null},RM=(t,e,n,i)=>{if(!i)return n;let a=n;for(const[o,u]of i)u===e||u===t||(a??=new Map).set(o,u);return a},rw=(t,e=t.wipContextDeps)=>{const n=Ns();!n||!e||(n.wipContextDeps=RM(n,t,n.wipContextDeps,e))},aw=()=>vr.size>0,Jm=t=>{if(!t.contextDeps||!aw())return!1;for(const e of vr.keys())if(t.contextDeps.has(e))return!0;return!1},MM=(t,e,n)=>{if(t.isNeverMounted)throw new Error("Resource updated before mount");let i=!1,a=!0;t.root.unsettledCount++,t.root.dispatchUpdate(()=>(i||(i=!0,n&&t.root.changelog.length===0&&!e.cell.isDirty&&!e.hasEagerState&&(e.prevState=e.cell.workInProgress,e.eagerState=n(e.cell.workInProgress,e.action),e.hasEagerState=!0,a=!Object.is(e.cell.current,e.eagerState),!a&&!e.settled&&(e.settled=!0,t.root.unsettledCount--))),a),()=>(i=!0,a=!0,XT(e),e.logged||(e.logged=!0,t.root.changelog.push(e)),!0))},kM=(t,e,n,i,a)=>{const o=i?i(n):n,u={type:"reducer",workInProgress:o,current:o,isDirty:!1,queue:null,renderQueue:null,reducer:e,dispatch:d=>{const f=Ns();if(f!==null){if(f!==t)throw new Error("Cannot update a resource while rendering a different resource.");(t.renderPendingCells??=new Set).add(u),(u.renderQueue??=[]).push(d)}else{const p={fiber:t,cell:u,action:d,hasEagerState:!1,eagerState:void 0,prevState:u.current,settled:!1,queued:!1,logged:!1};MM(t,p,a?e:void 0)}}};return u};function ow(t,e,n,i){const a=ts(),o=a.currentIndex++,u=a.cells[o],d=(()=>{if(u!==void 0)return u.type==="reducer"?u:Al();a.isFirstRender||El();const p=kM(a,t,e,n,i);return a.cells[o]=p,p})(),f=d.queue;if(f!==null){const p=t===d.reducer;for(let m=0;m<f.length;m++){const y=f[m];(!y.hasEagerState||!p||!Object.is(y.prevState,d.workInProgress))&&(y.prevState=d.workInProgress,y.eagerState=t(d.workInProgress,y.action),y.hasEagerState=!0),y.queued=!1,d.workInProgress=y.eagerState}d.queue=null}if(d.reducer=t,d.renderQueue!==null){let p=d.workInProgress;for(const m of d.renderQueue)p=t(p,m);d.renderQueue=null,a.renderPendingCells?.delete(d),Object.is(p,d.workInProgress)||(Km(a,d),d.workInProgress=p)}return d.isDirty&&Cl(a,()=>{d.current=d.workInProgress,d.isDirty=!1}),[d.workInProgress,d.dispatch]}function Zm(t,e,n){return ow(t,e,n,!1)}const NM=(t,e)=>typeof e=="function"?e(t):e,OM=t=>t===void 0?void 0:typeof t=="function"?t():t;function lw(t){return ow(NM,t,OM,!0)}const Il=(t,e)=>{for(let n=0;n<t.length&&n<e.length;n++)if(!Object.is(t[n],e[n]))return!1;return!0},$0=(t,e)=>{Cl(t,()=>{e.current=e.wip,e.currentDeps=e.wipDeps,e.wipIsRefreshing=!1,e.isDirty=!1})},Wm=(t,e)=>{const n=ts(),i=n.currentIndex++;let a=n.cells[i];if(a===void 0){n.isFirstRender||El();const d=t();return a={type:"memo",current:d,currentDeps:e,wip:d,wipDeps:e,wipIsRefreshing:!1,isDirty:!1},n.cells[i]=a,d}a.type!=="memo"&&Al();const o=a;if(o.wipIsRefreshing&&!n.isRefreshing&&(o.wip=o.current,o.wipDeps=o.currentDeps,o.wipIsRefreshing=!1,o.isDirty=!1),!n.isRefreshing&&Il(o.wipDeps,e))return o.isDirty&&$0(n,o),o.wip;const u=t();return o.wip=u,o.wipDeps=e,o.wipIsRefreshing=n.isRefreshing,o.isDirty||(o.isDirty=!0,rd(n.root,()=>{o.wip=o.current,o.wipDeps=o.currentDeps,o.wipIsRefreshing=!1,o.isDirty=!1})),$0(n,o),u},uw=(t,e)=>Wm(()=>t,e);function cw(t,e){WT(t,e,"insertion")}function eg(t){const e=ts(),n=Er(t);return n.current!==t&&Cl(e,()=>{n.current=t}),Er(((...i)=>n.current(...i))).current}const DM=t=>t!==null&&typeof t=="object"&&typeof t.then=="function",G0=()=>{},jM=t=>{const e=t;switch(typeof e.status!="string"?(e.status="pending",t.then(n=>{e.status==="pending"&&(e.status="fulfilled",e.value=n)},n=>{e.status==="pending"&&(e.status="rejected",e.reason=n)})):e.status!=="fulfilled"&&e.status!=="rejected"&&t.then(G0,G0),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw t}},tg=t=>DM(t)?jM(t):iw(t),dw=(t,e,n=e)=>{const a=ts().isNeverMounted?n():e(),[,o]=Zm(f=>f+1,0),u=Er(0),d=eg(()=>{try{if(Object.is(a,e()))return u.current=0,!1}catch{}return!0});return ni(()=>t(()=>{d()&&o()}),[t]),ni(()=>{if(d()){if(++u.current>50)throw u.current=0,new Error("Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.");o()}},[t,a,e]),a},fw=(t,e)=>{};let zM=0;const hw=()=>{const t=Er(null);return t.current??=`:tap${zM++}:`,t.current},pw=(t,e,n)=>{const i=()=>{if(!t)return;const a=e();if(typeof t=="function"){const o=t(a);return typeof o=="function"?o:()=>t(null)}return t.current=a,()=>{t.current=null}};n==null?ni(i):ni(i,[...n,t])},PM=Jn;function BM(t){const e=se.useRef(t);return se.useInsertionEffect(()=>{e.current=t}),se.useCallback(((...n)=>e.current(...n)),[])}const UM=PM.useEffectEvent??BM,cn=()=>Ns()!==null,ft=Jn,Ne=t=>cn()?lw(t):ft.useState(t),LM=(t,e,n)=>cn()?Zm(t,e,n):ft.useReducer(t,e,n),we=t=>cn()?Er(t):ft.useRef(t),yt=(t,e)=>cn()?Wm(t,e):ft.useMemo(t,e),on=(t,e)=>cn()?uw(t,e):ft.useCallback(t,e),Ce=(t,e)=>cn()?ni(t,e):ft.useEffect(t,e),mw=(t,e)=>cn()?ni(t,e):ft.useLayoutEffect(t,e),bn=t=>cn()?eg(t):UM(t),Ui=(t,e,n)=>cn()?dw(t,e,n):ft.useSyncExternalStore(t,e,n),qM=(t,e)=>cn()?fw():ft.useDebugValue(t,e),Os=(t,e)=>cn()?cw(t,e):ft.useInsertionEffect(t,e),ad=()=>cn()?hw():ft.useId(),HM=(t,e,n)=>cn()?pw(t,e,n):ft.useImperativeHandle(t,e,n),et=t=>ft.forwardRef(t),Nt=(t,e)=>ft.memo(t,e),gw=ft.Fragment,VM=(...t)=>ft.createElement(...t),$M=(...t)=>ft.cloneElement(...t),od=t=>ft.isValidElement(t);ft.Children;ft.Suspense;const Qt=t=>{const e=ft.createContext(t);return ew(e,t),e},Rl=t=>{if(cn()&&Vp(t))return tg(t);if(ft.use)return ft.use(t);if(Vp(t))return ft.useContext(t);throw new Error("React.use() requires React 19 outside a tap resource.")},Sn=t=>cn()&&Vp(t)?tg(t):ft.useContext(t),Nr=(t,e)=>{if(t.length!==0){if(t.length===1)throw t[0];for(const n of t)console.error(n);throw new AggregateError(t,e)}},GM=50;let Xt={schedulers:new Set,tasks:[],notifies:[],isScheduled:!1},ei=null;var FM=class{_isDirty=!1;_task;constructor(t){this._task=t}get isDirty(){return this._isDirty}markDirty(){if(ei&&(ei.get(this)??0)>=GM)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.");this._isDirty=!0,Xt.schedulers.add(this),yw()}runTask(){ei?.set(this,(ei.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}};const YM=new FM(()=>{const t=Xt.tasks.splice(0),e=[];for(const n of t)try{n()}catch(i){e.push(i)}Nr(e,"Errors occurred while running scheduled tasks")}),yw=()=>{Xt.isScheduled||(Xt.isScheduled=!0,QM())},$p=()=>{const t=ei;ei=new Map;const e=[];try{for(const n of Xt.schedulers)if(Xt.schedulers.delete(n),!!n.isDirty)try{n.runTask()}catch(i){e.push(i)}}finally{if(ei=t,Xt.schedulers.clear(),Xt.isScheduled=!1,ei===null){const n=Xt.notifies;for(;n.length>0;)try{n.shift()()}catch(i){e.push(i)}}}Nr(e,"Errors occurred during flushSync")},QM=(()=>{if(typeof MessageChannel<"u"){let t=null,e;return()=>{if(!t){const n=new MessageChannel;n.port1.onmessage=()=>{t?.unref?.(),$p()},t=n.port1,e=n.port2}t.ref?.(),e.postMessage(null)}}return()=>setTimeout($p,0)})(),F0=t=>{if(ei!==null)return t();const e=Xt;Xt={schedulers:new Set,tasks:[],notifies:[],isScheduled:!0};try{const n=t();return $p(),n}finally{const n=Xt;Xt=e;for(const i of n.tasks)Xt.tasks.push(i);if(Xt.tasks.length>0&&YM.markDirty(),n.schedulers.size>0){for(const i of n.schedulers)Xt.schedulers.add(i);yw()}}};function KM(t){if(t.length===0)return;let e;for(let n=0;n<t.length;n++)try{t[n]()}catch(i){(e??=[]).push(i)}e!==void 0&&Nr(e,"Errors during commit")}function XM(t){const e=t.setup,n=t.setupDeps,i=t.generation;let a;try{const o=e();if(o!==void 0&&typeof o!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof o}`);a=o}finally{t.generation===i?(t.cleanup=a,t.deps=n):a?.()}}const JM=t=>t.setup===void 0?!1:t.deps===null||t.setupDeps===void 0?!0:!Il(t.deps,t.setupDeps);function Y0(t,e){let n;for(const i of t)JM(i)&&(n??=[]).push(i);if(n===void 0)return e;for(const i of n)if(i.deps=null,i.cleanup!==void 0)try{i.cleanup()}catch(a){(e??=[]).push(a)}finally{i.cleanup=void 0}for(const i of n)try{XM(i)}catch(a){(e??=[]).push(a)}return e}function ZM(t,e=!0){let n;t.insertionCells!==null&&e&&(n=Y0(t.insertionCells,n)),n=Y0(t.effectCells,n),n!==void 0&&Nr(n,"Errors during commit")}function Q0(t){let e;for(const n of t)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(i){(e??=[]).push(i)}finally{n.cleanup=void 0}e!==void 0&&Nr(e,"Errors during cleanup")}const WM={useState:lw,useReducer:Zm,useRef:Er,useMemo:Wm,useCallback:uw,useEffect:ni,useLayoutEffect:ni,useInsertionEffect:cw,useEffectEvent:eg,useContext:iw,use:tg,useSyncExternalStore:dw,useDebugValue:fw,useId:hw,useImperativeHandle:pw,useMemoCache:ZT},K0=Jn,mr=K0.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??K0.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,uc=mr==null?null:"H"in mr?{get current(){return mr.H},set current(t){mr.H=t}}:"ReactCurrentDispatcher"in mr?{get current(){return mr.ReactCurrentDispatcher.current},set current(t){mr.ReactCurrentDispatcher.current=t}}:null;function ek(t){if(!uc)return t();const e=uc.current;uc.current=WM;try{return t()}finally{uc.current=e}}function tk(t,e,n=void 0,i){return{hook:t,root:e,markDirty:n,devStrictMode:i,cells:[],effectCells:[],insertionCells:null,hostCells:null,contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,refreshedIndices:null,index:0},renderPendingCells:null,currentIndex:0,isRefreshing:!1,isFirstRender:!0,isMounted:!1,isReleased:!1,isNeverMounted:!0}}function vw(t){t.wipCommitCallbacks=null,t.wipContextDeps=null,t.memoCache.workInProgress=null,t.memoCache.refreshedIndices=null}function Ua(t,e,n){try{e?(t.isReleased=!0,t.insertionCells!==null&&Q0(t.insertionCells)):t.isMounted&&(t.isMounted=!1,Q0(t.effectCells))}catch(i){(n??=[]).push(i)}if(t.hostCells!==null){for(const i of t.hostCells)if(i.fiber!==null&&(n=Ua(i.fiber,e,n)),i.fibers!==null)for(const{fiber:a}of i.fibers.values())n=Ua(a,e,n)}return n}function bw(t,e=!0){let n;e&&(n=Ua(t,!0,n)),n=Ua(t,!1,n),n!==void 0&&Nr(n,"Errors during cleanup")}function _w(t){let e;for(const n of t)n.isReleased&&(e=Ua(n,!0,e));for(const n of t)e=Ua(n,!1,e);e!==void 0&&Nr(e,"Errors during cleanup")}function ll(t,e){if(t.renderPendingCells!==null){for(const o of t.renderPendingCells)o.renderQueue=null;t.renderPendingCells.clear()}let n=0,i;const a=t.isRefreshing;t.isRefreshing=a||(Ns()?.isRefreshing??!1);try{do{if(++n>25)throw new Error("Too many re-renders. tap limits the number of renders to prevent an infinite loop.");t.memoCache.index=0,vM(t,()=>{i=ek(()=>t.hook(...e))})}while((t.renderPendingCells?.size??0)>0)}catch(o){throw vw(t),o}finally{t.isRefreshing=a}return rw(t),i}function kc(t){const e=t.wipCommitCallbacks;t.wipCommitCallbacks=null,t.isMounted=!0,t.isNeverMounted=!1,e!==null&&(t.contextDeps=t.wipContextDeps,KT(t.root),t.memoCache.workInProgress!==null&&(t.memoCache.current=t.memoCache.workInProgress,t.memoCache.workInProgress=null,t.memoCache.refreshedIndices=null),KM(e)),ZM(t,e!==null)}const nk=()=>{const t=ts();return t.devStrictMode?t.isFirstRender?"child":"root":null},sk=()=>null,ik=()=>sk,rk=()=>Ns()?nk:ik(),ak=t=>{const e=ts(),n=e.currentIndex++,i=e.cells[n];let a;if(i===void 0){e.isFirstRender||El();const o=t instanceof Map;a={type:"host",fiber:o?null:t,fibers:o?t:null},e.cells[n]=a,(e.hostCells??=[]).push(a)}else i.type!=="host"&&Al(),a=i;return a.fibers===null&&a.fiber!==t&&Cl(e,()=>{a.fiber=t}),a},X0=(t,e)=>{if(!(t instanceof Map))return e(t);for(const{fiber:n}of t.values())e(n)},ok=t=>{t.isReleased=!1},lk=t=>{t.isReleased=!0,t.isMounted||queueMicrotask(()=>{t.isReleased&&bw(t,!0)})},uk=t=>{Os(()=>(X0(t,ok),()=>X0(t,lk)),[t]),Ce(()=>()=>{_w(t instanceof Map?Array.from(t.values(),({fiber:e})=>e):[t])},[t])},ng=t=>Ns()?ak(t):(uk(t),null),ck=()=>{const t=we(0),e=t.current,n=ts();return{version:e,markDirty:yt(()=>()=>{t.current++,n.markDirty?.()},[n]),root:n.root}},dk=()=>{const[t]=Ne(()=>bM((a,o)=>{let u=!1;i(d=>(u=!a(),u?d:d+1)),u||n(()=>a()&&o())})),[e,n]=LM((a,o)=>(V0(t,a),a+(o()?1:0)),0),[,i]=Ne(0);return V0(t,e),{root:t,version:e,markDirty:void 0}},sg=()=>{const t=rk(),e=Ns()===null,n=e?t():null,{root:i,version:a,markDirty:o}=e?dk():ck();return{version:a,createFiber:on((u,d,f)=>tk(u,i,f?()=>{f(),o?.()}:o,e?n:t()),[])}};function Ye(t){return(...e)=>({hook:t,args:e})}function Jt(t,e,n){return typeof e=="function"?(...i)=>Jt(t,e(...i)):n?{...e,key:t,deps:n}:{...e,key:t}}const fk=(t,e)=>({fiber:t,key:e,currentDeps:null,current:null,wipDeps:null,wip:null});function Dn(t){const{version:e,createFiber:n}=sg(),i=we(null),a=i.current??=fk(n(t.hook,t.key),t.key),o=yt(()=>a.fiber.hook===t.hook&&a.key===t.key&&!a.fiber.isReleased?a.fiber:n(t.hook,t.key),[a,t.hook,t.key,n]);a.wipDeps=a.currentDeps,a.wip=a.current;const u=[o,e,t.args];(Ns()?.isRefreshing||Jm(o)||a.currentDeps===null||!Il(a.currentDeps,u))&&(a.wipDeps=u,a.wip={value:ll(o,t.args)});const d=a.wip,f=ng(o);return Ce(()=>{if(a.currentDeps=a.wipDeps,a.current=a.wip,a.fiber=o,a.key=t.key,kc(o),f!==null)return()=>{f.fiber!==o&&bw(o,!0)}},[a,f,o,t.key,d]),d.value}const hk=(t,e,n)=>{const i=we(null),a=i.current??(i.current={currentDeps:null,current:null}),o=!n&&a.currentDeps&&Il(a.currentDeps,e)?a.current:t();return Ce(()=>{a.currentDeps=e,a.current=o}),o},J0=(t,e)=>{const n=t.get(e);n&&(n.isDirty=!0)},pk=(t,e)=>!t.isDirty&&!Jm(t.fiber)&&(t.committedElement===e||e.deps!==void 0&&t.committedDeps!==void 0&&Il(t.committedDeps,e.deps)),mk=t=>{if(!aw())return!1;for(const{fiber:e}of t.values())if(Jm(e))return!0;return!1};function yl(t){const[e]=Ne(()=>new Map),{version:n,createFiber:i}=sg(),a=Ns()?.isRefreshing??!1,o=mk(e);let u=!1;const d=hk(()=>{const f=new Set,p=[];let m=0;for(let y=0;y<t.length;y++){const v=t[y],b=v.key;if(b===void 0)throw new Error(`useResources did not provide a key for array at index ${y}`);if(f.has(b))throw new Error(`Duplicate key ${b} in useResources`);f.add(b);let T=e.get(b);if(T)if(T.fiber.hook!==v.hook){const w=i(v.hook,v.key,()=>J0(e,b)),x=ll(w,v.args);T.next={value:x,deps:v.deps,element:v,remount:w},u=!0}else if(!a&&pk(T,v))typeof T.next=="object"&&vw(T.fiber),T.fiber.contextDeps&&rw(T.fiber,T.fiber.contextDeps),T.next="skip";else{const w=ll(T.fiber,v.args);T.next={value:w,deps:v.deps,element:v}}else{const w=i(v.hook,v.key,()=>J0(e,b));T={fiber:w,next:{value:ll(w,v.args),deps:v.deps,element:v},isDirty:!1,committedDeps:void 0,committedElement:void 0,committedValue:void 0},m++,e.set(b,T)}p.push(typeof T.next=="object"?T.next.value:T.committedValue)}if(e.size>p.length-m)for(const y of e.keys())f.has(y)||(e.get(y).next="delete",u=!0);return p},[t,e,i,n],a||o);return ng(e),Ce(()=>{if(u){const f=[];for(const[p,m]of e.entries()){const y=m.next;y==="delete"?(f.push(m.fiber),e.delete(p)):y!=="skip"&&y.remount&&(f.push(m.fiber),m.fiber=y.remount)}for(const p of f)p.isReleased=!0;_w(f)}for(const f of e.values()){const p=f.next;p==="skip"?!f.fiber.isNeverMounted&&!f.fiber.isMounted&&kc(f.fiber):p!=="delete"&&(kc(f.fiber),f.committedDeps=p.deps,f.committedElement=p.element,f.committedValue=p.value,f.isDirty=!1,f.next="skip")}},[d,e,u]),a?d.slice():d}const gk=t=>t(),Sw=t=>{const{createFiber:e}=sg(),[n]=Ne(()=>e(gk,void 0)),i=ll(n,[t]);ng(n);let a=!1;const o=()=>{a&&n.isMounted||(a=!0,kc(n))};return Ce(o),{value:i,effects:o}},yk=()=>{const t=Q(4),[e,n]=Ne(bk);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(f,p)=>(n(m=>{const y=wt(m.renderers);return y[f]=[...y[f]??[],p],{...m,renderers:y}}),()=>{n(m=>{const y=wt(m.renderers),v=y[f]?.filter(b=>b!==p)??[];return v.length>0?y[f]=v:delete y[f],{...m,renderers:y}})}),t[0]=i):i=t[0];const a=i;let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o=f=>(n(p=>({...p,fallbacks:[...p.fallbacks,f]})),()=>{n(p=>({...p,fallbacks:p.fallbacks.filter(m=>m!==f)}))}),t[1]=o):o=t[1];const u=o;let d;return t[2]!==e?(d={getState:()=>e,setDataUI:a,setFallbackDataUI:u},t[2]=e,t[3]=d):d=t[3],d},vk=Ye(yk);function bk(){return{renderers:wt(),fallbacks:[]}}const Wn=(t,e,n)=>{const i=a=>{console.error(`[assistant-ui] ${n} listener threw an error`,a)};for(const a of t)try{const o=a(typeof e=="function"?e():e);o!==null&&(typeof o=="object"||typeof o=="function")&&"then"in o&&typeof o.then=="function"&&Promise.resolve(o).catch(i)}catch(o){i(o)}},ns=t=>t,_k=new Set(["$$typeof","nodeType","then","__v_raw","__v_isRef","__v_isReactive","__v_isReadonly","__v_isShallow","__v_skip"]),Ar=(t,e)=>{if(t===Symbol.toStringTag)return e;if(typeof t!="symbol"){if(t==="toJSON")return()=>e;if(!_k.has(t))return!1}};var vl=class{getOwnPropertyDescriptor(t,e){const n=this.get(t,e);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}};const Ir=Symbol("assistant-ui.store.clientId"),Gp=Symbol("assistant-ui.store.instanceTag"),ig=new WeakSet,Tw=(t,e)=>{const n=new Proxy((()=>{}),{apply:()=>(e(),n),get:(i,a)=>a==="source"?t.source:a==="query"?t.query:a==="name"?t.name:a===Ir?Ml(e()):e()[a],has:(i,a)=>a==="source"||a==="query"||a==="name"||a===Ir||a in e(),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(i,a)=>{if(!(typeof a=="symbol"||!(a in e())))return{value:e()[a],writable:!1,enumerable:!0,configurable:!0}}});return ig.add(n),n},ww=(t,e)=>{const n=()=>{throw new Error(t)},i=new Proxy((()=>{}),{apply:n,get:(a,o)=>{if(o==="source"||o==="query")return null;if(o==="name")return e;if(o===Ir)return n();const u=Ar(o,"AssistantClientAccessor");return u!==!1?u:n()},has:(a,o)=>o==="source"||o==="query"||o==="name",ownKeys:()=>[],getOwnPropertyDescriptor:()=>{}});return ig.add(i),i},Sk=t=>{if(ig.has(t))return!1;const e=t[Ir];return e!==void 0&&e!==t},ld=t=>t?.source!=null,Fp=t=>t?.source===null,Ml=t=>t[Ir]??t,Tk=t=>t[Gp]??Ml(t),Tr=t=>t==="optional"||t==="subscribe"||t==="on"||t==="__proto__"||typeof t=="symbol",Yp=t=>{const e=[];for(const n in t)Tr(n)||e.push(n);return e};var wk=class extends vl{#e;constructor(t){super(),this.#e=t}get(t,e){const n=Ar(e,"OptionalAssistantClient");if(n!==!1)return n;if(Tr(e))return;const i=this.#e[e];return ld(i)?i:void 0}ownKeys(){return Yp(this.#e)}has(t,e){return!Tr(e)&&e in this.#e}};const xw=t=>new Proxy({},new wk(t)),Z0=()=>()=>{},xk="You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.";var Ck=class extends vl{#e;#t;#n;#s;constructor(t,e,n){super(),this.#e=t,this.#t=e,this.#n=n}get(t,e){if(e==="subscribe"||e==="on")return Z0;if(e==="optional")return this.#s??=xw(this.#n());const n=Ar(e,this.#e);return n!==!1?n:ww(this.#t(String(e)),String(e))}ownKeys(){return["subscribe","on","optional"]}getOwnPropertyDescriptor(t,e){if(e!=="optional")return super.getOwnPropertyDescriptor(t,e);const n=this.get(t,e);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(t,e){return e==="subscribe"||e==="on"||e==="optional"}};const Ek=(t,e)=>{const n=new Proxy({},new Ck(t,e,()=>n));return n},ja=Ek("DefaultAssistantClient",()=>xk),Ak=()=>new Proxy({},{get(t,e){const n=Ar(e,"AssistantClient");return n!==!1?n:ww(`The current scope does not have a "${String(e)}" property.`,String(e))}}),rg=Qt(ja),Ik=()=>{},Rk=new WeakMap,Mk=t=>Rk.get(t)??Ik,ag=()=>Sn(rg),Cw=(t,e)=>Fa(rg,t,e),Qp=Symbol("assistant-ui.transform-scopes");function Ew(t,e){const n=t;if(n[Qp])throw new Error("transformScopes is already attached to this resource");n[Qp]=e}function kk(t){return t[Qp]}const og=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},Kp=Symbol("assistant-ui.store.clientIndex"),Nk=t=>t[Kp],Aw=Qt([]),lg=()=>Rl(Aw),Ok=(t,e)=>{const n=Q(3),i=lg();let a;return n[0]!==t||n[1]!==i?(a=[...i,t],n[0]=t,n[1]=i,n[2]=a):a=n[2],Fa(Aw,a,e)},ud=Qt(null),W0=Symbol("aui.scope-effect-unapplied"),Dk=(t,e)=>Fa(ud,t,e),ug=()=>{const t=Rl(ud);if(!t)throw new Error("AssistantTapContext is not available");return t},Iw=()=>ug().clientRef,jk=()=>Rl(ud)!==null,zk=()=>{const t=Q(5),e=Rl(ud)?.markChanged;let n;t[0]!==e?(n=e?{readers:new Set,version:0}:void 0,t[0]=e,t[1]=n):n=t[1];const i=n;let a;return t[2]!==e||t[3]!==i?(a={signal:i,markChanged:e},t[2]=e,t[3]=i,t[4]=a):a=t[4],a},Pk=(t,e,n,i)=>{const a=Q(8);let o;a[0]!==t||a[1]!==n||a[2]!==e?(o=()=>{if(t===void 0)return;const d=t.current;if(d===null)throw new Error("useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.");const f=()=>{const b=t.current?.[e];return b!==void 0&&ld(b)?Tk(b):void 0};let p=W0,m;const y=b=>{if(m?.(),m=void 0,p=W0,b!==void 0){const T=n();m=typeof T=="function"?T:void 0}p=b};y(f());const v=d.subscribe(()=>{const b=f();b!==p&&y(b)});return()=>{v(),m?.()}},a[0]=t,a[1]=n,a[2]=e,a[3]=o):o=a[3];let u;a[4]!==t||a[5]!==i||a[6]!==e?(u=[t,e,...i],a[4]=t,a[5]=i,a[6]=e,a[7]=u):u=a[7],Ce(o,u)},Rw=(t,e,n)=>{const{clientRef:i}=ug();Pk(i,t,e,n)},Ya=()=>{const t=Q(3),{emit:e}=ug(),n=lg();let i;return t[0]!==n||t[1]!==e?(i=(a,o)=>{e(a,o,n)},t[0]=n,t[1]=e,t[2]=i):i=t[2],bn(i)},Mw=[];let za=-1,cs=null;const Rr=t=>{cs&&(t?cs.signals.includes(t)||(cs.signals.push(t),cs.versions.push(t.version)):cs.untracked=!0)},Bk=t=>{za++;const e=Mw[za]??={signals:[],versions:[],untracked:!1};e.signals.length=0,e.versions.length=0,e.untracked=!1;const n=cs;cs=e;try{return{value:t(),signals:[...e.signals],untracked:e.untracked}}finally{cs=n,za--,n&&(n.untracked||=e.untracked,e.signals.forEach(Rr))}},kw=(t,e)=>t.length===e.length&&t.every(n=>e.includes(n)),Uk=(t,e)=>{za++;const n=Mw[za]??={signals:[],versions:[],untracked:!1};n.signals.length=0,n.versions.length=0,n.untracked=!1;const i=cs;cs=n;try{const a=t(),o=e.current;if(n.untracked||n.signals.length===0)e.current=null;else if(o&&kw(o.signals,n.signals))for(let u=0;u<o.signals.length;u++)o.versions[u]=o.signals[u].version;else e.current={signals:[...n.signals],versions:[...n.versions]};return a}finally{cs=i,za--,i&&(i.untracked||=n.untracked,n.signals.forEach(Rr))}},Nw=(t,e)=>{const n=we(null),i=we(null),a=jk(),o=yt(()=>d=>{let f,p,m=!1;const y=()=>{const T=n.current,w=T?.signals??null;if(f!==void 0&&(f===null||w===null?f===w:kw(f,w)))return!1;let x=!1;if(f)for(const E of f)w?.includes(E)||E.readers.delete(v);return T===null?p??=t(v):(p?.(),p=void 0,T.signals.forEach((E,C)=>{f?.includes(E)||(x||=E.version!==T.versions[C],E.readers.add(v))})),f=w&&[...w],x};function v(){m||(d(),y())}y();const b=()=>{y()&&d()};return i.current=b,()=>{if(m=!0,p?.(),f)for(const T of f)T.readers.delete(v);i.current===b&&(i.current=null)}},[t]),u=Ui(o,a?e:()=>Uk(e,n),e);return Ce(()=>{i.current?.()}),u},Nc=Symbol("assistant-ui.store.getValue"),Oc=Symbol("assistant-ui.store.signal"),Lk=t=>t[Oc],eS=t=>{const e=t[Nc];if(!e)throw new Error("Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.");return Rr(Lk(t)),e.getState?.()},tS=new Map;function qk(t){let e=tS.get(t);return e||(e=function(...n){if(!this||typeof this!="object")throw new Error(`Method "${String(t)}" called without proper context. This may indicate the function was called incorrectly.`);const i=this[Nc];if(!i)throw new Error(`Method "${String(t)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);const a=i[t];if(!a)throw new Error(`Method "${String(t)}" is not implemented.`);if(typeof a!="function")throw new Error(`"${String(t)}" is not a function.`);return Rr(this[Oc]),a(...n)},tS.set(t,e)),e}var Hk=class extends vl{boundFns;cachedReceiver;outputRef;tagRef;index;signal;self;constructor(t,e,n,i){super(),this.outputRef=t,this.tagRef=e,this.index=n,this.signal=i}get(t,e,n){if(e===Nc)return this.outputRef.current;if(e===Oc)return this.signal;if(e===Kp)return this.index;if(e===Ir)return this.self;if(e===Gp)return this.tagRef.current;const i=Ar(e,"ClientProxy");if(i!==!1)return i;const a=this.outputRef.current[e];if(typeof a=="function"){if(n===void 0)return a;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let o=this.boundFns.get(e);return o||(o=qk(e).bind(n),this.boundFns.set(e,o)),o}return a}ownKeys(){return Object.keys(this.outputRef.current)}has(t,e){return e===Nc||e===Oc||e===Kp||e===Ir||e===Gp?!0:e in this.outputRef.current}};const La=t=>{const e=we(null),n=we(null),i=yt(()=>({}),[t.hook,t.key]),a=lg().length,{signal:o,markChanged:u}=zk(),d=yt(()=>{const p=new Hk(e,n,a,o),m=new Proxy({},p);return p.self=m,m},[a,o]),f=Ok(d,function(){return Dn(t)});return e.current||(e.current=f,n.current=i),Ce(()=>{const p=e.current!==f||n.current!==i;e.current=f,n.current=i,p&&o&&u(o)}),{methods:d,state:f.getState?.(),key:t.key}},Ow=Ye(La);let Dc=0,Xp=0;const Vk=t=>{Dc++,Xp++;try{return t()}finally{Xp--,Dc++}},$k=t=>{let e;const n=new Map;let i=-1;const a=d=>{if(Xp===0)return eS(t[d]());if(i!==Dc)n.clear(),i=Dc;else{const y=n.get(d);if(y)return y.signals.forEach(Rr),y.untracked&&Rr(void 0),y.state}const{value:f,signals:p,untracked:m}=Bk(()=>eS(t[d]()));return n.set(d,{state:f,signals:p,untracked:m}),f};class o extends vl{get(f,p){const m=Ar(p,"OptionalAssistantState");if(m!==!1)return m;const y=p;if(!Tr(y)&&ld(t[y]))return a(y)}ownKeys(){return Yp(t)}has(f,p){return!Tr(p)&&p in t}}class u extends vl{get(f,p){const m=Ar(p,"AssistantState");if(m!==!1)return m;if(p==="optional")return e??=new Proxy({},new o);const y=p;if(!Tr(y))return a(y)}ownKeys(){return[...Yp(t),"optional"]}has(f,p){return p==="optional"||!Tr(p)&&p in t}}return new Proxy({},new u)},nS=new WeakMap,Gk=t=>{let e=nS.get(t);return e||(e=$k(t),nS.set(t,e)),e},Jp=Qt(void 0),Dw=(t,e)=>{const n=Rl(Jp);return Fa(Jp,t??n,e)},qa=(t,e)=>{if(Array.isArray(t)!==Array.isArray(e))return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Object.is(t[i],e[i]))return!1;return!0}const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(i=>Object.hasOwn(e,i)&&Object.is(t[i],e[i]))},jw=Symbol("assistant-ui.derived-hook"),Fk=t=>{t[jw]=!0},Yk=t=>t[jw]===!0,sS=t=>{try{t()}catch(e){console.error("NotificationManager: subscriber callback error",e)}},iS=t=>{console.error("NotificationManager: event listener error",t)},rS=(t,e,n)=>{try{const i=t(e,n);i!==null&&(typeof i=="object"||typeof i=="function")&&typeof i.then=="function"&&Promise.resolve(i).catch(iS)}catch(i){iS(i)}},Qk=()=>{const t=new Map,e=new Set,n=new Set,i=new Set;return{on(a,o){const u=o;if(a==="*")return e.add(u),()=>e.delete(u);let d=t.get(a);return d||(d=new Set,t.set(a,d)),d.add(u),()=>{d.delete(u),d.size===0&&t.get(a)===d&&t.delete(a)}},emit(a,o,u){!t.has(a)&&e.size===0||queueMicrotask(()=>{const d=t.get(a);if(d)for(const f of d)rS(f,o,u);if(e.size>0){const f={event:a,payload:o};for(const p of e)rS(p,f,u)}})},subscribe(a){return n.add(a),()=>n.delete(a)},markChanged(a){a.version++,i.add(a)},notifySubscribers(){Vk(()=>{for(const o of n)sS(o);if(i.size===0)return;const a=new Set;for(const o of i)for(const u of o.readers)a.add(u);i.clear();for(const o of a)sS(o)})}}},Kk=()=>Ne(Qk)[0],Xk=()=>{const[t]=Ne(()=>({controller:new AbortController,generation:0}));return Os(()=>{const e=++t.generation;return()=>queueMicrotask(()=>{t.generation===e&&t.controller.abort()})},[t]),t.controller.signal},jc=t=>{const e=yt(()=>({}),[]);return e.v!==void 0&&qa(e.v,t)?e.v:(e.v=t,t)},fs=t=>{const e=Q(2),n=we(void 0);let i;return e[0]!==t?(i=a=>{const o=t(a);return n.current!==void 0&&qa(n.current,o)?n.current:(n.current=o,o)},e[0]=t,e[1]=i):i=e[1],i},zw=(()=>{try{return!1}catch{return!1}})(),Jk=(t,e)=>{const n={...t},i=new Set;let a=!0;for(;a;){a=!1;for(const o of Object.values(n)){if(i.has(o.hook))continue;i.add(o.hook);const u=kk(o.hook);if(u){u(n,e),a=!0;break}}}return n},cd=t=>Yk(t.hook),Zk=t=>{if(!cd(t))return{source:"root",query:{}};const e=t.args[0];return{source:e.source,query:e.query??{}}},Zp=Symbol.for("aui.event-receiver-ref"),Pw=(t,e)=>{const n=t===ja?Ak():t,i=Object.create(n);Object.assign(i,e);let a;return Object.defineProperty(i,"optional",{get:()=>a??=xw(i),enumerable:!1}),i},Wk=({notifications:t,clientRef:e})=>yt(()=>({subscribe:t.subscribe,on:function(n,i){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:a,event:o}=og(n),u=n[Zp];if(a!=="*"&&!u&&Fp(this[a]))throw new Error(`Scope "${a}" is not available. Use { scope: "*", event: "${o}" } to listen globally.`);const d=t.on(o,(p,m)=>{if(a==="*")return i(p);const y=((u??e).current??this)[a];if(!ld(y))return;const v=Ml(y);if(v===m[Nk(v)])return i(p)});if(a!=="*"){if(u){if(e.parent===ja)return d}else if(Fp(e.parent[a]))return d}const f=e.parent.on(n,i);return()=>{d(),f()}}}),[t,e]),Bw=t=>{const e=Q(5);let n;e[0]!==t?(n=Zk(t),e[0]=t,e[1]=n):n=e[1];const{source:i,query:a}=n,o=jc(a);let u;return e[2]!==i||e[3]!==o?(u={source:i,query:o},e[2]=i,e[3]=o,e[4]=u):u=e[4],jc(u)},Uw=t=>Sk(t)?()=>(Rr(void 0),t):()=>t,e3=(t,e)=>{const n=Q(3);let i;return n[0]!==e||n[1]!==t?(i=e?t:Ow(t),n[0]=e,n[1]=t,n[2]=i):i=n[2],Dn(i)},t3=(t,e)=>{const n=ag(),i=cd(e),a=e3(e,i),o=i?a:a.methods,u=Bw(e),d=yt(()=>Tw({name:t,...u},Uw(o)),[t,u,o]);return n[t]=d,d},n3=Ye(t3),s3=t=>{const e=Q(2);let n;return e[0]!==t?(n=t.map(c3),e[0]=t,e[1]=n):n=e[1],yl(n)},Lw=(t,e)=>{const n=jc(e),i=yt(()=>({}),[]);return i.deps!==n&&(i.deps=n,i.client=t),i.client},i3=({parent:t,entries:e,clientRef:n,notifications:i})=>{const a=Wk({notifications:i,clientRef:n}),o=Pw(t,a),u=yt(()=>({clientRef:n,emit:i.emit,markChanged:i.markChanged}),[n,i.emit,i.markChanged]),d=Dk(u,function(){return Cw(o,function(){return s3(e)})});return{client:Lw(o,[t,...d])}},r3=({parent:t,entries:e,destroySignal:n})=>{const i=we({parent:t,current:null}).current,{value:a,effects:o}=Sw(function(){const d=Kk(),{client:f}=Dw(n,function(){return i3({parent:t,entries:e,clientRef:i,notifications:d})});return Ce(()=>t.subscribe(d.notifySubscribers),[t,d]),Ce(()=>d.notifySubscribers()),f});return Os(()=>{i.parent=t,i.current=a},[a,t,i]),{client:a,effects:o}},a3=(t,e,n,i)=>{const{get:a}=i.args[0],o=Nw(t.subscribe,()=>a(t)),u=Bw(i),d=yt(()=>Tw({name:n,...u},Uw(o)),[n,u,o]);return e[n]=d,d},o3=(t,e)=>{if(zw){const[d]=Ne(()=>e.map(([m])=>m).join(",")),f=e.find(([,m])=>!cd(m));if(f)throw new Error(`Scope "${f[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);const p=e.map(([m])=>m).join(",");if(p!==d)throw new Error(`A derived-only config mounted scopes [${d}] but now has [${p}]; remount with a new key to change the scope set.`)}const n=we({parent:t,current:null}).current,i=function(d,f){if(!this)throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");const{scope:p,event:m}=og(d);if(p==="*")return t.on(d,f);const y=d[Zp];if(!y&&Fp(this[p]))throw new Error(`Scope "${p}" is not available. Use { scope: "*", event: "${m}" } to listen globally.`);return t.on({scope:p,event:m,[Zp]:y??n},f)},a=Pw(t,{subscribe:t.subscribe,on:i}),o=e.map(([d,f])=>a3(t,a,d,f)),u=Lw(a,[t,...o]);return Os(()=>{n.parent=t,n.current=u},[u,t,n]),u},l3=(t,e)=>{const n=Q(8);let i;n[0]!==e||n[1]!==t?(i=Object.entries(Jk(e,t)),n[0]=e,n[1]=t,n[2]=i):i=n[2];const a=i;let o;n[3]!==a?(o=()=>a.length===0||a.some(d3),n[3]=a,n[4]=o):o=n[4];const[u]=Ne(o);let d;return n[5]!==a||n[6]!==u?(d={entries:a,rooted:u},n[5]=a,n[6]=u,n[7]=d):d=n[7],d},u3=(t,e,n,i)=>{const{entries:a,rooted:o}=l3(t,e);return o?n({parent:t,entries:a,destroySignal:i}):{client:o3(t,a)}},qw=(t,e,n)=>u3(t,e,r3,n);function ke(t){return ag()}function c3(t){const[e,n]=t;return Jt(e,n3(e,n))}function d3(t){const[,e]=t;return!cd(e)}const me=t=>{const e=Q(5),n=ke();let i;e[0]!==n?(i=Gk(n),e[0]=n,e[1]=i):i=e[1];const a=i;let o;e[2]!==a||e[3]!==t?(o=()=>t(a),e[2]=a,e[3]=t,e[4]=o):o=e[4];const u=Nw(n.subscribe,o);if(typeof u=="object"&&u!==null&&(u===a||u===a.optional))throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return qM(u),u},Hw=t=>{const e=Q(3),{get:n}=t,i=ke();let a;return e[0]!==i||e[1]!==n?(a=()=>n(i),e[0]=i,e[1]=n,e[2]=a):a=e[2],me(a)};Fk(Hw);const jn=Ye(Hw),Vw=t=>{if(t.key===void 0)throw new Error("useClientLookup: Element has no key");return t.key};function ks(t){const e=Q(12);let n;e[0]!==t?(n=t.map(p3),e[0]=t,e[1]=n):n=e[1];const i=yl(n);let a;e[2]!==t?(a=t.reduce(h3,Object.create(null)),e[2]=t,e[3]=a):a=e[3];const o=a;let u;e[4]!==i?(u=i.map(f3),e[4]=i,e[5]=u):u=e[5];const d=u;let f;e[6]!==o||e[7]!==i?(f=m=>{if("index"in m){if(m.index<0||m.index>=i.length)throw new Error(`useClientLookup: index ${m.index} out of bounds (length: ${i.length}) (ignore if recovered)`);return i[m.index].methods}const y=o[m.key];if(y===void 0)throw new Error(`useClientLookup: key "${m.key}" not found (ignore if recovered)`);return i[y].methods},e[6]=o,e[7]=i,e[8]=f):f=e[8];let p;return e[9]!==d||e[10]!==f?(p={state:d,get:f},e[9]=d,e[10]=f,e[11]=p):p=e[11],p}function f3(t){return t.state}function h3(t,e,n){return t[Vw(e)]=n,t}function p3(t){return Jt(Vw(t),Ow(t),t.deps)}const aS=(t,e=0)=>e===0?Math.abs(t.scrollHeight-t.scrollTop-t.clientHeight)<=1||t.scrollHeight<=t.clientHeight:t.scrollHeight-e-t.scrollTop-t.clientHeight<=1||t.scrollHeight-e<=t.clientHeight,m3=(t,e=0)=>e===0?t.scrollHeight>t.clientHeight+1:t.scrollHeight-e>t.clientHeight+1,g3=(t,e)=>t.scrollTop>e.scrollTop&&t.scrollHeight===e.scrollHeight,oS=t=>t.nodeType===Node.ELEMENT_NODE,y3=(t,e)=>{const n=[],i=typeof ResizeObserver<"u"?new ResizeObserver(()=>e()):null;if(i){i.observe(t);for(const a of t.children)i.observe(a);n.push(()=>i.disconnect())}if(typeof MutationObserver<"u"){const a=new MutationObserver(o=>{if(i){for(const u of o)if(u.target===t){for(const d of u.addedNodes)oS(d)&&i.observe(d);for(const d of u.removedNodes)oS(d)&&i.unobserve(d)}}o.some(u=>u.type!=="attributes"||u.attributeName!=="style")&&e()});a.observe(t,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),n.push(()=>a.disconnect())}return()=>{for(const a of n)a()}},es=Symbol("skip-update"),Pn=(t,...e)=>{const n=[];for(const i of t)try{i(...e)}catch(a){n.push(a)}if(n.length===1)throw n[0];if(n.length>1){for(const i of n)console.error(i);throw new AggregateError(n)}},si=t=>{Pn(t)},cg=(t,e)=>{try{t()}catch(n){console.error("[assistant-ui] Subscription rollback cleanup threw",n)}throw e},$w=(t,e)=>t===void 0||e===void 0?t===e:qa(t,e);var Li=class{_subscribers=new Set;subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}waitForUpdate(){return new Promise(t=>{const e=this.subscribe(()=>{e(),t()})})}_notifySubscribers(){Pn(this._subscribers)}},bl=class extends Li{_state;constructor(t){super(),this._state=t,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>t}getState(){return this._state}getServerSnapshot;setState(t){Object.is(t,this._state)||(this._state=t,this._notifySubscribers())}},dd=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(t,e){if(e){Wn(this._subscriptions,t,e);return}Pn(this._subscriptions,t)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{const t=this._connection;this._connection=void 0,t?.()}}subscribe(t){this._subscriptions.add(t);try{this._updateConnection()}catch(e){throw this._subscriptions.delete(t),e}return()=>{this._subscriptions.delete(t),this._updateConnection()}}},Zn=class extends dd{get path(){return this.binding.path}binding;constructor(t){super(),this.binding=t;const e=t.getState();if(e===es)throw new Error("Entry not available in the store");this._previousState=e}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){const t=this.binding.getState();return t===es||$w(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()},e=this.binding.subscribe(t);try{return this._syncState(),e}catch(n){throw cg(e,n)}}},dg=class extends dd{get path(){return this.binding.path}binding;constructor(t){super(),this.binding=t}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==es&&(this._previousState===void 0||!$w(t,this._previousState))&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState};_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()},e=this.binding.subscribe(t);return this._previousStateDirty=!0,e}},zc=class extends dd{get path(){return this.binding.path}binding;constructor(t){super(),this.binding=t}getState(){return this.binding.getState()}outerSubscribe(t){return this.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let e=this.binding.getState(),n=e?.subscribe(t);const i=()=>{const o=this.binding.getState();if(o===e)return;e=o;const u=n;n=void 0;try{u?.()}finally{n=o?.subscribe(t),t()}};let a;try{a=this.outerSubscribe(i)}catch(o){throw cg(()=>n?.(),o)}return()=>si([()=>a(),()=>n?.()])}},Gw=class extends dd{config;constructor(t){super(),this.config=t}getState(){return this.config.binding.getState()}outerSubscribe(t){return this.config.binding.subscribe(t)}_connect(){const t=`Runtime event "${this.config.event}"`,e=u=>{this.notifySubscribers(u,t)};let n=this.config.binding.getState(),i=n?.unstable_on(this.config.event,e);const a=()=>{const u=this.config.binding.getState();if(u===n)return;n=u;const d=i;i=void 0;try{d?.()}finally{i=u?.unstable_on(this.config.event,e),this.config.notifyOnRebind&&e({})}};let o;try{o=this.outerSubscribe(a)}catch(u){throw cg(()=>i?.(),u)}return()=>si([()=>o(),()=>i?.()])}};const ep=t=>{if(!t.overwrite)return t;const{overwrite:e,...n}=t;return n},v3=t=>{const e=Array.from(t).map(i=>i.getModelContext()).sort((i,a)=>(a.priority??0)-(i.priority??0)),n=wt();return e.reduce((i,a)=>{const o=a.priority??0;if(a.system&&(i.system?i.system+=`
11
-
12
- ${a.system}`:i.system=a.system),a.tools)for(const[u,d]of Object.entries(a.tools)){const f=i.tools!==void 0&&Object.hasOwn(i.tools,u)?i.tools[u]:void 0;if(f&&f!==d){const p=n[u];if(p===o){if(!d.overwrite)throw new Error(`You tried to define a tool with the name ${u}, but it already exists.`);i.tools[u]=ep(d);continue}const m=p>o?f:d,y=p>o?d:f;i.tools[u]=ep({...y,...m}),n[u]=Math.max(p,o);continue}i.tools||(i.tools=wt()),i.tools[u]=ep(d),Object.hasOwn(n,u)||(n[u]=o)}return a.config&&(i.config={...a.config,...i.config}),a.callSettings&&(i.callSettings={...a.callSettings,...i.callSettings}),a.unstable_composerMetadata&&(i.unstable_composerMetadata={...a.unstable_composerMetadata,...i.unstable_composerMetadata}),i},{})};var fg=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return v3(new Set(this._providers.values()))}registerModelContextProvider(t){const e=Symbol();this._providers.set(e,t);let n;try{n=t.subscribe?.(()=>{this.notifySubscribers()})}catch(a){this._providers.delete(e);try{this.notifySubscribers()}catch(o){console.error(o)}throw a}this._providerUnsubscribes.set(e,n),this.notifySubscribers();let i=!1;return()=>{if(i)return;i=!0,this._providers.delete(e);const a=this._providerUnsubscribes.get(e);this._providerUnsubscribes.delete(e);let o=!1,u;const d=f=>{try{f()}catch(p){o?console.error(p):(o=!0,u=p)}};if(a&&d(a),d(()=>this.notifySubscribers()),o)throw u}}_subscribers=new Set;notifySubscribers(){Pn(this._subscribers)}subscribe(t){return this._subscribers.add(t),()=>{this._subscribers.delete(t)}}};const b3=()=>()=>{},Fw=()=>Ui(b3,_3,S3),Ha=(t,e)=>{(Fw()?Ce:mw)(t,e)};function _3(){return!1}function S3(){return typeof document>"u"}const T3=(t,e)=>t.length===e.length&&t.every((n,i)=>Object.is(n,e[i])),w3=(t,e)=>{const[n]=Ne(()=>({pending:void 0}));Ce(()=>{const i=n.pending;n.pending=void 0;let a;return i!==void 0&&T3(i.deps,e)?a=i:(i?.cleanup?.(),a={deps:e,cleanup:t()}),()=>{n.pending=a,queueMicrotask(()=>{n.pending===a&&(n.pending=void 0,a.cleanup?.())})}},e)},Wp=[],x3={modelName:void 0,toolNames:Wp},C3=(t,e)=>t===e||qa(t,e),cc=(t,e)=>{const n=t.getModelContext(),i=n.config?.modelName,a=n.tools?Object.keys(n.tools).sort():Wp,o=a.length?a:Wp;return i===e.modelName&&C3(o,e.toolNames)?e:{modelName:i,toolNames:o}},E3=()=>{const t=Q(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new fg,t[0]=e):e=t[0];const n=e;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>cc(n,x3),t[1]=i):i=t[1];const[a,o]=Ne(i);let u,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>(o(b=>cc(n,b)),n.subscribe(()=>{o(b=>cc(n,b))})),d=[n],t[2]=u,t[3]=d):(u=t[2],d=t[3]),Ce(u,d);let f;t[4]!==a?(f=()=>cc(n,a),t[4]=a,t[5]=f):f=t[5];let p,m,y;t[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>n.getModelContext(),m=b=>n.subscribe(b),y=b=>n.registerModelContextProvider(b),t[6]=p,t[7]=m,t[8]=y):(p=t[6],m=t[7],y=t[8]);let v;return t[9]!==f?(v={getState:f,getModelContext:p,subscribe:m,register:y},t[9]=f,t[10]=v):v=t[10],v},Yw=Ye(E3),A3=(t,e)=>{if(!(e.status?.type==="running"||e.status?.type==="requires-action")){const i=t.complete;return typeof i!="function"?i??null:i({args:e.args,result:e.result})}const n=t.running;return typeof n!="function"?n??null:n({args:e.args})},I3=t=>t.display!==void 0?t.display==="standalone":t.type==="human",R3=t=>function(n){return A3(t,n)},Qw=t=>{const e=Q(16),{toolkit:n,mcpApp:i}=t;let a;e[0]!==i?(a=i?[Jt("mcpApp",i)]:[],e[0]=i,e[1]=a):a=e[1];const o=yl(a)[0],[u,d]=Ne(k3);let f;e[2]!==o||e[3]!==u?(f={toolUIs:u,mcpApp:o},e[2]=o,e[3]=u,e[4]=f):f=e[4];const p=f,m=Iw();let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=(C,R,O)=>{const L={render:R,renderText:O?.renderText,standalone:O?.standalone??!1};return d(I=>{const P=wt(I);return P[C]=[...P[C]??[],L],P}),()=>{d(I=>{const P=I[C]?.filter(H=>H!==L)??[],k=wt(I);return P.length>0?(k[C]=P,k):(delete k[C],k)})}},e[5]=y):y=e[5];const v=y;let b,T;e[6]!==n?(b=()=>{if(!n)return;const C=[];for(const[R,O]of Object.entries(n)){const L="render"in O?O.render:void 0,I="renderText"in O?O.renderText:void 0,P=L??(I?R3(I):void 0);P&&C.push(v(R,P,{standalone:I3(O),renderText:I}))}return()=>si(C)},T=[n,v],e[6]=n,e[7]=b,e[8]=T):(b=e[7],T=e[8]),Ce(b,T);let w;e[9]!==m||e[10]!==n?(w=()=>{if(!n)return;const C=Object.entries(n).reduce(N3,wt());return m.current.modelContext().register({getModelContext:()=>({tools:C})})},e[9]=m,e[10]=n,e[11]=w):w=e[11];let x;e[12]!==n?(x=[n],e[12]=n,e[13]=x):x=e[13],Rw("modelContext",w,x);let E;return e[14]!==p?(E={getState:()=>p,setToolUI:v},e[14]=p,e[15]=E):E=e[15],E},M3=Ye(Qw);Ew(Qw,(t,e)=>{!t.modelContext&&e.modelContext.source===null&&(t.modelContext=Yw())});function k3(){return wt()}function N3(t,e){const[n,i]=e;if(i.type==="mcp")return t;const{display:a,render:o,renderText:u,...d}=i;return t[n]=d,t}const ln=t=>Ui(t.subscribe,t.getState,t.getServerSnapshot),Kw=Symbol.for("assistant-ui.silent-runtime-action"),Xw=t=>typeof t=="object"&&t!==null&&Kw in t,Jw=(t,e)=>{const n=e();return n.catch(i=>{Xw(i)||console.error(`[assistant-ui] ${t} failed:`,i)}),n},O3=t=>{const e=Q(9),{runtime:n}=t,i=ln(n);let a;e[0]!==i?(a=()=>i,e[0]=i,e[1]=a):a=e[1];let o,u;e[2]!==n?(o=()=>Jw("attachment remove",n.remove),u=()=>n,e[2]=n,e[3]=o,e[4]=u):(o=e[3],u=e[4]);let d;return e[5]!==a||e[6]!==o||e[7]!==u?(d={getState:a,remove:o,__internal_getRuntime:u},e[5]=a,e[6]=o,e[7]=u,e[8]=d):d=e[8],d},Zw=Ye(O3),D3=t=>{const e=Q(5),{runtime:n,index:i}=t;let a;e[0]!==i||e[1]!==n?(a=n.getAttachmentByIndex(i),e[0]=i,e[1]=n,e[2]=a):a=e[2];const o=a;let u;return e[3]!==o?(u=Zw({runtime:o}),e[3]=o,e[4]=u):u=e[4],Dn(u)},j3=Ye(D3),z3=({item:t,onMove:e,onRemove:n})=>({getState:()=>t,steer:()=>e({lane:"steer",insertAfter:null}),move:e,remove:n}),P3=Ye(z3),B3=t=>{const e=Q(65),{threadIdRef:n,messageIdRef:i,runtime:a,isSuggestion:o}=t,u=ln(a),d=Ya(),f=we(!1);let p,m;e[0]!==d||e[1]!==i||e[2]!==a||e[3]!==n?(p=()=>{const z=[],q=a.unstable_on("send",X=>{const Z=f.current;f.current=!1,d("composer.send",{threadId:n.current,...i&&{messageId:i.current},chars:X.chars,attachments:X.attachments,...Z?{suggestion:!0}:void 0})});z.push(q);const W=a.unstable_on("attachmentAdd",X=>{d("composer.attachmentAdd",{threadId:n.current,...i&&{messageId:i.current},...X.contentType?{contentType:X.contentType}:void 0})});return z.push(W),z.push(a.unstable_on("attachmentAddError",X=>{d("composer.attachmentAddError",{threadId:n.current,...i&&{messageId:i.current},...X.attachmentId&&{attachmentId:X.attachmentId},reason:X.reason,message:X.message,...X.contentType?{contentType:X.contentType}:void 0})})),()=>si(z)},m=[a,d,n,i],e[0]=d,e[1]=i,e[2]=a,e[3]=n,e[4]=p,e[5]=m):(p=e[4],m=e[5]),Ce(p,m);let y;if(e[6]!==a||e[7]!==u.attachments){let z;e[9]!==a?(z=(q,W)=>Jt(q.id,j3({runtime:a,index:W}),[a,W]),e[9]=a,e[10]=z):z=e[10],y=u.attachments.map(z),e[6]=a,e[7]=u.attachments,e[8]=y}else y=e[8];const v=ks(y),b=u.queue;let T;if(e[11]!==b||e[12]!==a){let z;e[14]!==a?(z=q=>Jt(q.id,P3({item:q,onMove:W=>a.moveQueueItem(q.id,W),onRemove:()=>a.removeQueueItem(q.id)})),e[14]=a,e[15]=z):z=e[15],T=b.map(z),e[11]=b,e[12]=a,e[13]=T}else T=e[13];const w=ks(T),x=u.type??"thread";let E;e[16]!==v.state||e[17]!==b||e[18]!==u.attachmentAccept||e[19]!==u.canCancel||e[20]!==u.canSend||e[21]!==u.dictation||e[22]!==u.inTransit||e[23]!==u.isEditing||e[24]!==u.isEmpty||e[25]!==u.quote||e[26]!==u.role||e[27]!==u.runConfig||e[28]!==u.submission||e[29]!==u.text||e[30]!==x?(E={text:u.text,role:u.role,attachments:v.state,runConfig:u.runConfig,isEditing:u.isEditing,canCancel:u.canCancel,canSend:u.canSend,attachmentAccept:u.attachmentAccept,isEmpty:u.isEmpty,type:x,dictation:u.dictation,quote:u.quote,queue:b,submission:u.submission,inTransit:u.inTransit},e[16]=v.state,e[17]=b,e[18]=u.attachmentAccept,e[19]=u.canCancel,e[20]=u.canSend,e[21]=u.dictation,e[22]=u.inTransit,e[23]=u.isEditing,e[24]=u.isEmpty,e[25]=u.quote,e[26]=u.role,e[27]=u.runConfig,e[28]=u.submission,e[29]=u.text,e[30]=x,e[31]=E):E=e[31];const C=E;let R;e[32]!==C?(R=()=>C,e[32]=C,e[33]=R):R=e[33];let O;e[34]!==o||e[35]!==a?(O=z=>{const q=a.getState();f.current=q.canSend&&(o?.(q.text)??!1),a.send(z)},e[34]=o,e[35]=a,e[36]=O):O=e[36];let L;e[37]!==d||e[38]!==i||e[39]!==a||e[40]!==n?(L=()=>{!i&&a.getState().canCancel&&d("composer.cancel",{threadId:n.current}),a.cancel()},e[37]=d,e[38]=i,e[39]=a,e[40]=n,e[41]=L):L=e[41];const I=a.beginEdit??U3;let P;e[42]!==v?(P=z=>"id"in z?v.get({key:z.id}):v.get(z),e[42]=v,e[43]=P):P=e[43];let k;e[44]!==w?(k=z=>"id"in z?w.get({key:z.id}):w.get(z),e[44]=w,e[45]=k):k=e[45];let H;e[46]!==a?(H=()=>a,e[46]=a,e[47]=H):H=e[47];let V;return e[48]!==a.addAttachment||e[49]!==a.clearAttachments||e[50]!==a.reset||e[51]!==a.setQuote||e[52]!==a.setRole||e[53]!==a.setRunConfig||e[54]!==a.setText||e[55]!==a.startDictation||e[56]!==a.stopDictation||e[57]!==I||e[58]!==P||e[59]!==k||e[60]!==H||e[61]!==R||e[62]!==O||e[63]!==L?(V={getState:R,setText:a.setText,setRole:a.setRole,setRunConfig:a.setRunConfig,addAttachment:a.addAttachment,reset:a.reset,clearAttachments:a.clearAttachments,send:O,cancel:L,beginEdit:I,startDictation:a.startDictation,stopDictation:a.stopDictation,setQuote:a.setQuote,attachment:P,queueItem:k,__internal_getRuntime:H},e[48]=a.addAttachment,e[49]=a.clearAttachments,e[50]=a.reset,e[51]=a.setQuote,e[52]=a.setRole,e[53]=a.setRunConfig,e[54]=a.setText,e[55]=a.startDictation,e[56]=a.stopDictation,e[57]=I,e[58]=P,e[59]=k,e[60]=H,e[61]=R,e[62]=O,e[63]=L,e[64]=V):V=e[64],V},Ww=Ye(B3);function U3(){throw new Error("beginEdit is not supported in this runtime")}const ex=t=>({get current(){return t()}}),lS=new WeakMap,Or=t=>{const e=lS.get(t);if(e)return e;const n=new Map,i=t.map(o=>{const u=o.type==="tool-call"?o.toolCallId:"id"in o?o.id:void 0;if(!u)return;const d=`${o.type}:${u}`;return n.set(d,(n.get(d)??0)+1),d}),a=t.map((o,u)=>{const d=i[u];return d&&n.get(d)===1?d:`${o.type}@${u}`});return lS.set(t,a),a},L3=t=>{const e=Q(17),{runtime:n}=t,i=ln(n);let a;e[0]!==i?(a=()=>i,e[0]=i,e[1]=a):a=e[1];let o,u,d;e[2]!==n?(o=y=>n.addToolResult(y),u=y=>n.resumeToolCall(y),d=y=>n.respondToToolApproval(y),e[2]=n,e[3]=o,e[4]=u,e[5]=d):(o=e[3],u=e[4],d=e[5]);let f;e[6]!==n.unstable_recordInteraction?(f=n.unstable_recordInteraction&&{unstable_recordInteraction:y=>n.unstable_recordInteraction(y)},e[6]=n.unstable_recordInteraction,e[7]=f):f=e[7];let p;e[8]!==n?(p=()=>n,e[8]=n,e[9]=p):p=e[9];let m;return e[10]!==a||e[11]!==o||e[12]!==u||e[13]!==d||e[14]!==f||e[15]!==p?(m={getState:a,addToolResult:o,resumeToolCall:u,respondToToolApproval:d,...f,__internal_getRuntime:p},e[10]=a,e[11]=o,e[12]=u,e[13]=d,e[14]=f,e[15]=p,e[16]=m):m=e[16],m},q3=Ye(L3),H3=t=>{const e=Q(5),{runtime:n,index:i}=t;let a;e[0]!==i||e[1]!==n?(a=n.getAttachmentByIndex(i),e[0]=i,e[1]=n,e[2]=a):a=e[2];const o=a;let u;return e[3]!==o?(u=Zw({runtime:o}),e[3]=o,e[4]=u):u=e[4],Dn(u)},V3=Ye(H3),$3=t=>{const e=Q(5),{runtime:n,index:i}=t;let a;e[0]!==i||e[1]!==n?(a=n.getMessagePartByIndex(i),e[0]=i,e[1]=n,e[2]=a):a=e[2];const o=a;let u;return e[3]!==o?(u=q3({runtime:o}),e[3]=o,e[4]=u):u=e[4],Dn(u)},G3=Ye($3),F3=t=>{const e=Q(78),{runtime:n,threadIdRef:i,threadId:a,isLast:o}=t,u=ln(n),d=Ya(),[f,p]=Ne(!1),[m,y]=Ne(!1);let v;e[0]!==n?(v=ex(()=>n.getState().id),e[0]=n,e[1]=v):v=e[1];const b=v,T=we(u.status);let w;e[2]!==d||e[3]!==n||e[4]!==a?(w=de=>{d(de,{threadId:a,messageId:n.getState().id})},e[2]=d,e[3]=n,e[4]=a,e[5]=w):w=e[5];const x=w;let E,C;e[6]!==d||e[7]!==u.id||e[8]!==u.status||e[9]!==a?(E=()=>{const de=u.status,B=T.current;T.current=de,de?.type==="incomplete"&&de.reason==="error"&&(B?.type!=="incomplete"||B.reason!=="error")&&d("message.error",{threadId:a,messageId:u.id,reason:"error"})},C=[u.status,u.id,d,a],e[6]=d,e[7]=u.id,e[8]=u.status,e[9]=a,e[10]=E,e[11]=C):(E=e[10],C=e[11]),Ce(E,C);let R;e[12]!==b||e[13]!==n.composer||e[14]!==i?(R=Ww({runtime:n.composer,threadIdRef:i,messageIdRef:b}),e[12]=b,e[13]=n.composer,e[14]=i,e[15]=R):R=e[15];const O=La(R);let L;if(e[16]!==n||e[17]!==u.content){let de;e[19]!==n?(de=(B,ce)=>Jt(B,G3({runtime:n,index:ce}),[n,ce]),e[19]=n,e[20]=de):de=e[20],L=Or(u.content).map(de),e[16]=n,e[17]=u.content,e[18]=L}else L=e[18];const I=ks(L);let P;e[21]!==u.attachments?(P=u.attachments??[],e[21]=u.attachments,e[22]=P):P=e[22];let k;if(e[23]!==n||e[24]!==P){let de;e[26]!==n?(de=(B,ce)=>Jt(B.id,V3({runtime:n,index:ce}),[n,ce]),e[26]=n,e[27]=de):de=e[27],k=P.map(de),e[23]=n,e[24]=P,e[25]=k}else k=e[25];const H=ks(k),V=u;let z;e[28]!==o?(z=o===!1?{isLast:o}:{},e[28]=o,e[29]=z):z=e[29];let q;e[30]!==O.state||e[31]!==f||e[32]!==m||e[33]!==I.state||e[34]!==z||e[35]!==V?(q={...V,...z,parts:I.state,composer:O.state,isCopied:f,isHovering:m},e[30]=O.state,e[31]=f,e[32]=m,e[33]=I.state,e[34]=z,e[35]=V,e[36]=q):q=e[36];const W=q;let X;e[37]!==W?(X=()=>W,e[37]=W,e[38]=X):X=e[38];let Z;e[39]!==O.methods?(Z=()=>O.methods,e[39]=O.methods,e[40]=Z):Z=e[40];let ee;e[41]!==n?(ee=()=>n.delete(),e[41]=n,e[42]=ee):ee=e[42];let oe,he;e[43]!==x||e[44]!==n?(oe=de=>(x("message.reload"),n.reload(de)),he=()=>(x("message.speak"),n.speak()),e[43]=x,e[44]=n,e[45]=oe,e[46]=he):(oe=e[45],he=e[46]);let ye,D;e[47]!==n?(ye=()=>n.stopSpeaking(),D=de=>n.submitFeedback(de),e[47]=n,e[48]=ye,e[49]=D):(ye=e[48],D=e[49]);let $;e[50]!==x||e[51]!==n?($=de=>(x("message.branchSwitched"),n.switchToBranch(de)),e[50]=x,e[51]=n,e[52]=$):$=e[52];let re;e[53]!==n?(re=()=>n.unstable_getCopyText(),e[53]=n,e[54]=re):re=e[54];let M;e[55]!==I||e[56]!==u.content?(M=de=>{if("index"in de)return I.get({index:de.index});{const B=u.content.findIndex(ce=>ce.type==="tool-call"&&ce.toolCallId===de.toolCallId);return I.get({index:B})}},e[55]=I,e[56]=u.content,e[57]=M):M=e[57];let N;e[58]!==H?(N=de=>"id"in de?H.get({key:de.id}):H.get(de),e[58]=H,e[59]=N):N=e[59];let te;e[60]!==x?(te=de=>{de&&x("message.copied"),p(de)},e[60]=x,e[61]=te):te=e[61];let ie;e[62]!==n?(ie=()=>n,e[62]=n,e[63]=ie):ie=e[63];let pe;return e[64]!==X||e[65]!==Z||e[66]!==ee||e[67]!==oe||e[68]!==he||e[69]!==ye||e[70]!==D||e[71]!==$||e[72]!==re||e[73]!==M||e[74]!==N||e[75]!==te||e[76]!==ie?(pe={getState:X,composer:Z,delete:ee,reload:oe,speak:he,stopSpeaking:ye,submitFeedback:D,switchToBranch:$,getCopyText:re,part:M,attachment:N,setIsCopied:te,setIsHovering:y,__internal_getRuntime:ie},e[64]=X,e[65]=Z,e[66]=ee,e[67]=oe,e[68]=he,e[69]=ye,e[70]=D,e[71]=$,e[72]=re,e[73]=M,e[74]=N,e[75]=te,e[76]=ie,e[77]=pe):pe=e[77],pe},Y3=Ye(F3),Qa=t=>t.content.filter(e=>e.type==="text").map(e=>e.text).join(`
13
-
14
- `),ds=Object.freeze({type:"complete"}),hg=Object.freeze({type:"running"}),Q3=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"})}),tx=t=>{const e=t.status;if(!e||typeof e!="object")return;const{type:n}=e;if(n==="running")return hg;if(n==="complete")return ds;if(n!=="incomplete")return;const{reason:i}=e;return Q3[i==="cancelled"||i==="length"||i==="content-filter"||i==="other"||i==="error"?i:"other"]},nx=t=>t.interrupt!=null||t.approval!=null&&t.approval.approved===void 0&&t.approval.resolution===void 0,sx=(t,e,n)=>{if(t.role!=="assistant")return ds;if(n.type==="tool-call")return n.result===void 0||n.isPreliminary||nx(n)?t.status:ds;if(t.status.type==="running"){const a=tx(n);if(a)return a}const i=e===Math.max(0,t.content.length-1);return t.status.type==="requires-action"?ds:i?t.status:ds},K3=t=>{const e=Q(7),{type:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={},e[1]=a):a=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2];let u;e[3]!==n?(u={isEditing:!1,isEmpty:!0,text:"",attachmentAccept:"*",attachments:i,role:"user",runConfig:a,canCancel:!1,canSend:!1,type:n,dictation:void 0,quote:void 0,queue:o,submission:void 0,inTransit:void 0},e[3]=n,e[4]=u):u=e[4];const d=u;let f;return e[5]!==d?(f={getState:()=>d,setText:J3,setRole:Z3,setRunConfig:W3,addAttachment:eN,clearAttachments:tN,attachment:nN,reset:sN,send:iN,cancel:rN,startDictation:aN,stopDictation:oN,beginEdit:lN,setQuote:uN,queueItem:cN},e[5]=d,e[6]=f):f=e[6],f},X3=Ye(K3);function J3(){throw new Error("Not supported")}function Z3(){throw new Error("Not supported")}function W3(){throw new Error("Not supported")}function eN(){throw new Error("Not supported")}function tN(){throw new Error("Not supported")}function nN(){throw new Error("Not supported")}function sN(){throw new Error("Not supported")}function iN(){throw new Error("Not supported")}function rN(){throw new Error("Not supported")}function aN(){throw new Error("Not supported")}function oN(){throw new Error("Not supported")}function lN(){throw new Error("Not supported")}function uN(){throw new Error("Not supported")}function cN(){throw new Error("Not supported")}const dN=t=>{const e=Q(8),{part:n,isMessageRunning:i}=t;let a;e[0]!==i||e[1]!==n?(a=i?tx(n)??ds:ds,e[0]=i,e[1]=n,e[2]=a):a=e[2];let o;e[3]!==n||e[4]!==a?(o={...n,status:a},e[3]=n,e[4]=a,e[5]=o):o=e[5];const u=o;let d;return e[6]!==u?(d={getState:()=>u,addToolResult:yN,resumeToolCall:vN,respondToToolApproval:bN,unstable_recordInteraction:_N},e[6]=u,e[7]=d):d=e[7],d},fN=Ye(dN),hN=({attachment:t})=>({getState:()=>t,remove:()=>{throw new Error("Not supported")}}),pN=Ye(hN),mN=t=>{const e=Q(38),{message:n,index:i,isLast:a,branchNumber:o,branchCount:u,submission:d}=t,f=a===void 0?!0:a,p=o===void 0?1:o,m=u===void 0?1:u,[y,v]=Ne(!1),[b,T]=Ne(!1),w=n.role==="assistant"&&n.status.type==="running";let x,E;if(e[0]!==w||e[1]!==n.content){const oe=Or(n.content);x=ks,E=n.content.map((he,ye)=>Jt(oe[ye],fN({part:he,isMessageRunning:w}),[he,w])),e[0]=w,e[1]=n.content,e[2]=x,e[3]=E}else x=e[2],E=e[3];const C=x(E);let R;e[4]!==n.attachments||e[5]!==d?.attachments?(R=d?.attachments??n.attachments??[],e[4]=n.attachments,e[5]=d?.attachments,e[6]=R):R=e[6];let O;e[7]!==R?(O=R.map(SN),e[7]=R,e[8]=O):O=e[8];const L=ks(O);let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=X3({type:"edit"}),e[9]=I):I=e[9];const P=La(I),k=P.state;let H;e[10]!==m||e[11]!==p||e[12]!==k||e[13]!==i||e[14]!==y||e[15]!==b||e[16]!==f||e[17]!==n||e[18]!==C.state||e[19]!==d?(H={...n,parts:C.state,composer:k,parentId:null,index:i,isLast:f,branchNumber:p,branchCount:m,speech:void 0,isCopied:y,isHovering:b,submission:d},e[10]=m,e[11]=p,e[12]=k,e[13]=i,e[14]=y,e[15]=b,e[16]=f,e[17]=n,e[18]=C.state,e[19]=d,e[20]=H):H=e[20];const V=H;let z;e[21]!==V?(z=()=>V,e[21]=V,e[22]=z):z=e[22];let q;e[23]!==P.methods?(q=()=>P.methods,e[23]=P.methods,e[24]=q):q=e[24];let W;e[25]!==n.content||e[26]!==C?(W=oe=>"index"in oe?C.get({index:oe.index}):C.get({index:n.content.findIndex(he=>he.type==="tool-call"&&he.toolCallId===oe.toolCallId)}),e[25]=n.content,e[26]=C,e[27]=W):W=e[27];let X;e[28]!==L?(X=oe=>"id"in oe?L.get({key:oe.id}):L.get(oe),e[28]=L,e[29]=X):X=e[29];let Z;e[30]!==n?(Z=()=>Qa(n),e[30]=n,e[31]=Z):Z=e[31];let ee;return e[32]!==z||e[33]!==q||e[34]!==W||e[35]!==X||e[36]!==Z?(ee={getState:z,composer:q,part:W,attachment:X,delete:TN,reload:wN,speak:xN,stopSpeaking:CN,submitFeedback:EN,switchToBranch:AN,getCopyText:Z,setIsCopied:v,setIsHovering:T},e[32]=z,e[33]=q,e[34]=W,e[35]=X,e[36]=Z,e[37]=ee):ee=e[37],ee},gN=Ye(mN);function yN(){throw new Error("Not supported")}function vN(){throw new Error("Not supported")}function bN(){throw new Error("Not supported")}async function _N(){}function SN(t){return Jt(t.id,pN({attachment:t}),[t])}function TN(){throw new Error("Not supported in ThreadMessageProvider")}function wN(){throw new Error("Not supported in ThreadMessageProvider")}function xN(){throw new Error("Not supported in ThreadMessageProvider")}function CN(){throw new Error("Not supported in ThreadMessageProvider")}function EN(){throw new Error("Not supported in ThreadMessageProvider")}function AN(){throw new Error("Not supported in ThreadMessageProvider")}let ix=(t,e=21)=>(n=e)=>{let i="",a=n|0;for(;a-- >0;)i+=t[Math.random()*t.length|0];return i};const un=ix("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),IN="text/plain",rx="application/octet-stream";function RN(t,e=rx){const n=t.match(/^data:([^;,]*)(?:;[^;,]+)*;base64,(.*)$/i);return n?{mimeType:n[1]?n[1].toLowerCase():e,data:n[2]}:null}function MN(t){if(t.slice(0,5).toLowerCase()!=="data:")return;const e=t.indexOf(",",5);if(e===-1)return;const n=t.slice(5,e),i=n.indexOf(";"),a=i===-1?n:n.slice(0,i);return a?a.toLowerCase():n.toLowerCase().endsWith(";base64")?rx:IN}const Va={entries:32,payloadLength:16384,logLength:65536},kN=64,NN=t=>{const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},Pc=(t,e,n)=>{if(t===null)return!0;switch(typeof t){case"string":case"boolean":return!0;case"number":return Number.isFinite(t);case"object":break;default:return!1}if(n>kN||e.has(t))return!1;e.add(t);const i=Array.isArray(t)?t.every(a=>Pc(a,e,n+1)):NN(t)&&Object.values(t).every(a=>Pc(a,e,n+1));return e.delete(t),i},Bc=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ax=t=>t==="action"||t==="human-response";function ON(t,e=Date.now()){const{type:n,payload:i}=t;if(!ax(n))throw new Error(`Unknown tool interaction type: ${String(n)}`);if(!Pc(i,new Set,0))throw new Error("A tool interaction payload must be plain JSON.");if(n==="action"&&!Bc(i))throw new Error("An action interaction payload must be a JSON object.");const a=JSON.stringify(i);if(a.length>Va.payloadLength)throw new Error(`A tool interaction payload is limited to ${Va.payloadLength} characters of JSON.`);return{type:n,occurredAt:e,payload:JSON.parse(a)}}function ox(t,e){const n=[...t?.entries??[],e];let i=t?.omitted??0;for(;n.length>1&&(n.length>Va.entries||JSON.stringify(n).length>Va.logLength);)n.shift(),i+=1;return i>0?{entries:n,omitted:i}:{entries:n}}const DN=t=>{if(!Bc(t))return;const{type:e,occurredAt:n,payload:i}=t;if(ax(e)&&!(typeof n!="number"||!Number.isFinite(n))&&Pc(i,new Set,0))return e==="action"?Bc(i)?{type:e,occurredAt:n,payload:i}:void 0:{type:e,occurredAt:n,payload:i}};function pg(t){if(!Bc(t))return;const{entries:e,omitted:n}=t,i=Array.isArray(e)?e.flatMap(o=>{const u=DN(o);return u?[u]:[]}):[];let a=typeof n=="number"&&Number.isInteger(n)&&n>0?n:0;for(;i.length>1&&(i.length>Va.entries||JSON.stringify(i).length>Va.logLength);)i.shift(),a+=1;if(!(i.length===0&&a===0))return a>0?{entries:i,omitted:a}:{entries:i}}function jN(){const t=this.getReader();let e=!1,n=Promise.resolve();const i=d=>{const f=n.then(d);return n=f.then(()=>{},()=>{}),f},a=async d=>{if(!e){e=!0;try{return t.cancel(d)}finally{t.releaseLock()}}},o={next:()=>i(async()=>{if(e)return{done:!0,value:void 0};try{const d=await t.read();return d.done&&(e=!0,t.releaseLock()),d}catch(d){throw e=!0,t.releaseLock(),d}}),return:d=>i(async()=>(await a(d),{done:!0,value:d})),throw:d=>i(async()=>{throw await a(void 0),d}),[Symbol.asyncIterator](){return this}},u=Symbol.asyncDispose;return u&&Object.defineProperty(o,u,{value:async()=>{await o.return()},writable:!0,configurable:!0}),o}function zN(t){return t[Symbol.asyncIterator]??=jN,t}const PN=/[0-9a-fA-F]/;function BN(t){const e=["ROOT"];let n=-1,i=null,a=0;const o=[];let u;function d(){u!==void 0&&(o.push(JSON.parse(`"${u}"`)),u=void 0)}function f(v,b,T){switch(v){case'"':n=b,e.pop(),e.push(T),e.push("INSIDE_STRING"),d();break;case"f":case"t":case"n":n=b,i=b,e.pop(),e.push(T),e.push("INSIDE_LITERAL");break;case"-":e.pop(),e.push(T),e.push("INSIDE_NUMBER"),d();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=b,e.pop(),e.push(T),e.push("INSIDE_NUMBER"),d();break;case"{":n=b,e.pop(),e.push(T),e.push("INSIDE_OBJECT_START"),d();break;case"[":n=b,e.pop(),e.push(T),e.push("INSIDE_ARRAY_START"),d()}}function p(v,b){switch(v){case",":e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":n=b,e.pop(),u=o.pop()}}function m(v,b){switch(v){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),u=(Number(u)+1).toString();break;case"]":n=b,e.pop(),u=o.pop()}}for(let v=0;v<t.length;v++){const b=t[v];switch(e[e.length-1]){case"ROOT":f(b,v,"FINISH");break;case"INSIDE_OBJECT_START":switch(b){case'"':e.pop(),e.push("INSIDE_OBJECT_KEY"),u="";break;case"}":n=v,e.pop(),u=o.pop()}break;case"INSIDE_OBJECT_AFTER_COMMA":b==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"),u="");break;case"INSIDE_OBJECT_KEY":switch(b){case'"':e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break;case"\\":e.push("INSIDE_STRING_ESCAPE"),u+=b;break;default:u+=b}break;case"INSIDE_OBJECT_AFTER_KEY":b===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break;case"INSIDE_OBJECT_BEFORE_VALUE":f(b,v,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":p(b,v);break;case"INSIDE_STRING":switch(b){case'"':e.pop(),n=v,u=o.pop();break;case"\\":e.push("INSIDE_STRING_ESCAPE");break;default:n=v}break;case"INSIDE_ARRAY_START":b==="]"?(n=v,e.pop(),u=o.pop()):(u="0",f(b,v,"INSIDE_ARRAY_AFTER_VALUE"));break;case"INSIDE_ARRAY_AFTER_VALUE":switch(b){case",":e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA"),u=(Number(u)+1).toString();break;case"]":n=v,e.pop(),u=o.pop();break;default:n=v}break;case"INSIDE_ARRAY_AFTER_COMMA":f(b,v,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":{e.pop();const T=e[e.length-1];b==="u"?(e.push("INSIDE_STRING_UNICODE_ESCAPE"),a=0):T==="INSIDE_STRING"&&(n=v),T==="INSIDE_OBJECT_KEY"&&(u+=b);break}case"INSIDE_STRING_UNICODE_ESCAPE":{const T=e[e.length-2];if(!PN.test(b)){e.pop(),v--;break}a++,a===4&&(e.pop(),T==="INSIDE_STRING"&&(n=v)),T==="INSIDE_OBJECT_KEY"&&(u+=b);break}case"INSIDE_NUMBER":switch(b){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n=v;break;case"e":case"E":case"-":case"+":case".":break;case",":e.pop(),u=o.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&m(b,v),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&p(b,v);break;case"}":e.pop(),u=o.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&p(b,v);break;case"]":e.pop(),u=o.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&m(b,v);break;default:e.pop(),u=o.pop()}break;case"INSIDE_LITERAL":{const T=t.substring(i,v+1);!"false".startsWith(T)&&!"true".startsWith(T)&&!"null".startsWith(T)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?p(b,v):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&m(b,v)):n=v;break}}}let y=t.slice(0,n+1);for(let v=e.length-1;v>=0;v--)switch(e[v]){case"INSIDE_STRING":y+='"';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":y+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":y+="]";break;case"INSIDE_LITERAL":{const b=t.substring(i,t.length);"true".startsWith(b)?y+="true".slice(b.length):"false".startsWith(b)?y+="false".slice(b.length):"null".startsWith(b)&&(y+="null".slice(b.length))}}return[y,o]}var gr={exports:{}},uS;function UN(){if(uS)return gr.exports;uS=1;const t=typeof Buffer<"u",e=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,n=/"(?: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 i(d,f,p){p==null&&f!==null&&typeof f=="object"&&(p=f,f=void 0),t&&Buffer.isBuffer(d)&&(d=d.toString()),d&&d.charCodeAt(0)===65279&&(d=d.slice(1));const m=JSON.parse(d,f);if(m===null||typeof m!="object")return m;const y=p&&p.protoAction||"error",v=p&&p.constructorAction||"error";if(y==="ignore"&&v==="ignore")return m;if(y!=="ignore"&&v!=="ignore"){if(e.test(d)===!1&&n.test(d)===!1)return m}else if(y!=="ignore"&&v==="ignore"){if(e.test(d)===!1)return m}else if(n.test(d)===!1)return m;return a(m,{protoAction:y,constructorAction:v,safe:p&&p.safe})}function a(d,{protoAction:f="error",constructorAction:p="error",safe:m}={}){let y=[d];for(;y.length;){const v=y;y=[];for(const b of v){if(f!=="ignore"&&Object.prototype.hasOwnProperty.call(b,"__proto__")){if(m===!0)return null;if(f==="error")throw new SyntaxError("Object contains forbidden prototype property");delete b.__proto__}if(p!=="ignore"&&Object.prototype.hasOwnProperty.call(b,"constructor")&&b.constructor!==null&&typeof b.constructor=="object"&&Object.prototype.hasOwnProperty.call(b.constructor,"prototype")){if(m===!0)return null;if(p==="error")throw new SyntaxError("Object contains forbidden prototype property");delete b.constructor}for(const T in b){const w=b[T];w&&typeof w=="object"&&y.push(w)}}}return d}function o(d,f,p){const{stackTraceLimit:m}=Error;Error.stackTraceLimit=0;try{return i(d,f,p)}finally{Error.stackTraceLimit=m}}function u(d,f){const{stackTraceLimit:p}=Error;Error.stackTraceLimit=0;let m;try{m=i(d,f,{safe:!0})}catch{m=void 0}finally{Error.stackTraceLimit=p}return m}return gr.exports=o,gr.exports.default=o,gr.exports.parse=o,gr.exports.safeParse=u,gr.exports.scan=a,gr.exports}var LN=UN();const cS=xl(LN),xc=Symbol("aui.parse-partial-json-object.meta"),lx=t=>t?.[xc],ul=t=>{if(t.length===0)return{[xc]:{state:"partial",partialPath:[]}};try{const e=cS.parse(t);if(typeof e!="object"||e===null)throw new Error("argsText is expected to be an object");return e[xc]={state:"complete",partialPath:[]},e}catch{try{const[e,n]=BN(t),i=cS.parse(e);if(typeof i!="object"||i===null)throw new Error("argsText is expected to be an object");return i[xc]={state:"partial",partialPath:n},i}catch{return}}},dc=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/,qN=/^-?$|^-?(?:0|[1-9]\d*)(?:\.\d*)?$|^-?(?:0|[1-9]\d*)(?:\.\d+)?[eE][+-]?\d*$/,fc=/^[\t\n\r ]$/,HN=/^[0-9a-fA-F]$/,VN={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
15
- `,r:"\r",t:" "},em=t=>typeof t=="object"&&t!==null,Uc=(t,e,n)=>{t[e]=n},ux=t=>{if(Array.isArray(t))return[...t];const e={};for(const n of Object.keys(t))e[n]=t[n];return e},$N=(t,e,n,i)=>{const a=(o,u)=>{const d=i.has(o)?o:ux(o);i.add(d);const f=e[u];if(u===e.length-1)return Uc(d,f,n),em(n)&&i.add(n),d;const p=d[f];if(!em(p))throw new Error("Invalid incremental JSON path");return Uc(d,f,a(p,u+1)),d};return a(t,0)},GN=(t,e,n)=>{const i=ul("");for(const o of Object.keys(t))Uc(i,o,t[o]);const a=lx(i);return a.state=e,a.partialPath=n.map(String),i},FN=t=>{const e=[t];for(;e.length>0;){const n=e.pop();for(const i of Object.keys(n)){const a=n[i];if(!em(a))continue;const o=ux(a);Uc(n,i,o),e.push(o)}}return t};var dS=class il{text;mode="start";root={};frames=[];token;args;publishedArgs;ownedContainers;constructor(e){this.args=e,this.publishedArgs=e}static from(e="",n=ul("")){const i=new il(n);e.length!==0&&(i.text={length:e.length,previous:void 0,value:e});const a=e.trimEnd().endsWith("}")?ul(e):void 0;return a&&lx(a)?.state==="complete"?(i.args=a,i.publishedArgs=a,i.mode="complete",i):(i.consumeDelta(e,!0),i.args=i.snapshot(n),i.args!==n&&(i.publishedArgs=i.mode==="fallback"?i.args:void 0),i)}get currentTextLength(){return this.text?.length??0}get currentArgs(){return this.publishedArgs??=FN(this.args)}append(e){if(e.length===0)return this;if(this.currentTextLength===0)return il.from(e,this.args);if(this.mode==="complete"){const a=il.from(this.accumulatedText()+e,this.args);return a.args===this.args&&(a.publishedArgs=this.currentArgs),a}const n=this.clone(),i=this.args;return n.consumeDelta(e),n.text={length:(this.text?.length??0)+e.length,previous:this.text,value:e},n.args=n.snapshot(i),n.publishedArgs=n.args===i?this.currentArgs:n.mode==="fallback"?n.args:void 0,n}clone(){const e=new il(this.args);return e.text=this.text,e.mode=this.mode,e.root=this.root,e.frames=this.frames.map(n=>({...n,path:[...n.path]})),e.token=this.token?{...this.token,..."path"in this.token&&this.token.path?{path:[...this.token.path]}:void 0}:void 0,e}snapshot(e){return this.mode==="fallback"?ul(this.accumulatedText())??e:this.mode==="start"?e:GN(this.root,this.mode==="complete"?"complete":"partial",this.partialPath())}accumulatedText(){const e=[];for(let n=this.text;n;n=n.previous)e.push(n.value);return e.reverse().join("")}partialPath(){return this.mode==="complete"?[]:this.token&&(this.token.kind==="number"||this.token.kind==="string"&&this.token.role==="value")?this.token.path:this.frames.at(-1)?.path??[]}isFallback(){return this.mode==="fallback"}consumeDelta(e,n=!1){if(!this.isFallback()){this.ownedContainers=n?new Set([this.root]):new Set;for(const i of e)if(this.consumeCharacter(i),this.isFallback())break;!this.isFallback()&&this.token?.kind==="string"&&this.token.role==="value"?this.writeValue(this.token.path,this.token.value):!this.isFallback()&&this.token?.kind==="number"&&dc.test(this.token.value)&&this.writeValue(this.token.path,Number(this.token.value)),this.ownedContainers=void 0}}consumeCharacter(e){let n=!0;for(;n&&this.mode!=="fallback";){if(n=!1,this.token){n=this.consumeToken(e);continue}if(this.mode==="complete"){fc.test(e)||(this.mode="fallback");continue}if(this.mode==="start"){if(fc.test(e))continue;if(e!=="{"){this.mode="fallback";continue}this.mode="parsing",this.frames.push({kind:"object",path:[],state:"first-key-or-end"});continue}const i=this.frames.at(-1);if(!i){this.mode="fallback";continue}i.kind==="object"?this.consumeObjectCharacter(i,e):this.consumeArrayCharacter(i,e)}}consumeObjectCharacter(e,n){if(!fc.test(n))switch(e.state){case"first-key-or-end":n==="}"?this.closeContainer():n==='"'?(e.state="key",this.startKeyString()):this.mode="fallback";break;case"key":n==='"'?this.startKeyString():this.mode="fallback";break;case"colon":n===":"?e.state="value":this.mode="fallback";break;case"value":this.startValue(n,[...e.path,e.key]);break;case"comma-or-end":n===","?(e.state="key",e.key=void 0):n==="}"?this.closeContainer():this.mode="fallback"}}consumeArrayCharacter(e,n){if(!fc.test(n))switch(e.state){case"first-value-or-end":n==="]"?this.closeContainer():(e.state="value",this.startValue(n,[...e.path,e.index]));break;case"value":this.startValue(n,[...e.path,e.index]);break;case"comma-or-end":n===","?(e.index+=1,e.state="value"):n==="]"?this.closeContainer():this.mode="fallback"}}startValue(e,n){if(e==="{")this.writeValue(n,{}),this.frames.push({kind:"object",path:n,state:"first-key-or-end"});else if(e==="[")this.writeValue(n,[]),this.frames.push({kind:"array",path:n,state:"first-value-or-end",index:0});else if(e==='"')this.writeValue(n,""),this.startValueString(n);else if(e==="t"||e==="f"||e==="n"){const i=e==="t"?"true":e==="f"?"false":"null";this.writeValue(n,i==="true"?!0:i==="false"?!1:null),this.token={kind:"literal",value:i,offset:1}}else e==="-"||e>="0"&&e<="9"?(this.token={kind:"number",path:n,value:e},dc.test(e)&&this.writeValue(n,Number(e))):this.mode="fallback"}startKeyString(){this.token={kind:"string",role:"key",value:"",escape:"none",unicode:""}}startValueString(e){this.token={kind:"string",role:"value",path:e,value:"",escape:"none",unicode:""}}consumeToken(e){const n=this.token;return n.kind==="string"?this.consumeString(n,e):n.kind==="number"?this.consumeNumber(n,e):this.consumeLiteral(n,e)}consumeString(e,n){if(e.escape==="unicode")return HN.test(n)?(e.unicode+=n,e.unicode.length===4&&(e.value+=String.fromCharCode(Number.parseInt(e.unicode,16)),e.escape="none",e.unicode=""),!1):(this.mode="fallback",!1);if(e.escape==="single"){if(n==="u")return e.escape="unicode",!1;const i=VN[n];return i===void 0?this.mode="fallback":(e.value+=i,e.escape="none"),!1}if(n==="\\")return e.escape="single",!1;if(n.charCodeAt(0)<32)return this.mode="fallback",!1;if(n!=='"')return e.value+=n,!1;if(this.token=void 0,e.role==="key"){const i=this.frames.at(-1);if(!i||i.kind!=="object")return this.mode="fallback",!1;if(e.value==="__proto__"||e.value==="prototype"&&i.path.at(-1)==="constructor")return this.mode="fallback",!1;i.key=e.value,i.state="colon"}else this.writeValue(e.path,e.value),this.finishValue();return!1}consumeNumber(e,n){if(n>="0"&&n<="9"||n==="e"||n==="E"||n==="+"||n==="-"||n==="."){const i=e.value+n;return qN.test(i)?(e.value=i,dc.test(e.value)&&this.writeValue(e.path,Number(e.value)),!1):(this.mode="fallback",!1)}return dc.test(e.value)?(this.token=void 0,this.finishValue(),!0):(this.mode="fallback",!1)}consumeLiteral(e,n){return n!==e.value[e.offset]?(this.mode="fallback",!1):(e.offset+=1,e.offset===e.value.length&&(this.token=void 0,this.finishValue()),!1)}finishValue(){const e=this.frames.at(-1);if(!e||e.state!=="value"){this.mode="fallback";return}e.state="comma-or-end"}closeContainer(){this.frames.pop(),this.frames.length===0?this.mode="complete":this.finishValue()}writeValue(e,n){try{this.root=$N(this.root,e,n,this.ownedContainers??new Set)}catch{this.mode="fallback"}}};const cx=ix("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),YN=(t,e)=>new ReadableStream({start(n){return t.start?.(e(n))},pull(n){return t.pull?.(e(n))},cancel(n){return t.cancel?.(n)}}),QN=(t,e)=>{let n;return[YN({start(i){n=i},cancel(i){return e?.(n,i)}},t),n]},cl=()=>{let t,e;const n=new Promise((i,a)=>{t=i,e=a});if(!t||!e)throw new Error("Failed to create promise");return{promise:n,resolve:t,reject:e}},KN=()=>{const t=[];let e=!1,n=!1,i=!1,a,o,u,d=0,f,p;const m=C=>{for(const R of C.holds)R.reached.resolve();C.holds=[]},y=()=>{if(o=void 0,!p){const C=t.splice(0);for(const R of C)R.orderedFinish?.delivered.resolve(),m(R);p=Promise.all(C.map(async R=>{try{await R.reader.cancel().catch(()=>{}),await R.pipeTask}finally{R.reader.releaseLock()}})).then(()=>{})}return p},v=C=>{n||i||(i=!0,console.error(C),y(),a.error(C),f?.reject(C),f=void 0)},b=C=>{C.promise||(C.promise=C.reader.read().then(async({done:R,value:O})=>{if(!(n||i)){if(R)C.orderedFinish?.delivered.resolve(),t.splice(t.indexOf(C),1),C.reader.releaseLock(),m(C),e&&t.length===0&&d===0&&a.close();else{if(C.gate&&(await C.gate,C.gate=void 0,n||i))return;for(;C.holds[0]&&C.delivered>=C.holds[0].writtenBefore;)if(await C.holds[0].flushed,C.holds.shift(),n||i)return;if(O.type==="part-finish"&&C.orderedFinish&&(await C.orderedFinish.previous(),n||i))return;a.enqueue(O),C.delivered++;for(const L of C.holds)C.delivered>=L.writtenBefore&&L.reached.resolve();O.type==="part-finish"&&C.orderedFinish?.delivered.resolve()}C.promise=void 0,f?.resolve(),f=void 0}}).catch(R=>{C.promise=void 0,v(R)}))},T=new ReadableStream({start(C){a=C},pull(){return f=cl(),t.forEach(C=>{b(C)}),f.promise},async cancel(){n=!0;const C=y();f?.resolve(),f=void 0,await C}}),w=(C,R)=>{const O={writtenBefore:C.written(),reached:cl(),flushed:R};return C.delivered>=O.writtenBefore&&O.reached.resolve(),C.holds.push(O),O.reached.promise},x=C=>{const R=C.type==="step-finish"||C.type==="message-finish"||C.type==="error";if((t.length>0||R)&&(o=void 0),!o){const O=[];o=O,d++;const L=u,I=R?t.filter(H=>H.written):[],P=L||I.length>0?cl():void 0,k=P?I.map(H=>w(H,P.promise)):[];P&&(u=P.promise),Promise.resolve().then(async()=>{if(L&&await L,k.length>0&&await Promise.all(k),d--,o===O&&(o=void 0),!(n||i)){for(const H of O)a.enqueue(H);e&&t.length===0&&d===0&&a.close(),f?.resolve(),f=void 0}}).catch(v).finally(()=>{P&&(P.resolve(),u===P.promise&&(u=void 0))})}o.push(C),R&&(o=void 0)};return{readable:T,isSealed(){return e},isCancelled(){return n},isErrored(){return i},seal(){e||n||i||(e=!0,t.length===0&&d===0&&a.close())},addStream:(C,R,O)=>{const L=R?.catch(()=>{});if(n||i){C.cancel().catch(()=>{});return}if(e)throw C.cancel().catch(()=>{}),new Error("Cannot add streams after the run callback has settled.");o=void 0;const I={reader:C.getReader(),pipeTask:L,orderedFinish:O?.orderedFinish,written:O?.written,delivered:0,gate:u,holds:[]};t.push(I),b(I)},enqueue(C){if(!(n||i)){if(e)throw new Error("Cannot add streams after the run callback has settled.");x(C)}}}},dx=t=>t instanceof TypeError,wr=(t,e,n)=>{try{t.enqueue(e)}catch(i){if(!dx(i))throw i;n?.(i)}},Lc=t=>{try{t.close()}catch(e){if(!dx(e))throw e}};var tm=class{_controller;_strict;_isClosed=!1;_ignoreAppends=!1;_warnedDropped=!1;constructor(t,e={}){this._controller=t,this._strict=e.strict??!0}append(t){if(this._ignoreAppends)return this;const e={type:"text-delta",path:[],textDelta:t};if(this._isClosed){if(this._strict)throw new TypeError("Cannot append to a closed TextStreamController");return wr(this._controller,e,this._warnDroppedAfterClose),this}return wr(this._controller,e),this}_warnDroppedAfterClose=t=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(t)}`))};close(){this._isClosed||(this._isClosed=!0,wr(this._controller,{type:"part-finish",path:[]}),Lc(this._controller))}__internal_close(){this._isClosed||(this._ignoreAppends=!0,this.close())}__internal_truncate(){this._isClosed||(this._ignoreAppends=!0,this._isClosed=!0,Lc(this._controller))}};const fS=Symbol.for("aui.tool-response"),nm="<no result>";var XN=class sm{get[fS](){return!0}artifact;result;isError;isPreliminary;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);const n=e.result;this.result=n===void 0?nm:n,this.isError=e.isError??!1,e.isPreliminary&&(this.isPreliminary=!0),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!==null&&fS in e}static toResponse(e){return e instanceof sm?e:new sm({result:e===void 0?nm:e})}},JN=class{_isClosed=!1;_hasArgsText=!1;_argsTextState="open";_controller;_argsTextController;_options;constructor(t,e={}){this._controller=t,this._options=e,this._argsTextController=new tm({enqueue:n=>{if(this._argsTextState!=="open")throw new TypeError("Cannot append to finished tool-call args");if(n.type==="text-delta"){this._hasArgsText=!0,this._controller.enqueue(n);return}this._argsTextState="finishing",queueMicrotask(()=>this._finishArgsText())},close:()=>{}},{strict:this._options.strict})}_finishArgsText(){this._argsTextState==="finishing"&&(this._argsTextState="finished",this._hasArgsText||wr(this._controller,{type:"text-delta",textDelta:"{}",path:[]}),wr(this._controller,{type:"tool-call-args-text-finish",path:[]}))}get argsText(){return this._argsTextController}async setResponse(t){if(this._isClosed)return;const e=t.result;wr(this._controller,{type:"result",path:[],...t.artifact!==void 0?{artifact:t.artifact}:{},result:e===void 0?nm:e,isError:t.isError??!1,...t.isPreliminary?{isPreliminary:!0}:{},...t.modelContent!==void 0?{modelContent:t.modelContent}:{},...t.messages!==void 0?{messages:t.messages}:{}}),t.isPreliminary?(this._argsTextController.close(),this._finishArgsText()):await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._options.onClose?.(),this._argsTextController.close(),this._finishArgsText(),wr(this._controller,{type:"part-finish",path:[]}),Lc(this._controller))}__internal_truncate(){this._isClosed||(this._isClosed=!0,this._finishArgsText(),this._argsTextController.__internal_truncate(),this._argsTextState="finished",Lc(this._controller))}},fx=class{value=-1;up(){return++this.value}},ZN=class extends TransformStream{constructor(t){super({transform(e,n){n.enqueue({...e,path:[t,...e.path]})}})}};(class extends TransformStream{constructor(t){super({transform(e,n){const{path:[i,...a]}=e;if(t!==i)throw new Error(`Path mismatch: expected ${t}, got ${i}`);n.enqueue({...e,path:a})}})}});var WN=class extends TransformStream{constructor(t){const e=new fx,n=new Map;super({transform(i,a){i.type==="part-start"&&i.path.length===0&&n.set(e.up(),t.up());const[o,...u]=i.path;if(o===void 0){a.enqueue(i);return}const d=n.get(o);if(d===void 0)throw new Error("Path not found");a.enqueue({...i,path:[d,...u]})}})}};const tp=t=>{let e=0;const[n,i]=QN(a=>t({get desiredSize(){return a.desiredSize},enqueue(o){a.enqueue(o),e++},close(){a.close()},error(o){a.error(o)}}));return[n,i,()=>e]};var eO=class hx{_state;_parentId;constructor(e,n={}){this._state=e||{strict:n.strict??!0,merger:KN(),contentCounter:new fx,openInputs:new Set,lastToolCallFinish:Promise.resolve()}}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_endOpenInputs(){this._state.append=void 0;for(const e of this._state.openInputs)e();this._state.openInputs.clear()}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,n,i){if(e.locked)throw new TypeError("Cannot merge a stream that is already locked to a reader.");const a=e.pipeTo(n.writable).catch(async o=>{throw await n.writable.abort(o).catch(()=>{}),o});return this._state.merger.addStream(n.readable,a,i),a}_trackOpenInput(e,n){const{openInputs:i}=this._state;i.add(n);const a=()=>i.delete(n);e.then(a,a)}_addPart(e,n,i,a,o){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:e,path:[]});const u=this._addTransformedStream(n,new ZN(this._state.contentCounter.value),{orderedFinish:o,written:i});a&&this._trackOpenInput(u,a)}merge(e){this._addTransformedStream(e,new WN(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,n){(n!==void 0||this._state.append?.kind!=="reasoning"||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:"reasoning",parentId:this._parentId,controller:this.addReasoningPart(n)}),!(n!==void 0&&e.length===0)&&this._state.append.controller.append(e)}addTextPart(){const[e,n,i]=tp(a=>new tm(a,{strict:this._state.strict}));return this._addPart(this._withParentIdOption({type:"text"}),e,i,()=>n.__internal_close()),n}addReasoningPart(e){const[n,i,a]=tp(o=>new tm(o,{strict:this._state.strict}));return this._addPart(this._withParentIdOption({type:"reasoning",...e}),n,a,()=>i.__internal_close()),i}addToolCallPart(e){const n=typeof e=="string"?{toolName:e}:e,i=n.toolName,a=n.toolCallId??cx(),o=cl();let u=Promise.resolve();const[d,f,p]=tp(m=>new JN(m,{strict:this._state.strict,onClose:()=>{u=this._state.lastToolCallFinish,this._state.lastToolCallFinish=o.promise}}));return this._addPart({type:"tool-call",toolName:i,toolCallId:a,...this._parentId&&{parentId:this._parentId}},d,p,()=>f.__internal_truncate(),{previous:()=>u,delivered:o}),n.argsText!==void 0&&(f.argsText.append(n.argsText),f.argsText.close()),n.args!==void 0&&(f.argsText.append(JSON.stringify(n.args)),f.argsText.close()),n.response!==void 0&&f.setResponse(n.response),f}_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(),()=>1)}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream(),()=>1)}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream(),()=>1)}enqueue(e){this._state.merger.enqueue(e),e.type==="part-start"&&e.path.length===0&&this._state.contentCounter.up()}withParentId(e){const n=new hx(this._state);return n._parentId=e,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function tO(t,e={}){const n=new eO(void 0,e);return(async()=>{try{await t(n)}catch(a){n.__internal_isClosed?n.__internal_isCancelled||console.error(a):(n.enqueue({type:"error",path:[],error:String(a)}),n.__internal_endOpenInputs())}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function nO(t={}){const{resolve:e,promise:n}=cl();let i;return[tO(a=>(i=a,i.__internal_subscribeToClose(e),n),t),i]}var sO=class extends TransformStream{constructor(t,e,n){const[i,a]=nO({strict:t.strict}),o=new AbortController;let u;super({start(p){u=i.pipeTo(new WritableStream({write(m){p.enqueue(m)},abort(m){p.error(m)},close(){p.terminate()}}),{signal:o.signal}).catch(m=>{p.error(m)});try{return t.start?.(a)}catch(m){throw o.abort(m),m}},transform(p){return t.transform?.(p,a)},async flush(){await t.flush?.(a),a.close(),await u}},e,n);const d=super.readable.getReader();let f=!1;Object.defineProperty(this,"readable",{value:new ReadableStream({start(p){d.closed.catch(m=>{o.abort(m),p.error(m),d.releaseLock()})},async pull(p){const m=await d.read();f||(m.done?(p.close(),d.releaseLock()):p.enqueue(m.value))},async cancel(p){f=!0;const m=d.cancel(p);o.abort(p);try{await m}finally{await u,d.releaseLock()}}},{highWaterMark:0}),writable:!1})}};const np=(t,e,n)=>{if(t?.startsWith("data-"))return{type:"data",name:t.substring(5),data:e,...typeof n=="string"&&{id:n}}},_l=(t,e,n)=>{const{role:i,id:a,createdAt:o,attachments:u,status:d,metadata:f}=t,p={id:a??e,createdAt:o??new Date},m=typeof t.content=="string"?[{type:"text",text:t.content}]:t.content,y=({image:v,...b})=>typeof v!="string"?null:RN(v)?.mimeType.startsWith("image/")?{...b,image:v}:/^(https:\/\/|blob:)/i.test(v)?{...b,image:v}:(console.warn("Invalid image data format detected"),null);if(i!=="user"&&u?.length)throw new Error("attachments are only supported for user messages");if(i!=="assistant"&&d)throw new Error("status is only supported for assistant messages");if(i!=="assistant"&&f?.steps)throw new Error("metadata.steps is only supported for assistant messages");switch(i){case"assistant":return{...p,role:i,content:m.map(v=>{const b=v.type;switch(b){case"text":return v.text?.trim()?v:null;case"reasoning":return!v.text?.trim()&&!v.unstable_summary?.trim()?null:v.text==null?{...v,text:""}:v;case"file":case"source":return v;case"image":return y(v);case"data":return v;case"generative-ui":return v;case"tool-call":{const{parentId:T,messages:w,unstable_interactions:x,...E}=v,C=pg(x),R={...E,toolCallId:v.toolCallId||`tool-${un()}`,...T!==void 0&&{parentId:T},...w!==void 0&&{messages:w},...C!==void 0&&{unstable_interactions:C}};return v.args?{...R,args:v.args,argsText:v.argsText??JSON.stringify(v.args)}:{...R,args:ul(v.argsText??"")??{},argsText:v.argsText??""}}case"audio":throw new Error(`Unsupported assistant message part type: ${b}`);default:{const T=b,w=np(T,v.data,v.id);if(w)return w;throw new Error(`Unsupported assistant message part type: ${T}`)}}}).filter(v=>!!v),status:d??n,metadata:{unstable_state:f?.unstable_state??null,unstable_annotations:f?.unstable_annotations??[],unstable_data:f?.unstable_data??[],custom:f?.custom??{},steps:f?.steps??[],...f?.timing&&{timing:f.timing},...f?.submittedFeedback&&{submittedFeedback:f.submittedFeedback},...f?.isOptimistic&&{isOptimistic:!0},...f?.modality&&{modality:f.modality}}};case"user":return{...p,role:i,content:m.filter(v=>v.type!=="text"||v.text!=null).map(v=>{const b=v.type;switch(b){case"text":case"image":case"audio":case"file":case"data":return v;case"reasoning":case"source":case"generative-ui":case"tool-call":throw new Error(`Unsupported user message part type: ${b}`);default:{const T=b,w=np(T,v.data,v.id);if(w)return w;throw new Error(`Unsupported user message part type: ${T}`)}}}),attachments:(u??[]).map(v=>({...v,content:(v.content??[]).map(b=>np(b.type,b.data,"id"in b?b.id:void 0)??b)})),metadata:{custom:f?.custom??{},...f?.isOptimistic&&{isOptimistic:!0},...f?.modality&&{modality:f.modality}}};case"system":if(m.length!==1||m[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...p,role:i,content:m,metadata:{custom:f?.custom??{}}};default:throw new Error(`Unknown message role: ${i}`)}},iO=t=>_l({role:t.role,content:t.role==="system"||t.text?[{type:"text",text:t.text}]:[],attachments:[],metadata:{custom:{...t.quote?{quote:t.quote}:{}}}},t.id,{type:"complete",reason:"unknown"}),rO=t=>{const e=yt(()=>({}),[]),n=e.state,i=[];t.suggestions.forEach(o=>{const u=n?.suggestions[i.length];i.push(u&&qa(u,o)?u:o)});const a=n&&qa(i,n.suggestions)?n:{suggestions:i};return e.state=a,a},aO=t=>({getState:()=>t}),oO=Ye(aO),lO=t=>{const e=Q(9),n=rO(t);let i;e[0]!==n.suggestions?(i=n.suggestions.map(dO),e[0]=n.suggestions,e[1]=i):i=e[1];const a=ks(i);let o;e[2]!==n?(o=()=>n,e[2]=n,e[3]=o):o=e[3];let u;e[4]!==a?(u=f=>{const{index:p}=f;return a.get({index:p})},e[4]=a,e[5]=u):u=e[5];let d;return e[6]!==o||e[7]!==u?(d={getState:o,suggestion:u},e[6]=o,e[7]=u,e[8]=d):d=e[8],d},uO=t=>{const e=Q(4);let n;e[0]!==t?(n=t.map(fO),e[0]=t,e[1]=n):n=e[1];let i;return e[2]!==n?(i={suggestions:n},e[2]=n,e[3]=i):i=e[3],lO(i)},cO=Ye(uO);function dO(t,e){return Jt(e,oO(t),[t])}function fO(t){return{title:t.title??t.prompt,label:t.label??"",prompt:t.prompt}}const hO=t=>"reason"in t?t.reason:void 0,pO=t=>"error"in t?t.error:void 0,mO=32,px=new WeakMap,mx=t=>px.get(t)??t.id,gO=(t,e,n)=>"status"in t&&t.status?sx(t,e,n):ds,yO=()=>{let t=[],e=new Map;return n=>{const i=[],a=new Map;let o=!0;const u=(f,p,m,y)=>{if(!(m>mO))for(const[v,b]of f.entries())for(const[T,w]of b.content.entries()){if(w.type!=="tool-call"||w.messages===void 0)continue;const x=w.messages,E=gO(b,T,w),C=hO(E),R=pO(E),O=`${y}${v}.${T}`,L=e.get(O),I=L?.part===w&&L.statusType===E.type&&L.statusReason===C&&Object.is(L.statusError,R)&&L.messages===x&&L.task.messageId===b.id&&L.task.parentTaskId===p&&L.task.depth===m?L.task:{id:w.toolCallId,toolName:w.toolName,args:w.args,result:w.result,...w.isError===void 0?void 0:{isError:w.isError},status:E,timing:w.timing,messageId:b.id,parentTaskId:p,depth:m,messages:x};I!==L?.task&&(o=!1,px.set(I,O)),i.push(I),a.set(O,{task:I,part:w,statusType:E.type,statusReason:C,statusError:R,messages:x}),u(x,I.id,m+1,`${O}.`)}};u(n,null,0,"");const d=o&&i.length===t.length&&i.every((f,p)=>f===t[p])?t:i;return t=d,e=a,d}},vO=({task:t})=>({getState:()=>t}),bO=Ye(vO),_O=t=>{const e=Q(8),{runtime:n,id:i,threadIdRef:a,threadId:o,isLast:u}=t;let d;e[0]!==i||e[1]!==n?(d=n.getMessageById(i),e[0]=i,e[1]=n,e[2]=d):d=e[2];const f=d;let p;return e[3]!==u||e[4]!==f||e[5]!==o||e[6]!==a?(p=Y3({runtime:f,threadIdRef:a,threadId:o,isLast:u}),e[3]=u,e[4]=f,e[5]=o,e[6]=a,e[7]=p):p=e[7],Dn(p)},SO=Ye(_O),TO=t=>{const e=Q(117),{runtime:n}=t,i=ln(n),a=Ya();let o,u;e[0]!==a||e[1]!==n?(o=()=>{const ge=[];for(const Oe of["runStart","runEnd","initialize","modelContextUpdate"]){const Pe=n.unstable_on(Oe,()=>{const $e=n.getState()?.threadId||"unknown";a(`thread.${Oe}`,{threadId:$e})});ge.push(Pe)}return ge.push(n.unstable_on("historyWriteError",Oe=>{const Pe=n.getState()?.threadId||"unknown";a("thread.historyWriteError",{threadId:Pe,operation:Oe.operation,messageIds:Oe.messageIds,message:Oe.message})}),n.unstable_on("toolApprovalAnswered",Oe=>{const Pe=n.getState()?.threadId||"unknown";a("thread.toolApprovalAnswered",{threadId:Pe,...Oe})})),()=>si(ge)},u=[n,a],e[0]=a,e[1]=n,e[2]=o,e[3]=u):(o=e[2],u=e[3]),Ce(o,u);let d;e[4]!==n?(d=ex(()=>n.getState().threadId),e[4]=n,e[5]=d):d=e[5];const f=d;let p;e[6]!==a||e[7]!==n?(p=ge=>{a(ge,{threadId:n.getState().threadId})},e[6]=a,e[7]=n,e[8]=p):p=e[8];const m=p;let y;e[9]!==n?(y=ge=>n.getState().suggestions.some(Oe=>Oe.prompt===ge),e[9]=n,e[10]=y):y=e[10];const v=y;let b;e[11]!==v||e[12]!==n.composer||e[13]!==f?(b=Ww({runtime:n.composer,threadIdRef:f,isSuggestion:v}),e[11]=v,e[12]=n.composer,e[13]=f,e[14]=b):b=e[14];const T=La(b);let w;e[15]!==i.suggestions?(w=cO(i.suggestions),e[15]=i.suggestions,e[16]=w):w=e[16];const x=La(w);let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=yO(),e[17]=E):E=e[17];const C=E;let R;e[18]!==i.messages?(R=C(i.messages),e[18]=i.messages,e[19]=R):R=e[19];const O=R;let L;e[20]!==O?(L=O.map(xO),e[20]=O,e[21]=L):L=e[21];const I=ks(L),P=T.state.submission,k=T.state.inTransit;let H;e[22]!==k?(H=k??[],e[22]=k,e[23]=H):H=e[23];let V;e[24]!==P?(V=P?[P]:[],e[24]=P,e[25]=V):V=e[25];let z;e[26]!==H||e[27]!==V?(z=[...H,...V],e[26]=H,e[27]=V,e[28]=z):z=e[28];const q=z;let W;e[29]!==q?(W=q.map(iO),e[29]=q,e[30]=W):W=e[30];const X=W,Z=i.messages.length-1;let ee;if(e[31]!==Z||e[32]!==q||e[33]!==X||e[34]!==n||e[35]!==i.messages||e[36]!==i.threadId||e[37]!==f){let ge;e[39]!==Z||e[40]!==q.length||e[41]!==n||e[42]!==i.threadId||e[43]!==f?(ge=($e,ve)=>{const Ae=ve===Z&&q.length>0?!1:void 0;return Jt($e.id,SO({runtime:n,id:$e.id,threadIdRef:f,threadId:i.threadId,isLast:Ae}),[n,$e.id,f,i.threadId,Ae])},e[39]=Z,e[40]=q.length,e[41]=n,e[42]=i.threadId,e[43]=f,e[44]=ge):ge=e[44];const Oe=i.messages.map(ge);let Pe;e[45]!==q||e[46]!==X||e[47]!==i.messages.length?(Pe=q.map(($e,ve)=>Jt($e.id,gN({message:X[ve],submission:$e,index:i.messages.length+ve,isLast:ve===q.length-1}),[X[ve],$e,i.messages.length,ve,q.length])),e[45]=q,e[46]=X,e[47]=i.messages.length,e[48]=Pe):Pe=e[48],ee=[...Oe,...Pe],e[31]=Z,e[32]=q,e[33]=X,e[34]=n,e[35]=i.messages,e[36]=i.threadId,e[37]=f,e[38]=ee}else ee=e[38];const oe=ks(ee),he=oe.state.length===0&&!i.isLoading;let ye;e[49]!==T.state||e[50]!==oe.state||e[51]!==i.capabilities||e[52]!==i.extras||e[53]!==i.hasEarlier||e[54]!==i.isDisabled||e[55]!==i.isLoading||e[56]!==i.isLoadingEarlier||e[57]!==i.isRunning||e[58]!==i.isSendDisabled||e[59]!==i.speech||e[60]!==i.state||e[61]!==i.suggestions||e[62]!==i.voice||e[63]!==he||e[64]!==O?(ye={isEmpty:he,isDisabled:i.isDisabled,isSendDisabled:i.isSendDisabled,isLoading:i.isLoading,hasEarlier:i.hasEarlier,isLoadingEarlier:i.isLoadingEarlier,isRunning:i.isRunning,capabilities:i.capabilities,state:i.state,suggestions:i.suggestions,extras:i.extras,speech:i.speech,voice:i.voice,composer:T.state,messages:oe.state,tasks:O},e[49]=T.state,e[50]=oe.state,e[51]=i.capabilities,e[52]=i.extras,e[53]=i.hasEarlier,e[54]=i.isDisabled,e[55]=i.isLoading,e[56]=i.isLoadingEarlier,e[57]=i.isRunning,e[58]=i.isSendDisabled,e[59]=i.speech,e[60]=i.state,e[61]=i.suggestions,e[62]=i.voice,e[63]=he,e[64]=O,e[65]=ye):ye=e[65];const D=ye;let $;e[66]!==D?($=()=>D,e[66]=D,e[67]=$):$=e[67];let re;e[68]!==T.methods?(re=()=>T.methods,e[68]=T.methods,e[69]=re):re=e[69];let M;e[70]!==x?(M=()=>x.methods,e[70]=x,e[71]=M):M=e[71];let N;e[72]!==I||e[73]!==O?(N=ge=>{if("id"in ge){const Oe=O.find(Pe=>Pe.id===ge.id);return I.get({key:Oe?mx(Oe):ge.id})}return I.get(ge)},e[72]=I,e[73]=O,e[74]=N):N=e[74];let te;e[75]!==a||e[76]!==v||e[77]!==n?(te=ge=>{const Oe=typeof ge=="string"?{content:[{type:"text",text:ge}]}:ge;if((Oe.role??"user")==="user"){const Pe=Oe.content.map(CO).join("");a("composer.send",{threadId:n.getState().threadId,chars:Pe.length,attachments:Oe.attachments?.length??0,...v(Pe)?{suggestion:!0}:void 0})}n.append(ge)},e[75]=a,e[76]=v,e[77]=n,e[78]=te):te=e[78];let ie;e[79]!==m||e[80]!==n||e[81]!==i.isRunning?(ie=()=>{i.isRunning&&m("thread.cancelRun"),n.cancelRun()},e[79]=m,e[80]=n,e[81]=i.isRunning,e[82]=ie):ie=e[82];let pe;e[83]!==n?(pe=()=>n.loadEarlier(),e[83]=n,e[84]=pe):pe=e[84];let de;e[85]!==m||e[86]!==n?(de=()=>{n.connectVoice(),m("thread.voiceStarted")},e[85]=m,e[86]=n,e[87]=de):de=e[87];let B;e[88]!==oe?(B=ge=>"id"in ge?oe.get({key:ge.id}):oe.get(ge),e[88]=oe,e[89]=B):B=e[89];let ce;e[90]!==n?(ce=()=>n,e[90]=n,e[91]=ce):ce=e[91];let fe;return e[92]!==n.deleteMessage||e[93]!==n.disconnectVoice||e[94]!==n.export||e[95]!==n.getModelContext||e[96]!==n.getVoiceVolume||e[97]!==n.import||e[98]!==n.importExternalState||e[99]!==n.muteVoice||e[100]!==n.reset||e[101]!==n.resumeRun||e[102]!==n.startRun||e[103]!==n.stopSpeaking||e[104]!==n.subscribeVoiceVolume||e[105]!==n.unmuteVoice||e[106]!==$||e[107]!==re||e[108]!==M||e[109]!==N||e[110]!==te||e[111]!==ie||e[112]!==pe||e[113]!==de||e[114]!==B||e[115]!==ce?(fe={getState:$,composer:re,suggestions:M,task:N,append:te,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:ie,loadEarlier:pe,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:de,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:B,__internal_getRuntime:ce},e[92]=n.deleteMessage,e[93]=n.disconnectVoice,e[94]=n.export,e[95]=n.getModelContext,e[96]=n.getVoiceVolume,e[97]=n.import,e[98]=n.importExternalState,e[99]=n.muteVoice,e[100]=n.reset,e[101]=n.resumeRun,e[102]=n.startRun,e[103]=n.stopSpeaking,e[104]=n.subscribeVoiceVolume,e[105]=n.unmuteVoice,e[106]=$,e[107]=re,e[108]=M,e[109]=N,e[110]=te,e[111]=ie,e[112]=pe,e[113]=de,e[114]=B,e[115]=ce,e[116]=fe):fe=e[116],fe},wO=Ye(TO);function xO(t){return Jt(mx(t),bO({task:t}),[t])}function CO(t){return t.type==="text"?t.text:""}const EO=t=>{const e=Q(4),n=Ya(),i=we(t);let a,o;e[0]!==n||e[1]!==t?(a=()=>{const u=i.current;u!==t&&(i.current=t,n("threads.selectionChanged",{threadId:t,previousThreadId:u}))},o=[t,n],e[0]=n,e[1]=t,e[2]=a,e[3]=o):(a=e[2],o=e[3]),Ce(a,o)},AO=(t,e,n)=>{const i=Q(8),a=e,o=Ya(),u=e&&a;let d;i[0]!==u||i[1]!==t?(d={isMain:u,threadId:t},i[0]=u,i[1]=t,i[2]=d):d=i[2];const f=we(d);let p,m;i[3]!==o||i[4]!==e||i[5]!==t?(p=()=>{const y=f.current;y.isMain===e&&y.threadId===t||(f.current={isMain:e,threadId:t},o(e?"threadListItem.switchedTo":"threadListItem.switchedAway",{threadId:t}))},m=[e,t,o],i[3]=o,i[4]=e,i[5]=t,i[6]=p,i[7]=m):(p=i[6],m=i[7]),Ce(p,m)},us=(t,e)=>Jw(`thread list ${t}`,e),IO=t=>{const e=Q(27),{runtime:n,mainThreadIsRunning:i}=t,a=i===void 0?!1:i,o=ln(n);let u;e:{const C=o.isRunning||o.isMain&&a;if(C===o.isRunning){u=o;break e}let R;e[0]!==C||e[1]!==o?(R={...o,isRunning:C},e[0]=C,e[1]=o,e[2]=R):R=e[2],u=R}const d=u;AO(o.id,o.isMain);let f;e[3]!==d?(f=()=>d,e[3]=d,e[4]=f):f=e[4];let p,m,y,v,b,T,w;e[5]!==n?(m=C=>us("switch",()=>n.switchTo(C)),y=C=>us("rename",()=>n.rename(C)),v=C=>us("update custom metadata",()=>n.updateCustom(C)),b=()=>us("archive",()=>n.archive()),T=()=>us("unarchive",()=>n.unarchive()),w=()=>us("delete",()=>n.delete()),p=C=>us("generate title",()=>n.generateTitle(C)),e[5]=n,e[6]=p,e[7]=m,e[8]=y,e[9]=v,e[10]=b,e[11]=T,e[12]=w):(p=e[6],m=e[7],y=e[8],v=e[9],b=e[10],T=e[11],w=e[12]);let x;e[13]!==n?(x=()=>n,e[13]=n,e[14]=x):x=e[14];let E;return e[15]!==n.detach||e[16]!==n.initialize||e[17]!==p||e[18]!==x||e[19]!==f||e[20]!==m||e[21]!==y||e[22]!==v||e[23]!==b||e[24]!==T||e[25]!==w?(E={getState:f,switchTo:m,rename:y,updateCustom:v,archive:b,unarchive:T,delete:w,generateTitle:p,initialize:n.initialize,detach:n.detach,__internal_getRuntime:x},e[15]=n.detach,e[16]=n.initialize,e[17]=p,e[18]=x,e[19]=f,e[20]=m,e[21]=y,e[22]=v,e[23]=b,e[24]=T,e[25]=w,e[26]=E):E=e[26],E},mg=Ye(IO),RO=100,MO=(t,e)=>{const[n]=Ne(()=>({committed:void 0,unmounted:!1,waiters:new Set,delayed:new WeakMap}));return Ce(()=>{if(n.committed={state:t},!Object.is(t,e()))return;const i=[...n.waiters];n.waiters.clear();for(const a of i)a()}),Ce(()=>(n.unmounted=!1,()=>{n.unmounted=!0,n.committed=void 0;const i=[...n.waiters];n.waiters.clear();for(const a of i)a()}),[n]),on(i=>{const a=n.delayed.get(i);if(a)return a;const o=i.then(u=>new Promise(d=>{const f=n.committed;if(n.unmounted||f!==void 0&&Object.is(f.state,e())){d(u);return}const p=()=>{clearTimeout(m),n.waiters.delete(p),d(u)},m=setTimeout(p,RO);n.waiters.add(p)}));return n.delayed.set(i,o),o},[n,e])},kO=t=>{const e=Q(6),{runtime:n,id:i,mainThreadIsRunning:a}=t;let o;e[0]!==i||e[1]!==n?(o=n.getItemById(i),e[0]=i,e[1]=n,e[2]=o):o=e[2];const u=o;let d;return e[3]!==a||e[4]!==u?(d=mg({runtime:u,mainThreadIsRunning:a}),e[3]=a,e[4]=u,e[5]=d):d=e[5],Dn(d)},NO=Ye(kO),OO=t=>{const e=Q(53),{runtime:n,__internal_assistantRuntime:i}=t,a=ln(n),o=MO(a,n.getState);EO(a.mainThreadId);const u=Ya();let d,f;e[0]!==u||e[1]!==n?(d=()=>n.unstable_subscribeThreadEvents(z=>{const{threadId:q,type:W}=z;q!==n.getState().mainThreadId&&u(`thread.${W}`,{threadId:q})}),f=[n,u],e[0]=u,e[1]=n,e[2]=d,e[3]=f):(d=e[2],f=e[3]),Ce(d,f);let p;e[4]!==n.main?(p=wO({runtime:n.main}),e[4]=n.main,e[5]=p):p=e[5];const m=La(p);let y;e[6]!==m.state||e[7]!==n||e[8]!==a.threadItems?(y=Object.keys(a.threadItems).map(z=>Jt(z,NO({runtime:n,id:z,mainThreadIsRunning:m.state.isRunning}),[n,z,m.state.isRunning])),e[6]=m.state,e[7]=n,e[8]=a.threadItems,e[9]=y):y=e[9];const v=ks(y),b=a.newThreadId??null;let T;e[10]!==m.state||e[11]!==a.archivedThreadIds||e[12]!==a.hasMore||e[13]!==a.isLoading||e[14]!==a.isLoadingMore||e[15]!==a.loadError||e[16]!==a.mainThreadId||e[17]!==a.threadIds||e[18]!==b||e[19]!==v.state?(T={mainThreadId:a.mainThreadId,newThreadId:b,isLoading:a.isLoading,loadError:a.loadError,isLoadingMore:a.isLoadingMore,hasMore:a.hasMore,threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadItems:v.state,main:m.state},e[10]=m.state,e[11]=a.archivedThreadIds,e[12]=a.hasMore,e[13]=a.isLoading,e[14]=a.isLoadingMore,e[15]=a.loadError,e[16]=a.mainThreadId,e[17]=a.threadIds,e[18]=b,e[19]=v.state,e[20]=T):T=e[20];const w=T;let x;e[21]!==w?(x=()=>w,e[21]=w,e[22]=x):x=e[22];let E;e[23]!==m.methods?(E=()=>m.methods,e[23]=m.methods,e[24]=E):E=e[24];let C;e[25]!==w||e[26]!==v?(C=z=>{if(z==="main")return v.get({key:w.mainThreadId});if("id"in z)return v.get({key:z.id});const{index:q,archived:W}=z,X=W!==void 0&&W?w.archivedThreadIds[q]:w.threadIds[q];return v.get({key:X})},e[25]=w,e[26]=v,e[27]=C):C=e[27];let R,O;e[28]!==n?(R=(z,q)=>us("switch",()=>n.switchToThread(z,q)),O=()=>us("create",()=>n.switchToNewThread()),e[28]=n,e[29]=R,e[30]=O):(R=e[29],O=e[30]);let L,I;e[31]!==o||e[32]!==n?(L=()=>o(n.getLoadThreadsPromise()),I=()=>o(n.reload()),e[31]=o,e[32]=n,e[33]=L,e[34]=I):(L=e[33],I=e[34]);let P;e[35]!==n?(P=()=>n.reloadMainThread(),e[35]=n,e[36]=P):P=e[36];let k;e[37]!==o||e[38]!==n?(k=()=>o(n.loadMore()),e[37]=o,e[38]=n,e[39]=k):k=e[39];let H;e[40]!==i?(H=()=>i,e[40]=i,e[41]=H):H=e[41];let V;return e[42]!==R||e[43]!==O||e[44]!==L||e[45]!==I||e[46]!==P||e[47]!==k||e[48]!==H||e[49]!==x||e[50]!==E||e[51]!==C?(V={getState:x,thread:E,item:C,switchToThread:R,switchToNewThread:O,getLoadThreadsPromise:L,reload:I,reloadMainThread:P,loadMore:k,__internal_getAssistantRuntime:H},e[42]=R,e[43]=O,e[44]=L,e[45]=I,e[46]=P,e[47]=k,e[48]=H,e[49]=x,e[50]=E,e[51]=C,e[52]=V):V=e[52],V},DO=Ye(OO),jO=(t,e)=>{t.thread??=jn({source:"threads",query:{type:"main"},get:n=>n.threads.thread("main")}),t.threadListItem??=jn({source:"threads",query:{type:"main"},get:n=>n.threads.item("main")}),t.composer??=jn({source:"thread",query:{},get:n=>n.threads.thread("main").composer()}),!t.modelContext&&e.modelContext.source===null&&(t.modelContext=Yw()),!t.suggestions&&e.suggestions.source===null&&(t.suggestions=jn({source:"thread",query:{},get:n=>n.thread.suggestions()}))},gx=t=>{const e=Q(7),n=Iw();let i;e[0]!==n||e[1]!==t?(i=()=>t.registerModelContextProvider(n.current.modelContext()),e[0]=n,e[1]=t,e[2]=i):i=e[2];let a;e[3]!==t?(a=[t],e[3]=t,e[4]=a):a=e[4],Rw("modelContext",i,a);let o;return e[5]!==t?(o=DO({runtime:t.threads,__internal_assistantRuntime:t}),e[5]=t,e[6]=o):o=e[6],Dn(o)},zO=Ye(gx),PO=(t,e)=>{jO(t,e),!t.tools&&e.tools.source===null&&(t.tools=M3({})),!t.dataRenderers&&e.dataRenderers.source===null&&(t.dataRenderers=vk())};Ew(gx,PO);const yx=t=>{const{children:e,condition:n}=t;return me(n)?e:null};yx.displayName="AuiIf";const BO=ns({}),hS=({effects:t})=>{"use no memo";return Ha(t),null},hs=et(function(e,n){"use no memo";const{config:i,children:a}=e,o="extends"in e,u="value"in e,d=ag();if(zw){if(o&&u)throw new Error("AuiProvider: pass either `extends` or `value`, not both.");if(o&&e.extends===void 0)throw new Error("AuiProvider: `extends` must be a client or null, not undefined.");if(o&&!i)throw new Error("AuiProvider: `extends` requires a `config`.");if(u&&i)throw new Error("AuiProvider: pass either `value` or `config`, not both.");if(!u&&!i)throw new Error("AuiProvider: a `config` is required.");if(!o&&!u&&d!==ja)throw new Error("A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.")}const f=o?e.extends??ja:u?e.value??ja:d,p=Xk(),{client:m,effects:y}=qw(f,i??BO,p);return HM(n,()=>m,[m]),_.jsx(Jp.Provider,{value:p,children:_.jsxs(rg.Provider,{value:m,children:[_.jsx(hS,{effects:Mk(f)}),y&&_.jsx(hS,{effects:y}),a]})})}),UO=t=>{const e=ke(),n=we(!1),i=n.current?null:t(e);return me(()=>n.current?t(e):i),()=>(n.current=!0,t(e))},LO=Object.freeze({});function qi(t){const e=Q(3),{getItemState:n,children:i}=t,a=UO(n);let o;return e[0]!==i||e[1]!==a?(o=i(a),e[0]=i,e[1]=a,e[2]=o):o=e[2],qO(o)}const qO=t=>{const e=typeof t=="object"&&t!=null&&"type"in t?t:null,n=e?.type,i=e?.key,a=typeof e?.props=="object"&&e.props!=null&&Object.entries(e.props).length===0?LO:e?.props;return yt(()=>e,[n,i,a])??t},pS=(t,e)=>{const n=Q(11),i=ke(),a=bn(e);let o;n[0]!==t?(o=og(t),n[0]=t,n[1]=o):o=n[1];const{scope:u,event:d}=o;let f;n[2]!==i||n[3]!==a||n[4]!==d||n[5]!==u?(f=()=>i.on({scope:u,event:d},a),n[2]=i,n[3]=a,n[4]=d,n[5]=u,n[6]=f):f=n[6];let p;n[7]!==i||n[8]!==d||n[9]!==u?(p=[i,u,d],n[7]=i,n[8]=d,n[9]=u,n[10]=p):p=n[10],Ce(f,p)},HO=t=>t._core?.RenderComponent,VO=({runtime:t,aui:e,config:n,children:i})=>{"use no memo";const a=HO(t),o=ns({...n,threads:zO(t)});return _.jsxs(hs,{extends:e,config:o,children:[a&&_.jsx(a,{}),i]})},$O=Nt(t=>{const e=Q(5),{runtime:n,aui:i,config:a,children:o}=t,u=i===void 0?null:i;let d;return e[0]!==u||e[1]!==o||e[2]!==a||e[3]!==n?(d=_.jsx(VO,{runtime:n,aui:u,config:a,children:o}),e[0]=u,e[1]=o,e[2]=a,e[3]=n,e[4]=d):d=e[4],d}),qc=Qt(null),GO=(t,e)=>Fa(qc,t,e),vx=()=>Sn(qc),FO={},YO=t=>{const e=jc(t??FO);return t==null?null:e},mS=t=>{const e=Q(6),{adapters:n,children:i}=t,a=Sn(qc);let o;e[0]!==n||e[1]!==a?(o={...a,...n},e[0]=n,e[1]=a,e[2]=o):o=e[2];const u=o;let d;return e[3]!==i||e[4]!==u?(d=_.jsx(qc.Provider,{value:u,children:i}),e[3]=i,e[4]=u,e[5]=d):d=e[5],d};function Ze(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}function Mr(t,e=0){return e>100?!1:t===null||typeof t=="string"||typeof t=="boolean"?!0:typeof t=="number"?!Number.isNaN(t)&&Number.isFinite(t):Array.isArray(t)?t.every(n=>Mr(n,e+1)):Ze(t)?Object.entries(t).every(([n,i])=>typeof n=="string"&&Mr(i,e+1)):!1}const QO=t=>{if(t instanceof Date&&!Number.isNaN(t.getTime()))return t;if(typeof t!="string"&&typeof t!="number")return null;const e=new Date(t);return Number.isNaN(e.getTime())?null:e},KO=t=>t==="system"||t==="user"||t==="assistant",gS={running:()=>!0,"requires-action":t=>typeof t.reason=="string",complete:t=>typeof t.reason=="string",incomplete:t=>(t.reason===void 0||typeof t.reason=="string")&&(t.error===void 0||Mr(t.error))},bx=t=>Ze(t)&&typeof t.type=="string"&&Object.hasOwn(gS,t.type)&&gS[t.type](t)===!0,_x=t=>{if(Ze(t)){if(t.messageId!==void 0&&typeof t.messageId!="string"){const{messageId:e,...n}=t;return _x(n)}if(t.usage!==void 0&&!Ze(t.usage)){const{usage:e,...n}=t;return n}return t}},Sx=t=>Array.isArray(t)?t.map(_x).filter(e=>e!==void 0):[],Tx=(t,e)=>{const n={text:i=>typeof i.text=="string",reasoning:i=>typeof i.text=="string"||typeof i.unstable_summary=="string",image:i=>typeof i.image=="string",file:i=>typeof i.data=="string"&&typeof i.mimeType=="string",audio:i=>Ze(i.audio)&&typeof i.audio.data=="string"&&typeof i.audio.format=="string",data:i=>typeof i.name=="string",source:i=>typeof i.id=="string"&&(i.sourceType==="url"?typeof i.url=="string":i.sourceType==="document"&&typeof i.title=="string"&&typeof i.mediaType=="string"),"generative-ui":i=>Ze(i.spec),"tool-call":i=>typeof i.toolCallId=="string"&&typeof i.toolName=="string"&&Ze(i.args)&&typeof i.argsText=="string",...t};return i=>Ze(i)&&typeof i.type=="string"&&(Object.hasOwn(n,i.type)?n[i.type](i):e(i.type))};Tx({},()=>!0);const XO=Tx({reasoning:t=>(t.text===void 0||typeof t.text=="string")&&(t.unstable_summary===void 0||typeof t.unstable_summary=="string")&&(typeof t.text=="string"||typeof t.unstable_summary=="string"),"tool-call":t=>typeof t.toolCallId=="string"&&typeof t.toolName=="string"&&(t.args===void 0||Ze(t.args))&&(t.argsText===void 0||typeof t.argsText=="string")&&(t.args!==void 0||t.argsText!==void 0)},t=>t.startsWith("data-")),sp={user:{text:!0,image:!0,file:!0,data:!0,audio:!0},assistant:{text:!0,reasoning:!0,"tool-call":!0,source:!0,file:!0,image:!0,data:!0,"generative-ui":!0}},wx=(t,e)=>XO(e)&&(t==="system"?e.type==="text":Object.hasOwn(sp.assistant,e.type)||Object.hasOwn(sp.user,e.type)?Object.hasOwn(sp[t],e.type):!0),JO=(t,e)=>!Ze(t)||typeof t.id!="string"||typeof t.type!="string"||typeof t.name!="string"||!Ze(t.status)||t.status.type!=="complete"||!Array.isArray(t.content)?null:{...t,content:t.content.filter(e)},ip=t=>{const e=t.threadListItem;if(!e.source)return;const n=e.getState().id;if(n!==void 0)return t.threads.getState().threadItems.some(i=>i.id===n||i.remoteId===n)?t.threads.item({id:n}):e},im={toResponse(t,e){return new Response(im.toByteStream(t,e),{headers:e.headers??{}})},fromResponse(t,e){return im.fromByteStream(t.body,e)},toByteStream(t,e){return t.pipeThrough(e)},fromByteStream(t,e){return t.pipeThrough(e)}},ZO=new Set(["__proto__","constructor","prototype"]);function WO(t){if(ZO.has(t))throw new Error(`Unsafe gorp path segment: ${t}`)}var e4=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(t=null,e={}){this._state=t,this._strict=e.strict??!0}get state(){return this._state}logOnce(t,e){this._logged.has(t)||this._logged.size>=20||(this._logged.add(t),e())}append(t){this._state=t.reduce((e,n)=>{if(this._strict)return this.apply(e,n);try{return this.apply(e,n)}catch(i){return this.logOnce(`skip:${String(i)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(i)}`,n)),e}},this._state)}apply(t,e){const n=e.type;switch(n){case"set":return this.updatePath(t,e.path,()=>e.value);case"append-text":return this.updatePath(t,e.path,i=>{if(typeof i!="string")throw new Error(`Expected string at path [${e.path.join(", ")}]`);return i+e.value});default:throw new Error(`Invalid operation type: ${n}`)}}updatePath(t,e,n){if(e.length===0)return n(t);const i=[];let a=t;for(let u=0;u<e.length;u++){if(a??={},typeof a!="object")throw new Error(`Invalid path: [${e.slice(u).join(", ")}]`);const d=e[u];if(WO(d),Array.isArray(a)){let f=Number(d);if(!Number.isInteger(f)||String(f)!==String(d))throw new Error(`Expected array index at [${e.slice(u).join(", ")}]`);if(f<0)throw new Error("Insert array index out of bounds");if(f>a.length){if(this._strict)throw new Error("Insert array index out of bounds");this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${f} to ${a.length}`)),f=a.length}i.push({kind:"array",state:a,key:f}),a=Object.hasOwn(a,f)?a[f]:void 0}else{const f=a;i.push({kind:"object",state:f,key:d}),a=Object.hasOwn(f,d)?f[d]:void 0}}let o=n(a);for(let u=i.length-1;u>=0;u--){const d=i[u];if(d.kind==="array"){const f=[...d.state];f[d.key]=o,o=f}else{const f={...d.state};f[d.key]=o,o=f}}return o}},t4=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(t){this._toolCallIds.add(t)}getTiming(t,e){const n=Date.now()-this._streamStartTime,i=t&&t>0?t:e?Math.ceil(e.length/4):void 0,a=i&&n>0?i/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime!==void 0?{firstTokenTime:this._firstTokenTime-this._streamStartTime}:void 0,totalStreamTime:n,...i!==void 0?{tokenCount:i}:void 0,...a!==void 0?{tokensPerSecond:a}:void 0,totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}};const xx=(t,e)=>({...t,parts:e,get content(){return this.parts}}),Ra=(t,e)=>xx(t,[...t.parts,e]),n4=({unstable_state:t=null}={})=>({role:"assistant",status:{type:"running"},parts:[],get content(){return this.parts},metadata:{unstable_state:t,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),s4=16,fd=(t,e,n,i)=>{const a=e.path.length===1?t.parts[e.path[0]]:void 0;if(a===void 0)return n(`no-part:${e.type}`,`Dropped ${e.type} chunk: no part at path [${e.path.join(", ")}]`),t;const o=e.path[0],u=i(a);return u===a?t:xx(t,[...t.parts.slice(0,o),u,...t.parts.slice(o+1)])},i4=(t,e,n)=>{const i=e.part;if(i.type==="text"||i.type==="reasoning"){const a={type:i.type,text:"",status:{type:"running"},...i.type==="reasoning"&&i.unstable_summary!==void 0?{unstable_summary:i.unstable_summary}:void 0,...i.type==="reasoning"?{timing:{startedAt:Date.now()}}:void 0,...i.parentId&&{parentId:i.parentId}};return Ra(t,a)}else if(i.type==="tool-call"){const a={type:"tool-call",state:"partial-call",status:{type:"running",isArgsComplete:!1},toolCallId:i.toolCallId,toolName:i.toolName,argsText:"",args:{},timing:{startedAt:Date.now()},...i.parentId&&{parentId:i.parentId}};return Ra(t,a)}else if(i.type==="source"){const a={type:"source",sourceType:i.sourceType,id:i.id,url:i.url,...i.title?{title:i.title}:void 0,...i.parentId&&{parentId:i.parentId}};return Ra(t,a)}else if(i.type==="file"){const a={type:"file",mimeType:i.mimeType,data:i.data,...i.parentId&&{parentId:i.parentId}};return Ra(t,a)}else if(i.type==="data"){const a={type:"data",name:i.name,data:i.data,...i.parentId&&{parentId:i.parentId}};return Ra(t,a)}else{const a=String(i.type);return n(`unsupported-part-start:${a}`,`Unsupported part-start type ${a}: inserting an empty reasoning part to preserve part indices`),Ra(t,{type:"reasoning",text:"",status:{type:"running"}})}},r4=(t,e,n)=>fd(t,e,n,i=>i.type!=="tool-call"?(n("wrong-part:tool-call-args-text-finish","Dropped tool-call-args-text-finish chunk: part is not a tool-call"),i):i.state!=="partial-call"?i:{...i,state:"call",status:i.status.type==="running"?{type:"running",isArgsComplete:!0}:i.status}),a4=(t,e,n)=>fd(t,e,n,i=>i.type==="tool-call"&&i.isPreliminary?i:i.type==="reasoning"&&i.timing!==void 0?{...i,status:{type:"complete",reason:"unknown"},timing:{...i.timing,completedAt:i.timing.completedAt??Date.now()}}:{...i,status:{type:"complete",reason:"unknown"}}),o4=(t,e,n,i)=>fd(t,e,n,a=>{if(a.type==="text"||a.type==="reasoning")return{...a,text:a.text+e.textDelta};if(a.type==="tool-call"){const o=a.argsText+e.textDelta,u=i.get(a),d=u?u.append(e.textDelta):o.length===0?dS.from(""):dS.from(o,a.args),f=d.currentArgs,p={...a,argsText:o,args:f};return i.set(p,d),p}else return n("wrong-part:text-delta","Dropped text-delta chunk: part is neither text nor tool-call"),a}),l4=(t,e,n)=>fd(t,e,n,i=>{if(i.type==="tool-call"){const a=e.isPreliminary===!0,o=i.status.type==="running"?i.status:{type:"running",isArgsComplete:i.state!=="partial-call"};if(a)return i.state==="result"?i:{...i,state:i.state==="partial-call"?"partial-call":"call",...e.artifact!==void 0?{artifact:e.artifact}:{},result:e.result,isError:e.isError??!1,isPreliminary:!0,...e.modelContent!==void 0?{modelContent:e.modelContent}:{},...e.messages!==void 0?{messages:e.messages}:{},status:o};const{isPreliminary:u,...d}=i;return{...d,state:"result",...i.timing!==void 0?{timing:{...i.timing,completedAt:i.timing.completedAt??Date.now()}}:{},...e.artifact!==void 0?{artifact:e.artifact}:{},result:e.result,isError:e.isError??!1,...e.modelContent!==void 0?{modelContent:e.modelContent}:{},...e.messages!==void 0?{messages:e.messages}:{},status:{type:"complete",reason:"stop"}}}else return n("wrong-part:result","Dropped result chunk: part is not a tool-call"),i}),yS=(t,e)=>{if(t.status?.type==="incomplete"&&t.status?.reason==="error")return t;const n=u4(e);return{...t,status:n}},u4=t=>t.finishReason==="tool-calls"?{type:"requires-action",reason:"tool-calls"}:t.finishReason==="stop"||t.finishReason==="unknown"?{type:"complete",reason:t.finishReason}:{type:"incomplete",reason:t.finishReason},c4=(t,e)=>({...t,metadata:{...t.metadata,unstable_annotations:[...t.metadata.unstable_annotations,...e.annotations]}}),d4=(t,e)=>({...t,metadata:{...t.metadata,unstable_data:[...t.metadata.unstable_data,...e.data]}}),f4=(t,e)=>({...t,metadata:{...t.metadata,steps:[...t.metadata.steps,{state:"started",messageId:e.messageId}]}}),h4=(t,e)=>{const n=t.metadata.steps.slice(),i=n.length-1;return n.length>0&&n[i]?.state==="started"?n[i]={...n[i],state:"finished",finishReason:e.finishReason,usage:e.usage,isContinued:e.isContinued}:n.push({state:"finished",messageId:cx(),finishReason:e.finishReason,usage:e.usage,isContinued:e.isContinued}),{...t,metadata:{...t.metadata,steps:n}}},p4=(t,e)=>{const n=e.severity==="critical"||e.severity==="warning"||e.severity==="info"?e.severity:void 0;return{...t,status:{type:"incomplete",reason:"error",error:{code:e.code??"unknown",message:e.error??"unknown error",...n!==void 0&&{severity:n}}}}},m4=(t,e,n)=>(n.append(e.operations),{...t,metadata:{...t.metadata,unstable_state:n.state}}),g4=t=>{let e=0;for(const n of t.metadata.steps)n.state==="finished"&&n.usage&&(e+=n.usage.outputTokens);return e},vS=(t,e,n=0)=>{const i=n>0?n:g4(e);if(i>0)return t.getTiming(i);let a="";for(const o of e.parts)(o.type==="text"||o.type==="reasoning")&&(a+=o.text);return t.getTiming(void 0,a||void 0)},y4=t=>{let e=!1;return()=>{e||(e=!0,queueMicrotask(()=>{e=!1,t()}))}};var v4=class extends TransformStream{constructor({initialMessage:t,throttle:e,onError:n,strict:i=!0}={}){let a=t??n4(),o,u;const d=new t4,f=new WeakMap,p=new Set,m=(b,T)=>{p.has(b)||p.size>=s4||(p.add(b),console.warn(T))};let y;const v=e?y4(()=>{y?.enqueue(a)}):()=>{y?.enqueue(a)};super({start(b){y=b},transform(b){d.recordChunk();const T=b.type;switch(T){case"part-start":a=i4(a,b,m),b.part.type==="tool-call"&&d.recordToolCallStart(b.part.toolCallId);break;case"tool-call-args-text-finish":a=r4(a,b,m);break;case"part-finish":a=a4(a,b,m);break;case"text-delta":{const w=o4(a,b,m,f);w!==a&&d.recordFirstToken(),a=w;break}case"result":a=l4(a,b,m);break;case"message-finish":u=b.usage?.outputTokens,a=yS(a,b);break;case"annotations":a=c4(a,b);break;case"data":a=d4(a,b);break;case"step-start":a=f4(a,b);break;case"step-finish":a=h4(a,b);break;case"error":a=p4(a,b),n?.(b.error);break;case"update-state":o??=new e4(a.metadata.unstable_state,{strict:i}),a=m4(a,b,o);break;default:throw new Error(`Unsupported chunk type: ${T}`)}a.status.type!=="running"&&(a={...a,metadata:{...a.metadata,timing:vS(d,a,u)}}),v()},flush(b){if(a.status?.type==="running"){const T=a.parts?.some(w=>w.type==="tool-call"&&(w.state==="call"||w.state==="partial-call")&&(w.result===void 0||w.isPreliminary))??!1;a=yS(a,{finishReason:T?"tool-calls":"unknown"}),a={...a,metadata:{...a.metadata,timing:vS(d,a,u)}},b.enqueue(a)}}})}},b4=class Cc{readable;constructor(e){this.readable=e}static fromAssistantStream(e){return new Cc(e.pipeThrough(new v4))}async unstable_result(){let e;for await(const n of this)e=n;return e||{role:"assistant",status:{type:"complete",reason:"unknown"},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return zN(this.readable)[Symbol.asyncIterator]()}tee(){const[e,n]=this.readable.tee();return[new Cc(e),new Cc(n)]}},_4=class extends TransformStream{constructor(t){super();const e=t(super.readable);Object.defineProperty(this,"readable",{value:e,writable:!1})}},S4=class extends _4{constructor(){super(t=>{const e=new sO({transform(n,i){i.appendText(n)}});return t.pipeThrough(new TextDecoderStream).pipeThrough(e)})}};const T4=100,rm=(t,e,n)=>{if(t===e)return!0;if(n>T4||t==null||e==null)return!1;if(Array.isArray(t))return!Array.isArray(e)||t.length!==e.length?!1:t.every((o,u)=>rm(o,e[u],n+1));if(Array.isArray(e)||!Ze(t)||!Ze(e))return!1;const i=Object.keys(t),a=Object.keys(e);return i.length!==a.length?!1:i.every(o=>Object.hasOwn(e,o)&&rm(t[o],e[o],n+1))},gg=(t,e)=>!Mr(t)||!Mr(e)?!1:rm(t,e,0);function w4(t){const e=t.metadata;if(!e||typeof e!="object")return;const n=e.custom;if(!n||typeof n!="object")return;const i=n.interactables;return Array.isArray(i)?i:void 0}function x4(t){return`update_${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`}const rp=t=>{if(!Ze(t))return;const e=t.id;return typeof e=="string"||typeof e=="number"?e:void 0};function yg(t,e,n=[]){if(!Ze(t)||!Ze(e))return e;const i={...t,...e},[a,...o]=n;return a!==void 0&&Object.hasOwn(e,a)&&(i[a]=yg(t[a],e[a],o)),i}function C4(t,e,n,i){let a=Array.isArray(e.set)?[...e.set]:[...t];if(e.clear===!0&&(a=[]),Array.isArray(e.remove)&&e.remove.length>0){const u=new Set(e.remove);a=a.filter(d=>{const f=rp(d);return f!==void 0?!u.has(f):!u.has(d)})}const o=e.update;if(Array.isArray(o)&&o.length>0){const u=new Map;for(const f of o){const p=rp(f);p!==void 0&&!Number.isNaN(p)&&!u.has(p)&&u.set(p,f)}const d=i?.[0]==="update"?{patch:o[Number(i[1])],rest:i.slice(2)}:void 0;a=a.map(f=>{const p=rp(f);if(p===void 0||!Ze(f))return f;const m=u.get(p);return m?d&&m===d.patch?yg(f,m,d.rest):{...f,...m}:f})}if(Array.isArray(e.add)&&e.add.length>0){const u=n?e.add.map(d=>{if(!Ze(d)||d.id!==void 0)return d;const f=n();return f===void 0?d:{...d,id:f}}):e.add;a=[...a,...u]}return a}function ap(t,e,n){if(!Ze(t)||!Ze(e))return e;const i=Ze(n?.arrayBaseline)?n.arrayBaseline:t,a=n?.partialPath,o=Object.entries(t);for(const[u,d]of Object.entries(e)){const f=i[u],p=a?.[0]===u?a.slice(1):void 0;if(Array.isArray(f)&&Ze(d)){const m=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(u))?()=>n.idFactory?.(u):void 0;o.push([u,C4(f,d,m,p)])}else p?o.push([u,yg(t[u],d,p)]):o.push([u,d])}return Object.fromEntries(o)}function E4(t,e){if(!Ze(t)||!Ze(e))return;for(const a of Object.keys(t))if(!Object.hasOwn(e,a))return;const n=[];for(const[a,o]of Object.entries(e))(!Object.hasOwn(t,a)||!gg(t[a],o))&&n.push([a,o]);const i=n.length;if(!(i===0||i===Object.keys(e).length))return Object.fromEntries(n)}const A4=t=>{if(!t||typeof t!="object")return;const e=t;return e.type==="tool-call"?e:void 0},I4=(t,e)=>{if(!t.args||typeof t.args!="object")return!1;const n=Ze(t.result)?t.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id=="string")return n.id===e;const i=t.args.id;return i===e||i===void 0},R4=t=>{const e=Ze(t)?t.addedItemIds:void 0;if(!Ze(e))return;const n=new Map;for(const[i,a]of Object.entries(e)){if(!Array.isArray(a))continue;const o=a.filter(u=>typeof u=="string");o.length>0&&n.set(i,o)}if(n.size!==0)return i=>n.get(i)?.shift()},bS=new WeakMap;function M4(t,e,n){let i=bS.get(t);i||(i=new Map,bS.set(t,i));let a=i.get(n);a||(a=new Map,i.set(n,a));const o=a.get(e);if(o)return o;const u=x4(n),d=[],f=()=>d[d.length-1];for(const p of t){if(p.role==="user"){const m=w4(p)?.find(y=>y.id===e);if(!m)continue;if(m.partial){const y=f();y&&d.push({state:ap(y.state,m.state),origin:"user-edit"})}else d.push({state:m.state,origin:"user-edit"});continue}if(p.role==="assistant")for(const m of p.content??[]){const y=A4(m);if(y){if(y.toolCallId===e&&y.toolName===n)y.args&&typeof y.args=="object"&&d.push({state:y.args,origin:"create",toolCallId:e});else if(y.toolName===u&&I4(y,e)){const v=f();if(v){const{id:b,...T}=y.args,w=R4(y.result);d.push({state:w?ap(v.state,T,{idFactory:w}):ap(v.state,T),origin:"update",toolCallId:y.toolCallId})}}}}}return a.set(e,d),d}function k4(t,e,n){const i=M4(t,e,n),a=i[i.length-1];return a?{state:a.state}:void 0}function N4(t,e){if(!t)return;const{interactables:n,...i}=t,a={...i};if(Array.isArray(n)){const o=[];for(const u of n){const d=k4(e,u.id,u.name);if(!d){o.push({id:u.id,name:u.name,state:u.state});continue}if(gg(u.state,d.state))continue;const f=E4(d.state,u.state);o.push(f?{id:u.id,name:u.name,state:f,partial:!0}:{id:u.id,name:u.name,state:u.state})}o.length&&(a.interactables=o)}return Object.keys(a).length?a:void 0}const Hc=Symbol("innerMessage"),O4=t=>t.type==="tool-call"&&t.result===void 0,D4=t=>t.type==="tool-call"&&nx(t),Ka=Symbol("autoStatus"),_S=Object.freeze(Object.assign({type:"running"},{[Ka]:!0})),j4=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[Ka]:!0})),z4=Object.freeze(Object.assign({type:"incomplete",reason:"cancelled"},{[Ka]:!0})),P4=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[Ka]:!0})),B4=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[Ka]:!0})),vg=(t,e,n,i,a,o,u)=>t&&a!==void 0&&a!==null?Object.assign({type:"incomplete",reason:"error",error:a},{[Ka]:!0}):t&&e?_S:n?B4:u&&!o?_S:i?P4:o?z4:j4,SS=t=>vg(!1,!1,typeof t!="string"&&t.some(D4),typeof t!="string"&&t.some(O4)),Cx=t=>{const e=Q(6),{index:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({attachment:jn({source:"message",query:{type:"index",index:n},get:f=>f.message.attachment({index:n})})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},Ex=t=>{const e=Q(6),{index:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({attachment:jn({source:"composer",query:{type:"index",index:n},get:f=>f.composer.attachment({index:n})})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},U4=t=>{const e=Q(6),{runtime:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({threadListItem:mg({runtime:n})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},Ax=t=>{const e=Q(6),{index:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({message:jn({source:"thread",query:{type:"index",index:n},get:f=>f.thread.message({index:n})}),composer:jn({source:"message",query:{},get:f=>f.thread.message({index:n}).composer()})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},bg=t=>{const e=Q(6),{index:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({part:jn({source:"message",query:{type:"index",index:n},get:f=>f.message.part({index:n})})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},L4=t=>{const e=Q(7),{text:n,isRunning:i}=t;let a;e[0]!==i?(a=i?{type:"running"}:{type:"complete"},e[0]=i,e[1]=a):a=e[1];let o;e[2]!==a||e[3]!==n?(o={type:"text",text:n,status:a},e[2]=a,e[3]=n,e[4]=o):o=e[4];const u=o;let d;return e[5]!==u?(d={getState:()=>u,addToolResult:H4,resumeToolCall:V4,respondToToolApproval:$4,unstable_recordInteraction:G4},e[5]=u,e[6]=d):d=e[6],d},q4=Ye(L4),_g=t=>{const e=Q(7),{text:n,isRunning:i,children:a}=t,o=i===void 0?!1:i,u=ke();let d;e[0]!==o||e[1]!==n?(d=ns({part:q4({text:n,isRunning:o})}),e[0]=o,e[1]=n,e[2]=d):d=e[2];const f=d;let p;return e[3]!==u||e[4]!==a||e[5]!==f?(p=_.jsx(hs,{extends:u,config:f,children:a}),e[3]=u,e[4]=a,e[5]=f,e[6]=p):p=e[6],p};function H4(){throw new Error("Not supported")}function V4(){throw new Error("Not supported")}function $4(){throw new Error("Not supported")}async function G4(){throw new Error("Not supported")}const F4=t=>{for(const e of t)if(e?.status.type==="running")return hg;return t.at(-1)?.status??ds},Y4=(t,e)=>{const n={running:0,complete:0,incomplete:0,requiresAction:0};let i=ds,a=!1,o,u,d=!0;for(const p of e){const m=t[p]?.timing;switch(m&&(o=Math.min(o??m.startedAt,m.startedAt),m.completedAt===void 0?d=!1:u=Math.max(u??m.completedAt,m.completedAt)),i=t[p]?.status??ds,i.type){case"running":n.running++,a=!0;break;case"complete":n.complete++;break;case"incomplete":n.incomplete++;break;case"requires-action":n.requiresAction++}}const f=o===void 0?void 0:!a&&d&&u!==void 0?{startedAt:o,completedAt:u}:{startedAt:o};return{status:a?hg:i,counts:n,...f&&{timing:f}}},Q4=t=>{const e=Q(11),{parts:n,getMessagePart:i}=t,[a,o]=Ne(!0);let u;e[0]!==n?(u=F4(n),e[0]=n,e[1]=u):u=e[1];const d=u;let f;e[2]!==a||e[3]!==n||e[4]!==d?(f={parts:n,collapsed:a,status:d},e[2]=a,e[3]=n,e[4]=d,e[5]=f):f=e[5];const p=f;let m;e[6]!==p?(m=()=>p,e[6]=p,e[7]=m):m=e[7];let y;return e[8]!==i||e[9]!==m?(y={getState:m,setCollapsed:o,part:i},e[8]=i,e[9]=m,e[10]=y):y=e[10],y},K4=Ye(Q4),X4=Qt(null),J4=t=>{const e=Q(13),{startIndex:n,endIndex:i,children:a}=t,o=me(Z4).slice(n,i+1);let u;e[0]!==i||e[1]!==n?(u=T=>Or(T.message.parts).slice(n,i+1),e[0]=i,e[1]=n,e[2]=u):u=e[2];const d=me(fs(u));let f;e[3]!==d||e[4]!==n?(f={partKeys:d,startIndex:n},e[3]=d,e[4]=n,e[5]=f):f=e[5];const p=f,m=ke(),y=ns({chainOfThought:K4({parts:o,getMessagePart:T=>{const{index:w}=T;if(w<0||w>=o.length)throw new Error(`ChainOfThought part index ${w} is out of bounds (0..${o.length-1})`);return m.message.part({index:n+w})}})});let v;e[6]!==a||e[7]!==y||e[8]!==m?(v=_.jsx(hs,{extends:m,config:y,children:a}),e[6]=a,e[7]=y,e[8]=m,e[9]=v):v=e[9];let b;return e[10]!==p||e[11]!==v?(b=_.jsx(X4.Provider,{value:p,children:v}),e[10]=p,e[11]=v,e[12]=b):b=e[12],b};function Z4(t){return t.message.parts}const Ix=t=>{const e=Q(6),{index:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({suggestion:jn({source:"suggestions",query:{index:n},get:f=>f.suggestions.suggestion({index:n})})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},W4=t=>{const e=Q(6),{index:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({queueItem:jn({source:"composer",query:{type:"index",index:n},get:f=>f.composer.queueItem({index:n})})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},eD=["critical","warning","info"],tD=["inline","toast","silent","dev-only"],nD=t=>{if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.code!="string"||typeof e.message!="string"||"severity"in e&&e.severity!==void 0&&(typeof e.severity!="string"||!eD.includes(e.severity))||"display"in e&&e.display!==void 0&&(typeof e.display!="string"||!tD.includes(e.display)))},Rx=Symbol.for("assistant-ui.message-not-sent");var Ec=class extends Error{[Rx]=!0;constructor(t="The message was not sent."){super(t),this.name="MessageNotSentError"}};const Mx=t=>typeof t=="object"&&t!==null&&Rx in t,sD=t=>{if(nD(t))return t;if(t instanceof Error)return{code:"unknown",message:t.message};if(typeof t=="string")return{code:"unknown",message:t};try{return{code:"unknown",message:`[${typeof t}] ${String(t)}`}}catch{return{code:"unknown",message:`[${typeof t}]`}}},kx=(t,e)=>{Promise.resolve(e).catch(n=>{Mx(n)||console.error(`[assistant-ui] ${t} failed`,n)})};var Nx=class{get path(){return this._core.path}_core;constructor(t){this._core=t,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(t){return this._core.subscribe(t)}},Ox=class extends Nx{_composerApi;constructor(t,e){super(t),this._composerApi=e}remove(){const t=this._composerApi.getState();if(!t)throw new Error("Composer is not available");return t.removeAttachment(this.getState().id)}},iD=class extends Ox{get source(){return"thread-composer"}},rD=class extends Ox{get source(){return"edit-composer"}},aD=class extends Nx{get source(){return"message"}remove(){throw new Error("Message attachments cannot be removed")}};const Pa=Object.freeze([]),Dx=Object.freeze({}),oD=t=>Object.freeze({type:"thread",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,canSend:t?.canSend??!1,isEmpty:t?.isEmpty??!0,attachments:t?.attachments??Pa,text:t?.text??"",role:t?.role??"user",runConfig:t?.runConfig??Dx,attachmentAccept:t?.attachmentAccept??"",dictation:t?.dictation,quote:t?.quote,queue:t?.queue??Pa,submission:t?.submission,inTransit:t?.inTransit??Pa,value:t?.text??""}),lD=t=>Object.freeze({type:"edit",isEditing:t?.isEditing??!1,canCancel:t?.canCancel??!1,canSend:t?.canSend??!1,isEmpty:t?.isEmpty??!0,text:t?.text??"",role:t?.role??"user",attachments:t?.attachments??Pa,runConfig:t?.runConfig??Dx,attachmentAccept:t?.attachmentAccept??"",dictation:t?.dictation,quote:t?.quote,queue:t?.queue??Pa,submission:t?.submission,inTransit:t?.inTransit??Pa,parentId:t?.parentId??null,sourceId:t?.sourceId??null,value:t?.text??""});var jx=class{get path(){return this._core.path}_core;constructor(t){this._core=t}__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(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setText(t)}setRunConfig(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRunConfig(t)}addAttachment(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.addAttachment(t)}reset(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.reset()}clearAttachments(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.clearAttachments()}send(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.send(t)}cancel(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.cancel()}steerQueueItem(t){this.moveQueueItem(t,{lane:"steer",insertAfter:null})}moveQueueItem(t,e){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.moveQueueItem(t,e)}removeQueueItem(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.removeQueueItem(t)}setRole(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setRole(t)}startDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.startDictation()}stopDictation(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.stopDictation()}setQuote(t){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.setQuote(t)}subscribe(t){return this._core.subscribe(t)}_eventSubscriptionSubjects=new Map;unstable_on(t,e){let n=this._eventSubscriptionSubjects.get(t);return n||(n=new Gw({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}},uD=class extends jx{get path(){return this._core.path}get type(){return"thread"}_getState;constructor(t){const e=new dg({path:t.path,getState:()=>oD(t.getState()),subscribe:n=>t.subscribe(n)});super({path:t.path,getState:()=>t.getState(),subscribe:n=>e.subscribe(n)}),this._getState=e.getState.bind(e),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(t){return new iD(new Zn({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const e=this.getState().attachments[t];return e?{...e,source:"thread-composer"}:es},subscribe:e=>this._core.subscribe(e)}),this._core)}},cD=class extends jx{get path(){return this._core.path}get type(){return"edit"}_getState;_beginEdit;constructor(t,e){const n=new dg({path:t.path,getState:()=>lD(t.getState()),subscribe:i=>t.subscribe(i)});super({path:t.path,getState:()=>t.getState(),subscribe:i=>n.subscribe(i)}),this._beginEdit=e,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(t){return new rD(new Zn({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}.attachments[${t}]`},getState:()=>{const e=this.getState().attachments[t];return e?{...e,source:"edit-composer"}:es},subscribe:e=>this._core.subscribe(e)}),this._core)}};const dD="ui://",fD=t=>!!t?.startsWith(dD),hD=t=>t.display==="text"||t.display!=="questions"&&t.allowFreeform===!0,TS={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},pD=(t,e)=>{const n=t.questions??[];if(n.length===0)throw new Error(`Tool approval "${t.id}" has display "questions" but declares no questions`);const i=new Set;for(const a of n){if(i.has(a.id))throw new Error(`Tool approval "${t.id}" declares question "${a.id}" more than once`);i.add(a.id)}for(const a of Object.keys(e))if(!i.has(a))throw new Error(`Tool approval "${t.id}" has no question with id "${a}"`);for(const a of n){const o=Object.hasOwn(e,a.id)?e[a.id]:void 0,u=o?.optionIds??[],d=o?.text;if(!Array.isArray(u)||d!==void 0&&typeof d!="string")throw new Error(`Question "${a.id}" takes optionIds as an array and text as a string`);if(u.length===0&&(d===void 0||d.trim()===""))throw new Error(`Tool approval "${t.id}" is missing an answer to question "${a.id}"`);if(u.length>1&&!a.multiple)throw new Error(`Question "${a.id}" takes one option, not ${u.length}`);if(new Set(u).size!==u.length)throw new Error(`Question "${a.id}" lists an option more than once`);for(const f of u)if(!a.options?.some(p=>p.id===f))throw new Error(`Question "${a.id}" has no option with id "${f}"`);if(d!==void 0&&(a.options?.length??0)>0&&!a.allowFreeform)throw new Error(`Question "${a.id}" does not accept a typed answer; it must declare allowFreeform`)}},mD=(t,e)=>{const n=e.reason;if("answers"in e){if("approved"in e||"optionId"in e||"text"in e)throw new Error(`Tool approval "${t.id}" takes its answers alone, without approved, optionId or text`);return pD(t,e.answers),{approvalId:t.id,approved:!0,answers:e.answers,...n!=null&&{reason:n}}}if("approved"in e&&e.approved===!1&&!("optionId"in e)&&e.text===void 0)return{approvalId:t.id,approved:!1,...n!=null&&{reason:n}};throw new Error(`Tool approval "${t.id}" asks questions; respond with answers, or with approved: false to dismiss it`)},gD=(t,e)=>{if(t.display==="questions")return mD(t,e);if("answers"in e)throw new Error(`Tool approval "${t.id}" asks no questions; answers only resolve a display "questions" request`);const n=e.text;if(n!==void 0&&!hD(t))throw new Error(`Tool approval "${t.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let i,a;if("optionId"in e){const o=t.options?.find(u=>u.id===e.optionId);if(!o)throw new Error(`Tool approval has no option with id "${e.optionId}"`);if("approved"in e)i=e.approved;else{if(!Object.hasOwn(TS,o.kind))throw new Error(`Tool approval option "${o.id}" has a custom kind "${o.kind}"; respond with an explicit approved value instead`);i=TS[o.kind]}a=o.id}else if("approved"in e)i=e.approved;else{if(t.display!=="text"&&t.display!=="select")throw new Error(`Tool approval "${t.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);i=!0}return{approvalId:t.id,approved:i,...a!==void 0&&{optionId:a},...n!==void 0&&{text:n},...e.reason!=null&&{reason:e.reason}}};var wS=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;interactionState;interactionMessageId;interactionThreadId;interactionCore;constructor(t,e,n){this.contentBinding=t,this.messageApi=e,this.threadApi=n,this.interactionState=t.getState(),this.interactionMessageId=this.interactionState.type==="tool-call"?e?.getState().id:void 0,this.interactionThreadId=this.interactionState.type==="tool-call"?this.threadApi?.getStateState?.().threadId:void 0,this.interactionCore=this.interactionState.type==="tool-call"?n?.getState():void 0,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.unstable_recordInteraction=this.unstable_recordInteraction.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}getInteractionCore(){const t=this.interactionThreadId!==void 0&&this.threadApi?.getStateState?.().threadId===this.interactionThreadId?this.threadApi.getState():this.interactionCore;if(!t)throw new Error("Thread API is not available");return t}addToolResult(t){const e=this.interactionState;if(e.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const n=this.interactionMessageId;if(n===void 0)throw new Error("Message is not available");const i=e.toolName,a=e.toolCallId,o=XN.toResponse(t);this.getInteractionCore().addToolResult({messageId:n,toolName:i,toolCallId:a,result:o.result,isError:o.isError,...o.artifact!==void 0&&{artifact:o.artifact},...o.modelContent!==void 0&&{modelContent:o.modelContent}})}resumeToolCall(t){const e=this.interactionState;if(e.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");this.getInteractionCore().resumeToolCall({toolCallId:e.toolCallId,payload:t}),this.unstable_recordInteraction({type:"human-response",payload:t}).catch(()=>{})}respondToToolApproval(t){const e=this.interactionState;if(e.type!=="tool-call")throw new Error("Tried to respond to tool approval on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const n=this.getInteractionCore(),i=this.interactionMessageId===void 0?void 0:n.getMessageById(this.interactionMessageId)?.message.content.find(o=>o.type==="tool-call"&&o.toolCallId===e.toolCallId),a=i?.type==="tool-call"?i.approval:void 0;if(!a||a.approved!==void 0||a.resolution!==void 0)throw new Error("Tool call has no pending approval");return n.respondToToolApproval(gD(a,t))}async unstable_recordInteraction(t){const e=this.interactionState;if(e.type!=="tool-call")throw new Error("Tried to record interaction on non-tool message part");const n=this.interactionMessageId;if(n===void 0)throw new Error("Message is not available");const i=this.getInteractionCore();if(!i.unstable_recordToolInteraction)throw new Error("Runtime does not support recording tool interactions.");await i.unstable_recordToolInteraction({messageId:n,toolCallId:e.toolCallId,interaction:ON(t)})}subscribe(t){return this.contentBinding.subscribe(t)}};const xS=(t,e)=>{const n=t.content[e];if(!n)return es;const i=sx(t,e,n);return Object.freeze({...n,[Hc]:n[Hc],status:i})};var yD=class{get path(){return this._core.path}_core;_threadBinding;constructor(t,e){this._core=t,this._threadBinding=e,this.composer=new cD(new zc({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:n=>this._threadBinding.subscribe(n)}),()=>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(){const t=this._core.getState();return this._threadBinding.getState().deleteMessage(t.id)}reload(t={}){const e=this._getEditComposerRuntimeCore(),n=e??this._threadBinding.getState().composer,i=e??n,{runConfig:a=i.runConfig}=t,o=this._core.getState();if(o.role!=="assistant")throw new Error("Can only reload assistant messages");kx("Message reload",this._threadBinding.getState().startRun({parentId:o.parentId,sourceId:o.id,runConfig:a}))}speak(){const t=this._core.getState();return this._threadBinding.getState().speak(t.id)}stopSpeaking(){const t=this._core.getState();if(this._threadBinding.getState().speech?.messageId===t.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:t,comment:e}){const n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:t,...e!==void 0?{comment:e}:void 0})}switchToBranch({position:t,branchId:e}){const n=this._core.getState();if(e&&t)throw new Error("May not specify both branchId and position");if(!e&&!t)throw new Error("Must specify either branchId or position");const i=this._threadBinding.getState().getBranches(n.id);let a=e;if(t==="previous"?a=i[n.branchNumber-2]:t==="next"&&(a=i[n.branchNumber]),!a)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(a)}unstable_getCopyText(){return Qa(this.getState())}subscribe(t){return this._core.subscribe(t)}getMessagePartByIndex(t){if(t<0)throw new Error("Message part index must be >= 0");return new wS(new Zn({path:{...this.path,ref:`${this.path.ref}.content[${t}]`,messagePartSelector:{type:"index",index:t}},getState:()=>xS(this.getState(),t),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(t){return new wS(new Zn({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(t)}]`,messagePartSelector:{type:"toolCallId",toolCallId:t}},getState:()=>{const e=this._core.getState(),n=e.content.findIndex(i=>i.type==="tool-call"&&i.toolCallId===t);return n===-1?es:xS(e,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(t){return new aD(new Zn({path:{...this.path,ref:`${this.path.ref}.attachments[${t}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:t}},getState:()=>{const e=this.getState().attachments?.[t];return e?{...e,source:"message"}:es},subscribe:e=>this._core.subscribe(e)}))}};const vD=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{},...t.stream?{stream:t.stream}:{}}),bD=t=>({parentId:t.parentId??null,sourceId:t.sourceId??null,runConfig:t.runConfig??{}}),_D=(t,e)=>typeof e=="string"?{createdAt:new Date,parentId:t.at(-1)?.id??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:e}],attachments:[],metadata:{custom:{}}}:{createdAt:e.createdAt??new Date,parentId:e.parentId===void 0?t.at(-1)?.id??null:e.parentId,sourceId:e.sourceId??null,role:e.role??"user",content:e.content,attachments:e.attachments??[],metadata:e.metadata??{custom:{}},runConfig:e.runConfig??{},startRun:e.startRun},Vc=t=>{if(t.isRunning!==void 0)return t.isRunning;const e=t.messages.at(-1);return e?.role==="assistant"&&e.status.type==="running"},SD=(t,e)=>Object.freeze({threadId:e.id,metadata:e,capabilities:t.capabilities,isDisabled:t.isDisabled,isSendDisabled:t.isSendDisabled,isLoading:t.isLoading,hasEarlier:t.hasEarlier??!1,isLoadingEarlier:t.isLoadingEarlier??!1,isRunning:Vc(t),messages:t.messages,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,voice:t.voice});var zx=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(t,e){const n=new Zn({path:t.path,getState:()=>SD(t.getState(),e.getState()),subscribe:i=>{const a=t.subscribe(i),o=e.subscribe(i);return()=>si([a,o])}});this._stateBinding=n,this._threadBinding={path:t.path,getState:()=>t.getState(),getStateState:()=>n.getState(),outerSubscribe:i=>t.outerSubscribe(i),subscribe:i=>t.subscribe(i)},this.composer=new uD(new zc({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:i=>this._threadBinding.subscribe(i)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.loadEarlier=this.loadEarlier.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(t){kx("Message append",this._threadBinding.getState().append(_D(this._threadBinding.getState().messages,t)))}deleteMessage(t){return this._threadBinding.getState().deleteMessage(t)}subscribe(t){return this._stateBinding.subscribe(t)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(t){return this._threadBinding.getState().startRun(bD(t))}resumeRun(t){return this._threadBinding.getState().resumeRun(vD(t))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(t){this._threadBinding.getState().importExternalState(t)}cancelRun(){this._threadBinding.getState().cancelRun()}loadEarlier(){return this._threadBinding.getState().loadEarlier?.()??Promise.resolve()}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(t){return this._threadBinding.getState().subscribeVoiceVolume(t)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(t){this._threadBinding.getState().import(t)}reset(t){this._threadBinding.getState().reset(t)}getMessageByIndex(t){if(t<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${t}]`,messageSelector:{type:"index",index:t}},()=>{const e=this._threadBinding.getState().messages,n=e[t];if(n)return{message:n,parentId:e[t-1]?.id??null,index:t}})}getMessageById(t){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(t)}]`,messageSelector:{type:"messageId",messageId:t}},()=>this._threadBinding.getState().getMessageById(t))}_getMessageRuntime(t,e){return new yD(new Zn({path:t,getState:()=>{const{message:n,parentId:i,index:a}=e()??{},{messages:o,speech:u}=this._threadBinding.getState();if(!n||i===void 0||a===void 0)return es;const d=this._threadBinding.getState().getBranches(n.id);return{...n,[Hc]:n[Hc],index:a,isLast:o.at(-1)?.id===n.id,parentId:i,branchNumber:d.indexOf(n.id)+1,branchCount:d.length,speech:u?.messageId===n.id?u:void 0}},subscribe:n=>this._threadBinding.subscribe(n)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(t,e){let n=this._eventSubscriptionSubjects.get(t);return n||(n=new Gw({event:t,binding:this._threadBinding,notifyOnRebind:t==="modelContextUpdate"}),this._eventSubscriptionSubjects.set(t,n)),n.subscribe(e)}};const TD=(t,e)=>({attachments:[],attachmentAccept:"*",async addAttachment(){throw t},async removeAttachment(){throw t},isEditing:e,canCancel:!1,canSend:!1,isEmpty:!0,text:"",setText(){throw t},role:"user",setRole(){throw t},runConfig:{},setRunConfig(){throw t},async reset(){},async clearAttachments(){},send(){throw t},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw t},stopDictation(){},quote:void 0,setQuote(){throw t},subscribe(){return()=>{}},unstable_on(){return()=>{}}});var wD=class extends Li{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}async unstable_recordToolInteraction(t){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,answerToolCall:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}};const $a=new WeakMap,Ac=t=>{let e=$a.get(t);return e||(e=new AbortController,$a.set(t,e)),e.signal},CS=new WeakMap,Px=t=>{let e=CS.get(t);return e||(e=new AbortController,CS.set(t,e)),e},xD=t=>Px(t).signal,Bx=t=>{const e=$a.get(t);e?.signal.aborted||($a.delete(t),e?.abort())},hc=(t,e)=>{try{t()}catch(n){console.error(`[assistant-ui] ${e} cleanup threw while discarding a thread runtime`,n)}},Ux=t=>{t.voice&&hc(()=>t.disconnectVoice(),"Voice"),t.composer.dictation&&hc(()=>t.composer.stopDictation(),"Dictation");const e=t.__internal_getEditComposers?.()??t.messages.map(n=>t.getEditComposer(n.id));for(const n of e)n?.dictation&&hc(()=>n.stopDictation(),"Dictation");t.speech&&hc(()=>t.stopSpeaking(),"Speech")},Lx=t=>{Ux(t),Bx(t)},ES=t=>{const e=$a.get(t)??new AbortController;$a.set(t,e),e.abort(),Px(t).abort(),Ux(t)};var rl=class{get path(){return this._core.path}_core;_threadListBinding;constructor(t,e){this._core=t,this._threadListBinding=e,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(t){const e=this._core.getState();return this._threadListBinding.switchToThread(e.id,t)}rename(t){const e=this._core.getState();return this._threadListBinding.rename(e.id,t)}updateCustom(t){const e=this._core.getState();if(!this._threadListBinding.updateCustom)throw new Error("Thread list runtime does not support updating custom metadata");return this._threadListBinding.updateCustom(e.id,t)}archive(){const t=this._core.getState();return this._threadListBinding.archive(t.id)}unarchive(){const t=this._core.getState();return this._threadListBinding.unarchive(t.id)}delete(){const t=this._core.getState();return this._threadListBinding.delete(t.id)}initialize(){const t=this._core.getState();return this._threadListBinding.initialize(t.id)}generateTitle(t){const e=this._core.getState();return this._threadListBinding.generateTitle(e.id,t)}unstable_on(t,e){let n=this._core.getState().isMain,i=this._core.getState().id;return this.subscribe(()=>{const a=this._core.getState(),o=a.isMain,u=a.id;n===o&&i===u||(n=o,i=u,!(t==="switchedTo"&&!o)&&(t==="switchedAway"&&o||Wn([e],{},`Thread list item "${t}"`)))})}subscribe(t){return this._core.subscribe(t)}detach(){const t=this._core.getState();this._threadListBinding.detach(t.id)}__internal_getRuntime(){return this}};const op=Promise.resolve(),CD=()=>{},ED=t=>({mainThreadId:t.mainThreadId,newThreadId:t.newThreadId,threadIds:t.threadIds,archivedThreadIds:t.archivedThreadIds,isLoading:t.isLoading,loadError:t.loadError,isLoadingMore:t.isLoadingMore??!1,hasMore:t.hasMore??!1,threadItems:t.threadItems}),pc=(t,e)=>{if(e===void 0)return es;const n=t.getItemById(e);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===t.mainThreadId,isRunning:t.unstable_isThreadRunning?.(n.id)??!1}:es};var qx=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(t,e=zx){this._core=t,this._runtimeFactory=e;const n=new dg({path:{},getState:()=>ED(t),subscribe:i=>t.subscribe(i)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new rl(new Zn({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>pc(this._core,this._core.mainThreadId),subscribe:i=>this._core.subscribe(i)}),this._core),this.main=new e(new zc({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>t.getMainThreadRuntimeCore(),subscribe:i=>t.subscribe(i)}),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(t,e){return this._core.switchToThread(t,e)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(t){return this._core.unstable_subscribeThreadEvents?.(t)??CD}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??op}reloadMainThread(){return this._core.reloadMainThread?.()??op}loadMore(){return this._core.loadMore?.()??op}getState(){return this._getState()}subscribe(t){return this._stateBinding.subscribe(t)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(t){return new Zn({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>pc(this._core,t),subscribe:e=>this._core.subscribe(e)})}getById(t){return new this._runtimeFactory(new zc({path:{ref:`threads[threadId=${JSON.stringify(t)}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>this._core.getThreadRuntimeCore(t),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(t))}getItemByIndex(t){return new rl(new Zn({path:{ref:`threadItems[${t}]`,threadSelector:{type:"index",index:t}},getState:()=>pc(this._core,this._core.threadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(t){return new rl(new Zn({path:{ref:`archivedThreadItems[${t}]`,threadSelector:{type:"archiveIndex",index:t}},getState:()=>pc(this._core,this._core.archivedThreadIds[t]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(t){return new rl(this._createItemStateBinding(t),this._core)}},Sg=class{threads;_thread;_core;constructor(t){this._core=t,this.threads=new qx(t.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(t){return this._core.registerModelContextProvider(t)}},Tg=class{_contextProvider=new fg;registerModelContextProvider(t){return this._contextProvider.registerModelContextProvider(t)}getModelContextProvider(){return this._contextProvider}};const Hx={fromArray:t=>{const e=t.map(n=>_l(n,n.id??un(),SS(n.content)));return{messages:e.map((n,i)=>({parentId:i>0?e[i-1].id:null,message:n}))}},fromBranchableArray:(t,e)=>({...e?.headId!==void 0?{headId:e.headId}:void 0,messages:t.map(({message:n,parentId:i})=>{if(!n.id)throw new Error("ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.");return{parentId:i,message:_l(n,n.id,SS(n.content))}})})},mc=t=>{let e=t;for(;e.next;)e=e.next;return"current"in e?e:null},AD=(t,e)=>{const n=new Set(t.map(u=>u.message.id)),i=new Set,a=new Map,o=[];for(const u of t){const{parentId:d}=u;if(d!==null&&n.has(d)&&!i.has(d)&&!e(d)){const f=a.get(d);f?f.push(u):a.set(d,[u]);continue}for(let f=o.push(u)-1;f<o.length;f++){const{id:p}=o[f].message;if(i.has(p))continue;i.add(p);const m=a.get(p);m&&(a.delete(p),o.push(...m))}}for(const u of a.values())o.push(...u);return o},ID=t=>{const e=new Set(t.messages.map(m=>m.message.id)),n=new Map,i=[];for(const{message:m,parentId:y}of t.messages){if(y===null)continue;const v=n.get(y);v?v.push(m.id):n.set(y,[m.id]),e.has(y)||i.push(m.id)}const a=new Set;for(let m=0;m<i.length;m++){const y=i[m];if(!a.has(y)){a.add(y);for(const v of n.get(y)??[])i.push(v)}}const o=t.headId!=null&&!e.has(t.headId);if(a.size===0&&!o)return{repository:t,droppedIds:[]};const u=[],d=new Set,f=t.messages.filter(({message:m,parentId:y})=>a.has(m.id)?(u.push(m.id),!1):(y!==null&&d.add(y),!0));let{headId:p}=t;if(p!=null&&(o||a.has(p))){p=null;for(const{message:m}of f)d.has(m.id)||(p=m.id)}return{repository:{...t,messages:f,...p!==void 0&&{headId:p}},droppedIds:u}};var RD=class{_value=null;func;constructor(t){this.func=t}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Vx=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(t,e){const n=[{message:t,level:e}];for(;n.length>0;){const i=n.pop();i.message.level=i.level;for(const a of i.message.children){const o=this.messages.get(a);o&&n.push({message:o,level:i.level+1})}}}selectPathTo(t){for(let e=t;e;e=e.prev)(e.prev??this.root).next=e}performOp(t,e,n){const i=e.prev??this.root,a=t??this.root;if(!(n==="relink"&&i===a)){if(n==="relink"){for(let o=t;o;o=o.prev)if(o.current.id===e.current.id)throw new 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"&&(i.children=i.children.filter(o=>o!==e.current.id),i.next===e)){const o=i.children.at(-1),u=o?this.messages.get(o):null;if(u===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");i.next=u}if(n!=="cut"){a.children=[...a.children,e.current.id],e.prev=t,mc(e)===this.head?this.selectPathTo(e):a.next===null&&(a.next=e,this.head===a&&(this.head=mc(e)));const o=t?t.level+1:0;this.updateLevels(e,o)}}}_messages=new RD(()=>{const t=new Array((this.head?.level??-1)+1);for(let e=this.head;e;e=e.prev)t[e.level]=e.current;return t});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return t?.current.id??null}getMessages(t){if(t===void 0||t===this.head?.current.id)return this._messages.value;const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const n=new Array(e.level+1);for(let i=e;i;i=i.prev)n[i.level]=i.current;return n}addOrUpdateMessage(t,e){const n=this.messages.get(e.id),i=t?this.messages.get(t):null;if(i===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(n){this.performOp(i,n,"relink"),n.current=e,this._messages.dirty();return}const a={prev:i,current:e,next:null,children:[],level:i?i.level+1:0};this.messages.set(e.id,a),this.performOp(i,a,"link"),this.head===i&&(this.head=a,this.selectPathTo(a)),this._messages.dirty()}getMessage(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:e.prev?.current.id??null,message:e.current,index:e.level}}deleteMessage(t,e){const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const i=e===void 0?n.prev:e===null?null:this.messages.get(e);if(i===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(let a=i;a;a=a.prev)if(a===n)throw new Error("MessageRepository(deleteMessage): Replacement is the deleted message or one of its descendants. This is likely an internal bug in assistant-ui.");for(const a of n.children){const o=this.messages.get(a);if(!o)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(i,o,"relink")}this.performOp(null,n,"cut"),this.messages.delete(t),this.head===n&&(this.head=mc(i??this.root)),this._messages.dirty()}hasChildren(t){return(this.messages.get(t)?.children.length??0)>0}getBranches(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:n}=e.prev??this.root;return n}evictOffBranchOptimisticMessages(t,e){if(!t)return;const n=new Set;for(let a=e;a;a=a.prev)n.add(a.current.id);const i=[];for(let a=t;a&&!n.has(a.current.id);a=a.prev)a.current.metadata?.isOptimistic&&i.push(a.current.id);for(const a of i)this.messages.has(a)&&this.deleteMessage(a)}switchToBranch(t){const e=this.messages.get(t);if(!e)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const n=this.head;this.selectPathTo(e),this.head=mc(e),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}setHead(t,e){if(t===null){this.clear();return}const n=this.messages.get(t);if(!n)throw new Error(`MessageRepository(${e?"resetHead":"import"}): Branch not found. This is likely an internal bug in assistant-ui.`);const i=this.head;if(e&&n.children.length>0){const a=[...n.children];for(;a.length>0;){const o=a.pop(),u=this.messages.get(o);if(u){for(const d of u.children)a.push(d);this.messages.delete(o)}}n.children=[],n.next=null}this.head=n,this.selectPathTo(n),this.evictOffBranchOptimisticMessages(i,this.head),this._messages.dirty()}resetHead(t){this.setHead(t,!0)}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){const t=[],e=[...this.root.children].reverse();for(;e.length>0;){const n=this.messages.get(e.pop());if(!n)continue;for(let a=n.children.length-1;a>=0;a--)e.push(n.children[a]);if(n.current.metadata?.isOptimistic)continue;let i=n.prev;for(;i&&i.current.metadata?.isOptimistic;)i=i.prev;t.push({message:n.current,parentId:i?.current.id??null})}return{headId:this.exportedHeadId(),messages:t}}exportedHeadId(){let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;if(t===this.head)return t?.current.id??null;for(;;){const e=this.exportedChild(t??this.root);if(!e)return t?.current.id??null;t=e}}exportedChild(t){const e=t.next;if(e){if(!e.current.metadata?.isOptimistic)return e;const a=this.exportedChild(e);if(a)return a}const n=e?t.children.indexOf(e.current.id):t.children.length,i=[...t.children.slice(0,n).reverse(),...t.children.slice(n+1).reverse()];for(const a of i){const o=this.messages.get(a);if(!o)continue;if(!o.current.metadata?.isOptimistic)return o;const u=this.exportedChild(o);if(u)return u}return null}import({headId:t,messages:e}){const n=AD(e,a=>this.messages.has(a));for(const{message:a,parentId:o}of n)this.addOrUpdateMessage(o,a);const i=t??n.at(-1)?.message.id??null;this.setHead(i,!1)}};const ti=Object.freeze([]),MD=new WeakMap,kD=t=>{const e=[...t.content,...(t.attachments??[]).flatMap(i=>(i.content??[]).filter(a=>a.type!=="text"))],n=[];for(const i of e)i.type==="file"||i.type==="text"?n.push(i):i.type==="image"&&n.push({type:"file",data:i.image,mimeType:"image/*",...i.filename!==void 0&&{filename:i.filename}});return n},ND=t=>{let e={queue:ti,steer:ti};const n=new Map,i=new Map,a=new Set;let o=!1,u=!1,d=!1,f=!1,p=$=>$,m,y=[],v=[],b=!1,T=0,w=0,x;const E=$=>{if(!$.started){$.suppressedAt===T&&D(),y=y.filter(M=>M!==$);const re=v.includes($);v=v.filter(M=>M!==$),re&&$!==x&&(v.length===0&&y.length>0&&v.push(y.pop()),o=v.length>0,H())}return $===x},C=$=>{$ instanceof Error&&$.name==="AbortError"||console.error("[MessageQueue] run rejected",$)},R=($,re)=>{$!==void 0&&Promise.resolve($).catch(M=>{try{re()}catch(N){C(N)}C(M)})},O=()=>{Wn(a,void 0,"Message queue")},L=$=>{e=$,ye.items=$.queue,ye.steerItems=$.steer,O()},I=($,re)=>({id:$,prompt:Qa(re),parts:kD(re)}),P=($,re,M=0)=>{d=!0,n.set(re.id,re.message),re.transform&&i.set(re.id,re.transform),L({...e,[$]:[...e[$].slice(0,M),re.item,...e[$].slice(M)]})},k=$=>{if(e.steer.some(re=>re.id===$))return"steer";if(e.queue.some(re=>re.id===$))return"queue"},H=()=>{if(o||d||f)return;const $=e.steer.length>0?"steer":"queue",re=e[$][0];if(!re)return;const M=n.get(re.id);if(!M)return;const N=i.get(re.id);i.delete(re.id),o=!0,n.delete(re.id);const te={id:re.id,item:re,message:M,transform:N},ie={started:!1,busyEdge:T};x=ie;const pe=T,de=w;u=!0,L({...e,[$]:e[$].slice(1)}),u=!1;const B=()=>{E(ie)&&T===pe&&(o=!1,w===de?P($,te):H())};try{R(t.run(N?N(M):p(M),{steer:!1}),B)}catch(ce){throw B(),ce}},V=($,re="steer",M=0)=>{d=!1;const N=w;y.push(...v.length?v:[x]),v=[];const te={started:!1,busyEdge:T};x=te;const ie=(B=!1)=>{if(!E(te)||B)return;const ce=y.length,fe=y.pop();v=ce>0?[fe]:[],o=ce>0,w===N?P(re,$,M):H()};b=!0;try{t.cancel()}catch(B){throw ie(),B}finally{b=!1}o=!0;const pe=T,de=()=>{ie(T!==pe)};try{R(t.run($.transform?$.transform($.message):p($.message),{steer:!0}),de)}catch(B){throw de(),B}},z=($,re)=>{d=!1;const M=un(),N=m;m=void 0,N&&i.set(M,N),n.set(M,re),L({...e,[$]:[...e[$],I(M,re)]}),H()},q=$=>{z("queue",$)},W=$=>{if(o&&!u&&t.cancel){const re=un(),M=m;m=void 0,V({id:re,item:I(re,$),message:$,transform:M});return}z("steer",$)},X=($,re)=>{const M=k($);if(!M)throw new Error(`Unknown queue item "${$}".`);const N=re.lane??M,te=e[M].findIndex(Pe=>Pe.id===$),ie=e[M][te],pe=(N===M?e[M]:e[N]).filter(Pe=>Pe.id!==$),de=Pe=>{if(Pe===$)throw new Error(`Queue item "${$}" cannot anchor itself.`);const $e=pe.findIndex(ve=>ve.id===Pe);if($e===-1)throw new Error(`Unknown anchor "${Pe}" in lane "${N}".`);return $e},{insertAfter:B,insertBefore:ce}=re;let fe;if(B===void 0&&ce===void 0)fe=N===M?e[M].findIndex(Pe=>Pe.id===$):pe.length;else if(B!==void 0&&ce!==void 0){const Pe=B===null?-1:de(B);if((ce===null?pe.length:de(ce))!==Pe+1)throw new Error(`insertAfter "${B}" and insertBefore "${ce}" are not adjacent in lane "${N}".`);fe=Pe+1}else B!==void 0?fe=B===null?0:de(B)+1:fe=ce===null?pe.length:de(ce);if(B===void 0&&ce===void 0&&N==="steer"&&M!=="steer"&&o&&!u&&t.cancel){const Pe=n.get($),$e=i.get($);i.delete($),n.delete($),L({queue:e.queue.filter(ve=>ve.id!==$),steer:e.steer}),V({id:$,item:ie,message:Pe,transform:$e},M,te);return}const ge=[...pe.slice(0,fe),ie,...pe.slice(fe)],Oe={...e,[N]:ge};N!==M&&(Oe[M]=e[M].filter(Pe=>Pe.id!==$)),L(Oe),H()},Z=($,re)=>{const M=k($);if(!M)throw new Error(`Unknown queue item "${$}".`);n.set($,re),L({...e,[M]:e[M].map(N=>N.id===$?I($,re):N)})},ee=$=>{n.delete($)&&(i.delete($),L({queue:e.queue.filter(re=>re.id!==$),steer:e.steer.filter(re=>re.id!==$)}))},oe=()=>{b||u||o&&v.length===0&&(d=!0,v=[x])},he=$=>{p=$},ye={items:e.queue,steerItems:e.steer,enqueue:q,steer:W,move:X,edit:Z,remove:ee,__internal_setDispatchTransform:he,__internal_notifyCancelled:oe};MD.set(he,{bindNext:()=>{m=p},getCurrent:()=>p});const D=()=>{if(y.length>0){const $=y.shift();$&&!$.started&&T>$.busyEdge&&($.suppressedAt=T);return}v.shift(),o=!1,H()};return{adapter:ye,hold:()=>{f=!0},release:()=>{f=!1,H()},notifyBusy:()=>{d=!1,v.length>0?(y.push(...v),v=[],x=void 0):x&&(x.started=!0),o=!0,T++},notifyIdle:D,notifyCancelled:oe,clear:()=>{w++,n.clear(),i.clear(),m=void 0,L({queue:ti,steer:ti})},subscribe:$=>(a.add($),()=>{a.delete($)})}};function AS(t,e){if(e==="*")return!0;const n=e.split(",").map(o=>o.trim().toLowerCase()),i=t.name.toLowerCase(),a=t.type.split(";",1)[0].trim().toLowerCase();for(const o of n){if(o.startsWith(".")&&i.endsWith(o)||o.includes("/")&&o===a)return!0;if(o.endsWith("/*")){const u=o.split("/")[0];if(a.startsWith(`${u}/`))return!0}}return!1}function OD(t){const e=un();return t.type==="image"?{id:e,type:"image",name:t.filename??"image",content:[t],status:{type:"complete"}}:t.type==="file"?{id:e,type:"document",name:t.filename??"document",contentType:t.mimeType,content:[t],status:{type:"complete"}}:t.type==="audio"?{id:e,type:"audio",name:`audio.${t.audio.format}`,contentType:`audio/${t.audio.format}`,content:[t],status:{type:"complete"}}:{id:e,type:"data",name:t.name,content:[t],status:{type:"complete"}}}function DD(t){const e=[];for(const n of t)n.type!=="text"&&e.push(OD(n));return e}const jD=t=>"content"in t&&!("lastModified"in t),As=t=>t.status.type==="complete";var zD=class{operations=new Set;uploading=new Map;start(){const t={cancelled:!1,attachmentIds:new Set};return this.operations.add(t),t}accept(t,e){if(t.cancelled)return!1;t.attachmentIds.add(e.id);const n=this.uploading.get(e.id);return n?.operation!==t&&(n||e.status.type==="running")&&this.uploading.set(e.id,{operation:t,waiters:n?.waiters??new Set}),e.status.type!=="running"&&this.settle(e.id,t),!0}finish(t){this.operations.delete(t);for(const e of t.attachmentIds)this.settle(e,t)}isCancelled(t){return t.cancelled}cancel(t){for(const e of[...this.operations])e.attachmentIds.has(t)&&(e.cancelled=!0,this.operations.delete(e));this.settle(t)}cancelAll(t){for(const e of[...this.operations])t&&[...e.attachmentIds].some(n=>t.has(n))||(e.cancelled=!0,this.operations.delete(e));for(const e of[...this.uploading.keys()])t?.has(e)||this.settle(e)}whenSendable(t){const e=this.uploading.get(t);if(e)return new Promise(n=>e.waiters.add(n))}settle(t,e){const n=this.uploading.get(t);if(n&&!(e&&n.operation!==e)){this.uploading.delete(t);for(const i of n.waiters)i()}}};const PD=async(t,e)=>{if(Symbol.asyncIterator in t){let n,i=!1;for await(const a of t){if(n===void 0&&(n=a.id),a.id!==n){i||(console.warn("[assistant-ui] AttachmentAdapter.add() yielded multiple attachment ids; only the first id is accepted"),i=!0);continue}if(!e(a))break}}else e(await t)};var BD=class{entries=new WeakMap;removals=new WeakMap;beginRemoval(t){const e=this.removals.get(t);return e?.phase==="pending"?!1:(e?e.phase="pending":this.removals.set(t,{phase:"pending",dispatched:!1,retried:!1,abandoned:!1}),!0)}abandonRemoval(t){const e=this.removals.get(t);e&&(e.abandoned=!0),this.removals.delete(t)}isRemoved(t){return this.removals.has(t)}shouldRemoveOnClear(t){const e=this.removals.get(t);return!e||e.dispatched&&e.retried&&e.phase==="failed"}isRemovalPending(t){return this.removals.get(t)?.phase==="pending"}async remove(t,e,n){const i=this.removals.get(t);try{if(!As(t)){if(!e)throw new Error("Attachments are not supported");await e.remove(t)}i.phase="complete"}catch(a){throw i.phase="failed",n?.(a,a instanceof Error?a.message:String(a)),this.retryDispatched(i),a}}dispatchRemoval(t,e){const n=this.removals.get(t);n&&(n.dispatched=!0,n.retry=e,this.retryDispatched(n))}retryDispatched(t){t.abandoned||!t.dispatched||t.phase!=="failed"||t.retried||!t.retry||(t.retried=!0,t.retry())}restore(t){const e=this.removals.get(t);if(!e||e.dispatched||e.phase!=="failed")return t;const n={...t},i=this.entries.get(t);return i&&this.entries.set(n,i),n}adoptFrom(t,e){const n=t.removals.get(e);n&&this.removals.set(e,n);const i=t.entries.get(e);i&&this.entries.set(e,i)}isSameRemoval(t,e){const n=this.removals.get(t);return n!==void 0&&n===this.removals.get(e)}async send(t,e,n){if(As(t))return t;const i=this.entries.get(t)??{};if(i.result)return i.result;if(!e)throw new Error("Attachments are not supported");this.entries.set(t,i);const a=await e.send(t,n?{signal:n}:void 0);return i.result=a,a}transfer(t,e){const n=this.entries.get(t);n&&this.entries.set(e,n);const i=this.removals.get(t);return i&&this.removals.set(e,i),e}},UD=class{_host;constructor(t){this._host=t}rebase(t){if(!this._dictation)return;this._dictationBaseText=t,this._currentInterimText="";const{status:e,inputDisabled:n}=this._dictation;this._dictation=n?{status:e,inputDisabled:n}:{status:e}}cancel(){if(!this._dictationSession)return;const t=this._activeDictationSessionId;try{this._dictationSession.cancel()}catch(e){console.error("[assistant-ui] Dictation session cancel threw",e)}finally{this._cleanupDictation({sessionId:t})}}_dictation;_dictationSession;_stoppingDictationSession;_dictationUnsubscribes=[];_dictationBaseText="";_currentInterimText="";_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(t,e){return this._activeDictationSessionId===t&&this._dictationSession===e}startDictation(){const t=this._host.getAdapter();if(!t)throw new Error("Dictation adapter not configured");const e=this._dictationSession!==void 0;if(this._dictationSession){const f=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(f)}const n=t.disableInputDuringDictation??!1;this._dictationBaseText=this._host.getText(),this._currentInterimText="";let i;try{i=t.listen()}catch(f){if(e)try{this._host.notify()}catch(p){console.error("[assistant-ui] Dictation replacement rollback notification threw",p)}throw f}this._dictationSession=i;const a=++this._dictationSessionIdCounter;this._activeDictationSessionId=a,this._dictation={status:i.status,inputDisabled:n};try{this._host.notify()}catch(f){console.error("[assistant-ui] Dictation start notification threw",f)}if(!this._isActiveSession(a,i))return;const o=[],u=()=>{for(const f of o.splice(0))try{f()}catch(p){console.error("[assistant-ui] Dictation cleanup threw",p)}},d=f=>(o.push(f),this._isActiveSession(a,i)?!0:(u(),!1));try{if(!d(i.onSpeech(p=>{if(!this._isActiveSession(a,i))return;const m=p.isFinal!==!1,y=this._dictationBaseText&&!this._dictationBaseText.endsWith(" ")&&p.transcript?" ":"";if(m){if(this._dictationBaseText=this._dictationBaseText+y+p.transcript,this._currentInterimText="",this._host.setText(this._dictationBaseText),this._dictation){const{transcript:v,...b}=this._dictation;this._dictation=b}this._host.notify()}else this._currentInterimText=y+p.transcript,this._host.setText(this._dictationBaseText+this._currentInterimText),this._dictation&&(this._dictation={...this._dictation,transcript:p.transcript}),this._host.notify()}))||!d(i.onSpeechStart(()=>{this._isActiveSession(a,i)&&(this._dictation={status:{type:"running"},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._host.notify())}))||!d(i.onSpeechEnd(()=>{this._cleanupDictation({sessionId:a})})))return;const f=setInterval(()=>{this._isActiveSession(a,i)&&i.status.type==="ended"&&this._cleanupDictation({sessionId:a})},100);if(!d(()=>clearInterval(f)))return;this._dictationUnsubscribes.push(...o.splice(0))}catch(f){if(u(),this._isActiveSession(a,i))try{i.cancel()}catch(p){console.error("[assistant-ui] Dictation session cancel threw",p)}finally{this._cleanupDictation({sessionId:a})}throw f}}stopDictation(){if(!this._dictationSession)return;const t=this._dictationSession;if(this._stoppingDictationSession===t)return;this._stoppingDictationSession=t;const e=this._activeDictationSessionId,n=()=>this._cleanupDictation({sessionId:e});this._stopDictationSession(t,n)}_stopDictationSession(t,e=()=>{}){let n;try{n=t.stop()}catch(i){console.error("[assistant-ui] Dictation session stop threw",i),e();return}n.then(e,i=>{console.error("[assistant-ui] Dictation session stop rejected",i),e()})}_cleanupDictation(t){if(t?.sessionId!==void 0&&t.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;const e=n=>{try{n()}catch(i){console.error("[assistant-ui] Dictation cleanup threw",i)}};try{const n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._stoppingDictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText="",this._currentInterimText="";for(const i of n)e(i);t?.notify!==!1&&e(()=>this._host.notify())}finally{this._isCleaningDictation=!1}}},am=class extends Li{isEditing=!0;enrichWithComposerMetadata(t,e){return e?{...t,metadata:{...t.metadata,custom:{...t.metadata?.custom,...e}}}:t}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??"*"}_attachments=[];get attachments(){return this._attachments}setAttachments(t){this._attachments=t,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.sendableAttachments.length}get sendableAttachments(){return this.attachments.filter(t=>!this._attachmentSends.isRemoved(t))}_text="";_dictationSessionController=new UD({getAdapter:()=>this.getDictationAdapter(),getText:()=>this._text,setText:t=>{this._text=t},notify:()=>this._notifySubscribers()});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(t){this._quote!==t&&(this._quote=t,this._notifySubscribers())}setText(t){this._text!==t&&(this._text=t,this._rebaseDictation(t),this._notifySubscribers())}_rebaseDictation(t){this._dictationSessionController.rebase(t)}setRole(t){this._role!==t&&(this._role=t,this._notifySubscribers())}setRunConfig(t){this._runConfig!==t&&(this._runConfig=t,this._notifySubscribers())}_submission;_submissionSend;_inTransit=[];_inTransitSubmissions=[];_sendGeneration=0;_draftEpoch=0;_attachmentAddOperations=new zD;_attachmentSends=new BD;get submission(){return this._submission}get inTransit(){return this._inTransitSubmissions}get isSubmitting(){return this._submission!==void 0}get detachesDraftOnSend(){return!0}threadMessageIds(t){}settleInTransit(){if(this._inTransit.length===0)return;const t=new Set,e=this._inTransit.filter(({submission:n,known:i})=>{const a=this.threadMessageIds(n.role)?.find(o=>!i.has(o)&&!t.has(o));return a===void 0?!0:(t.add(a),!1)});e.length!==this._inTransit.length&&(this._setInTransit(e.map(n=>({...n,known:new Set([...n.known,...t])}))),this._notifySubscribers())}_setInTransit(t){this._inTransit=t,this._inTransitSubmissions=t.map(e=>e.submission)}_leaveTransit(t){const e=this._inTransit.filter(n=>n.submission!==t);return e.length===this._inTransit.length?!1:(this._setInTransit(e),!0)}_cancelAttachmentAdd(t){this._attachmentAddOperations.cancel(t)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._rebaseDictation(""),this._notifySubscribers()}_draftUploadsToRemove(){return this._attachments.filter(t=>!As(t)&&this._attachmentSends.shouldRemoveOnClear(t))}async _onClearAttachments(t){const e=this.getAttachmentAdapter();e&&await Promise.all(t.map(n=>(this._attachmentSends.beginRemoval(n),this._attachmentSends.remove(n,e))))}async reset(){this._cancelAllAttachmentAdds(),this._draftEpoch++,this._sendGeneration++;const t=this._discardSubmission();if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0&&this._quote===void 0){await t;return}this._role="user",this._runConfig={},this._quote=void 0;const e=this._onClearAttachments(this._draftUploadsToRemove());this._emptyTextAndAttachments(),await Promise.all([e,t])}async clearAttachments(){this._draftEpoch++,this._attachmentAddOperations.cancelAll(this.detachesDraftOnSend?new Set(this._submission?.attachments.map(n=>n.id)):void 0);const t=this._draftUploadsToRemove();if(this.isSubmitting)for(const n of this._attachments)this._attachmentSends.beginRemoval(n);const e=this._onClearAttachments(t);this.setAttachments([]),await e}async send(t){if(!this.canSend||this.isSubmitting)return;this._dictationSessionController.cancel();const e=this.sendableAttachments;if(!this.text.trim()&&e.length===0)return;const n={id:un(),role:this.role,text:this.text,quote:this._quote,attachments:e},i={options:t,runConfig:this.runConfig},a=e.filter(As),o=a.length===e.length;if(o||(this._submission=n,this._submissionSend={...i,controller:new AbortController}),this.detachesDraftOnSend){const d=new Set(e);this._attachments=this._attachments.filter(f=>!d.has(f)),this._text="",this._rebaseDictation(""),this._quote=void 0}const u=++this._sendGeneration;if(this._notifySubscribers(),o){this._dispatch(u,n,a,i,!1);return}await this._prepareSubmission(u)}async _prepareSubmission(t){const e=this.getAttachmentAdapter(),n=(this._submission?.attachments??[]).flatMap(m=>{const y=this._attachmentAddOperations.whenSendable(m.id);return y?[y]:[]});if(n.length>0&&(await Promise.all(n),t!==this._sendGeneration))return;const i=this._submission,a=this._submissionSend;if(!i||!a)return;const o=i.attachments.filter(m=>!this._attachmentSends.isRemoved(m));for(const m of o)this._cancelAttachmentAdd(m.id);const u=await Promise.allSettled(o.map(m=>this._attachmentSends.send(m,e,a.controller.signal)));if(t!==this._sendGeneration)return;const d=u.find(m=>m.status==="rejected");if(d){this._returnSubmissionToDraft(o,u,d.reason);return}const f=u.flatMap((m,y)=>this._attachmentSends.isRemoved(o[y])||m.status==="rejected"?[]:[m.value]),p=this._submission??i;if(!p.text.trim()&&f.length===0){this._endSubmission(),this._returnToDraft(p);return}this._dispatch(t,p,f,a,!0)}_dispatch(t,e,n,i,a){const o={createdAt:new Date,role:e.role,content:e.text?[{type:"text",text:e.text}]:[],attachments:n,runConfig:i.runConfig,metadata:{custom:{...e.quote?{quote:e.quote}:{}}}},u={...e,attachments:n},d=this.queue.length;if(a){if(this._submission=void 0,this._submissionSend=void 0,!this.detachesDraftOnSend){const v=new Map(n.map(b=>[b.id,b]));this._attachments=this._attachments.map(b=>v.get(b.id)??b)}const y=this.threadMessageIds(e.role);y&&this._setInTransit([...this._inTransit,{submission:u,known:new Set(y)}])}const f=this.cleanupOwner,p=f._draftEpoch;let m;try{m=this.handleSend(o,i.options)}catch(y){console.error("[assistant-ui] Failed to send the message",y),this._leaveTransit(u),t===this._sendGeneration?this._returnToDraft(u):this._notifySubscribers();return}if(m&&m.catch(y=>{const v=this._leaveTransit(u);t===this._sendGeneration&&Mx(y)?this._returnToDraft(u):v&&this._notifySubscribers()}),a)for(const y of e.attachments)As(y)||this._attachmentSends.dispatchRemoval(y,()=>{this._retrySubmittedRemoval(y,f,p)});this._notifyEventSubscribers("send",{chars:e.text.length,attachments:n.length}),a&&(this.queue.length>d&&this._leaveTransit(u),this._notifySubscribers(),this.settleInTransit())}_returnSubmissionToDraft(t,e,n){const i=this._submission;if(!i)return;const a=new Map;e.forEach((u,d)=>{u.status==="rejected"&&a.set(t[d].id,u.reason)});const o=i.attachments.map(u=>{if(!a.has(u.id)||As(u)||this._attachmentSends.isRemoved(u))return u;const d=a.get(u.id);return this._attachmentSends.transfer(u,{...u,status:{type:"incomplete",reason:"error",message:d instanceof Error?d.message:String(d)}})});this._endSubmission(),this._returnToDraft({...i,attachments:o}),console.error("[assistant-ui] Failed to send attachments",n)}_endSubmission(){this._sendGeneration++,this._submission=void 0,this._submissionSend=void 0}__internal_dispose(){this._cancelAllAttachmentAdds(),this._submission&&(this._submissionSend?.controller.abort(),this._endSubmission(),this._notifySubscribers())}cancelSubmission(){const t=this._submission;t&&(this._submissionSend?.controller.abort(),this._endSubmission(),this._returnToDraft(t))}_returnToDraft(t){if(this.detachesDraftOnSend){const e=t.attachments.map(i=>this._attachmentSends.restore(i));this._attachments=[...e,...this._attachments];const n=[t.text,this._text].filter(Boolean).join(`
16
- `);this._text=n,this._rebaseDictation(n),this._quote=this._quote??t.quote}else{const e=new Map(t.attachments.filter(n=>!this._attachmentSends.isRemoved(n)).map(n=>[n.id,n]));this._attachments=this._attachments.map(n=>this._attachmentSends.isRemoved(n)?this._attachmentSends.restore(n):this._attachmentSends.restore(e.get(n.id)??n))}this._notifySubscribers()}async _discardSubmission(){const t=this._submission;if(!t)return;this._submissionSend?.controller.abort(),this._endSubmission(),this._notifySubscribers();const e=this.getAttachmentAdapter();if(!e)return;const n=new Set(this._attachments.map(i=>i.id));await Promise.all(t.attachments.filter(i=>!As(i)&&!n.has(i.id)&&!this._attachmentSends.isRemovalPending(i)).map(async i=>e.remove(i)))}restoreDraft(t){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=t.text,this._rebaseDictation(t.text),this._quote=t.quote,this._attachments=t.attachments??[],this._notifySubscribers(),!0)}retractDraft(t){const e=t.attachments!==void 0?this._attachments===t.attachments:this._attachments.length===0;this._text!==t.text||this._quote!==t.quote||!e||(this._text="",this._rebaseDictation(""),this._quote=void 0,this._attachments=[],this._notifySubscribers())}cancel(){this.isSubmitting&&!this.detachesDraftOnSend&&(this._submissionSend?.controller.abort(),this._endSubmission(),this._notifySubscribers()),this.handleCancel()}get queue(){return ti}moveQueueItem(t,e){}removeQueueItem(t){}async addAttachment(t){if(jD(t)){const o=this.getAttachmentAdapter();if(o&&!AS({name:t.name,type:t.contentType??""},o.accept)){const d=`File type ${t.contentType||"unknown"} is not accepted. Accepted types: ${o.accept}`,f=new Error(d);throw this._safeEmitAttachmentAddError("not-accepted",d,void 0,f,t.contentType),f}const u={id:t.id??un(),type:t.type??"document",name:t.name,contentType:t.contentType,content:t.content,status:{type:"complete"}};this._attachments=[...this._attachments,u],this._notifySubscribers(),this._notifyEventSubscribers("attachmentAdd",{...u.contentType?{contentType:u.contentType}:void 0});return}const e=this.getAttachmentAdapter();if(!e){const o="Attachments are not supported",u=new Error(o);throw this._safeEmitAttachmentAddError("no-adapter",o,void 0,u,t.type),u}if(!AS({name:t.name,type:t.type},e.accept)){const o=`File type ${t.type||"unknown"} is not accepted. Accepted types: ${e.accept}`,u=new Error(o);throw this._safeEmitAttachmentAddError("not-accepted",o,void 0,u,t.type),u}const n=this._attachmentAddOperations.start(),i=o=>{if(!this._attachmentAddOperations.accept(n,o))return!1;const u=this._submission,d=u?.attachments.some(p=>p.id===o.id)??!1;u&&d&&(this._submission={...u,attachments:u.attachments.map(p=>p.id===o.id?this._attachmentSends.transfer(p,o):p)});const f=this._attachments.findIndex(p=>p.id===o.id);return f!==-1?this._attachments=[...this._attachments.slice(0,f),o,...this._attachments.slice(f+1)]:d||(this._attachments=[...this._attachments,o]),this._notifySubscribers(),!0};let a;try{await PD(e.add({file:t}),o=>(a=o,i(o)))}catch(o){if(this._attachmentAddOperations.isCancelled(n))return;throw a&&i({...a,status:{type:"incomplete",reason:"error",message:o instanceof Error?o.message:String(o)}}),this._safeEmitAttachmentAddError("adapter-error",o instanceof Error?o.message:String(o),a?.id,o instanceof Error?o:void 0,a?.contentType||t.type),o}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(a?.status.type==="incomplete"&&a.status.reason==="error"?this._safeEmitAttachmentAddError("adapter-error",a.status.message??"Attachment upload did not complete successfully.",a.id,void 0,a.contentType||t.type):this._notifyEventSubscribers("attachmentAdd",{...a?.contentType?{contentType:a.contentType}:t.type?{contentType:t.type}:void 0}))}_safeEmitAttachmentAddError(t,e,n,i,a){try{this._notifyEventSubscribers("attachmentAddError",{reason:t,message:e,...n!==void 0&&{attachmentId:n},...i!==void 0&&{error:i},...a?{contentType:a}:void 0})}catch(o){console.error("[assistant-ui] attachmentAddError subscriber threw:",o)}}async removeAttachment(t){const e=this._attachments.find(a=>a.id===t)??this._submission?.attachments.find(a=>a.id===t);if(!e)throw new Error("Attachment not found");const n=this.getAttachmentAdapter();if(!As(e)&&!n)throw new Error("Attachments are not supported");if(!this._attachmentSends.beginRemoval(e))return;this._cancelAttachmentAdd(t),this._notifySubscribers(),await this._attachmentSends.remove(e,n,(a,o)=>{const u=f=>this._attachmentSends.transfer(f,{...f,status:{type:"incomplete",reason:"error",message:o}}),d=this._submission;d&&(this._submission={...d,attachments:d.attachments.map(f=>!As(f)&&this._attachmentSends.isSameRemoval(f,e)?u(f):f)}),this._attachments.some(f=>this._attachmentSends.isSameRemoval(f,e))&&(this._attachments=this._attachments.map(f=>!As(f)&&this._attachmentSends.isSameRemoval(f,e)?u(f):f),this._submission||(this._attachments=this._attachments.map(f=>this._attachmentSends.isSameRemoval(f,e)?this._attachmentSends.restore(f):f))),this._notifySubscribers()});const i=this._submission;i&&(this._submission={...i,attachments:i.attachments.filter(a=>!this._attachmentSends.isSameRemoval(a,e))}),this._attachments.some(a=>this._attachmentSends.isSameRemoval(a,e))&&(this._attachments=this._attachments.filter(a=>!this._attachmentSends.isSameRemoval(a,e))),this._notifySubscribers()}get cleanupOwner(){return this}_adoptCleanupFailure(t,e,n){this._draftEpoch===n&&(this._attachments.some(i=>i.id===e.id)||(this._attachmentSends.adoptFrom(t,e),this._attachments=[e,...this._attachments],this._notifySubscribers()))}async _retrySubmittedRemoval(t,e,n){this._attachmentSends.beginRemoval(t),await this._attachmentSends.remove(t,this.getAttachmentAdapter(),(i,a)=>{console.error("[assistant-ui] Failed to remove sent attachment",i);const o=this._attachmentSends.transfer(t,{...t,status:{type:"incomplete",reason:"error",message:a}});e._adoptCleanupFailure(this._attachmentSends,o,n)}).catch(()=>{})}get dictation(){return this._dictationSessionController.dictation}startDictation(){this._dictationSessionController.startDictation()}stopDictation(){this._dictationSessionController.stopDictation()}_eventSubscribers=new Map;_notifyEventSubscribers(t,e){const n=this._eventSubscribers.get(t);n&&Wn(n,e,`Composer runtime "${t}"`)}unstable_on(t,e){const n=e;let i=this._eventSubscribers.get(t);return i||(i=new Set,this._eventSubscribers.set(t,i)),i.add(n),()=>{this._eventSubscribers.get(t)?.delete(n)}}};const IS=t=>t.capabilities?.cancel?Vc(t):!1;var $x=class extends am{get canCancel(){return this.isSubmitting||IS(this.runtime)}get canSend(){if(this.runtime.isDisabled||this.isEmpty||this.runtime.isSendDisabled||this.isSubmitting)return!1;const t=this.runtime.voice;return t?t.canSendText&&this.role==="user"&&this.sendableAttachments.length===0:!0}addAttachment(t){return this.runtime.isDisabled?Promise.resolve():super.addAttachment(t)}cancel(){if(!this.isSubmitting){super.cancel();return}this.cancelSubmission(),IS(this.runtime)&&super.cancel()}threadMessageIds(t){return this.runtime.messages.filter(e=>e.role===t).map(e=>e.id)}_queueCache;get queue(){const t=this.runtime.getSteerQueueItems?.()??ti,e=this.runtime.getQueueItems?.()??ti,n=this._queueCache;if(n&&n.steer===t&&n.queue===e)return n.flat;const i=t.length===0?e:e.length===0?t:[...t,...e];return this._queueCache={steer:t,queue:e,flat:i},i}moveQueueItem(t,e){this.runtime.moveQueueItem?.(t,e)}removeQueueItem(t){this.runtime.removeQueueItem?.(t)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(t){super(),this.runtime=t,this.connect()}connect(){let t=!1,e=this.runtime.isDisabled,n=this.runtime.isSendDisabled,i=this.runtime.voice?.canSendText,a=this.queue;return this.runtime.subscribe(()=>{this.settleInTransit();let o=!1;const u=this.canCancel;t!==u&&(t=u,o=!0),e!==this.runtime.isDisabled&&(e=this.runtime.isDisabled,o=!0),n!==this.runtime.isSendDisabled&&(n=this.runtime.isSendDisabled,o=!0);const d=this.runtime.voice?.canSendText;i!==d&&(i=d,o=!0),a!==this.queue&&(a=this.queue,o=!0),o&&this._notifySubscribers()})}async handleSend(t,e){return this.runtime.append({...t,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:e?.startRun,steer:e?.steer})}async handleCancel(){this.runtime.cancelRun()}},LD=class extends am{get canCancel(){return!0}get detachesDraftOnSend(){return!1}get cleanupOwner(){return this.runtime.composer instanceof am?this.runtime.composer:this}get canSend(){return!this.runtime.isDisabled&&!this.isEmpty&&!this.runtime.voice&&!this.isSubmitting}addAttachment(t){return this.runtime.isDisabled?Promise.resolve():super.addAttachment(t)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;_ended=!1;constructor(t,e,{parentId:n,message:i}){super(),this.runtime=t;let a=t.voice!==void 0,o=t.isDisabled;const u=t.subscribe(()=>{const f=t.voice!==void 0,p=t.isDisabled;f===a&&p===o||(a=f,o=p,this._notifySubscribers())});this.endEditCallback=()=>{u(),e()},this._parentId=n,this._sourceId=i.id,this.setText(Qa(i)),this.setRole(i.role);let d;i.role==="user"?(d=[...i.attachments??[],...DD(i.content)],this._nonTextPassthrough=[]):(d=i.attachments??[],this._nonTextPassthrough=i.content.filter(f=>f.type!=="text")),this.setAttachments(d),this.setQuote(i.metadata.custom.quote),this.setRunConfig({...t.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(t,e){const n=this._nonTextPassthrough.length>0?[...t.content,...this._nonTextPassthrough]:t.content,i=this.runtime.append({...t,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:e?.startRun});return this.handleCancel(),i}handleCancel(){this._ended||(this._ended=!0,this.reset().catch(t=>{console.error("[assistant-ui] Failed to clear cancelled edit",t)}),this.endEditCallback(),this._notifySubscribers())}},qD=class{voiceMessages=[];voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;host;constructor(t){this.host=t}markMessagesDirty(){this.voiceGeneration++,this._cachedMergedMessages=null}dropMessage(t,e){const n=this.voiceMessages.findIndex(i=>i.id===t);n!==-1&&(this.voiceMessages.splice(n,1),this.host.markVoiceMessagesDirty(),e&&this.host.notify())}getMessages(){if(this.voiceMessages.length===0)return this.host.getBaseMessages();const t=this.host.getBaseMessages();if(this._cachedVoiceGeneration!==this.voiceGeneration||this._cachedMergedBase!==t){const e=new Set(t.map(n=>n.id));this._cachedMergedMessages=[...t,...this.voiceMessages.filter(n=>!e.has(n.id))],this._cachedVoiceGeneration=this.voiceGeneration,this._cachedMergedBase=t}return this._cachedMergedMessages}replaceAssistantMessage(t,e){this._currentAssistantMsg===t&&(this._currentAssistantMsg=e)}isVoiceMessage(t){return t!==null&&this.voiceMessages.some(e=>e.id===t)}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=t=>(this._voiceVolumeSubscribers.add(t),()=>this._voiceVolumeSubscribers.delete(t));_toVoiceSessionState(t,e,n){return{status:e,isMuted:t.isMuted,mode:n,canSendText:e.type==="running"&&t.sendText!==void 0}}isRunActive(){if(this.host.isRunning())return!0;const t=this.host.getBaseMessages().at(-1);return t?.role==="assistant"&&(t.status.type==="running"||t.status.type==="requires-action")}getVoiceCommitBarrier(){if(!this.host.isLoading())return;const t=this.host.captureGeneration();return(async()=>{for(;this.host.isLoading()&&!t.aborted;)await new Promise(e=>{const n=()=>{i(),t.removeEventListener("abort",n),e()},i=this.host.subscribe(n);t.addEventListener("abort",n)})})()}connectVoice(){const t=this.host.adapter();if(!t)throw new Error("Voice adapter not configured");if(this.host.isRunActive())throw new Error("Cannot start a voice session while a run is in progress or paused on a pending tool action");const e=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(o){console.error("[assistant-ui] Voice cleanup threw before reconnect",o)}if(this._voiceSession!==void 0)return;let n;try{n=t.connect({})}catch(o){throw e&&this._voiceSession===void 0&&this.host.onDisconnected(),o}this._voiceSession=n;const i=[];this._voiceUnsubs=i;const a=()=>{if(this._voiceSession===n&&this._voiceUnsubs===i)return!1;try{Pn(i.splice(0))}catch(o){console.error("[assistant-ui] Detached voice setup cleanup threw",o)}return!0};try{let o="listening";if(this.voice=this._toVoiceSessionState(n,n.status,o),this._voiceVolume=0,this.host.notify(),a()||(i.push(n.onStatusChange(u=>{if(this._voiceSession===n)if(u.type==="ended"){this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;try{Pn([()=>this._finishVoiceAssistantMessage(!1),()=>{this._voiceSession===void 0&&this.host.onDisconnected()},()=>Wn(this._voiceVolumeSubscribers,void 0,"Voice volume"),()=>this.host.notify()])}finally{a()}}else this.voice=this._toVoiceSessionState(n,u,o),this.host.notify()})),a())||(i.push(n.onModeChange(u=>{this._voiceSession===n&&(o=u,this.voice&&(this.voice={...this.voice,mode:u},this.host.notify()))})),a())||(i.push(n.onVolumeChange(u=>{this._voiceSession===n&&(this._voiceVolume=u,Wn(this._voiceVolumeSubscribers,void 0,"Voice volume"))})),a()))return;i.push(n.onTranscript(u=>{this._voiceSession===n&&this._handleVoiceTranscript(u)})),a()||this.host.onConnected()}catch(o){if(this._voiceSession===n&&this._voiceUnsubs===i){try{this._disconnectVoice(!1)}catch(u){console.error("[assistant-ui] Voice rollback cleanup threw",u)}e&&this._voiceSession===void 0&&this.host.onDisconnected()}else a();throw o}}_currentAssistantMsg=null;_observeVoiceCommit(t){new Promise(e=>e(t())).catch(e=>{console.error("[assistant-ui] Voice message commit failed",e)})}_handleVoiceTranscript(t){const e=this._voiceSession;if(this.host.ensureInitialized(),this._voiceSession===e)if(t.role==="user"){if(this._finishVoiceAssistantMessage(),this._voiceSession!==e)return;this._currentAssistantMsg=null,t.isFinal&&this._observeVoiceCommit(()=>this._commitVoiceUserMessage({id:un(),role:"user",content:[{type:"text",text:t.text}],metadata:{modality:"voice",custom:{}},createdAt:new Date,attachments:[]}))}else{const n=t.isFinal?{type:"complete",reason:"stop"}:{type:"running"};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:un(),role:"assistant",content:[{type:"text",text:t.text}],metadata:{unstable_state:this.host.state(),unstable_annotations:[],unstable_data:[],steps:[],modality:"voice",custom:{}},status:n,createdAt:new Date},this.voiceMessages.push(this._currentAssistantMsg);else{const i=this.voiceMessages.indexOf(this._currentAssistantMsg);if(i===-1)return;const a={...this._currentAssistantMsg,content:[{type:"text",text:t.text}],status:n};this.voiceMessages[i]=a,this._currentAssistantMsg=a}if(t.isFinal){const i=this._currentAssistantMsg;this._observeVoiceCommit(()=>this.host.commitVoiceMessage(i)),this._currentAssistantMsg=null}this.host.markVoiceMessagesDirty(),this.host.notify()}}_commitVoiceUserMessage(t){this.voiceMessages.push(t);try{return this.host.commitVoiceMessage(t)}finally{this.host.markVoiceMessagesDirty(),this.host.notify()}}async appendToVoiceSession(t){const e=this._voiceSession;if(!this.voice?.canSendText||!e?.sendText)throw new Error("Cannot send a text message while a voice session is connected");const n=t.content.filter(o=>o.type==="text");if(t.role!=="user"||t.sourceId!=null||t.parentId!==this.host.resolveAppendParent(this.host.messages().at(-1)?.id??null)||t.attachments?.length||n.length!==t.content.length||!n.some(o=>o.text.trim()))throw new Error("Only a plain text user message can be sent while a voice session is connected");const i=this.host.enrichAppendMetadata(t);this.host.ensureInitialized();const a=this.host.captureGeneration();try{await e.sendText(Qa(t))}catch(o){if(a.aborted)return;const u=new Ec;throw u.cause=o,u}if(!a.aborted){if(this._voiceSession!==e)throw new Ec("The voice session ended before the typed message was recorded");if(this._finishVoiceAssistantMessage(!1),this._voiceSession!==e)throw new Ec("The voice session ended before the typed message was recorded");this._currentAssistantMsg=null,await this._commitVoiceUserMessage({id:un(),role:"user",content:n,metadata:{custom:{...i.metadata?.custom}},createdAt:t.createdAt,attachments:[]})}}_finishVoiceAssistantMessage(t=!0){const e=this.voiceMessages.at(-1);if(e?.role==="assistant"&&e.status.type==="running"){const n=this.voiceMessages.length-1;this.voiceMessages[n]={...e,status:{type:"complete",reason:"stop"}},this._observeVoiceCommit(()=>this.host.commitVoiceMessage(this.voiceMessages[n])),this._currentAssistantMsg=null,this.host.markVoiceMessagesDirty(),t&&this.host.notify()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(t){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;const e=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];const n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;const i=this.host.stopSpeakingForVoiceMessage();this.voiceMessages=[],this.host.markVoiceMessagesDirty();try{Pn([...e,...i?[i]:[],...n?[()=>n.disconnect()]:[],()=>Wn(this._voiceVolumeSubscribers,void 0,"Voice volume"),()=>this.host.notify()])}finally{t&&n&&this._voiceSession===void 0&&this.host.onDisconnected()}}muteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this.host.notify()}unmuteVoice(){if(!this._voiceSession)throw new Error("No active voice session");this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this.host.notify()}},HD=class extends Li{_isInitialized=!1;repository=new Vx;_voiceController=new qD({adapter:()=>this.adapters?.voice,isRunning:()=>this.isRunning===!0,isRunActive:()=>this._isRunActive(),isLoading:()=>this.isLoading,getBaseMessages:()=>this._getBaseMessages(),messages:()=>this.messages,state:()=>this.state,notify:()=>this._notifySubscribers(),subscribe:t=>this.subscribe(t),captureGeneration:()=>Ac(this),ensureInitialized:()=>this.ensureInitialized(),commitVoiceMessage:t=>this._commitVoiceMessage(t),markVoiceMessagesDirty:()=>this._markVoiceMessagesDirty(),onConnected:()=>this._onVoiceConnected(),onDisconnected:()=>this._onVoiceDisconnected(),enrichAppendMetadata:t=>this.enrichAppendMetadata(t),resolveAppendParent:t=>this._resolveAppendParent(t),stopSpeakingForVoiceMessage:()=>this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0});get _voiceMessages(){return this._voiceController.voiceMessages}set _voiceMessages(t){this._voiceController.voiceMessages=t}get _voiceGeneration(){return this._voiceController.voiceGeneration}set _voiceGeneration(t){this._voiceController.voiceGeneration=t}_markVoiceMessagesDirty(){this._voiceController.markMessagesDirty()}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(t){}_onMessageMetadataChanged(t,e){}_dropVoiceMessage(t,e){this._voiceController.dropMessage(t,e)}get messages(){return this._voiceController.getMessages()}get state(){let t;for(const e of this.messages)e.role==="assistant"&&(t=e);return t?.metadata.unstable_state??null}composer=new $x(this);_contextProvider;constructor(t){super(),this._contextProvider=t,xD(this).addEventListener("abort",()=>{this.composer.__internal_dispose();for(const e of this._editComposers.values())e.__internal_dispose()})}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(t,e=t.parentId){if(t.role!=="user")return t;const n=this.messages,i=e===null?-1:n.findIndex(o=>o.id===e),a=N4(this.getModelContext().unstable_composerMetadata,n.slice(0,i+1));return a?{...t,metadata:{...t.metadata,custom:{...t.metadata?.custom,...a}}}:t}_editComposers=new Map;getEditComposer(t){return this._editComposers.get(t)}__internal_getEditComposers(){return this._editComposers.values()}_isVoiceMessage(t){return this._voiceController.isVoiceMessage(t)}_resolveAppendParent(t){return this._isVoiceMessage(t)?this._getBaseMessages().at(-1)?.id??null:t}beginEdit(t){if(this.voice)throw new Error("Cannot edit a message while a voice session is connected");if(this._isVoiceMessage(t))throw new Error("Voice transcript messages cannot be edited");if(this._editComposers.has(t))throw new Error("Edit already in progress");this._editComposers.set(t,new LD(this,()=>this._editComposers.delete(t),this.repository.getMessage(t))),this._notifySubscribers()}getMessageById(t){try{return this.repository.getMessage(t)}catch{const e=this.repository.getMessages(),n=this._voiceMessages.findIndex(i=>i.id===t);return n!==-1?{parentId:n>0?this._voiceMessages[n-1].id:e.at(-1)?.id??null,message:this._voiceMessages[n],index:e.length+n}:void 0}}getBranches(t){return this._voiceMessages.some(e=>e.id===t)?[]:this.repository.getBranches(t)}switchToBranch(t){this.repository.switchToBranch(t),this._notifySubscribers()}_notifyEventSubscribers(t,e){const n=this._eventSubscribers.get(t);n&&Wn(n,e,`Thread runtime "${t}"`)}_notifyToolApprovalAnswered(t,e,n,i){this._notifyEventSubscribers("toolApprovalAnswered",{messageId:t,toolCallId:e,toolName:n,approved:i})}submitFeedback({messageId:t,type:e,comment:n}){const i=this.adapters?.feedback,a=this.getMessageById(t);if(!a)throw new Error(`Message not found: ${t}`);const{message:o,parentId:u}=a,d=n?.trim(),f={type:e,...d?{comment:d}:void 0};if(i?.submit({message:o,...f}),o.role==="assistant"){const p={...o,metadata:{...o.metadata,submittedFeedback:f}},m=this._voiceMessages.findIndex(y=>y.id===t);m===-1?(this.repository.addOrUpdateMessage(u,p),this._onMessageMetadataChanged(o,p)):(this._voiceMessages[m]=p,this._voiceController.replaceAssistantMessage(o,p),this._markVoiceMessagesDirty())}this._notifySubscribers()}_stopSpeaking;speech;speak(t){const e=this.adapters?.speech;if(!e)throw new Error("Speech adapter not configured");const n=this.getMessageById(t);if(!n)throw new Error(`Message not found: ${t}`);const{message:i}=n,a=this._stopSpeaking;let o;try{a?.(),o=e.speak(Qa(i))}catch(m){if(a&&!this._stopSpeaking)try{this._notifySubscribers()}catch(y){console.error("[assistant-ui] Speech rollback notification threw",y)}throw m}let u;const d=()=>{this._stopSpeaking=void 0,this.speech=void 0;const m=u;u=void 0,m?.()},f=()=>{if(this._stopSpeaking===f)try{d()}finally{o.cancel()}},p=()=>{this._stopSpeaking===f&&(o.status.type==="ended"?Pn([d,()=>this._notifySubscribers()]):(this.speech={messageId:t,status:o.status},this._notifySubscribers()))};this._stopSpeaking=f;try{if(u=o.subscribe(p),this._stopSpeaking!==f){u();return}p()}catch(m){if(this._stopSpeaking===f)try{Pn([f,()=>this._notifySubscribers()])}catch(y){console.error("[assistant-ui] Speech rollback cleanup threw",y)}throw m}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");Pn([this._stopSpeaking,()=>this._notifySubscribers()])}get voice(){return this._voiceController.voice}set voice(t){this._voiceController.voice=t}getVoiceVolume=()=>this._voiceController.getVoiceVolume();subscribeVoiceVolume=t=>this._voiceController.subscribeVoiceVolume(t);_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){return this._voiceController.isRunActive()}_getVoiceCommitBarrier(){return this._voiceController.getVoiceCommitBarrier()}connectVoice(){this._voiceController.connectVoice()}async _appendToVoiceSession(t){return this._voiceController.appendToVoiceSession(t)}disconnectVoice(){this._voiceController.disconnectVoice()}muteVoice(){this._voiceController.muteVoice()}unmuteVoice(){this._voiceController.unmuteVoice()}ensureInitialized(){return this._isInitialized?!1:(this._isInitialized=!0,this._notifyEventSubscribers("initialize",{}),!0)}export(){return this.repository.export()}import(t){this.ensureInitialized(),this.repository.clear(),this.repository.import(t),this._notifySubscribers()}reset(t){this.import(Hx.fromArray(t??[]))}_eventSubscribers=new Map;unstable_on(t,e){const n=e;if(t==="modelContextUpdate")return this._contextProvider.subscribe?.(()=>Wn([n],{},`Thread runtime "${t}"`))??(()=>{});let i=this._eventSubscribers.get(t);return i||(i=new Set,this._eventSubscribers.set(t,i)),i.add(n),t==="initialize"&&this._isInitialized&&queueMicrotask(()=>{i.has(n)&&Wn([n],{},`Thread runtime "${t}"`)}),()=>{this._eventSubscribers.get(t)?.delete(n)}}};const VD=Qt(!1),$D=t=>Fa(VD,!0,t),GD=({threadId:t,generation:e,runtimeHook:n,publish:i,itemRuntime:a})=>{const o=$D(n),u=o?.thread?.__internal_threadBinding,d=on(()=>{u&&i(t,u.getState(),e)},[t,e,u,i]),f=we(!1);f.current||d(),Ce(()=>{if(u)return f.current=!0,d(),u.outerSubscribe(d)},[u,d]);const p=we(void 0),m=we(!1),y=we(a.getState().status==="new"),v=bn(()=>{if(m.current||a.getState().status!=="new"&&!y.current)return;m.current=!0,y.current=!1;const T=a.initialize();p.current=T,T.catch(()=>{p.current===T&&(p.current=void 0,m.current=!1)})}),b=bn(()=>(v(),p.current));return Ce(()=>{if(!u)return;const T=u.getState(),w=T.__internal_setGetInitializePromise;typeof w=="function"&&w.call(T,b)},[u]),Ce(()=>{if(o?.threads?.main)return m.current=!1,o.threads.main.unstable_on("initialize",v)},[o]),o},FD=({threadId:t,generation:e,parentList:n,runtimeHook:i,parentClient:a,adapters:o,publish:u,destroySignal:d})=>{const f=yt(()=>new rl(new Zn({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>{const m=n.getItemById(t);return m?{id:m.id,remoteId:m.remoteId,externalId:m.externalId,title:m.title,lastMessageAt:m.lastMessageAt,custom:m.custom,status:m.status,isMain:m.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(m.id)??!1}:es},subscribe:m=>n.subscribe(m)}),n),[n,t]),{client:p}=qw(a,{threadListItem:mg({runtime:f})});return Dw(d,function(){return Cw(p,function(){return GO(o,function(){return GD({threadId:t,generation:e,runtimeHook:i,publish:u,itemRuntime:f})})})})},YD=Ye(FD),QD=["runStart","runEnd","initialize","modelContextUpdate"],KD=t=>{const e=Q(3),{detectorRef:n}=t;let i,a;return e[0]!==n?(i=()=>{n.current=!0},a=[n],e[0]=n,e[1]=i,e[2]=a):(i=e[1],a=e[2]),Ha(i,a),null};var XD=class extends Li{runtimeHook;adapterStore=new bl({defaultAdapters:null,threadAdapters:new Map});hostStore=new bl({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(t,e){super(),this.parent=e,this.runtimeHook=t}_whenRuntimeAttached(t){return new Promise((e,n)=>{const i=()=>{const o=this.instances.get(t);if(!o)a(),n(new Error("Thread was deleted before runtime was started"));else{if(!o.runtime||o.publishedGeneration!==o.generation)return;a(),e(o.runtime)}},a=this.subscribe(i);i()})}startThreadRuntime(t){if(!this.instances.has(t)){const e=this.nextGeneration++;this.instances.set(t,{generation:e,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(t)}_retireThreadRuntime(t){try{t.unsubscribeRunning?.()}finally{t.unsubscribeRunning=void 0,t.runtime&&Lx(t.runtime),t.destroy.abort(),t.destroy=new AbortController,t.generation=this.nextGeneration++}}__internal_restartThreadRuntime(t){const e=this.instances.get(t);if(!e)return this.startThreadRuntime(t);try{this._retireThreadRuntime(e)}finally{this._syncHostThreads(),this._notifySubscribers()}return this._whenRuntimeAttached(t)}getThreadRuntimeCore(t){const e=this.instances.get(t);if(e)return e.runtime}__internal_hasThreadRuntime(t){return this.instances.has(t)}__internal_isThreadRunning(t){return this.instances.get(t)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(t){return this.runningSubscribers.add(t),()=>this.runningSubscribers.delete(t)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(t){return this.threadEventSubscribers.add(t),()=>this.threadEventSubscribers.delete(t)}_publish=(t,e,n)=>{this._publishThreadRuntime(t,e,n)};_publishThreadRuntime(t,e,n){const i=this.instances.get(t);if(!i||i.generation!==n)return;const a=i.runtime,o=i.publishedGeneration;i.runtime=e,i.publishedGeneration=n;try{a!==e&&this._trackRunning(t,i)}finally{try{this._notifySubscribers(),a!==void 0&&a!==e&&Pn(this.replacedSubscribers)}finally{o===n&&a!==void 0&&a!==e&&ES(a)}}}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(t){return this.replacedSubscribers.add(t),()=>this.replacedSubscribers.delete(t)}_trackRunning(t,e){const n=e.unsubscribeRunning;e.unsubscribeRunning=void 0;try{n?.()}finally{const i=e.runtime;if(!i)this._setRunning(e,!1);else{const a=Vc(i);e.isRunning!==a&&(e.isRunning=a,queueMicrotask(()=>Pn(this.runningSubscribers)));const o=[i.subscribe(()=>{this._setRunning(e,Vc(i))}),...QD.map(u=>i.unstable_on(u,()=>{Wn(this.threadEventSubscribers,{threadId:t,type:u},`Thread event "${u}"`)}))];e.unsubscribeRunning=()=>si(o)}}}_setRunning(t,e){t.isRunning!==e&&(t.isRunning=e,Pn(this.runningSubscribers))}stopThreadRuntime(t){const e=this.instances.get(t);try{e?.unsubscribeRunning?.()}finally{e?.runtime&&ES(e.runtime),e?.destroy.abort(),this.instances.delete(t),this.pendingThreadAdapters.delete(t),this._syncHostThreads(),this._notifySubscribers()}}setRuntimeHook(t){if(this.runtimeHook===t)return;this.runtimeHook=t;const e=this.hostStore.getState().hookEpoch+1;try{si(Array.from(this.instances.values(),n=>()=>this._retireThreadRuntime(n)))}finally{this._syncHostThreads(e)}}__internal_setDefaultAdapters(t){const e=this.adapterStore.getState();e.defaultAdapters!==t&&this.adapterStore.setState({...e,defaultAdapters:t})}__internal_setThreadAdapters(t,e){const n=this.adapterStore.getState(),i=new Map(n.threadAdapters);e===null?i.delete(t):i.set(t,e),this.adapterStore.setState({...n,threadAdapters:i})}__internal_dispose(){for(const t of[...this.instances.keys()])try{this.stopThreadRuntime(t)}catch(e){console.error("[assistant-ui] Thread runtime cleanup threw while stopping a thread",e)}}_syncHostThreads(t){const e=this.hostStore.getState();this.hostStore.setState({...e,hookEpoch:t??e.hookEpoch,threads:Array.from(this.instances.entries()).map(([n,{generation:i,destroy:a}])=>({id:n,generation:i,destroySignal:a.signal}))})}_threadElements(t,{threads:e,hookEpoch:n},i){const a=this.runtimeHook;return e.map(({id:o,generation:u,destroySignal:d})=>{const f=this.pendingThreadAdapters.has(o)?this.pendingThreadAdapters.get(o):i.threadAdapters.get(o)??i.defaultAdapters;return Jt(`${o}:${u}:${n}`,YD({threadId:o,generation:u,parentList:this.parent,runtimeHook:a,parentClient:t,adapters:f,publish:this._publish,destroySignal:d}))})}__internal_useHost(t){const e=ln(this.hostStore),n=ln(this.adapterStore);return yl(this._threadElements(t,e,n))}__internal_RenderThreadRuntimes=({provider:t})=>(ln(this.hostStore),Array.from(this.instances.entries()).map(([e,{generation:n}])=>_.jsx(this._OuterActiveThreadProvider,{threadId:e,provider:t},`${e}:${n}`)));__internal_Host=({parentClient:t})=>{const e=ln(this.hostStore),n=ln(this.adapterStore),i=this._threadElements(t,e,n),{effects:a}=Sw(function(){return yl(i)});return Ha(a),null};_OuterActiveThreadProvider=Nt(({threadId:t,provider:e})=>{const n=yt(()=>new qx(this.parent).getItemById(t),[t]),i=we(!1);return Ce(()=>{},[e]),_.jsx(U4,{runtime:n,children:_.jsx(e,{children:_.jsx(this._AdapterSink,{threadId:t,detectorRef:i})})})});_AdapterSink=({threadId:t,detectorRef:e})=>{const n=vx();return this.pendingThreadAdapters.set(t,n),Ha(()=>(this.__internal_setThreadAdapters(t,n),()=>{this.pendingThreadAdapters.get(t)===n&&this.pendingThreadAdapters.delete(t),this.__internal_setThreadAdapters(t,null)}),[t,n]),_.jsx(KD,{detectorRef:e})}};function JD(t,e,n,...i){if(!n)return;const a=o=>{try{console.error(`[${t}] ${e} callback threw an error`,o)}catch{}};try{const o=n(...i);if(o!==null&&(typeof o=="object"||typeof o=="function")&&"then"in o&&typeof o.then=="function")return Promise.resolve(o).then(()=>{},u=>a(u))}catch(o){a(o)}}const RS=(t,e,n)=>n.reduce((i,a)=>a?.(i,e)??i,t);var ZD=class extends Li{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(t){super(),this._baseValue=t,this._cachedValue=t}_updateState(){const t=[...this._pendingTransforms.map(e=>({order:e.order,apply:n=>RS(n,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:n})=>({order:e,apply:n}))].sort((e,n)=>e.order-n.order);this._cachedValue=t.reduce((e,n)=>n.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(t){this._baseValue=t,this._updateState()}reset(t){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=t,this._cachedValue=t,this._notifySubscribers()}async optimisticUpdate(t){const e=this._epoch,n=this._nextTransformOrder++,i=t.execute(),a={...t,order:n,task:i};try{this._pendingTransforms.push(a),this._updateState();const o=await i;if(e!==this._epoch)return o;this._baseValue=RS(this._baseValue,o,[t.optimistic,t.then]);for(const u of this._completedOptimistics)(t.then||u.order>a.order)&&(this._baseValue=u.optimistic(this._baseValue));return t.optimistic&&(this._completedOptimistics.push({order:a.order,optimistic:t.optimistic}),this._completedOptimistics.sort((u,d)=>u.order-d.order)),o}finally{const o=this._pendingTransforms.indexOf(a);o>-1&&this._pendingTransforms.splice(o,1);try{this._updateState()}finally{this._pendingTransforms.length===0&&(this._completedOptimistics.length=0)}}}};const lp=new 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.");var WD=class extends wD{get error(){return lp}messages=[];composer=TD(lp,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(lp)}};const ej=new WD;const MS="__LOCALID_",wg=t=>t||void 0,hd=(t,e)=>{let n=[...e.threadIds],i=[...e.archivedThreadIds];const a=wt(e.threadIdMap),o=wt(e.threadData),u=new Set([...n,...i]);for(const d of t){switch(d.status){case"regular":case"archived":break;default:{const b=d.status;throw new Error(`Unsupported state: ${b}`)}}const f=a[d.remoteId],p=f!==void 0?o[f]:void 0,m=p?.id??d.remoteId,y=f??m,v=p!==void 0&&p.status!=="new"?p.initializeTask:void 0;u.has(m)?p!==void 0&&p.status!==d.status&&(d.status==="regular"?(i=i.filter(b=>b!==m),n.push(m)):(n=n.filter(b=>b!==m),i.push(m))):(u.add(m),d.status==="regular"?n.push(m):i.push(m)),a[m]=y,a[d.remoteId]=y,o[y]={...p?.localOrigin===!0?{localOrigin:!0}:{},id:m,remoteId:d.remoteId,externalId:d.externalId,status:d.status,title:d.title,lastMessageAt:d.lastMessageAt,custom:d.custom,initializeTask:v??Promise.resolve({remoteId:d.remoteId,externalId:d.externalId})}}return{threadIds:n,archivedThreadIds:i,threadIdMap:a,threadData:o}},tj=(t,e)=>({...t,...hd([e],{threadIds:[...t.threadIds],archivedThreadIds:[...t.archivedThreadIds],threadIdMap:t.threadIdMap,threadData:t.threadData})}),nj=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:wt(),threadData:wt()}),up=(t,e)=>{let n=`${MS}${e??un()}`;for(;t.threadIdMap[n];)n=`${MS}${un()}`;const i=n;return{id:n,state:{...t,newThreadId:n,threadIdMap:wt(t.threadIdMap,{[n]:i}),threadData:wt(t.threadData,{[i]:{status:"new",id:n,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},sj=(t,e,n)=>{const i=new Set(t.threadIds),a=new Set(t.archivedThreadIds),o=[],u=[],d=(p,m)=>p.has(m.id)||m.remoteId!==void 0&&p.has(m.remoteId);for(const p of Object.values(t.threadData)){const m=n.get(p.id);m!==void 0&&m!=="new"||m===void 0&&p.localOrigin!==!0||(p.status==="regular"&&!d(i,p)?(o.push(p),i.add(p.id)):p.status==="archived"&&!d(a,p)&&(u.push(p),a.add(p.id)))}if(o.length===0&&u.length===0)return t;const f=(p,m)=>{const y=p.indexOf(m.id);if(y!==-1)return y;const v=m.remoteId!==void 0?p.indexOf(m.remoteId):-1;return v!==-1?v:Number.MAX_SAFE_INTEGER};return o.sort((p,m)=>f(e.threadIds,p)-f(e.threadIds,m)),u.sort((p,m)=>f(e.archivedThreadIds,p)-f(e.archivedThreadIds,m)),{...t,threadIds:[...o.map(p=>p.id),...t.threadIds],archivedThreadIds:[...u.map(p=>p.id),...t.archivedThreadIds]}},ij=t=>new Map(Object.values(t.threadData).map(e=>[e.id,e.status])),rj=(t,e,n)=>{const i=hd(e.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...t.threadIdMap},threadData:{...t.threadData}}),a={...t,isLoading:!1,loadError:void 0,cursor:wg(e.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData};return sj(a,t,n)},aj=(t,e)=>{const n=hd(e.threads,{threadIds:[...t.threadIds],archivedThreadIds:[...t.archivedThreadIds],threadIdMap:{...t.threadIdMap},threadData:{...t.threadData}});return{...t,isLoadingMore:!1,cursor:wg(e.nextCursor),threadIds:n.threadIds,archivedThreadIds:n.archivedThreadIds,threadIdMap:n.threadIdMap,threadData:n.threadData}},bt=(t,e)=>{const n=Object.hasOwn(t.threadIdMap,e)?t.threadIdMap[e]:void 0;if(n!==void 0)return Object.hasOwn(t.threadData,n)?t.threadData[n]:void 0},oj=(t,e,n,i,a)=>{const o=e,u=Object.hasOwn(t.threadData,o)?t.threadData[o]:void 0;if(!u)return{state:t,removedMappingId:void 0,survivorMappingId:o};const d=Object.hasOwn(t.threadIdMap,n)?t.threadIdMap[n]:void 0,f=d!==void 0&&d!==o&&Object.hasOwn(t.threadData,d)?t.threadData[d]:void 0,p=d!==void 0&&f!==void 0?{mappingId:d,data:f}:void 0,m=a!==void 0&&Object.hasOwn(t.threadIdMap,a)?t.threadIdMap[a]:void 0,y=p!==void 0&&m===p.mappingId?p.mappingId:o,v=p===void 0?void 0:y===o?p.mappingId:o,b=i??p?.data.externalId,T=wt(t.threadData);v!==void 0&&delete T[v];const w={...u,id:y,initializeTask:Promise.resolve({remoteId:n,externalId:b}),remoteId:n,externalId:b};T[y]={...p?.data,...w,title:u.title??p?.data.title,lastMessageAt:("lastMessageAt"in u?u.lastMessageAt:void 0)??(p&&"lastMessageAt"in p.data?p.data.lastMessageAt:void 0),custom:u.custom??p?.data.custom};const x=wt(t.threadIdMap);if(v!==void 0)for(const[C,R]of Object.entries(x))R===v&&(x[C]=y);x[e]=y,x[n]=y;const E=C=>p===void 0?C:C.filter(R=>R!==p.data.id).map(R=>R===u.id?y:R);return{state:{...t,threadIds:E(t.threadIds),archivedThreadIds:E(t.archivedThreadIds),threadIdMap:x,threadData:T},removedMappingId:v,survivorMappingId:y}},Gx=(t,e,n,i)=>{const a=bt(t,e);if(!a)return t;const{id:o,status:u}=a;if(u===n)return t;let d;if(n!=="deleted")if(a.status==="new"){if(i===void 0)return t;d={...a,initializeTask:i,status:n}}else d={...a,status:n};const f={...t};switch(u){case"new":f.newThreadId=void 0;break;case"regular":f.threadIds=f.threadIds.filter(p=>p!==o);break;case"archived":f.archivedThreadIds=f.archivedThreadIds.filter(p=>p!==o);break;default:throw new Error(`Unsupported state: ${u}`)}switch(n){case"regular":f.threadIds=[o,...f.threadIds];break;case"archived":f.archivedThreadIds=[o,...f.archivedThreadIds];break;case"deleted":{const p=t.threadIdMap[e],m=wt(f.threadData);delete m[p],f.threadData=m;const y=wt(f.threadIdMap);for(const[v,b]of Object.entries(y))b===p&&delete y[v];f.threadIdMap=y;break}default:throw new Error(`Unsupported state: ${n}`)}return d!==void 0&&(f.threadData={...f.threadData,[o]:d}),f},$c=(t,e,n)=>Gx(t,e,n,void 0),lj=(t,e,n)=>Gx(t,e,"regular",n),kS=(t,e,n)=>{const i=$c(t,e,"deleted");return n===void 0?i:$c(i,n,"deleted")};var cp=class extends Error{[Kw]=!0;constructor(){super("Thread list adapter changed while an operation was pending."),this.name="ThreadListAdapterChangedError"}};const NS=t=>t.status?.type!=="running",uj=async(t,e)=>{const n=b4.fromAssistantStream(t);for await(const i of n){const a=i.parts.filter(o=>o.type==="text")[0]?.text;a?.trim()&&await e(a)}};function xg(t,e){let n=t.get(e);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualClaim:null,latestExplicit:null,nextOrder:0},t.set(e,n)),n}function Cg(t,e,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualClaim===null&&t.get(e)===n&&t.delete(e)}function gc(t,e){return!e.superseded&&(t.latestExplicit?.order??0)<=e.order}function Gc(t,e){return(t.latestExplicit?.order??0)<e.order}function cj(t,e,n){const i=xg(t,e);let a;const o=new Promise(d=>{a=d}),u={title:n,order:++i.nextOrder,settled:o,settle:a,renamed:void 0};i.pendingClaim=u,i.inFlightClaims.add(u);for(const d of i.generations)d.order<u.order&&(d.claim=u,d.claims.push(u));return u}function OS(t,e,n,i){n.renamed=i,n.settle(i);const a=t.get(e);a!==void 0&&(a.inFlightClaims.delete(n),i&&Gc(a,n)&&(a.manualClaim?.order??0)<n.order&&(a.manualClaim=n),a.pendingClaim===n&&(a.pendingClaim=i?null:Fx(a,a.inFlightClaims)),Cg(t,e,a))}function Fx(t,e){let n=null;for(const i of e)i.renamed===!1||!Gc(t,i)||(n===null||i.order>n.order)&&(n=i);return n}function Yx(t,e,n){const i=n.manualClaim;if(i!==null)return n.manualClaim=null,Cg(t,e,n),i.title}function dp(t,e){t.delete(e)}function dj(t,e,n){const i=xg(t,e);if(n&&i.pendingClaim===null&&Yx(t,e,i)!==void 0)return null;let a;const o=new Promise(d=>{a=d}),u={automatic:n,order:++i.nextOrder,claim:n?i.pendingClaim:null,claims:n&&i.pendingClaim!==null?[i.pendingClaim]:[],beforeGenerationClaims:n?[]:[...i.inFlightClaims],superseded:!1,persisted:o,settlePersisted:a};if(!n){i.pendingClaim=null,i.manualClaim=null,i.latestExplicit=u;for(const d of i.generations)d.automatic&&(d.superseded=!0)}return i.generations.add(u),u}async function fj(t){const{states:e,threadId:n,automatic:i}=t,a=xg(e,n),o=dj(e,n,i);if(o===null)return;const u=()=>e.get(n)===a,d=async x=>{u()&&await t.generate(x)},f=async x=>{u()&&await t.rename(x)},p=async x=>{u()&&await t.applyTitle(x)};let m,y=o.order;const v=async x=>{const E=await x.settled;if(o.claim===x){if(!E){a.pendingClaim===x&&(a.pendingClaim=null);const C=Fx(a,i?[...o.claims,...a.inFlightClaims,...a.manualClaim===null?[]:[a.manualClaim]]:o.claims);if(o.claim=C,C!==null)return}return E}},b=()=>i&&Yx(e,n,a)!==void 0,T=async()=>{if(m!==void 0)for(;;){const x=o.claim;if(x!==null&&x.order>y&&Gc(a,x)){await v(x)===!0&&(m=x.title,y=x.order,await f(x.title));continue}const E=a.latestExplicit;if(E===null||E.order<=y)return;const C=await E.persisted;if(a.latestExplicit===E){if(y=E.order,C===void 0||C===m)return;m=C,await f(C)}}},w=async()=>{for(o.beforeGenerationClaims.length>0&&await Promise.all(o.beforeGenerationClaims.map(C=>C.settled));o.claim!==null;){const C=await v(o.claim);if(C!==void 0){if(C){o.superseded=!0;return}if(b())return;break}}if(!gc(a,o))return;let x=!1,E;for(await d(async C=>{x=!0,E=C,C!==void 0&&(m=C);const R=o.claim;if(R!==null){if(await v(R)!==!1)return;if(b()){o.superseded=!0;return}}gc(a,o)&&await p(E)});;){const C=o.claim;if(C===null)return;const R=await v(C);if(R!==void 0){if(R===!1){if(b())return;x&&gc(a,o)&&await p(E);return}if(!Gc(a,C))return;if(await f(C.title),m=C.title,y=C.order,o.claim===C){if(!gc(a,o))return;await p(C.title),o.superseded=!0;return}}}};try{await w(),await T()}finally{o.settlePersisted(m),a.generations.delete(o),Cg(e,n,a)}}const Es=(t,e)=>new Error(`Thread "${t}" not found while ${e}.`),ji=(t,e,n)=>new Error(`Thread "${t}" has status "${e}", so it cannot ${n}.`),hj=nj();var pj=class extends Li{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_listedAdapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_staleThreadsAdapter;_switchGeneration=0;_switchTask;_titleStates=new Map;_automaticTitles=new Map;_disposed=!1;_mainThreadId;_state=new ZD(hj);_useAdaptersProvider=({children:t})=>{const e=this._options.adapter.unstable_useAdapters;return e===void 0?t:_.jsx(this._SynthesizedAdapters,{useAdapters:e,children:t})};_SynthesizedAdapters=({useAdapters:t,children:e})=>{const n=YO(t());return n==null?e:_.jsx(mS,{adapters:n,children:e})};resolveProvider(t){return t.unstable_Provider!==void 0?t.unstable_Provider:t.unstable_useAdapters===void 0?gw:this._useAdaptersProvider}_exposedItems;_getExposedItems(){const t=this._state.value,e=this._exposedItems;if(e?.state===t&&e.mainThreadId===this._mainThreadId)return e;const n=new Set;for(const o of[t.newThreadId,...t.threadIds,...t.archivedThreadIds,this._mainThreadId]){if(o===void 0)continue;const u=bt(t,o);u!==void 0&&n.add(u.id)}const i=Object.entries(t.threadData),a=i.every(([,o])=>n.has(o.id))?t.threadData:wt(Object.fromEntries(i.filter(([,o])=>n.has(o.id))));return this._exposedItems={state:t,mainThreadId:this._mainThreadId,ids:n,items:a},this._exposedItems}get threadItems(){return this._getExposedItems().items}getLoadThreadsPromise(){if(!this._loadThreadsPromise){const t=this._loadGeneration,e=this._switchGeneration;let n=!1,i=!1;const a=ij(this._state.baseValue),o=(u,d)=>{this._loadThreadsPromise=void 0,console.error("[assistant-ui] thread list load failed:",d);const f={...u,isLoading:!1,loadError:d};return this._replaceListOnNextLoad?(this._replaceListOnNextLoad=!1,this._listedAdapterGeneration=this._adapterGeneration,n=!0,this._replaceWithThreads(f,[],void 0)):f};this._loadThreadsPromise=this._state.optimisticUpdate({execute:async()=>{try{return{success:!0,response:await this._options.adapter.list()}}catch(u){return{success:!1,error:u}}},loading:u=>t!==this._loadGeneration?u:{...u,isLoading:!0,loadError:void 0},then:(u,d)=>{if(t!==this._loadGeneration)return u;if(!d.success)return o(u,d.error);const f=d.response;let p=!1;try{return p=this._replaceListOnNextLoad,i=!0,p?(this._replaceListOnNextLoad=!1,this._listedAdapterGeneration=this._adapterGeneration,n=!0,this._replaceWithThreads({...u,loadError:void 0},f.threads,wg(f.nextCursor))):rj(u,f,a)}catch(m){return p&&(this._replaceListOnNextLoad=!0),o(u,m)}}}).catch(u=>{t===this._loadGeneration&&this._state.update(o(this._state.baseValue,u))}).then(()=>{(i||n)&&this._reapplyControlledThread(n,e)})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;const t=this._state.value;if(t.cursor===void 0||t.isLoading)return Promise.resolve();const e=this._loadGeneration,n=this._options.adapter,i=t.cursor;let a=!1;const o=this._state.optimisticUpdate({execute:()=>n.list({after:i}),loading:u=>e!==this._loadGeneration?u:{...u,isLoadingMore:!0},then:(u,d)=>e!==this._loadGeneration||n!==this._options.adapter?u:(a=!0,aj(u,d))}).catch(u=>{e===this._loadGeneration&&console.error("[assistant-ui] thread list loadMore failed:",u)}).then(()=>{this._loadMorePromise===o&&(this._loadMorePromise=void 0),a&&this._reapplyControlledThread(!1)});return this._loadMorePromise=o,o}_reapplyControlledThread(t,e=this._switchGeneration){const n=this._options.threadId;if(n===void 0)return;const i=this.getItemById(n);t&&e!==this._switchGeneration&&this._controlledSwitchGeneration!==this._switchGeneration||!t&&(i===void 0||this._controlledSwitchGeneration!==this._switchGeneration)||i?.id!==this._mainThreadId&&this._switchToThreadFromProp(n).catch(()=>{})}constructor(t,e,n){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:e},this._hookManager=new XD(t.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new bl(this.resolveProvider(t.adapter)),this.__internal_setOptions(t),this._startSwitchToNewThread(!0,n)}_initialThreadLoaded=!1;providerStore;__internal_setOptions(t){if(this._options===t)return;const e=this._options!==void 0&&this._options.adapter!==t.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==t.threadId;e&&!this._replaceListOnNextLoad&&(this._staleThreadsAdapter=this._options.adapter),this._options=t,this.providerStore.setState(this.resolveProvider(t.adapter)),this._hookManager.setRuntimeHook(t.runtimeHook),e&&(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),...Object.values(this._state.value.threadData).filter(i=>bt(this._state.baseValue,i.id)?.status==="new")].filter(i=>i.status!=="new").map(i=>i.id)),this._titleStates.clear(),this._disarmAutomaticTitles(),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0})),n&&this._switchToThreadFromProp(t.threadId).catch(()=>{})}_requireAdapterGeneration(t){if(t!==this._adapterGeneration)throw new cp}_isOtherAdaptersThread(t,e,n){const i=bt(t,n);return i===void 0?!1:(this._staleThreadIdsOnReplace?.has(i.id)?this._staleThreadsAdapter:this._options.adapter)!==e}_updateStatusFromAdapter(t,e,n,i){return this._isOtherAdaptersThread(t,e,n)?t:$c(t,n,i)}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new cp}_replaceWithThreads(t,e,n){const i=[];if(t.newThreadId){const v=Object.hasOwn(t.threadIdMap,t.newThreadId)?t.threadIdMap[t.newThreadId]:void 0,b=v&&Object.hasOwn(t.threadData,v)?t.threadData[v]:void 0;b?.status==="new"&&i.push(b)}const a=this._staleThreadIdsOnReplace;if(a){const v=new Map(e.map(b=>[b.remoteId,b]));for(const b of Object.values(t.threadData)){if(!a.has(b.id)){if(b.status!=="new"&&b.remoteId===void 0)continue;i.push(b);continue}if(b.remoteId===void 0||b.localOrigin!==!0||bt(this._state.value,b.id)===void 0)continue;const T=v.get(b.remoteId);T!==void 0&&i.push({...b,initializeTask:Promise.resolve({remoteId:T.remoteId,externalId:T.externalId})})}}const o={threadIds:[],archivedThreadIds:[],threadIdMap:wt(),threadData:wt()};for(const v of i){const b=v.id;Object.hasOwn(o.threadData,b)||(o.threadIdMap[v.id]=b,v.remoteId!==void 0&&(o.threadIdMap[v.remoteId]=b),o.threadData[b]=v)}const{threadIds:u,archivedThreadIds:d,threadIdMap:f,threadData:p}=hd(e,o);this._staleThreadIdsOnReplace=void 0,this._staleThreadsAdapter=void 0;for(const v of i){if(v.remoteId===void 0)continue;const b=v.id,T=Object.hasOwn(p,b)?p[b]:void 0;T!==void 0&&(T.status==="regular"&&!u.includes(T.id)?u.push(T.id):T.status==="archived"&&!d.includes(T.id)&&d.push(T.id))}let m={...t,isLoading:!1,cursor:n,threadIds:u,archivedThreadIds:d,threadIdMap:f,threadData:p,newThreadId:t.newThreadId!==void 0&&!Object.hasOwn(f,t.newThreadId)?void 0:t.newThreadId};if(bt(m,this._mainThreadId)===void 0){const v=m.newThreadId;if(v!==void 0)this._mainThreadId=v;else{const b=up(m);this._mainThreadId=b.id,m=b.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}const y=new Set(Object.values(m.threadData).map(v=>v.id));for(const v of Object.values(t.threadData))if(!y.has(v.id)){this._disarmAutomaticTitle(v.id);try{this._hookManager.stopThreadRuntime(v.id)}catch(b){console.error("[assistant-ui] Thread runtime cleanup threw while stopping a thread",b)}}return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>{}),m}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;const t=this._options.threadId??this._options.initialThreadId;t!==void 0&&(this._options.threadId!==void 0?this._switchToThreadFromProp(t):this.switchToThread(t)).catch(()=>{})}async reloadMainThread(){const t=this._mainThreadId;if(t===void 0||this.getItemById(t)?.status==="new")return;const e=this._hookManager.getThreadRuntimeCore(t);try{e?.unstable_refetchThread?await e.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(t)}catch(n){if(t!==this._mainThreadId)return;throw n}t===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 bt(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(t=!0){const e=this._mainThreadRemoteId;this._lastNotifiedThreadId!==e&&(this._lastNotifiedThreadId=e,t&&JD("assistant-ui","onThreadIdChange",this._options.onThreadIdChange,e))}getMainThreadRuntimeCore(){const t=this._hookManager.getThreadRuntimeCore(this._mainThreadId);return t||ej}getThreadRuntimeCore(t){const e=this.getItemById(t);if(!e)throw Es(t,"getting its runtime");const n=this._hookManager.getThreadRuntimeCore(e.id);if(!n)throw new Error(`Runtime for thread "${t}" not found while getting its runtime.`);return n}unstable_isThreadRunning(t){const e=this.getItemById(t);return e?this._hookManager.__internal_isThreadRunning(e.id):!1}unstable_subscribeThreadEvents(t){return this._hookManager.__internal_subscribeThreadEvents(t)}_getExposedItem(t){const e=bt(this._state.value,t);if(!(e===void 0||!this._getExposedItems().ids.has(e.id)))return e}getItemById(t){const e=bt(this._state.value,t);if(e!==void 0&&(this._getExposedItems().ids.has(e.id)||this._hookManager.__internal_hasThreadRuntime(e.id)))return e}switchToThread(t,e){return this._startSwitchToThread(t,e,!0)}_startSwitchToThread(t,e,n){const i=++this._switchGeneration,a=this._switchToThread(t,e,i,n);return this._switchTask=a,a}async _switchToThread(t,e,n,i){if(this._replaceListOnNextLoad&&t!==this._state.value.newThreadId)throw new cp;let a=bt(this._state.value,t);if(!a){const d=this._options.adapter;if(await this._state.optimisticUpdate({execute:()=>d.fetch(t),then:(f,p)=>n===this._switchGeneration?tj(f,p):f}),n!==this._switchGeneration)return;a=bt(this._state.value,t)}if(!a)throw Es(t,"switching to it");if(this._mainThreadId===a.id)return;const o=this._hookManager.startThreadRuntime(a.id);if(this.mainThreadId!==void 0?await o:o.then(()=>this._notifySubscribers(),()=>{}),n!==this._switchGeneration)return;let u=bt(this._state.value,a.id);u?.id===a.id&&(u.status==="archived"&&e?.unarchive!==!1&&(await u.initializeTask,n!==this._switchGeneration||(u=bt(this._state.value,a.id),u?.id!==a.id)||u.status==="archived"&&(await this._unarchive(u.id,u),n!==this._switchGeneration||(u=bt(this._state.value,a.id),u?.id!==a.id)))||(this._setMainThreadId(u.id),this._notifySubscribers(),this._notifyThreadIdChange(i)))}_setMainThreadId(t){if(this._mainThreadId=t,this._disposed||this._hookManager.getThreadRuntimeCore(t))return;const e=()=>this._notifySubscribers();this._hookManager.startThreadRuntime(t).then(e,e)}switchToNewThread(){return this._startSwitchToNewThread(!0)}_controlledSwitchGeneration;_switchToThreadFromProp(t){const e=t!==void 0?us("switch",()=>this._startSwitchToThread(t,void 0,!1)):us("create",()=>this._startSwitchToNewThread(!1));return this._controlledSwitchGeneration=this._switchGeneration,e}_startSwitchToNewThread(t,e){const n=++this._switchGeneration,i=this._switchToNewThread(n,t,e);return this._switchTask=i,i}async _switchToNewThread(t,e,n){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),t!==this._switchGeneration)return;const i=this._state.baseValue;let a=this._state.value.newThreadId;if(a===void 0){const o=up(i,n);a=o.id,this._state.update(o.state)}return this._switchToThread(a,void 0,t,e)}initialize=async t=>{const e=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==t){this._requireAdapterSettled();const f=bt(this._state.value,t);if(!f)throw Es(t,"initializing it");if(f.status==="new")throw ji(t,f.status,"be initialized here");const{remoteId:p,externalId:m}=await f.initializeTask;return this._requireAdapterGeneration(n),{remoteId:p,externalId:m}}this._requireAdapterGeneration(n);const i=e.initialize(t);let a;const o=this._state.optimisticUpdate({execute:()=>i,optimistic:f=>this._listedAdapterGeneration>n?f:lj(f,t,i),then:(f,{remoteId:p,externalId:m})=>{if(n!==this._adapterGeneration)return f;const y=oj(f,t,p,m,t);return a=y.removedMappingId,a===this._mainThreadId&&this._setMainThreadId(y.survivorMappingId),y.state}});this._armAutomaticTitle(t,o);const{remoteId:u,externalId:d}=await o.finally(()=>{this._leaveRemovedMainThread(t).catch(()=>{})});return this._requireAdapterGeneration(n),a!==void 0&&this._hookManager.stopThreadRuntime(a),{remoteId:u,externalId:d}};_armAutomaticTitle(t,e){if(this._disposed)return;this._automaticTitles.get(t)?.();let n,i,a=[],o=!1,u=!1,d=!0;const f=()=>{if(!d)return;const m=this.getItemById(t);if(!m){this._disarmAutomaticTitle(t);return}const y=this._hookManager.getThreadRuntimeCore(m.id);y!==n&&(i?.(),n=y,i=y?.subscribe(f));const v=n?.messages.filter(NS);if(v?.length&&(a=v),!(!o||u||!n||n.isLoading||a.length===0)){if(this._replaceListOnNextLoad){u=!0,this._state.waitForUpdate().then(()=>{u=!1,f()});return}u=!0,this._generateTitle(t,{automatic:!0},()=>d?a:void 0).then(b=>{u=!1,d&&(b?this._disarmAutomaticTitle(t):f())},b=>{d&&(this._disarmAutomaticTitle(t),!Xw(b)&&console.error("[assistant-ui] Thread title generation failed",b))})}},p=this._hookManager.subscribe(f);this._automaticTitles.set(t,()=>{d=!1,p(),i?.()}),e.then(()=>{o=!0,f()},()=>{d&&this._disarmAutomaticTitle(t)}),f()}_disarmAutomaticTitle(t){this._automaticTitles.get(t)?.(),this._automaticTitles.delete(t)}_disarmAutomaticTitles(){for(const t of[...this._automaticTitles.keys()])this._disarmAutomaticTitle(t)}generateTitle=async(t,e)=>{await this._generateTitle(t,e)};_generateTitle=async(t,e,n)=>{this._requireAdapterSettled();const i=this._options.adapter,a=this._adapterGeneration,o=this.getItemById(t);if(!o)throw Es(t,"generating its title");if(o.status==="new")throw ji(t,o.status,"generate a title");const{remoteId:u}=await o.initializeTask;this._requireAdapterGeneration(a);const d=n?.();if(n&&!d)return!1;const f=this._hookManager.getThreadRuntimeCore(o.id);if(!f||n&&f.isLoading)return!1;const p=f.messages.filter(NS),m=p.length?p:d??p,y=()=>bt(this._state.baseValue,o.id)===void 0;return await fj({states:this._titleStates,threadId:o.id,automatic:e?.automatic===!0,generate:async v=>{if(y())return;const b=await i.generateTitle(u,m);this._requireAdapterGeneration(a),await uj(b,v)},rename:async v=>{this._requireAdapterGeneration(a),!y()&&await i.rename(u,v)},applyTitle:async v=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:b=>{if(a!==this._adapterGeneration)return b;const T=bt(b,o.id);return T?{...b,threadData:{...b.threadData,[T.id]:{...T,title:v}}}:b}})}}),!0};async rename(t,e){this._requireAdapterSettled();const n=this._options.adapter,i=this._adapterGeneration,a=this._getExposedItem(t);if(!a)throw Es(t,"renaming it");if(a.status==="new")throw ji(t,a.status,"be renamed");const o=cj(this._titleStates,a.id,e);try{const u=await this._state.optimisticUpdate({execute:async()=>{const{remoteId:d}=await a.initializeTask;return this._requireAdapterGeneration(i),n.rename(d,e)},optimistic:d=>{if(this._isOtherAdaptersThread(d,n,t))return d;const f=bt(d,t);return f?{...d,threadData:{...d.threadData,[f.id]:{...f,title:e}}}:d}});return OS(this._titleStates,a.id,o,!0),u}catch(u){throw OS(this._titleStates,a.id,o,!1),u}}async updateCustom(t,e){this._requireAdapterSettled();const n=this._options.adapter,i=this._adapterGeneration,a=this._getExposedItem(t);if(!a)throw Es(t,"updating its custom metadata");if(a.status==="new")throw ji(t,a.status,"update custom metadata");if(!n.updateCustom)throw new Error("Remote thread list adapter does not support updating custom metadata");return this._state.optimisticUpdate({execute:async()=>{const{remoteId:o}=await a.initializeTask;if(this._requireAdapterGeneration(i),!n.updateCustom)throw new Error("Remote thread list adapter does not support updating custom metadata");return n.updateCustom(o,e)},optimistic:o=>{if(this._isOtherAdaptersThread(o,n,t))return o;const u=bt(o,t);return u?{...o,threadData:{...o.threadData,[u.id]:{...u,custom:e}}}:o}})}async _ensureThreadIsNotMain(t){if(t===this.newThreadId)throw new Error("Cannot ensure new thread is not main");let e;for(;this._isMainThread(t);){if(t===this.newThreadId)throw new Error("Cannot ensure new thread is not main");let n=this._switchTask;const i=!n||n===e;i&&(n=this.switchToNewThread()),e=n;try{await n}catch(a){if(i&&this._switchTask===n)throw a}}}_isMainThread(t){return(this.getItemById(t)?.id??t)===this._mainThreadId}async _leaveRemovedMainThread(t){const e=this._mainThreadId,n=this.getItemById(e);if(n!==void 0&&(n.status!=="archived"||!this._isMainThread(t)))return;const i=this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;if(n===void 0&&!i){let a=this._state.value.newThreadId;if(a===void 0){const o=up(this._state.baseValue);a=o.id,this._state.update(o.state)}this._mainThreadId=bt(this._state.value,a)?.id??a,this._hookManager.stopThreadRuntime(e),this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>{}),this._notifySubscribers(),this._notifyThreadIdChange();return}await this._ensureThreadIsNotMain(e),this.getItemById(e)===void 0&&this._hookManager.stopThreadRuntime(e)}async archive(t){this._requireAdapterSettled();const e=this._options.adapter,n=this._adapterGeneration,i=this._getExposedItem(t);if(!i)throw Es(t,"archiving it");if(i.status!=="regular")throw ji(t,i.status,"be archived");do await this._ensureThreadIsNotMain(i.id);while(i.id===this._mainThreadId);this._requireAdapterGeneration(n),await this._state.optimisticUpdate({execute:async()=>{const{remoteId:a}=await i.initializeTask;return this._requireAdapterGeneration(n),e.archive(a)},optimistic:a=>this._updateStatusFromAdapter(a,e,i.id,"archived")}),await this._leaveRemovedMainThread(i.id)}unarchive(t){return this._unarchive(t,this._getExposedItem(t))}async _unarchive(t,e){this._requireAdapterSettled();const n=this._options.adapter,i=this._adapterGeneration;if(!e)throw Es(t,"unarchiving it");if(e.status!=="archived")throw ji(t,e.status,"be unarchived");return this._state.optimisticUpdate({execute:async()=>{try{const{remoteId:a}=await e.initializeTask;return this._requireAdapterGeneration(i),await n.unarchive(a)}catch(a){throw i===this._adapterGeneration&&await this._ensureThreadIsNotMain(e.id),a}},optimistic:a=>this._updateStatusFromAdapter(a,n,e.id,"regular")})}async delete(t){this._requireAdapterSettled();const e=this._options.adapter,n=this._adapterGeneration,i=this._getExposedItem(t);if(!i)throw Es(t,"deleting it");if(i.status!=="regular"&&i.status!=="archived")throw ji(t,i.status,"be deleted");const a=bt(this._state.baseValue,i.id);let o;try{do await this._ensureThreadIsNotMain(i.id);while(i.id===this._mainThreadId);this._requireAdapterGeneration(n),await this._state.optimisticUpdate({execute:async()=>({remoteId:o}=await i.initializeTask,this._requireAdapterGeneration(n),await e.delete(o)),optimistic:u=>this._isOtherAdaptersThread(u,e,i.id)?u:kS(u,i.id,this._options.adapter===e?o:void 0)})}catch(u){const d=()=>{if(n===this._adapterGeneration)return;const p=bt(this._state.baseValue,i.id);if(p?.status==="new"&&p===a&&this._mainThreadId!==p.id){this._state.update(kS(this._state.baseValue,i.id,void 0)),this._hookManager.stopThreadRuntime(i.id),dp(this._titleStates,i.id);return}this._replaceListOnNextLoad&&p!==void 0&&p.status!=="new"&&p.remoteId===void 0&&this._mainThreadId!==p.id&&!this._isOtherAdaptersThread(this._state.baseValue,e,i.id)&&(this._state.update($c(this._state.baseValue,i.id,"deleted")),this._hookManager.stopThreadRuntime(i.id),dp(this._titleStates,i.id))};n!==this._adapterGeneration&&this._replaceListOnNextLoad&&bt(this._state.baseValue,i.id)?.status==="new"?i.initializeTask.then(d,()=>{}):d();const f=this._options.threadId;throw this._switchGeneration===this._controlledSwitchGeneration&&f!==void 0&&this._mainThreadId!==i.id&&this.getItemById(f)?.id===i.id&&this._switchToThreadFromProp(f).catch(()=>{}),u}this._isOtherAdaptersThread(this._state.value,e,i.id)||(this._hookManager.stopThreadRuntime(i.id),dp(this._titleStates,i.id),await this._leaveRemovedMainThread(i.id))}__internal_dispose(){this._disposed=!0,this._disarmAutomaticTitles(),this._hookManager.__internal_dispose()}async detach(t){const e=this._adapterGeneration,n=this.getItemById(t);if(!n)throw Es(t,"detaching it");if(n.status!=="regular"&&n.status!=="archived")throw ji(t,n.status,"be detached");do await this._ensureThreadIsNotMain(n.id);while(n.id===this._mainThreadId);this._requireAdapterGeneration(e),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new bl([]);__internal_RenderComponent=()=>{const t=ad();Ce(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),t]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(a=>a!==t))}),[t]);const e=ln(this.boundIdsStore),n=ln(this.providerStore),i=ke();return(e.length===0||e[0]===t)&&_.jsxs(mS,{adapters:this._runtimeAdapters,children:[_.jsx(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),_.jsx(this._hookManager.__internal_Host,{parentClient:i})]})}},mj=class extends Tg{threads;constructor(t,e){super(),this.threads=new pj(t,this._contextProvider,e)}get RenderComponent(){return this.threads.__internal_RenderComponent}};const gj=t=>{const e=ad(),n=Fw(),[i]=Ne(()=>new mj(t,n?e:void 0)),[a]=Ne(()=>({generation:0}));Os(()=>{const u=++a.generation;return()=>queueMicrotask(()=>{a.generation===u&&i.threads.__internal_dispose()})},[i,a]),Ce(()=>{i.threads.__internal_setOptions(t),i.threads.__internal_load()},[i,t]),Ce(()=>{if(typeof window>"u"||typeof document>"u")return;const u=()=>{i.threads.loadError!==void 0&&i.threads.reload()},d=()=>{document.visibilityState==="visible"&&u()};return window.addEventListener("online",u),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("online",u),document.removeEventListener("visibilitychange",d)}},[i]);const[o]=Ne(()=>new Sg(i));return o},yj=t=>{const[e]=Ne(()=>new bl(t.runtimeHook));Ha(()=>{e.setState(t.runtimeHook)},[e,t.runtimeHook]);const n=we(t.initialThreadId),[i]=Ne(()=>function(){return ln({subscribe:e.subscribe,getState:e.getState,getServerSnapshot:e.getState})()}),a=bn(u=>t.onThreadIdChange?.(u)),o=yt(()=>({adapter:t.adapter,allowNesting:t.allowNesting,threadId:t.threadId,initialThreadId:n.current,runtimeHook:i,onThreadIdChange:a}),[t.adapter,t.allowNesting,t.threadId,i]);if(ke().threadListItem.source!==null){if(!o.allowNesting)throw new Error("useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).");return t.runtimeHook()}return gj(o)},vj=t=>{const e=t.type;switch(e){case"text":return{type:"text",...t.id!==void 0?{id:t.id}:void 0,text:t.text,...t.providerMetadata!==void 0?{providerMetadata:t.providerMetadata}:void 0,...t.parentId!==void 0?{parentId:t.parentId}:void 0};case"image":return{type:"image",...t.id!==void 0?{id:t.id}:void 0,image:t.image,...t.filename!=null?{filename:t.filename}:void 0,...t.providerMetadata!==void 0?{providerMetadata:t.providerMetadata}:void 0};case"file":return{type:"file",...t.id!==void 0?{id:t.id}:void 0,data:t.data,mimeType:t.mimeType,...t.filename!=null?{filename:t.filename}:void 0,...t.sourceType!=null?{sourceType:t.sourceType}:void 0,...t.providerMetadata!=null?{providerMetadata:t.providerMetadata}:void 0,...t.parentId!==void 0?{parentId:t.parentId}:void 0};case"audio":return{type:"audio",audio:{data:t.audio.data,format:t.audio.format}};case"data":return Mr(t.data)||console.warn(`attachment data is not JSON! ${JSON.stringify(t)}`),{type:"data",...t.id!==void 0?{id:t.id}:void 0,name:t.name,data:t.data};default:throw new Error(`Attachment part type not supported by aui/v0: ${e}`)}},bj=t=>{if(!(t.role!=="user"||t.attachments.length===0))return t.attachments.map(({id:e,type:n,name:i,contentType:a,status:o,content:u})=>({id:e,type:n,name:i,status:o,...a!=null?{contentType:a}:void 0,content:u.map(vj)}))},DS=t=>{if(t!==void 0)try{const e=JSON.stringify(t);return e===void 0?void 0:JSON.parse(e)}catch{return}},om=(t,e=0)=>{if(e>100||t===void 0||typeof t=="function")return!1;if(typeof t=="number")return Number.isFinite(t);if(typeof t!="object"||t===null||typeof t.toJSON=="function")return!0;if((t instanceof Map||t instanceof Set)&&t.size>0)return!1;if(Array.isArray(t)){if(Reflect.ownKeys(t).length!==t.length+1)return!1;for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!om(t[n],e+1))return!1;return!0}return Reflect.ownKeys(t).every(n=>typeof n=="string"&&Object.getOwnPropertyDescriptor(t,n)?.enumerable===!0&&om(t[n],e+1))},_j=t=>{try{return!om(t)}catch{return!0}};function lm(t){const e=t.status?.type==="running"?{type:"incomplete",reason:"cancelled"}:t.status,n=bj(t);return{role:t.role,content:t.content.map(i=>{const a=i.type;switch(a){case"text":return{type:"text",...i.id!==void 0?{id:i.id}:void 0,text:i.text,...i.providerMetadata!==void 0?{providerMetadata:i.providerMetadata}:void 0,...i.parentId!==void 0?{parentId:i.parentId}:void 0};case"reasoning":return{type:"reasoning",...i.id!==void 0?{id:i.id}:void 0,text:i.text,...i.unstable_summary!==void 0?{unstable_summary:i.unstable_summary}:void 0,...i.timing!==void 0?{timing:i.timing}:void 0,...i.providerMetadata!==void 0?{providerMetadata:i.providerMetadata}:void 0,...i.parentId!==void 0?{parentId:i.parentId}:void 0};case"source":return i.sourceType==="url"?{type:"source",sourceType:"url",id:i.id,url:i.url,...i.title!=null?{title:i.title}:void 0,...i.providerMetadata!=null?{providerMetadata:i.providerMetadata}:void 0,...i.parentId!==void 0?{parentId:i.parentId}:void 0}:{type:"source",sourceType:"document",id:i.id,title:i.title,mediaType:i.mediaType,...i.filename!=null?{filename:i.filename}:void 0,...i.providerMetadata!=null?{providerMetadata:i.providerMetadata}:void 0,...i.parentId!==void 0?{parentId:i.parentId}:void 0};case"tool-call":{const o=DS(i.result);i.result!==void 0&&(o===void 0||_j(i.result))&&console.warn(o===void 0?`tool-call result for ${i.toolCallId} cannot be serialized as JSON; omitted`:`tool-call result for ${i.toolCallId} loses data in JSON; persisted as its JSON form`);const u=DS(i.artifact);i.artifact!==void 0&&u===void 0&&console.warn(`tool-call artifact is not JSON for ${i.toolCallId}`);const d=pg(i.unstable_interactions);return{type:"tool-call",toolCallId:i.toolCallId,toolName:i.toolName,...JSON.stringify(i.args)===i.argsText?{args:i.args}:{argsText:i.argsText},...o!==void 0?{result:o}:void 0,...u!==void 0?{artifact:u}:void 0,...i.modelContent!==void 0?{modelContent:i.modelContent}:void 0,...i.providerMetadata!==void 0?{providerMetadata:i.providerMetadata}:void 0,...i.isPreliminary?{isPreliminary:!0}:void 0,...i.isError?{isError:!0}:void 0,...i.interrupt!==void 0?{interrupt:{type:i.interrupt.type,payload:i.interrupt.payload}}:void 0,...i.timing!==void 0?{timing:i.timing}:void 0,...i.mcp!==void 0?{mcp:i.mcp}:void 0,...i.approval?{approval:i.approval}:void 0,...i.parentId!==void 0?{parentId:i.parentId}:void 0,...i.messages!==void 0?{messages:i.messages.map(wj)}:void 0,...d!==void 0?{unstable_interactions:d}:void 0}}case"image":return{type:"image",...i.id!==void 0?{id:i.id}:void 0,image:i.image,...i.filename!=null?{filename:i.filename}:void 0,...i.providerMetadata!=null?{providerMetadata:i.providerMetadata}:void 0};case"file":return{type:"file",...i.id!==void 0?{id:i.id}:void 0,data:i.data,mimeType:i.mimeType,...i.filename!=null?{filename:i.filename}:void 0,...i.sourceType?{sourceType:i.sourceType}:void 0,...i.providerMetadata!=null?{providerMetadata:i.providerMetadata}:void 0,...i.parentId!==void 0?{parentId:i.parentId}:void 0};case"data":return Mr(i.data)||console.warn(`data part is not JSON! ${JSON.stringify(i)}`),{type:"data",...i.id!==void 0?{id:i.id}:void 0,name:i.name,data:i.data};case"audio":return{type:"audio",audio:{data:i.audio.data,format:i.audio.format}};case"generative-ui":return{type:"generative-ui",spec:i.spec,...i.id!==void 0?{id:i.id}:void 0,...i.parentId!==void 0?{parentId:i.parentId}:void 0};default:throw new Error(`Message part type not supported by aui/v0: ${a}`)}}),metadata:t.metadata,...e?{status:e}:void 0,...n?{attachments:n}:void 0}}const Sj=(t,e,n)=>e.flatMap(i=>{if(!wx(t,i))return[];if(i.type!=="tool-call"||i.messages===void 0)return[i];const{messages:a,...o}=i;return!Array.isArray(a)||n>=100?[o]:[{...o,messages:a.flatMap(u=>{const d=Qx(u,n+1);return d?[d]:[]})}]}),Tj=t=>t.flatMap(e=>{const n=JO(e,i=>wx("user",i));return n?[n]:[]}),Qx=(t,e)=>{if(!Ze(t)||!KO(t.role)||!Array.isArray(t.content))return null;const{role:n}=t,i=Sj(n,t.content,e);if(n==="system"&&i.length!==1)return null;const{attachments:a,createdAt:o,status:u,metadata:d,...f}=t,p=QO(o),m=Ze(d)?n==="assistant"?{...d,steps:Sx(d.steps)}:{...d,steps:void 0}:d;return{...f,...p?{createdAt:o}:void 0,...n==="assistant"&&bx(u)?{status:u}:void 0,...d!==void 0?{metadata:m}:void 0,content:i,...n==="user"&&Array.isArray(a)?{attachments:Tj(a)}:void 0}};function jS(t){try{const e=Qx(t.content,0);if(!e)throw new Error("stored row is not an aui/v0 message");return{parentId:t.parent_id,message:Kx({...e,id:t.id,createdAt:t.created_at},t.id)}}catch(e){return console.warn(`aui/v0: dropping unreadable message ${t.id}`,e),null}}const wj=t=>({...lm(t),id:t.id,createdAt:t.createdAt.toISOString()}),Kx=(t,e)=>_l({...t,content:t.content.map((n,i)=>n.type!=="tool-call"||n.messages===void 0?n:{...n,messages:n.messages.map((a,o)=>Kx({...a,createdAt:a.createdAt!==void 0?new Date(a.createdAt):t.createdAt},a.id??`${e}-${n.toolCallId}-${i}-${o}`))})},e,{type:"complete",reason:"unknown"});var Sl=class extends Error{constructor(t){super(t),this.name="CloudResponseError"}};const ii=(t,e)=>new Sl(`Invalid Assistant Cloud response for "${t}": expected ${e}`),Mt=(t,e)=>{if(typeof t!="object"||t===null||Array.isArray(t))throw ii(e,"an object");return t},kl=(t,e)=>{if(!Array.isArray(t))throw ii(e,"an array");return t},mt=(t,e)=>{if(typeof t!="string")throw ii(e,"a string");return t},xj=(t,e)=>{if(typeof t!="number"||!Number.isFinite(t))throw ii(e,"a number");return t},Cj=(t,e)=>t===null?null:xj(t,e),Xx=(t,e,n)=>{const i=mt(t,e);if(!n.includes(i))throw ii(e,`one of ${n.map(a=>`"${a}"`).join(", ")}`);return i},Ga=(t,e)=>t===null?null:mt(t,e),um=(t,e)=>{if(typeof t!="boolean")throw ii(e,"a boolean");return t},Jx=(t,e)=>{if(!Number.isInteger(t))throw ii(e,"an integer");return t},dl=(t,e)=>{if(typeof t!="string")throw ii(e,"a canonical ISO timestamp");const n=new Date(t);if(Number.isNaN(n.getTime())||n.toISOString()!==t)throw ii(e,"a canonical ISO timestamp");return n},Ej=(t,e)=>Mt(t,e),fp=t=>{if(!t)return t;let e=t.length;for(;e>0&&t[e-1]==="/";)e--;return t.slice(0,e)},zS=3e4,PS=async(t,e)=>{const n=new AbortController;let i=!1;const a=setTimeout(()=>{i=!0,n.abort()},zS);try{return await e(n.signal)}catch(o){throw i?new Error(`Assistant Cloud ${t} timed out after ${zS}ms`,{cause:o}):o}finally{clearTimeout(a)}},BS=t=>{try{const e=t.split(".")[1];if(!e)throw new Error("Invalid JWT format");let n=e.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";const i=atob(n),a=JSON.parse(i).exp;if(!a||typeof a!="number")throw new Error('JWT does not contain a valid "exp" field');return a*1e3}catch(e){throw new Error(`Unable to determine the token expiry: ${e}`)}},cm=(t,e)=>{const n=mt(t,e);if(n.length===0)throw new Sl(`Invalid Assistant Cloud response for "${e}": expected a non-empty string`);return n},US=(t,e)=>{const n=Mt(t,e);return{token:cm(n.token,`${e}.token`),expires_at:cm(n.expires_at,`${e}.expires_at`)}},LS=async(t,e)=>{let n;try{n=await t.json()}catch{throw new Sl(`Invalid Assistant Cloud response for "${e}": expected valid JSON`)}const i=Mt(n,e);return{data:i,accessToken:cm(i.access_token,`${e}.access_token`)}};var Zx=class{strategy="jwt";cachedToken=null;tokenExpiry=null;tokenRequest=null;generation=0;#e;constructor(t){this.#e=t}async getAuthHeaders(){const t=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-t>3e4)return this.createAuthHeaders(this.cachedToken);this.tokenRequest||(this.tokenRequest=this.fetchAuthHeaders(this.generation));const e=this.tokenRequest;try{return await e}finally{this.tokenRequest===e&&(this.tokenRequest=null)}}async fetchAuthHeaders(t){const e=await this.#e();if(t!==this.generation)return!1;if(!e)return this.cachedToken=null,this.tokenExpiry=null,!1;const n=BS(e);return this.cachedToken=e,this.tokenExpiry=n,this.createAuthHeaders(e)}createAuthHeaders(t){return{Authorization:`Bearer ${t}`}}readAuthHeaders(t){const e=t.get("Authorization");if(!e)return;const[n,i]=e.split(" ");if(n!=="Bearer"||!i)throw new Error("Invalid auth header received");const a=BS(i);this.cachedToken=i,this.tokenExpiry=a}invalidate(){this.generation++,this.cachedToken=null,this.tokenExpiry=null,this.tokenRequest=null}},Aj=class{strategy="api-key";#e;#t;#n;constructor(t,e,n){this.#e=t,this.#t=e,this.#n=n}async getAuthHeaders(){return{Authorization:`Bearer ${this.#e}`,"Aui-User-Id":this.#t,"Aui-Workspace-Id":this.#n}}readAuthHeaders(){}invalidate(){}};const Eg="aui:refresh_token",Ag=t=>`${Eg}:${t}`,hp=t=>{try{t.removeItem(Eg)}catch{}},pd=()=>{if(!("localStorage"in globalThis))return null;try{return globalThis.localStorage}catch{return null}},Ij=t=>{const e=pd();if(e)try{const n=Ag(t),i=e.getItem(n);if(i)return hp(e),JSON.parse(i);const a=e.getItem(Eg);if(!a)return;let o;try{o=JSON.parse(a)}catch{hp(e);return}return e.setItem(n,a),hp(e),o}catch{return}},qS=(t,e)=>{const n=pd();if(n)try{n.setItem(Ag(t),JSON.stringify(e))}catch{}},Rj=t=>{const e=pd();if(e)try{e.removeItem(Ag(t))}catch{}},HS=new WeakMap,Mj=()=>"navigator"in globalThis?globalThis.navigator?.locks??null:null,kj=t=>`assistant-cloud:anonymous-auth:${t}`,Nj=(t,e)=>{const n=pd();if(!n)return e();let i=HS.get(n);i||(i=new Map,HS.set(n,i));const a=i.get(t);if(a)return a;const o=Mj(),u=(o?o.request(kj(t),e):e()).finally(()=>{i.get(t)===u&&i.delete(t)});return i.set(t,u),u};var Oj=class{strategy="anon";baseUrl;jwtStrategy;constructor(t){this.baseUrl=t;const e=async()=>{const n=Date.now(),i=Ij(this.baseUrl);if(i)if(new Date(i.expires_at).getTime()-n>3e4){const a=await PS("refresh token request",async o=>{const u=await fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:i.token}),signal:o});if(u.ok){const{data:d,accessToken:f}=await LS(u,"refresh auth token response");return d.refresh_token!=null&&qS(this.baseUrl,US(d.refresh_token,"refresh auth token response.refresh_token")),f}if(u.status===429||u.status>=500)throw new Error(`Assistant Cloud token refresh failed with status ${u.status}`);return null});if(a!==null)return a}else Rj(this.baseUrl);return PS("anonymous token request",async a=>{const o=await fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:"POST",signal:a});if(!o.ok)return null;const{data:u,accessToken:d}=await LS(o,"anonymous auth token response");return qS(this.baseUrl,US(u.refresh_token,"anonymous auth token response.refresh_token")),d})};this.jwtStrategy=new Zx(()=>Nj(this.baseUrl,e))}async getAuthHeaders(){return this.jwtStrategy.getAuthHeaders()}readAuthHeaders(t){this.jwtStrategy.readAuthHeaders(t)}invalidate(){this.jwtStrategy.invalidate()}};const Dj="0.2.7";var Ig=class extends Error{status;code;details;constructor(t,e,n,i){super(t),this.status=e,n!==void 0&&(this.code=n),i!==void 0&&(this.details=i),this.name="CloudAPIError"}};const VS=/^[\x21-\x7e]+$/,Oa=new WeakMap,Wx=async(t,e,n,i=Oa.get(t)??0)=>{const a=await t._auth.getAuthHeaders();if(i!==(Oa.get(t)??0)||!a)throw new Error("Authorization failed");return{...a,...n,...e,"Aui-Sdk":t.sdkHeader()}};var jj=class{_auth;_baseUrl;registerSdk;sdkHeader;constructor(t){const e=new Map;if(this.registerSdk=n=>{const i=n.name.trim(),a=n.version.trim();!VS.test(i)||!VS.test(a)||e.set(`${i}/${a}`,{name:i,version:a})},this.sdkHeader=()=>[`assistant-cloud/${Dj}`,...Array.from(e.values(),({name:n,version:i})=>`${n}/${i}`)].join(" "),"authToken"in t)this._baseUrl=fp(t.baseUrl),this._auth=new Zx(t.authToken);else if("apiKey"in t)this._baseUrl=fp(t.baseUrl??"https://backend.assistant-api.com"),this._auth=new Aj(t.apiKey,t.userId,t.workspaceId);else if("anonymous"in t)this._baseUrl=fp(t.baseUrl),this._auth=new Oj(this._baseUrl);else throw new Error("Invalid configuration: Must provide authToken, apiKey, or anonymous configuration")}async initializeAuth(){return!!await this._auth.getAuthHeaders()}invalidateAuth(){Oa.set(this,(Oa.get(this)??0)+1),this._auth.invalidate()}async makeRawRequest(t,e={}){const n=Oa.get(this)??0,i=await Wx(this,{"Content-Type":"application/json"},e.headers,n),a=new URLSearchParams;if(e.query)for(const[d,f]of Object.entries(e.query))f!==!1&&(f===!0?a.set(d,"true"):a.set(d,f.toString()));const o=new URL(`${this._baseUrl}/v1${t}`);o.search=a.toString();const u=await fetch(o,{method:e.method??"GET",headers:i,body:e.body?JSON.stringify(e.body):null,...e.keepalive?{keepalive:!0}:{}});if(n===(Oa.get(this)??0)&&this._auth.readAuthHeaders(u.headers),!u.ok){const d=await u.text();let f,p,m;try{const y=JSON.parse(d);if(typeof y=="object"&&y!==null&&!Array.isArray(y)){const v=y;typeof v.message=="string"&&v.message.length>0&&(f=v.message),typeof v.error=="string"&&(p=v.error,m={...v},delete m.error)}}catch{}throw new Ig(f??`Request failed with status ${u.status}, ${d}`,u.status,p,m)}return u}async makeRequest(t,e={}){const n=await this.makeRawRequest(t,e);if(n.status===204||n.headers.get("content-length")==="0")return;const i=await n.text();if(i.trim()!=="")return JSON.parse(i)}};const zj=20,Pj=50,Bj=2e3,Uj=[250,1e3],eC=new WeakMap,$S=t=>{eC.get(t)?.()};var Lj=class{buffer=[];timer;flushing;retryTimer;resolveRetryDelay;bestEffortRequested=!1;generation=0;cloud;isEnabled;listening=!1;constructor(t,e){this.cloud=t,this.isEnabled=e,eC.set(this,()=>this.clearPending())}track(t){if(this.isEnabled()){if(this.listen(),this.buffer.push(qj(t)),this.buffer.length>=zj){this.flush(!0);return}this.scheduleFlush()}}listen(){this.listening||typeof window>"u"||typeof document>"u"||(this.listening=!0,window.addEventListener("pagehide",this.flushBestEffort),document.addEventListener("visibilitychange",this.onVisibilityChange))}unlisten(){this.listening&&(this.listening=!1,window.removeEventListener("pagehide",this.flushBestEffort),document.removeEventListener("visibilitychange",this.onVisibilityChange))}dispose(){this.unlisten(),this.clearFlushTimer(),this.flushBestEffort()}clearPending(){this.generation++,this.buffer=[],this.clearFlushTimer(),this.interruptRetryDelay(),this.unlisten()}onVisibilityChange=()=>{document.visibilityState==="hidden"&&this.flushBestEffort()};flushBestEffort=()=>(this.flushing&&(this.bestEffortRequested=!0,this.interruptRetryDelay()),this.flush(!1));flush=async t=>{if(!this.isEnabled()){this.clearPending();return}if(this.flushing)return this.flushing;this.clearFlushTimer();const e=this.flushPending(t);return this.flushing=e,e.then(()=>{this.flushing===e&&(this.flushing=void 0,this.bestEffortRequested=!1,this.buffer.length===0?(this.clearFlushTimer(),this.unlisten()):this.flush(!0))}),e};async flushPending(t){for(;this.buffer.length>0;){if(!this.isEnabled()){this.buffer=[];return}const e=this.buffer.splice(0,Pj),n=this.generation;for(let i=0;;i++)try{if(await this.cloud.makeRequest("/events",{method:"POST",body:{events:e},keepalive:!0}),n!==this.generation)return;break}catch{if(n!==this.generation)return;const a=t&&!this.bestEffortRequested?Uj[i]:void 0;if(a===void 0)break;if(await this.waitForRetry(a),n!==this.generation)return;if(!this.isEnabled())return this.clearPending();if(this.bestEffortRequested)break}}}waitForRetry(t){return new Promise(e=>{const n=()=>{this.retryTimer=void 0,this.resolveRetryDelay=void 0,e()};this.resolveRetryDelay=n,this.retryTimer=setTimeout(n,t)})}interruptRetryDelay(){this.retryTimer!==void 0&&clearTimeout(this.retryTimer),this.resolveRetryDelay?.()}scheduleFlush(){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush(!0)},Bj))}clearFlushTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}};const qj=t=>{const e=Vj(t.props);return{kind:t.kind,...pp(t.thread_id)?{thread_id:t.thread_id}:{},...pp(t.message_id)?{message_id:t.message_id}:{},...pp(t.run_id)?{run_id:t.run_id}:{},...Hj(t.value)?{value:t.value}:{},...e?{props:e}:{}}},pp=t=>t&&t.length<=48?t:void 0,Hj=t=>t!==void 0&&Number.isInteger(t)&&t>=0,Vj=t=>{if(!t)return;const e=Object.entries(t);if(e.some(([,i])=>typeof i=="string"&&i.length>256||typeof i=="number"&&!Number.isFinite(i)||typeof i!="string"&&typeof i!="number"&&typeof i!="boolean"))return;const n=Object.fromEntries(e);return new TextEncoder().encode(JSON.stringify(n)).byteLength<=1024?n:void 0},$j=["numeric","categorical","boolean"];var Gj=class{cloud;constructor(t){this.cloud=t}async create(t){const e=Mt(await this.cloud.makeRequest("/scores",{method:"POST",body:t}),"score response");return{score_id:mt(e.score_id,"score response.score_id"),name:mt(e.name,"score response.name"),data_type:Xx(e.data_type,"score response.data_type",$j),value:Cj(e.value,"score response.value"),string_value:Ga(e.string_value,"score response.string_value")}}},Fj=class{cloud;constructor(t){this.cloud=t}async create(){const t=Mt(await this.cloud.makeRequest("/auth/tokens",{method:"POST"}),"auth token response");return{token:mt(t.token,"token")}}};const Yj=["positive","negative"],tC=(t,e)=>{const n=Mt(t,e);return{id:mt(n.id,`${e}.id`),parent_id:Ga(n.parent_id,`${e}.parent_id`),height:Jx(n.height,`${e}.height`),created_at:dl(n.created_at,`${e}.created_at`),updated_at:dl(n.updated_at,`${e}.updated_at`),format:mt(n.format,`${e}.format`),content:Ej(n.content,`${e}.content`),external_id:Ga(n.external_id??null,`${e}.external_id`)}};var Qj=class{cloud;constructor(t){this.cloud=t}async list(t,e){const n=Mt(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages`,{query:e}),"thread message list response");return{messages:kl(n.messages,"messages").map((i,a)=>tC(i,`messages[${a}]`))}}async create(t,e){const n=Mt(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages`,{method:"POST",body:{parent_id:e.parent_id,format:e.format,content:e.content,...e.external_id!==void 0?{external_id:e.external_id}:void 0,...e.parent_external_id!==void 0?{parent_external_id:e.parent_external_id}:void 0}}),"thread message create response");return{message_id:mt(n.message_id,"message_id")}}async update(t,e,n){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(e)}`,{method:"PUT",body:n})}async feedback(t,e,n){const i=n.comment?.trim(),a=Mt(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages/${encodeURIComponent(e)}/feedback`,{method:"POST",body:{type:n.type,...i?{comment:i}:void 0}}),"thread message feedback response");return{feedback_id:mt(a.feedback_id,"feedback_id"),type:Xx(a.type,"type",Yj),..."comment"in a?{comment:Ga(a.comment,"comment")}:void 0}}};const dm=(t,e)=>{const n=Mt(t,e);return{title:Ga(n.title,`${e}.title`)??"",last_message_at:dl(n.last_message_at,`${e}.last_message_at`),metadata:n.metadata,external_id:Ga(n.external_id,`${e}.external_id`),id:mt(n.id,`${e}.id`),project_id:mt(n.project_id,`${e}.project_id`),created_at:dl(n.created_at,`${e}.created_at`),updated_at:dl(n.updated_at,`${e}.updated_at`),workspace_id:mt(n.workspace_id,`${e}.workspace_id`),is_archived:um(n.is_archived,`${e}.is_archived`)}};var Kj=class{messages;cloud;constructor(t){this.cloud=t,this.messages=new Qj(t)}async list(t){const e=t?.is_archived===void 0?t:{...t,is_archived:String(t.is_archived)},n=Mt(await this.cloud.makeRequest("/threads",{query:e}),"thread list response");return{threads:kl(n.threads,"threads").map((i,a)=>dm(i,`threads[${a}]`))}}async get(t){const e=Mt(await this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`),"thread response");return dm(e.thread,"thread")}async create(t){const e=Mt(await this.cloud.makeRequest("/threads",{method:"POST",body:t}),"thread create response");return{thread_id:mt(e.thread_id,"thread_id")}}async update(t,e){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`,{method:"PUT",body:e})}async claim(t){const e=Mt(await this.cloud.makeRequest("/threads/claim",{method:"POST",body:t}),"thread claim response");return{moved:Jx(e.moved,"moved")}}async delete(t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`,{method:"DELETE"})}},Xj=class{cloud;constructor(t){this.cloud=t}async list(t,e){const n=Mt(await this.cloud.makeRequest(`/projects/threads/${encodeURIComponent(t)}/messages`,{query:e}),"project thread message list response");return{messages:kl(n.messages,"messages").map((i,a)=>tC(i,`messages[${a}]`))}}},Jj=class{messages;cloud;constructor(t){this.cloud=t,this.messages=new Xj(t)}async list(t){const e=Mt(await this.cloud.makeRequest("/projects/threads",{query:{...t,...t?.is_archived!==void 0?{is_archived:String(t.is_archived)}:{}}}),"project thread list response");return{threads:kl(e.threads,"threads").map((n,i)=>dm(n,`threads[${i}]`))}}},Zj=class{threads;constructor(t){this.threads=new Jj(t)}},Wj=class{cloud;constructor(t){this.cloud=t}__internal_getAssistantOptions(t){return{api:`${this.cloud._baseUrl}/v1/runs/stream`,protocol:"ui-message-stream",headers:()=>Wx(this.cloud,{Accept:"text/plain"}),body:async e=>{const n=e?.threadId;if(n===void 0)throw new Error("Assistant Cloud runs need a thread; the thread list adapter has not assigned a remote id to this thread yet.");return{assistant_id:t,response_format:"vercel-ai-data-stream/v1",thread_id:n}}}}async stream(t){const e=await this.cloud.makeRawRequest("/runs/stream",{method:"POST",headers:{Accept:"text/plain"},body:t});if(!e.body)throw new Sl('Invalid Assistant Cloud response for "run stream": expected a response body');const n=e.headers.get("content-type");if(n?.split(";",1)[0]?.trim().toLowerCase()!=="text/plain")throw await e.body.cancel().catch(()=>{}),new Sl(`Invalid Assistant Cloud response for "run stream": expected a "text/plain" content type, received ${n?`"${n}"`:"no Content-Type header"}`);return im.fromResponse(e,new S4)}async report(t){const e=Mt(await this.cloud.makeRequest("/runs",{method:"POST",body:t}),"run report response");return{run_id:mt(e.run_id,"run_id")}}},e5=class{cloud;constructor(t){this.cloud=t}async pdfToImages(t){const e=Mt(await this.cloud.makeRequest("/files/pdf-to-images",{method:"POST",body:t}),"PDF conversion response");return{success:um(e.success,"PDF conversion response.success"),urls:kl(e.urls,"PDF conversion response.urls").map((n,i)=>mt(n,`PDF conversion response.urls[${i}]`)),message:mt(e.message,"PDF conversion response.message")}}async generatePresignedUploadUrl(t){const e=Mt(await this.cloud.makeRequest("/files/attachments/generate-presigned-upload-url",{method:"POST",body:t}),"presigned upload response");return{success:um(e.success,"presigned upload response.success"),signedUrl:mt(e.signedUrl,"presigned upload response.signedUrl"),expiresAt:mt(e.expiresAt,"presigned upload response.expiresAt"),publicUrl:mt(e.publicUrl,"presigned upload response.publicUrl"),..."key"in e?{key:mt(e.key,"presigned upload response.key")}:{}}}async generatePresignedDownloadUrl(t){const e=Mt(await this.cloud.makeRequest("/files/attachments/generate-presigned-download-url",{method:"POST",body:t}),"presigned download response");return{signedUrl:mt(e.signedUrl,"presigned download response.signedUrl"),expiresAt:mt(e.expiresAt,"presigned download response.expiresAt"),key:mt(e.key,"presigned download response.key")}}},t5=class{threads;projects;auth;runs;files;events;scores;telemetry;registerSdk;constructor(t){const e=new jj(t);this.registerSdk=e.registerSdk;const n=t.telemetry,i=n===!1?{enabled:!1}:n===!0||n===void 0?{enabled:!0}:{...n,enabled:n.enabled!==!1};this.telemetry=new Proxy(i,{set:(a,o,u)=>{const d=Reflect.set(a,o,u);return(o==="enabled"||o==="events")&&(a.enabled===!1||a.events===!1)&&$S(this.events),d}}),this.threads=new Kj(e),this.projects=new Zj(e),this.auth={tokens:new Fj(e),invalidate:()=>{e.invalidateAuth(),$S(this.events)}},this.runs=new Wj(e),this.files=new e5(e),this.events=new Lj(e,()=>this.telemetry.enabled!==!1&&this.telemetry.events!==!1),this.scores=new Gj(e)}};const nC=256;function GS(t,e,n){t.delete(e),t.set(e,n),t.size>nC&&t.delete(t.keys().next().value)}function FS(t,e){t.delete(e),t.add(e),t.size>nC&&t.delete(t.values().next().value)}const n5=(t,e)=>({thread_id:t,...e!==void 0?{message_id:e}:void 0});var sC=class{runStartedAt=new Map;runEndedAt=new Map;shownErrors=new Set;shownSuggestions=new Set;getCloud;resolveIds;constructor(t,e=n5){this.getCloud=typeof t=="function"?t:()=>t,this.resolveIds=e}runStarted(t){this.runStartedAt.set(t,Date.now()),this.shownErrors.delete(t)}runEnded(t){this.runStartedAt.delete(t),GS(this.runEndedAt,t,Date.now())}runStopped(t){const e=this.runStartedAt.get(t);if(e===void 0)return;const n=Date.now();this.runStartedAt.delete(t),GS(this.runEndedAt,t,n),this.track("run_stopped",t,void 0,{value:Math.max(0,n-e)})}messageSent(t,e){const n=this.runEndedAt.get(t);this.track("message_sent",t,e.messageId,{props:{chars:e.chars,attachments:e.attachments},...n!==void 0?{value:Math.max(0,Date.now()-n)}:void 0},{awaitThread:!0})}messageEdited(t,e){this.track("message_edited",t,e.messageId,{props:{chars:e.chars}})}messageRegenerated(t,e){this.track("message_regenerated",t,e)}errorShown(t,e){this.shownErrors.has(t)||(FS(this.shownErrors,t),this.track("error_shown",t,e.messageId,{props:{reason:e.reason}}))}suggestionsShown(t,e){this.shownSuggestions.has(t)||(FS(this.shownSuggestions,t),this.track("suggestions_shown",t,void 0,{value:e}))}suggestionClicked(t){this.track("suggestion_clicked",t)}attachmentAdded(t,e){this.track("attachment_added",t,e.messageId,{...e.contentType?{props:{type:e.contentType}}:void 0})}attachmentFailed(t,e){this.track("attachment_failed",t,e.messageId,{...e.contentType?{props:{type:e.contentType}}:void 0})}voiceStarted(t){this.track("voice_started",t)}speechStarted(t,e){this.track("speech_started",t,e)}branchSwitched(t,e){this.track("branch_switched",t,e)}messageCopied(t,e){this.track("message_copied",t,e)}toolApproved(t,e,n,i){this.track("tool_approved",t,e,{props:{toolCallId:n,toolName:i}})}toolRejected(t,e,n,i){this.track("tool_rejected",t,e,{props:{toolCallId:n,toolName:i}})}threadSwitched(t){this.track("thread_switched",t)}track(t,e,n,i={},a={awaitThread:!1}){Promise.resolve().then(()=>this.resolveIds(e,n,a)).then(o=>{o&&(t==="thread_switched"&&!o.thread_id||this.getCloud().events.track({kind:t,...i,...o}))}).catch(()=>{})}};const YS=200;var s5=class{idMapping=new Map;getCloud;constructor(t){this.getCloud=typeof t=="function"?t:()=>t}async append(t,e,n,i,a){const o=this.getCloud(),u=this.idMapping.get(e);if(u instanceof Promise){await u;return}const d=(async()=>{const f=n?this.idMapping.get(n):void 0,p=n?await f??n:null,{message_id:m}=await o.threads.messages.create(t,{parent_id:p,format:i,content:a});return m})();this.idMapping.set(e,d);try{const f=await d;this.idMapping.get(e)===d&&this.idMapping.set(e,f)}catch(f){throw this.idMapping.get(e)===d&&this.idMapping.delete(e),f}}async update(t,e,n,i){const a=this.getCloud(),o=await this.getRemoteId(e);if(!o){console.warn(`Skipping update for message ${e}: no remote id is mapped.`);return}await a.threads.messages.update(t,o,{content:i})}isPersisted(t){return this.idMapping.has(t)}async getRemoteId(t){const e=this.idMapping.get(t);if(e)return e}getResolvedRemoteId(t){const e=this.idMapping.get(t);return typeof e=="string"?e:void 0}record(t,e){this.idMapping.set(t,e)}async load(t,e){const n=this.idMapping,i=this.getCloud(),a=[],o=new Set;let u;for(;;){const d=await i.threads.messages.list(t,{...e?{format:e}:void 0,limit:YS,...u?{after:u}:void 0}),f=d.messages.at(-1);if(!f)break;const p=d.messages.filter(m=>!o.has(m.id));if(p.length===0)break;for(const m of p)o.add(m.id);if(a.push(...p),d.messages.length<YS)break;u=f.id}if(this.idMapping===n)for(const d of a){const f=n.get(d.id);f===void 0?n.set(d.id,d.id):f instanceof Promise&&f.catch(()=>{const p=n.get(d.id);(p===void 0||p===f)&&n.set(d.id,d.id)})}return a}reset(){this.idMapping=new Map}};const QS=5e4,i5=/^[A-Za-z0-9+/]+={0,2}$/;function r5(t,e="completed"){if(t.isError)return{status:"error"};if(t.isAbort)return{status:"incomplete",outcome:"aborted"};if(t.isDisconnect)return{status:"incomplete",outcome:"disconnected"};switch(t.finishReason){case"length":return{status:"incomplete",outcome:"length"};case"content-filter":case"content_filter":return{status:"incomplete",outcome:"content_filter"};case"cancelled":return{status:"incomplete",outcome:"aborted"};case"error":return{status:"error"};default:return{status:t.finishReason===void 0?e:"completed"}}}const a5=64,o5=2048;function l5(t){if(t==null)return{};const e=typeof t=="object"?t:void 0,n=typeof t=="string"?t:typeof e?.message=="string"?e.message:void 0,i=typeof e?.code=="string"?e.code:typeof e?.name=="string"&&e.name!=="Error"?e.name:void 0;return{...n?{error:n.slice(0,o5)}:void 0,...i?{errorCode:i.slice(0,a5)}:void 0}}function Bi(t){return t.length<=QS?t:t.slice(0,QS)}function fm(t){if(t!=null)try{return Bi(JSON.stringify(t))}catch{return}}const KS=t=>(t.length*3/4/1024).toFixed(1),XS=t=>{if(typeof t!="string")return!1;const e=t.slice(0,200);return e.length>0&&e.length%4===0&&i5.test(e)};function JS(t){if(!t||typeof t!="object")return t;const e=t;if((e.type==="image"||e.type==="audio")&&XS(e.data))return{...e,data:`[${String(e.type)}: ${KS(e.data)}KB]`};if(e.type==="resource"&&e.resource&&typeof e.resource=="object"){const n=e.resource;if(XS(n.blob))return{...e,resource:{...n,blob:`[resource: ${KS(n.blob)}KB]`}}}return t}function u5(t){if(t!=null){try{const e=typeof t=="string"?JSON.parse(t):t;if(Array.isArray(e))return Bi(JSON.stringify(e.map(JS)));if(typeof e=="object"){const n=e.content;if(Array.isArray(n))return Bi(JSON.stringify({...e,content:n.map(JS)}))}}catch{}return fm(t)}}function iC(t){const{toolName:e,toolCallId:n,args:i,argsText:a,result:o,toolSource:u}=t,d={tool_name:e,tool_call_id:n},f=a!=null?Bi(a):fm(i);f!==void 0&&(d.tool_args=f);const p=u==="mcp"?u5(o):fm(o);return p!==void 0&&(d.tool_result=p),u&&(d.tool_source=u),d}function rC(t){if(!t)return;if(typeof t.modelId=="string")return t.modelId;const e=t.custom;if(typeof e?.modelId=="string")return e.modelId;const n=t.steps;if(Array.isArray(n))for(const i of n){if(!i||typeof i!="object")continue;const a=i.response;if(!a||typeof a!="object")continue;const o=a.modelId;if(typeof o=="string")return o}}function c5(t,e){if(!e)return;const n=Tl(e);n&&(n.inputTokens!==void 0&&(t.input_tokens=n.inputTokens),n.outputTokens!==void 0&&(t.output_tokens=n.outputTokens),n.reasoningTokens!==void 0&&(t.reasoning_tokens=n.reasoningTokens),n.cachedInputTokens!==void 0&&(t.cached_input_tokens=n.cachedInputTokens))}function d5(t){const e={},n=t.usage?Tl(t.usage):void 0;return n?.inputTokens!==void 0&&(e.input_tokens=n.inputTokens),n?.outputTokens!==void 0&&(e.output_tokens=n.outputTokens),n?.reasoningTokens!==void 0&&(e.reasoning_tokens=n.reasoningTokens),n?.cachedInputTokens!==void 0&&(e.cached_input_tokens=n.cachedInputTokens),t.toolCalls!==void 0&&(e.tool_calls=t.toolCalls),t.startMs!==void 0&&(e.start_ms=t.startMs),t.endMs!==void 0&&(e.end_ms=t.endMs),t.finishReason!==void 0&&(e.finish_reason=t.finishReason.slice(0,32)),t.input!==void 0&&(e.input=Bi(t.input)),e}function f5(t){if(!t)return;const e=[],n=new Set;for(const i of t){const a=i.trim().slice(0,64).trim();if(!(!a||n.has(a))&&(n.add(a),e.push(a),e.length===20))break}return e.length>0?e:void 0}function ZS(t){if(!(t===void 0||!Number.isFinite(t)))return Math.max(0,Math.round(t))}function al(t){if(!(t===void 0||!Number.isFinite(t)||t<0))return t}function h5(t,e){if(!e)return;const n={},i=al(e.input);i!==void 0&&(n.input=i);const a=al(e.inputCachedTokens);a!==void 0&&(n.input_cached_tokens=a);const o=al(e.output);o!==void 0&&(n.output=o);const u=al(e.total);u!==void 0&&(n.total=u),Object.keys(n).length>0&&(t.cost_details=n)}function p5(t){const e={thread_id:t.threadId,status:t.status},n=t.traceId?.toLowerCase();n&&/^[0-9a-f]{32}$/.test(n)&&(e.trace_id=n);const i=t.rootSpanId?.toLowerCase();i&&/^[0-9a-f]{16}$/.test(i)&&(e.root_span_id=i),t.outcome!==void 0&&(e.outcome_type=t.outcome),t.errorCode!==void 0&&(e.error_code=t.errorCode),t.error!==void 0&&(e.error=t.error),t.messageId!==void 0&&(e.message_id=t.messageId),t.modelId!==void 0&&(e.model_id=t.modelId),t.provider!==void 0&&(e.provider=t.provider,e.provider_type=t.provider),c5(e,t.usage),t.steps!==void 0?(e.steps=t.steps.map(d5),e.total_steps=t.steps.length):t.totalSteps!==void 0&&(e.total_steps=t.totalSteps),t.toolCalls!==void 0&&(e.tool_calls=t.toolCalls);const a=ZS(t.durationMs);a!==void 0&&(e.duration_ms=a);const o=ZS(t.firstTokenMs);o!==void 0&&(e.first_token_ms=o);const u=al(t.costUsd);u!==void 0&&(e.cost_usd=u),h5(e,t.costDetails),t.outputText!==void 0&&(e.output_text=Bi(t.outputText)),t.attributes!==void 0&&(e.attributes=t.attributes),t.metadata!==void 0&&(e.metadata=t.metadata),t.telemetry?.environment!==void 0&&(e.environment=t.telemetry.environment),t.telemetry?.release!==void 0&&(e.release=t.telemetry.release);const d=f5(t.telemetry?.tags);return d!==void 0&&(e.tags=d),e}function Tl(t){const e=t.inputTokens??t.promptTokens,n=t.outputTokens??t.completionTokens,i=t.reasoningTokens??t.outputTokenDetails?.reasoningTokens,a=t.cachedInputTokens??t.inputTokenDetails?.cacheReadTokens;if(!(e==null&&n==null&&i==null&&a==null))return{...e!=null?{inputTokens:e}:void 0,...n!=null?{outputTokens:n}:void 0,...i!=null?{reasoningTokens:i}:void 0,...a!=null?{cachedInputTokens:a}:void 0}}var m5=class{reported=new Set;getCloud;constructor(t){this.getCloud=typeof t=="function"?t:()=>t}async report(t,e){let n;try{const i=this.getCloud();if(!i.telemetry.enabled||e!==void 0&&this.reported.has(e))return;const a=p5({...t,telemetry:i.telemetry}),{beforeReport:o}=i.telemetry,u=o?o(a):a;if(!u)return;e!==void 0&&(this.reported.add(e),n=e),await i.runs.report(u)}catch(i){n!==void 0&&g5(i)&&this.reported.delete(n);return}}};const g5=t=>t instanceof Ig&&t.status===429,y5=(t,e)=>({append:async(n,i)=>{const a=e.getId(i.message),o=e.encode(i);return t.append(n,a,i.parentId,e.format,o)},update:t.update?async(n,i,a)=>{const o=e.encode(i);return t.update(n,a,e.format,o)}:void 0,load:async n=>({messages:(await t.load(n,e.format)).filter(i=>i.format===e.format).map(i=>e.decode({id:i.id,parent_id:i.parent_id,format:i.format,content:i.content})).reverse()}),isPersisted:n=>t.isPersisted(n)});function kr(t){return t!==null&&typeof t=="object"}function v5(t){return kr(t)&&typeof t.type=="string"}function b5(t){if(typeof t.toolCallId!="string")return;const e=t.type.startsWith("tool-");if(!e&&t.type!=="dynamic-tool")return;const n=e?t.type.slice(5):typeof t.toolName=="string"?t.toolName:void 0;if(n)return iC({toolName:n,toolCallId:t.toolCallId,args:t.input??t.args,result:t.output??t.result,toolSource:e?"frontend":"mcp"})}function _5(t,e){const n=kr(e?.samplingCalls)?e.samplingCalls:void 0;if(n)for(const i of t){const a=n[i.tool_call_id];Array.isArray(a)&&a.length>0&&(i.sampling_calls=a)}}function aC(t){const e=t?.steps;return Array.isArray(e)?e.map(n=>kr(n)&&kr(n.usage)?n.usage:void 0):[]}function oC(t){const e={};for(const n of t)n.inputTokens!=null&&(e.inputTokens=(e.inputTokens??0)+n.inputTokens),n.outputTokens!=null&&(e.outputTokens=(e.outputTokens??0)+n.outputTokens),n.reasoningTokens!=null&&(e.reasoningTokens=(e.reasoningTokens??0)+n.reasoningTokens),n.cachedInputTokens!=null&&(e.cachedInputTokens=(e.cachedInputTokens??0)+n.cachedInputTokens);return e}function S5(t){const e=kr(t?.usage)?Tl(t.usage):void 0;if(e)return e;const n=aC(t).flatMap(i=>{const a=i?Tl(i):void 0;return a?[a]:[]});return n.length>0?oC(n):void 0}function lC(t){const e=[],n=[],i=[],a=[];let o;for(const m of t){if(m.role!=="assistant")continue;o=m;const y=kr(m.metadata)?m.metadata:void 0,v=aC(y),b=[];let T,w=-1;for(const E of m.parts){if(!v5(E))continue;if(E.type==="step-start"){w+=1;const R=v[w];T=R?{usage:R}:{},i.push(T);continue}if(E.type==="text"&&typeof E.text=="string"&&E.text){e.push(E.text);continue}const C=b5(E);C&&(n.push(C),b.push(C),T&&(T.toolCalls=[...T.toolCalls??[],C],T.finishReason="tool-calls"))}_5(b,y);const x=S5(y);x&&a.push(x)}if(!o)return null;const u=kr(o.metadata)?o.metadata:void 0,d=a.length>0?oC(a):void 0,f=rC(u),p=e.length>0||n.length>0;return{...o.id!==void 0?{assistantMessageId:o.id}:void 0,status:p?"completed":"incomplete",...n.length>0?{toolCalls:n}:void 0,...i.length>0?{steps:i,totalSteps:i.length}:void 0,...e.length>0?{outputText:Bi(e.join(""))}:void 0,...d?{usage:d}:void 0,...f?{modelId:f}:void 0,...u?{metadata:u}:void 0}}function T5(t,e){if(!e)return t;if(!t)return e.map(({start_ms:i,end_ms:a})=>({startMs:i,endMs:a}));const n=Math.min(t.length,e.length);return t.map((i,a)=>({...i,...a<n?{startMs:e[a].start_ms,endMs:e[a].end_ms}:void 0}))}function w5(t,e){for(let n=t.length-1;n>=0;n--){const i=t[n],a=hm(i.message,e.format,e.getId(i.message));if(a)return a}}function x5(t,e){if(!e)return t;const{localMessageId:n,...i}=e;return{...t,...i}}function hm(t,e,n){if(!Ws(t)||t.role!=="assistant")return;const i=Ws(t.status)?t.status:void 0,a=Ws(t.metadata)?t.metadata:void 0,o=Ws(a?.custom)?a.custom:void 0,u=(Ws(a?.timing)?a.timing:void 0)?.firstTokenTime,d=typeof u=="number"&&Number.isFinite(u)?Math.round(u):void 0,f=i?.type==="incomplete"?typeof i.reason=="string"?i.reason:void 0:typeof a?.finishReason=="string"?a.finishReason:void 0,p=i?.type==="incomplete"&&i.reason==="error",m=r5({finishReason:f,isError:p}),y=m.outcome,v=m.status==="error"?"error":i?.type==="incomplete"?"incomplete":f!==void 0?m.status:void 0,b=p?l5(i.error):{},T=n??(typeof t.id=="string"?t.id:void 0),w=e==="aui/v0"?o?.traceId:e==="ai-sdk/v6"?a?.traceId:void 0,x=typeof o?.provider=="string"?o.provider:typeof a?.provider=="string"?a.provider:void 0;return{...T?{localMessageId:T}:void 0,...v!==void 0?{status:v}:void 0,...y?{outcomeType:y}:void 0,...b,...d!=null&&d>=0?{firstTokenMs:d}:void 0,...typeof w=="string"?{traceId:w}:void 0,...x!==void 0?{provider:x}:void 0}}function Ws(t){return t!==null&&typeof t=="object"}const C5=["inputTokens","outputTokens","reasoningTokens","cachedInputTokens","promptTokens","completionTokens"],mp=t=>typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0,E5=t=>{if(!Ws(t)||Array.isArray(t))return;const e={};for(const a of C5){const o=mp(t[a]);o!==void 0&&(e[a]=o)}const n=Ws(t.inputTokenDetails)&&!Array.isArray(t.inputTokenDetails)?mp(t.inputTokenDetails.cacheReadTokens):void 0;n!==void 0&&(e.inputTokenDetails={cacheReadTokens:n});const i=Ws(t.outputTokenDetails)&&!Array.isArray(t.outputTokenDetails)?mp(t.outputTokenDetails.reasoningTokens):void 0;return i!==void 0&&(e.outputTokenDetails={reasoningTokens:i}),Object.keys(e).length>0?e:void 0},A5=t=>Sx(t).map(e=>{const n=E5(e.usage);return n?{usage:n}:{}});function uC(t,e){switch(t){case"aui/v0":return R5(e);case"ai-sdk/v6":return lC([e]);default:return null}}function I5(t,e){if(t==="ai-sdk/v6")return lC(e);for(let n=e.length-1;n>=0;n--){const i=uC(t,e[n]);if(i)return i}return null}function R5(t){const e=t;if(e.role!=="assistant"||e.status!==void 0&&!bx(e.status))return null;const n=Ws(e.status)&&typeof e.status.type=="string"?e.status.type:void 0;if(n==="running"||n==="requires-action")return null;const i=e.content?.filter(w=>w.type==="tool-call"&&w.toolName&&w.toolCallId).map(w=>iC({toolName:w.toolName,toolCallId:w.toolCallId,args:w.args,result:w.result,argsText:w.argsText})),a=e.content?.filter(w=>w.type==="text"&&w.text),o=a&&a.length>0?Bi(a.map(w=>w.text).join("")):void 0,u=A5(e.metadata?.steps);let d,f,p,m;if(u&&u.length>0){let w=0,x=0,E=0,C=0,R=!1,O=!1,L=!1,I=!1;for(const P of u){if(!P.usage)continue;const k=Tl(P.usage);k&&(k.inputTokens!=null&&(w+=k.inputTokens,R=!0),k.outputTokens!=null&&(x+=k.outputTokens,O=!0),k.reasoningTokens!=null&&(E+=k.reasoningTokens,L=!0),k.cachedInputTokens!=null&&(C+=k.cachedInputTokens,I=!0))}d=R?w:void 0,f=O?x:void 0,p=L?E:void 0,m=I?C:void 0}const y=n==="incomplete"?"incomplete":"completed",v=e.metadata?.custom,b=rC(e.metadata),T=u.length>0?u:void 0;return{status:y,...i&&i.length>0?{toolCalls:i}:void 0,...u?.length?{totalSteps:u.length}:void 0,...d!=null||f!=null||p!=null||m!=null?{usage:{...d!=null?{inputTokens:d}:void 0,...f!=null?{outputTokens:f}:void 0,...p!=null?{reasoningTokens:p}:void 0,...m!=null?{cachedInputTokens:m}:void 0}}:void 0,...o!=null?{outputText:o}:void 0,...v?{metadata:v}:void 0,...T?{steps:T}:void 0,...b?{modelId:b}:void 0}}const WS=new WeakMap,Fc=Symbol("assistant-ui:cloud-default-scope"),e1=new WeakMap,t1=t=>{let e=e1.get(t);return e||(e={settled:new Set,reported:new Set},e1.set(t,e)),e},n1=t=>t.role==="assistant"&&(t.status.type==="complete"||t.status.type==="incomplete"),s1=(t,e)=>{const n=pg(e);if(!t)return n;if(!n)return t;const i=Math.max(t.omitted??0,n.omitted??0);let a={entries:t.entries,...i?{omitted:i}:void 0};for(const o of n.entries)a.entries.some(u=>u.type===o.type&&u.occurredAt===o.occurredAt&&gg(u.payload,o.payload))||(a=ox(a,o));return a},M5=new Set([401,403,408,429]),k5=new Set([402,404]),N5=t=>t instanceof Ig&&t.status>=400&&t.status<500&&!M5.has(t.status);var O5=class{cloudRef;scopeRef;getAui;runReporterContext;copiedThreads=new WeakMap;copyQueues=new WeakMap;constructor(t,e,n){this.cloudRef=t,this.scopeRef=n,this.getAui=e}get aui(){return this.getAui()}captureScopeSnapshot(){return{cloud:this.cloudRef.current,scope:this.scopeRef.current}}getCloud(){return this.cloudRef.current}getScope(){return this.scopeRef.current}ownsThread(t){const e=this.aui.threadListItem;if(!e.source)return!1;const{id:n,remoteId:i}=e.getState();return n===t||i===t}isCurrentScope({scope:t}){return Object.is(this.scopeRef.current,t)}assertCurrentScope(t){if(!this.isCurrentScope(t))throw new Error("Cloud scope changed during the persistence operation")}captureScope(t=this.aui.threadListItem){const e=this.captureScopeSnapshot();return{...e,persistence:this.getPersistence(t,e)}}getPersistence(t=this.aui.threadListItem,e=this.captureScopeSnapshot()){const n=Ml(t);let i=WS.get(n);if(!i||!Object.is(i.scope,e.scope)){const a={current:this.cloudRef};i={cloudRef:a,scope:e.scope,persistence:new s5(()=>a.current.current)},WS.set(n,i)}else i.cloudRef.current=this.cloudRef;return i.persistence}async resolveExistingRemoteId(t){if(t.getState().remoteId)return(await t.initialize()).remoteId}async resolveEngagementEventIds(t,e,n){return this.resolveEngagementEventIdsForScope(this.captureScopeSnapshot(),t,e,n)}async resolveEngagementEventIdsForScope(t,e,n,i){this.assertCurrentScope(t);const a=this.getThreadListItem(e);if(!a)return;const o=this.getPersistence(a,t);let u;(a.getState().remoteId||i?.awaitThread)&&(u=(await a.initialize()).remoteId),this.assertCurrentScope(t);const d=n?o.getResolvedRemoteId(n):void 0;return{...u?{thread_id:u}:void 0,...d?{message_id:d}:void 0}}feedback={submit:({message:t,type:e,comment:n})=>{(async()=>{const i=ip(this.aui);if(!i||!i.getState().remoteId){console.warn(`[assistant-ui] Skipping feedback for message ${t.id}: the thread has no remote id.`);return}const a=this.captureScope(i),o=await this.resolveExistingRemoteId(i);if(this.assertCurrentScope(a),!o)return;const u=await a.persistence.getRemoteId(t.id);if(this.assertCurrentScope(a),!u){console.warn(`[assistant-ui] Skipping feedback for message ${t.id}: no cloud message id is mapped.`);return}await a.cloud.threads.messages.feedback(o,u,{type:e,...n?{comment:n}:void 0})})().catch(i=>{console.error("[assistant-ui] Cloud feedback submission failed:",i)})}};getThreadListItem(t){const e=this.aui.threadListItem;if(e.source){const i=e.getState();if(i.id===t||i.remoteId===t)return e}const n=this.aui.threads.getState().threadItems.find(i=>i.id===t||i.remoteId===t);return n?this.aui.threads.item({id:n.id}):void 0}withFormat(t){const e=this;let n;const i=()=>{const u=ip(e.aui);return u&&(n=u),n},a=()=>n??i(),o=u=>y5(u.persistence,t);return{pin(){i()},async append(u){const d=a();if(!d)throw new Error("Cannot persist cloud history without a thread list item.");const f=e.captureScope(d),{remoteId:p}=await d.initialize();e.assertCurrentScope(f),await o(f).append(p,u)},async update(u,d){const f=a();if(!f||!f.getState().remoteId)return;const p=e.captureScope(f),m=await e.resolveExistingRemoteId(f);e.assertCurrentScope(p),m&&await o(p).update?.(m,u,d)},async delete(){throw new Error("Assistant Cloud does not support deleting thread messages yet.")},reportTelemetry(u,d){const f=u.map(p=>t.encode(p));e._reportRunTelemetry(t.format,f,d,a(),x5(w5(u,t),d?.message?hm(d.message,"aui/v0"):void 0))},async load(){const u=i(),d=e.aui.threadListItem;if(!d.source||!d.getState().remoteId)return{messages:[]};const f=u??d,p=e.captureScope(f),m=await e.resolveExistingRemoteId(f);if(e.assertCurrentScope(p),!m)return{messages:[]};const y=await o(p).load(m);return e.assertCurrentScope(p),y}}}async append({parentId:t,message:e}){const n=this.aui.threadListItem,i=this.captureScope(n),{remoteId:a}=await n.initialize();this.assertCurrentScope(i),await this._writeMessage(i,a,e,o=>i.persistence.append(a,e.id,t,"aui/v0",o))}async update(t){const e=this.aui.threadListItem,n=this.captureScope(e);if(!n.persistence.isPersisted(t.message.id))return this.append(t);const{message:i}=t,a=await this.resolveExistingRemoteId(e);this.assertCurrentScope(n),a&&await this._writeMessage(n,a,i,o=>n.persistence.update(a,i.id,"aui/v0",o))}get unstable_copy(){const t=this.cloudRef.current?.telemetry;return t?.enabled===!1||t?.messages===!1?void 0:this.copy}copy=async(t,e)=>{if(e.length===0)return;const n=ip(this.aui);if(!n)throw new Error("Cannot copy cloud history without a thread list item.");const i=this.captureScope(n),a=(await n.initialize()).remoteId;this.assertCurrentScope(i);let o=this.copyQueues.get(i.persistence);o||(o=new Map,this.copyQueues.set(i.persistence,o));const u=(o.get(a)??Promise.resolve()).catch(()=>{}).then(()=>this.copyBranch(i,a,t,e));o.set(a,u);try{await u}finally{o.get(a)===u&&o.delete(a)}};async copyBranch(t,e,n,i){let a=this.copiedThreads.get(t.persistence);a||(a=new Map,this.copiedThreads.set(t.persistence,a));let o=a.get(e);o||(o=(async()=>{const y={stored:new Set,refused:new Set,closed:!1,interactions:new Map},v=new Set;let b;for(;;){this.assertCurrentScope(t);const T=await t.cloud.threads.messages.list(e,{limit:200,...b?{after:b}:void 0});this.assertCurrentScope(t);const w=T.messages.filter(E=>!v.has(E.id));for(const E of w){if(v.add(E.id),!E.external_id||E.format!=="aui/v0")continue;y.stored.add(E.external_id),t.persistence.record(E.external_id,E.id);const C=jS(E);for(const R of C?.message.content??[]){if(R.type!=="tool-call")continue;const O=s1(y.interactions.get(R.toolCallId),R.unstable_interactions);O&&y.interactions.set(R.toolCallId,O)}}const x=T.messages.at(-1);if(w.length===0||T.messages.length<200||!x)break;b=x.id}return y})(),a.set(e,o));let u;try{u=await o}catch(y){throw a.get(e)===o&&a.delete(e),y}if(u.closed)return;const d=n.filter(y=>y.id.length>0&&y.id.length<=255),f=new Set(i);let p=0,m;for(let y=0;y<d.length;y++)if(f.has(d[y].id))for(;p<=y;p++){const v=d[p];if(p!==y&&(u.stored.has(v.id)||u.refused.has(v.id))){u.stored.has(v.id)&&(m=v.id);continue}const b=lm(v),T={...b,content:b.content.map(x=>{if(x.type!=="tool-call")return x;const E=s1(u.interactions.get(x.toolCallId),x.unstable_interactions);return{...x,...E?{unstable_interactions:E}:void 0}})};let w;try{this.assertCurrentScope(t),{message_id:w}=await t.cloud.threads.messages.create(e,{parent_id:null,format:"aui/v0",content:T,external_id:v.id,...m?{parent_external_id:m}:void 0}),this.assertCurrentScope(t)}catch(x){if(!N5(x))throw x;if(k5.has(x.status)||u.stored.size===0&&u.refused.size>0){u.closed=!0,console.warn(`[assistant-ui] The cloud refused copies to thread ${e}; the dashboard shows the conversation as far as it was copied.`,x);return}u.refused.add(v.id),console.warn(`[assistant-ui] The cloud refused the copy of message ${v.id}; the dashboard shows the conversation without it.`,x);continue}u.stored.add(v.id),u.refused.delete(v.id),m=v.id,t.persistence.record(v.id,w);for(const x of T.content)x.type==="tool-call"&&x.unstable_interactions&&u.interactions.set(x.toolCallId,x.unstable_interactions)}}async _writeMessage(t,e,n,i){const a=lm(n),o=t1(t.persistence),u=n1(n)&&!o.settled.has(n.id);if(this.assertCurrentScope(t),await i(a),!u||(o.settled.add(n.id),o.reported.has(n.id))||!t.cloud.telemetry.enabled)return;const d=uC("aui/v0",a);d&&(o.reported.add(n.id),this._sendReport(e,d,void 0,void 0,hm(n,"aui/v0"),t))}async delete(){throw new Error("Assistant Cloud does not support deleting thread messages yet.")}async load(){const t=this.aui.threadListItem,e=this.captureScope(t),n=await this.resolveExistingRemoteId(t);if(this.assertCurrentScope(e),!n)return{messages:[]};const i=await e.persistence.load(n,"aui/v0");this.assertCurrentScope(e);const a=i.filter(f=>f.format==="aui/v0").reverse(),o=[],u=new Set,{settled:d}=t1(e.persistence);for(const f of a){const p=jS(f);p&&(p.parentId&&!u.has(p.parentId)||(u.add(p.message.id),n1(p.message)&&d.add(p.message.id),o.push(p)))}return{messages:o}}_reportRunTelemetry(t,e,n,i,a){const o=i??this.aui.threadListItem,u=this.captureScope(o);if(!o.getState().remoteId)return;const d=I5(t,e)??(a?.status!==void 0?{status:"incomplete"}:void 0);d&&this.resolveExistingRemoteId(o).then(f=>{f&&(this.assertCurrentScope(u),this._sendReport(f,d,n?.durationMs,n?.stepTimestamps,a,u))}).catch(()=>{})}_sendReport(t,e,n,i,a,o=this.captureScope()){if(!this.isCurrentScope(o))return;const u=this.runReporterContext,d=u&&u.cloud===o.cloud&&Object.is(u.scope,o.scope)?u.reporter:new m5(o.cloud);this.runReporterContext={cloud:o.cloud,scope:o.scope,reporter:d};const f=T5(e.steps,i),p=a?.localMessageId?o.persistence.getResolvedRemoteId(a.localMessageId):void 0;d.report({threadId:t,status:a?.status??e.status,outcome:a?.outcomeType,error:a?.error,errorCode:a?.errorCode,messageId:p,traceId:a?.traceId,modelId:e.modelId,provider:a?.provider,usage:e.usage,steps:f,totalSteps:e.totalSteps,toolCalls:e.toolCalls,durationMs:n,firstTokenMs:a?.firstTokenMs,outputText:e.outputText,metadata:e.metadata})}};function D5(t,e){const n=ke(),i=we(n);Ce(()=>{i.current=n});const[a]=Ne(()=>new O5(t,()=>i.current,e));return U5(a,n),a}const i1=new WeakMap,fl=(t,e)=>{let n;for(const i of t.mounted.keys()){if(e!==void 0&&i.ownsThread(e))return i;n??=i}return n??t.lastMounted},j5=t=>{let e;return e={mounted:new Map,lastMounted:t,reporterScope:t.getScope(),reporter:new sC(()=>fl(e).getCloud(),(n,i,a)=>fl(e,n).resolveEngagementEventIds(n,i,a)),host:void 0,dispose:void 0},e},z5=(t,e)=>{const n=fl(t,e).getScope();return Object.is(t.reporterScope,n)||(t.reporterScope=n,t.reporter=new sC(()=>fl(t).getCloud(),(i,a,o)=>fl(t,i).resolveEngagementEventIds(i,a,o))),t.reporter},P5=(t,e)=>{const n=()=>{const{mainThreadId:a}=t.threads.getState(),{isEmpty:o,suggestions:u}=t.thread.getState();!o||u.length===0||e(a).suggestionsShown(a,u.length)},i=[t.on({scope:"*",event:"threads.selectionChanged"},a=>{e(a.threadId).threadSwitched(a.threadId)}),t.on({scope:"*",event:"composer.send"},a=>{const o=e(a.threadId);a.messageId?o.messageEdited(a.threadId,{messageId:a.messageId,chars:a.chars}):o.messageSent(a.threadId,{chars:a.chars,attachments:a.attachments}),a.suggestion&&o.suggestionClicked(a.threadId)}),t.on({scope:"*",event:"composer.attachmentAdd"},a=>{e(a.threadId).attachmentAdded(a.threadId,{messageId:a.messageId,contentType:a.contentType})}),t.on({scope:"*",event:"composer.attachmentAddError"},a=>{e(a.threadId).attachmentFailed(a.threadId,{messageId:a.messageId,contentType:a.contentType})}),t.on({scope:"*",event:"composer.cancel"},a=>{e(a.threadId).runStopped(a.threadId)}),t.on({scope:"*",event:"thread.runStart"},a=>{e(a.threadId).runStarted(a.threadId)}),t.on({scope:"*",event:"thread.runEnd"},a=>{e(a.threadId).runEnded(a.threadId)}),t.on({scope:"*",event:"thread.cancelRun"},a=>{e(a.threadId).runStopped(a.threadId)}),t.on({scope:"*",event:"thread.voiceStarted"},a=>{e(a.threadId).voiceStarted(a.threadId)}),t.on({scope:"*",event:"message.reload"},a=>{e(a.threadId).messageRegenerated(a.threadId,a.messageId)}),t.on({scope:"*",event:"message.branchSwitched"},a=>{e(a.threadId).branchSwitched(a.threadId,a.messageId)}),t.on({scope:"*",event:"message.copied"},a=>{e(a.threadId).messageCopied(a.threadId,a.messageId)}),t.on({scope:"*",event:"thread.toolApprovalAnswered"},a=>{const o=e(a.threadId);a.approved?o.toolApproved(a.threadId,a.messageId,a.toolCallId,a.toolName):o.toolRejected(a.threadId,a.messageId,a.toolCallId,a.toolName)}),t.on({scope:"*",event:"message.speak"},a=>{e(a.threadId).speechStarted(a.threadId,a.messageId)}),t.on({scope:"*",event:"message.error"},a=>{e(a.threadId).errorShown(a.threadId,{messageId:a.messageId,reason:a.reason})}),t.subscribe(n)];return n(),()=>si(i)},r1=(t,e)=>{t.host=e,t.dispose=P5(e,n=>z5(t,n))},B5=t=>{const e=t.dispose;t.host=void 0,t.dispose=void 0,e?.()},U5=(t,e)=>{const n=Q(4);let i,a;n[0]!==t||n[1]!==e?(i=()=>{const o=Ml(e.threads);let u=i1.get(o);u||(u=j5(t),i1.set(o,u));const d=u;return d.mounted.set(t,e),d.lastMounted=t,d.host===void 0&&r1(d,e),()=>{if(d.mounted.delete(t),d.host!==e)return;B5(d);const f=d.mounted.values().next();f.done||r1(d,f.value)}},a=[t,e],n[0]=t,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),Ce(i,a)};function L5(t,e){return e||MN(t)||"application/octet-stream"}const q5="application/octet-stream",H5=t=>t.startsWith("image/")?"image":t.startsWith("text/")?"document":"file",pm=new WeakMap,V5=(t,e,n)=>{const i=new $5(t);return pm.set(i,{getScope:e,subscribe:n}),i};var $5=class{accept="*";getCloud;defaultScope={};constructor(t){this.getCloud=typeof t=="function"?t:()=>t}getScope=()=>pm.get(this)?.getScope()??this.defaultScope;uploadedUrls=new Map;activeUploads=new Map;async*add({file:t}){const e=un(),n=H5(t.type),i=t.type||q5;let a={id:e,type:n,name:t.name,contentType:i,file:t,status:{type:"running",reason:"uploading",progress:0}};const o=new AbortController,u={cancelled:!1,controller:o,unsubscribe:()=>{}},d=this.getCloud(),f=this.getScope();let p=!1;u.unsubscribe=pm.get(this)?.subscribe?.(m=>{Object.is(f,m)||(p=!0,u.unsubscribe(),o.abort())})??u.unsubscribe,this.activeUploads.set(e,u);try{if(yield a,u.cancelled)return;if(p)throw new Error("Cloud scope changed while uploading the attachment");const{signedUrl:m,publicUrl:y}=await d.files.generatePresignedUploadUrl({filename:t.name});if(u.cancelled)return;if(!Object.is(f,this.getScope()))throw new Error("Cloud scope changed while uploading the attachment");const v=await fetch(m,{method:"PUT",body:t,headers:{"Content-Type":i},mode:"cors",signal:o.signal});if(u.cancelled)return;if(!Object.is(f,this.getScope()))throw new Error("Cloud scope changed while uploading the attachment");if(!v.ok)throw new Error(`Failed to upload file: ${v.status} ${v.statusText}`);this.uploadedUrls.set(e,{url:y,scope:f}),a={...a,status:{type:"requires-action",reason:"composer-send"}},yield a}catch(m){if(u.cancelled)return;const y=p?new Error("Cloud scope changed while uploading the attachment"):m;console.error("[assistant-ui] Failed to upload attachment:",y),a={...a,status:{type:"incomplete",reason:"error",message:y instanceof Error?y.message:String(y)}},yield a}finally{u.unsubscribe(),this.activeUploads.get(e)===u&&this.activeUploads.delete(e)}}async remove(t){const e=this.activeUploads.get(t.id);e&&(e.cancelled=!0,e.unsubscribe(),e.controller.abort(),this.activeUploads.delete(t.id)),this.uploadedUrls.delete(t.id)}async send(t){const e=this.uploadedUrls.get(t.id);if(!e)throw new Error("Attachment not uploaded");if(!Object.is(e.scope,this.getScope()))throw new Error("Attachment was uploaded for a different Cloud scope");this.uploadedUrls.delete(t.id);const{url:n}=e;let i;return t.type==="image"?i=[{type:"image",image:n,filename:t.name}]:i=[{type:"file",data:n,mimeType:L5(n,t.contentType),filename:t.name}],{...t,status:{type:"complete"},content:i}}},G5=class{threads=new Map;list(){return Promise.resolve({threads:[...this.threads.values()].reverse()})}rename(t,e){if(t===void 0)return Promise.resolve();const n=this.threads.get(t);return n&&this.threads.set(t,{...n,title:e}),Promise.resolve()}updateCustom(t,e){if(t===void 0)return Promise.resolve();const n=this.threads.get(t);return n&&this.threads.set(t,{...n,custom:e}),Promise.resolve()}archive(t){if(t===void 0)return Promise.resolve();const e=this.threads.get(t);return e&&e.status!=="archived"&&(this.threads.delete(t),this.threads.set(t,{...e,status:"archived"})),Promise.resolve()}unarchive(t){if(t===void 0)return Promise.resolve();const e=this.threads.get(t);return e&&e.status!=="regular"&&(this.threads.delete(t),this.threads.set(t,{...e,status:"regular"})),Promise.resolve()}delete(t){return t===void 0||this.threads.delete(t),Promise.resolve()}initialize(t){return Promise.resolve(this.register(t))}register(t,e){const n=this.threads.get(t),i=n?e===void 0||n.externalId===e?n:{...n,externalId:e}:{status:"regular",remoteId:t,externalId:e};return this.threads.set(t,i),{remoteId:t,externalId:i.externalId}}generateTitle(){return Promise.resolve(new ReadableStream({start(t){t.close()}}))}fetch(t){const e=this.threads.get(t);return e?Promise.resolve(e):Promise.reject(new Error(`Thread "${t}" not found in in-memory thread list.`))}};const F5={name:"@assistant-ui/core",version:"0.3.28"};var Y5={};const a1=t=>Ze(t)?t:void 0,o1=typeof process<"u"?Y5.NEXT_PUBLIC_ASSISTANT_BASE_URL:void 0,mm=o1?new t5({baseUrl:o1,anonymous:!0}):void 0,cC=t=>{let e=t;const n=new Set;return{get current(){return e},update(i){if(!Object.is(e,i)){e=i;for(const a of n)a(i)}},subscribe(i){return n.add(i),()=>n.delete(i)}}},dC=(t,e)=>{const n=D5(t,e),[i]=Ne(()=>V5(()=>t.current,()=>e.current,a=>e.subscribe(a)));return yt(()=>({history:n,attachments:i,feedback:n.feedback}),[n,i])},yc=20,Q5=t=>{const e={activeCursor:t,archivedCursor:void 0,activeExhausted:!1,archivedExhausted:!1};if(!t||!t.startsWith("{"))return e;try{const n=JSON.parse(t);return Ze(n)?{activeCursor:typeof n.a=="string"?n.a:void 0,archivedCursor:typeof n.r=="string"?n.r:void 0,activeExhausted:n.ae===!0,archivedExhausted:n.re===!0}:e}catch{return e}},K5=t=>{const e=typeof t=="function"?t:()=>t,n=e(),i=n.cloud??mm,a=n.scopeId;if(!i){const d=new G5;return d.initialize=async f=>{const p=await e().create?.(f);return d.register(f,p?.externalId)},d}const o=function(){const f=we(i),[p]=Ne(()=>cC(a??Fc));return Os(()=>{f.current=i,p.update(a??Fc)},[i,a,p]),dC(f,p)};i.registerSdk?.(F5);const u=e().sdk;return u&&i.registerSdk?.(u),{list:async({after:d}={})=>{const{activeCursor:f,archivedCursor:p,activeExhausted:m,archivedExhausted:y}=Q5(d),[{threads:v},{threads:b}]=await Promise.all([m?Promise.resolve({threads:[]}):i.threads.list({limit:yc,...f?{after:f}:{}}),y?Promise.resolve({threads:[]}):i.threads.list({is_archived:!0,limit:yc,...p?{after:p}:{}})]),T=!m&&v.length===yc?v.at(-1)?.id:void 0,w=!y&&b.length===yc?b.at(-1)?.id:void 0;return{threads:[...v,...b].map(x=>({status:x.is_archived?"archived":"regular",remoteId:x.id,title:x.title,lastMessageAt:x.last_message_at?new Date(x.last_message_at):void 0,externalId:x.external_id??void 0,custom:a1(x.metadata)})),nextCursor:T||w?JSON.stringify({a:T,r:w,...T===void 0?{ae:!0}:{},...w===void 0?{re:!0}:{}}):void 0}},initialize:async d=>{const f=await(e().create?.(d)??Promise.resolve()),p=f?f.externalId:void 0,{thread_id:m}=await i.threads.create({last_message_at:new Date,external_id:p,...p!==void 0&&e().upsert?{upsert:!0}:{}});return{externalId:p,remoteId:m}},rename:async(d,f)=>i.threads.update(d,{title:f}),updateCustom:async(d,f)=>i.threads.update(d,{metadata:f??null}),archive:async d=>i.threads.update(d,{is_archived:!0}),unarchive:async d=>i.threads.update(d,{is_archived:!1}),delete:async d=>(await e().delete?.(d),i.threads.delete(d)),generateTitle:async(d,f)=>{const p=f.map(m=>({...m,content:m.content.filter(y=>y.type==="text"||y.type==="tool-call")}));return i.runs.stream({thread_id:d,assistant_id:"system/thread_title",messages:p})},fetch:async d=>{const f=await i.threads.get(d);return{status:f.is_archived?"archived":"regular",remoteId:f.id,title:f.title,lastMessageAt:f.last_message_at?new Date(f.last_message_at):void 0,externalId:f.external_id??void 0,custom:a1(f.metadata)}},unstable_useAdapters:o}},X5=t=>{const e=we(t),[n]=Ne(()=>({get current(){return e.current.cloud??mm}})),[i]=Ne(()=>cC(t.scopeId??Fc));Os(()=>{e.current=t,i.update(t.scopeId??Fc)},[t,i]);const[a]=Ne(()=>function(){return dC(n,i)}),o=t.cloud??mm,u=t.scopeId,d=()=>{let m=()=>t;const y=K5(()=>({...m(),cloud:o,scopeId:u}));return m=()=>e.current,y.unstable_useAdapters===void 0?y:{...y,unstable_useAdapters:a}},[f,p]=Ne(()=>({cloud:o,scope:u,adapter:d()}));if(f.cloud!==o||f.scope!==u){const m={cloud:o,scope:u,adapter:d()};return p(m),m.adapter}return f.adapter},fC=t=>{const e=Q(6),{id:n,children:i}=t,a=ke();let o;e[0]!==n?(o=ns({message:jn({source:"thread",query:{type:"id",id:n},get:f=>f.thread.message({id:n})}),composer:jn({source:"message",query:{},get:f=>f.thread.message({id:n}).composer()})}),e[0]=n,e[1]=o):o=e[1];const u=o;let d;return e[2]!==a||e[3]!==i||e[4]!==u?(d=_.jsx(hs,{extends:a,config:u,children:i}),e[2]=a,e[3]=i,e[4]=u,e[5]=d):d=e[5],d},Rg=(t,e)=>t.Message===e.Message&&t.EditComposer===e.EditComposer&&t.UserEditComposer===e.UserEditComposer&&t.AssistantEditComposer===e.AssistantEditComposer&&t.SystemEditComposer===e.SystemEditComposer&&t.UserMessage===e.UserMessage&&t.AssistantMessage===e.AssistantMessage&&t.SystemMessage===e.SystemMessage,l1=()=>null,u1=new WeakMap,hC=(t,e)=>{let n=u1.get(t);return n||(n=new Set(t.map(i=>i.id)),u1.set(t,n)),n.has(e)},J5=(t,e,n)=>{switch(e){case"user":return n?t.UserEditComposer??t.EditComposer??t.UserMessage??t.Message:t.UserMessage??t.Message;case"assistant":return n?t.AssistantEditComposer??t.EditComposer??t.AssistantMessage??t.Message:t.AssistantMessage??t.Message;case"system":return n?t.SystemEditComposer??t.EditComposer??t.SystemMessage??t.Message??l1:t.SystemMessage??t.Message??l1;default:throw new Error(`Unknown message role: ${e}`)}},Mg=t=>{const e=Q(6),{components:n}=t,i=me(W5),a=me(e6);let o;e[0]!==n||e[1]!==a||e[2]!==i?(o=J5(n,i,a),e[0]=n,e[1]=a,e[2]=i,e[3]=o):o=e[3];const u=o;let d;return e[4]!==u?(d=_.jsx(u,{}),e[4]=u,e[5]=d):d=e[5],d},pC=Nt(t=>{const e=Q(5),{index:n,components:i}=t;let a;e[0]!==i?(a=_.jsx(Mg,{components:i}),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==n||e[3]!==a?(o=_.jsx(Ax,{index:n,children:a}),e[2]=n,e[3]=a,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&Rg(t.components,e.components));pC.displayName="ThreadPrimitive.MessageByIndex";const mC=Nt(t=>{const e=Q(7),{messageId:n,components:i}=t;let a;if(e[0]!==n?(a=d=>hC(d.thread.messages,n),e[0]=n,e[1]=a):a=e[1],!me(a))return null;let o;e[2]!==i?(o=_.jsx(Mg,{components:i}),e[2]=i,e[3]=o):o=e[3];let u;return e[4]!==n||e[5]!==o?(u=_.jsx(fC,{id:n,children:o}),e[4]=n,e[5]=o,e[6]=u):u=e[6],u},(t,e)=>t.messageId===e.messageId&&Rg(t.components,e.components));mC.displayName="ThreadPrimitive.Unstable_MessageById";const c1=({children:t})=>{const e=me(fs(n=>n.thread.messages.map(i=>i.id)));return yt(()=>e.length===0?null:e.map((n,i)=>_.jsx(Ax,{index:i,children:_.jsx(qi,{getItemState:a=>a.thread.message({index:i}).getState(),children:a=>t({get message(){return a()}})})},n)),[e,t])},gC=t=>{const e=Q(4),{components:n,children:i}=t;if(n){let o;return e[0]!==n?(o=_.jsx(c1,{children:()=>_.jsx(Mg,{components:n})}),e[0]=n,e[1]=o):o=e[1],o}let a;return e[2]!==i?(a=_.jsx(c1,{children:i}),e[2]=i,e[3]=a):a=e[3],a};gC.displayName="ThreadPrimitive.Messages";const Z5=Nt(gC,(t,e)=>t.children||e.children?t.children===e.children:Rg(t.components,e.components));function W5(t){return t.message.role}function e6(t){return t.message.composer.isEditing}const yC=t=>{const e=t.message.metadata;if(!(!e||typeof e!="object"))return e.custom?.quote};var t6=class extends Error{componentName;constructor(t,e=`Component "${t}" is not in the generative-ui allowlist.`){super(e),this.name="GenerativeUIRenderError",this.componentName=t}};const n6=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),vC=t=>t==null?[]:Array.isArray(t)?t:[t],d1=(t,...e)=>{},s6=64,gm=(t,e,n,i,a=0)=>{if(a>s6)return d1(),null;if(t==null)return null;if(typeof t=="string"||typeof t=="number")return t;if(Array.isArray(t))return t.map((m,y)=>gm(m,e,n,`${i}/${y}`,a+1));if(!n6(t)||!("component"in t)||typeof t.component!="string")return d1(`[generative-ui] Skipping malformed node at ${i}:`,t),null;const{component:o,props:u,children:d,key:f}=t,p=Object.hasOwn(e,o)?e[o]:void 0;if(!p){if(n)return _.jsx(n,{component:o,props:u},f??i);throw new t6(o)}return VM(p,{...u??{},key:f??i},...vC(d).map((m,y)=>gm(m,e,n,`${i}/${y}`,a+1)))},kg=t=>{const e=Q(11),{spec:n,components:i,Fallback:a}=t,o=n?.root;let u;e[0]!==o?(u=vC(o),e[0]=o,e[1]=u):u=e[1];const d=u;let f;if(e[2]!==a||e[3]!==i||e[4]!==d){let m;e[6]!==a||e[7]!==i?(m=(y,v)=>gm(y,i,a,`${v}`),e[6]=a,e[7]=i,e[8]=m):m=e[8],f=d.map(m),e[2]=a,e[3]=i,e[4]=d,e[5]=f}else f=e[5];let p;return e[9]!==f?(p=_.jsx(_.Fragment,{children:f}),e[9]=f,e[10]=p):p=e[10],p};kg.displayName="GenerativeUIRender";const bC=t=>{const e=Q(4),{components:n,spec:i,Fallback:a}=t,o=me(i6),u=i??o;if(!u)return null;let d;return e[0]!==a||e[1]!==n||e[2]!==u?(d=_.jsx(kg,{spec:u,components:n,Fallback:a}),e[0]=a,e[1]=n,e[2]=u,e[3]=d):d=e[3],d};bC.displayName="MessagePrimitive.GenerativeUI";function i6(t){const e=t.part;return e?.type==="generative-ui"?e.spec:void 0}const Ng=(t,e,n)=>{const i=t.toolUIs[e.toolName]?.[0]?.render??null;return i||n||(fD(e.mcp?.app?.resourceUri)&&t.mcpApp?t.mcpApp.render:null)},gp=t=>{let e=-1;return{startGroup:n=>{e===-1&&(e=n)},endGroup:(n,i)=>{e!==-1&&(i.push({type:t,startIndex:e,endIndex:n}),e=-1)},finalize:(n,i)=>{e!==-1&&i.push({type:t,startIndex:e,endIndex:n})}}},r6=(t,e,n)=>{const i=[];if(e){const a=gp("chainOfThoughtGroup");for(let o=0;o<t.length;o++){const u=t[o];u==="tool-call"||u==="reasoning"?a.startGroup(o):(a.endGroup(o-1,i),i.push({type:"single",index:o}))}a.finalize(t.length-1,i)}else{const a=gp("toolGroup"),o=gp("reasoningGroup");for(let u=0;u<t.length;u++){const d=t[u];d==="tool-call"?(o.endGroup(u-1,i),a.startGroup(u)):d==="reasoning"?(a.endGroup(u-1,i),o.startGroup(u)):(a.endGroup(u-1,i),o.endGroup(u-1,i),i.push({type:"single",index:u}))}a.finalize(t.length-1,i),o.finalize(t.length-1,i)}if(n){const a=new Set;for(const o of i){if(o.type==="single")continue;const u=n[o.startIndex];u?.includes(":")&&!a.has(u)&&(a.add(u),o.idKey=`id:${u}`)}}return i},a6=t=>{const e=Q(10),n=me(fs(T6)),i=me(fs(w6));let a;e:{if(n.length===0){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let f;e[1]!==i?(f={ranges:d,partIds:i},e[1]=i,e[2]=f):f=e[2],a=f;break e}let o;e[3]!==n||e[4]!==i||e[5]!==t?(o=r6(n,t,i),e[3]=n,e[4]=i,e[5]=t,e[6]=o):o=e[6];let u;e[7]!==i||e[8]!==o?(u={ranges:o,partIds:i},e[7]=i,e[8]=o,e[9]=u):u=e[9],a=u}return a},o6=t=>{const e=Q(11);let n,i,a;e[0]!==t?({ByName:n,Fallback:i,...a}=t,e[0]=t,e[1]=n,e[2]=i,e[3]=a):(n=e[1],i=e[2],a=e[3]);let o;e[4]!==n||e[5]!==i||e[6]!==a?(o=f=>Ng(f.tools,a,n)??i,e[4]=n,e[5]=i,e[6]=a,e[7]=o):o=e[7];const u=me(o);if(!u)return null;let d;return e[8]!==u||e[9]!==a?(d=_.jsx(u,{...a}),e[8]=u,e[9]=a,e[10]=d):d=e[10],d},Og=(t,e,n)=>{const i=t.renderers[e]?.[0];return i||(t.fallbacks[0]??n)},l6=t=>{const e=Q(9);let n,i;e[0]!==t?({Fallback:n,...i}=t,e[0]=t,e[1]=n,e[2]=i):(n=e[1],i=e[2]);let a;e[3]!==n||e[4]!==i.name?(a=d=>Og(d.dataRenderers,i.name,n),e[3]=n,e[4]=i.name,e[5]=a):a=e[5];const o=me(a);if(!o)return null;let u;return e[6]!==o||e[7]!==i?(u=_.jsx(o,{...i}),e[6]=o,e[7]=i,e[8]=u):u=e[8],u},Rs={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:t})=>t,ReasoningGroup:({children:t})=>t},_C=t=>{const e=Q(54),{components:n}=t;let i;e[0]!==n?(i=n===void 0?{}:n,e[0]=n,e[1]=i):i=e[1];const{Text:a,Reasoning:o,Image:u,Source:d,File:f,Unstable_Audio:p,tools:m,data:y,generativeUI:v}=i,b=a===void 0?Rs.Text:a,T=o===void 0?Rs.Reasoning:o,w=u===void 0?Rs.Image:u,x=d===void 0?Rs.Source:d,E=f===void 0?Rs.File:f,C=p===void 0?Rs.Unstable_Audio:p;let R;e[2]!==m?(R=m===void 0?{}:m,e[2]=m,e[3]=R):R=e[3];const O=R,L=ke(),I=me(x6),P=I.type;if(P==="tool-call"){const k=L.part.addToolResult,H=L.part.resumeToolCall,V=L.part.respondToToolApproval,z=L.part.unstable_recordInteraction;if("Override"in O){let ee;e[4]!==z?(ee=z&&{unstable_recordInteraction:z},e[4]=z,e[5]=ee):ee=e[5];let oe;return e[6]!==k||e[7]!==I||e[8]!==V||e[9]!==H||e[10]!==ee||e[11]!==O.Override?(oe=_.jsx(O.Override,{...I,addResult:k,resume:H,respondToApproval:V,...ee}),e[6]=k,e[7]=I,e[8]=V,e[9]=H,e[10]=ee,e[11]=O.Override,e[12]=oe):oe=e[12],oe}let q;e[13]!==I.toolName||e[14]!==O.by_name?(q=O.by_name&&Object.hasOwn(O.by_name,I.toolName)?O.by_name[I.toolName]:void 0,e[13]=I.toolName,e[14]=O.by_name,e[15]=q):q=e[15];const W=q;let X;e[16]!==z?(X=z&&{unstable_recordInteraction:z},e[16]=z,e[17]=X):X=e[17];let Z;return e[18]!==W||e[19]!==k||e[20]!==I||e[21]!==V||e[22]!==H||e[23]!==X||e[24]!==O.Fallback?(Z=_.jsx(o6,{...I,ByName:W,Fallback:O.Fallback,addResult:k,resume:H,respondToApproval:V,...X}),e[18]=W,e[19]=k,e[20]=I,e[21]=V,e[22]=H,e[23]=X,e[24]=O.Fallback,e[25]=Z):Z=e[25],Z}if(I.status?.type==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(P){case"text":{let k;return e[26]!==b||e[27]!==I?(k=_.jsx(b,{...I}),e[26]=b,e[27]=I,e[28]=k):k=e[28],k}case"reasoning":{let k;return e[29]!==T||e[30]!==I?(k=_.jsx(T,{...I}),e[29]=T,e[30]=I,e[31]=k):k=e[31],k}case"source":{let k;return e[32]!==x||e[33]!==I?(k=_.jsx(x,{...I}),e[32]=x,e[33]=I,e[34]=k):k=e[34],k}case"image":{let k;return e[35]!==w||e[36]!==I?(k=_.jsx(w,{...I}),e[35]=w,e[36]=I,e[37]=k):k=e[37],k}case"file":{let k;return e[38]!==E||e[39]!==I?(k=_.jsx(E,{...I}),e[38]=E,e[39]=I,e[40]=k):k=e[40],k}case"audio":{let k;return e[41]!==C||e[42]!==I?(k=_.jsx(C,{...I}),e[41]=C,e[42]=I,e[43]=k):k=e[43],k}case"data":{let k;e[44]!==y||e[45]!==I.name?(k=(y?.by_name&&Object.hasOwn(y.by_name,I.name)?y.by_name[I.name]:void 0)??y?.Fallback,e[44]=y,e[45]=I.name,e[46]=k):k=e[46];const H=k;let V;return e[47]!==H||e[48]!==I?(V=_.jsx(l6,{...I,Fallback:H}),e[47]=H,e[48]=I,e[49]=V):V=e[49],V}case"generative-ui":{if(!v?.components)return null;const k=I;let H;return e[50]!==v.Fallback||e[51]!==v.components||e[52]!==k.spec?(H=_.jsx(kg,{spec:k.spec,components:v.components,Fallback:v.Fallback}),e[50]=v.Fallback,e[51]=v.components,e[52]=k.spec,e[53]=H):H=e[53],H}default:return console.warn(`Unknown message part type: ${P}`),null}},hl=Nt(t=>{const e=Q(5),{index:n,components:i}=t;let a;e[0]!==i?(a=_.jsx(_C,{components:i}),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==n||e[3]!==a?(o=_.jsx(bg,{index:n,children:a}),e[2]=n,e[3]=a,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components?.Text===e.components?.Text&&t.components?.Reasoning===e.components?.Reasoning&&t.components?.Source===e.components?.Source&&t.components?.Image===e.components?.Image&&t.components?.File===e.components?.File&&t.components?.Unstable_Audio===e.components?.Unstable_Audio&&t.components?.tools===e.components?.tools&&t.components?.data===e.components?.data&&t.components?.generativeUI===e.components?.generativeUI&&t.components?.ToolGroup===e.components?.ToolGroup&&t.components?.ReasoningGroup===e.components?.ReasoningGroup);hl.displayName="MessagePrimitive.PartByIndex";const u6=t=>{const e=Q(6),{status:n,component:i}=t,a=n.type==="running";let o;e[0]!==i||e[1]!==n?(o=_.jsx(i,{type:"text",text:"",status:n}),e[0]=i,e[1]=n,e[2]=o):o=e[2];let u;return e[3]!==a||e[4]!==o?(u=_.jsx(_g,{text:"",isRunning:a,children:o}),e[3]=a,e[4]=o,e[5]=u):u=e[5],u},c6=Object.freeze({type:"complete"}),d6=Object.freeze({type:"running"}),f6=t=>{const e=Q(6),{components:n}=t,i=me(C6);if(n?.Empty){let u;return e[0]!==n.Empty||e[1]!==i?(u=_.jsx(n.Empty,{status:i}),e[0]=n.Empty,e[1]=i,e[2]=u):u=e[2],u}if(i.type!=="running")return null;const a=n?.Text??Rs.Text;let o;return e[3]!==i||e[4]!==a?(o=_.jsx(u6,{status:i,component:a}),e[3]=i,e[4]=a,e[5]=o):o=e[5],o},SC=Nt(f6,(t,e)=>t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),h6=t=>{const e=Q(4),{components:n,enabled:i}=t;let a;if(e[0]!==i?(a=u=>{if(!i||u.message.parts.length===0)return!1;const d=u.message.parts[u.message.parts.length-1];return d?.type!=="text"&&d?.type!=="reasoning"},e[0]=i,e[1]=a):a=e[1],!me(a))return null;let o;return e[2]!==n?(o=_.jsx(SC,{components:n}),e[2]=n,e[3]=o):o=e[3],o},p6=Nt(h6,(t,e)=>t.enabled===e.enabled&&t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),m6=t=>{const e=Q(4),{Quote:n}=t,i=me(yC);if(!i)return null;let a;return e[0]!==n||e[1]!==i.messageId||e[2]!==i.text?(a=_.jsx(n,{text:i.text,messageId:i.messageId}),e[0]=n,e[1]=i.messageId,e[2]=i.text,e[3]=a):a=e[3],a},g6=Nt(m6),TC=()=>{const t=Q(9),e=ke(),n=me(E6),i=me(A6),a=e.part.unstable_recordInteraction;if(!i||n.type!=="tool-call")return null;let o;t[0]!==a?(o=a&&{unstable_recordInteraction:a},t[0]=a,t[1]=o):o=t[1];let u;return t[2]!==i||t[3]!==e.part.addToolResult||t[4]!==e.part.respondToToolApproval||t[5]!==e.part.resumeToolCall||t[6]!==n||t[7]!==o?(u=_.jsx(i,{...n,addResult:e.part.addToolResult,resume:e.part.resumeToolCall,respondToApproval:e.part.respondToToolApproval,...o}),t[2]=i,t[3]=e.part.addToolResult,t[4]=e.part.respondToToolApproval,t[5]=e.part.resumeToolCall,t[6]=n,t[7]=o,t[8]=u):u=t[8],u},wC=()=>{const t=Q(3),e=me(I6),n=me(R6);if(!n||e.type!=="data")return null;const i=e;let a;return t[0]!==n||t[1]!==i?(a=_.jsx(n,{...i}),t[0]=n,t[1]=i,t[2]=a):a=t[2],a},xC=()=>{const t=Q(2),e=me(M6);if(e==="tool-call"){let n;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=_.jsx(TC,{}),t[0]=n):n=t[0],n}if(e==="data"){let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=_.jsx(wC,{}),t[1]=n):n=t[1],n}return null},y6=Object.freeze({type:"text",text:"",status:d6}),v6=({children:t})=>{const e=ke(),n=me(i=>i.dataRenderers);return _.jsx(qi,{getItemState:i=>i.part.getState(),children:i=>t({get part(){const a=i();if(a.type==="tool-call"){const o=e.tools.getState(),u=Ng(o,a)!==null,d=e.part;return{...a,toolUI:u?_.jsx(TC,{}):null,addResult:d.addToolResult,resume:d.resumeToolCall,respondToApproval:d.respondToToolApproval,...d.unstable_recordInteraction&&{unstable_recordInteraction:d.unstable_recordInteraction}}}if(a.type==="data"){const o=Og(n,a.name,void 0)!==void 0;return{...a,dataRendererUI:o?_.jsx(wC,{}):null}}return a}})})},CC=t=>{const e=Q(5),{index:n,children:i}=t;let a;e[0]!==i?(a=_.jsx(v6,{children:i}),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==n||e[3]!==a?(o=_.jsx(bg,{index:n,children:a}),e[2]=n,e[3]=a,e[4]=o):o=e[4],o},b6=t=>{const e=Q(11),{children:n}=t,i=me(fs(k6)),a=i.length,o=me(N6),u=a===0&&o;if(a===0){if(!u)return null;let p;e[0]!==n?(p=n({part:y6}),e[0]=n,e[1]=p):p=e[1];let m;return e[2]!==p?(m=_.jsx(_g,{text:"",isRunning:!0,children:p}),e[2]=p,e[3]=m):m=e[3],m}let d;if(e[4]!==n||e[5]!==i){let p;e[7]!==n?(p=(m,y)=>_.jsx(CC,{index:y,children:v=>n(v)??_.jsx(xC,{})},m),e[7]=n,e[8]=p):p=e[8],d=i.map(p),e[4]=n,e[5]=i,e[6]=d}else d=e[6];let f;return e[9]!==d?(f=_.jsx(_.Fragment,{children:d}),e[9]=d,e[10]=f):f=e[10],f},ym=t=>{const e=Q(5),{components:n,unstable_showEmptyOnNonTextEnd:i,children:a}=t,o=i===void 0?!0:i;if(a){let d;return e[0]!==a?(d=_.jsx(b6,{children:a}),e[0]=a,e[1]=d):d=e[1],d}let u;return e[2]!==n||e[3]!==o?(u=_.jsx(_6,{components:n,unstable_showEmptyOnNonTextEnd:o}),e[2]=n,e[3]=o,e[4]=u):u=e[4],u};ym.displayName="MessagePrimitive.Parts";const _6=t=>{const e=Q(18),{components:n,unstable_showEmptyOnNonTextEnd:i}=t,a=me(O6),o=!!n?.ChainOfThought,{ranges:u,partIds:d}=a6(o);let f;e:{if(a===0){let T;e[0]!==n?(T=_.jsx(SC,{components:n}),e[0]=n,e[1]=T):T=e[1],f=T;break e}let b;if(e[2]!==n||e[3]!==u||e[4]!==d){let T;e[6]!==n||e[7]!==d?(T=w=>{if(w.type==="single")return _.jsx(hl,{index:w.index,components:n},d[w.index]);const x=JSON.stringify([w.type,w.idKey??w.startIndex]);if(w.type==="chainOfThoughtGroup"){const E=n?.ChainOfThought;return E?_.jsx(J4,{startIndex:w.startIndex,endIndex:w.endIndex,children:_.jsx(E,{})},x):null}else if(w.type==="toolGroup"){const E=n?.ToolGroup??Rs.ToolGroup;return _.jsx(E,{startIndex:w.startIndex,endIndex:w.endIndex,children:Array.from({length:w.endIndex-w.startIndex+1},(C,R)=>{const O=w.startIndex+R;return _.jsx(hl,{index:O,components:n},d[O])})},x)}else{const E=n?.ReasoningGroup??Rs.ReasoningGroup;return _.jsx(E,{startIndex:w.startIndex,endIndex:w.endIndex,children:Array.from({length:w.endIndex-w.startIndex+1},(C,R)=>{const O=w.startIndex+R;return _.jsx(hl,{index:O,components:n},d[O])})},x)}},e[6]=n,e[7]=d,e[8]=T):T=e[8],b=u.map(T),e[2]=n,e[3]=u,e[4]=d,e[5]=b}else b=e[5];f=b}const p=f;let m;e[9]!==n?(m=n?.Quote&&_.jsx(g6,{Quote:n.Quote}),e[9]=n,e[10]=m):m=e[10];let y;e[11]!==n||e[12]!==i?(y=_.jsx(p6,{components:n,enabled:i}),e[11]=n,e[12]=i,e[13]=y):y=e[13];let v;return e[14]!==p||e[15]!==m||e[16]!==y?(v=_.jsxs(_.Fragment,{children:[m,p,y]}),e[14]=p,e[15]=m,e[16]=y,e[17]=v):v=e[17],v};function S6(t){return t.type}function T6(t){return t.message.parts.map(S6)}function w6(t){return Or(t.message.parts)}function x6(t){return t.part}function C6(t){return t.message.status??c6}function E6(t){return t.part}function A6(t){return t.part.type==="tool-call"?Ng(t.tools,t.part):null}function I6(t){return t.part}function R6(t){return t.part.type==="data"?Og(t.dataRenderers,t.part.name,void 0)??null:null}function M6(t){return t.part.type}function k6(t){return Or(t.message.parts)}function N6(t){return(t.message.status?.type??"complete")==="running"}function O6(t){return t.message.parts.length}const D6=Symbol.for("@assistant-ui/groupBy.memoKey"),f1=t=>{const e=t.nextChildIdx++;return t.nodeKey===""?String(e):`${t.nodeKey}.${e}`},h1=(t,e)=>{if(!(e===void 0||t.claimed.has(e)))return t.claimed.add(e),`id:${e}`},j6=(t,e)=>{const n={key:"",nodeKey:"",indices:[],children:[],nextChildIdx:0,claimed:new Set},i=[n],a=()=>{const o=i.pop(),u=i[i.length-1],d=e?.[o.indices[0]];u.children.push({type:"group",key:o.key,nodeKey:o.nodeKey,idKey:h1(u,d?.includes(":")?d:void 0),indices:o.indices,children:o.children})};for(let o=0;o<t.length;o++){const u=t[o];let d=0;for(;d<i.length-1&&d<u.length&&i[d+1].key===u[d];)d++;for(;i.length-1>d;)a();for(;i.length-1<u.length;){const p=i[i.length-1];i.push({key:u[i.length-1],nodeKey:f1(p),indices:[],children:[],nextChildIdx:0,claimed:new Set})}const f=i[i.length-1];f.children.push({type:"part",index:o,nodeKey:f1(f),idKey:h1(f,e?.[o])});for(let p=1;p<i.length;p++)i[p].indices.push(o)}for(;i.length>1;)a();return n.children},z6=(t,e,n)=>{if(!n)return!1;switch(t){case"never":return!1;case"always":return!0;case"empty":return e.length===0;case"no-text":{const i=e[e.length-1];return i===void 0||i.type!=="text"&&i.type!=="reasoning"}}},EC=()=>{throw new 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 use registered UIs.")},Dg=(t,e,n)=>{if(t.type==="part")return _.jsx(CC,{index:t.index,children:({part:d})=>n({part:d,children:_.jsx(EC,{})})??_.jsx(xC,{})},t.idKey?`part-${t.idKey}`:`part-${t.index}`);const{status:i,counts:a,timing:o}=Y4(e,t.indices),u={type:t.key,status:i,counts:a,indices:t.indices,...o&&{timing:o}};return _.jsx(gw,{children:n({part:u,children:_.jsx(_.Fragment,{children:t.children.map(d=>Dg(d,e,n))})})},JSON.stringify([t.key,t.idKey??t.nodeKey]))},AC=({groupBy:t,indicator:e="no-text",children:n})=>{const i=me(fs(f=>f.message.parts)),a=me(f=>f.tools.toolUIs),o=me(f=>e==="never"?!1:f.message.status?.type==="running"),u=t[D6]??t,d=yt(()=>{const f={toolUIs:a};return j6(i.map(p=>t(p,f)??[]),Or(i))},[i,u,a]);return _.jsxs(_.Fragment,{children:[d.map(f=>Dg(f,i,n)),z6(e,i,o)&&n({part:{type:"indicator"},children:_.jsx(EC,{})})]})};AC.displayName="MessagePrimitive.GroupedParts";const P6=new WeakMap,B6=t=>P6.get(t),U6=t=>t.length===1?{type:"part",index:t[0],nodeKey:"0",idKey:void 0}:{type:"group",key:"group-row",nodeKey:"0",idKey:void 0,indices:t,children:t.map((e,n)=>({type:"part",index:e,nodeKey:`0.${n}`,idKey:void 0}))},L6=t=>{const e=Q(7),{row:n,children:i}=t,a=me(fs($6));if(n.indices.some(u=>u>=a.length))return null;let o;if(e[0]!==i||e[1]!==a||e[2]!==n){const u=B6(n)??U6(n.indices);let d;e[4]!==i||e[5]!==n?(d=f=>i({type:"part",row:n,part:f.part,children:f.children}),e[4]=i,e[5]=n,e[6]=d):d=e[6],o=Dg(u,a,d),e[0]=i,e[1]=a,e[2]=n,e[3]=o}else o=e[3];return o},q6=({row:t,children:e})=>_.jsx(qi,{getItemState:n=>n.message.getState(),children:n=>e({type:"message",row:t,get message(){return n()}})}),H6=({row:t,children:e})=>_.jsx(qi,{getItemState:n=>n.message.getState(),children:n=>e({type:"turn-end",row:t,get message(){return n()}})}),V6=t=>{const e=Q(8),{row:n,children:i}=t;let a;if(e[0]!==n.messageId?(a=d=>hC(d.thread.messages,n.messageId),e[0]=n.messageId,e[1]=a):a=e[1],!me(a))return null;let o;e[2]!==i||e[3]!==n?(o=n.type==="message"?_.jsx(q6,{row:n,children:i}):n.type==="part"?_.jsx(L6,{row:n,children:i}):_.jsx(H6,{row:n,children:i}),e[2]=i,e[3]=n,e[4]=o):o=e[4];let u;return e[5]!==n.messageId||e[6]!==o?(u=_.jsx(fC,{id:n.messageId,children:o}),e[5]=n.messageId,e[6]=o,e[7]=u):u=e[7],u},IC=Nt(V6,(t,e)=>t.row===e.row&&t.children===e.children);IC.displayName="ThreadPrimitive.Row";function $6(t){return t.message.parts}const G6=t=>{const e=Q(5),{children:n}=t,i=me(yC);if(!i)return null;let a;e[0]!==n||e[1]!==i?(a=n(i),e[0]=n,e[1]=i,e[2]=a):a=e[2];let o;return e[3]!==a?(o=_.jsx(_.Fragment,{children:a}),e[3]=a,e[4]=o):o=e[4],o},RC=Nt(G6);RC.displayName="MessagePrimitive.Quote";const MC=(t,e)=>{switch(e.type){case"image":return t?.Image??t?.Attachment;case"document":return t?.Document??t?.Attachment;case"file":return t?.File??t?.Attachment;default:return t?.Attachment}},F6=t=>{const e=Q(5),{components:n}=t,i=me(Y6);if(!i)return null;let a;e[0]!==i||e[1]!==n?(a=MC(n,i),e[0]=i,e[1]=n,e[2]=a):a=e[2];const o=a;if(!o)return null;let u;return e[3]!==o?(u=_.jsx(o,{}),e[3]=o,e[4]=u):u=e[4],u},kC=Nt(t=>{const e=Q(5),{index:n,components:i}=t;let a;e[0]!==i?(a=_.jsx(F6,{components:i}),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==n||e[3]!==a?(o=_.jsx(Cx,{index:n,children:a}),e[2]=n,e[3]=a,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components?.Image===e.components?.Image&&t.components?.Document===e.components?.Document&&t.components?.File===e.components?.File&&t.components?.Attachment===e.components?.Attachment);kC.displayName="MessagePrimitive.AttachmentByIndex";const p1=({children:t})=>{const e=me(fs(n=>n.message.role!=="user"?[]:(n.message.submission?.attachments??n.message.attachments??[]).map(i=>i.id)));return yt(()=>e.map((n,i)=>_.jsx(Cx,{index:i,children:_.jsx(qi,{getItemState:a=>a.message.attachment({index:i}).getState(),children:a=>t({get attachment(){return a()}})})},n)),[e,t])},NC=t=>{const e=Q(4),{components:n,children:i}=t;if(n){let o;return e[0]!==n?(o=_.jsx(p1,{children:u=>{const{attachment:d}=u,f=MC(n,d);return f?_.jsx(f,{}):null}}),e[0]=n,e[1]=o):o=e[1],o}let a;return e[2]!==i?(a=_.jsx(p1,{children:i}),e[2]=i,e[3]=a):a=e[3],a};NC.displayName="MessagePrimitive.Attachments";function Y6(t){return t.attachment}const OC=(t,e)=>{switch(e.type){case"image":return t?.Image??t?.Attachment;case"document":return t?.Document??t?.Attachment;case"file":return t?.File??t?.Attachment;default:return t?.Attachment}},Q6=t=>{const e=Q(5),{components:n}=t,i=me(K6);if(!i)return null;let a;e[0]!==i||e[1]!==n?(a=OC(n,i),e[0]=i,e[1]=n,e[2]=a):a=e[2];const o=a;if(!o)return null;let u;return e[3]!==o?(u=_.jsx(o,{}),e[3]=o,e[4]=u):u=e[4],u},DC=Nt(t=>{const e=Q(5),{index:n,components:i}=t;let a;e[0]!==i?(a=_.jsx(Q6,{components:i}),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==n||e[3]!==a?(o=_.jsx(Ex,{index:n,children:a}),e[2]=n,e[3]=a,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components?.Image===e.components?.Image&&t.components?.Document===e.components?.Document&&t.components?.File===e.components?.File&&t.components?.Attachment===e.components?.Attachment);DC.displayName="ComposerPrimitive.AttachmentByIndex";const m1=({children:t})=>{const e=me(fs(n=>n.composer.attachments.map(i=>i.id)));return yt(()=>e.map((n,i)=>_.jsx(Ex,{index:i,children:_.jsx(qi,{getItemState:a=>a.composer.attachment({index:i}).getState(),children:a=>t({get attachment(){return a()}})})},n)),[e,t])},jC=t=>{const e=Q(4),{components:n,children:i}=t;if(n){let o;return e[0]!==n?(o=_.jsx(m1,{children:u=>{const{attachment:d}=u,f=OC(n,d);return f?_.jsx(f,{}):null}}),e[0]=n,e[1]=o):o=e[1],o}let a;return e[2]!==i?(a=_.jsx(m1,{children:i}),e[2]=i,e[3]=a):a=e[3],a};jC.displayName="ComposerPrimitive.Attachments";function K6(t){return t.attachment}const X6=({children:t})=>{const e=me(fs(n=>n.composer.queue.map(i=>i.id)));return yt(()=>e.map((n,i)=>_.jsx(W4,{index:i,children:_.jsx(qi,{getItemState:a=>a.composer.queueItem({index:i}).getState(),children:a=>t({get queueItem(){return a()}})})},n)),[e,t])},zC=Nt(X6);zC.displayName="ComposerPrimitive.Queue";const jg=t=>{const{children:e}=t;return me(J6)?e:null};jg.displayName="MessagePartPrimitive.InProgress";function J6(t){return t.part.status.type==="running"}const Z6=t=>{const e=new Map;return t.map(n=>{const i=JSON.stringify([n.title,n.label,n.prompt]),a=e.get(i)??0;return e.set(i,a+1),a===0?i:`${i}:${a}`})},PC=t=>{const e=Q(2),{components:n}=t,i=n.Suggestion;let a;return e[0]!==i?(a=_.jsx(i,{}),e[0]=i,e[1]=a):a=e[1],a},BC=Nt(t=>{const e=Q(5),{index:n,components:i}=t;let a;e[0]!==i?(a=_.jsx(PC,{components:i}),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==n||e[3]!==a?(o=_.jsx(Ix,{index:n,children:a}),e[2]=n,e[3]=a,e[4]=o):o=e[4],o},(t,e)=>t.index===e.index&&t.components.Suggestion===e.components.Suggestion);BC.displayName="ThreadPrimitive.SuggestionByIndex";const g1=({children:t})=>{const e=me(fs(n=>Z6(n.suggestions.suggestions)));return yt(()=>e.length===0?null:e.map((n,i)=>_.jsx(Ix,{index:i,children:_.jsx(qi,{getItemState:a=>a.suggestions.suggestion({index:i}).getState(),children:a=>t({get suggestion(){return a()}})})},n)),[e,t])},UC=t=>{const e=Q(4),{components:n,children:i}=t;if(n){let o;return e[0]!==n?(o=_.jsx(g1,{children:()=>_.jsx(PC,{components:n})}),e[0]=n,e[1]=o):o=e[1],o}let a;return e[2]!==i?(a=_.jsx(g1,{children:i}),e[2]=i,e[3]=a):a=e[3],a};UC.displayName="ThreadPrimitive.Suggestions";const W6=Nt(UC,(t,e)=>t.children||e.children?t.children===e.children:t.components.Suggestion===e.components.Suggestion),ez=t=>{const e=Q(3);let n;return e[0]!==t.dictation||e[1]!==t.editing?(n=i=>{if(t.editing===!0&&!i.composer.isEditing||t.editing===!1&&i.composer.isEditing)return!1;const a=i.composer.dictation!=null;return!(t.dictation===!0&&!a||t.dictation===!1&&a)},e[0]=t.dictation,e[1]=t.editing,e[2]=n):n=e[2],me(n)},LC=t=>{const e=Q(3);let n,i;return e[0]!==t?({children:n,...i}=t,e[0]=t,e[1]=n,e[2]=i):(n=e[1],i=e[2]),ez(i)?n:null};LC.displayName="ComposerPrimitive.If";const tz=t=>t.thread.isDisabled||!t.composer.canSend||t.thread.isRunning&&!t.thread.capabilities.queue&&t.thread.voice===void 0,nz=t=>!t.composer.canCancel,sz=t=>t.composer.isEditing||t.optional.message?.submission!==void 0||t.optional.thread?.isDisabled===!0||t.optional.thread?.voice!==void 0||t.optional.thread?.capabilities.edit===!1,iz=t=>t.thread.isRunning||t.thread.isDisabled||t.thread.voice!==void 0||t.message.role!=="assistant"||!t.thread.capabilities.reload,qC=t=>(t.message.role!=="assistant"||t.message.status?.type!=="running")&&t.message.parts.some(e=>e.type==="text"&&e.text.length>0),rz=t=>!qC(t),az=t=>t.optional.thread?.capabilities.speech!==!0||!qC(t),HC=t=>t.isSendDisabled?"blocked":t.voice!==void 0?t.voice.canSendText?"now":"blocked":t.isRunning?t.capabilities.queue?"queued":"blocked":"now",oz=(t,e)=>t.thread.isDisabled||e&&HC(t.thread)==="blocked",lz=t=>{if(t.message.status?.type!=="incomplete"||t.message.status.reason!=="error")return;const e=t.message.status.error;return typeof e=="string"?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"?e.message:e??"An error occurred"},uz=()=>{const t=Q(5),e=ke(),n=me(tz);let i;t[0]!==e?(i=u=>{e.composer.send(u)},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={send:a,disabled:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o},cz=()=>{const t=Q(5),e=ke(),n=me(nz);let i;t[0]!==e?(i=()=>{e.composer.cancel()},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==a||t[3]!==n?(o={cancel:a,disabled:n},t[2]=a,t[3]=n,t[4]=o):o=t[4],o},dz=()=>{const t=Q(5),e=ke(),n=me(fz);let i;t[0]!==e?(i=()=>{e.composer.startDictation()},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={startDictation:a,disabled:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o};function fz(t){return t.composer.dictation!=null||!t.thread.capabilities.dictation||!t.composer.isEditing}const hz=()=>{const t=Q(5),e=ke(),n=me(pz);let i;t[0]!==e?(i=u=>e.composer.addAttachment(u),t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==a||t[3]!==n?(o={addAttachment:a,disabled:n},t[2]=a,t[3]=n,t[4]=o):o=t[4],o};function pz(t){return t.thread.isDisabled||!t.composer.isEditing}const mz=t=>{const e=Q(20);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const{copiedDuration:i,copyToClipboard:a}=n,o=i===void 0?3e3:i,u=ke(),d=me(rz),f=me(gz),p=me(yz),m=me(vz),y=me(bz),v=we(void 0),b=we(void 0),T=we(0),w=we(f);let x,E;e[2]!==f?(x=()=>{w.current=f},E=[f],e[2]=f,e[3]=x,e[4]=E):(x=e[3],E=e[4]),Os(x,E);let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=()=>()=>{T.current=T.current+1,v.current!==void 0&&(clearTimeout(v.current),v.current=void 0,b.current?.(!1),b.current=void 0)},e[5]=C):C=e[5];let R;e[6]!==u||e[7]!==f?(R=[u,f],e[6]=u,e[7]=f,e[8]=R):R=e[8],Ce(C,R);let O;e[9]!==u||e[10]!==y||e[11]!==o||e[12]!==a||e[13]!==m||e[14]!==f?(O=()=>{if(!a)return;const k=m?y:u.message.getCopyText();if(!k)return;const H=T.current,V=f,z=u.message.setIsCopied;let q;try{q=a(k)}catch{return}Promise.resolve(q).then(()=>{H!==T.current||V!==w.current||(v.current!==void 0&&clearTimeout(v.current),b.current=z,z(!0),v.current=setTimeout(()=>{if(v.current=void 0,V!==w.current){z(!1),b.current=void 0;return}z(!1),b.current=void 0},o))},_z)},e[9]=u,e[10]=y,e[11]=o,e[12]=a,e[13]=m,e[14]=f,e[15]=O):O=e[15];const L=O,I=d||!a;let P;return e[16]!==L||e[17]!==p||e[18]!==I?(P={copy:L,disabled:I,isCopied:p},e[16]=L,e[17]=p,e[18]=I,e[19]=P):P=e[19],P};function gz(t){return t.message.id}function yz(t){return t.message.isCopied}function vz(t){return t.composer.isEditing}function bz(t){return t.composer.text}function _z(){}const Sz=()=>{const t=Q(5),e=ke(),n=me(sz);let i;t[0]!==e?(i=()=>{e.composer.beginEdit()},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={edit:a,disabled:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o},Tz=()=>{const t=Q(5),e=ke(),n=me(iz);let i;t[0]!==e?(i=()=>{e.message.reload()},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={reload:a,disabled:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o},wz=()=>{const t=Q(5),e=ke(),n=me(Cz);let i;t[0]!==e?(i=()=>{e.message.submitFeedback({type:"positive"})},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={submit:a,isSubmitted:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o},xz=()=>{const t=Q(5),e=ke(),n=me(Ez);let i;t[0]!==e?(i=()=>{e.message.submitFeedback({type:"negative"})},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={submit:a,isSubmitted:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o};function Cz(t){return t.message.metadata.submittedFeedback?.type==="positive"}function Ez(t){return t.message.metadata.submittedFeedback?.type==="negative"}const Az=()=>{const t=Q(5),e=ke(),n=me(az);let i;t[0]!==e?(i=async()=>{e.message.speak()},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={speak:a,disabled:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o},Iz=()=>{const t=Q(5),e=ke(),n=me(Rz);let i;t[0]!==e?(i=()=>{e.message.stopSpeaking()},t[0]=e,t[1]=i):i=t[1];const a=i;let o;return t[2]!==n||t[3]!==a?(o={stopSpeaking:a,disabled:n},t[2]=n,t[3]=a,t[4]=o):o=t[4],o};function Rz(t){return t.message.speech==null}const Mz=t=>{const e=Q(10),{prompt:n,send:i,clearComposer:a}=t,o=a===void 0?!0:a,u=ke(),d=i??!1;let f;e[0]!==d?(f=b=>oz(b,d),e[0]=d,e[1]=f):f=e[1];const p=me(f);let m;e[2]!==u||e[3]!==o||e[4]!==n||e[5]!==d?(m=()=>{if(d){const b=HC(u.thread.getState());if(b==="blocked")return;u.thread.append({content:[{type:"text",text:n}],runConfig:u.composer.getState().runConfig}),o&&b==="now"&&u.composer.setText("")}else if(o)u.composer.setText(n);else{const b=u.composer.getState().text;u.composer.setText([b,n].filter(kz).join(" "))}},e[2]=u,e[3]=o,e[4]=n,e[5]=d,e[6]=m):m=e[6];const y=m;let v;return e[7]!==p||e[8]!==y?(v={trigger:y,disabled:p},e[7]=p,e[8]=y,e[9]=v):v=e[9],v};function kz(t){return t.trim()}const Nz=()=>me(lz),Oz=async(t,e)=>{const{signal:n,onUpdate:i}=e;if(Symbol.asyncIterator in t)for await(const a of t){if(n.aborted)break;i(a)}else{const a=await t;if(n.aborted)return;i(a)}},Ma=(t,e)=>t.status?.type!=="requires-action"||t.status.reason!=="tool-calls"||t.content.some(n=>n.type==="tool-call"&&n.result===void 0&&n.approval!==void 0&&n.approval.approved===void 0&&n.approval.resolution===void 0)?!1:e===void 0?t.content.every(n=>n.type!=="tool-call"||n.result!==void 0||n.approval!==void 0):t.content.every(n=>n.type!=="tool-call"||n.result!==void 0||n.approval!==void 0||!e.includes(n.toolName));var yp=class extends Error{name="AbortError";detach;constructor(t,e){super(e),this.detach=t}};const Dz=t=>t.role!=="assistant"||t.status.type!=="requires-action"||t.status.reason!=="interrupt"||t.content.some(e=>e.type==="tool-call"&&e.result===void 0&&e.interrupt!=null)?t:{...t,status:vg(!1,!1,!1,t.content.some(e=>e.type==="tool-call"&&e.result===void 0))},ol=t=>{let e=!1;const n=t.content.map(a=>a.type!=="tool-call"||a.approval===void 0||a.approval.approved!==void 0||a.approval.resolution!==void 0?a:(e=!0,{...a,approval:{...a.approval,resolution:"cancelled"}})),i=t.status.type==="running"||t.status.type==="requires-action";return!e&&!i?t:{...t,content:n,status:i?{type:"incomplete",reason:"cancelled"}:t.status}},vp=t=>{const e=new Set(t.messages.map(n=>n.parentId));return{...t,messages:t.messages.map(n=>({...n,message:n.message.role==="assistant"&&e.has(n.message.id)?ol(n.message):Dz(n.message)}))}},vm=t=>{if(t.role!=="assistant")return t;let e=!1;const n=t.content.map(i=>{if(i.type!=="tool-call")return i;const a=i.messages?.map(vm),o=a?.some((f,p)=>f!==i.messages?.[p]);if(i.unstable_interactions===void 0&&o!==!0)return i;e=!0;const{unstable_interactions:u,...d}=i;return o?{...d,messages:a}:d});return e?{...t,content:n}:t};var jz=class extends HD{capabilities={switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,delete:!1,reload:!0,refetchThread:!1,cancel:!0,unstable_copy:!0,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1,answerToolCall:!0};abortController=null;_queue=null;_queueRunInFlight=null;_activeRun=null;_queueBusy=!1;_queueCancelReserved=!1;_messageReplacements=new WeakMap;_historyWrites=new Map;_unwrittenSeedMessages=new Set;_runStarted=!1;async _writeHistory(t,e,n){const i=this._loadGeneration;try{await n()}catch(a){throw console.error("[assistant-ui] local thread history write failed:",a),i===this._loadGeneration&&this._notifyEventSubscribers("historyWriteError",{operation:t,messageIds:e,message:a instanceof Error?a.message:String(a),error:a}),a}}_deletedMessages=new Map;_chainHistoryWrite(t,e){const n=this._loadGeneration,i=()=>n===this._loadGeneration?e():Promise.resolve(),a=this._deletedMessages.get(t);if(a)return a.suppressed?.push(i),Promise.resolve();const o=this._unwrittenSeedMessages.has(t);if(o&&!this._runStarted)return Promise.resolve();const u=this._options.adapters.history;if(u&&this._unwrittenSeedMessages.size>0){const m=this.repository.export().messages.filter(v=>this._unwrittenSeedMessages.has(v.message.id));this._unwrittenSeedMessages.clear();let y;for(const v of m){const b=this._chainHistoryWrite(v.message.id,()=>this._writeHistory("append",[v.message.id],()=>u.append(v)));v.message.id===t?y=b:b.catch(()=>{})}if(o)return y??Promise.resolve()}const d=this._historyWrites.get(t);let f;if(d)f=d.then(i,i);else try{f=Promise.resolve(i())}catch(m){f=Promise.reject(m)}const p=f.then(()=>{},()=>{});return this._historyWrites.set(t,p),p.then(()=>{this._historyWrites.get(t)===p&&this._historyWrites.delete(t)}),f}_persistMessageUpdate(t){const e=this._options.adapters.history;if(!e)return;let n;try{n=this.repository.getMessage(t)}catch{return}const{parentId:i,message:a}=n;a.role!=="assistant"||a.status.type==="running"||this._unwrittenMessages.has(a.id)&&!e.update&&a.status.type==="requires-action"||this._persistSettled(i,a)?.catch(()=>{})}_roundtripsInFlight=new Map;_followedDuringRun=new Set;_unwrittenMessages=new Set;_persistSettled(t,e){const n=this._options.adapters.history;if(!n)return;const i=this._unwrittenMessages.delete(e.id)||this._unwrittenSeedMessages.has(e.id)?"append":"update",a=i==="append"?n.append:n.update;if(!a)return;const o={parentId:t,message:e,runConfig:this._lastRunConfig};return this._chainHistoryWrite(e.id,()=>this._writeHistory(i,[e.id],()=>a.call(n,o)))}_cancelPause(t){if(t===null)return;let e;try{e=this.repository.getMessage(t)}catch{return}if(e.message.role!=="assistant")return;if(this._roundtripsInFlight.has(t)){this._followedDuringRun.add(t);const i=ol(e.message),a=this._options.adapters.history;if(a&&!a.update&&this._roundtripsInFlight.get(t)?.resumedFromPause&&!this._unwrittenMessages.has(t)){const o={parentId:e.parentId,message:i,runConfig:this._lastRunConfig};return this._chainHistoryWrite(t,()=>this._writeHistory("append",[t],()=>a.append(o)))}return this._persistSettled(e.parentId,i)}const n=ol(e.message);if(n!==e.message)return this.repository.addOrUpdateMessage(e.parentId,n),this._persistSettled(e.parentId,n)}_resumeIfReady(t){const e=this.getMessageById(t);return e?.message.role!=="assistant"||this.repository.hasChildren(t)||this._followedDuringRun.has(t)||!Ma(e.message,this._options.unstable_humanToolNames)?!1:(this._runLoop(e.parentId,e.message,this._lastRunConfig).catch(()=>{}),!0)}isDisabled=!1;isSendDisabled=!1;get isRunning(){return this._activeRun?.isRunning||this._roundtripsInFlight.size>0?!0:void 0}_isLoading=!1;get isLoading(){return this._isLoading}_suggestions=[];_suggestionsController=null;get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}constructor(t,e,n){if(super(t),this.__internal_setOptions(e),n){this.repository.import(vp(n));for(const{message:i}of n.messages)this._unwrittenSeedMessages.add(i.id)}}_options;_historyScopeInitialized=!1;_historyScopeId;_lastRunConfig={};_getThreadId;__internal_setGetThreadId(t){this._getThreadId=t}_getInitializePromise;_pendingInitialization;__internal_setGetInitializePromise(t){this._getInitializePromise=t}get extras(){}__internal_setOptions(t){if(this._options===t)return;const e=this._options?.adapters.history,n=this._options?.adapters.suggestion,i=t.adapters.history,a=i!==void 0&&this._historyScopeInitialized&&this._historyScopeId!==i.scopeId;i&&(this._historyScopeInitialized=!0,this._historyScopeId=i.scopeId);const o=this._loadRequested&&a;if(o&&(this._loadGeneration++,this._historyWrites.clear(),this._deletedMessages.clear(),this._roundtripsInFlight.clear(),this._followedDuringRun.clear(),this._unwrittenMessages.clear(),this._unwrittenSeedMessages.clear(),this._queue?.clear(),this.cancelRun(),Lx(this),this._queue=null,this._queueRunInFlight=null,this._activeRun=null,this._appendsBeforeRun=0,this.composer.reset().catch(w=>{console.error("[assistant-ui] Composer reset threw after the history scope changed",w)}),this._suggestions=[],this._lastRunConfig={},this.repository.clear(),this._loadPromise=void 0,this._isLoading=!1),this._options=t,!t.adapters.voice&&this.voice)try{this.disconnectVoice()}catch(w){console.error("[assistant-ui] Voice cleanup threw after the adapter changed",w)}let u=o;const d=t.adapters.suggestion;d?(!n||n.key!==d.key)&&(this._suggestionsController?.abort(),this._suggestionsController=null,this._suggestions.length>0&&(this._suggestions=[],u=!0),this._generateSuggestions()):(this._suggestionsController?.abort(),this._suggestionsController=null,this._suggestions.length>0&&(this._suggestions=[],u=!0));const f=t.adapters?.speech!==void 0;this.capabilities.speech!==f&&(this.capabilities.speech=f,u=!0);const p=t.adapters?.dictation!==void 0;this.capabilities.dictation!==p&&(this.capabilities.dictation=p,u=!0);const m=t.adapters?.voice!==void 0;this.capabilities.voice!==m&&(this.capabilities.voice=m,u=!0);const y=t.adapters?.attachments!==void 0;this.capabilities.attachments!==y&&(this.capabilities.attachments=y,u=!0);const v=t.adapters?.feedback!==void 0;this.capabilities.feedback!==v&&(this.capabilities.feedback=v,u=!0);const b=t.adapters?.history?.delete!==void 0;this.capabilities.delete!==b&&(this.capabilities.delete=b,u=!0);const T=t.unstable_enableMessageQueue===!0;T&&!this._queue?(this._queue=ND({run:w=>{const x={};this._queueRunInFlight=x,this._runAppend({...w,parentId:this._resolveAppendParent(this.messages.at(-1)?.id??null)}).finally(()=>{this._queueRunInFlight===x&&(this._queueRunInFlight=null)}).catch(()=>{})}}),this.voice&&this._queue.hold(),this._queueBusy=!1,this._queueCancelReserved=!1,this._syncQueue(),this._queue.subscribe(()=>this._notifySubscribers())):!T&&this._queue&&(this._queue=null),this.capabilities.queue!==T&&(this.capabilities.queue=T,u=!0),u&&this._notifySubscribers(),this._loadRequested&&!this._loadPromise&&i&&(a||!e&&this.messages.length===0)&&this.__internal_load().catch(w=>{console.error("[assistant-ui] local thread history load failed:",w)})}_loadPromise;_loadGeneration=0;_loadImports=0;_loadRequested=!1;__internal_load(){if(this._loadRequested=!0,this._loadPromise)return this._loadPromise;if(!this.adapters.history)return Promise.resolve();this._isLoading=!0;const t=this.adapters.history,e=t.scopeId,n=this._loadGeneration;let i=!1;const o=(async()=>{let u;try{u=await t.load()}catch(v){if(n!==this._loadGeneration)return;const b=this.adapters.history;if(b&&b.scopeId!==e)return;throw i=!0,v}if(n!==this._loadGeneration)return;const d=this.adapters.history;if(d&&d.scopeId!==e||!u)return;const{repository:f,droppedIds:p}=ID(u);if(p.length>0&&console.warn("[assistant-ui] Skipped history messages with missing parents:",p),u.headId!=null&&!u.messages.some(v=>v.message.id===u.headId)&&console.warn("[assistant-ui] History head is not among the loaded messages:",u.headId),(f.messages.length>0||this._unwrittenSeedMessages.size===0)&&(this._unwrittenSeedMessages.clear(),this._loadImports++,this.repository.clear(),this.repository.import(vp(f))),f.messages.length>0&&this.ensureInitialized(),this._notifySubscribers(),n!==this._loadGeneration)return;const m=this.adapters.history;if(!m||m.scopeId!==e)return;const y=m.resume?.bind(m);u.unstable_resume&&y&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},y).catch(()=>{})})().finally(()=>{n!==this._loadGeneration||this._loadPromise!==o||(this._isLoading=!1,i&&!this.adapters.history&&(this._loadPromise=void 0),this._notifySubscribers())});return this._loadPromise=o,this._notifySubscribers(),o}_getHistoryLoadBarrier(t){if(!this._isLoading||!this._loadPromise)return;const e=this._loadPromise;return new Promise(n=>{const i=()=>{t.removeEventListener("abort",i),n()};if(t.aborted){i();return}t.addEventListener("abort",i,{once:!0}),e.then(i,i)})}async append(t){if(t={...t,parentId:this._resolveAppendParent(t.parentId)},this.voice)return this._appendToVoiceSession(t);if(this._isVoiceMessage(t.sourceId))throw new Error("Voice transcript messages cannot be edited");const e=t.parentId===(this.messages.at(-1)?.id??null),n=t.startRun??t.role==="user";if(this._queue&&n&&e){t.steer??this._queueRunInFlight!==null?this._queue.adapter.steer(t):this._queue.adapter.enqueue(t);return}return this._queue&&!e&&(this._options.unstable_queueClearOnRewind??!0)&&this._queue.clear(),this._runAppend(t)}_commitVoiceMessage(t){const e=Ac(this),n=a=>{if(e.aborted){this._dropVoiceMessage(t.id,a);return}const o=this.repository.headId;this.repository.addOrUpdateMessage(o,t);const u=this._cancelPause(o);this.repository.resetHead(t.id);const d=this._options.adapters.history,f=d?this._chainHistoryWrite(t.id,()=>this._writeHistory("append",[t.id],()=>d.append({parentId:o,message:t}))):void 0;return f?.catch(()=>{}),this._dropVoiceMessage(t.id,!1),a&&this._notifySubscribers(),u?Promise.all([u,f]).then(()=>{}):f},i=this._getVoiceCommitBarrier();return i?i.then(()=>n(!0)):n(!1)}_onVoiceConnected(){this._queue?.hold()}_onVoiceDisconnected(){this._queue?.release()}getQueueItems(){return this._queue?.adapter.items??ti}getSteerQueueItems(){return this._queue?.adapter.steerItems??ti}moveQueueItem(t,e){this._queue?.adapter.move(t,e)}removeQueueItem(t){this._queue?.adapter.remove(t)}_rollbackAppend(t){try{if(this.repository.getMessage(t.id).message!==t)return;this.repository.deleteMessage(t.id)}catch{return}this._notifySubscribers()}_pendingAppends=0;_isRunActive(){return this._pendingAppends>0||super._isRunActive()}_appendsBeforeRun=0;_isQueueBusy(){return this._appendsBeforeRun>0||this._activeRun!==null}_syncQueue(){const t=this._queue;if(!t)return;const e=this._isQueueBusy();e&&!this._queueBusy?(this._queueBusy=!0,t.notifyBusy()):!e&&this._queueBusy&&queueMicrotask(()=>{this._queue!==t||!this._queueBusy||this._isQueueBusy()||(this._queueBusy=!1,this._queueCancelReserved=!1,t.notifyIdle())})}async _runAppend(t){const e=this._loadGeneration;this._pendingAppends+=1,this._appendsBeforeRun+=1;let n=!0;const i=()=>{n&&(n=!1,e===this._loadGeneration&&(this._appendsBeforeRun-=1))};this._syncQueue();try{await this._runAppendInner(t,i)}finally{this._pendingAppends-=1,i(),this._syncQueue()}}async _runAppendInner(t,e){const n=Ac(this),i=this._getHistoryLoadBarrier(n);if(i){const m=t.parentId===(this.messages.at(-1)?.id??null);if(await i,n.aborted)return;m&&(t={...t,parentId:this._resolveAppendParent(this.messages.at(-1)?.id??null)})}const a=this.enrichAppendMetadata(t);this.ensureInitialized();const o=_l(a,un(),{type:"complete",reason:"unknown"});this.repository.addOrUpdateMessage(a.parentId,o),this._notifySubscribers();try{const m=this._getInitializePromise?.();m&&await m}catch(m){if(this._rollbackAppend(o),n.aborted)return;a.parentId!==null&&this._resumeIfReady(a.parentId);const y=new Ec;throw y.cause=m,y}if(n.aborted){this._rollbackAppend(o);return}const u=this._cancelPause(a.parentId),d=this._options.adapters.history,f=d?this._chainHistoryWrite(o.id,()=>this._writeHistory("append",[o.id],()=>d.append({parentId:a.parentId,message:o,...a.runConfig!==void 0&&{runConfig:a.runConfig}}))):void 0,p=u?Promise.all([u,f]).then(()=>{}):f;if(p?.catch(()=>{}),a.startRun??a.role==="user"){e();const[m,y]=await Promise.allSettled([this.startRun({parentId:o.id,sourceId:a.sourceId,runConfig:a.runConfig??{}}),p]);if(m.status==="rejected")throw m.reason;if(y.status==="rejected")throw y.reason}else this.repository.switchToBranch(o.id),this._notifySubscribers(),await p}async deleteMessage(t){const e=this._loadGeneration,n=this._options.adapters.history;if(!n?.delete)throw new Error("Runtime does not support deleting messages.");const i=this.repository.getMessages(),a=i.findIndex(v=>v.id===t);if(a===-1)throw new Error("Message not found.");if(this._unwrittenSeedMessages.delete(t)){this._deletedMessages.set(t,{suppressed:null}),this.repository.deleteMessage(t),this._notifySubscribers();return}const o=this._deletedMessages.get(t);if(o?.suppressed&&o.deletion)return o.deletion;const u=n.delete.bind(n),d=v=>this._writeHistory("delete",v.map(b=>b.message.id),()=>u(v)),f=i[a],p=[{parentId:i[a-1]?.id??null,message:f}],m=this._historyWrites.get(t),y={suppressed:[]};return this._deletedMessages.set(t,y),y.deletion=(async()=>{try{await d(p)}catch(v){const b=y.suppressed??[];if(y.suppressed=null,this._deletedMessages.get(t)===y){this._deletedMessages.delete(t);for(const T of b)this._chainHistoryWrite(t,T).catch(()=>{})}throw v}y.suppressed=null,e===this._loadGeneration&&(m?.then(()=>this._deletedMessages.get(t)===y?d(p):void 0).catch(()=>{}),this.repository.deleteMessage(t),this._notifySubscribers())})(),y.deletion}resumeRun({stream:t,...e}){if(!t)throw new Error("You must pass a stream parameter to resume runs.");return this.startRun(e,t)}exportExternalState(){throw new Error("Runtime does not support exporting external states.")}import(t){this._roundtripsInFlight.clear(),this._followedDuringRun.clear(),this._unwrittenMessages.clear(),this._unwrittenSeedMessages.clear(),this._deletedMessages.clear(),super.import(vp(t))}importExternalState(){throw new Error("Runtime does not support importing external states.")}unstable_notifySessionReset(){throw new Error("Runtime does not support resetting sessions.")}async startRun({parentId:t,sourceId:e,runConfig:n},i){if(this.voice)throw new Error("Cannot start a run while a voice session is connected");if(this._isVoiceMessage(e))throw new Error("Voice transcript messages cannot be reloaded");const a=this._cancelPause(t),o=un(),u={id:o,role:"assistant",status:{type:"running"},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};this._unwrittenMessages.add(o);const d=this._runLoop(t,u,n,i);if(!a)return d;const[f,p]=await Promise.allSettled([d,a]);if(f.status==="rejected")throw f.reason;if(p.status==="rejected")throw p.reason}async _runLoop(t,e,n,i){const a=this._loadGeneration,o=Ac(this);if(this.ensureInitialized()){const m=this._getInitializePromise?.();if(m){this._pendingInitialization=m;const y=()=>{this._pendingInitialization===m&&(this._pendingInitialization=void 0)};m.then(y,y)}}const u=this._pendingInitialization;if(u){const m=this.getMessageById(e.id)!==void 0;if(await u.catch(()=>{}),o.aborted||a!==this._loadGeneration||m&&!this.getMessageById(e.id))return}const d=this._getHistoryLoadBarrier(o);if(d){const m=this._loadImports;if(await d,o.aborted||a!==this._loadGeneration||this._loadImports!==m)return}if(this.voice)throw new Error("Cannot start a run while a voice session is connected");this._runStarted=!0,this._notifyEventSubscribers("runStart",{});const f={resumedFromPause:e.status.type==="requires-action",isRunning:!0};this._activeRun=f;let p=!1;try{this._queueCancelReserved&&this._queue&&(this._queueCancelReserved=!1,this._queue.notifyBusy(),this._queue.notifyIdle()),this._syncQueue(),this._suggestions=[],this._suggestionsController?.abort(),this._suggestionsController=null,this._notifySubscribers();do{if(e=await this.performRoundtrip(t,e,n,f,i),i=void 0,this._activeRun!==f)break;let m=this._messageReplacements.get(e);for(;m;)e=m.message,m=this._messageReplacements.get(e);if(this.getMessageById(e.id)?.message!==e)break}while(Ma(e,this._options.unstable_humanToolNames)&&!this.repository.hasChildren(e.id))}finally{const m=this.isRunning;f.isRunning=!1,a===this._loadGeneration&&this._notifyEventSubscribers("runEnd",{}),p=a===this._loadGeneration&&this._activeRun===f,p&&(this._activeRun=null),a===this._loadGeneration&&this._syncQueue(),m!==this.isRunning&&this._notifySubscribers()}p&&!o.aborted&&e.status?.type!=="requires-action"&&this._generateSuggestions()}_generateSuggestions(){const t=this.adapters.suggestion,e=this.messages.at(-1);if(!t||this._activeRun||e?.role!=="assistant"||e.status.type!=="complete"&&e.status.type!=="incomplete")return;this._suggestionsController?.abort();const n=new AbortController;this._suggestionsController=n;const{signal:i}=n;(async()=>{try{const a=t.generate({messages:this.messages,signal:i});await Oz(a,{signal:i,onUpdate:o=>{this._suggestionsController===n&&(this._suggestions=o,this._notifySubscribers())}})}catch{}})()}async performRoundtrip(t,e,n,i,a){const o=this._loadGeneration,u=(t?this.repository.getMessages(t):[]).map(R=>vm(R.role==="assistant"&&(R.status.type==="running"||this._roundtripsInFlight.has(R.id))?ol(R):R));this.abortController?.abort();const d=new AbortController;this.abortController=d;const f=e.content,p=e.metadata?.unstable_annotations,m=e.metadata?.unstable_data,y=e.metadata?.steps,v=e.metadata?.custom,b=new Set;let T=!0;try{this.repository.getMessage(e.id)}catch{T=!1}const w=()=>{if(o!==this._loadGeneration)return!1;if(!T)return this._activeRun===i;try{let R=e,O=this._messageReplacements.get(R);for(;O;)O.toolCallId!==void 0&&b.add(O.toolCallId),R=O.message,O=this._messageReplacements.get(R);return this.repository.getMessage(e.id).message!==R?!1:(e=R,!0)}catch{return!1}},x=R=>{const O=new Map;for(const k of e.content)k.type==="tool-call"&&k.unstable_interactions!==void 0&&O.set(k.toolCallId,k.unstable_interactions);const L=R.map(k=>{if(k.type!=="tool-call"||k.unstable_interactions!==void 0)return k;const H=O.get(k.toolCallId);return H===void 0?k:{...k,unstable_interactions:H}});if(b.size===0)return L;const I=new Map;for(const k of e.content){if(k.type!=="tool-call"||!b.has(k.toolCallId))continue;const H=I.get(k.toolCallId)??[];H.push(k),I.set(k.toolCallId,H)}const P=new Map;return L.map(k=>{if(k.type!=="tool-call")return k;const H=P.get(k.toolCallId)??0;if(P.set(k.toolCallId,H+1),k.result!==void 0&&k.isPreliminary!==!0)return k;const V=I.get(k.toolCallId)?.[H];if(!V||V.result===void 0||V.isPreliminary===!0)return k;const{isPreliminary:z,artifact:q,modelContent:W,...X}=k;return{...X,result:V.result,isError:V.isError,...V.artifact!==void 0&&{artifact:V.artifact},...V.modelContent!==void 0&&{modelContent:V.modelContent}}})},E=R=>{if(!w())return;const O=R.metadata?.steps,L=O?[...y??[],...O]:void 0,I=R.metadata?.unstable_annotations,P=R.metadata?.unstable_data,k=I?[...p??[],...I]:void 0,H=P?[...m??[],...P]:void 0,V=R.content?x([...f,...R.content]):void 0;e={...e,...V?{content:V}:void 0,status:R.status??e.status,...R.metadata?{metadata:{...e.metadata,...R.metadata.unstable_state!==void 0?{unstable_state:R.metadata.unstable_state}:void 0,...k?{unstable_annotations:k}:void 0,...H?{unstable_data:H}:void 0,...L?{steps:L}:void 0,...R.metadata?.timing?{timing:R.metadata.timing}:void 0,...R.metadata?.custom?{custom:{...v??{},...R.metadata.custom}}:void 0}}:void 0},this.repository.addOrUpdateMessage(t,e),T=!0,this._notifySubscribers()},C=this._options.maxSteps??2;this._roundtripsInFlight.set(e.id,{controller:d,resumedFromPause:i.resumedFromPause});try{if((e.metadata?.steps?.length??0)>=C)return E({status:{type:"incomplete",reason:"tool-calls"}}),e;const R=!T;E({status:{type:"running"}}),R&&(this.repository.switchToBranch(e.id),this._notifySubscribers()),this._lastRunConfig=n??{};const{unstable_composerMetadata:O,...L}=this.getModelContext();a=a??this.adapters.chatModel.run.bind(this.adapters.chatModel);const I=d.signal,P=()=>I.aborted&&(e.status.type==="running"||e.status.type==="requires-action"&&(this._activeRun!==i||Ma(e,this._options.unstable_humanToolNames))),k=this._getThreadId?.(),H=a({messages:u,runConfig:this._lastRunConfig,abortSignal:I,context:L,unstable_assistantMessageId:e.id,unstable_threadId:k,unstable_parentId:t,unstable_getMessage(){return w(),vm(e)}});if(Symbol.asyncIterator in H)for await(const V of H){if(I.aborted){P()&&E({status:{type:"incomplete",reason:"cancelled"}});break}E(V)}else E(await H);P()?E({status:{type:"incomplete",reason:"cancelled"}}):e.status.type==="running"&&E({status:{type:"complete",reason:"unknown"}})}catch(R){if(R instanceof yp)E({status:{type:"incomplete",reason:"cancelled"}});else if(R instanceof Error&&R.name==="AbortError")E({status:{type:"incomplete",reason:"cancelled"}});else throw E({status:{type:"incomplete",reason:"error",error:sD(R)}}),R}finally{const R=this.isRunning;this.abortController===d&&(this.abortController=null);const O=this._roundtripsInFlight.get(e.id)?.controller===d;O&&this._roundtripsInFlight.delete(e.id);const L=this._options.adapters.history,I=w();let P=!1,k;const H=O&&this._followedDuringRun.delete(e.id);if(H){const q=this.getMessageById(e.id);if(q?.message.role==="assistant"){const W=ol(q.message);W!==q.message&&(this.repository.addOrUpdateMessage(q.parentId,W),P=!0,I?e=W:k=this._persistSettled(q.parentId,W))}}if(O&&!I&&!k){const q=this.getMessageById(e.id);q?.message.role==="assistant"&&(q.message.status.type==="complete"||q.message.status.type==="incomplete")&&this._unwrittenMessages.has(e.id)&&(k=this._persistSettled(q.parentId,q.message))}const V=e.status.type==="complete"||e.status.type==="incomplete",z=e.status.type==="requires-action"&&!Ma(e,this._options.unstable_humanToolNames);if(I&&(V||z&&L?.update))if(V&&i.resumedFromPause&&!H&&!this._unwrittenMessages.has(e.id)&&L&&!L.update){const q={parentId:t,message:e,runConfig:this._lastRunConfig};k=this._chainHistoryWrite(e.id,()=>this._writeHistory("append",[e.id],()=>L.append(q)))}else k=this._persistSettled(t,e);i.isRunning=Ma(e,this._options.unstable_humanToolNames)&&!this.repository.hasChildren(e.id),(P||R!==this.isRunning)&&this._notifySubscribers(),k&&await k}return e}detach(){Bx(this),this._queue=null;const t=new yp(!0);this.abortController?.abort(t),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}cancelRun(){this._queue&&(this._options.unstable_queueClearOnCancel??!0?this._queue.clear():(this._queue.notifyCancelled(),this._queueBusy&&(this._queueCancelReserved=!0)));const t=new yp(!1);this.abortController?.abort(t),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}_onMessageMetadataChanged(t,e){this._messageReplacements.set(t,{message:e}),this._persistMessageUpdate(e.id)}addToolResult({messageId:t,toolCallId:e,result:n,isError:i,artifact:a,modelContent:o}){if(this.voice)throw new Error("Cannot add a tool result while a voice session is connected");const u=this.repository.getMessage(t),{parentId:d}=u;let{message:f}=u;if(f.role!=="assistant")throw new Error("Tried to add tool result to non-assistant message");let p=!1,m=!1;const y=f.content.map(b=>{if(b.type!=="tool-call"||b.toolCallId!==e)return b;m=!0,(b.result===void 0||b.isPreliminary===!0)&&(p=!0);const{isPreliminary:T,...w}=b;return{...w,result:n,isError:i,...a!==void 0&&{artifact:a},...o!==void 0&&{modelContent:o}}});if(!m)throw new Error("Tried to add tool result to non-existing tool call");const v=f;f={...f,content:y},v.status.type==="running"&&this._messageReplacements.set(v,{message:f,toolCallId:e}),this.repository.addOrUpdateMessage(d,f),this._notifySubscribers(),p&&(this._resumeIfReady(t)||this._persistMessageUpdate(t))}resumeToolCall(t){throw new Error("Local runtime does not support resuming tool calls. For human-in-the-loop tools, list the tool in unstable_humanToolNames and complete the call with addToolResult.")}async unstable_recordToolInteraction({messageId:t,toolCallId:e,interaction:n}){let i;try{i=this.repository.getMessage(t)}catch{throw new Error("Tried to record a tool interaction on a non-existing message")}const{parentId:a,message:o}=i;if(o.role!=="assistant")throw new Error("Tried to record a tool interaction on a non-assistant message");const u=o.content.findIndex(p=>p.type==="tool-call"&&p.toolCallId===e);if(u===-1)throw new Error("Tried to record a tool interaction on a non-existing tool call");const d=o.content[u];if(d.type!=="tool-call")throw new Error("Tried to record a tool interaction on a non-existing tool call");const f={...o,content:o.content.map((p,m)=>m===u?{...p,unstable_interactions:ox(d.unstable_interactions,n)}:p)};o.status.type==="running"&&this._messageReplacements.set(o,{message:f}),this.repository.addOrUpdateMessage(a,f),this._notifySubscribers(),this._persistMessageUpdate(f.id)}respondToToolApproval({approvalId:t,approved:e,optionId:n,text:i,answers:a,reason:o}){if(this.voice)throw new Error("Cannot respond to a tool approval while a voice session is connected");let u=this.repository.getMessages().findLast(v=>v.role==="assistant"&&v.content.some(b=>b.type==="tool-call"&&b.approval?.id===t));if(!u)throw new Error("Tried to respond to a non-existing tool approval");if(this.abortController!==null)throw new Error("Tried to respond to a tool approval while a run is in progress");if(u.status?.type!=="requires-action")throw new Error("Tried to respond to a tool approval on a message whose status is not requires-action");if(this.repository.hasChildren(u.id))throw new Error("Tried to respond to a tool approval on a message that later messages follow");if(this._followedDuringRun.has(u.id))throw new Error("Tried to respond to a tool approval that was cancelled or expired");const d=u.content.find(v=>v.type==="tool-call"&&v.approval?.id===t);if(d?.type!=="tool-call"||!d.approval)throw new Error("Tried to respond to a non-existing tool approval");if(d.approval.resolution!==void 0)throw new Error("Tried to respond to a tool approval that was cancelled or expired");if(d.approval.approved!==void 0)throw new Error("Tried to respond to an already decided tool approval");const f=d.approval,p=u.content.map(v=>{if(v!==d)return v;const b={...f,approved:e,...n!=null&&{optionId:n},...i!=null&&{text:i},...a!=null&&{answers:a},...o!=null&&{reason:o}};return e?{...v,approval:b}:{...v,approval:b,result:{error:o||"Tool approval denied"},isError:!0}});u={...u,content:p};const{parentId:m}=this.repository.getMessage(u.id);this.repository.addOrUpdateMessage(m,u),this._notifySubscribers(),this._notifyToolApprovalAnswered(u.id,d.toolCallId,d.toolName,e);const y=this.getMessageById(u.id);return this.repository.headId===u.id&&y?.message.role==="assistant"&&Ma(y.message,this._options.unstable_humanToolNames)?this._runLoop(y.parentId,y.message,this._lastRunConfig).catch(()=>{}):this._persistMessageUpdate(u.id),Promise.resolve()}};const y1=Object.freeze([]),bm="__DEFAULT_ID__",zz=Object.freeze({[bm]:{id:bm,remoteId:void 0,externalId:void 0,status:"regular",title:void 0}});var Pz=class extends Li{_mainThread;constructor(t){super(),this._mainThread=t()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){}get threadIds(){return y1}get archivedThreadIds(){return y1}get mainThreadId(){return bm}get threadItems(){return zz}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getLoadThreadsPromise(){return Promise.resolve()}getItemById(t){if(t===this.mainThreadId)return{status:"regular",id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw new Error("Method not implemented")}async switchToThread(){throw new Error("Method not implemented.")}switchToNewThread(){throw new Error("Method not implemented.")}rename(){throw new Error("Method not implemented.")}archive(){throw new Error("Method not implemented.")}detach(){throw new Error("Method not implemented.")}unarchive(){throw new Error("Method not implemented.")}delete(){throw new Error("Method not implemented.")}initialize(t){return Promise.resolve({remoteId:t,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}},Bz=class extends Tg{threads;Provider=void 0;_options;constructor(t,e){super(),this._options=t,this.threads=new Pz(()=>new jz(this._contextProvider,this._options,e&&Hx.fromArray(e)))}};const Uz=()=>()=>{},Lz=(t,e,n)=>{const i=Q(40);let a,o;i[0]!==e?({initialMessages:a,...o}=e,i[0]=e,i[1]=a,i[2]=o):(a=i[1],o=i[2]);const u=vx()??{};let d,f;i[3]!==u?({modelContext:d,...f}=u,i[3]=u,i[4]=d,i[5]=f):(d=i[4],f=i[5]);let p;i[6]!==t||i[7]!==o.adapters||i[8]!==f?(p={...f,...o.adapters,chatModel:t},i[6]=t,i[7]=o.adapters,i[8]=f,i[9]=p):p=i[9];let m;i[10]!==o||i[11]!==p?(m={...o,adapters:p},i[10]=o,i[11]=p,i[12]=m):m=i[12];const y=m;let v;i[13]!==a||i[14]!==n||i[15]!==y?(v=()=>{const z=n!==void 0?a?.map((q,W)=>({...q,id:q.id??`${n}-message-${W}`,content:typeof q.content=="string"?q.content:q.content.map((X,Z)=>X.type==="tool-call"&&!X.toolCallId?{...X,toolCallId:`${n}-tool-${W}-${Z}`}:X)})):a;return new Bz(y,z)},i[13]=a,i[14]=n,i[15]=y,i[16]=v):v=i[16];const[b]=Ne(v),T=ke(),w=we(void 0);let x;i[17]!==T||i[18]!==b.threads?(x=()=>{b.threads.getMainThreadRuntimeCore().__internal_setGetThreadId(()=>T.threadListItem.__internal_getRuntime?.().getState().remoteId)},i[17]=T,i[18]=b.threads,i[19]=x):x=i[19];let E;i[20]!==T||i[21]!==b?(E=[T,b],i[20]=T,i[21]=b,i[22]=E):E=i[22],Ce(x,E);let C;i[23]!==b.threads?(C=()=>()=>{b.threads.getMainThreadRuntimeCore().detach()},i[23]=b.threads,i[24]=C):C=i[24];let R;i[25]!==b?(R=[b],i[25]=b,i[26]=R):R=i[26],w3(C,R);let O;i[27]!==y||i[28]!==b.threads?(O=()=>{b.threads.getMainThreadRuntimeCore().__internal_setOptions(y)},i[27]=y,i[28]=b.threads,i[29]=O):O=i[29],Ha(O);let L;i[30]!==b.threads?(L=()=>{const z=b.threads.getMainThreadRuntimeCore().__internal_load();w.current!==z&&(w.current=z,z.catch(Vz))},i[30]=b.threads,i[31]=L):L=i[31];let I;i[32]!==b?(I=[b],i[32]=b,i[33]=I):I=i[33],Ce(L,I);let P,k;i[34]!==d||i[35]!==b?(P=()=>{if(d)return b.registerModelContextProvider(d)},k=[d,b],i[34]=d,i[35]=b,i[36]=P,i[37]=k):(P=i[36],k=i[37]),Ce(P,k);let H;i[38]!==b?(H=()=>new Sg(b),i[38]=b,i[39]=H):H=i[39];const[V]=Ne(H);return V},qz=t=>{const{cloud:e,scopeId:n,initialMessages:i,maxSteps:a,adapters:o,unstable_humanToolNames:u,unstable_enableMessageQueue:d,unstable_queueClearOnRewind:f,unstable_queueClearOnCancel:p,...m}=t;return{localRuntimeOptions:{cloud:e,scopeId:n,initialMessages:i,maxSteps:a,adapters:o,unstable_humanToolNames:u,unstable_enableMessageQueue:d,unstable_queueClearOnRewind:f,unstable_queueClearOnCancel:p},otherOptions:m}},Hz=(t,{cloud:e,scopeId:n,...i}={})=>{const a=ad(),o=i.initialMessages?.some(f=>f.id===void 0||typeof f.content!="string"&&f.content.some(p=>p.type==="tool-call"&&!p.toolCallId))??!1,u=Ui(Uz,()=>!1,()=>o),d=X5({cloud:e,scopeId:n});return yj({runtimeHook:function(){return Lz(t,i,u?a:void 0)},adapter:d,allowNesting:!0})};function Vz(t){console.error("[assistant-ui] local thread history load failed:",t)}function $z(t,e){function n(i){const a=Sn(t);if(!i?.optional&&!a)throw new Error(`This component must be used within ${e}.`);return a}return n}function VC(t,e){function n(a){const o=t(a);return o?o[e]:null}function i(a){let o=!1,u;typeof a=="function"?u=a:a&&typeof a=="object"&&(o=!!a.optional,u=a.selector);const d=n({optional:o});return d?u?d(u):d():null}return{[e]:i,[`${e}Store`]:n}}const $C=Qt(null),Gz=$z($C,"ThreadPrimitive.Viewport"),{useThreadViewport:Hi,useThreadViewportStore:Dr}=VC(Gz,"useThreadViewport"),v1=t=>{let e;const n=new Set,i=(p,m)=>{const y=typeof p=="function"?p(e):p;if(!Object.is(y,e)){const v=e;e=m??(typeof y!="object"||y===null)?y:Object.assign({},e,y),n.forEach(b=>b(e,v))}},a=()=>e,d={setState:i,getState:a,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p))},f=e=t(i,a,d);return d},Fz=(t=>t?v1(t):v1),Yz=t=>t;function Qz(t,e=Yz){const n=Jn.useSyncExternalStore(t.subscribe,Jn.useCallback(()=>e(t.getState()),[t,e]),Jn.useCallback(()=>e(t.getInitialState()),[t,e]));return Jn.useDebugValue(n),n}const b1=t=>{const e=Fz(t),n=i=>Qz(e,i);return Object.assign(n,e),n},GC=(t=>t?b1(t):b1),_1=t=>{const e=new Map,n=()=>{let i=0;for(const a of e.values())i+=a;t(i)};return{register:()=>{const i=Symbol();return e.set(i,0),{setHeight:a=>{e.get(i)!==a&&(e.set(i,a),n())},unregister:()=>{e.delete(i),n()}}}}},Kz=(t={})=>{const e=new Set,n=_1(u=>{o.setState({height:{...o.getState().height,viewport:u}})}),i=_1(u=>{o.setState({height:{...o.getState().height,inset:u}})}),a=(u,d)=>(o.setState({element:{...o.getState().element,[u]:d}}),()=>{o.getState().element[u]===d&&o.setState({element:{...o.getState().element,[u]:null}})}),o=GC(()=>({isAtBottom:!0,scrollToBottom:({behavior:u="auto"}={})=>{Wn(e,()=>({behavior:u}),"Thread viewport")},onScrollToBottom:u=>(e.add(u),()=>{e.delete(u)}),turnAnchor:t.turnAnchor??"bottom",topAnchorMessageClamp:{tallerThan:t.topAnchorMessageClamp?.tallerThan??"10em",visibleHeight:t.topAnchorMessageClamp?.visibleHeight??"6em"},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:i.register,registerViewportElement:u=>a("viewport",u),registerAnchorElement:u=>a("anchor",u),registerAnchorTargetElement:(u,d)=>(o.setState({element:{...o.getState().element,target:u},targetConfig:u&&d?d:null}),()=>{o.getState().element.target===u&&o.setState({element:{...o.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:u=>{o.setState({topAnchorTurn:u})}}));return o},Yc=t=>t,Xz=t=>{const e=Q(11);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={optional:!0},e[0]=n):n=e[0];const i=Dr(n);let a;e[1]!==t?(a=()=>Kz(t),e[1]=t,e[2]=a):a=e[2];const[o]=Ne(a);let u,d;e[3]!==i||e[4]!==o?(u=()=>i?.getState().onScrollToBottom(m=>{o.getState().scrollToBottom(m)}),d=[i,o],e[3]=i,e[4]=o,e[5]=u,e[6]=d):(u=e[5],d=e[6]),Ce(u,d);let f,p;return e[7]!==i||e[8]!==o?(f=()=>{if(i)return o.subscribe(m=>{i.getState().isAtBottom!==m.isAtBottom&&Yc(i).setState({isAtBottom:m.isAtBottom})})},p=[o,i],e[7]=i,e[8]=o,e[9]=f,e[10]=p):(f=e[9],p=e[10]),Ce(f,p),o},zg=t=>{const e=Q(7),{children:n,options:i}=t;let a;e[0]!==i?(a=i===void 0?{}:i,e[0]=i,e[1]=a):a=e[1];const o=Xz(a);let u;e[2]!==o?(u=()=>({useThreadViewport:o}),e[2]=o,e[3]=u):u=e[3];const[d]=Ne(u);let f;return e[4]!==n||e[5]!==d?(f=_.jsx($C.Provider,{value:d,children:n}),e[4]=n,e[5]=d,e[6]=f):f=e[6],f},Jz=()=>{const t=Q(3),e=ke();let n,i;return t[0]!==e?(n=()=>{},i=[e],t[0]=e,t[1]=n,t[2]=i):(n=t[1],i=t[2]),Ce(n,i),null},Zz=t=>{const e=Q(8),{children:n,aui:i,config:a,runtime:o}=t,u=i??null;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(Jz,{}),e[0]=d):d=e[0];let f;e[1]!==n?(f=_.jsx(zg,{children:n}),e[1]=n,e[2]=f):f=e[2];let p;return e[3]!==a||e[4]!==o||e[5]!==u||e[6]!==f?(p=_.jsxs($O,{runtime:o,aui:u,config:a,children:[d,f]}),e[3]=a,e[4]=o,e[5]=u,e[6]=f,e[7]=p):p=e[7],p},Wz=Nt(Zz),eP=()=>me(tP);function tP(t){return t.message.role==="assistant"?t.message.metadata?.timing:void 0}const Zs=typeof globalThis.window<"u"?mw:Ce,nP=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,FC={serialize(t){const e=t.id!==t.label?`{name=${t.id}}`:"";return`:${t.type}[${t.label}]${e}`},parse(t){const e=[];let n=0;for(const i of t.matchAll(nP)){i.index>n&&e.push({kind:"text",text:t.slice(n,i.index)});const a=i[2];e.push({kind:"mention",type:i[1],label:a,id:i[3]??a}),n=i.index+i[0].length}return n<t.length&&e.push({kind:"text",text:t.slice(n)}),e}};var sP=YT(),iP=Object.defineProperty,Pg=(t,e)=>iP(t,"name",{value:e,configurable:!0});function _m(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Pg(_m,"setRef");function YC(...t){return e=>{let n=!1;const i=t.map(a=>{const o=_m(a,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a<i.length;a++){const o=i[a];typeof o=="function"?o():_m(t[a],null)}}}}Pg(YC,"composeRefs");function ai(...t){return se.useCallback(YC(...t),t)}Pg(ai,"useComposedRefs");var rP=Object.defineProperty,Bn=(t,e)=>rP(t,"name",{value:e,configurable:!0});function Bg(t){const e=se.forwardRef((n,i)=>{let{children:a,...o}=n,u=null,d=!1;const f=[];a=WC(a),se.Children.forEach(a,v=>{if(JC(v)){d=!0;const b=v;let T="child"in b.props?b.props.child:b.props.children;for(;Lg(T)&&typeof Qc=="function";)T=Qc(T._payload);u=oP(b,T),f.push(u?.props?.children)}else f.push(v)}),u?u=se.cloneElement(u,void 0,f):!d&&se.Children.count(a)===1&&se.isValidElement(a)&&(u=a);const p=u?XC(u):void 0,m=ai(i,p);if(!u){if(a||a===0)throw new Error(d?cP(t):uP(t));return a}const y=KC(o,u.props??{});return u.type!==se.Fragment&&(y.ref=i?m:p),se.cloneElement(u,y)});return e.displayName=`${t}.Slot`,e}Bn(Bg,"createSlot");var Ug=Bg("Slot"),QC=Symbol.for("radix.slottable");function aP(t){const e=Bn(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=QC,e}Bn(aP,"createSlottable");var oP=Bn((t,e)=>"child"in t.props?se.isValidElement(e)?se.cloneElement(e,void 0,t.props.children(e.props.children)):null:se.isValidElement(e)?e:null,"getSlottableElementFromSlottable");function KC(t,e){const n={...e};for(const i in e){const a=t[i],o=e[i];/^on[A-Z]/.test(i)?a&&o?n[i]=(...d)=>{const f=o(...d);return a(...d),f}:a&&(n[i]=a):i==="style"?n[i]={...a,...o}:i==="className"?n[i]=[a,o].filter(Boolean).join(" "):i==="aria-describedby"&&(n[i]=eE(o,a))}return{...t,...n}}Bn(KC,"mergeProps");function XC(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Bn(XC,"getElementRef");function JC(t){return se.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===QC}Bn(JC,"isSlottable");var lP=Symbol.for("react.lazy");function Lg(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===lP&&"_payload"in t&&ZC(t._payload)}Bn(Lg,"isLazyComponent");function ZC(t){return typeof t=="object"&&t!==null&&"then"in t}Bn(ZC,"isPromiseLike");function WC(t){let e=t;for(;Lg(e)&&typeof Qc=="function";)e=Qc(e._payload);return e}Bn(WC,"useUnwrappedLazy");function eE(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const i of String(n).trim().split(/\s+/))i&&e.add(i);return e.size>0?Array.from(e).join(" "):void 0}Bn(eE,"concatAriaDescribedby");var uP=Bn(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),cP=Bn(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Qc=QT[" use ".trim().toString()],dP=Object.defineProperty,fP=(t,e)=>dP(t,"name",{value:e,configurable:!0}),hP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],tE=hP.reduce((t,e)=>{const n=Bg(`Primitive.${e}`),i=se.forwardRef((a,o)=>{const{asChild:u,...d}=a,f=u?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),_.jsx(f,{...d,ref:o})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function nE(t,e){t&&sP.flushSync(()=>t.dispatchEvent(e))}fP(nE,"dispatchDiscreteCustomEvent");var pP=globalThis?.document?se.useLayoutEffect:()=>{},mP=Object.defineProperty,Xa=(t,e)=>mP(t,"name",{value:e,configurable:!0}),sE=!!(typeof window<"u"&&window.document&&window.document.createElement);function dt(t,e,{checkForDefaultPrevented:n=!0}={}){return Xa(function(a){if(t?.(a),n===!1||!a||!a.defaultPrevented)return e?.(a)},"handleEvent")}Xa(dt,"composeEventHandlers");function gP(t){if(!sE)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}Xa(gP,"getOwnerWindow");function Sm(t){if(!sE)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}Xa(Sm,"getOwnerDocument");function iE(t,e=!1){const{activeElement:n}=Sm(t);if(!n?.nodeName)return null;if(rE(n)&&n.contentDocument)return iE(n.contentDocument.body,e);if(e){const i=n.getAttribute("aria-activedescendant");if(i){const a=Sm(n).getElementById(i);if(a)return a}}return n}Xa(iE,"getActiveElement");function rE(t){return t.tagName==="IFRAME"}Xa(rE,"isFrame");var yP=Object.defineProperty,vP=(t,e)=>yP(t,"name",{value:e,configurable:!0}),S1=QT[" useInsertionEffect ".trim().toString()];function ri(t){const e=se.useRef(t);return typeof S1=="function"?S1(()=>{e.current=t}):pP(()=>{e.current=t}),se.useMemo(()=>((...n)=>e.current?.(...n)),[])}vP(ri,"useCallbackRef");var bP=Object.defineProperty,aE=(t,e)=>bP(t,"name",{value:e,configurable:!0});function oE(t,e=globalThis?.document){const n=ri(t);se.useEffect(()=>{const i=aE(a=>{a.key==="Escape"&&n(a)},"handleKeyDown");return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[n,e])}aE(oE,"useEscapeKeydown");var qg=tE;qg.dispatchDiscreteCustomEvent=nE;qg.Root=tE;var T1=Object.defineProperty,Nl=(t,e)=>{let n={};for(var i in t)T1(n,i,{get:t[i],enumerable:!0});return T1(n,Symbol.toStringTag,{value:"Module"}),n};const _P=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"];function lE(t,e){return $M(t,void 0,e!==void 0?e:t.props.children)}function Hg(t,e,n){return _.jsx(Ug,{...n,children:lE(t,e)})}function SP(t){const e=et((n,i)=>{const a=Q(17);let o,u,d,f;a[0]!==n?({render:d,asChild:o,children:u,...f}=n,a[0]=n,a[1]=o,a[2]=u,a[3]=d,a[4]=f):(o=a[1],u=a[2],d=a[3],f=a[4]);const p=t;if(d&&od(d)){const v=f;let b;a[5]!==u||a[6]!==d?(b=lE(d,u),a[5]=u,a[6]=d,a[7]=b):b=a[7];let T;return a[8]!==i||a[9]!==v||a[10]!==b?(T=_.jsx(p,{...v,asChild:!0,ref:i,children:b}),a[8]=i,a[9]=v,a[10]=b,a[11]=T):T=a[11],T}const m=f;let y;return a[12]!==o||a[13]!==u||a[14]!==i||a[15]!==m?(y=_.jsx(p,{...m,asChild:o,ref:i,children:u}),a[12]=o,a[13]=u,a[14]=i,a[15]=m,a[16]=y):y=a[16],y});return e.displayName=typeof t=="string"?t:t.displayName??t.name??"Component",e}function TP(t){const e=qg[t],n=SP(e);return n.displayName=`Primitive.${t}`,n}const ht=_P.reduce((t,e)=>(t[e]=TP(e),t),{}),br={Hidden:"hidden",Floating:"floating",Normal:"normal"},wP=t=>{const e=Q(5),{hideWhenRunning:n,autohide:i,autohideFloat:a,forceVisible:o}=t;let u;return e[0]!==i||e[1]!==a||e[2]!==o||e[3]!==n?(u=d=>{if(n&&d.thread.isRunning)return br.Hidden;const f=i==="always"||i==="not-last"&&!d.message.isLast,p=o||d.message.isHovering;return f?p?a==="always"||a==="single-branch"&&d.message.branchCount<=1?br.Floating:br.Normal:br.Hidden:br.Normal},e[0]=i,e[1]=a,e[2]=o,e[3]=n,e[4]=u):u=e[4],me(u)},xP=Qt(null),uE=et((t,e)=>{const n=Q(18);let i,a,o,u;n[0]!==t?({hideWhenRunning:o,autohide:i,autohideFloat:a,...u}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u):(i=n[1],a=n[2],o=n[3],u=n[4]);const[d,f]=Ne(0);let p;n[5]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{let C=!1;return f(CP),()=>{C||(C=!0,f(EP))}},n[5]=p):p=n[5];const m=p;let y;n[6]===Symbol.for("react.memo_cache_sentinel")?(y={acquireInteractionLock:m},n[6]=y):y=n[6];const v=y,b=d>0;let T;n[7]!==i||n[8]!==a||n[9]!==o||n[10]!==b?(T={hideWhenRunning:o,autohide:i,autohideFloat:a,forceVisible:b},n[7]=i,n[8]=a,n[9]=o,n[10]=b,n[11]=T):T=n[11];const w=wP(T);if(w===br.Hidden)return null;let x;n[12]!==w?(x=w===br.Floating?{"data-floating":"true"}:null,n[12]=w,n[13]=x):x=n[13];let E;return n[14]!==e||n[15]!==u||n[16]!==x?(E=_.jsx(xP.Provider,{value:v,children:_.jsx(ht.div,{...x,...u,ref:e})}),n[14]=e,n[15]=u,n[16]=x,n[17]=E):E=n[17],E});uE.displayName="ActionBarPrimitive.Root";function CP(t){return t+1}function EP(t){return Math.max(0,t-1)}const AP=t=>{const e=Q(4);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const{copiedDuration:i}=n,a=i===void 0?3e3:i;let o;e[2]!==a?(o={copiedDuration:a,copyToClipboard:IP},e[2]=a,e[3]=o):o=e[3];const{copy:u,disabled:d}=mz(o);return d?null:u},cE=et((t,e)=>{const n=Q(20);let i,a,o,u;n[0]!==t?({copiedDuration:i,onClick:o,disabled:a,...u}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u):(i=n[1],a=n[2],o=n[3],u=n[4]);const d=me(RP);let f;n[5]!==i?(f={copiedDuration:i},n[5]=i,n[6]=f):f=n[6];const p=AP(f);let m;n[7]!==d?(m=d?{"data-copied":"true"}:{},n[7]=d,n[8]=m):m=n[8];const y=a||!p;let v;n[9]!==p?(v=()=>{p?.()},n[9]=p,n[10]=v):v=n[10];let b;n[11]!==o||n[12]!==v?(b=dt(o,v),n[11]=o,n[12]=v,n[13]=b):b=n[13];let T;return n[14]!==e||n[15]!==u||n[16]!==m||n[17]!==y||n[18]!==b?(T=_.jsx(ht.button,{type:"button",...m,...u,ref:e,disabled:y,onClick:b}),n[14]=e,n[15]=u,n[16]=m,n[17]=y,n[18]=b,n[19]=T):T=n[19],T});cE.displayName="ActionBarPrimitive.Copy";function IP(t){return typeof navigator>"u"||!navigator.clipboard?Promise.reject(new Error("Clipboard API is unavailable")):navigator.clipboard.writeText(t)}function RP(t){return t.message.isCopied}const ps=(t,e,n=[])=>{const i=et((a,o)=>{const u=Q(6),d={},f={};Object.keys(a).forEach(w=>{n.includes(w)?d[w]=a[w]:f[w]=a[w]});const p=e(d)??void 0,m=ht,y="button",v=f.disabled||!p,b=dt(f.onClick,p);let T;return u[0]!==o||u[1]!==f||u[2]!==m.button||u[3]!==v||u[4]!==b?(T=_.jsx(m.button,{type:y,...f,ref:o,disabled:v,onClick:b}),u[0]=o,u[1]=f,u[2]=m.button,u[3]=v,u[4]=b,u[5]=T):T=u[5],T});return i.displayName=t,i},MP=()=>{const{disabled:t,reload:e}=Tz();return t?null:e},kP=ps("ActionBarPrimitive.Reload",MP),NP=()=>{const{disabled:t,edit:e}=Sz();return t?null:e},OP=ps("ActionBarPrimitive.Edit",NP),DP=()=>{const{disabled:t,speak:e}=Az();return t?null:e},jP=ps("ActionBarPrimitive.Speak",DP),zP=()=>{const{disabled:t,stopSpeaking:e}=Iz();return t?null:e},dE=et((t,e)=>{const n=Q(10),i=zP(),a=!i;let o;n[0]!==i?(o=()=>{i?.()},n[0]=i,n[1]=o):o=n[1];let u;n[2]!==t.onClick||n[3]!==o?(u=dt(t.onClick,o),n[2]=t.onClick,n[3]=o,n[4]=u):u=n[4];let d;return n[5]!==t||n[6]!==e||n[7]!==a||n[8]!==u?(d=_.jsx(ht.button,{type:"button",disabled:a,...t,ref:e,onClick:u}),n[5]=t,n[6]=e,n[7]=a,n[8]=u,n[9]=d):d=n[9],d});dE.displayName="ActionBarPrimitive.StopSpeaking";const PP=()=>{const{submit:t}=wz();return t},fE=et((t,e)=>{const n=Q(18);let i,a,o;n[0]!==t?({onClick:a,disabled:i,...o}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o):(i=n[1],a=n[2],o=n[3]);const u=me(BP),d=PP();let f;n[4]!==u?(f=u?{"data-submitted":"true"}:{},n[4]=u,n[5]=f):f=n[5];const p=i||!d;let m;n[6]!==d?(m=()=>{d?.()},n[6]=d,n[7]=m):m=n[7];let y;n[8]!==a||n[9]!==m?(y=dt(a,m),n[8]=a,n[9]=m,n[10]=y):y=n[10];let v;return n[11]!==e||n[12]!==u||n[13]!==o||n[14]!==f||n[15]!==p||n[16]!==y?(v=_.jsx(ht.button,{type:"button","aria-pressed":u,...f,...o,ref:e,disabled:p,onClick:y}),n[11]=e,n[12]=u,n[13]=o,n[14]=f,n[15]=p,n[16]=y,n[17]=v):v=n[17],v});fE.displayName="ActionBarPrimitive.FeedbackPositive";function BP(t){return t.message.metadata.submittedFeedback?.type==="positive"}const UP=()=>{const{submit:t}=xz();return t},hE=et((t,e)=>{const n=Q(18);let i,a,o;n[0]!==t?({onClick:a,disabled:i,...o}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o):(i=n[1],a=n[2],o=n[3]);const u=me(LP),d=UP();let f;n[4]!==u?(f=u?{"data-submitted":"true"}:{},n[4]=u,n[5]=f):f=n[5];const p=i||!d;let m;n[6]!==d?(m=()=>{d?.()},n[6]=d,n[7]=m):m=n[7];let y;n[8]!==a||n[9]!==m?(y=dt(a,m),n[8]=a,n[9]=m,n[10]=y):y=n[10];let v;return n[11]!==e||n[12]!==u||n[13]!==o||n[14]!==f||n[15]!==p||n[16]!==y?(v=_.jsx(ht.button,{type:"button","aria-pressed":u,...f,...o,ref:e,disabled:p,onClick:y}),n[11]=e,n[12]=u,n[13]=o,n[14]=f,n[15]=p,n[16]=y,n[17]=v):v=n[17],v});hE.displayName="ActionBarPrimitive.FeedbackNegative";function LP(t){return t.message.metadata.submittedFeedback?.type==="negative"}const qP=t=>{const e=Q(6);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const{filename:i,onExport:a}=n,o=ke(),u=me(VP);let d;e[2]!==o.message||e[3]!==i||e[4]!==a?(d=async()=>{const p=o.message.getCopyText();if(!p)return;if(a){await a(p);return}const m=new Blob([p],{type:"text/markdown"}),y=URL.createObjectURL(m),v=document.createElement("a");v.href=y,v.download=i??`message-${Date.now()}.md`,v.rel="noopener",document.body.appendChild(v),v.click(),document.body.removeChild(v),setTimeout(()=>URL.revokeObjectURL(y),4e4)},e[2]=o.message,e[3]=i,e[4]=a,e[5]=d):d=e[5];const f=d;return u?f:null},pE=et((t,e)=>{const n=Q(19);let i,a,o,u,d;n[0]!==t?({filename:a,onExport:u,onClick:o,disabled:i,...d}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u,n[5]=d):(i=n[1],a=n[2],o=n[3],u=n[4],d=n[5]);let f;n[6]!==a||n[7]!==u?(f={filename:a,onExport:u},n[6]=a,n[7]=u,n[8]=f):f=n[8];const p=qP(f),m=i||!p;let y;n[9]!==p?(y=()=>{p?.().catch($P)},n[9]=p,n[10]=y):y=n[10];let v;n[11]!==o||n[12]!==y?(v=dt(o,y),n[11]=o,n[12]=y,n[13]=v):v=n[13];let b;return n[14]!==e||n[15]!==d||n[16]!==m||n[17]!==v?(b=_.jsx(ht.button,{type:"button",...d,ref:e,disabled:m,onClick:v}),n[14]=e,n[15]=d,n[16]=m,n[17]=v,n[18]=b):b=n[18],b});pE.displayName="ActionBarPrimitive.ExportMarkdown";function HP(t){return t.type==="text"&&t.text.length>0}function VP(t){return(t.message.role!=="assistant"||t.message.status?.type!=="running")&&t.message.parts.some(HP)}function $P(t){console.error("[assistant-ui] markdown export failed:",t)}var _r=Nl({Copy:()=>cE,Edit:()=>OP,ExportMarkdown:()=>pE,FeedbackNegative:()=>hE,FeedbackPositive:()=>fE,Reload:()=>kP,Root:()=>uE,Speak:()=>jP,StopSpeaking:()=>dE});const mE=Qt(null),md=()=>Sn(mE),GP=t=>{const e=Q(8),{children:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,e[0]=i):i=e[0];const a=we(i);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[1]=o):o=e[1];const u=we(o);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const x=Array.from(a.current.entries());x.sort(FP),u.current=x.map(YP)},e[2]=d):d=e[2];const f=d;let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=(x,E)=>{const C=E?.priority??0;return a.current.set(x,C),f(),()=>{a.current.delete(x),f()}},e[3]=p):p=e[3];const m=p;let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=()=>u.current,e[4]=y):y=e[4];const v=y;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b={register:m,getPlugins:v},e[5]=b):b=e[5];const T=b;let w;return e[6]!==n?(w=_.jsx(mE.Provider,{value:T,children:n}),e[6]=n,e[7]=w):w=e[7],w};function FP(t,e){return e[1]-t[1]}function YP(t){const[e]=t;return e}const Vg=Qt(null),gE=Qt(null),$g=()=>{const t=Sn(Vg);if(!t)throw new Error("useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot");return t},Gg=()=>Sn(Vg),QP=()=>{const t=Sn(gE);if(!t)throw new Error("useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot");return t},KP=()=>{const t=$g();return Ui(t.subscribe,t.getTriggers,t.getTriggers)},XP=new Map,yE=()=>()=>{},w1=()=>XP,JP=()=>{const t=Gg();return Ui(t?t.subscribe:yE,t?t.getTriggers:w1,t?t.getTriggers:w1)},x1=()=>null,ZP=()=>{const t=Gg();return Ui(t?t.subscribeAria:yE,t?t.getActiveAria:x1,t?t.getActiveAria:x1)};function C1(){const t=Q(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Set,t[0]=e):e=t[0];const n=we(e);let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{for(const f of n.current)f()},t[1]=i):i=t[1];const a=i;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=f=>(n.current.add(f),()=>{n.current.delete(f)}),t[2]=o):o=t[2];const u=o;let d;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d={notify:a,subscribe:u},t[3]=d):d=t[3],d}const E1=t=>{const e=Q(21),{children:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,e[0]=i):i=e[0];const a=we(i);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[1]=o):o=e[1];const u=we(o),{notify:d,subscribe:f}=C1();let p;e[2]!==d?(p=W=>{const{char:X}=W;if(a.current.has(X))return WP;const Z=new Map(a.current);Z.set(X,W),a.current=Z,d();for(const ee of u.current)ee.added(W);return()=>{const ee=new Map(a.current);ee.delete(X),a.current=ee,d();for(const oe of u.current)oe.removed(X)}},e[2]=d,e[3]=p):p=e[3];const m=p;let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=()=>a.current,e[4]=y):y=e[4];const v=y;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=W=>(u.current.add(W),()=>{u.current.delete(W)}),e[5]=b):b=e[5];const T=b,w=we(null),x=we(null),{notify:E,subscribe:C}=C1();let R;e[6]!==E?(R=(W,X)=>{if(X===null){if(x.current!==W)return;w.current=null,x.current=null,E();return}const Z=w.current;x.current===W&&Z!==null&&Z.popoverId===X.popoverId&&Z.highlightedItemId===X.highlightedItemId||(w.current=X,x.current=W,E())},e[6]=E,e[7]=R):R=e[7];const O=R;let L;e[8]===Symbol.for("react.memo_cache_sentinel")?(L=()=>w.current,e[8]=L):L=e[8];const I=L;let P;e[9]!==m||e[10]!==f||e[11]!==C?(P={register:m,getTriggers:v,subscribe:f,subscribeLifecycle:T,getActiveAria:I,subscribeAria:C},e[9]=m,e[10]=f,e[11]=C,e[12]=P):P=e[12];const k=P;let H;e[13]!==O?(H={setActiveAria:O},e[13]=O,e[14]=H):H=e[14];const V=H;let z;e[15]!==V||e[16]!==n?(z=_.jsx(gE.Provider,{value:V,children:n}),e[15]=V,e[16]=n,e[17]=z):z=e[17];let q;return e[18]!==z||e[19]!==k?(q=_.jsx(Vg.Provider,{value:k,children:z}),e[18]=z,e[19]=k,e[20]=q):q=e[20],q},Tm=t=>{const e=Q(4),{children:n}=t;if(md()){let a;return e[0]!==n?(a=_.jsx(E1,{children:n}),e[0]=n,e[1]=a):a=e[1],a}let i;return e[2]!==n?(i=_.jsx(GP,{children:_.jsx(E1,{children:n})}),e[2]=n,e[3]=i):i=e[3],i};Tm.displayName="ComposerPrimitive.TriggerPopoverRoot";function WP(){}const A1=/\s/u;function eB(t,e,n,i){if(i===null)return null;const{query:a,offset:o,endOffset:u}=i;return o<0||o+e.length>n||!t.startsWith(e,o)||u<o+e.length||u>t.length?null:{query:a,offset:o,endOffset:u}}function tB(t,e,n,i){if(i)return eB(t,e,n,i(t,e,n));const a=t.slice(0,n);for(let o=a.length-1;o>=0;o--){const u=a[o];if(A1.test(u))return null;if(a.startsWith(e,o)){if(o>0&&!A1.test(a[o-1]))continue;return{query:a.slice(o+e.length),offset:o,endOffset:n}}}return null}const nB=t=>{const e=Q(8),{text:n,triggerChar:i,matcher:a}=t,[o,u]=Ne(n.length),d=Math.min(o,n.length);let f;e[0]!==a||e[1]!==d||e[2]!==n||e[3]!==i?(f=tB(n,i,d,a),e[0]=a,e[1]=d,e[2]=n,e[3]=i,e[4]=f):f=e[4];const p=f,m=p?.query??"";let y;return e[5]!==m||e[6]!==p?(y={trigger:p,query:m,setCursorPosition:u},e[5]=m,e[6]=p,e[7]=y):y=e[7],y},sB=Ye(nB);function iB(t){return"type"in t}const rB=t=>{const e=Q(22),{navigableList:n,isSearchMode:i,activeCategoryId:a,query:o,popoverId:u,open:d,selectItem:f,selectCategory:p,goBack:m,close:y}=t,[v,b]=Ne(0);let T;e[0]!==a||e[1]!==i||e[2]!==n?(T={navigableList:n,isSearchMode:i,activeCategoryId:a},e[0]=a,e[1]=i,e[2]=n,e[3]=T):T=e[3];const[w,x]=Ne(T);(w.navigableList!==n||w.isSearchMode!==i||w.activeCategoryId!==a)&&(x({navigableList:n,isSearchMode:i,activeCategoryId:a}),b(0));let E;e[4]!==v||e[5]!==n.length?(E=k=>{k<0||k>=n.length||k!==v&&b(k)},e[4]=v,e[5]=n.length,e[6]=E):E=e[6];const C=bn(E);let R;e[7]!==a||e[8]!==y||e[9]!==m||e[10]!==v||e[11]!==n||e[12]!==d||e[13]!==o||e[14]!==p||e[15]!==f?(R=k=>{if(!d)return!1;switch(k.key){case"ArrowDown":return k.preventDefault(),b(H=>{const V=n.length;return V===0?0:H<V-1?H+1:0}),!0;case"ArrowUp":return k.preventDefault(),b(H=>{const V=n.length;return V===0?0:H>0?H-1:V-1}),!0;case"Enter":case"Tab":{if(k.shiftKey)return!1;k.preventDefault();const H=n[v];return H&&(iB(H)?f(H):p(H.id)),!0}case"Escape":return k.preventDefault(),y(),!0;case"Backspace":return a&&o===""?(k.preventDefault(),m(),!0):!1;default:return!1}},e[7]=a,e[8]=y,e[9]=m,e[10]=v,e[11]=n,e[12]=d,e[13]=o,e[14]=p,e[15]=f,e[16]=R):R=e[16];const O=bn(R),L=n[v],I=d&&L?`${u}-option-${L.id}`:void 0;let P;return e[17]!==O||e[18]!==C||e[19]!==v||e[20]!==I?(P={highlightedIndex:v,highlightedItemId:I,highlightIndex:C,handleKeyDown:O},e[17]=O,e[18]=C,e[19]=v,e[20]=I,e[21]=P):P=e[21],P},aB=Ye(rB);function I1(t,e){return e?t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||(t.description?.toLowerCase().includes(e)??!1):!0}const oB=t=>{const e=Q(35),{adapter:n,query:i,open:a}=t,[o,u]=Ne(null),[d,f]=Ne(a);d!==a&&(f(a),a||u(null));let p;e:{if(!a||!n){let W;e[0]===Symbol.for("react.memo_cache_sentinel")?(W=[],e[0]=W):W=e[0],p=W;break e}let q;e[1]!==n?(q=n.categories(),e[1]=n,e[2]=q):q=e[2],p=q}const m=p,y=a?o:null;let v;e:{if(!y||!n){let W;e[3]===Symbol.for("react.memo_cache_sentinel")?(W=[],e[3]=W):W=e[3],v=W;break e}let q;e[4]!==n||e[5]!==y?(q=n.categoryItems(y),e[4]=n,e[5]=y,e[6]=q):q=e[6],v=q}const b=v;let T;e:{if(!a||!n||y){T=null;break e}if(!i&&m.length>0){T=null;break e}if(n.search){let W;e[7]!==n||e[8]!==i?(W=n.search(i),e[7]=n,e[8]=i,e[9]=W):W=e[9],T=W;break e}let q;if(e[10]!==n||e[11]!==m||e[12]!==i){q=[];const W=i.toLowerCase();for(const X of m)for(const Z of n.categoryItems(X.id))I1(Z,W)&&q.push(Z);e[10]=n,e[11]=m,e[12]=i,e[13]=q}else q=e[13];T=q}const w=T,x=w!==null;let E;e:{if(x){let W;e[14]===Symbol.for("react.memo_cache_sentinel")?(W=[],e[14]=W):W=e[14],E=W;break e}if(!i){E=m;break e}let q;if(e[15]!==m||e[16]!==i){const W=i.toLowerCase();q=m.filter(X=>X.label.toLowerCase().includes(W)),e[15]=m,e[16]=i,e[17]=q}else q=e[17];E=q}const C=E;let R;e:{if(x){let W;e[18]!==w?(W=w??[],e[18]=w,e[19]=W):W=e[19],R=W;break e}if(!i){R=b;break e}let q;if(e[20]!==b||e[21]!==i){const W=i.toLowerCase();q=b.filter(X=>I1(X,W)),e[20]=b,e[21]=i,e[22]=q}else q=e[22];R=q}const O=R;let L;e:{if(x){let q;e[23]!==w?(q=w??[],e[23]=w,e[24]=q):q=e[24],L=q;break e}if(y){L=O;break e}L=C}const I=L;let P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=q=>{u(q)},e[25]=P):P=e[25];const k=bn(P);let H;e[26]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{u(null)},e[26]=H):H=e[26];const V=bn(H);let z;return e[27]!==y||e[28]!==C||e[29]!==O||e[30]!==V||e[31]!==x||e[32]!==I||e[33]!==k?(z={categories:C,items:O,isSearchMode:x,activeCategoryId:y,navigableList:I,selectCategory:k,goBack:V},e[27]=y,e[28]=C,e[29]=O,e[30]=V,e[31]=x,e[32]=I,e[33]=k,e[34]=z):z=e[34],z},lB=Ye(oB),uB=t=>{const e=Q(15),{behavior:n,trigger:i,aui:a,setCursorPosition:o,onSelected:u}=t,d=we(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=w=>(d.current=w,()=>{d.current===w&&(d.current=null)}),e[0]=f):f=e[0];const p=bn(f);let m;e[1]!==a||e[2]!==n||e[3]!==u||e[4]!==o||e[5]!==i?(m=w=>{if(!i||!n)return;if(d.current?.(w)){u();return}const x=a.composer.getState().text,E=x.slice(0,i.offset),C=x.slice(i.endOffset),R=()=>{const O=n.formatter.serialize(w);a.composer.setText(E+O+(C.startsWith(" ")?C:` ${C}`)),o(E.length+O.length+1)};n.kind==="directive"?(R(),n.onInserted?.(w)):(n.removeOnExecute?(a.composer.setText(E+(C.startsWith(" ")?C.slice(1):C)),o(E.length)):R(),n.onExecute(w)),u()},e[1]=a,e[2]=n,e[3]=u,e[4]=o,e[5]=i,e[6]=m):m=e[6];const y=bn(m);let v;e[7]!==u||e[8]!==o||e[9]!==i?(v=()=>{u(),i&&o(i.offset)},e[7]=u,e[8]=o,e[9]=i,e[10]=v):v=e[10];const b=bn(v);let T;return e[11]!==b||e[12]!==p||e[13]!==y?(T={selectItem:y,close:b,registerSelectItemOverride:p},e[11]=b,e[12]=p,e[13]=y,e[14]=T):T=e[14],T},cB=Ye(uB),dB=t=>{const e=Q(47),{adapter:n,text:i,triggerChar:a,matcher:o,behavior:u,aui:d,popoverId:f,isLoading:p}=t;let m;e[0]!==o||e[1]!==i||e[2]!==a?(m=sB({text:i,triggerChar:a,matcher:o}),e[0]=o,e[1]=i,e[2]=a,e[3]=m):m=e[3];const y=Dn(m),v=y.trigger!==null&&n!==void 0&&u!==void 0;let b;e[4]!==n||e[5]!==y.query||e[6]!==v?(b=lB({adapter:n,query:y.query,open:v}),e[4]=n,e[5]=y.query,e[6]=v,e[7]=b):b=e[7];const T=Dn(b);let w;e[8]!==T?(w=()=>{T.goBack()},e[8]=T,e[9]=w):w=e[9];const x=bn(w);let E;e[10]!==d||e[11]!==u||e[12]!==y.setCursorPosition||e[13]!==y.trigger||e[14]!==x||e[15]!==a?(E=cB({behavior:u,trigger:y.trigger,aui:d,triggerChar:a,setCursorPosition:y.setCursorPosition,onSelected:x}),e[10]=d,e[11]=u,e[12]=y.setCursorPosition,e[13]=y.trigger,e[14]=x,e[15]=a,e[16]=E):E=e[16];const C=Dn(E);let R;e[17]!==y.query||e[18]!==T.activeCategoryId||e[19]!==T.goBack||e[20]!==T.isSearchMode||e[21]!==T.navigableList||e[22]!==T.selectCategory||e[23]!==v||e[24]!==f||e[25]!==C.close||e[26]!==C.selectItem?(R=aB({navigableList:T.navigableList,isSearchMode:T.isSearchMode,activeCategoryId:T.activeCategoryId,query:y.query,popoverId:f,open:v,selectItem:C.selectItem,selectCategory:T.selectCategory,goBack:T.goBack,close:C.close}),e[17]=y.query,e[18]=T.activeCategoryId,e[19]=T.goBack,e[20]=T.isSearchMode,e[21]=T.navigableList,e[22]=T.selectCategory,e[23]=v,e[24]=f,e[25]=C.close,e[26]=C.selectItem,e[27]=R):R=e[27];const O=Dn(R);let L;return e[28]!==y.query||e[29]!==y.setCursorPosition||e[30]!==p||e[31]!==O.handleKeyDown||e[32]!==O.highlightIndex||e[33]!==O.highlightedIndex||e[34]!==O.highlightedItemId||e[35]!==T.activeCategoryId||e[36]!==T.categories||e[37]!==T.goBack||e[38]!==T.isSearchMode||e[39]!==T.items||e[40]!==T.selectCategory||e[41]!==v||e[42]!==f||e[43]!==C.close||e[44]!==C.registerSelectItemOverride||e[45]!==C.selectItem?(L={open:v,query:y.query,activeCategoryId:T.activeCategoryId,categories:T.categories,items:T.items,highlightedIndex:O.highlightedIndex,isSearchMode:T.isSearchMode,isLoading:p,popoverId:f,highlightedItemId:O.highlightedItemId,selectCategory:T.selectCategory,goBack:T.goBack,selectItem:C.selectItem,close:C.close,highlightIndex:O.highlightIndex,handleKeyDown:O.handleKeyDown,setCursorPosition:y.setCursorPosition,registerSelectItemOverride:C.registerSelectItemOverride},e[28]=y.query,e[29]=y.setCursorPosition,e[30]=p,e[31]=O.handleKeyDown,e[32]=O.highlightIndex,e[33]=O.highlightedIndex,e[34]=O.highlightedItemId,e[35]=T.activeCategoryId,e[36]=T.categories,e[37]=T.goBack,e[38]=T.isSearchMode,e[39]=T.items,e[40]=T.selectCategory,e[41]=v,e[42]=f,e[43]=C.close,e[44]=C.registerSelectItemOverride,e[45]=C.selectItem,e[46]=L):L=e[46],L},fB=Ye(dB),Fg=Qt(null),Ja=()=>{const t=Sn(Fg);if(!t)throw new Error("useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover");return t},hB=()=>Sn(Fg),vE=Qt(null),bE=()=>{const t=Sn(vE);if(!t)throw new Error("TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover");return t},_E=et((t,e)=>{const n=Q(70);let i,a,o,u,d,f,p;n[0]!==t?({char:o,matcher:d,adapter:i,isLoading:p,"aria-label":a,children:u,...f}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u,n[5]=d,n[6]=f,n[7]=p):(i=n[1],a=n[2],o=n[3],u=n[4],d=n[5],f=n[6],p=n[7]);const m=p===void 0?!1:p,y=ke(),v=me(pB),b=ad(),T=we(d);let w;n[8]!==d?(w=()=>{T.current=d},n[8]=d,n[9]=w):w=n[9],Ce(w);let x;n[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>(fe,ge,Oe)=>T.current(fe,ge,Oe),n[10]=x):x=n[10];const[E]=Ne(x),C=d!==void 0,R=we(null),[O,L]=Ne(null),I=we(0);let P;n[11]!==o?(P=fe=>(I.current=I.current+1,R.current=fe,L(fe),()=>{I.current=Math.max(0,I.current-1),R.current===fe&&(R.current=null,L(null))}),n[11]=o,n[12]=P):P=n[12];const k=P;let H;n[13]!==k?(H={register:k},n[13]=k,n[14]=H):H=n[14];const V=H,z=O??void 0;let q;n[15]!==i||n[16]!==y||n[17]!==o||n[18]!==m||n[19]!==d||n[20]!==b||n[21]!==z||n[22]!==v?(q=fB({adapter:i,text:v,triggerChar:o,matcher:d,behavior:z,aui:y,popoverId:b,isLoading:m}),n[15]=i,n[16]=y,n[17]=o,n[18]=m,n[19]=d,n[20]=b,n[21]=z,n[22]=v,n[23]=q):q=n[23];const W=Dn(q);let X;n[24]!==W?(X=()=>W,n[24]=W,n[25]=X):X=n[25];const Z=bn(X),ee=$g();let oe;n[26]!==O||n[27]!==o||n[28]!==Z||n[29]!==C||n[30]!==E||n[31]!==ee?(oe=()=>ee.register({char:o,...C?{matcher:E}:{},...O?{behavior:O}:{},resource:Z()}),n[26]=O,n[27]=o,n[28]=Z,n[29]=C,n[30]=E,n[31]=ee,n[32]=oe):oe=n[32];let he;n[33]!==O||n[34]!==o||n[35]!==C||n[36]!==E||n[37]!==ee?(he=[ee,o,C,E,O],n[33]=O,n[34]=o,n[35]=C,n[36]=E,n[37]=ee,n[38]=he):he=n[38],Ce(oe,he);const ye=md();let D;n[39]!==Z||n[40]!==ye?(D=()=>{if(ye)return ye.register(Z())},n[39]=Z,n[40]=ye,n[41]=D):D=n[41];let $;n[42]!==ye?($=[ye],n[42]=ye,n[43]=$):$=n[43],Ce(D,$);const re=O!==null&&W.open,M=QP();let N,te;n[44]!==M||n[45]!==o||n[46]!==re?(N=()=>{if(re)return()=>{M.setActiveAria(o,null)}},te=[M,o,re],n[44]=M,n[45]=o,n[46]=re,n[47]=N,n[48]=te):(N=n[47],te=n[48]),Ce(N,te);let ie,pe;n[49]!==M||n[50]!==o||n[51]!==re||n[52]!==b||n[53]!==W.highlightedItemId?(ie=()=>{re&&M.setActiveAria(o,{popoverId:b,highlightedItemId:W.highlightedItemId})},pe=[M,o,b,re,W.highlightedItemId],n[49]=M,n[50]=o,n[51]=re,n[52]=b,n[53]=W.highlightedItemId,n[54]=ie,n[55]=pe):(ie=n[54],pe=n[55]),Ce(ie,pe);let de;n[56]!==a||n[57]!==u||n[58]!==e||n[59]!==re||n[60]!==b||n[61]!==f||n[62]!==W.highlightedItemId?(de=re?_.jsx(ht.div,{role:"listbox",id:b,"aria-label":a??"Suggestions","aria-activedescendant":W.highlightedItemId,"data-state":"open",...f,ref:e,children:u}):u,n[56]=a,n[57]=u,n[58]=e,n[59]=re,n[60]=b,n[61]=f,n[62]=W.highlightedItemId,n[63]=de):de=n[63];let B;n[64]!==W||n[65]!==de?(B=_.jsx(Fg.Provider,{value:W,children:de}),n[64]=W,n[65]=de,n[66]=B):B=n[66];let ce;return n[67]!==V||n[68]!==B?(ce=_.jsx(vE.Provider,{value:V,children:B}),n[67]=V,n[68]=B,n[69]=ce):ce=n[69],ce});_E.displayName="ComposerPrimitive.TriggerPopover";function pB(t){return t.composer.text}const SE=()=>{const t=Q(2),{disabled:e,send:n}=uz();let i;t[0]!==n?(i=()=>n(),t[0]=n,t[1]=i):i=t[1];const a=i;return e?null:a},mB=ps("ComposerPrimitive.Send",SE),TE=Qt(null),gB=()=>Sn(TE),wE="[contenteditable]:not([contenteditable='false'])",xE=`textarea:not(:disabled), ${wE}`,yB=["a","audio[controls]","button","details","embed","iframe","input","label","select","summary","textarea","video[controls]",wE,"[tabindex]"].join(", "),vB=se.version.startsWith("18."),CE=et((t,e)=>{const n=Q(27);let i,a,o,u,d;n[0]!==t?({onSubmit:u,onMouseDown:o,compact:i,inert:a,...d}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u,n[5]=d):(i=n[1],a=n[2],o=n[3],u=n[4],d=n[5]);const f=SE(),p=me(bB),[m,y]=Ne(!1);let v;n[6]===Symbol.for("react.memo_cache_sentinel")?(v={setMultiline:y},n[6]=v):v=n[6];const b=v;let T;n[7]!==i?(T=z=>i?z.composer.attachments.length===0&&z.composer.quote==null&&z.composer.queue.length===0&&z.composer.dictation==null&&!z.composer.text.includes(`
17
- `):!1,n[7]=i,n[8]=T):T=n[8];const w=me(T)&&!m,x=vB&&typeof a=="boolean"?a?"":void 0:a;let E;n[9]!==f?(E=z=>{z.preventDefault(),f&&f()},n[9]=f,n[10]=E):E=n[10];const C=E,R=_B,O=i?b:null,L=x,I=w?"":void 0;let P;n[11]!==C||n[12]!==u?(P=dt(u,C),n[11]=C,n[12]=u,n[13]=P):P=n[13];let k;n[14]!==o?(k=dt(o,R),n[14]=o,n[15]=k):k=n[15];let H;n[16]!==p||n[17]!==e||n[18]!==d||n[19]!==L||n[20]!==I||n[21]!==P||n[22]!==k?(H=_.jsx(ht.form,{...d,inert:L,"data-aui-composer-type":p,"data-compact":I,ref:e,onSubmit:P,onMouseDown:k}),n[16]=p,n[17]=e,n[18]=d,n[19]=L,n[20]=I,n[21]=P,n[22]=k,n[23]=H):H=n[23];let V;return n[24]!==O||n[25]!==H?(V=_.jsx(TE.Provider,{value:O,children:H}),n[24]=O,n[25]=H,n[26]=V):V=n[26],V});CE.displayName="ComposerPrimitive.Root";function bB(t){return t.composer.type}function _B(t){if(t.button!==0)return;const e=t.target;if(!(e instanceof Element)||!t.currentTarget.contains(e))return;const n=e.closest(yB);if(n&&t.currentTarget.contains(n))return;const i=t.currentTarget.querySelector(xE);i&&(t.preventDefault(),i.focus())}const EE=t=>{const e=Q(4),n=ri(t),i=Hi(SB);let a,o;e[0]!==n||e[1]!==i?(a=()=>i(n),o=[i,n],e[0]=n,e[1]=i,e[2]=a,e[3]=o):(a=e[2],o=e[3]),Ce(a,o)};function SB(t){return t.onScrollToBottom}const TB=()=>!1,wB=()=>{},AE=t=>{const e=Q(4);let n;e[0]!==t?(n=o=>{if(typeof window>"u"||t===null||!window.matchMedia)return wB;const u=window.matchMedia(t);return u.addEventListener("change",o),()=>u.removeEventListener("change",o)},e[0]=t,e[1]=n):n=e[1];const i=n;let a;return e[2]!==t?(a=()=>typeof window>"u"||t===null||!window.matchMedia?!1:window.matchMedia(t).matches,e[2]=t,e[3]=a):a=e[3],Ui(i,a,TB)},wm=t=>t.isComposing||t.keyCode===229,IE=Qt(void 0),xB=()=>Sn(IE),R1="[data-aui-composer-type]",M1="[data-aui-thread-root]",RE=t=>{const e=Q(4),n=ke(),i=xB();let a;return e[0]!==n.composer||e[1]!==t||e[2]!==i?(a=o=>{const u=i?.current,d=o?.ownerDocument,f=d?.activeElement,p=o?.closest(R1),m=n.composer.getState().type==="edit"&&u&&f&&p?.getAttribute("data-aui-composer-type")==="edit"&&p.contains(f)&&p.closest(M1)===u,y=m?Array.from(u.querySelectorAll(xE)).filter(v=>v.closest(M1)===u&&v.closest(R1)?.getAttribute("data-aui-composer-type")==="thread"):[];if(t(),!(!d||!f||!m)&&!(d.activeElement!==f&&d.activeElement!==d.body)){for(const v of y)if(!(!v.isConnected||v.closest("[hidden], [inert]"))&&(v.focus({preventScroll:!0}),d.activeElement!==f&&d.activeElement!==d.body))break}},e[0]=n.composer,e[1]=t,e[2]=i,e[3]=a):a=e[3],a};function CB(){return me(EB)}function EB(t){return t.composer.isEditing?t.composer.text:""}function AB(t){return!!me(IB)||!!t}function IB(t){return t.thread.isDisabled||t.composer.dictation?.inputDisabled}function RB(){const t=Q(4),e=ZP();if(!e){let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i={},t[0]=i):i=t[0],i}let n;return t[1]!==e.highlightedItemId||t[2]!==e.popoverId?(n={"aria-controls":e.popoverId,"aria-expanded":!0,"aria-haspopup":"listbox","aria-activedescendant":e.highlightedItemId},t[1]=e.highlightedItemId,t[2]=e.popoverId,t[3]=n):n=t[3],n}function xm(){return xm=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},xm.apply(null,arguments)}function MB(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var kB=se.useLayoutEffect,NB=function(e){var n=Jn.useRef(e);return kB(function(){n.current=e}),n},k1=function(e,n){if(typeof e=="function"){e(n);return}e.current=n},OB=function(e,n){var i=Jn.useRef();return Jn.useCallback(function(a){e.current=a,i.current&&k1(i.current,null),i.current=n,n&&k1(n,a)},[n])},N1={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},DB=function(e){Object.keys(N1).forEach(function(n){e.style.setProperty(n,N1[n],"important")})},O1=DB,an=null,D1=function(e,n){var i=e.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?i+n.borderSize:i-n.paddingSize};function jB(t,e,n,i){n===void 0&&(n=1),i===void 0&&(i=1/0),an||(an=document.createElement("textarea"),an.setAttribute("tabindex","-1"),an.setAttribute("aria-hidden","true"),O1(an)),an.parentNode===null&&document.body.appendChild(an);var a=t.paddingSize,o=t.borderSize,u=t.sizingStyle,d=u.boxSizing;Object.keys(u).forEach(function(v){var b=v;an.style[b]=u[b]}),O1(an),an.value=e;var f=D1(an,t);an.value=e,f=D1(an,t),an.value="x";var p=an.scrollHeight-a,m=p*n;d==="border-box"&&(m=m+a+o),f=Math.max(m,f);var y=p*i;return d==="border-box"&&(y=y+a+o),f=Math.min(y,f),[f,p]}var j1=function(){},zB=function(e,n){return e.reduce(function(i,a){return i[a]=n[a],i},{})},PB=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],BB=!!document.documentElement.currentStyle,UB=function(e){var n=window.getComputedStyle(e);if(n===null)return null;var i=zB(PB,n),a=i.boxSizing;if(a==="")return null;BB&&a==="border-box"&&(i.width=parseFloat(i.width)+parseFloat(i.borderRightWidth)+parseFloat(i.borderLeftWidth)+parseFloat(i.paddingRight)+parseFloat(i.paddingLeft)+"px");var o=parseFloat(i.paddingBottom)+parseFloat(i.paddingTop),u=parseFloat(i.borderBottomWidth)+parseFloat(i.borderTopWidth);return{sizingStyle:i,paddingSize:o,borderSize:u}},LB=UB;function Yg(t,e,n){var i=NB(n);se.useLayoutEffect(function(){var a=function(u){return i.current(u)};if(t)return t.addEventListener(e,a),function(){return t.removeEventListener(e,a)}},[])}var qB=function(e,n){Yg(document.body,"reset",function(i){e.current.form===i.target&&n(i)})},HB=function(e){Yg(window,"resize",e)},VB=function(e){Yg(document.fonts,"loadingdone",e)},$B=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],GB=function(e,n){var i=e.cacheMeasurements,a=e.maxRows,o=e.minRows,u=e.onChange,d=u===void 0?j1:u,f=e.onHeightChange,p=f===void 0?j1:f,m=MB(e,$B),y=m.value!==void 0,v=se.useRef(null),b=OB(v,n),T=se.useRef(0),w=se.useRef(),x=function(){var R=v.current,O=i&&w.current?w.current:LB(R);if(O){w.current=O;var L=jB(O,R.value||R.placeholder||"x",o,a),I=L[0],P=L[1];T.current!==I&&(T.current=I,R.style.setProperty("height",I+"px","important"),p(I,{rowHeight:P}))}},E=function(R){y||x(),d(R)};return se.useLayoutEffect(x),qB(v,function(){if(!y){var C=v.current.value;requestAnimationFrame(function(){var R=v.current;R&&C!==R.value&&x()})}}),HB(x),VB(x),se.createElement("textarea",xm({},m,{onChange:E,ref:b}))},FB=se.forwardRef(GB);const YB="(pointer: coarse) and (not (any-pointer: fine))",ME=et(({autoFocus:t=!1,asChild:e,render:n,disabled:i,onChange:a,onKeyDown:o,onPaste:u,onSelect:d,submitOnEnter:f,submitMode:p,cancelOnEscape:m=!0,unstable_focusOnRunStart:y=!0,unstable_focusOnScrollToBottom:v=!0,unstable_focusOnThreadSwitched:b=!0,unstable_insertNewlineOnTouchEnter:T=!1,addAttachmentOnPaste:w=!0,onHeightChange:x,...E},C)=>{const R=ke(),O=md(),L=gB(),I=p??(f===!1?"none":"enter"),P=AE(T?YB:null),k=T&&P&&I==="enter"?"none":I,H=CB(),V=AB(i),z=we(null),q=RE(on(()=>R.composer.cancel(),[R])),W=ai(C,z),X=we(!1);oE(M=>{if(z.current?.contains(M.target)&&!wm(M)){if(O){for(const N of O.getPlugins())if(N.handleKeyDown(M))return}m&&R.composer.getState().canCancel&&(q(z.current),M.preventDefault())}});const Z=M=>{if(!V&&!wm(M.nativeEvent)){if(O){for(const N of O.getPlugins())if(N.handleKeyDown(M))return}if(M.key==="Enter"){const N=R.thread.getState(),te=N.capabilities.queue;if(M.shiftKey&&(M.ctrlKey||M.metaKey)&&te&&I!=="none"&&R.composer.getState().canSend){M.preventDefault(),R.composer.send({steer:!0});return}if(M.shiftKey||N.isRunning&&!te&&N.voice===void 0)return;let ie=!1;k==="ctrlEnter"?ie=M.ctrlKey||M.metaKey:k==="enter"&&(ie=!0),ie&&(M.preventDefault(),z.current?.closest("form")?.requestSubmit())}}},ee=async M=>{if(!w)return;const N=R.thread.getState().capabilities,te=Array.from(M.clipboardData?.files||[]);N.attachments&&te.length>0&&(M.preventDefault(),await Promise.all(te.map(async ie=>{try{await R.composer.addAttachment(ie)}catch{}})))},oe=(M,N)=>{if(x?.(M,N),!L)return;const te=z.current;if(!te||te.value==="")return;const ie=getComputedStyle(te),pe=ie.boxSizing==="border-box"?M-parseFloat(ie.paddingTop)-parseFloat(ie.paddingBottom)-parseFloat(ie.borderTopWidth)-parseFloat(ie.borderBottomWidth):M;Math.round(pe/N.rowHeight)>1&&L.setMultiline(!0)},he=t&&!V,ye=on(()=>{const M=z.current;!M||!he||(M.focus({preventScroll:!0}),M.setSelectionRange(M.value.length,M.value.length))},[he]);Ce(()=>ye(),[ye]),EE(()=>{R.composer.getState().type==="thread"&&v&&ye()}),Ce(()=>{if(!(R.composer.getState().type!=="thread"||!y))return R.on("thread.runStart",ye)},[y,ye,R]),Ce(()=>{if(!(R.composer.getState().type!=="thread"||!b))return R.on("threads.selectionChanged",ye)},[b,ye,R]),Ce(()=>{H===""&&L?.setMultiline(!1)},[H,L]);const D=RB(),$={name:"input",value:H,...E,...D,ref:W,disabled:V,onChange:dt(a,M=>{if(!R.composer.getState().isEditing)return;const N=M.nativeEvent.isComposing===!0;X.current&&!N&&(X.current=!1);const te=N||X.current;if(F0(()=>{R.composer.setText(M.target.value)}),te)return;const ie=M.target.selectionStart??M.target.value.length;if(O)for(const pe of O.getPlugins())pe.setCursorPosition(ie)}),onKeyDown:dt(o,Z),onCompositionStart:dt(E.onCompositionStart,()=>{X.current=!0}),onCompositionEnd:dt(E.onCompositionEnd,M=>{if(X.current=!1,!R.composer.getState().isEditing)return;const N=M.target;F0(()=>{R.composer.setText(N.value)});const te=N.selectionStart??N.value.length;if(O)for(const ie of O.getPlugins())ie.setCursorPosition(te)}),onSelect:dt(d,M=>{if(X.current)return;const N=M.target,te=N.selectionStart??N.value.length;if(O)for(const ie of O.getPlugins())ie.setCursorPosition(te)}),onPaste:dt(u,ee),...L?{onHeightChange:oe}:x!==void 0?{onHeightChange:x}:{}};if(n&&od(n))return Hg(n,E.children,$);const re=e?Ug:FB;return _.jsx(re,{...$})});ME.displayName="ComposerPrimitive.Input";const QB=()=>{const t=Q(2),{disabled:e,cancel:n}=cz(),i=RE(n);if(e)return null;let a;return t[0]!==i?(a=o=>i(o.detail===0?o.currentTarget:null),t[0]=i,t[1]=a):a=t[1],a},KB=ps("ComposerPrimitive.Cancel",QB),XB=t=>{const e=Q(6);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const{multiple:i}=n,a=i===void 0?!0:i,{disabled:o,addAttachment:u}=hz(),d=ke();let f;e[2]!==u||e[3]!==d.composer||e[4]!==a?(f=()=>{const m=document.createElement("input");m.type="file",m.multiple=a,m.hidden=!0;const y=d.composer.getState().attachmentAccept;y!=="*"&&(m.accept=y),document.body.appendChild(m),m.onchange=async v=>{const b=v.target.files;if(!b)return;const T=Array.from(b,async w=>{try{await u(w)}catch{}});document.body.removeChild(m),await Promise.all(T)},m.oncancel=()=>{(!m.files||m.files.length===0)&&document.body.removeChild(m)},m.click()},e[2]=u,e[3]=d.composer,e[4]=a,e[5]=f):f=e[5];const p=f;return o?null:p},JB=ps("ComposerPrimitive.AddAttachment",XB,["multiple"]),kE=et(({disabled:t,asChild:e=!1,render:n,children:i,...a},o)=>{const[u,d]=Ne(!1),f=ke(),p=me(E=>E.thread.isDisabled),m=t||p;Ce(()=>{m&&d(!1)},[m]);const y=on(E=>{if(E.dataTransfer.types.includes("Files")){if(E.preventDefault(),m||!f.thread.getState().capabilities.attachments){E.dataTransfer.dropEffect="none";return}d(!0)}},[m,f]),v=on(E=>{if(E.dataTransfer.types.includes("Files")){if(E.preventDefault(),m||!f.thread.getState().capabilities.attachments){E.dataTransfer.dropEffect="none";return}u||d(!0)}},[m,u,f]),b=on(E=>{if(m)return;E.preventDefault();const C=E.relatedTarget;C&&E.currentTarget.contains(C)||d(!1)},[m]),T=on(async E=>{if(d(!1),!E.dataTransfer.types.includes("Files")||(E.preventDefault(),m))return;const C=Array.from(E.dataTransfer.files);!f.thread.getState().capabilities.attachments||C.length===0||await Promise.all(C.map(async R=>{try{await f.composer.addAttachment(R)}catch{}}))},[m,f]),w={...u&&!m?{"data-dragging":"true"}:null,...a,onDragEnterCapture:dt(a.onDragEnterCapture,y),onDragOverCapture:dt(a.onDragOverCapture,v),onDragLeaveCapture:dt(a.onDragLeaveCapture,b),onDropCapture:dt(a.onDropCapture,T),ref:o};if(n&&od(n))return Hg(n,i,w);const x=e?Ug:"div";return _.jsx(x,{...w,children:i})});kE.displayName="ComposerPrimitive.AttachmentDropzone";const ZB=()=>{const{disabled:t,startDictation:e}=dz();return t?null:e},WB=ps("ComposerPrimitive.Dictate",ZB),eU=()=>{const t=Q(2),e=ke(),n=me(nU);let i;t[0]!==e.composer?(i=()=>{e.composer.stopDictation()},t[0]=e.composer,t[1]=i):i=t[1];const a=i;return n?a:null},tU=ps("ComposerPrimitive.StopDictation",eU);function nU(t){return t.composer.dictation!=null}const NE=et((t,e)=>{const n=Q(7);let i,a;n[0]!==t?({children:i,...a}=t,n[0]=t,n[1]=i,n[2]=a):(i=n[1],a=n[2]);const o=me(sU);if(!o)return null;const u=i??o;let d;return n[3]!==e||n[4]!==a||n[5]!==u?(d=_.jsx(ht.span,{...a,ref:e,children:u}),n[3]=e,n[4]=a,n[5]=u,n[6]=d):d=n[6],d});NE.displayName="ComposerPrimitive.DictationTranscript";function sU(t){return t.composer.dictation?.transcript}const OE=et((t,e)=>{const n=Q(3);if(!me(iU))return null;let i;return n[0]!==e||n[1]!==t?(i=_.jsx(ht.div,{...t,ref:e}),n[0]=e,n[1]=t,n[2]=i):i=n[2],i});OE.displayName="ComposerPrimitive.Quote";const DE=et((t,e)=>{const n=Q(7);let i,a;n[0]!==t?({children:i,...a}=t,n[0]=t,n[1]=i,n[2]=a):(i=n[1],a=n[2]);const o=me(rU);if(!o)return null;const u=i??o;let d;return n[3]!==e||n[4]!==a||n[5]!==u?(d=_.jsx(ht.span,{...a,ref:e,children:u}),n[3]=e,n[4]=a,n[5]=u,n[6]=d):d=n[6],d});DE.displayName="ComposerPrimitive.QuoteText";const jE=et((t,e)=>{const n=Q(12);let i,a;n[0]!==t?({onClick:i,...a}=t,n[0]=t,n[1]=i,n[2]=a):(i=n[1],a=n[2]);const o=ke();let u;n[3]!==o?(u=()=>{o.composer.setQuote(void 0)},n[3]=o,n[4]=u):u=n[4];const d=u;let f;n[5]!==d||n[6]!==i?(f=dt(i,d),n[5]=d,n[6]=i,n[7]=f):f=n[7];let p;return n[8]!==e||n[9]!==a||n[10]!==f?(p=_.jsx(ht.button,{type:"button",...a,ref:e,onClick:f}),n[8]=e,n[9]=a,n[10]=f,n[11]=p):p=n[11],p});jE.displayName="ComposerPrimitive.QuoteDismiss";function iU(t){return t.composer.quote}function rU(t){return t.composer.quote?.text}const Cm=et((t,e)=>{const n=Q(12);let i,a,o;n[0]!==t?({children:a,"aria-label":i,...o}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o):(i=n[1],a=n[2],o=n[3]);const{categories:u,activeCategoryId:d,isSearchMode:f,open:p}=Ja();if(!p||d||f)return null;const m=i??"Categories";let y;n[4]!==u||n[5]!==a?(y=a(u),n[4]=u,n[5]=a,n[6]=y):y=n[6];let v;return n[7]!==e||n[8]!==o||n[9]!==m||n[10]!==y?(v=_.jsx(ht.div,{role:"group","aria-label":m,...o,ref:e,children:y}),n[7]=e,n[8]=o,n[9]=m,n[10]=y,n[11]=v):v=n[11],v});Cm.displayName="ComposerPrimitive.TriggerPopoverCategories";const Em=et((t,e)=>{const n=Q(30);let i,a,o,u;n[0]!==t?({categoryId:i,onClick:a,onMouseMove:o,...u}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u):(i=n[1],a=n[2],o=n[3],u=n[4]);const{selectCategory:d,highlightIndex:f,categories:p,highlightedIndex:m,activeCategoryId:y,isSearchMode:v,popoverId:b}=Ja();let T;n[5]!==i||n[6]!==d?(T=()=>{d(i)},n[5]=i,n[6]=d,n[7]=T):T=n[7];const w=T;let x;if(n[8]!==p||n[9]!==i){let V;n[11]!==i?(V=z=>z.id===i,n[11]=i,n[12]=V):V=n[12],x=p.findIndex(V),n[8]=p,n[9]=i,n[10]=x}else x=n[10];const E=x,C=!y&&!v&&E===m;let R;n[13]!==E||n[14]!==f?(R=()=>{f(E)},n[13]=E,n[14]=f,n[15]=R):R=n[15];const O=R,L=`${b}-option-${i}`,I=C?"":void 0;let P;n[16]!==w||n[17]!==a?(P=dt(a,w),n[16]=w,n[17]=a,n[18]=P):P=n[18];let k;n[19]!==O||n[20]!==o?(k=dt(o,O),n[19]=O,n[20]=o,n[21]=k):k=n[21];let H;return n[22]!==e||n[23]!==C||n[24]!==u||n[25]!==L||n[26]!==I||n[27]!==P||n[28]!==k?(H=_.jsx(ht.button,{type:"button",role:"option",id:L,"aria-selected":C,"data-highlighted":I,...u,ref:e,onClick:P,onMouseMove:k}),n[22]=e,n[23]=C,n[24]=u,n[25]=L,n[26]=I,n[27]=P,n[28]=k,n[29]=H):H=n[29],H});Em.displayName="ComposerPrimitive.TriggerPopoverCategoryItem";const Am=et((t,e)=>{const n=Q(12);let i,a,o;n[0]!==t?({children:a,"aria-label":i,...o}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o):(i=n[1],a=n[2],o=n[3]);const{items:u,activeCategoryId:d,isSearchMode:f,open:p}=Ja();if(!p||!d&&!f)return null;const m=i??"Items";let y;n[4]!==a||n[5]!==u?(y=a(u),n[4]=a,n[5]=u,n[6]=y):y=n[6];let v;return n[7]!==e||n[8]!==o||n[9]!==m||n[10]!==y?(v=_.jsx(ht.div,{role:"group","aria-label":m,...o,ref:e,children:y}),n[7]=e,n[8]=o,n[9]=m,n[10]=y,n[11]=v):v=n[11],v});Am.displayName="ComposerPrimitive.TriggerPopoverItems";const Im=et((t,e)=>{const n=Q(30);let i,a,o,u,d;n[0]!==t?({item:a,index:i,onClick:o,onMouseMove:u,...d}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u,n[5]=d):(i=n[1],a=n[2],o=n[3],u=n[4],d=n[5]);const{selectItem:f,highlightIndex:p,items:m,highlightedIndex:y,activeCategoryId:v,isSearchMode:b,popoverId:T}=Ja();let w;n[6]!==a||n[7]!==f?(w=()=>{f(a)},n[6]=a,n[7]=f,n[8]=w):w=n[8];const x=w;let E;n[9]!==i||n[10]!==a.id||n[11]!==m?(E=i??m.findIndex(z=>z.id===a.id),n[9]=i,n[10]=a.id,n[11]=m,n[12]=E):E=n[12];const C=E,R=(b||v!==null)&&C===y;let O;n[13]!==p||n[14]!==C?(O=()=>{p(C)},n[13]=p,n[14]=C,n[15]=O):O=n[15];const L=O,I=`${T}-option-${a.id}`,P=R?"":void 0;let k;n[16]!==x||n[17]!==o?(k=dt(o,x),n[16]=x,n[17]=o,n[18]=k):k=n[18];let H;n[19]!==L||n[20]!==u?(H=dt(u,L),n[19]=L,n[20]=u,n[21]=H):H=n[21];let V;return n[22]!==e||n[23]!==R||n[24]!==d||n[25]!==I||n[26]!==P||n[27]!==k||n[28]!==H?(V=_.jsx(ht.button,{type:"button",role:"option",id:I,"aria-selected":R,"data-highlighted":P,...d,ref:e,onClick:k,onMouseMove:H}),n[22]=e,n[23]=R,n[24]=d,n[25]=I,n[26]=P,n[27]=k,n[28]=H,n[29]=V):V=n[29],V});Im.displayName="ComposerPrimitive.TriggerPopoverItem";const Rm=et((t,e)=>{const n=Q(10);let i,a;n[0]!==t?({onClick:i,...a}=t,n[0]=t,n[1]=i,n[2]=a):(i=n[1],a=n[2]);const{activeCategoryId:o,isSearchMode:u,goBack:d,open:f}=Ja();if(!f||!o||u)return null;let p;n[3]!==d||n[4]!==i?(p=dt(i,d),n[3]=d,n[4]=i,n[5]=p):p=n[5];let m;return n[6]!==e||n[7]!==a||n[8]!==p?(m=_.jsx(ht.button,{type:"button",...a,ref:e,onClick:p}),n[6]=e,n[7]=a,n[8]=p,n[9]=m):m=n[9],m});Rm.displayName="ComposerPrimitive.TriggerPopoverBack";const zE=t=>{const e=Q(8),{formatter:n,onExecute:i,removeOnExecute:a}=t,{register:o}=bE(),u=we(i);let d,f;e[0]!==i?(d=()=>{u.current=i},f=[i],e[0]=i,e[1]=d,e[2]=f):(d=e[1],f=e[2]),Os(d,f);let p,m;return e[3]!==n||e[4]!==o||e[5]!==a?(p=()=>{const y={kind:"action",formatter:n??FC,onExecute:v=>u.current(v),...a!==void 0?{removeOnExecute:a}:{}};return o(y)},m=[o,n,a],e[3]=n,e[4]=o,e[5]=a,e[6]=p,e[7]=m):(p=e[6],m=e[7]),Ce(p,m),null};zE.displayName="ComposerPrimitive.TriggerPopoverAction";const PE=t=>{const e=Q(7),{formatter:n,onInserted:i}=t,{register:a}=bE(),o=we(i);let u,d;e[0]!==i?(u=()=>{o.current=i},d=[i],e[0]=i,e[1]=u,e[2]=d):(u=e[1],d=e[2]),Os(u,d);let f,p;return e[3]!==n||e[4]!==a?(f=()=>a({kind:"directive",formatter:n??FC,onInserted:m=>o.current?.(m)}),p=[a,n],e[3]=n,e[4]=a,e[5]=f,e[6]=p):(f=e[5],p=e[6]),Ce(f,p),null};PE.displayName="ComposerPrimitive.TriggerPopoverDirective";const z1=Object.assign(_E,{Directive:PE,Action:zE});var Zo=Nl({AddAttachment:()=>JB,AttachmentByIndex:()=>DC,AttachmentDropzone:()=>kE,Attachments:()=>jC,Cancel:()=>KB,Dictate:()=>WB,DictationTranscript:()=>NE,If:()=>LC,Input:()=>ME,Queue:()=>zC,Quote:()=>OE,QuoteDismiss:()=>jE,QuoteText:()=>DE,Root:()=>CE,Send:()=>mB,StopDictation:()=>tU,TriggerPopover:()=>z1,TriggerPopoverBack:()=>Rm,TriggerPopoverCategories:()=>Cm,TriggerPopoverCategoryItem:()=>Em,TriggerPopoverItem:()=>Im,TriggerPopoverItems:()=>Am,TriggerPopoverRoot:()=>Tm,Unstable_TriggerPopover:()=>z1,Unstable_TriggerPopoverBack:()=>Rm,Unstable_TriggerPopoverCategories:()=>Cm,Unstable_TriggerPopoverCategoryItem:()=>Em,Unstable_TriggerPopoverItem:()=>Im,Unstable_TriggerPopoverItems:()=>Am,Unstable_TriggerPopoverRoot:()=>Tm,unstable_useTriggerPopoverRootContext:()=>$g,unstable_useTriggerPopoverRootContextOptional:()=>Gg,unstable_useTriggerPopoverScopeContext:()=>Ja,unstable_useTriggerPopoverScopeContextOptional:()=>hB,unstable_useTriggerPopoverTriggers:()=>KP,unstable_useTriggerPopoverTriggersOptional:()=>JP});const aU=Object.freeze({type:"complete"}),oU=Object.freeze({type:"text",text:"",status:aU}),BE=()=>me(lU);function lU(t){return t.part.type!=="text"&&t.part.type!=="reasoning"?oU:t.part}const UE=Qt(null),uU=t=>({useSmoothStatus:GC(()=>t)}),cU=t=>{const e=Q(6),{children:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={optional:!0},e[0]=i):i=e[0];const a=LE(i),o=ke();let u;e[1]!==o.part?(u=()=>uU(o.part.getState().status),e[1]=o.part,e[2]=u):u=e[2];const[d]=Ne(u);if(a)return n;let f;return e[3]!==n||e[4]!==d?(f=_.jsx(UE.Provider,{value:d,children:n}),e[3]=n,e[4]=d,e[5]=f):f=e[5],f},dU=t=>{const e=et((n,i)=>{const a=Q(3),o=n;let u;return a[0]!==i||a[1]!==o?(u=_.jsx(cU,{children:_.jsx(t,{...o,ref:i})}),a[0]=i,a[1]=o,a[2]=u):u=a[2],u});return e.displayName=t.displayName,e};function LE(t){const e=Sn(UE);if(!t?.optional&&!e)throw new Error("This component must be used within a SmoothContextProvider.");return e}const{useSmoothStatus:fU,useSmoothStatusStore:hU}=VC(LE,"useSmoothStatus"),qE=250,HE=5;var pU=class{animationFrameId=null;lastUpdateTime=0;lastCommitTime=-1/0;targetText="";drainMs=qE;maxCharIntervalMs=HE;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(t,e){this.currentText=t,this.setText=e}start(){this.animationFrameId===null&&(this.lastUpdateTime=performance.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{const t=performance.now();let e=t-this.lastUpdateTime;const n=this.targetText.length-this.currentText.length,i=Math.min(this.maxCharIntervalMs,this.drainMs/n),a=Math.min(n,this.maxCharsPerFrame);let o=0;for(;e>=i&&o<a;)o++,e-=i;o===a&&a===this.maxCharsPerFrame&&(e=0),o!==n?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,o!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+o),this.lastUpdateTime=t-e,(o===n||t-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=t,this.setText(this.currentText)))}};const bp=Object.freeze({type:"running"}),vc=(t,e)=>t!==void 0&&t>0?t:e,VE=(t,e=!1)=>{const{text:n}=t,i=AE("(prefers-reduced-motion: reduce)"),a=typeof e=="object"&&e!==null?e:void 0,o=e!==!1&&e!==null&&!i,u=vc(a?.drainMs,qE),d=vc(a?.maxCharIntervalMs,HE),f=vc(a?.maxCharsPerFrame,1/0),p=vc(a?.minCommitMs,0),[m,y]=Ne(t.status.type==="running"?"":n),v=ke(),b=me(()=>v.part),[T,w]=Ne(b);(b!==T||!n.startsWith(m))&&(w(b),y(t.status.type==="running"?"":n));const x=hU({optional:!0}),E=ri(O=>{if(y(O),x){const L=m!==O||t.status.type==="running"?bp:t.status;Yc(x).setState(L,!0)}});Ce(()=>{if(x){const O=o&&(m!==n||t.status.type==="running")?bp:t.status;Yc(x).setState(O,!0)}},[x,o,n,m,t.status]);const[C]=Ne(()=>new pU(m,E));Ce(()=>{C.drainMs=u,C.maxCharIntervalMs=d,C.maxCharsPerFrame=f,C.minCommitMs=p},[C,u,d,f,p]);const R=we(b);return Ce(()=>{if(!o){C.stop();return}const O=R.current!==b;if(R.current=b,O||!n.startsWith(C.targetText)){t.status.type==="running"?(C.currentText="",C.targetText=n,C.lastCommitTime=-1/0,C.start()):(C.currentText=n,C.targetText=n,C.stop(),E(n));return}if(C.targetText=n,t.status.type!=="running"){if(C.currentText===""){C.currentText=n,C.stop(),E(n);return}C.start();return}C.start()},[C,o,n,t.status.type,b,E]),Ce(()=>()=>{C.stop()},[C]),yt(()=>o?{...t,text:m,status:n===m?t.status:bp}:t,[o,m,t,n])},mU=Object.freeze({type:"complete"}),gU=Object.freeze({type:"image",image:"",status:mU}),yU=()=>me(vU);function vU(t){return t.part.type!=="image"?gU:t.part}const Qg=et(({smooth:t=!0,component:e=ht.span,render:n,...i},a)=>{const{text:o,status:u}=VE(BE(),t),d={"data-status":u.type,...i,ref:a};return n&&od(n)?Hg(n,o,d):_.jsx(e,{...d,children:o})});Qg.displayName="MessagePartPrimitive.Text";const Kg=et((t,e)=>{const n=Q(4),{image:i}=yU();let a;return n[0]!==e||n[1]!==i||n[2]!==t?(a=_.jsx(ht.img,{src:i,...t,ref:e}),n[0]=e,n[1]=i,n[2]=t,n[3]=a):a=n[3],a});Kg.displayName="MessagePartPrimitive.Image";const jr=t=>{const e=Q(2),n=we(void 0);let i;return e[0]!==t?(i=a=>{n.current&&(n.current(),n.current=void 0),a&&(n.current=t(a))},e[0]=t,e[1]=i):i=e[1],i},P1=(t,e)=>{const n=t.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return Number.POSITIVE_INFINITY;const i=Number(n[1]),a=n[2];return a==="px"?i:a==="em"?i*(parseFloat(getComputedStyle(e).fontSize)||16):a==="rem"?i*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):Number.POSITIVE_INFINITY},bU=t=>t.dataset.messageId,_U=()=>{const t=document.createElement("div");return t.dataset.auiTopAnchorReserve="",t.style.height="0px",t.style.flexShrink="0",t.style.pointerEvents="none",t.setAttribute("aria-hidden","true"),t},_p=(t,e)=>{const n=`${e}px`;return t.style.height!==n?(t.style.height=n,!0):!1},B1=t=>{const e=window.devicePixelRatio||1;return Math.round(t*e)/e},$E=()=>{const t=Q(4),e=ke();let n;t[0]!==e.message?(n=()=>e.message,t[0]=e.message,t[1]=n):n=t[1];const i=me(n);let a;return t[2]!==i?(a=o=>{let u=!0;const d=()=>{i.setIsHovering(!0)},f=()=>{i.setIsHovering(!1)};return o.addEventListener("mouseenter",d),o.addEventListener("mouseleave",f),o.matches(":hover")&&queueMicrotask(()=>{u&&i.setIsHovering(!0)}),()=>{u=!1,o.removeEventListener("mouseenter",d),o.removeEventListener("mouseleave",f),i.setIsHovering(!1)}},t[2]=i,t[3]=a):a=t[3],jr(a)},SU=()=>{const t=Q(2),e=Hi(AU);let n;return t[0]!==e?(n=i=>i.message.role==="user"&&i.message.index>0&&i.message.index===i.thread.messages.length-2&&i.thread.messages.at(-1)?.role==="assistant"&&(i.message.id===e||i.thread.isRunning),t[0]=e,t[1]=n):n=t[1],me(n)},TU=()=>{const t=Q(2),e=Hi(IU);let n;return t[0]!==e?(n=i=>i.message.isLast&&i.message.role==="assistant"&&i.message.index>=1&&i.thread.messages.at(i.message.index-1)?.role==="user"&&(i.message.id===e||i.thread.isRunning),t[0]=e,t[1]=n):n=t[1],me(n)},wU=(t,e)=>{const n=Q(3);let i;return n[0]!==t||n[1]!==e?(i=a=>{if(t)return e.getState().registerAnchorElement(a)},n[0]=t,n[1]=e,n[2]=i):i=n[2],jr(i)},xU=t=>{const e=Q(3),{active:n,threadViewportStore:i}=t;let a;return e[0]!==n||e[1]!==i?(a=o=>{if(!n)return;const u=i.getState(),d=u.topAnchorMessageClamp;return u.registerAnchorTargetElement(o,{tallerThan:P1(d.tallerThan,o),visibleHeight:P1(d.visibleHeight,o)})},e[0]=n,e[1]=i,e[2]=a):a=e[2],jr(a)},CU=t=>{const e=Q(7);let n,i;e[0]!==t?({forwardedRef:n,...i}=t,e[0]=t,e[1]=n,e[2]=i):(n=e[1],i=e[2]);const a=$E(),o=ai(n,a),u=me(RU);let d;return e[3]!==u||e[4]!==i||e[5]!==o?(d=_.jsx(ht.div,{...i,ref:o,"data-message-id":u}),e[3]=u,e[4]=i,e[5]=o,e[6]=d):d=e[6],d},EU=t=>{const e=Q(13);let n,i,a;e[0]!==t?({forwardedRef:n,threadViewportStore:a,...i}=t,e[0]=t,e[1]=n,e[2]=i,e[3]=a):(n=e[1],i=e[2],a=e[3]);const o=$E(),u=SU(),d=TU(),f=wU(u,a);let p;e[4]!==d||e[5]!==a?(p={active:d,threadViewportStore:a},e[4]=d,e[5]=a,e[6]=p):p=e[6];const m=xU(p),y=ai(n,o,f,m),v=me(MU),b=u?"":void 0,T=d?"":void 0;let w;return e[7]!==v||e[8]!==i||e[9]!==y||e[10]!==b||e[11]!==T?(w=_.jsx(ht.div,{...i,ref:y,"data-message-id":v,"data-aui-top-anchor-user":b,"data-aui-top-anchor-target":T}),e[7]=v,e[8]=i,e[9]=y,e[10]=b,e[11]=T,e[12]=w):w=e[12],w},GE=et((t,e)=>{const n=Q(7),i=Dr();if(i.getState().turnAnchor==="top"){let o;return n[0]!==e||n[1]!==t||n[2]!==i?(o=_.jsx(EU,{...t,forwardedRef:e,threadViewportStore:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=o):o=n[3],o}let a;return n[4]!==e||n[5]!==t?(a=_.jsx(CU,{...t,forwardedRef:e}),n[4]=e,n[5]=t,n[6]=a):a=n[6],a});GE.displayName="MessagePrimitive.Root";function AU(t){return t.topAnchorTurn?.anchorId}function IU(t){return t.topAnchorTurn?.targetId}function RU(t){return t.message.id}function MU(t){return t.message.id}const Sp={...Rs,Text:()=>_.jsxs("p",{style:{whiteSpace:"pre-line"},children:[_.jsx(Qg,{}),_.jsx(jg,{children:_.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Image:()=>_.jsx(Kg,{})},Mm=t=>{const e=Q(10);if("children"in t){let d;return e[0]!==t.children?(d=_.jsx(ym,{children:t.children}),e[0]=t.children,e[1]=d):d=e[1],d}let n,i;e[2]!==t?({components:n,...i}=t,e[2]=t,e[3]=n,e[4]=i):(n=e[3],i=e[4]);let a;e[5]!==n?(a=n?{...n,Text:n.Text??Sp.Text,Image:n.Image??Sp.Image}:Sp,e[5]=n,e[6]=a):a=e[6];const o=a;let u;return e[7]!==i||e[8]!==o?(u=_.jsx(ym,{components:o,...i}),e[7]=i,e[8]=o,e[9]=u):u=e[9],u};Mm.displayName="MessagePrimitive.Parts";const kU=t=>{const e=Q(12);let n;return e[0]!==t.assistant||e[1]!==t.copied||e[2]!==t.hasAttachments||e[3]!==t.hasBranches||e[4]!==t.hasContent||e[5]!==t.last||e[6]!==t.lastOrHover||e[7]!==t.speaking||e[8]!==t.submittedFeedback||e[9]!==t.system||e[10]!==t.user?(n=i=>{const{role:a,attachments:o,parts:u,branchCount:d,isLast:f,speech:p,isCopied:m,isHovering:y}=i.message;return!(t.hasBranches===!0&&d<2||t.user===!0&&a!=="user"||t.user===!1&&a==="user"||t.assistant===!0&&a!=="assistant"||t.assistant===!1&&a==="assistant"||t.system===!0&&a!=="system"||t.system===!1&&a==="system"||t.lastOrHover===!0&&!y&&!f||t.last!==void 0&&t.last!==f||t.copied===!0&&!m||t.copied===!1&&m||t.speaking===!0&&p==null||t.speaking===!1&&p!=null||t.hasAttachments===!0&&(a!=="user"||!o?.length)||t.hasAttachments===!1&&a==="user"&&o?.length||t.hasContent===!0&&u.length===0||t.hasContent===!1&&u.length>0||t.submittedFeedback!==void 0&&(i.message.metadata.submittedFeedback?.type??null)!==t.submittedFeedback)},e[0]=t.assistant,e[1]=t.copied,e[2]=t.hasAttachments,e[3]=t.hasBranches,e[4]=t.hasContent,e[5]=t.last,e[6]=t.lastOrHover,e[7]=t.speaking,e[8]=t.submittedFeedback,e[9]=t.system,e[10]=t.user,e[11]=n):n=e[11],me(n)},FE=t=>{const e=Q(3);let n,i;return e[0]!==t?({children:n,...i}=t,e[0]=t,e[1]=n,e[2]=i):(n=e[1],i=e[2]),kU(i)?n:null};FE.displayName="MessagePrimitive.If";const YE=t=>{const{children:e}=t;return Nz()!==void 0?e:null};YE.displayName="MessagePrimitive.Error";const NU=t=>{const e=new Map;for(let i=0;i<t.length;i++){const a=t[i]?.parentId??i,o=e.get(a)??[];o.push(i),e.set(a,o)}const n=[];for(const[i,a]of e){const o=typeof i=="string"?i:void 0;n.push({groupKey:o,indices:a})}return n},OU=t=>{const e=Q(9),n=me(UU);let i;e:{if(n.length===0){let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[0]=f):f=e[0],i=f;break e}let d;e[1]!==t||e[2]!==n?(d=t(n),e[1]=t,e[2]=n,e[3]=d):d=e[3],i=d}const a=i;let o;e[4]!==n?(o=Or(n),e[4]=n,e[5]=o):o=e[5];let u;return e[6]!==a||e[7]!==o?(u={groups:a,partKeys:o},e[6]=a,e[7]=o,e[8]=u):u=e[8],u},Pi={Text:()=>_.jsxs("p",{style:{whiteSpace:"pre-line"},children:[_.jsx(Qg,{}),_.jsx(jg,{children:_.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>_.jsx(Kg,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:t})=>t},DU=Nt(t=>{const e=Q(5),{partIndex:n,components:i}=t;let a;e[0]!==i?(a=_.jsx(_C,{components:i}),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==n||e[3]!==a?(o=_.jsx(bg,{index:n,children:a}),e[2]=n,e[3]=a,e[4]=o):o=e[4],o},(t,e)=>t.partIndex===e.partIndex&&t.components?.Text===e.components?.Text&&t.components?.Reasoning===e.components?.Reasoning&&t.components?.Source===e.components?.Source&&t.components?.Image===e.components?.Image&&t.components?.File===e.components?.File&&t.components?.Unstable_Audio===e.components?.Unstable_Audio&&t.components?.tools===e.components?.tools&&t.components?.data===e.components?.data),jU=t=>{const e=Q(6),{status:n,component:i}=t,a=n.type==="running";let o;e[0]!==i||e[1]!==n?(o=_.jsx(i,{type:"text",text:"",status:n}),e[0]=i,e[1]=n,e[2]=o):o=e[2];let u;return e[3]!==a||e[4]!==o?(u=_.jsx(_g,{text:"",isRunning:a,children:o}),e[3]=a,e[4]=o,e[5]=u):u=e[5],u},zU=Object.freeze({type:"complete"}),PU=t=>{const e=Q(6),{components:n}=t,i=me(LU);if(n?.Empty){let u;return e[0]!==n.Empty||e[1]!==i?(u=_.jsx(n.Empty,{status:i}),e[0]=n.Empty,e[1]=i,e[2]=u):u=e[2],u}const a=n?.Text??Pi.Text;let o;return e[3]!==i||e[4]!==a?(o=_.jsx(jU,{status:i,component:a}),e[3]=i,e[4]=a,e[5]=o):o=e[5],o},BU=Nt(PU,(t,e)=>t.components?.Empty===e.components?.Empty&&t.components?.Text===e.components?.Text),Xg=t=>{const e=Q(21),{groupingFunction:n,components:i}=t,a=me(qU),{groups:o,partKeys:u}=OU(n);let d;e:{if(a===0){let R;e[0]!==i?(R=_.jsx(BU,{components:i}),e[0]=i,e[1]=R):R=e[1],d=R;break e}const m=i?.Text??Pi.Text,y=i?.Reasoning??Pi.Reasoning,v=i?.Image??Pi.Image,b=i?.Source??Pi.Source,T=i?.File??Pi.File,w=i?.Unstable_Audio??Pi.Unstable_Audio;let x;e[2]!==i||e[3]!==m||e[4]!==y||e[5]!==v||e[6]!==b||e[7]!==T||e[8]!==w?(x={...i,Text:m,Reasoning:y,Image:v,Source:b,File:T,Unstable_Audio:w},e[2]=i,e[3]=m,e[4]=y,e[5]=v,e[6]=b,e[7]=T,e[8]=w,e[9]=x):x=e[9];const E=x;let C;if(e[10]!==i?.Group||e[11]!==E||e[12]!==o||e[13]!==u){let R;e[15]!==i?.Group||e[16]!==E||e[17]!==u?(R=(O,L)=>{const I=i?.Group??Pi.Group,P=u[O.indices[0]];return _.jsx(I,{groupKey:O.groupKey,indices:O.indices,children:O.indices.map(k=>_.jsx(DU,{partIndex:k,components:E},u[k]))},JSON.stringify(["group",O.groupKey??null,P?.includes(":")?`id:${P}`:L]))},e[15]=i?.Group,e[16]=E,e[17]=u,e[18]=R):R=e[18],C=o.map(R),e[10]=i?.Group,e[11]=E,e[12]=o,e[13]=u,e[14]=C}else C=e[14];d=C}const f=d;let p;return e[19]!==f?(p=_.jsx(_.Fragment,{children:f}),e[19]=f,e[20]=p):p=e[20],p};Xg.displayName="MessagePrimitive.Unstable_PartsGrouped";const QE=t=>{const e=Q(6);let n,i;e[0]!==t?({components:n,...i}=t,e[0]=t,e[1]=n,e[2]=i):(n=e[1],i=e[2]);let a;return e[3]!==n||e[4]!==i?(a=_.jsx(Xg,{...i,components:n,groupingFunction:NU}),e[3]=n,e[4]=i,e[5]=a):a=e[5],a};QE.displayName="MessagePrimitive.Unstable_PartsGroupedByParentId";function UU(t){return t.message.parts}function LU(t){return t.message.status??zU}function qU(t){return t.message.parts.length}var Kc=Nl({AttachmentByIndex:()=>kC,Attachments:()=>NC,Content:()=>Mm,Error:()=>YE,GenerativeUI:()=>bC,GroupedParts:()=>AC,If:()=>FE,PartByIndex:()=>hl,Parts:()=>Mm,Quote:()=>RC,Root:()=>GE,Unstable_PartsGrouped:()=>Xg,Unstable_PartsGroupedByParentId:()=>QE});const HU=t=>{const e=Q(2),n=ri(t);let i;return e[0]!==n?(i=a=>y3(a,n),e[0]=n,e[1]=i):i=e[1],jr(i)},KE=new Set([" ","ArrowUp","ArrowDown","PageUp","PageDown","Home","End"]),VU=new Set(["Enter",...KE]),Tp=["textarea","select","[contenteditable]:not([contenteditable='false'])","input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']):not([type='image']):not([type='range']):not([type='file']):not([type='color'])"].join(", "),gd="[data-message-id]",$U="[aria-expanded], summary",GU=t=>{const e=t.closest($U);return e?e.tagName==="SUMMARY"?e.parentElement?.hasAttribute("open")===!1:e.getAttribute("aria-expanded")==="false"&&(e.getAttribute("aria-haspopup")??"false")==="false"&&e.getAttribute("role")!=="combobox":!1},XE=(t,e)=>t.getBoundingClientRect().top-e.getBoundingClientRect().top,FU=t=>{const e=t.querySelector(gd),n=e?.dataset.messageId;return e&&n?{id:n,offset:XE(e,t)}:null},YU=t=>{const{top:e,bottom:n}=t.getBoundingClientRect();let i=null;for(const a of t.querySelectorAll(gd)){const o=a.getBoundingClientRect();if(o.bottom<=e)continue;if(o.top>=n)break;const u=a.dataset.messageId;if(u){if(o.top>=e)return{id:u,offset:o.top-e};i??={id:u,offset:o.top-e}}}return i},QU=(t,e)=>{for(const n of t.querySelectorAll(gd))if(n.dataset.messageId===e)return n;return null},U1=(t,e,n)=>{const i=QU(t,e.id);if(!i)return!1;const a=XE(i,t)-e.offset;return n.current=t.scrollTop+a,Math.abs(a)>=1&&t.scrollTo({top:n.current,behavior:"instant"}),n.current=t.scrollTop,!0},KU=({autoScroll:t,scrollToBottomOnRunStart:e=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:i=!0})=>{const a=ke(),o=we(null),u=me($=>$.thread.messages.length>0),d=me($=>$.thread.messages[0]?.id),f=me($=>$.threadListItem.id),p=me($=>$.thread.isRunning),m=we(!1),y=we(null),v=Dr();t===void 0&&(t=v.getState().turnAnchor!=="top");const b=we(0),T=we(0),w=we(0),x=we(0),E=we(null),C=we(null),R=we(0),O=we(null),L=we(t),I=we(!1),P=we(!1),k=we(t);Zs(()=>{const $=k.current;if(k.current=t,$||!t)return;const re=o.current;L.current=re!==null&&aS(re)},[t]);const H=on($=>{const re=o.current;re&&(L.current=!0,I.current=!1,O.current=$,C.current=null,re.scrollTo({top:re.scrollHeight,behavior:$}),b.current=re.scrollTop,T.current=re.scrollHeight)},[]),V=on(()=>{y.current!==null&&(cancelAnimationFrame(y.current),y.current=null)},[]),z=on($=>{O.current=$,V(),y.current=requestAnimationFrame(()=>{y.current=null,H($)})},[V,H]);Zs(()=>()=>V(),[V]);const q=on(()=>{const $=v.getState();return $.turnAnchor==="top"&&$.element.viewport===o.current&&$.element.anchor!==null},[v]),W=()=>{const $=o.current;if(!$)return;C.current&&Math.abs($.scrollTop-R.current)>=1&&(C.current=null);const re=v.getState().isAtBottom,M=aS($);if(!(O.current!==null&&!M&&b.current<$.scrollTop)){const N=g3({scrollTop:b.current,scrollHeight:T.current},$);M?(m3($)&&(O.current=null,P.current&&(I.current=!1)),t&&(L.current=!0)):N&&(V(),O.current=null,L.current=!1),(M||O.current===null)&&M!==re&&Yc(v).setState({isAtBottom:M})}b.current=$.scrollTop,T.current=$.scrollHeight,E.current=FU($)},X=we(W);Zs(()=>{X.current=W});const Z=on(()=>X.current(),[]),ee=()=>{const $=o.current;if(!$)return;const{scrollHeight:re,clientHeight:M}=$;if(!(re===w.current&&M===x.current)){if(w.current=re,x.current=M,y.current===null){const N=O.current;N&&q()?O.current=null:N?H(N):t&&!(p&&q())&&L.current&&!I.current?H("instant"):C.current&&!U1($,C.current,R)&&(C.current=null)}Z()}},oe=we(ee);Zs(()=>{oe.current=ee});const he=HU(()=>oe.current()),ye=jr(on($=>{const re=()=>{O.current===null&&y.current===null||(V(),O.current=null,Z())},M=B=>{VU.has(B.key)&&(B.target?.closest?.(Tp)||re())},N=B=>{const ce=B.target;!ce?.closest?.(gd)||ce.closest(Tp)||!GU(ce)||(I.current=!0,P.current=!1,re())},te=B=>{if(B instanceof KeyboardEvent){if(!KE.has(B.key)||B.target?.closest?.(Tp))return}else if(B.type==="pointerdown"&&B.target!==$)return;P.current=!0},ie=()=>{C.current=null},pe=["pointerdown","wheel","touchstart","keydown"],de=["pointerdown","wheel","touchmove","keydown"];$.addEventListener("scroll",Z),$.addEventListener("pointerdown",re),$.addEventListener("wheel",re,{passive:!0}),$.addEventListener("touchstart",re,{passive:!0}),$.addEventListener("keydown",M),$.addEventListener("click",N,{capture:!0});for(const B of de)$.addEventListener(B,te,{passive:!0});for(const B of pe)$.addEventListener(B,ie,{passive:!0});return()=>{$.removeEventListener("scroll",Z),$.removeEventListener("pointerdown",re),$.removeEventListener("wheel",re),$.removeEventListener("touchstart",re),$.removeEventListener("keydown",M),$.removeEventListener("click",N,{capture:!0});for(const B of de)$.removeEventListener(B,te);for(const B of pe)$.removeEventListener(B,ie)}},[V,Z])),D=we({threadId:f,firstMessageId:d});return Zs(()=>{const $=D.current;if(D.current={threadId:f,firstMessageId:d},$.threadId!==f){C.current=null;return}const re=o.current,M=$.firstMessageId;if(!re||M===void 0||M===d||t&&L.current&&!I.current||O.current!==null||!a.thread.getState().messages.some((te,ie)=>ie>0&&te.id===M))return;const N=E.current;if(N?.id===M&&U1(re,N,R))C.current=YU(re)??N;else{const te=re.scrollHeight-(T.current-b.current);Math.abs(re.scrollTop-te)>=1&&re.scrollTo({top:te,behavior:"instant"})}b.current=re.scrollTop,T.current=re.scrollHeight},[a,t,d,f]),Zs(()=>{if(n){if(!u){m.current=!1;return}m.current||(m.current=!0,O.current===null&&z("instant"))}},[u,z,n]),EE(({behavior:$})=>{H($)}),pS("thread.runStart",()=>{C.current=null,I.current=!1,e&&v.getState().turnAnchor!=="top"&&z("auto")}),pS("threads.selectionChanged",()=>{I.current=!1,i&&z("instant")}),ai(he,ye,o)},L1=new WeakMap,JE=et((t,e)=>{const n=Q(9),i=ke(),a=we(null),o=ai(e,a);let u;n[0]!==t?(u=y=>{y.key==="Escape"&&a.current&&L1.set(y.nativeEvent,a.current),t.onKeyDown?.(y)},n[0]=t,n[1]=u):u=n[1];const d=u;let f,p;n[2]!==i?(f=()=>{const y=v=>{if(v.key!=="Escape"||wm(v)||v.defaultPrevented||i.thread.source===null)return;const b=L1.get(v)??v.composedPath().find(XU);if(!(b&&b!==a.current)&&i.thread.getState().speech!=null){v.preventDefault();try{i.thread.stopSpeaking()}catch(T){const w=T;if(!(w instanceof Error)||w.message!=="No message is being spoken")throw w}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y)}},p=[i],n[2]=i,n[3]=f,n[4]=p):(f=n[3],p=n[4]),Ce(f,p);let m;return n[5]!==o||n[6]!==d||n[7]!==t?(m=_.jsx(IE.Provider,{value:a,children:_.jsx(ht.div,{...t,"data-aui-thread-root":"",ref:o,onKeyDown:d})}),n[5]=o,n[6]=d,n[7]=t,n[8]=m):m=n[8],m});JE.displayName="ThreadPrimitive.Root";function XU(t){return t instanceof Element&&t.hasAttribute("data-aui-thread-root")}const ZE=t=>{const{children:e}=t;return me(JU)?e:null};ZE.displayName="ThreadPrimitive.Empty";function JU(t){return t.thread.isEmpty}const ZU=t=>{const e=Q(4);let n;return e[0]!==t.disabled||e[1]!==t.empty||e[2]!==t.running?(n=i=>!(t.empty===!0&&!i.thread.isEmpty||t.empty===!1&&i.thread.isEmpty||t.running===!0&&!i.thread.isRunning||t.running===!1&&i.thread.isRunning||t.disabled===!0&&!i.thread.isDisabled||t.disabled===!1&&i.thread.isDisabled),e[0]=t.disabled,e[1]=t.empty,e[2]=t.running,e[3]=n):n=e[3],me(n)},WE=t=>{const e=Q(3);let n,i;return e[0]!==t?({children:n,...i}=t,e[0]=t,e[1]=n,e[2]=i):(n=e[1],i=e[2]),ZU(i)?n:null};WE.displayName="ThreadPrimitive.If";const eA=(t,e)=>{const n=Q(3);let i;return n[0]!==e||n[1]!==t?(i=a=>{if(!t)return;const o=t(),u=()=>{const f=e?e(a):a.offsetHeight;o.setHeight(f)},d=new ResizeObserver(u);return d.observe(a),u(),()=>{d.disconnect(),o.unregister()}},n[0]=e,n[1]=t,n[2]=i):i=n[2],jr(i)},q1=t=>{let e=0,n=t;for(;n;)e+=n.offsetTop,n=n.offsetParent;return e},WU=(t,e)=>{let n=0,i=t;for(;i&&i!==e;)n+=i.offsetTop,i=i.offsetParent;return i===e?n:q1(t)-q1(e)},tA=({viewport:t,anchor:e,tallerThan:n,visibleHeight:i})=>{const a=WU(e,t),o=e.offsetHeight;return a+Math.max(0,o-(o<=n?o:i))},eL=({scrollHeight:t,...e})=>{const{viewport:n}=e,i=tA(e)+n.clientHeight;return Math.max(0,i-t)},tL=({viewport:t,reserve:e,...n})=>eL({viewport:t,...n,scrollHeight:t.scrollHeight-e.offsetHeight}),nL=t=>{const e=new ResizeObserver(t),n=new MutationObserver(t);let i=null,a=null,o=null;const u=()=>{e.disconnect(),n.disconnect(),i=null,a=null,o=null};return{target:(d,f,p)=>{i===d&&a===f&&o===p||(u(),e.observe(d),e.observe(f),e.observe(p),n.observe(p,{childList:!0,subtree:!0,characterData:!0}),i=d,a=f,o=p)},disconnect:u}},sL=t=>{let e=null;return{schedule:()=>{e===null&&(e=requestAnimationFrame(()=>{e=null,t()}))},cancel:()=>{e!==null&&(cancelAnimationFrame(e),e=null)}}},iL=t=>{let e=null,n,i=null,a=0,o=null,u=!1,d=null;const f=()=>{o=null,d=null},p=()=>d!==null&&Math.abs(a-d)<=1,m=()=>{const x=i;if(!x)return;const E=x.scrollTop,C=Math.max(0,x.scrollHeight-x.clientHeight);E<a&&a>C+1&&Math.abs(E-C)<=1&&p()&&!u&&(o??=a,b.schedule()),a=E},y=x=>{i!==x&&(i&&i.removeEventListener("scroll",m),i=x,u=!1,f(),x&&(x.addEventListener("scroll",m,{passive:!0}),a=x.scrollTop))};function v(){const x=t.getState(),{viewport:E,anchor:C,target:R}=x.element,O=x.targetConfig;if(y(x.turnAnchor==="top"?E:null),x.turnAnchor!=="top"||!E){T.disconnect(),f(),e&&(_p(e,0),e.remove());return}if(!C&&!R&&!O&&x.topAnchorTurn){T.disconnect(),f(),e?.parentElement&&e.parentElement.lastElementChild!==e&&e.parentElement.append(e);return}if(!C||!R||!O){T.disconnect(),f(),e&&(_p(e,0),e.remove());return}if(e??=_U(),(e.parentElement!==R.parentElement||e.previousElementSibling!==R)&&R.after(e),T.target(E,C,R),_p(e,tL({viewport:E,anchor:C,reserve:e,...O}))){b.schedule();return}const L=bU(C),I=B1(tA({viewport:E,anchor:C,...O}));if(L===void 0||L!==n)o=null,u=!1,Math.abs(E.scrollTop-I)>1&&E.scrollTo({top:I,behavior:"smooth"}),L!==void 0&&(n=L);else if(o!==null&&d!==null){const P=B1(o+(I-d));o=null,u=!0,Math.abs(E.scrollTop-P)>1&&E.scrollTo({top:P,behavior:"instant"})}d=I}const b=sL(v),T=nL(b.schedule);b.schedule();const w=t.subscribe(b.schedule);return()=>{b.cancel(),w(),T.disconnect(),y(null),e?.remove()}},rL=t=>{const e=Q(4),n=Dr();let i,a;e[0]!==t||e[1]!==n?(i=()=>{if(t)return iL(n)},a=[t,n],e[0]=t,e[1]=n,e[2]=i,e[3]=a):(i=e[2],a=e[3]),Zs(i,a)},aL=(t,e)=>{if(!t)return!1;const n=e.findIndex(i=>i.id===t.targetId);return n<1?!1:e[n-1]?.id===t.anchorId&&e.slice(n+1).every(i=>i.role==="user")},nA=({isRunning:t,messages:e})=>{if(!t)return null;const n=e.at(-1),i=e.at(-2);return i?.role!=="user"||n?.role!=="assistant"?null:{anchorId:i.id,targetId:n.id}},oL=t=>nA(t)?.anchorId,lL=t=>nA(t)?.targetId,uL=()=>{const t=Hi(fL);return eA(t,hL)},cL=()=>{const t=Hi(pL);return jr(t)},dL=t=>{const e=Q(19),n=Dr();let i;e[0]!==t?(i=x=>{if(t)return oL(x.thread)},e[0]=t,e[1]=i):i=e[1];const a=me(i);let o;e[2]!==t?(o=x=>{if(t)return lL(x.thread)},e[2]=t,e[3]=o):o=e[3];const u=me(o),d=Hi(mL);let f;e:{if(!a||!u){f=null;break e}let x;e[4]!==a||e[5]!==u?(x={anchorId:a,targetId:u},e[4]=a,e[5]=u,e[6]=x):x=e[6],f=x}const p=f;let m;e[7]!==t||e[8]!==d?(m=x=>t&&!!d&&aL(d,x.thread.messages),e[7]=t,e[8]=d,e[9]=m):m=e[9];const y=me(m);let v,b;e[10]!==n||e[11]!==d||e[12]!==y?(v=()=>{!d||y||n.getState().setTopAnchorTurn(null)},b=[n,d,y],e[10]=n,e[11]=d,e[12]=y,e[13]=v,e[14]=b):(v=e[13],b=e[14]),Zs(v,b);let T,w;e[15]!==p||e[16]!==n?(T=()=>{if(!p)return;const x=n.getState(),E=x.topAnchorTurn;E?.anchorId===p.anchorId&&E.targetId===p.targetId||x.setTopAnchorTurn(p)},w=[p,n],e[15]=p,e[16]=n,e[17]=T,e[18]=w):(T=e[17],w=e[18]),Zs(T,w)},sA=et((t,e)=>{const n=Q(18);let i,a,o,u,d,f;n[0]!==t?({autoScroll:i,scrollToBottomOnRunStart:d,scrollToBottomOnInitialize:u,scrollToBottomOnThreadSwitch:f,children:a,...o}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o,n[4]=u,n[5]=d,n[6]=f):(i=n[1],a=n[2],o=n[3],u=n[4],d=n[5],f=n[6]);let p;n[7]!==i||n[8]!==u||n[9]!==d||n[10]!==f?(p={autoScroll:i,scrollToBottomOnRunStart:d,scrollToBottomOnInitialize:u,scrollToBottomOnThreadSwitch:f},n[7]=i,n[8]=u,n[9]=d,n[10]=f,n[11]=p):p=n[11];const m=KU(p),y=uL(),v=cL(),b=Dr();let T;n[12]!==b?(T=b.getState(),n[12]=b,n[13]=T):T=n[13];const w=T.turnAnchor==="top";dL(w),rL(w);const x=ai(e,m,y,v);let E;return n[14]!==a||n[15]!==x||n[16]!==o?(E=_.jsx(ht.div,{...o,ref:x,children:a}),n[14]=a,n[15]=x,n[16]=o,n[17]=E):E=n[17],E});sA.displayName="ThreadPrimitive.ViewportScrollable";const iA=et((t,e)=>{const n=Q(13);let i,a,o;n[0]!==t?({turnAnchor:o,topAnchorMessageClamp:a,...i}=t,n[0]=t,n[1]=i,n[2]=a,n[3]=o):(i=n[1],a=n[2],o=n[3]);let u;n[4]!==a||n[5]!==o?(u={turnAnchor:o,topAnchorMessageClamp:a},n[4]=a,n[5]=o,n[6]=u):u=n[6];let d;n[7]!==i||n[8]!==e?(d=_.jsx(sA,{...i,ref:e}),n[7]=i,n[8]=e,n[9]=d):d=n[9];let f;return n[10]!==u||n[11]!==d?(f=_.jsx(zg,{options:u,children:d}),n[10]=u,n[11]=d,n[12]=f):f=n[12],f});iA.displayName="ThreadPrimitive.Viewport";function fL(t){return t.registerViewport}function hL(t){return t.clientHeight}function pL(t){return t.registerViewportElement}function mL(t){return t.topAnchorTurn}const rA=et((t,e)=>{const n=Q(3),i=Hi(gL),a=eA(i,yL),o=ai(e,a);let u;return n[0]!==t||n[1]!==o?(u=_.jsx(ht.div,{...t,ref:o}),n[0]=t,n[1]=o,n[2]=u):u=n[2],u});rA.displayName="ThreadPrimitive.ViewportFooter";function gL(t){return t.registerContentInset}function yL(t){const e=parseFloat(getComputedStyle(t).marginTop)||0;return t.offsetHeight+e}const vL=t=>{const e=Q(5);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const{behavior:i}=n,a=Hi(_L),o=Dr();let u;e[2]!==i||e[3]!==o?(u=()=>{o.getState().scrollToBottom({behavior:i})},e[2]=i,e[3]=o,e[4]=u):u=e[4];const d=u;return a?null:d},bL=ps("ThreadPrimitive.ScrollToBottom",vL,["behavior"]);function _L(t){return t.isAtBottom}const SL=()=>{const t=Q(2),e=ke(),n=me(wL);let i;t[0]!==e.thread?(i=()=>{e.thread.loadEarlier()},t[0]=e.thread,t[1]=i):i=t[1];const a=i;return n?a:null},TL=ps("ThreadPrimitive.LoadEarlier",SL);function wL(t){return t.thread.hasEarlier}const xL=t=>{const e=Q(4),{prompt:n,send:i,clearComposer:a,autoSend:o}=t,u=i??o??!1;let d;e[0]!==a||e[1]!==n||e[2]!==u?(d={prompt:n,send:u,clearComposer:a},e[0]=a,e[1]=n,e[2]=u,e[3]=d):d=e[3];const{disabled:f,trigger:p}=Mz(d);return f?null:p},CL=ps("ThreadPrimitive.Suggestion",xL,["prompt","send","clearComposer","autoSend","method"]);var Sr=Nl({Empty:()=>ZE,If:()=>WE,LoadEarlier:()=>TL,MessageByIndex:()=>pC,Messages:()=>Z5,Root:()=>JE,Row:()=>IC,ScrollToBottom:()=>bL,Suggestion:()=>CL,SuggestionByIndex:()=>BC,Suggestions:()=>W6,Unstable_MessageById:()=>mC,Viewport:()=>iA,ViewportFooter:()=>rA,ViewportProvider:()=>zg}),EL=Nl({AssistantRuntimeImpl:()=>Sg,BaseAssistantRuntimeCore:()=>Tg,CompositeContextProvider:()=>fg,DefaultThreadComposerRuntimeCore:()=>$x,MessageRepository:()=>Vx,ThreadRuntimeImpl:()=>zx,getAutoStatus:()=>vg,splitLocalRuntimeOptions:()=>qz,useComposerInputPluginRegistryOptional:()=>md,useSmooth:()=>VE,useSmoothStatus:()=>fU,withSmoothContextProvider:()=>dU});const Xc=(t,e,n=0,i=!1)=>{if(Object.is(t,e))return!0;if(n>=100||typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let m=0;m<t.length;m++)if(!Xc(t[m],e[m],n+1))return!1;return!0}if(Array.isArray(e))return!1;const a=Object.getPrototypeOf(t),o=Object.getPrototypeOf(e);if(a!==Object.prototype&&a!==null||o!==Object.prototype&&o!==null)return!1;const u=t,d=e;let f=0;for(const m in u)if(Object.hasOwn(u,m)&&!(i&&(m==="position"||m==="data"))){if(!Object.prototype.propertyIsEnumerable.call(d,m)||!Xc(u[m],d[m],n+1))return!1;f++}let p=0;for(const m in d)Object.hasOwn(d,m)&&(i&&(m==="position"||m==="data")||p++);return f===p},AL=(t,e)=>!t||!e?!1:t===e?!0:Xc(t.properties,e.properties,0,!0)&&Xc(t.children,e.children),aA=(t,e)=>AL(t.node,e.node),Jg=se.createContext(null),IL=()=>se.useContext(Jg)!==null,RL=({children:t,fallbackPre:e,...n})=>n.node?.children.some(i=>i.type==="element"&&i.tagName==="code")??!0?_.jsx(Jg.Provider,{value:n,children:t}):_.jsx(e,{...n,children:t}),ML=se.memo(RL,(t,e)=>t.fallbackPre===e.fallbackPre&&aA(t,e)),kL=({node:t,...e})=>_.jsx("pre",{...e}),NL=({node:t,...e})=>_.jsx("code",{...e}),oA=({node:t,components:{Pre:e,Code:n},code:i})=>_.jsx(e,{children:_.jsx(n,{node:t,children:i})}),OL=()=>null,DL=t=>/language-([^\s]+)/.exec(t??"")?.[1]??"",jL=({node:t,components:{Pre:e,Code:n,SyntaxHighlighter:i,CodeHeader:a},language:o,code:u})=>{const d=se.useMemo(()=>({Pre:e,Code:n}),[e,n]);return _.jsxs(_.Fragment,{children:[_.jsx(a,{node:t,language:o,code:u}),_.jsx(i,{node:t,components:d,language:o,code:u})]})};var wp={exports:{}};var H1;function zL(){return H1||(H1=1,(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var o="",u=0;u<arguments.length;u++){var d=arguments[u];d&&(o=a(o,i(d)))}return o}function i(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return n.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var u="";for(var d in o)e.call(o,d)&&o[d]&&(u=a(u,d));return u}function a(o,u){return u?o?o+" "+u:o+u:o}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(wp)),wp.exports}var PL=zL();const lA=xl(PL),V1=({className:t,...e})=>({className:n,...i})=>({className:lA(t,n),...e,...i});function km(t){if(typeof t=="string")return t;if(Array.isArray(t)){let e="";for(const n of t)e+=km(n);return e}return se.isValidElement(t)?km(t.props.children):""}const BL=({node:t,components:{Pre:e,Code:n,SyntaxHighlighter:i,CodeHeader:a},componentsByLanguage:o={},children:u,...d})=>{const f=se.useContext(Jg),p=V1(f),m=ri(x=>_.jsx(e,{...p(x)})),y=V1(d),v=ri(x=>_.jsx(n,{...y(x)})),b=DL(d.className),T=o[b]?.SyntaxHighlighter??i,w=o[b]?.CodeHeader??a;return u!=null&&typeof u!="string"?_.jsxs(_.Fragment,{children:[_.jsx(w,{node:t,language:b,code:km(u)}),_.jsx(oA,{node:t,components:{Pre:m,Code:v},code:u})]}):_.jsx(jL,{node:t,components:{Pre:m,Code:v,SyntaxHighlighter:T,CodeHeader:w},language:b,code:u??""})},UL=({node:t,components:e,componentsByLanguage:n,...i})=>IL()?_.jsx(BL,{node:t,components:e,componentsByLanguage:n,...i}):_.jsx(e.Code,{...i}),LL=(t,e)=>{if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.hasOwn(e,i))return!1;const a=t[i],o=e[i];if(a!==o&&(!a||!o||a.SyntaxHighlighter!==o.SyntaxHighlighter||a.CodeHeader!==o.CodeHeader))return!1}return!0},qL=se.memo(UL,(t,e)=>t.components===e.components&&LL(t.componentsByLanguage,e.componentsByLanguage)&&aA(t,e));function HL(t,e){const n={};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const VL=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$L=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GL={};function $1(t,e){return(GL.jsx?$L:VL).test(t)}const FL=/[ \t\n\f\r]/g;function YL(t){return typeof t=="object"?t.type==="text"?G1(t.value):!1:G1(t)}function G1(t){return t.replace(FL,"")===""}class Ol{constructor(e,n,i){this.normal=n,this.property=e,i&&(this.space=i)}}Ol.prototype.normal={};Ol.prototype.property={};Ol.prototype.space=void 0;function uA(t,e){const n={},i={};for(const a of t)Object.assign(n,a.property),Object.assign(i,a.normal);return new Ol(n,i,e)}function Nm(t){return t.toLowerCase()}class Tn{constructor(e,n){this.attribute=n,this.property=e}}Tn.prototype.attribute="";Tn.prototype.booleanish=!1;Tn.prototype.boolean=!1;Tn.prototype.commaOrSpaceSeparated=!1;Tn.prototype.commaSeparated=!1;Tn.prototype.defined=!1;Tn.prototype.mustUseProperty=!1;Tn.prototype.number=!1;Tn.prototype.overloadedBoolean=!1;Tn.prototype.property="";Tn.prototype.spaceSeparated=!1;Tn.prototype.space=void 0;let QL=0;const ze=zr(),Rt=zr(),Om=zr(),be=zr(),ot=zr(),Cr=zr(),On=zr();function zr(){return 2**++QL}const Dm=Object.freeze(Object.defineProperty({__proto__:null,boolean:ze,booleanish:Rt,commaOrSpaceSeparated:On,commaSeparated:Cr,number:be,overloadedBoolean:Om,spaceSeparated:ot},Symbol.toStringTag,{value:"Module"})),xp=Object.keys(Dm);class Zg extends Tn{constructor(e,n,i,a){let o=-1;if(super(e,n),F1(this,"space",a),typeof i=="number")for(;++o<xp.length;){const u=xp[o];F1(this,xp[o],(i&Dm[u])===Dm[u])}}}Zg.prototype.defined=!0;function F1(t,e,n){n&&(t[e]=n)}function Za(t){const e={},n={};for(const[i,a]of Object.entries(t.properties)){const o=new Zg(i,t.transform(t.attributes||{},i),a,t.space);t.mustUseProperty&&t.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),e[i]=o,n[Nm(i)]=i,n[Nm(o.attribute)]=i}return new Ol(e,n,t.space)}const cA=Za({properties:{ariaActiveDescendant:null,ariaAtomic:Rt,ariaAutoComplete:null,ariaBusy:Rt,ariaChecked:Rt,ariaColCount:be,ariaColIndex:be,ariaColSpan:be,ariaControls:ot,ariaCurrent:null,ariaDescribedBy:ot,ariaDetails:null,ariaDisabled:Rt,ariaDropEffect:ot,ariaErrorMessage:null,ariaExpanded:Rt,ariaFlowTo:ot,ariaGrabbed:Rt,ariaHasPopup:null,ariaHidden:Rt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ot,ariaLevel:be,ariaLive:null,ariaModal:Rt,ariaMultiLine:Rt,ariaMultiSelectable:Rt,ariaOrientation:null,ariaOwns:ot,ariaPlaceholder:null,ariaPosInSet:be,ariaPressed:Rt,ariaReadOnly:Rt,ariaRelevant:null,ariaRequired:Rt,ariaRoleDescription:ot,ariaRowCount:be,ariaRowIndex:be,ariaRowSpan:be,ariaSelected:Rt,ariaSetSize:be,ariaSort:null,ariaValueMax:be,ariaValueMin:be,ariaValueNow:be,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function dA(t,e){return e in t?t[e]:e}function fA(t,e){return dA(t,e.toLowerCase())}const KL=Za({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Cr,acceptCharset:ot,accessKey:ot,action:null,allow:null,allowFullScreen:ze,allowPaymentRequest:ze,allowUserMedia:ze,alpha:ze,alt:null,as:null,async:ze,autoCapitalize:null,autoComplete:ot,autoFocus:ze,autoPlay:ze,blocking:ot,capture:null,charSet:null,checked:ze,cite:null,className:ot,closedBy:null,colorSpace:null,cols:be,colSpan:be,command:null,commandFor:null,content:null,contentEditable:Rt,controls:ze,controlsList:ot,coords:be|Cr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ze,defer:ze,dir:null,dirName:null,disabled:ze,download:Om,draggable:Rt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ze,formTarget:null,headers:ot,height:be,hidden:Om,high:be,href:null,hrefLang:null,htmlFor:ot,httpEquiv:ot,id:null,imageSizes:null,imageSrcSet:null,inert:ze,inputMode:null,integrity:null,is:null,isMap:ze,itemId:null,itemProp:ot,itemRef:ot,itemScope:ze,itemType:ot,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ze,low:be,manifest:null,max:null,maxLength:be,media:null,method:null,min:null,minLength:be,multiple:ze,muted:ze,name:null,nonce:null,noModule:ze,noValidate:ze,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:ze,optimum:be,pattern:null,ping:ot,placeholder:null,playsInline:ze,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ze,referrerPolicy:null,rel:ot,required:ze,reversed:ze,rows:be,rowSpan:be,sandbox:ot,scope:null,scoped:ze,seamless:ze,selected:ze,shadowRootClonable:ze,shadowRootCustomElementRegistry:ze,shadowRootDelegatesFocus:ze,shadowRootMode:null,shadowRootSerializable:ze,shape:null,size:be,sizes:null,slot:null,span:be,spellCheck:Rt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:be,step:null,style:null,tabIndex:be,target:null,title:null,translate:null,type:null,typeMustMatch:ze,useMap:null,value:Rt,width:be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ot,axis:null,background:null,bgColor:null,border:be,borderColor:null,bottomMargin:be,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ze,declare:ze,event:null,face:null,frame:null,frameBorder:null,hSpace:be,leftMargin:be,link:null,longDesc:null,lowSrc:null,marginHeight:be,marginWidth:be,noResize:ze,noHref:ze,noShade:ze,noWrap:ze,object:null,profile:null,prompt:null,rev:null,rightMargin:be,rules:null,scheme:null,scrolling:Rt,standby:null,summary:null,text:null,topMargin:be,valueType:null,version:null,vAlign:null,vLink:null,vSpace:be,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ze,disablePictureInPicture:ze,disableRemotePlayback:ze,exportParts:Cr,part:ot,prefix:null,property:null,results:be,security:null,unselectable:null},space:"html",transform:fA}),XL=Za({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:On,accentHeight:be,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:be,amplitude:be,arabicForm:null,ascent:be,attributeName:null,attributeType:null,azimuth:be,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:be,by:null,calcMode:null,capHeight:be,className:ot,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:be,diffuseConstant:be,direction:null,display:null,dur:null,divisor:be,dominantBaseline:null,download:ze,dx:null,dy:null,edgeMode:null,editable:null,elevation:be,enableBackground:null,end:null,event:null,exponent:be,externalResourcesRequired:null,fill:null,fillOpacity:be,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:Cr,g2:Cr,glyphName:Cr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:be,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:be,horizOriginX:be,horizOriginY:be,id:null,ideographic:be,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:be,k:be,k1:be,k2:be,k3:be,k4:be,kernelMatrix:On,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:be,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:be,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:be,overlineThickness:be,paintOrder:null,panose1:null,path:null,pathLength:be,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ot,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:be,pointsAtY:be,pointsAtZ:be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:On,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:On,rev:On,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:On,requiredFeatures:On,requiredFonts:On,requiredFormats:On,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:be,specularExponent:be,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:be,strikethroughThickness:be,string:null,stroke:null,strokeDashArray:On,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:be,strokeOpacity:be,strokeWidth:null,style:null,surfaceScale:be,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:On,tabIndex:be,tableValues:null,target:null,targetX:be,targetY:be,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:On,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:be,underlineThickness:be,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:be,values:null,vAlphabetic:be,vMathematical:be,vectorEffect:null,vHanging:be,vIdeographic:be,version:null,vertAdvY:be,vertOriginX:be,vertOriginY:be,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:be,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:dA}),hA=Za({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),pA=Za({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:fA}),mA=Za({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),JL={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"},ZL=/[A-Z]/g,Y1=/-[a-z]/g,WL=/^data[-\w.:]+$/i;function e8(t,e){const n=Nm(e);let i=e,a=Tn;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&WL.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(Y1,n8);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!Y1.test(o)){let u=o.replace(ZL,t8);u.charAt(0)!=="-"&&(u="-"+u),e="data"+u}}a=Zg}return new a(i,e)}function t8(t){return"-"+t.toLowerCase()}function n8(t){return t.charAt(1).toUpperCase()}const s8=uA([cA,KL,hA,pA,mA],"html"),Wg=uA([cA,XL,hA,pA,mA],"svg");function i8(t){return t.join(" ").trim()}var ka={},Cp,Q1;function r8(){if(Q1)return Cp;Q1=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,d=/^\s+|\s+$/g,f=`
18
- `,p="/",m="*",y="",v="comment",b="declaration";function T(x,E){if(typeof x!="string")throw new TypeError("First argument must be a string");if(!x)return[];E=E||{};var C=1,R=1;function O(X){var Z=X.match(e);Z&&(C+=Z.length);var ee=X.lastIndexOf(f);R=~ee?X.length-ee:R+X.length}function L(){var X={line:C,column:R};return function(Z){return Z.position=new I(X),H(),Z}}function I(X){this.start=X,this.end={line:C,column:R},this.source=E.source}I.prototype.content=x;function P(X){var Z=new Error(E.source+":"+C+":"+R+": "+X);if(Z.reason=X,Z.filename=E.source,Z.line=C,Z.column=R,Z.source=x,!E.silent)throw Z}function k(X){var Z=X.exec(x);if(Z){var ee=Z[0];return O(ee),x=x.slice(ee.length),Z}}function H(){k(n)}function V(X){var Z;for(X=X||[];Z=z();)Z!==!1&&X.push(Z);return X}function z(){var X=L();if(!(p!=x.charAt(0)||m!=x.charAt(1))){for(var Z=2;y!=x.charAt(Z)&&(m!=x.charAt(Z)||p!=x.charAt(Z+1));)++Z;if(Z+=2,y===x.charAt(Z-1))return P("End of comment missing");var ee=x.slice(2,Z-2);return R+=2,O(ee),x=x.slice(Z),R+=2,X({type:v,comment:ee})}}function q(){var X=L(),Z=k(i);if(Z){if(z(),!k(a))return P("property missing ':'");var ee=k(o),oe=X({type:b,property:w(Z[0].replace(t,y)),value:ee?w(ee[0].replace(t,y)):y});return k(u),oe}}function W(){var X=[];V(X);for(var Z;Z=q();)Z!==!1&&(X.push(Z),V(X));return X}return H(),W()}function w(x){return x?x.replace(d,y):y}return Cp=T,Cp}var K1;function a8(){if(K1)return ka;K1=1;var t=ka&&ka.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(ka,"__esModule",{value:!0}),ka.default=n;const e=t(r8());function n(i,a){let o=null;if(!i||typeof i!="string")return o;const u=(0,e.default)(i),d=typeof a=="function";return u.forEach(f=>{if(f.type!=="declaration")return;const{property:p,value:m}=f;d?a(p,m,f):m&&(o=o||{},o[p]=m)}),o}return ka}var Wo={},X1;function o8(){if(X1)return Wo;X1=1,Object.defineProperty(Wo,"__esModule",{value:!0}),Wo.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(p){return!p||n.test(p)||t.test(p)},u=function(p,m){return m.toUpperCase()},d=function(p,m){return"".concat(m,"-")},f=function(p,m){return m===void 0&&(m={}),o(p)?p:(p=p.toLowerCase(),m.reactCompat?p=p.replace(a,d):p=p.replace(i,d),p.replace(e,u))};return Wo.camelCase=f,Wo}var el,J1;function l8(){if(J1)return el;J1=1;var t=el&&el.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},e=t(a8()),n=o8();function i(a,o){var u={};return!a||typeof a!="string"||(0,e.default)(a,function(d,f){d&&f&&(u[(0,n.camelCase)(d,o)]=f)}),u}return i.default=i,el=i,el}var u8=l8();const c8=xl(u8),gA=yA("end"),ey=yA("start");function yA(t){return e;function e(n){const i=n&&n.position&&n.position[t]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function d8(t){const e=ey(t),n=gA(t);if(e&&n)return{start:e,end:n}}function pl(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?Z1(t.position):"start"in t||"end"in t?Z1(t):"line"in t||"column"in t?jm(t):""}function jm(t){return W1(t&&t.line)+":"+W1(t&&t.column)}function Z1(t){return jm(t&&t.start)+"-"+jm(t&&t.end)}function W1(t){return t&&typeof t=="number"?t:1}class Zt extends Error{constructor(e,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let a="",o={},u=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof e=="string"?a=e:!o.cause&&e&&(u=!0,a=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof i=="string"){const f=i.indexOf(":");f===-1?o.ruleId=i:(o.source=i.slice(0,f),o.ruleId=i.slice(f+1))}if(!o.place&&o.ancestors&&o.ancestors){const f=o.ancestors[o.ancestors.length-1];f&&(o.place=f.position)}const d=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=d?d.line:void 0,this.name=pl(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=u&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Zt.prototype.file="";Zt.prototype.name="";Zt.prototype.reason="";Zt.prototype.message="";Zt.prototype.stack="";Zt.prototype.column=void 0;Zt.prototype.line=void 0;Zt.prototype.ancestors=void 0;Zt.prototype.cause=void 0;Zt.prototype.fatal=void 0;Zt.prototype.place=void 0;Zt.prototype.ruleId=void 0;Zt.prototype.source=void 0;const ty={}.hasOwnProperty,f8=new Map,h8=/[A-Z]/g,p8=new Set(["table","tbody","thead","tfoot","tr"]),m8=new Set(["td","th"]),vA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function g8(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let i;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=x8(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=w8(n,e.jsx,e.jsxs)}const a={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:i,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?Wg:s8,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},o=bA(a,t,void 0);return o&&typeof o!="string"?o:a.create(t,a.Fragment,{children:o||void 0},void 0)}function bA(t,e,n){if(e.type==="element")return y8(t,e,n);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return v8(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return _8(t,e,n);if(e.type==="mdxjsEsm")return b8(t,e);if(e.type==="root")return S8(t,e,n);if(e.type==="text")return T8(t,e)}function y8(t,e,n){const i=t.schema;let a=i;e.tagName.toLowerCase()==="svg"&&i.space==="html"&&(a=Wg,t.schema=a),t.ancestors.push(e);const o=SA(t,e.tagName,!1),u=C8(t,e);let d=sy(t,e);return p8.has(e.tagName)&&(d=d.filter(function(f){return typeof f=="string"?!YL(f):!0})),_A(t,u,o,e),ny(u,d),t.ancestors.pop(),t.schema=i,t.create(e,o,u,n)}function v8(t,e){if(e.data&&e.data.estree&&t.evaluater){const i=e.data.estree.body[0];return i.type,t.evaluater.evaluateExpression(i.expression)}wl(t,e.position)}function b8(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);wl(t,e.position)}function _8(t,e,n){const i=t.schema;let a=i;e.name==="svg"&&i.space==="html"&&(a=Wg,t.schema=a),t.ancestors.push(e);const o=e.name===null?t.Fragment:SA(t,e.name,!0),u=E8(t,e),d=sy(t,e);return _A(t,u,o,e),ny(u,d),t.ancestors.pop(),t.schema=i,t.create(e,o,u,n)}function S8(t,e,n){const i={};return ny(i,sy(t,e)),t.create(e,t.Fragment,i,n)}function T8(t,e){return e.value}function _A(t,e,n,i){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=i)}function ny(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function w8(t,e,n){return i;function i(a,o,u,d){const p=Array.isArray(u.children)?n:e;return d?p(o,u,d):p(o,u)}}function x8(t,e){return n;function n(i,a,o,u){const d=Array.isArray(o.children),f=ey(i);return e(a,o,u,d,{columnNumber:f?f.column-1:void 0,fileName:t,lineNumber:f?f.line:void 0},void 0)}}function C8(t,e){const n={};let i,a;for(a in e.properties)if(a!=="children"&&ty.call(e.properties,a)){const o=A8(t,a,e.properties[a]);if(o){const[u,d]=o;t.tableCellAlignToStyle&&u==="align"&&typeof d=="string"&&m8.has(e.tagName)?i=d:n[u]=d}}if(i){const o=n.style||(n.style={});o[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function E8(t,e){const n={};for(const i of e.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&t.evaluater){const o=i.data.estree.body[0];o.type;const u=o.expression;u.type;const d=u.properties[0];d.type,Object.assign(n,t.evaluater.evaluateExpression(d.argument))}else wl(t,e.position);else{const a=i.name;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&t.evaluater){const d=i.value.data.estree.body[0];d.type,o=t.evaluater.evaluateExpression(d.expression)}else wl(t,e.position);else o=i.value===null?!0:i.value;n[a]=o}return n}function sy(t,e){const n=[];let i=-1;const a=t.passKeys?new Map:f8;for(;++i<e.children.length;){const o=e.children[i];let u;if(t.passKeys){const f=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(f){const p=a.get(f)||0;u=f+"-"+p,a.set(f,p+1)}}const d=bA(t,o,u);d!==void 0&&n.push(d)}return n}function A8(t,e,n){const i=e8(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?HL(n):i8(n)),i.property==="style"){let a=typeof n=="object"?n:I8(t,String(n));return t.stylePropertyNameCase==="css"&&(a=R8(a)),["style",a]}return[t.elementAttributeNameCase==="react"&&i.space?JL[i.property]||i.property:i.attribute,n]}}function I8(t,e){try{return c8(e,{reactCompat:!0})}catch(n){if(t.ignoreInvalidStyle)return{};const i=n,a=new Zt("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=t.filePath||void 0,a.url=vA+"#cannot-parse-style-attribute",a}}function SA(t,e,n){let i;if(!n)i={type:"Literal",value:e};else if(e.includes(".")){const a=e.split(".");let o=-1,u;for(;++o<a.length;){const d=$1(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};u=u?{type:"MemberExpression",object:u,property:d,computed:!!(o&&d.type==="Literal"),optional:!1}:d}i=u}else i=$1(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(i.type==="Literal"){const a=i.value;return ty.call(t.components,a)?t.components[a]:a}if(t.evaluater)return t.evaluater.evaluateExpression(i);wl(t)}function wl(t,e){const n=new Zt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=vA+"#cannot-handle-mdx-estrees-without-createevaluater",n}function R8(t){const e={};let n;for(n in t)ty.call(t,n)&&(e[M8(n)]=t[n]);return e}function M8(t){let e=t.replace(h8,k8);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function k8(t){return"-"+t.toLowerCase()}const Ep={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"]},N8={};function O8(t,e){const n=N8,i=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return TA(t,i,a)}function TA(t,e,n){if(D8(t)){if("value"in t)return t.type==="html"&&!n?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return eT(t.children,e,n)}return Array.isArray(t)?eT(t,e,n):""}function eT(t,e,n){const i=[];let a=-1;for(;++a<t.length;)i[a]=TA(t[a],e,n);return i.join("")}function D8(t){return!!(t&&typeof t=="object")}const tT=document.createElement("i");function iy(t){const e="&"+t+";";tT.innerHTML=e;const n=tT.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function Vi(t,e,n,i){const a=t.length;let o=0,u;if(e<0?e=-e>a?0:a+e:e=e>a?a:e,n=n>0?n:0,i.length<1e4)u=Array.from(i),u.unshift(e,n),t.splice(...u);else for(n&&t.splice(e,n);o<i.length;)u=i.slice(o,o+1e4),u.unshift(e,0),t.splice(...u),o+=1e4,e+=1e4}function Xn(t,e){return t.length>0?(Vi(t,t.length,0,e),t):e}const nT={}.hasOwnProperty;function j8(t){const e={};let n=-1;for(;++n<t.length;)z8(e,t[n]);return e}function z8(t,e){let n;for(n in e){const a=(nT.call(t,n)?t[n]:void 0)||(t[n]={}),o=e[n];let u;if(o)for(u in o){nT.call(a,u)||(a[u]=[]);const d=o[u];P8(a[u],Array.isArray(d)?d:d?[d]:[])}}}function P8(t,e){let n=-1;const i=[];for(;++n<e.length;)(e[n].add==="after"?t:i).push(e[n]);Vi(t,0,0,i)}function wA(t,e){const n=Number.parseInt(t,e);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 Ba(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ms=$i(/[A-Za-z]/),zn=$i(/[\dA-Za-z]/),B8=$i(/[#-'*+\--9=?A-Z^-~]/);function zm(t){return t!==null&&(t<32||t===127)}const Pm=$i(/\d/),U8=$i(/[\dA-Fa-f]/),L8=$i(/[!-/:-@[-`{-~]/);function je(t){return t!==null&&t<-2}function _n(t){return t!==null&&(t<0||t===32)}function Ke(t){return t===-2||t===-1||t===32}const q8=$i(new RegExp("\\p{P}|\\p{S}","u")),H8=$i(/\s/);function $i(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function Wa(t){const e=[];let n=-1,i=0,a=0;for(;++n<t.length;){const o=t.charCodeAt(n);let u="";if(o===37&&zn(t.charCodeAt(n+1))&&zn(t.charCodeAt(n+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(u=String.fromCharCode(o));else if(o>55295&&o<57344){const d=t.charCodeAt(n+1);o<56320&&d>56319&&d<57344?(u=String.fromCharCode(o,d),a=1):u="�"}else u=String.fromCharCode(o);u&&(e.push(t.slice(i,n),encodeURIComponent(u)),i=n+a+1,u=""),a&&(n+=a,a=0)}return e.join("")+t.slice(i)}function gt(t,e,n,i){const a=i?i-1:1/0;let o=0;return u;function u(f){return Ke(f)?(t.enter(n),d(f)):e(f)}function d(f){return Ke(f)&&o++<a?(t.consume(f),d):(t.exit(n),e(f))}}function xA(t,e,n,i,a,o){let u=0;return d;function d(m){return Ke(m)?(t.enter(i),f(m)):p(m)}function f(m){return Ke(m)&&u<o?(t.consume(m),u++,f):(t.exit(i),p(m))}function p(m){return u>=a?e(m):n(m)}}const V8={tokenize:$8};function $8(t){const e=t.attempt(this.parser.constructs.contentInitial,i,a);let n;return e;function i(d){if(d===null){t.consume(d);return}return t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),gt(t,e,"linePrefix")}function a(d){return t.enter("paragraph"),o(d)}function o(d){const f=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=f),n=f,u(d)}function u(d){if(d===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(d);return}return je(d)?(t.consume(d),t.exit("chunkText"),o):(t.consume(d),u)}}class Jc{constructor(){this.index=new Map,this.map=[]}add(e,n,i){sT(this,e,n,i,!1)}addBefore(e,n,i){sT(this,e,n,i,!0)}consume(e){if(this.map.sort(function(o,u){return o[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const i=[];for(;n>0;)n-=1,i.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];i.push(e.slice()),e.length=0;let a=i.pop();for(;a;){for(const o of a)e.push(o);a=i.pop()}this.map.length=0,this.index.clear()}}function sT(t,e,n,i,a){if(n===0&&i.length===0)return;const o=t.index.get(e);if(o){o[1]+=n,a?(i.push(...o[2]),o[2]=i):o[2].push(...i);return}const u=[e,n,i];t.map.push(u),t.index.set(e,u)}const G8={tokenize:F8},iT={tokenize:Y8};function F8(t){const e=this,n=[];let i=0,a,o,u;return d;function d(R){if(i<n.length){const O=n[i];return e.containerState=O[1],t.attempt(O[0].continuation,f,p)(R)}return p(R)}function f(R){if(i++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,a&&C();const O=e.events.length;let L=O,I;for(;L--;)if(e.events[L][0]==="exit"&&e.events[L][1].type==="chunkFlow"){I=e.events[L][1].end;break}E(i);let P=O;for(;P<e.events.length;)e.events[P][1].end={...I},P++;const k=new Jc;return k.add(L+1,0,e.events.slice(O)),k.add(O,P-O,[]),k.consume(e.events),p(R)}return d(R)}function p(R){if(i===n.length){if(!a)return v(R);if(a.currentConstruct&&a.currentConstruct.concrete)return T(R);e.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(iT,m,y)(R)}function m(R){return a&&C(),E(i),v(R)}function y(R){return e.parser.lazy[e.now().line]=i!==n.length,u=e.now().offset,T(R)}function v(R){return e.containerState={},t.attempt(iT,b,T)(R)}function b(R){return i++,n.push([e.currentConstruct,e.containerState]),v(R)}function T(R){if(R===null){a&&C(),E(0),t.consume(R);return}return a=a||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),w(R)}function w(R){if(R===null){x(t.exit("chunkFlow"),!0),E(0),t.consume(R);return}return je(R)?(t.consume(R),x(t.exit("chunkFlow")),i=0,e.interrupt=void 0,d):(t.consume(R),w)}function x(R,O){const L=e.sliceStream(R);if(O&&L.push(null),R.previous=o,o&&(o.next=R),o=R,a.defineSkip(R.start),a.write(L),e.parser.lazy[R.start.line]){let I=a.events.length;for(;I--;)if(a.events[I][1].start.offset<u&&(!a.events[I][1].end||a.events[I][1].end.offset>u))return;const P=e.events.length;let k=P,H,V;for(;k--;)if(e.events[k][0]==="exit"&&e.events[k][1].type==="chunkFlow"){if(H){V=e.events[k][1].end;break}H=!0}for(E(i),I=P;I<e.events.length;)e.events[I][1].end={...V},I++;const z=new Jc;z.add(k+1,0,e.events.slice(P)),z.add(P,I-P,[]),z.consume(e.events)}}function E(R){let O=n.length;for(;O-- >R;){const L=n[O];e.containerState=L[1],L[0].exit.call(e,t)}n.length=R}function C(){a.write([null]),o=void 0,a=void 0,e.containerState._closeFlow=void 0}}function Y8(t,e,n){return gt(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function rT(t){if(t===null||_n(t)||H8(t))return 1;if(q8(t))return 2}function ry(t,e,n){const i=[];let a=-1;for(;++a<t.length;){const o=t[a].resolveAll;o&&!i.includes(o)&&(e=o(e,n),i.push(o))}return e}const Bm={name:"attention",resolveAll:Q8,tokenize:K8};function Q8(t,e){let n=-1,i;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){let a=n;for(;a--;)if(t[a][0]==="exit"&&t[a][1].type==="attentionSequence"&&t[a][1]._open&&e.sliceSerialize(t[a][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[a][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[a][1].end.offset-t[a][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;const o=t[a][1].end.offset-t[a][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1,u={...t[a][1].end},d={...t[n][1].start};aT(u,-o),aT(d,o);const f={type:o>1?"strongSequence":"emphasisSequence",start:u,end:{...t[a][1].end}},p={type:o>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:d},m={type:o>1?"strongText":"emphasisText",start:{...t[a][1].end},end:{...t[n][1].start}},y={type:o>1?"strong":"emphasis",start:{...f.start},end:{...p.end}};t[a][1].end={...f.start},t[n][1].start={...p.end},i=[],t[a][1].end.offset-t[a][1].start.offset&&(i=Xn(i,[["enter",t[a][1],e],["exit",t[a][1],e]])),i=Xn(i,[["enter",y,e],["enter",f,e],["exit",f,e],["enter",m,e]]),i=Xn(i,ry(e.parser.constructs.insideSpan.null,t.slice(a+1,n),e)),i=Xn(i,[["exit",m,e],["enter",p,e],["exit",p,e],["exit",y,e]]);let v=0;t[n][1].end.offset-t[n][1].start.offset&&(v=2,i=Xn(i,[["enter",t[n][1],e],["exit",t[n][1],e]])),Vi(t,a-1,n-a+3,i),n=a+i.length-v-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function K8(t,e){const n=this.parser.constructs.attentionMarkers.null,i=this.previous,a=rT(i);let o;return u;function u(f){return o=f,t.enter("attentionSequence"),d(f)}function d(f){if(f===o)return t.consume(f),d;const p=t.exit("attentionSequence"),m=rT(f),y=!m||m===2&&a||n.includes(f)&&f!==42&&f!==95,v=!a||a===2&&m||n.includes(i)&&i!==42&&i!==95;return p._open=!!(o===42?y:y&&(a||!v)),p._close=!!(o===42?v:v&&(m||!y)),e(f)}}function aT(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const X8={name:"autolink",tokenize:J8};function J8(t,e,n){let i=0;return a;function a(b){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(b),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),o}function o(b){return Ms(b)?(t.consume(b),u):b===64?n(b):p(b)}function u(b){return b===43||b===45||b===46||zn(b)?(i=1,d(b)):p(b)}function d(b){return b===58?(t.consume(b),i=0,f):(b===43||b===45||b===46||zn(b))&&i++<32?(t.consume(b),d):(i=0,p(b))}function f(b){return b===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(b),t.exit("autolinkMarker"),t.exit("autolink"),e):b===null||b===32||b===60||zm(b)?n(b):(t.consume(b),f)}function p(b){return b===64?(t.consume(b),m):B8(b)?(t.consume(b),p):n(b)}function m(b){return zn(b)?y(b):n(b)}function y(b){return b===46?(t.consume(b),i=0,m):b===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(b),t.exit("autolinkMarker"),t.exit("autolink"),e):v(b)}function v(b){if((b===45||zn(b))&&i++<63){const T=b===45?v:y;return t.consume(b),T}return n(b)}}const yd={partial:!0,tokenize:Z8};function Z8(t,e,n){return i;function i(o){return Ke(o)?gt(t,a,"linePrefix")(o):a(o)}function a(o){return o===null||je(o)?e(o):n(o)}}const CA={continuation:{tokenize:e7},exit:t7,name:"blockQuote",tokenize:W8};function W8(t,e,n){const i=this;return a;function a(u){if(u===62){const d=i.containerState;return d.open||(t.enter("blockQuote",{_container:!0}),d.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(u),t.exit("blockQuoteMarker"),o}return n(u)}function o(u){return Ke(u)?(t.enter("blockQuotePrefixWhitespace"),t.consume(u),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(u))}}function e7(t,e,n){const i=this;return a;function a(u){return Ke(u)?gt(t,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):o(u)}function o(u){return t.attempt(CA,e,n)(u)}}function t7(t){t.exit("blockQuote")}const EA={name:"characterEscape",tokenize:n7};function n7(t,e,n){return i;function i(o){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(o),t.exit("escapeMarker"),a}function a(o){return L8(o)?(t.enter("characterEscapeValue"),t.consume(o),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(o)}}const AA={name:"characterReference",tokenize:s7};function s7(t,e,n){const i=this;let a=0,o,u;return d;function d(y){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(y),t.exit("characterReferenceMarker"),f}function f(y){return y===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(y),t.exit("characterReferenceMarkerNumeric"),p):(t.enter("characterReferenceValue"),o=31,u=zn,m(y))}function p(y){return y===88||y===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(y),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),o=6,u=U8,m):(t.enter("characterReferenceValue"),o=7,u=Pm,m(y))}function m(y){if(y===59&&a){const v=t.exit("characterReferenceValue");return u===zn&&!iy(i.sliceSerialize(v))?n(y):(t.enter("characterReferenceMarker"),t.consume(y),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return u(y)&&a++<o?(t.consume(y),m):n(y)}}const Um={partial:!0,tokenize:i7};function i7(t,e,n){const i=this;return a;function a(u){return u===null?n(u):(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),o)}function o(u){return i.parser.lazy[i.now().line]?n(u):e(u)}}const oT={concrete:!0,name:"codeFenced",tokenize:r7};function r7(t,e,n){const i=this,a={partial:!0,tokenize:L};let o=0,u=0,d;return f;function f(I){return p(I)}function p(I){const P=i.events[i.events.length-1];return o=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,d=I,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),m(I)}function m(I){return I===d?(u++,t.consume(I),m):u<3?n(I):(t.exit("codeFencedFenceSequence"),Ke(I)?gt(t,y,"whitespace")(I):y(I))}function y(I){return I===null||je(I)?(t.exit("codeFencedFence"),i.interrupt?e(I):t.check(Um,w,O)(I)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),v(I))}function v(I){return I===null||je(I)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),y(I)):Ke(I)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),gt(t,b,"whitespace")(I)):I===96&&I===d?n(I):(t.consume(I),v)}function b(I){return I===null||je(I)?y(I):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),T(I))}function T(I){return I===null||je(I)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),y(I)):I===96&&I===d?n(I):(t.consume(I),T)}function w(I){return t.attempt(a,O,x)(I)}function x(I){return t.enter("lineEnding"),t.consume(I),t.exit("lineEnding"),E}function E(I){return o>0&&Ke(I)?gt(t,C,"linePrefix",o+1)(I):C(I)}function C(I){return I===null||je(I)?t.check(Um,w,O)(I):(t.enter("codeFlowValue"),R(I))}function R(I){return I===null||je(I)?(t.exit("codeFlowValue"),C(I)):(t.consume(I),R)}function O(I){return t.exit("codeFenced"),e(I)}function L(I,P,k){let H=0;return V;function V(Z){return I.enter("lineEnding"),I.consume(Z),I.exit("lineEnding"),z}function z(Z){return I.enter("codeFencedFence"),Ke(Z)?gt(I,q,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):q(Z)}function q(Z){return Z===d?(I.enter("codeFencedFenceSequence"),W(Z)):k(Z)}function W(Z){return Z===d?(H++,I.consume(Z),W):H>=u?(I.exit("codeFencedFenceSequence"),Ke(Z)?gt(I,X,"whitespace")(Z):X(Z)):k(Z)}function X(Z){return Z===null||je(Z)?(I.exit("codeFencedFence"),P(Z)):k(Z)}}}const Ap={name:"codeIndented",tokenize:o7},a7={partial:!0,tokenize:l7};function o7(t,e,n){return i;function i(d){return t.enter("codeIndented"),xA(t,a,n,"linePrefix",4,4)(d)}function a(d){return d===null?u(d):je(d)?t.attempt(a7,a,u)(d):(t.enter("codeFlowValue"),o(d))}function o(d){return d===null||je(d)?(t.exit("codeFlowValue"),a(d)):(t.consume(d),o)}function u(d){return t.exit("codeIndented"),e(d)}}function l7(t,e,n){const i=this;return a;function a(u){return i.parser.lazy[i.now().line]?n(u):je(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),a):xA(t,e,o,"linePrefix",4,4)(u)}function o(u){return je(u)?a(u):n(u)}}const u7={name:"codeText",previous:d7,resolve:c7,tokenize:f7};function c7(t){let e=t.length-4,n=3,i,a;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(i=n;++i<e;)if(t[i][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(i=n-1,e++;++i<=e;)a===void 0?i!==e&&t[i][1].type!=="lineEnding"&&(a=i):(i===e||t[i][1].type==="lineEnding")&&(t[a][1].type="codeTextData",i!==a+2&&(t[a][1].end=t[i-1][1].end,t.splice(a+2,i-a-2),e-=i-a-2,i=a+2),a=void 0);return t}function d7(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function f7(t,e,n){let i=0,a,o;return u;function u(y){return t.enter("codeText"),t.enter("codeTextSequence"),d(y)}function d(y){return y===96?(t.consume(y),i++,d):(t.exit("codeTextSequence"),f(y))}function f(y){return y===null?n(y):y===32?(t.enter("space"),t.consume(y),t.exit("space"),f):y===96?(o=t.enter("codeTextSequence"),a=0,m(y)):je(y)?(t.enter("lineEnding"),t.consume(y),t.exit("lineEnding"),f):(t.enter("codeTextData"),p(y))}function p(y){return y===null||y===32||y===96||je(y)?(t.exit("codeTextData"),f(y)):(t.consume(y),p)}function m(y){return y===96?(t.consume(y),a++,m):a===i?(t.exit("codeTextSequence"),t.exit("codeText"),e(y)):(o.type="codeTextData",p(y))}}class h7{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new 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,n){const i=n??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(e,i):e>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,n,i){const a=n||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return i&&tl(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),tl(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),tl(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){const n=this.left.splice(e,Number.POSITIVE_INFINITY);tl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);tl(this.left,n.reverse())}}}function tl(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function IA(t){const e={};let n=-1,i,a,o,u,d,f,p;const m=new h7(t);for(;++n<m.length;){for(;n in e;)n=e[n];if(i=m.get(n),n&&i[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(f=i[1]._tokenizer.events,o=0,o<f.length&&f[o][1].type==="lineEndingBlank"&&(o+=2),o<f.length&&f[o][1].type==="content"))for(;++o<f.length&&f[o][1].type!=="content";)f[o][1].type==="chunkText"&&(f[o][1]._isInFirstContentOfListItem=!0,o++);if(i[0]==="enter")i[1].contentType&&(Object.assign(e,p7(m,n)),n=e[n],p=!0);else if(i[1]._container){for(o=n,a=void 0;o--;)if(u=m.get(o),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(m.get(a)[1].type="lineEndingBlank"),u[1].type="lineEnding",a=o);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;a&&(i[1].end={...m.get(a)[1].start},d=m.slice(a,n),d.unshift(i),m.splice(a,n-a+1,d))}}return Vi(t,0,Number.POSITIVE_INFINITY,m.slice(0)),!p}function p7(t,e){const n=t.get(e)[1],i=t.get(e)[2];let a=e-1;const o=[];let u=n._tokenizer;u||(u=i.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const d=u.events,f=[],p={};let m,y,v=-1,b=n,T=0,w=0;const x=[w];for(;b;){for(;t.get(++a)[1]!==b;);o.push(a),b._tokenizer||(m=i.sliceStream(b),b.next||m.push(null),y&&u.defineSkip(b.start),b._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(m),b._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),y=b,b=b.next}for(b=n;++v<d.length;)d[v][0]==="exit"&&d[v-1][0]==="enter"&&d[v][1].type===d[v-1][1].type&&d[v][1].start.line!==d[v][1].end.line&&(w=v+1,x.push(w),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(u.events=[],b?(b._tokenizer=void 0,b.previous=void 0):x.pop(),v=x.length;v--;){const E=d.slice(x[v],x[v+1]),C=o.pop();f.push([C,C+E.length-1]),t.splice(C,2,E)}for(f.reverse(),v=-1;++v<f.length;)p[T+f[v][0]]=T+f[v][1],T+=f[v][1]-f[v][0]-1;return p}const m7={resolve:y7,tokenize:v7},g7={partial:!0,tokenize:b7};function y7(t){return IA(t),t}function v7(t,e){let n;return i;function i(d){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),a(d)}function a(d){return d===null?o(d):je(d)?t.check(g7,u,o)(d):(t.consume(d),a)}function o(d){return t.exit("chunkContent"),t.exit("content"),e(d)}function u(d){return t.consume(d),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function b7(t,e,n){const i=this;return a;function a(u){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),gt(t,o,"linePrefix")}function o(u){if(u===null||je(u))return n(u);const d=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?e(u):t.interrupt(i.parser.constructs.flow,n,e)(u)}}function RA(t,e,n,i,a,o,u,d,f){const p=f||Number.POSITIVE_INFINITY;let m=0;return y;function y(E){return E===60?(t.enter(i),t.enter(a),t.enter(o),t.consume(E),t.exit(o),v):E===null||E===32||E===41||zm(E)?n(E):(t.enter(i),t.enter(u),t.enter(d),t.enter("chunkString",{contentType:"string"}),w(E))}function v(E){return E===62?(t.enter(o),t.consume(E),t.exit(o),t.exit(a),t.exit(i),e):(t.enter(d),t.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===62?(t.exit("chunkString"),t.exit(d),v(E)):E===null||E===60||je(E)?n(E):(t.consume(E),E===92?T:b)}function T(E){return E===60||E===62||E===92?(t.consume(E),b):b(E)}function w(E){return!m&&(E===null||E===41||_n(E))?(t.exit("chunkString"),t.exit(d),t.exit(u),t.exit(i),e(E)):m<p&&E===40?(t.consume(E),m++,w):E===41?(t.consume(E),m--,w):E===null||E===32||E===40||zm(E)?n(E):(t.consume(E),E===92?x:w)}function x(E){return E===40||E===41||E===92?(t.consume(E),w):w(E)}}function MA(t,e,n,i,a,o){const u=this;let d=0,f;return p;function p(b){return t.enter(i),t.enter(a),t.consume(b),t.exit(a),t.enter(o),m}function m(b){return d>999||b===null||b===91||b===93&&!f||b===94&&!d&&"_hiddenFootnoteSupport"in u.parser.constructs?n(b):b===93?(t.exit(o),t.enter(a),t.consume(b),t.exit(a),t.exit(i),e):je(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),m):(t.enter("chunkString",{contentType:"string"}),y(b))}function y(b){return b===null||b===91||b===93||je(b)||d++>999?(t.exit("chunkString"),m(b)):(t.consume(b),f||(f=!Ke(b)),b===92?v:y)}function v(b){return b===91||b===92||b===93?(t.consume(b),d++,y):y(b)}}function kA(t,e,n,i,a,o){let u;return d;function d(v){return v===34||v===39||v===40?(t.enter(i),t.enter(a),t.consume(v),t.exit(a),u=v===40?41:v,f):n(v)}function f(v){return v===u?(t.enter(a),t.consume(v),t.exit(a),t.exit(i),e):(t.enter(o),p(v))}function p(v){return v===u?(t.exit(o),f(u)):v===null?n(v):je(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),gt(t,p,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),m(v))}function m(v){return v===u||v===null||je(v)?(t.exit("chunkString"),p(v)):(t.consume(v),v===92?y:m)}function y(v){return v===u||v===92?(t.consume(v),m):m(v)}}function ml(t,e){let n;return i;function i(a){return je(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),n=!0,i):Ke(a)?gt(t,i,n?"linePrefix":"lineSuffix")(a):e(a)}}const _7={name:"definition",tokenize:T7},S7={partial:!0,tokenize:w7};function T7(t,e,n){const i=this;let a;return o;function o(b){return t.enter("definition"),u(b)}function u(b){return MA.call(i,t,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function d(b){return a=Ba(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),b===58?(t.enter("definitionMarker"),t.consume(b),t.exit("definitionMarker"),f):n(b)}function f(b){return _n(b)?ml(t,p)(b):p(b)}function p(b){return RA(t,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return t.attempt(S7,y,y)(b)}function y(b){return Ke(b)?gt(t,v,"whitespace")(b):v(b)}function v(b){return b===null||je(b)?(t.exit("definition"),i.parser.defined.push(a),e(b)):n(b)}}function w7(t,e,n){return i;function i(d){return _n(d)?ml(t,a)(d):n(d)}function a(d){return kA(t,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function o(d){return Ke(d)?gt(t,u,"whitespace")(d):u(d)}function u(d){return d===null||je(d)?e(d):n(d)}}const x7={name:"hardBreakEscape",tokenize:C7};function C7(t,e,n){return i;function i(o){return t.enter("hardBreakEscape"),t.consume(o),a}function a(o){return je(o)?(t.exit("hardBreakEscape"),e(o)):n(o)}}const E7={name:"headingAtx",resolve:A7,tokenize:I7};function A7(t,e){let n=t.length-2,i=3;if(t[i][1].type==="whitespace"&&(i+=2),n-2>i&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&t[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i){const a={type:"atxHeadingText",start:t[i][1].start,end:t[n][1].end},o={type:"chunkText",start:t[i][1].start,end:t[n][1].end,contentType:"text"};Vi(t,i,n-i+1,[["enter",a,e],["enter",o,e],["exit",o,e],["exit",a,e]])}return t}function I7(t,e,n){let i=0;return a;function a(m){return t.enter("atxHeading"),o(m)}function o(m){return t.enter("atxHeadingSequence"),u(m)}function u(m){return m===35&&i++<6?(t.consume(m),u):m===null||_n(m)?(t.exit("atxHeadingSequence"),d(m)):n(m)}function d(m){return m===35?(t.enter("atxHeadingSequence"),f(m)):m===null||je(m)?(t.exit("atxHeading"),e(m)):Ke(m)?gt(t,d,"whitespace")(m):(t.enter("atxHeadingText"),p(m))}function f(m){return m===35?(t.consume(m),f):(t.exit("atxHeadingSequence"),d(m))}function p(m){return m===null||m===35||_n(m)?(t.exit("atxHeadingText"),d(m)):(t.consume(m),p)}}const R7=["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"],lT=["pre","script","style","textarea"],M7={concrete:!0,name:"htmlFlow",resolveTo:N7,tokenize:O7},k7={partial:!0,tokenize:D7};function N7(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function O7(t,e,n){const i=this;let a,o,u,d,f;return p;function p(M){return m(M)}function m(M){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(M),y}function y(M){return M===33?(t.consume(M),v):M===47?(t.consume(M),o=!0,w):M===63?(t.consume(M),a=3,i.interrupt?e:D):Ms(M)?(t.consume(M),u=String.fromCharCode(M),x):n(M)}function v(M){return M===45?(t.consume(M),a=2,b):M===91?(t.consume(M),a=5,d=0,T):Ms(M)?(t.consume(M),a=4,i.interrupt?e:D):n(M)}function b(M){return M===45?(t.consume(M),i.interrupt?e:D):n(M)}function T(M){const N="CDATA[";return M===N.charCodeAt(d++)?(t.consume(M),d===N.length?i.interrupt?e:q:T):n(M)}function w(M){return Ms(M)?(t.consume(M),u=String.fromCharCode(M),x):n(M)}function x(M){if(M===null||M===47||M===62||_n(M)){const N=M===47,te=u.toLowerCase();return!N&&!o&&lT.includes(te)?(a=1,i.interrupt?e(M):q(M)):R7.includes(u.toLowerCase())?(a=6,N?(t.consume(M),E):i.interrupt?e(M):q(M)):(a=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(M):o?C(M):R(M))}return M===45||zn(M)?(t.consume(M),u+=String.fromCharCode(M),x):n(M)}function E(M){return M===62?(t.consume(M),i.interrupt?e:q):n(M)}function C(M){return Ke(M)?(t.consume(M),C):V(M)}function R(M){return M===47?(t.consume(M),V):M===58||M===95||Ms(M)?(t.consume(M),O):Ke(M)?(t.consume(M),R):V(M)}function O(M){return M===45||M===46||M===58||M===95||zn(M)?(t.consume(M),O):L(M)}function L(M){return M===61?(t.consume(M),I):Ke(M)?(t.consume(M),L):R(M)}function I(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(t.consume(M),f=M,P):Ke(M)?(t.consume(M),I):k(M)}function P(M){return M===f?(t.consume(M),f=null,H):M===null||je(M)?n(M):(t.consume(M),P)}function k(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||_n(M)?L(M):(t.consume(M),k)}function H(M){return M===47||M===62||Ke(M)?R(M):n(M)}function V(M){return M===62?(t.consume(M),z):n(M)}function z(M){return M===null||je(M)?q(M):Ke(M)?(t.consume(M),z):n(M)}function q(M){return M===45&&a===2?(t.consume(M),ee):M===60&&a===1?(t.consume(M),oe):M===62&&a===4?(t.consume(M),$):M===63&&a===3?(t.consume(M),D):M===93&&a===5?(t.consume(M),ye):je(M)&&(a===6||a===7)?(t.exit("htmlFlowData"),t.check(k7,re,W)(M)):M===null||je(M)?(t.exit("htmlFlowData"),W(M)):(t.consume(M),q)}function W(M){return t.check(Um,X,re)(M)}function X(M){return t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),Z}function Z(M){return M===null||je(M)?W(M):(t.enter("htmlFlowData"),q(M))}function ee(M){return M===45?(t.consume(M),D):q(M)}function oe(M){return M===47?(t.consume(M),u="",he):q(M)}function he(M){if(M===62){const N=u.toLowerCase();return lT.includes(N)?(t.consume(M),$):q(M)}return Ms(M)&&u.length<8?(t.consume(M),u+=String.fromCharCode(M),he):q(M)}function ye(M){return M===93?(t.consume(M),D):q(M)}function D(M){return M===62?(t.consume(M),$):M===45&&a===2?(t.consume(M),D):q(M)}function $(M){return M===null||je(M)?(t.exit("htmlFlowData"),re(M)):(t.consume(M),$)}function re(M){return t.exit("htmlFlow"),e(M)}}function D7(t,e,n){return i;function i(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),t.attempt(yd,e,n)}}const j7={name:"htmlText",tokenize:z7};function z7(t,e,n){const i=this;let a,o,u;return d;function d(D){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(D),f}function f(D){return D===33?(t.consume(D),p):D===47?(t.consume(D),L):D===63?(t.consume(D),R):Ms(D)?(t.consume(D),k):n(D)}function p(D){return D===45?(t.consume(D),m):D===91?(t.consume(D),o=0,T):Ms(D)?(t.consume(D),C):n(D)}function m(D){return D===45?(t.consume(D),b):n(D)}function y(D){return D===null?n(D):D===45?(t.consume(D),v):je(D)?(u=y,oe(D)):(t.consume(D),y)}function v(D){return D===45?(t.consume(D),b):y(D)}function b(D){return D===62?ee(D):D===45?v(D):y(D)}function T(D){const $="CDATA[";return D===$.charCodeAt(o++)?(t.consume(D),o===$.length?w:T):n(D)}function w(D){return D===null?n(D):D===93?(t.consume(D),x):je(D)?(u=w,oe(D)):(t.consume(D),w)}function x(D){return D===93?(t.consume(D),E):w(D)}function E(D){return D===62?ee(D):D===93?(t.consume(D),E):w(D)}function C(D){return D===null||D===62?ee(D):je(D)?(u=C,oe(D)):(t.consume(D),C)}function R(D){return D===null?n(D):D===63?(t.consume(D),O):je(D)?(u=R,oe(D)):(t.consume(D),R)}function O(D){return D===62?ee(D):R(D)}function L(D){return Ms(D)?(t.consume(D),I):n(D)}function I(D){return D===45||zn(D)?(t.consume(D),I):P(D)}function P(D){return je(D)?(u=P,oe(D)):Ke(D)?(t.consume(D),P):ee(D)}function k(D){return D===45||zn(D)?(t.consume(D),k):D===47||D===62||_n(D)?H(D):n(D)}function H(D){return D===47?(t.consume(D),ee):D===58||D===95||Ms(D)?(t.consume(D),V):je(D)?(u=H,oe(D)):Ke(D)?(t.consume(D),H):ee(D)}function V(D){return D===45||D===46||D===58||D===95||zn(D)?(t.consume(D),V):z(D)}function z(D){return D===61?(t.consume(D),q):je(D)?(u=z,oe(D)):Ke(D)?(t.consume(D),z):H(D)}function q(D){return D===null||D===60||D===61||D===62||D===96?n(D):D===34||D===39?(t.consume(D),a=D,W):je(D)?(u=q,oe(D)):Ke(D)?(t.consume(D),q):(t.consume(D),X)}function W(D){return D===a?(t.consume(D),a=void 0,Z):D===null?n(D):je(D)?(u=W,oe(D)):(t.consume(D),W)}function X(D){return D===null||D===34||D===39||D===60||D===61||D===96?n(D):D===47||D===62||_n(D)?H(D):(t.consume(D),X)}function Z(D){return D===47||D===62||_n(D)?H(D):n(D)}function ee(D){return D===62?(t.consume(D),t.exit("htmlTextData"),t.exit("htmlText"),e):n(D)}function oe(D){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(D),t.exit("lineEnding"),he}function he(D){return Ke(D)?gt(t,ye,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):ye(D)}function ye(D){return t.enter("htmlTextData"),u(D)}}const ay={name:"labelEnd",resolveAll:L7,resolveTo:q7,tokenize:H7},P7={tokenize:V7},B7={tokenize:$7},U7={tokenize:G7};function L7(t){let e=-1;const n=[];for(;++e<t.length;){const i=t[e][1];if(n.push(t[e]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const a=i.type==="labelImage"?4:2;i.type="data",e+=a}}return t.length!==n.length&&Vi(t,0,t.length,n),t}function q7(t,e){let n=t.length,i=0,a,o,u;for(;n--;){const m=t[n][1];if(a){if(m.type==="link"||m.type==="labelLink"&&m._inactive)break;t[n][0]==="enter"&&m.type==="labelLink"&&(m._inactive=!0)}else if(o){if(t[n][0]==="enter"&&(m.type==="labelImage"||m.type==="labelLink")&&!m._balanced&&(a=n,m.type!=="labelLink")){i=2;break}}else m.type==="labelEnd"&&(o=n)}const d={type:t[a][1].type==="labelLink"?"link":"image",start:{...t[a][1].start},end:{...t[t.length-1][1].end}},f={type:"label",start:{...t[a][1].start},end:{...t[o][1].end}},p={type:"labelText",start:{...t[a+i+2][1].end},end:{...t[o-2][1].start}};return u=[["enter",d,e],["enter",f,e]],u=Xn(u,t.slice(a+1,a+i+3)),u=Xn(u,[["enter",p,e]]),u=Xn(u,ry(e.parser.constructs.insideSpan.null,t.slice(a+i+4,o-3),e)),u=Xn(u,[["exit",p,e],t[o-2],t[o-1],["exit",f,e]]),u=Xn(u,t.slice(o+1)),u=Xn(u,[["exit",d,e]]),Vi(t,a,t.length,u),t}function H7(t,e,n){const i=this,a=i._labelStarts;let o,u;if(a){for(;a.length>0&&a[a.length-1]._balanced;)a.pop();o=a[a.length-1]}return d;function d(v){return o?o._inactive?y(v):(u=i.parser.defined.includes(Ba(i.sliceSerialize({start:o.end,end:i.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(v),t.exit("labelMarker"),t.exit("labelEnd"),f):n(v)}function f(v){return v===40?t.attempt(P7,m,u?m:y)(v):v===91?t.attempt(B7,m,u?p:y)(v):u?m(v):y(v)}function p(v){return t.attempt(U7,m,y)(v)}function m(v){return a.pop(),e(v)}function y(v){return o._balanced=!0,n(v)}}function V7(t,e,n){return i;function i(y){return t.enter("resource"),t.enter("resourceMarker"),t.consume(y),t.exit("resourceMarker"),a}function a(y){return _n(y)?ml(t,o)(y):o(y)}function o(y){return y===41?m(y):RA(t,u,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(y)}function u(y){return _n(y)?ml(t,f)(y):m(y)}function d(y){return n(y)}function f(y){return y===34||y===39||y===40?kA(t,p,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(y):m(y)}function p(y){return _n(y)?ml(t,m)(y):m(y)}function m(y){return y===41?(t.enter("resourceMarker"),t.consume(y),t.exit("resourceMarker"),t.exit("resource"),e):n(y)}}function $7(t,e,n){const i=this;return a;function a(d){return MA.call(i,t,o,u,"reference","referenceMarker","referenceString")(d)}function o(d){return i.parser.defined.includes(Ba(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?e(d):n(d)}function u(d){return n(d)}}function G7(t,e,n){return i;function i(o){return t.enter("reference"),t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),a}function a(o){return o===93?(t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),t.exit("reference"),e):n(o)}}const F7={name:"labelStartImage",resolveAll:ay.resolveAll,tokenize:Y7};function Y7(t,e,n){const i=this;let a;return o;function o(f){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(f),t.exit("labelImageMarker"),u}function u(f){return f===91?(t.enter("labelMarker"),t.consume(f),t.exit("labelMarker"),a=t.exit("labelImage"),d):n(f)}function d(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(f):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(a),e(f))}}const Q7={name:"labelStartLink",resolveAll:ay.resolveAll,tokenize:K7};function K7(t,e,n){const i=this;let a;return o;function o(d){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(d),t.exit("labelMarker"),a=t.exit("labelLink"),u}function u(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(d):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(a),e(d))}}const Ip={name:"lineEnding",tokenize:X7};function X7(t,e){return n;function n(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),gt(t,e,"linePrefix")}}const Ic={name:"thematicBreak",tokenize:J7};function J7(t,e,n){let i=0,a;return o;function o(p){return t.enter("thematicBreak"),u(p)}function u(p){return a=p,d(p)}function d(p){return p===a?(t.enter("thematicBreakSequence"),f(p)):i>=3&&(p===null||je(p))?(t.exit("thematicBreak"),e(p)):n(p)}function f(p){return p===a?(t.consume(p),i++,f):(t.exit("thematicBreakSequence"),Ke(p)?gt(t,d,"whitespace")(p):d(p))}}const vn={continuation:{tokenize:t9},exit:s9,name:"list",tokenize:e9},Z7={partial:!0,tokenize:i9},W7={partial:!0,tokenize:n9};function e9(t,e,n){const i=this,a=i.events[i.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return d;function d(b){const T=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(T==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:Pm(b)){if(i.containerState.type||(i.containerState.type=T,t.enter(T,{_container:!0})),T==="listUnordered")return t.enter("listItemPrefix"),b===42||b===45?t.check(Ic,n,p)(b):p(b);if(!i.interrupt||b===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),f(b)}return n(b)}function f(b){return Pm(b)&&++u<10?(t.consume(b),f):(!i.interrupt||u<2)&&(i.containerState.marker?b===i.containerState.marker:b===41||b===46)?(t.exit("listItemValue"),p(b)):n(b)}function p(b){return t.enter("listItemMarker"),t.consume(b),t.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,t.check(yd,i.interrupt?n:m,t.attempt(Z7,v,y))}function m(b){return i.containerState.initialBlankLine=!0,o++,v(b)}function y(b){return Ke(b)?(t.enter("listItemPrefixWhitespace"),t.consume(b),t.exit("listItemPrefixWhitespace"),v):n(b)}function v(b){return i.containerState.size=o+i.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(b)}}function t9(t,e,n){const i=this;return i.containerState._closeFlow=void 0,t.check(yd,a,o);function a(d){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,gt(t,e,"listItemIndent",i.containerState.size+1)(d)}function o(d){return i.containerState.furtherBlankLines||!Ke(d)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,u(d)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,t.attempt(W7,e,u)(d))}function u(d){return i.containerState._closeFlow=!0,i.interrupt=void 0,gt(t,t.attempt(vn,e,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function n9(t,e,n){const i=this;return gt(t,a,"listItemIndent",i.containerState.size+1);function a(o){const u=i.events[i.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===i.containerState.size?e(o):n(o)}}function s9(t){t.exit(this.containerState.type)}function i9(t,e,n){const i=this;return gt(t,a,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const u=i.events[i.events.length-1];return!Ke(o)&&u&&u[1].type==="listItemPrefixWhitespace"?e(o):n(o)}}const uT={name:"setextUnderline",resolveTo:r9,tokenize:a9};function r9(t,e){const n=new Jc;let i=t.length,a,o,u;for(;i--;)if(t[i][0]==="enter"){if(t[i][1].type==="content"){a=i;break}t[i][1].type==="paragraph"&&(o=i)}else t[i][1].type==="content"&&n.add(i,1,[]),!u&&t[i][1].type==="definition"&&(u=i);const d={type:"setextHeading",start:{...t[a][1].start},end:{...t[t.length-1][1].end}};return t[o][1].type="setextHeadingText",u?(n.add(o,0,[["enter",d,e]]),n.add(u+1,0,[["exit",t[a][1],e]]),t[a][1].end={...t[u][1].end}):t[a][1]=d,n.add(t.length,0,[["exit",d,e]]),n.consume(t),t}function a9(t,e,n){const i=this;let a;return o;function o(p){let m=i.events.length,y;for(;m--;)if(i.events[m][1].type!=="lineEnding"&&i.events[m][1].type!=="linePrefix"&&i.events[m][1].type!=="content"){y=i.events[m][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||y)?(t.enter("setextHeadingLine"),a=p,u(p)):n(p)}function u(p){return t.enter("setextHeadingLineSequence"),d(p)}function d(p){return p===a?(t.consume(p),d):(t.exit("setextHeadingLineSequence"),Ke(p)?gt(t,f,"lineSuffix")(p):f(p))}function f(p){return p===null||je(p)?(t.exit("setextHeadingLine"),e(p)):n(p)}}const o9={tokenize:l9};function l9(t){const e=this,n=t.attempt(yd,i,t.attempt(this.parser.constructs.flowInitial,a,gt(t,t.attempt(this.parser.constructs.flow,a,t.attempt(m7,a)),"linePrefix")));return n;function i(o){if(o===null){t.consume(o);return}return t.enter("lineEndingBlank"),t.consume(o),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function a(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const u9={resolveAll:OA()},c9=NA("string"),d9=NA("text");function NA(t){return{resolveAll:OA(t==="text"?f9:void 0),tokenize:e};function e(n){const i=this,a=this.parser.constructs[t],o=n.attempt(a,u,d);return u;function u(m){return p(m)?o(m):d(m)}function d(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),f}function f(m){return p(m)?(n.exit("data"),o(m)):(n.consume(m),f)}function p(m){if(m===null)return!0;const y=a[m];let v=-1;if(y)for(;++v<y.length;){const b=y[v];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function OA(t){return e;function e(n,i){let a=-1,o;for(;++a<=n.length;)o===void 0?n[a]&&n[a][1].type==="data"&&(o=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==o+2&&(n[o][1].end=n[a-1][1].end,n.splice(o+2,a-o-2),a=o+2),o=void 0);return t?t(n,i):n}}function f9(t,e){const n=new Jc;let i=0;for(;++i<=t.length;)if((i===t.length||t[i][1].type==="lineEnding")&&t[i-1][1].type==="data"){const a=t[i-1][1],o=e.sliceStream(a);let u=o.length,d=-1,f=0,p;for(;u--;){const m=o[u];if(typeof m=="string"){for(d=m.length;m.charCodeAt(d-1)===32;)f++,d--;if(d)break;d=-1}else if(m===-2)p=!0,f++;else if(m!==-1){u++;break}}if(e._contentTypeTextTrailing&&i===t.length&&(f=0),f){const m={type:i===t.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:a.start._bufferIndex+d,_index:a.start._index+u,line:a.end.line,column:a.end.column-f,offset:a.end.offset-f},end:{...a.end}};a.end={...m.start},a.start.offset===a.end.offset?Object.assign(a,m):n.add(i,0,[["enter",m,e],["exit",m,e]])}i++}return n.consume(t),t}const h9={42:vn,43:vn,45:vn,48:vn,49:vn,50:vn,51:vn,52:vn,53:vn,54:vn,55:vn,56:vn,57:vn,62:CA},p9={91:_7},m9={[-2]:Ap,[-1]:Ap,32:Ap},g9={35:E7,42:Ic,45:[uT,Ic],60:M7,61:uT,95:Ic,96:oT,126:oT},y9={38:AA,92:EA},v9={[-5]:Ip,[-4]:Ip,[-3]:Ip,33:F7,38:AA,42:Bm,60:[X8,j7],91:Q7,92:[x7,EA],93:ay,95:Bm,96:u7},b9={null:[Bm,u9]},_9={null:[42,95]},S9={null:[]},T9=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:_9,contentInitial:p9,disable:S9,document:h9,flow:g9,flowInitial:m9,insideSpan:b9,string:y9,text:v9},Symbol.toStringTag,{value:"Module"}));function w9(t,e,n){let i={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},o=[];let u=[],d=[];const f={attempt:P(L),check:P(I),consume:C,enter:R,exit:O,interrupt:P(I,{interrupt:!0})},p={code:null,containerState:{},defineSkip:w,events:[],now:T,parser:t,previous:null,sliceSerialize:v,sliceStream:b,write:y};let m=e.tokenize.call(p,f);return e.resolveAll&&o.push(e),p;function y(z){return u=Xn(u,z),x(),u[u.length-1]!==null?[]:(k(e,0),p.events=ry(o,p.events,p),p.events)}function v(z,q){return C9(b(z),q)}function b(z){return x9(u,z)}function T(){const{_bufferIndex:z,_index:q,line:W,column:X,offset:Z}=i;return{_bufferIndex:z,_index:q,line:W,column:X,offset:Z}}function w(z){a[z.line]=z.column,V()}function x(){for(;i._index<u.length;){const z=u[i._index];if(typeof z=="string"){const q=i._index;for(i._bufferIndex<0&&(i._bufferIndex=0);i._index===q&&i._bufferIndex<z.length;)E(z.charCodeAt(i._bufferIndex))}else E(z)}}function E(z){m=m(z)}function C(z){je(z)?(i.line++,i.column=1,i.offset+=z===-3?2:1,V()):z!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===u[i._index].length&&(i._bufferIndex=-1,i._index++)),p.previous=z}function R(z,q){const W=q||{};return W.type=z,W.start=T(),p.events.push(["enter",W,p]),d.push(W),W}function O(z){const q=d.pop();return q.end=T(),p.events.push(["exit",q,p]),q}function L(z,q){k(z,q.from)}function I(z,q){q.restore()}function P(z,q){return W;function W(X,Z,ee){let oe,he,ye,D;return Array.isArray(X)?re(X):"tokenize"in X?re([X]):$(X);function $(ie){return pe;function pe(de){const B=de!==null&&ie[de],ce=de!==null&&ie.null,fe=[...Array.isArray(B)?B:B?[B]:[],...Array.isArray(ce)?ce:ce?[ce]:[]];return re(fe)(de)}}function re(ie){return oe=ie,he=0,ie.length===0?ee:M(ie[he])}function M(ie){return pe;function pe(de){return D=H(),ye=ie,ie.partial||(p.currentConstruct=ie),ie.name&&p.parser.constructs.disable.null.includes(ie.name)?te():ie.tokenize.call(q?Object.assign(Object.create(p),q):p,f,N,te)(de)}}function N(ie){return z(ye,D),Z}function te(ie){return D.restore(),++he<oe.length?M(oe[he]):ee}}}function k(z,q){z.resolveAll&&!o.includes(z)&&o.push(z),z.resolve&&Vi(p.events,q,p.events.length-q,z.resolve(p.events.slice(q),p)),z.resolveTo&&(p.events=z.resolveTo(p.events,p))}function H(){const z=T(),q=p.previous,W=p.currentConstruct,X=p.events.length,Z=Array.from(d);return{from:X,restore:ee};function ee(){i=z,p.previous=q,p.currentConstruct=W,p.events.length=X,d=Z,V()}}function V(){i.line in a&&i.column<2&&(i.column=a[i.line],i.offset+=a[i.line]-1)}}function x9(t,e){const n=e.start._index,i=e.start._bufferIndex,a=e.end._index,o=e.end._bufferIndex;let u;if(n===a)u=[t[n].slice(i,o)];else{if(u=t.slice(n,a),i>-1){const d=u[0];typeof d=="string"?u[0]=d.slice(i):u.shift()}o>0&&u.push(t[a].slice(0,o))}return u}function C9(t,e){let n=-1;const i=[];let a;for(;++n<t.length;){const o=t[n];let u;if(typeof o=="string")u=o;else switch(o){case-5:{u="\r";break}case-4:{u=`
19
- `;break}case-3:{u=`\r
20
- `;break}case-2:{u=e?" ":" ";break}case-1:{if(!e&&a)continue;u=" ";break}default:u=String.fromCharCode(o)}a=o===-2,i.push(u)}return i.join("")}function E9(t){const i={constructs:j8([T9,...(t||{}).extensions||[]]),content:a(V8),defined:[],document:a(G8),flow:a(o9),lazy:{},string:a(c9),text:a(d9)};return i;function a(o){return u;function u(d){return w9(i,o,d)}}}function A9(t){for(;!IA(t););return t}const cT=/[\0\t\n\r]/g;function I9(){let t=1,e="",n=!0,i;return a;function a(o,u,d){o=e+(typeof o=="string"?o.toString():new TextDecoder(u||void 0).decode(o));const f=[];let p=0;for(e="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){cT.lastIndex=p;const m=cT.exec(o),y=m&&m.index!==void 0?m.index:o.length,v=o.charCodeAt(y);if(!m){e=o.slice(p);break}if(v===10&&p===y&&i)f.push(-3),i=void 0;else switch(i&&(f.push(-5),i=void 0),p<y&&(f.push(o.slice(p,y)),t+=y-p),v){case 0:{f.push(65533),t++;break}case 9:{const b=Math.ceil(t/4)*4;for(f.push(-2);t++<b;)f.push(-1);break}case 10:{f.push(-4),t=1;break}default:i=!0,t=1}p=y+1}return d&&(i&&f.push(-5),e&&f.push(e),f.push(null)),f}}const R9=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function M9(t){return t.replace(R9,k9)}function k9(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),o=a===120||a===88;return wA(n.slice(o?2:1),o?16:10)}return iy(n)||t}const DA={}.hasOwnProperty;function N9(t,e,n){return e&&typeof e=="object"&&(n=e,e=void 0),O9(n)(A9(E9(n).document().write(I9()(t,e,!0))))}function O9(t){const e={afterExit:[],beforeEnter:[],transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(Wt),autolinkProtocol:V,autolinkEmail:V,atxHeading:u(ve),blockQuote:u(fe),characterEscape:V,characterReference:V,codeFenced:u(ge),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:u(ge,d),codeText:u(Oe,d),codeTextData:V,data:V,codeFlowValue:V,definition:u(Pe),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:u($e),hardBreakEscape:u(Ae),hardBreakTrailing:u(Ae),htmlFlow:u(Ie,d),htmlFlowData:V,htmlText:u(Ie,d),htmlTextData:V,image:u(ct),label:d,link:u(Wt),listItem:u(Pr),listItemValue:b,listOrdered:u(Ot,v),listUnordered:u(Ot),paragraph:u(Br),reference:N,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:u(ve),strong:u(oi),thematicBreak:u(Ur)},exit:{atxHeading:p(),atxHeadingSequence:I,autolink:p(),autolinkEmail:ce,autolinkProtocol:B,blockQuote:p(),characterEscapeValue:z,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:pe,characterReference:de,codeFenced:p(E),codeFencedFence:x,codeFencedFenceInfo:T,codeFencedFenceMeta:w,codeFlowValue:z,codeIndented:p(C),codeText:p(ee),codeTextData:z,data:z,definition:p(),definitionDestinationString:L,definitionLabelString:R,definitionTitleString:O,emphasis:p(),hardBreakEscape:p(W),hardBreakTrailing:p(W),htmlFlow:p(X),htmlFlowData:z,htmlText:p(Z),htmlTextData:z,image:p(he),label:D,labelText:ye,lineEnding:q,link:p(oe),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:te,resourceDestinationString:$,resourceTitleString:re,resource:M,setextHeading:p(H),setextHeadingLineSequence:k,setextHeadingText:P,strong:p(),thematicBreak:p()}};jA(e,(t||{}).mdastExtensions||[]);const n={};return i;function i(ae){let _e={type:"root",children:[],position:void 0};const Re={stack:[_e],tokenStack:[],config:e,enter:f,exit:m,buffer:d,resume:y,data:n},Be=[],Dt=[];let rt=-1;for(;++rt<ae.length;)if(Dt.push(ae[rt]),ae[rt][1].type==="listOrdered"||ae[rt][1].type==="listUnordered")if(ae[rt][0]==="enter")Be.push(Dt.length-1);else{const Ut=Be.pop();o(Dt,Ut)}for(ae=Dt,rt=-1;++rt<ae.length;){const Ut=e[ae[rt][0]];ae[rt][0]==="enter"&&e.beforeEnter.length>0&&a(e.beforeEnter,{...Re,sliceSerialize:ae[rt][2].sliceSerialize},ae[rt][1]),DA.call(Ut,ae[rt][1].type)&&Ut[ae[rt][1].type].call({...Re,sliceSerialize:ae[rt][2].sliceSerialize},ae[rt][1]),ae[rt][0]==="exit"&&e.afterExit.length>0&&a(e.afterExit,{...Re,sliceSerialize:ae[rt][2].sliceSerialize},ae[rt][1])}if(Re.tokenStack.length>0){const Ut=Re.tokenStack[Re.tokenStack.length-1];(Ut[1]||dT).call(Re,void 0,Ut[0])}for(_e.position={start:zi(ae.length>0?ae[0][1].start:{line:1,column:1,offset:0}),end:zi(ae.length>0?ae[ae.length-2][1].end:{line:1,column:1,offset:0})},rt=-1;++rt<e.transforms.length;)_e=e.transforms[rt](_e)||_e;return _e}function a(ae,_e,Re){let Be=-1;for(;++Be<ae.length;)ae[Be].call(_e,Re)}function o(ae,_e){const Re=ae.length-1;let Be=_e-1,Dt=-1,rt=!1,Ut,dn,Ds,js;const Gi=[];for(;++Be<=Re;){const en=ae[Be];switch(en[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{en[0]==="enter"?Dt++:Dt--,js=void 0;break}case"lineEndingBlank":{en[0]==="enter"&&(Ut&&!js&&!Dt&&!Ds&&(Ds=Be),js=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:js=void 0}if(!Dt&&en[0]==="enter"&&en[1].type==="listItemPrefix"||Dt===-1&&en[0]==="exit"&&(en[1].type==="listUnordered"||en[1].type==="listOrdered")){if(Ut){let zs=Be;for(dn=void 0;zs--;){const Un=ae[zs];if(Un[1].type==="lineEnding"||Un[1].type==="lineEndingBlank"){if(Un[0]==="exit")continue;dn&&(ae[dn][1].type="lineEndingBlank",rt=!0),Un[1].type="lineEnding",dn=zs}else if(!(Un[1].type==="linePrefix"||Un[1].type==="blockQuotePrefix"||Un[1].type==="blockQuotePrefixWhitespace"||Un[1].type==="blockQuoteMarker"||Un[1].type==="listItemIndent"))break}Ds&&(!dn||Ds<dn)&&(Ut._spread=!0),Ut.end=Object.assign({},dn?ae[dn][1].start:en[1].end),Gi.push({at:dn||Be,event:["exit",Ut,en[2]]})}if(en[1].type==="listItemPrefix"){const zs={type:"listItem",_spread:!1,start:Object.assign({},en[1].start),end:void 0};Ut=zs,Gi.push({at:Be,event:["enter",zs,en[2]]}),Ds=void 0,js=!0}}}const jl=ae.splice(_e);let Lt=0;for(Be=-1;++Be<jl.length;){for(;Lt<Gi.length&&Gi[Lt].at===_e+Be;)ae.push(Gi[Lt++].event);ae.push(jl[Be])}ae[_e][1]._spread=rt}function u(ae,_e){return Re;function Re(Be){f.call(this,ae(Be),Be),_e&&_e.call(this,Be)}}function d(){this.stack.push({type:"fragment",children:[]})}function f(ae,_e,Re){this.stack[this.stack.length-1].children.push(ae),this.stack.push(ae),this.tokenStack.push([_e,Re||void 0]),ae.position={start:zi(_e.start),end:void 0}}function p(ae){return _e;function _e(Re){ae&&ae.call(this,Re),m.call(this,Re)}}function m(ae,_e){const Re=this.stack.pop(),Be=this.tokenStack.pop();if(!Be)throw new Error("Cannot close `"+ae.type+"` ("+pl({start:ae.start,end:ae.end})+"): it’s not open");Be[0].type!==ae.type&&(_e?_e.call(this,ae,Be[0]):(Be[1]||dT).call(this,ae,Be[0])),Re.position.end=zi(ae.end)}function y(){return O8(this.stack.pop())}function v(){this.data.expectingFirstListItemValue=!0}function b(ae){if(this.data.expectingFirstListItemValue){const _e=this.stack[this.stack.length-2];_e.start=Number.parseInt(this.sliceSerialize(ae),10),this.data.expectingFirstListItemValue=void 0}}function T(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.lang=ae}function w(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.meta=ae}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function E(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.value=ae.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function C(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.value=ae.replace(/(\r?\n|\r)$/g,"")}function R(ae){const _e=this.resume(),Re=this.stack[this.stack.length-1];Re.label=_e,Re.identifier=Ba(this.sliceSerialize(ae)).toLowerCase()}function O(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.title=ae}function L(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.url=ae}function I(ae){const _e=this.stack[this.stack.length-1];if(!_e.depth){const Re=this.sliceSerialize(ae).length;_e.depth=Re}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function k(ae){const _e=this.stack[this.stack.length-1];_e.depth=this.sliceSerialize(ae).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function V(ae){const Re=this.stack[this.stack.length-1].children;let Be=Re[Re.length-1];(!Be||Be.type!=="text")&&(Be=to(),Be.position={start:zi(ae.start),end:void 0},Re.push(Be)),this.stack.push(Be)}function z(ae){const _e=this.stack.pop();_e.value+=this.sliceSerialize(ae),_e.position.end=zi(ae.end)}function q(ae){const _e=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Re=_e.children[_e.children.length-1];Re.position.end=zi(ae.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(_e.type)&&(V.call(this,ae),z.call(this,ae))}function W(){this.data.atHardBreak=!0}function X(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.value=ae}function Z(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.value=ae}function ee(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.value=ae}function oe(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const _e=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=_e,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function he(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const _e=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=_e,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function ye(ae){const _e=this.sliceSerialize(ae),Re=this.stack[this.stack.length-2];Re.label=M9(_e),Re.identifier=Ba(_e).toLowerCase()}function D(){const ae=this.stack[this.stack.length-1],_e=this.resume(),Re=this.stack[this.stack.length-1];if(this.data.inReference=!0,Re.type==="link"){const Be=ae.children;Re.children=Be}else Re.alt=_e}function $(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.url=ae}function re(){const ae=this.resume(),_e=this.stack[this.stack.length-1];_e.title=ae}function M(){this.data.inReference=void 0}function N(){this.data.referenceType="collapsed"}function te(ae){const _e=this.resume(),Re=this.stack[this.stack.length-1];Re.label=_e,Re.identifier=Ba(this.sliceSerialize(ae)).toLowerCase(),this.data.referenceType="full"}function ie(ae){this.data.characterReferenceType=ae.type}function pe(ae){const _e=this.sliceSerialize(ae),Re=this.data.characterReferenceType;let Be;Re?(Be=wA(_e,Re==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Be=iy(_e);const Dt=this.stack[this.stack.length-1];Dt.value+=Be}function de(ae){const _e=this.stack.pop();_e.position.end=zi(ae.end)}function B(ae){z.call(this,ae);const _e=this.stack[this.stack.length-1];_e.url=this.sliceSerialize(ae)}function ce(ae){z.call(this,ae);const _e=this.stack[this.stack.length-1];_e.url="mailto:"+this.sliceSerialize(ae)}function fe(){return{type:"blockquote",children:[],position:void 0}}function ge(){return{type:"code",lang:null,meta:null,value:"",position:void 0}}function Oe(){return{type:"inlineCode",value:"",position:void 0}}function Pe(){return{type:"definition",identifier:"",label:null,title:null,url:"",position:void 0}}function $e(){return{type:"emphasis",children:[],position:void 0}}function ve(){return{type:"heading",depth:0,children:[],position:void 0}}function Ae(){return{type:"break",position:void 0}}function Ie(){return{type:"html",value:"",position:void 0}}function ct(){return{type:"image",title:null,url:"",alt:null,position:void 0}}function Wt(){return{type:"link",title:null,url:"",children:[],position:void 0}}function Ot(ae){return{type:"list",ordered:ae.type==="listOrdered",start:null,spread:ae._spread,children:[],position:void 0}}function Pr(ae){return{type:"listItem",spread:ae._spread,checked:null,children:[],position:void 0}}function Br(){return{type:"paragraph",children:[],position:void 0}}function oi(){return{type:"strong",children:[],position:void 0}}function to(){return{type:"text",value:"",position:void 0}}function Ur(){return{type:"thematicBreak",position:void 0}}}function zi(t){return{line:t.line,column:t.column,offset:t.offset}}function jA(t,e){let n=-1;for(;++n<e.length;){const i=e[n];Array.isArray(i)?jA(t,i):D9(t,i)}}function D9(t,e){let n;for(n in e)if(DA.call(e,n))switch(n){case"canContainEols":{const i=e[n];i&&t[n].push(...i);break}case"transforms":{const i=e[n];i&&t[n].push(...i);break}case"afterExit":case"beforeEnter":{const i=e[n];i&&t[n].push(i);break}case"enter":case"exit":{const i=e[n];i&&Object.assign(t[n],i);break}}}function dT(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+pl({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+pl({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+pl({start:e.start,end:e.end})+") is still open")}function j9(t){const e=this;e.parser=n;function n(i){return N9(i,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function z9(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function P9(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
21
- `}]}function B9(t,e){const n=e.value?e.value+`
22
- `:"",i={},a=e.lang?e.lang.split(/\s+/):[];a.length>0&&(i.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return e.meta&&(o.data={meta:e.meta}),t.patch(e,o),o=t.applyData(e,o),o={type:"element",tagName:"pre",properties:{},children:[o]},t.patch(e,o),o}function U9(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function L9(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function q9(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",i=String(e.identifier).toUpperCase(),a=Wa(i.toLowerCase()),o=t.footnoteOrder.indexOf(i);let u,d=t.footnoteCounts.get(i);d===void 0?(d=0,t.footnoteOrder.push(i),u=t.footnoteOrder.length):u=o+1,d+=1,t.footnoteCounts.set(i,d);const f={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};t.patch(e,f);const p={type:"element",tagName:"sup",properties:{},children:[f]};return t.patch(e,p),t.applyData(e,p)}function H9(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function V9(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function zA(t,e){const n=e.referenceType;let i="]";if(n==="collapsed"?i+="[]":n==="full"&&(i+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+i}];const a=t.all(e),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=i:a.push({type:"text",value:i}),a}function $9(t,e){const n=String(e.identifier).toUpperCase(),i=t.definitionById.get(n);if(!i)return zA(t,e);const a={src:Wa(i.url||""),alt:e.alt};i.title!==null&&i.title!==void 0&&(a.title=i.title);const o={type:"element",tagName:"img",properties:a,children:[]};return t.patch(e,o),t.applyData(e,o)}function G9(t,e){const n={src:Wa(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const i={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,i),t.applyData(e,i)}function F9(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const i={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,i),t.applyData(e,i)}function Y9(t,e){const n=String(e.identifier).toUpperCase(),i=t.definitionById.get(n);if(!i)return zA(t,e);const a={href:Wa(i.url||"")};i.title!==null&&i.title!==void 0&&(a.title=i.title);const o={type:"element",tagName:"a",properties:a,children:t.all(e)};return t.patch(e,o),t.applyData(e,o)}function Q9(t,e){const n={href:Wa(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const i={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function K9(t,e,n){const i=t.all(e),a=n?X9(n):PA(e),o={},u=[];if(typeof e.checked=="boolean"){const m=i[0];let y;m&&m.type==="element"&&m.tagName==="p"?y=m:(y={type:"element",tagName:"p",properties:{},children:[]},i.unshift(y)),y.children.length>0&&y.children.unshift({type:"text",value:" "}),y.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let d=-1;for(;++d<i.length;){const m=i[d];(a||d!==0||m.type!=="element"||m.tagName!=="p")&&u.push({type:"text",value:`
23
- `}),m.type==="element"&&m.tagName==="p"&&!a?u.push(...m.children):u.push(m)}const f=i[i.length-1];f&&(a||f.type!=="element"||f.tagName!=="p")&&u.push({type:"text",value:`
24
- `});const p={type:"element",tagName:"li",properties:o,children:u};return t.patch(e,p),t.applyData(e,p)}function X9(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let i=-1;for(;!e&&++i<n.length;)e=PA(n[i])}return e}function PA(t){const e=t.spread;return e??t.children.length>1}function J9(t,e){const n={},i=t.all(e);let a=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++a<i.length;){const u=i[a];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(i,!0)};return t.patch(e,o),t.applyData(e,o)}function Z9(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function W9(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function eq(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function tq(t,e){const n=t.all(e),i=n.shift(),a=[];if(i){const u={type:"element",tagName:"thead",properties:{},children:t.wrap([i],!0)};t.patch(e.children[0],u),a.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},d=ey(e.children[1]),f=gA(e.children[e.children.length-1]);d&&f&&(u.position={start:d,end:f}),a.push(u)}const o={type:"element",tagName:"table",properties:{},children:t.wrap(a,!0)};return t.patch(e,o),t.applyData(e,o)}function nq(t,e,n){const i=n?n.children:void 0,o=(i?i.indexOf(e):1)===0?"th":"td",u=n&&n.type==="table"?n.align:void 0,d=u?u.length:e.children.length;let f=-1;const p=[];for(;++f<d;){const y=e.children[f],v={},b=u?u[f]:void 0;b&&(v.align=b);let T={type:"element",tagName:o,properties:v,children:[]};y&&(T.children=t.all(y),t.patch(y,T),T=t.applyData(y,T)),p.push(T)}const m={type:"element",tagName:"tr",properties:{},children:t.wrap(p,!0)};return t.patch(e,m),t.applyData(e,m)}function sq(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}const fT=9,hT=32;function iq(t){const e=String(t),n=/\r?\n|\r/g;let i=n.exec(e),a=0;const o=[];for(;i;)o.push(pT(e.slice(a,i.index),a>0,!0),i[0]),a=i.index+i[0].length,i=n.exec(e);return o.push(pT(e.slice(a),a>0,!1)),o.join("")}function pT(t,e,n){let i=0,a=t.length;if(e){let o=t.codePointAt(i);for(;o===fT||o===hT;)i++,o=t.codePointAt(i)}if(n){let o=t.codePointAt(a-1);for(;o===fT||o===hT;)a--,o=t.codePointAt(a-1)}return a>i?t.slice(i,a):""}function rq(t,e){const n={type:"text",value:iq(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function aq(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const oq={blockquote:z9,break:P9,code:B9,delete:U9,emphasis:L9,footnoteReference:q9,heading:H9,html:V9,imageReference:$9,image:G9,inlineCode:F9,linkReference:Y9,link:Q9,listItem:K9,list:J9,paragraph:Z9,root:W9,strong:eq,table:tq,tableCell:sq,tableRow:nq,text:rq,thematicBreak:aq,toml:bc,yaml:bc,definition:bc,footnoteDefinition:bc};function bc(){}const BA=-1,vd=0,gl=1,Zc=2,oy=3,ly=4,uy=5,cy=6,UA=7,LA=8,{defineProperty:lq}=Object,qA=typeof self=="object"?self:globalThis,mT=(t,e)=>{switch(t){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+t)}return new qA[t](e)},uq=(t,e)=>{const n=(a,o)=>(t.set(o,a),a),i=a=>{if(t.has(a))return t.get(a);const[o,u]=e[a];switch(o){case vd:case BA:return n(u,a);case gl:{const d=n([],a);for(const f of u)d.push(i(f));return d}case Zc:{const d=n({},a);for(const[f,p]of u){const m=i(f),y=i(p);m==="__proto__"?lq(d,m,{value:y,configurable:!0,enumerable:!0,writable:!0}):d[m]=y}return d}case oy:return n(new Date(u),a);case ly:{const{source:d,flags:f}=u;return n(new RegExp(d,f),a)}case uy:{const d=n(new Map,a);for(const[f,p]of u)d.set(i(f),i(p));return d}case cy:{const d=n(new Set,a);for(const f of u)d.add(i(f));return d}case UA:{const{name:d,message:f}=u;return n(typeof qA[d]=="function"?mT(d,f):new Error(f),a)}case LA:return n(BigInt(u),a);case"BigInt":return n(Object(BigInt(u)),a);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:d}=new Uint8Array(u);return n(new DataView(d),u)}case"-0":return-0}return n(mT(o,u),a)};return i},gT=t=>uq(new Map,t)(0),yr="",{toString:cq}={},{keys:dq,is:fq}=Object,nl=t=>{const e=typeof t;if(e!=="object"||!t)return[vd,e];const n=cq.call(t).slice(8,-1);switch(n){case"Array":return[gl,yr];case"Object":return[Zc,yr];case"Date":return[oy,yr];case"RegExp":return[ly,yr];case"Map":return[uy,yr];case"Set":return[cy,yr];case"DataView":return[gl,n]}return n.includes("Array")?[gl,n]:t instanceof Error?[UA,t.name||"Error"]:[Zc,n]},_c=([t,e])=>t===vd&&(e==="function"||e==="symbol"),hq=(t,e,n,i)=>{const a=(u,d)=>{const f=i.push(u)-1;return n.set(d,f),f},o=u=>{if(n.has(u))return n.get(u);let[d,f]=nl(u);switch(d){case vd:{let m=u;switch(f){case"bigint":d=LA,m=u.toString();break;case"number":if(!u&&fq(u,-0))return i.push(["-0"])-1;break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+f);m=null;break;case"undefined":return a([BA],u)}return a([d,m],u)}case gl:{if(f){let v=u;return f==="DataView"?v=new Uint8Array(u.buffer):f==="ArrayBuffer"&&(v=new Uint8Array(u)),a([f,[...v]],u)}const m=[],y=a([d,m],u);for(const v of u)m.push(o(v));return y}case Zc:{if(f)switch(f){case"BigInt":return a([f,u.toString()],u);case"Boolean":case"Number":case"String":return a([f,u.valueOf()],u)}if(e&&"toJSON"in u)return o(u.toJSON());const m=[],y=a([d,m],u);for(const v of dq(u))(t||!_c(nl(u[v])))&&m.push([o(v),o(u[v])]);return y}case oy:return a([d,isNaN(u.getTime())?yr:u.toISOString()],u);case ly:{const{source:m,flags:y}=u;return a([d,{source:m,flags:y}],u)}case uy:{const m=[],y=a([d,m],u);for(const[v,b]of u)(t||!(_c(nl(v))||_c(nl(b))))&&m.push([o(v),o(b)]);return y}case cy:{const m=[],y=a([d,m],u);for(const v of u)(t||!_c(nl(v)))&&m.push(o(v));return y}}const{message:p}=u;return a([d,{name:f,message:p}],u)};return o},yT=(t,{json:e,lossy:n}={})=>{const i=[];return hq(!(e||n),!!e,new Map,i)(t),i},Wc=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?gT(yT(t,e)):structuredClone(t):(t,e)=>gT(yT(t,e));function pq(t,e){const n=[{type:"text",value:"↩"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function mq(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function gq(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||pq,i=t.options.footnoteBackLabel||mq,a=t.options.footnoteLabel||"Footnotes",o=t.options.footnoteLabelTagName||"h2",u=t.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let f=-1;for(;++f<t.footnoteOrder.length;){const p=t.footnoteById.get(t.footnoteOrder[f]);if(!p)continue;const m=t.all(p),y=String(p.identifier).toUpperCase(),v=Wa(y.toLowerCase());let b=0;const T=[],w=t.footnoteCounts.get(y);for(;w!==void 0&&++b<=w;){T.length>0&&T.push({type:"text",value:" "});let C=typeof n=="string"?n:n(f,b);typeof C=="string"&&(C={type:"text",value:C}),T.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+v+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(f,b),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const x=m[m.length-1];if(x&&x.type==="element"&&x.tagName==="p"){const C=x.children[x.children.length-1];C&&C.type==="text"?C.value+=" ":x.children.push({type:"text",value:" "}),x.children.push(...T)}else m.push(...T);const E={type:"element",tagName:"li",properties:{id:e+"fn-"+v},children:t.wrap(m,!0)};t.patch(p,E),d.push(E)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Wc(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
25
- `},{type:"element",tagName:"ol",properties:{},children:t.wrap(d,!0)},{type:"text",value:`
26
- `}]}}const HA=(function(t){if(t==null)return _q;if(typeof t=="function")return bd(t);if(typeof t=="object")return Array.isArray(t)?yq(t):vq(t);if(typeof t=="string")return bq(t);throw new Error("Expected function, string, or object as test")});function yq(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=HA(t[n]);return bd(i);function i(...a){let o=-1;for(;++o<e.length;)if(e[o].apply(this,a))return!0;return!1}}function vq(t){const e=t;return bd(n);function n(i){const a=i;let o;for(o in t)if(a[o]!==e[o])return!1;return!0}}function bq(t){return bd(e);function e(n){return n&&n.type===t}}function bd(t){return e;function e(n,i,a){return!!(Sq(n)&&t.call(this,n,typeof i=="number"?i:void 0,a||void 0))}}function _q(){return!0}function Sq(t){return t!==null&&typeof t=="object"&&"type"in t}const VA=[],Tq=!0,vT=!1,wq="skip";function xq(t,e,n,i){let a;typeof e=="function"&&typeof n!="function"?(i=n,n=e):a=e;const o=HA(a),u=i?-1:1;d(t,void 0,[])();function d(f,p,m){const y=f&&typeof f=="object"?f:{};if(typeof y.type=="string"){const b=typeof y.tagName=="string"?y.tagName:typeof y.name=="string"?y.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(f.type+(b?"<"+b+">":""))+")"})}return v;function v(){let b=VA,T,w,x;if((!e||o(f,p,m[m.length-1]||void 0))&&(b=Cq(n(f,m)),b[0]===vT))return b;if("children"in f&&f.children){const E=f;if(E.children&&b[0]!==wq)for(w=(i?E.children.length:-1)+u,x=m.concat(E);w>-1&&w<E.children.length;){const C=E.children[w];if(T=d(C,w,x)(),T[0]===vT)return T;w=typeof T[1]=="number"?T[1]:w+u}}return b}}}function Cq(t){return Array.isArray(t)?t:typeof t=="number"?[Tq,t]:t==null?VA:[t]}function $A(t,e,n,i){let a,o,u;typeof e=="function"&&typeof n!="function"?(o=void 0,u=e,a=n):(o=e,u=n,a=i),xq(t,o,d,a);function d(f,p){const m=p[p.length-1],y=m?m.children.indexOf(f):void 0;return u(f,y,m)}}const Lm={}.hasOwnProperty,Eq={};function Aq(t,e){const n=e||Eq,i=new Map,a=new Map,o=new Map,u={...oq,...n.handlers},d={all:p,applyData:Rq,definitionById:i,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:u,one:f,options:n,patch:Iq,wrap:kq};return $A(t,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const y=m.type==="definition"?i:a,v=String(m.identifier).toUpperCase();y.has(v)||y.set(v,m)}}),d;function f(m,y){const v=m.type,b=d.handlers[v];if(Lm.call(d.handlers,v)&&b)return b(d,m,y);if(d.options.passThrough&&d.options.passThrough.includes(v)){if("children"in m){const{children:w,...x}=m,E=Wc(x);return E.children=d.all(m),E}return Wc(m)}return(d.options.unknownHandler||Mq)(d,m,y)}function p(m){const y=[];if("children"in m){const v=m.children;let b=-1;for(;++b<v.length;){const T=d.one(v[b],m);if(T){if(b&&v[b-1].type==="break"&&(!Array.isArray(T)&&T.type==="text"&&(T.value=bT(T.value)),!Array.isArray(T)&&T.type==="element")){const w=T.children[0];w&&w.type==="text"&&(w.value=bT(w.value))}Array.isArray(T)?y.push(...T):y.push(T)}}}return y}}function Iq(t,e){t.position&&(e.position=d8(t))}function Rq(t,e){let n=e;if(t&&t.data){const i=t.data.hName,a=t.data.hChildren,o=t.data.hProperties;if(typeof i=="string")if(n.type==="element")n.tagName=i;else{const u="children"in n?n.children:[n];n={type:"element",tagName:i,properties:{},children:u}}n.type==="element"&&o&&Object.assign(n.properties,Wc(o)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function Mq(t,e){const n=e.data||{},i="value"in e&&!(Lm.call(n,"hProperties")||Lm.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function kq(t,e){const n=[];let i=-1;for(e&&n.push({type:"text",value:`
27
- `});++i<t.length;)i&&n.push({type:"text",value:`
28
- `}),n.push(t[i]);return e&&t.length>0&&n.push({type:"text",value:`
29
- `}),n}function bT(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function _T(t,e){const n=Aq(t,e),i=n.one(t,void 0),a=gq(n),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
30
- `},a),o}function Nq(t,e){return t&&"run"in t?async function(n,i){const a=_T(n,{file:i,...e});await t.run(a,i)}:function(n,i){return _T(n,{file:i,...t||e})}}function ST(t){if(t)throw t}var Rp,TT;function Oq(){if(TT)return Rp;TT=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=function(p){return typeof Array.isArray=="function"?Array.isArray(p):e.call(p)==="[object Array]"},o=function(p){if(!p||e.call(p)!=="[object Object]")return!1;var m=t.call(p,"constructor"),y=p.constructor&&p.constructor.prototype&&t.call(p.constructor.prototype,"isPrototypeOf");if(p.constructor&&!m&&!y)return!1;var v;for(v in p);return typeof v>"u"||t.call(p,v)},u=function(p,m){n&&m.name==="__proto__"?n(p,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):p[m.name]=m.newValue},d=function(p,m){if(m==="__proto__")if(t.call(p,m)){if(i)return i(p,m).value}else return;return p[m]};return Rp=function f(){var p,m,y,v,b,T,w=arguments[0],x=1,E=arguments.length,C=!1;for(typeof w=="boolean"&&(C=w,w=arguments[1]||{},x=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});x<E;++x)if(p=arguments[x],p!=null)for(m in p)y=d(w,m),v=d(p,m),w!==v&&(C&&v&&(o(v)||(b=a(v)))?(b?(b=!1,T=y&&a(y)?y:[]):T=y&&o(y)?y:{},u(w,{name:m,newValue:f(C,T,v)})):typeof v<"u"&&u(w,{name:m,newValue:v}));return w},Rp}var Dq=Oq();const Mp=xl(Dq);function qm(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function jq(){const t=[],e={run:n,use:i};return e;function n(...a){let o=-1;const u=a.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);d(null,...a);function d(f,...p){const m=t[++o];let y=-1;if(f){u(f);return}for(;++y<a.length;)(p[y]===null||p[y]===void 0)&&(p[y]=a[y]);a=p,m?zq(m,d)(...p):u(null,...p)}}function i(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return t.push(a),e}}function zq(t,e){let n;return i;function i(...u){const d=t.length>u.length;let f;d&&u.push(a);try{f=t.apply(this,u)}catch(p){const m=p;if(d&&n)throw m;return a(m)}d||(f&&f.then&&typeof f.then=="function"?f.then(o,a):f instanceof Error?a(f):o(f))}function a(u,...d){n||(n=!0,e(u,...d))}function o(u){a(null,u)}}const Is={basename:Pq,dirname:Bq,extname:Uq,join:Lq,sep:"/"};function Pq(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Dl(t);let n=0,i=-1,a=t.length,o;if(e===void 0||e.length===0||e.length>t.length){for(;a--;)if(t.codePointAt(a)===47){if(o){n=a+1;break}}else i<0&&(o=!0,i=a+1);return i<0?"":t.slice(n,i)}if(e===t)return"";let u=-1,d=e.length-1;for(;a--;)if(t.codePointAt(a)===47){if(o){n=a+1;break}}else u<0&&(o=!0,u=a+1),d>-1&&(t.codePointAt(a)===e.codePointAt(d--)?d<0&&(i=a):(d=-1,i=u));return n===i?i=u:i<0&&(i=t.length),t.slice(n,i)}function Bq(t){if(Dl(t),t.length===0)return".";let e=-1,n=t.length,i;for(;--n;)if(t.codePointAt(n)===47){if(i){e=n;break}}else i||(i=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function Uq(t){Dl(t);let e=t.length,n=-1,i=0,a=-1,o=0,u;for(;e--;){const d=t.codePointAt(e);if(d===47){if(u){i=e+1;break}continue}n<0&&(u=!0,n=e+1),d===46?a<0?a=e:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===i+1?"":t.slice(a,n)}function Lq(...t){let e=-1,n;for(;++e<t.length;)Dl(t[e]),t[e]&&(n=n===void 0?t[e]:n+"/"+t[e]);return n===void 0?".":qq(n)}function qq(t){Dl(t);const e=t.codePointAt(0)===47;let n=Hq(t,!e);return n.length===0&&!e&&(n="."),n.length>0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function Hq(t,e){let n="",i=0,a=-1,o=0,u=-1,d,f;for(;++u<=t.length;){if(u<t.length)d=t.codePointAt(u);else{if(d===47)break;d=47}if(d===47){if(!(a===u-1||o===1))if(a!==u-1&&o===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(f=n.lastIndexOf("/"),f!==n.length-1){f<0?(n="",i=0):(n=n.slice(0,f),i=n.length-1-n.lastIndexOf("/")),a=u,o=0;continue}}else if(n.length>0){n="",i=0,a=u,o=0;continue}}e&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+t.slice(a+1,u):n=t.slice(a+1,u),i=u-a-1;a=u,o=0}else d===46&&o>-1?o++:o=-1}return n}function Dl(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const Vq={cwd:$q};function $q(){return"/"}function Hm(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function Gq(t){if(typeof t=="string")t=new URL(t);else if(!Hm(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Fq(t)}function Fq(t){if(t.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const e=t.pathname;let n=-1;for(;++n<e.length;)if(e.codePointAt(n)===37&&e.codePointAt(n+1)===50){const i=e.codePointAt(n+2);if(i===70||i===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(e)}const kp=["history","path","basename","stem","extname","dirname"];class GA{constructor(e){let n;e?Hm(e)?n={path:e}:typeof e=="string"||Yq(e)?n={value:e}:n=e:n={},this.cwd="cwd"in n?"":Vq.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<kp.length;){const o=kp[i];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let a;for(a in n)kp.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Is.basename(this.path):void 0}set basename(e){Op(e,"basename"),Np(e,"basename"),this.path=Is.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Is.dirname(this.path):void 0}set dirname(e){wT(this.basename,"dirname"),this.path=Is.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Is.extname(this.path):void 0}set extname(e){if(Np(e,"extname"),wT(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Is.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Hm(e)&&(e=Gq(e)),Op(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Is.basename(this.path,this.extname):void 0}set stem(e){Op(e,"stem"),Np(e,"stem"),this.path=Is.join(this.dirname||"",e+(this.extname||""))}fail(e,n,i){const a=this.message(e,n,i);throw a.fatal=!0,a}info(e,n,i){const a=this.message(e,n,i);return a.fatal=void 0,a}message(e,n,i){const a=new Zt(e,n,i);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function Np(t,e){if(t&&t.includes(Is.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Is.sep+"`")}function Op(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function wT(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function Yq(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const Qq=(function(t){const i=this.constructor.prototype,a=i[t],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,i),o}),Kq={}.hasOwnProperty;class dy extends Qq{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=jq()}copy(){const e=new dy;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];e.use(...i)}return e.data(Mp(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(zp("data",this.frozen),this.namespace[e]=n,this):Kq.call(this.namespace,e)&&this.namespace[e]||void 0:e?(zp("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const a=n.call(e,...i);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Sc(e),i=this.parser||this.Parser;return Dp("parse",i),i(String(n),n)}process(e,n){const i=this;return this.freeze(),Dp("process",this.parser||this.Parser),jp("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,u){const d=Sc(e),f=i.parse(d);i.run(f,d,function(m,y,v){if(m||!y||!v)return p(m);const b=y,T=i.stringify(b,v);Zq(T)?v.value=T:v.result=T,p(m,v)});function p(m,y){m||!y?u(m):o?o(y):n(void 0,y)}}}processSync(e){let n=!1,i;return this.freeze(),Dp("processSync",this.parser||this.Parser),jp("processSync",this.compiler||this.Compiler),this.process(e,a),CT("processSync","process",n),i;function a(o,u){n=!0,ST(o),i=u}}run(e,n,i){xT(e),this.freeze();const a=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?o(void 0,i):new Promise(o);function o(u,d){const f=Sc(n);a.run(e,f,p);function p(m,y,v){const b=y||e;m?d(m):u?u(b):i(void 0,b,v)}}}runSync(e,n){let i=!1,a;return this.run(e,n,o),CT("runSync","run",i),a;function o(u,d){ST(u),a=d,i=!0}}stringify(e,n){this.freeze();const i=Sc(n),a=this.compiler||this.Compiler;return jp("stringify",a),xT(e),a(e,i)}use(e,...n){const i=this.attachers,a=this.namespace;if(zp("use",this.frozen),e!=null)if(typeof e=="function")f(e,n);else if(typeof e=="object")Array.isArray(e)?d(e):u(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function o(p){if(typeof p=="function")f(p,[]);else if(typeof p=="object")if(Array.isArray(p)){const[m,...y]=p;f(m,y)}else u(p);else throw new TypeError("Expected usable value, not `"+p+"`")}function u(p){if(!("plugins"in p)&&!("settings"in p))throw new 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");d(p.plugins),p.settings&&(a.settings=Mp(!0,a.settings,p.settings))}function d(p){let m=-1;if(p!=null)if(Array.isArray(p))for(;++m<p.length;){const y=p[m];o(y)}else throw new TypeError("Expected a list of plugins, not `"+p+"`")}function f(p,m){let y=-1,v=-1;for(;++y<i.length;)if(i[y][0]===p){v=y;break}if(v===-1)i.push([p,...m]);else if(m.length>0){let[b,...T]=m;const w=i[v][1];qm(w)&&qm(b)&&(b=Mp(!0,w,b)),i[v]=[p,b,...T]}}}}const Xq=new dy().freeze();function Dp(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function jp(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function zp(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xT(t){if(!qm(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function CT(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Sc(t){return Jq(t)?t:new GA(t)}function Jq(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function Zq(t){return typeof t=="string"||Wq(t)}function Wq(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const eH="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",ET=[],AT={allowDangerousHtml:!0},tH=/^(https?|ircs?|mailto|xmpp)$/i,nH=[{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 sH(t){const e=iH(t),n=rH(t);return aH(e.runSync(e.parse(n),n),t)}function iH(t){const e=t.rehypePlugins||ET,n=t.remarkPlugins||ET,i=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...AT}:AT;return Xq().use(j9).use(n).use(Nq,i).use(e)}function rH(t){const e=t.children||"",n=new GA;return typeof e=="string"&&(n.value=e),n}function aH(t,e){const n=e.allowedElements,i=e.allowElement,a=e.components,o=e.disallowedElements,u=e.skipHtml,d=e.unwrapDisallowed,f=e.urlTransform||oH;for(const m of nH)Object.hasOwn(e,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+eH+m.id,void 0);return $A(t,p),g8(t,{Fragment:_.Fragment,components:a,ignoreInvalidStyle:!0,jsx:_.jsx,jsxs:_.jsxs,passKeys:!0,passNode:!0});function p(m,y,v){if(m.type==="raw"&&v&&typeof y=="number")return u?v.children.splice(y,1):v.children[y]={type:"text",value:m.value},y;if(m.type==="element"){let b;for(b in Ep)if(Object.hasOwn(Ep,b)&&Object.hasOwn(m.properties,b)){const T=m.properties[b],w=Ep[b];(w===null||w.includes(m.tagName))&&(m.properties[b]=f(String(T||""),b,m))}}if(m.type==="element"){let b=n?!n.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&i&&typeof y=="number"&&(b=!i(m,y,v)),b&&v&&typeof y=="number")return d&&m.children?v.children.splice(y,1,...m.children):v.children.splice(y,1),y}}}function oH(t){const e=t.indexOf(":"),n=t.indexOf("?"),i=t.indexOf("#"),a=t.indexOf("/");return e===-1||a!==-1&&e>a||n!==-1&&e>n||i!==-1&&e>i||tH.test(t.slice(0,e))?t:""}const{useSmooth:lH,useSmoothStatus:uH,withSmoothContextProvider:cH}=EL,fy=se.memo(({text:t,overrideVersion:e,...n})=>_.jsx(sH,{...n,children:t}));fy.displayName="MarkdownRenderer";const dH=({text:t,...e})=>{const n=se.useDeferredValue(t);return _.jsx(fy,{text:n,...e})},IT=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ed=(t,e,n=1)=>{if(Object.is(t,e))return!0;if(n<=0)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!ed(t[i],e[i],n-1))return!1;return!0}if(IT(t)&&IT(e)){const i=Object.keys(t);return i.length===Object.keys(e).length&&i.every(a=>Object.hasOwn(e,a)&&ed(t[a],e[a],n-1))}return!1};function fH(t,e){const n=se.useRef(t);return ed(t,n.current,e)||(n.current=t),n.current}function RT(t){const e=se.useRef(t),n=(o,u)=>o[u],i=Object.keys(t),a=Object.keys(e.current);return i.length===a.length&&i.every(o=>Object.hasOwn(e.current,o)&&ed(n(t,o),n(e.current,o)))||(e.current=t),e.current}const hH=({components:t,componentsByLanguage:e,smooth:n=!0,defer:i=!1,preprocess:a,...o})=>{const u=BE(),{text:d}=lH(u,n),f=se.useMemo(()=>a?a(d):d,[a,d]),{pre:p=kL,code:m=NL,SyntaxHighlighter:y=oA,CodeHeader:v=OL}=t??{},b=se.useMemo(()=>({Pre:p,Code:m,SyntaxHighlighter:y,CodeHeader:v}),[p,m,y,v]),T=ri(O=>_.jsx(qL,{components:b,componentsByLanguage:e,...O})),w=ri(O=>_.jsx(ML,{fallbackPre:p,...O})),x=RT(se.useMemo(()=>{const{pre:O,code:L,SyntaxHighlighter:I,CodeHeader:P,...k}=t??{};return{...k,pre:w,code:T}},[T,w,t])),E=fH(se.useMemo(()=>({components:b,componentsByLanguage:e}),[b,e]),3),C=i?dH:fy,R=RT(o);return _.jsx(C,{text:f,components:x,overrideVersion:E,...R})},FA=se.forwardRef(({className:t,containerProps:e,containerComponent:n="div",...i},a)=>{const o=uH();return _.jsx(n,{"data-status":o.type,...e,className:lA(t,e?.className),ref:a,children:_.jsx(hH,{...i})})});FA.displayName="MarkdownTextPrimitive";const pH=cH(FA),td="agentchat.devUserId",YA="dev-admin",MT=[{id:YA,label:"dev-admin"},{id:"dev-free",label:"dev-free"}],QA=(()=>{try{return!1}catch{return!1}})();function mH(){try{const t=new URLSearchParams(location.search).get("as");if(t&&/^[\w.@-]{1,64}$/.test(t))return localStorage.setItem(td,t),t;const e=localStorage.getItem(td);if(e)return e}catch{}return QA?YA:null}const Tt={token:void 0,set(t){Tt.token=t||void 0},devUserId:mH(),setDevUserId(t){Tt.devUserId=t||null;try{t?localStorage.setItem(td,t):localStorage.removeItem(td)}catch{}}};function eo(t){const e={};return t&&(e.authorization=`Bearer ${t}`),Tt.devUserId&&(e["x-user-id"]=Tt.devUserId),e}async function KA(t){let e="";try{e=(await t.json())?.error?.message??""}catch{}return new Error(e?`${e}(HTTP ${t.status})`:`HTTP ${t.status}`)}async function Kn(t,e){const n=await fetch(t,{headers:eo(e)});if(!n.ok)throw await KA(n);return n.json()}async function Vm(t,e,n){const i=await fetch(t,{method:"POST",headers:{"content-type":"application/json",...eo(n)},body:JSON.stringify(e)});if(!i.ok)throw await KA(i);return i.json()}async function gH(t,e){return(await fetch("/api/decision",{method:"POST",headers:{"content-type":"application/json",...eo(e)},body:JSON.stringify(t)})).ok}async function*yH(t,e,n){const i=await fetch("/api/chat",{method:"POST",headers:{"content-type":"application/json",...eo(n)},body:JSON.stringify(t),signal:e});if(!i.ok||!i.body){let d=`HTTP ${i.status}`;try{const f=await i.json();f.error?.message&&(d=f.error.message)}catch{}yield{type:"error",code:i.status===401?"unauthorized":i.status===429?"quota_exceeded":"internal",message:d,retryable:!1},yield{type:"done",aborted:!1,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0,costUsd:0}};return}const a=i.body.getReader(),o=new TextDecoder;let u="";for(;;){const{value:d,done:f}=await a.read();if(f)break;u+=o.decode(d,{stream:!0});let p;for(;(p=u.indexOf(`
31
-
32
- `))>=0;){const m=u.slice(0,p);u=u.slice(p+2);const y=m.split(`
33
- `).find(v=>v.startsWith("data: "));y&&(yield JSON.parse(y.slice(6)))}}}const vH=/^data:([^;,]+);base64,(.+)$/;function XA(t){const e=vH.exec(t);return e?{mimeType:e[1],data:e[2]}:void 0}function bH(t){if(t?.role!=="user")return[];const e=[],n=i=>{if(i.type!=="image")return;const a=i.image,o=typeof a=="string"?XA(a):void 0;o&&e.push(o)};for(const i of t.content)n(i);for(const i of t.attachments??[])for(const a of i.content??[])n(a);return e}function _H(t){if(t?.role!=="user")return[];const e=[],n=i=>{if(i.type!=="file")return;const a=i;a.mimeType!=="text/markdown"||typeof a.data!="string"||a.data.trim()===""||e.push({name:a.filename??"附件",text:a.data})};for(const i of t.content)n(i);for(const i of t.attachments??[])for(const a of i.content??[])n(a);return e}let $m=!1;function SH(){$m=!0}function TH(t){return{async*run({messages:e,abortSignal:n}){const i=e.at(-1),o={message:i?.role==="user"?i.content.filter(I=>I.type==="text").map(I=>I.text).join(""):""},u=t.getSessionId();u&&(o.sessionId=u);const d=t.getContext();d&&(o.context=d);const f=t.getTier();f&&(o.tier=f);const p=t.getScope();p&&(o.scope=p);const m=t.getPersona?.();m&&(o.persona=m);const y=bH(i);y.length>0&&(o.images=y);const v=_H(i);if(v.length>0&&(o.attachments=v),$m&&($m=!1,u))try{await Vm("/api/history/truncate-last-turn",{sessionId:u},t.getAuthToken())}catch(I){yield{content:[{type:"text",text:`⚠️ 编辑未能生效(旧回答仍在上下文里):${I.message}`}],status:{type:"incomplete",reason:"error"}},t.onRunEnd({usage:null,aborted:!1});return}const b=[],T=(I,P)=>{const k=b.at(-1);k&&k.type===I?k.text+=P:b.push({type:I,text:P})},w=Date.now();let x,E=0,C=0;const R=()=>({streamStartTime:w,totalChunks:E,toolCallCount:C,totalStreamTime:Date.now()-w,...x===void 0?{}:{firstTokenTime:x-w}});let O=null,L=!1;try{for await(const I of yH(o,n,t.getAuthToken())){switch(I.type){case"ready":t.setSessionId(I.sessionId);continue;case"tools_meta":t.onToolsMeta?.(I.labels);continue;case"text_delta":x??=Date.now(),T("text",I.delta);break;case"thinking_delta":x??=Date.now(),T("reasoning",I.delta);break;case"tool_start":x??=Date.now(),C++,b.push({type:"tool-call",toolCallId:I.toolCallId,toolName:I.name,args:I.args,argsText:JSON.stringify(I.args)});break;case"tool_confirm":t.onToolConfirm({sessionId:t.getSessionId()??"",toolCallId:I.toolCallId,name:I.name,args:I.args});continue;case"tool_update":case"tool_end":{I.type==="tool_end"&&t.onToolSettled(I.toolCallId);const P=b.findIndex(k=>k.type==="tool-call"&&k.toolCallId===I.toolCallId);if(P>=0){const k=b[P],H=I.type==="tool_end"?I.result:I.partial;b[P]={...k,result:{text:H.text,details:H.details},isError:I.type==="tool_end"?!I.ok:k.isError}}break}case"error":b.push({type:"text",text:`⚠️ ${I.message}`});break;case"message_end":I.usage&&(O=I.usage);continue;case"ui_prompt":t.onUiPrompt(I);continue;case"ui_notify":t.onUiNotify(I);continue;case"done":O??=I.usage,L=I.aborted;continue}E++,yield{content:[...b],metadata:{timing:R()}}}}catch(I){I.name!=="AbortError"&&b.push({type:"text",text:`⚠️ 网络错误:${I.message}`}),L=!0}t.onRunEnd({usage:O,aborted:L}),yield{content:[...b],status:L?{type:"incomplete",reason:"cancelled"}:void 0,metadata:O?{custom:{usage:O},timing:R()}:{timing:R()}}}}}const wH=["off","static","llm"],kT=t=>typeof t=="string"&&wH.includes(t),nd={count:3,maxMessages:10,messageChars:500,totalChars:4e3};function xH(t){const e=typeof t?.count=="number"&&Number.isInteger(t.count)&&t.count>=1&&t.count<=5?t.count:nd.count,n=typeof t?.maxMessages=="number"&&Number.isInteger(t.maxMessages)&&t.maxMessages>=1&&t.maxMessages<=20?t.maxMessages:nd.maxMessages,i=Array.isArray(t?.static)?t.static.filter(a=>typeof a=="string"&&a.trim()!=="").map(a=>a.trim()):[];return{count:e,maxMessages:n,staticFallback:i}}function CH(t,e){const n=kT(t.ui?.followUp?.mode)?t.ui.followUp.mode:"llm";if(n==="off")return"off";const i=e??t.defaultPersona,a=i?t.personas?.[i]?.followUpMode:void 0;return kT(a)?a:n}function EH(t,e){const n=[];for(const u of t)if(!(u.role!=="user"&&u.role!=="assistant"))for(const d of u.content??[]){if(d?.type!=="text"||typeof d.text!="string")continue;const f=d.text.trim();f&&n.push({role:u.role,text:f.slice(0,nd.messageChars)})}const i=n.slice(-Math.max(1,e));let a=0;const o=[];for(let u=i.length-1;u>=0&&(a+=i[u].text.length,!(a>nd.totalChars));u--)o.unshift(i[u]);return o}function AH(t,e,n){if(e==="static"){const i=t.staticFallback.slice(0,t.count).map(a=>({prompt:a}));return{generate:()=>Promise.resolve(i)}}return{async generate({messages:i,signal:a}){try{const o=await fetch("/api/suggestions",{method:"POST",headers:{"content-type":"application/json",...eo(Tt.token)},body:JSON.stringify({messages:EH(i,t.maxMessages),persona:n}),signal:a});if(!o.ok)return[];const u=await o.json();return Array.isArray(u.suggestions)?u.suggestions.filter(d=>typeof d=="string"&&d.trim()!=="").slice(0,t.count).map(d=>({prompt:d})):[]}catch{return[]}}}}const IH="modulepreload",RH=function(t){return"/"+t},NT={},sd=function(e,n,i){let a=Promise.resolve();if(n&&n.length>0){let f=function(p){return Promise.all(p.map(m=>Promise.resolve(m).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=u?.nonce||u?.getAttribute("nonce");a=f(n.map(p=>{if(p=RH(p),p in NT)return;NT[p]=!0;const m=p.endsWith(".css"),y=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${y}`))return;const v=document.createElement("link");if(v.rel=m?"stylesheet":IH,m||(v.as="script"),v.crossOrigin="",v.href=p,d&&v.setAttribute("nonce",d),document.head.appendChild(v),m)return new Promise((b,T)=>{v.addEventListener("load",b),v.addEventListener("error",()=>T(new Error(`Unable to preload CSS for ${p}`)))})}))}function o(u){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=u,window.dispatchEvent(d),!d.defaultPrevented)throw u}return a.then(u=>{for(const d of u||[])d.status==="rejected"&&o(d.reason);return e().catch(o)})},Pp=4,MH=24e3,kH={md:"text",markdown:"text",txt:"text",log:"text",json:"text",yaml:"text",yml:"text",toml:"text",ini:"text",csv:"csv",tsv:"csv",pdf:"pdf",docx:"docx",xlsx:"xlsx",xlsm:"xlsx"};function JA(t){const e=t.lastIndexOf(".");if(!(e<0))return kH[t.slice(e+1).toLowerCase()]}function NH(t,e=MH){const n=t.trim();if(n.length<=e)return{text:n,truncated:!1};const i=e-100;return{text:`${n.slice(0,i)}
34
-
35
- …[已截断:原文 ${n.length} 字符,只上传了前 ${i} 字符]`,truncated:!0}}function OH(t){return{type:"file",filename:t.name,mimeType:"text/markdown",data:t.text}}function ZA(t){if(t.length===0)return"";const e=o=>o.trim().replace(/\|/g,"\\|").replace(/\r?\n/g," "),n=t.reduce((o,u)=>Math.max(o,u.length),0),i=t.map(o=>Array.from({length:n},(u,d)=>e(o[d]??""))),a=o=>`| ${o.join(" | ")} |`;return[a(i[0]),a(i[0].map(()=>"---")),...i.slice(1).map(a)].join(`
36
- `)}function DH(t){const e=t.replace(/\r\n?/g,`
37
- `).replace(/\n$/,""),n=e.indexOf(`
38
- `),i=n<0?e:e.slice(0,n),a=m=>i.split(m).length,o=[","," ",";"].reduce((m,y)=>a(y)>a(m)?y:m,","),u=[];let d=[],f="",p=!1;for(let m=0;m<e.length;m++){const y=e[m];p?y==='"'?e[m+1]==='"'?(f+='"',m++):p=!1:f+=y:y==='"'?p=!0:y===o?(d.push(f),f=""):y===`
39
- `?(d.push(f),u.push(d),d=[],f=""):f+=y}return d.push(f),u.push(d),u.filter(m=>m.some(y=>y.trim()!==""))}function jH(t){return ZA(DH(t))}let OT=!1;async function zH(t){const e=await sd(()=>import("./pdf-CfhDiWmk.js"),[]);if(!OT){OT=!0;const{default:a}=await sd(async()=>{const{default:o}=await import("./pdf.worker.min-CdXBBzB4.js");return{default:o}},[]);e.GlobalWorkerOptions.workerSrc=a}const n=await e.getDocument({data:new Uint8Array(t)}).promise,i=[];for(let a=1;a<=n.numPages;a++){const o=await(await n.getPage(a)).getTextContent();let u="",d;for(const f of o.items){if(!("str"in f))continue;const p=f.transform[5];d!==void 0&&Math.abs(p-d)>4&&(u+=`
40
- `),u+=f.str,d=p}i.push(n.numPages>1?`【第 ${a} 页】
41
- ${u.trim()}`:u.trim())}return i.join(`
42
-
43
- `)}async function PH(t){const n=(await sd(async()=>{const{default:a}=await import("./index-Dviy7gnB.js").then(o=>o.i);return{default:a}},__vite__mapDeps([0,1]))).default.convertToMarkdown;return(await n({arrayBuffer:t})).value}async function BH(t){const{Workbook:e}=await sd(async()=>{const{Workbook:a}=await import("./exceljs.min-jlEt4kSc.js").then(o=>o.e);return{Workbook:a}},__vite__mapDeps([2,1])),n=new e;await n.xlsx.load(t);const i=[];for(const a of n.worksheets){const o=[];a.eachRow({includeEmpty:!1},u=>{const d=[];u.eachCell({includeEmpty:!0},f=>d.push(f.text)),o.push(d)}),o.length>0&&i.push(`【工作表 ${a.name}】
44
- ${ZA(o)}`)}return i.join(`
45
-
46
- `)}async function UH(t){const e=JA(t.name);if(!e)throw new Error(`暂不支持的文件类型:${t.name}`);let n;switch(e){case"text":n=await t.text();break;case"csv":n=jH(await t.text());break;case"pdf":n=await zH(await t.arrayBuffer());break;case"docx":n=await PH(await t.arrayBuffer());break;case"xlsx":n=await BH(await t.arrayBuffer());break}if(n.trim()==="")throw new Error(`未检出可提取文本(扫描件或空文件?):${t.name}`);const i=NH(n);return{name:t.name,text:i.text,truncated:i.truncated}}const WA="dock.mode",e2="dock.last";function t2(t){return t?"docked":"closed"}function LH(t,e){return t==="docked"||t==="floating"||t==="closed"?t:t2(e)}function qH(t,e,n){return t!=="closed"?t:e==="floating"||e==="docked"?e:t2(n)}function DT(t){try{return localStorage.getItem(t)}catch{return null}}function jT(t,e){try{localStorage.setItem(t,e)}catch{}}const Gm=new Set,HH=()=>typeof window<"u"&&window.innerWidth>1100;let Rc="closed",Fm="docked",Mc=!1,zT=!1;function PT(){for(const t of Gm)t()}function Bp(){if(zT)return;zT=!0;const t=DT(e2);(t==="docked"||t==="floating")&&(Fm=t),Rc=LH(DT(WA),HH())}const xr={subscribe(t){return Gm.add(t),()=>Gm.delete(t)},mode(){return Bp(),Rc},lastOpen(){return Bp(),Fm},running(){return Mc},setMode(t){Bp(),t!=="closed"&&(Fm=t,jT(e2,t)),t!==Rc&&(Rc=t,jT(WA,t),PT())},setRunning(t){t!==Mc&&(Mc=t,PT())}};function VH(){return se.useSyncExternalStore(xr.subscribe,xr.mode,()=>"closed")}let BT=[];function $H(t){const e=BT;BT=[];for(const n of e)t(n);return()=>{}}function Ym(t="切换",e="助手"){return!Mc||typeof window>"u"?!0:window.confirm(`${e}正在回答,${t}会中断这一轮。继续?`)}function GH({request:t,onAnswer:e}){return _.jsxs("div",{className:"confirm",children:[_.jsxs("div",{className:"confirm-title",children:["⚠️ 助手请求执行 ",_.jsx("b",{children:t.name}),",是否允许?"]}),_.jsx("pre",{className:"confirm-args",children:JSON.stringify(t.args,null,2)}),_.jsxs("div",{className:"confirm-actions",children:[_.jsx("button",{className:"allow",onClick:()=>e(!0),children:"允许"}),_.jsx("button",{className:"deny",onClick:()=>e(!1),children:"拒绝"})]})]})}function FH({language:t,code:e}){const[n,i]=se.useState(!1),a=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}};return _.jsxs("div",{className:"code-head",children:[_.jsx("span",{className:"code-lang",children:t||"text"}),_.jsx("button",{type:"button",className:"copy-code",onClick:()=>{a()},children:n?"已复制":"复制"})]})}function YH(){const[t,e]=se.useState(null);return se.useEffect(()=>{const n=a=>{const o=a.target;!(o instanceof HTMLImageElement)||!o.closest(".thread")||e(o.currentSrc||o.src)},i=a=>{a.key==="Escape"&&e(null)};return document.addEventListener("click",n,!0),document.addEventListener("keydown",i),()=>{document.removeEventListener("click",n,!0),document.removeEventListener("keydown",i)}},[]),t?_.jsx("div",{className:"lightbox",role:"dialog","aria-label":"图片预览",onClick:()=>e(null),children:_.jsx("img",{src:t,alt:""})}):null}function QH(t){const e=t.filter(a=>a.type==="text").map(a=>a.text).join(""),n=t.filter(a=>a.type==="image").length,i=t.filter(a=>a.type==="file").length;return{text:e.trim(),images:n,docs:i}}function KH({queue:t,onSteer:e,onDrop:n}){return _.jsxs("div",{className:"queuebar",children:[_.jsxs("span",{className:"q-label",children:["等待 ",t.length," 条"]}),t.map((i,a)=>{const{text:o,images:u,docs:d}=QH(i);return _.jsxs("span",{className:"q-item",title:o||`${u} 图片 / ${d} 文档`,children:[u>0&&_.jsxs("span",{className:"q-img","aria-label":`${u} 张图片`,children:["🖼",u>1?`×${u}`:""]}),d>0&&_.jsxs("span",{className:"q-img","aria-label":`${d} 个文档`,children:["📄",d>1?`×${d}`:""]}),_.jsx("span",{className:"q-text",children:o}),_.jsx("button",{onClick:()=>e(a),title:"中止当前回答,优先发送这条",children:"插队"}),_.jsx("button",{onClick:()=>n(a),title:"从队列移除",children:"移除"})]},a)})]})}const XH=["paperclip","plus","image","upload"],Tc={kind:"svg",name:"paperclip"},UT=8;function JH(t){if(t==null)return Tc;const e=t.trim();if(!e)return Tc;if(e.startsWith("svg:")){const n=e.slice(4).trim();return XH.includes(n)?{kind:"svg",name:n}:Tc}if(e.startsWith("url:")){const n=e.slice(4).trim();return/^https?:\/\/\S+$/i.test(n)?{kind:"url",href:n}:Tc}return{kind:"text",text:e.length>UT?e.slice(0,UT):e}}const ZH={paperclip:()=>_.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"}),plus:()=>_.jsx("path",{d:"M12 5v14M5 12h14"}),image:()=>_.jsxs(_.Fragment,{children:[_.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),_.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),_.jsx("polyline",{points:"21 15 16 10 5 21"})]}),upload:()=>_.jsxs(_.Fragment,{children:[_.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),_.jsx("polyline",{points:"17 8 12 3 7 8"}),_.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})};function WH({spec:t,className:e="ac-icon"}){const n=JH(t);return n.kind==="url"?_.jsx("img",{className:e,src:n.href,alt:""}):n.kind==="text"?_.jsx("span",{className:e,"aria-hidden":"true",children:n.text}):_.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:ZH[n.name]()})}function eV(){return _.jsx("div",{className:"ac-followup",children:_.jsx(Sr.Suggestions,{children:({suggestion:t})=>_.jsx(Sr.Suggestion,{className:"ac-followup-chip",prompt:t.prompt,send:!0,title:t.prompt,children:t.title})})})}const n2={Icon:WH,FollowUpSuggestions:eV},s2=se.createContext(n2),tV=s2.Provider;function i2(){return se.useContext(s2)}function nV(t){return{...n2,...t}}function sV({tiers:t,value:e,onChange:n}){const[i,a]=se.useState(!1),[o,u]=se.useState(null),d=se.useRef(null),f=t.find(y=>y.id===e)??t[0],p=t[o??t.indexOf(f)]??f;se.useEffect(()=>{if(!i)return;const y=v=>{d.current?.contains(v.target)||a(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[i]);const m=y=>{n(y.id),a(!1),u(null)};return _.jsxs("div",{className:"tierpick",ref:d,onKeyDown:y=>{if(y.key==="Escape")a(!1),u(null);else if(i&&(y.key==="ArrowDown"||y.key==="ArrowUp")){y.preventDefault();const v=o??t.indexOf(f);u(y.key==="ArrowDown"?Math.min(t.length-1,v+1):Math.max(0,v-1))}else if(i&&y.key==="Enter"&&o!==null){y.preventDefault();const v=t[o];v&&m(v)}},children:[i&&_.jsxs("div",{className:"tier-pop",role:"listbox","aria-label":"回答档位",children:[_.jsxs("div",{className:"tier-desc",children:[_.jsx("div",{className:"tier-desc-name",children:p.label}),p.description&&_.jsx("div",{className:"tier-desc-text",children:p.description}),_.jsxs("div",{className:"tier-desc-meta",children:[_.jsx("span",{children:"消耗倍率"}),_.jsxs("span",{children:["×",p.multiplier]})]}),p.pricePerThousandTokensCents!==void 0&&_.jsxs("div",{className:"tier-desc-meta",children:[_.jsx("span",{children:"单价"}),_.jsxs("span",{children:[p.pricePerThousandTokensCents," 分/千字"]})]})]}),t.map((y,v)=>_.jsxs("button",{type:"button",role:"option","aria-selected":y.id===f.id,className:y.id===f.id?"tier-row on":"tier-row",onMouseEnter:()=>u(v),onClick:()=>m(y),children:[_.jsx("span",{children:y.label}),_.jsxs("span",{className:"tier-mult",children:["×",y.multiplier]})]},y.id))]}),_.jsxs("button",{type:"button",className:"tier-btn","aria-haspopup":"listbox","aria-expanded":i,onKeyDown:y=>{!i&&(y.key==="ArrowDown"||y.key==="ArrowUp")&&(y.preventDefault(),a(!0))},onClick:()=>a(y=>!y),children:[f.label,_.jsx("span",{className:"tier-caret",children:"▾"})]})]})}const r2="ac.theme";function a2(){const t=globalThis.localStorage?.getItem(r2);return t==="light"||t==="dark"?t:"auto"}function o2(t){t==="auto"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",t)}function iV(t){globalThis.localStorage?.setItem(r2,t)}const rV={auto:"🌗",light:"☀️",dark:"🌙"},aV={auto:"跟随系统",light:"浅色",dark:"深色"},oV={auto:"light",light:"dark",dark:"auto"};function l2(){const[t,e]=se.useState(a2);return _.jsx("button",{className:"theme-toggle",title:`主题:${aV[t]}(点击切换)`,onClick:()=>{const n=oV[t];e(n),o2(n),iV(n)},children:rV[t]})}function lV({prompt:t,onAnswer:e}){const[n,i]=se.useState(""),a=()=>{n.trim()&&e({value:n})};return _.jsxs("div",{className:"uidialog",role:t.kind==="confirm"?"alertdialog":"dialog","aria-label":t.title,children:[_.jsx("div",{className:"uidialog-title",children:t.title}),t.message&&_.jsx("div",{className:"uidialog-msg",children:t.message}),t.kind==="select"&&_.jsxs("div",{className:"uidialog-options",children:[(t.options??[]).map(o=>_.jsx("button",{onClick:()=>e({value:o}),children:o},o)),_.jsx("button",{className:"uidialog-dismiss",onClick:()=>e({cancelled:!0}),children:"取消"})]}),t.kind==="confirm"&&_.jsxs("div",{className:"uidialog-actions",children:[_.jsx("button",{className:"allow",onClick:()=>e({confirmed:!0}),children:"确定"}),_.jsx("button",{className:"deny",onClick:()=>e({cancelled:!0}),children:"取消"})]}),t.kind==="input"&&_.jsxs("div",{className:"uidialog-input",children:[_.jsx("input",{value:n,placeholder:t.placeholder??"",autoFocus:!0,onChange:o=>i(o.target.value),onKeyDown:o=>o.key==="Enter"&&a()}),_.jsx("button",{onClick:a,disabled:!n.trim(),children:"提交"}),_.jsx("button",{className:"uidialog-dismiss",onClick:()=>e({cancelled:!0}),children:"取消"})]})]})}function uV({branding:t,sessionId:e,initialMessages:n,tier:i,scope:a,renderCard:o,slots:u,persona:d,title:f,policyNote:p,welcome:m,suggestions:y,commands:v,onRunEnd:b,onTier:T}){const[w,x]=se.useState(!1),[E,C]=se.useState([]),[R,O]=se.useState(null),[L,I]=se.useState([]),[P,k]=se.useState([]),[H,V]=se.useState([]),[z,q]=se.useState({}),W=se.useRef(0),X=se.useRef(!1),Z=se.useRef([]),ee=se.useRef(e),oe=se.useRef(i),he=se.useRef(a);Z.current=E,oe.current=i,he.current=a;const ye=se.useMemo(()=>TH({getSessionId:()=>ee.current,setSessionId:ve=>{ee.current=ve},getContext:()=>{const ve=Oe.current;return Oe.current=void 0,ve},getAuthToken:()=>Tt.token,getTier:()=>oe.current,getScope:()=>he.current,getPersona:()=>d,onRunEnd:({usage:ve})=>{O(ve),I([]),k([]),X.current=!1,x(!1),b(),setTimeout(()=>fe.current?.(),0)},onToolConfirm:ve=>I(Ae=>[...Ae.filter(Ie=>Ie.toolCallId!==ve.toolCallId),ve]),onToolSettled:ve=>I(Ae=>Ae.filter(Ie=>Ie.toolCallId!==ve)),onToolsMeta:ve=>q(ve),onUiPrompt:ve=>k(Ae=>[...Ae.filter(Ie=>Ie.id!==ve.id),ve]),onUiNotify:ve=>{const Ae=++W.current;V(Ie=>[...Ie,{...ve,key:Ae}]),setTimeout(()=>V(Ie=>Ie.filter(ct=>ct.key!==Ae)),8e3)}}),[b]),D=se.useMemo(()=>({submit:({message:ve,type:Ae})=>{const Ie=ee.current;Ie&&Vm("/api/feedback",{sessionId:Ie,rating:Ae==="positive"?"up":"down",ref:ve.id},Tt.token).catch(()=>{})}}),[]),$=se.useMemo(()=>xH(t.ui?.followUp),[t.ui?.followUp]),re=CH(t,d),M=d??t.defaultPersona,N=se.useMemo(()=>re==="off"?void 0:AH($,re,M),[$,re,M]),te=se.useMemo(()=>nV(u),[u]),ie=Hz(ye,{initialMessages:n,adapters:{feedback:D,...N?{suggestion:N}:{}}}),{FollowUpSuggestions:pe}=i2(),de=se.useCallback((ve,Ae)=>{I(Ie=>Ie.filter(ct=>ct.toolCallId!==ve.toolCallId)),gH({sessionId:ve.sessionId,toolCallId:ve.toolCallId,allow:Ae},Tt.token)},[]),B=se.useCallback((ve,Ae)=>{k(ct=>ct.filter(Wt=>Wt.id!==ve.id));const Ie=ee.current;Ie&&Vm("/api/ui-response",{sessionId:Ie,id:ve.id,...Ae},Tt.token).catch(()=>{})},[]),ce=se.useCallback(()=>{const[ve,...Ae]=Z.current;ve&&(C(Ae),X.current=!0,x(!0),ie.thread.append({role:"user",content:ve}))},[ie]),fe=se.useRef(ce);fe.current=ce;const ge=se.useCallback((ve,Ae=[],Ie=[])=>{const ct=ve.trim();if(!ct&&Ae.length===0&&Ie.length===0)return;const Wt=[...ct?[{type:"text",text:ct}]:[],...Ae.map(Ot=>({type:"image",image:`data:${Ot.mimeType};base64,${Ot.data}`})),...Ie.map(Ot=>OH(Ot))];if(X.current){C(Ot=>[...Ot,Wt]);return}X.current=!0,x(!0),ie.thread.append({role:"user",content:Wt})},[ie]),Oe=se.useRef(void 0);se.useEffect(()=>$H(ve=>{Oe.current=ve.context,ge(ve.text)}),[ge]),se.useEffect(()=>{xr.setRunning(w)},[w]);const Pe=ve=>{C(Ae=>{const Ie=Ae[ve];return Ie?[Ie,...Ae.filter((ct,Wt)=>Wt!==ve)]:Ae}),ie.thread.cancelRun()},$e=ve=>C(Ae=>Ae.filter((Ie,ct)=>ct!==ve));return _.jsx(Wz,{runtime:ie,children:_.jsx(tV,{value:te,children:_.jsxs("div",{className:"chat",children:[_.jsxs("header",{className:"chatbar",children:[t.logo?_.jsx("img",{className:"logo",src:t.logo,alt:""}):null,_.jsx("h1",{children:f??t.title}),_.jsx(l2,{})]}),p&&_.jsxs("p",{className:"policy-bar",role:"note",children:[_.jsx("span",{className:"policy-dot","aria-hidden":"true",children:"i"}),_.jsx("span",{children:p})]}),_.jsxs(Sr.Root,{className:"thread",children:[_.jsxs("div",{className:"thread-wrap",children:[_.jsxs(Sr.Viewport,{className:"viewport",children:[_.jsx(Sr.Empty,{children:_.jsxs("div",{className:"welcome",children:[_.jsx("p",{children:m??t.welcome??"有什么可以帮你?"}),(y??t.suggestions??[]).map(ve=>_.jsx("button",{className:"chip",onClick:()=>ge(ve),children:ve},ve))]})}),_.jsx(c2.Provider,{value:z,children:_.jsx(d2.Provider,{value:o??(()=>null),children:_.jsx(Sr.Messages,{components:{UserMessage:dV,UserEditComposer:fV,AssistantMessage:gV}})})}),_.jsx(yx,{condition:ve=>ve.thread.isRunning,children:_.jsx(cV,{})})]}),_.jsx(Sr.ScrollToBottom,{className:"scroll-bottom",title:"滚动到最新",children:"↓"})]}),_.jsx(pe,{}),L.length>0&&_.jsx("div",{className:"confirms",children:L.map(ve=>_.jsx(GH,{request:ve,onAnswer:Ae=>de(ve,Ae)},ve.toolCallId))}),H.length>0&&_.jsx("div",{className:"notices",children:H.map(ve=>_.jsx("div",{className:`notice ${ve.level}`,children:ve.message},ve.key))}),P.length>0&&_.jsx("div",{className:"confirms",children:P.map(ve=>_.jsx(lV,{prompt:ve,onAnswer:Ae=>B(ve,Ae)},ve.id))}),E.length>0&&_.jsx(KH,{queue:E,onSteer:Pe,onDrop:$e}),R&&_.jsxs("div",{className:"statusbar",children:["本次用量 ",R.total," tokens(输入 ",R.input," / 输出 ",R.output,")"]}),_.jsx(SV,{running:w,commands:v,tiers:t.tiers,tier:i,onTier:T,onSend:ge,attachIconSpec:t.ui?.icons?.attachment,onStop:()=>ie.thread.cancelRun()}),_.jsx(YH,{})]})]})})})}function cV(){const[t,e]=se.useState(0);return se.useEffect(()=>{const n=setInterval(()=>e(i=>i+1),1e3);return()=>clearInterval(n)},[]),_.jsxs("div",{className:"loading",role:"status","aria-live":"polite",children:[_.jsxs("span",{className:"dots","aria-hidden":"true",children:[_.jsx("i",{}),_.jsx("i",{}),_.jsx("i",{})]}),"正在生成 ",t,"s"]})}function u2(){const t=me(i=>i.message.createdAt),e=eP()?.firstTokenTime,n=new Date(t);return _.jsxs("div",{className:"msg-time",children:[`${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`,e!==void 0&&_.jsxs("span",{className:"msg-ttft",children:["· 首字 ",(e/1e3).toFixed(1),"s"]})]})}function dV(){return _.jsxs(Kc.Root,{className:"msg user",children:[_.jsx(Kc.Parts,{components:{File:mV}}),_.jsx(u2,{}),_.jsx(_r.Root,{hideWhenRunning:!0,autohide:"not-last",className:"actions",children:_.jsx(_r.Edit,{title:"编辑这条消息(会丢弃它之后的回答并重新提问)",children:"编辑"})})]})}function fV(){const t=ke(),e=se.useRef(null),n=me(a=>a.composer.text);se.useEffect(()=>{const a=e.current;a&&(a.style.height="auto",a.style.height=`${a.scrollHeight}px`)},[n]);const i=()=>{const a=t.thread.getState();!a.isDisabled&&!a.isRunning&&t.composer.getState().canSend&&SH()};return _.jsxs(Zo.Root,{className:"edit-composer",onSubmit:i,children:[_.jsx(Zo.Attachments,{components:{Image:hV,File:pV}}),_.jsx(Zo.Input,{ref:e,className:"edit-input",autoFocus:!0,submitMode:"enter","aria-label":"编辑消息"}),_.jsxs("div",{className:"edit-actions",children:[_.jsx(Zo.Cancel,{className:"edit-btn",children:"取消"}),_.jsx(Zo.Send,{className:"edit-btn primary",onClick:i,children:"重新发送"})]})]})}function hV(){const t=me(e=>{const n=e.attachment.content?.find(i=>i.type==="image");return n?.type==="image"?n.image:void 0});return t?_.jsx("img",{src:t,alt:"附件"}):null}function pV(){const t=me(e=>{const n=e.attachment.content?.find(i=>i.type==="file");return n?.type==="file"?{filename:n.filename,chars:n.data.length}:void 0});return t?_.jsxs("span",{className:"doc-chip",children:["📄 ",t.filename??"文档","(",t.chars," 字符)"]}):null}function mV({filename:t,data:e}){return _.jsxs("details",{className:"doc-chip",title:"上传文件已由浏览器转换为文本随消息发送",children:[_.jsxs("summary",{children:["📄 ",t??"文档"]}),_.jsx("pre",{children:e})]})}function gV(){return _.jsxs(Kc.Root,{className:"msg assistant",children:[_.jsx(Kc.Parts,{components:{Text:yV,Reasoning:vV,tools:{Fallback:_V}}}),_.jsx(u2,{}),_.jsxs(_r.Root,{hideWhenRunning:!0,autohide:"not-last",className:"actions",children:[_.jsx(_r.Copy,{title:"复制回答",children:"复制"}),_.jsx(_r.Reload,{title:"重新生成(旧回答仍留在服务端上下文里)",children:"重新生成"}),_.jsx(_r.FeedbackPositive,{title:"这条回答有用",children:"👍"}),_.jsx(_r.FeedbackNegative,{title:"这条回答有问题",children:"👎"})]})]})}function yV(){return _.jsx(pH,{className:"md",smooth:!0,components:{CodeHeader:FH}})}function vV({text:t}){return _.jsxs("details",{className:"reasoning",children:[_.jsx("summary",{children:"思考过程"}),_.jsx("div",{className:"reasoning-body",children:t})]})}const c2=se.createContext({}),d2=se.createContext(()=>null);function bV({details:t}){const e=se.useContext(d2);return _.jsx(_.Fragment,{children:e(t)})}function _V({toolName:t,result:e,isError:n,status:i}){const a=se.useContext(c2),o=i?.type==="running",u=typeof e=="object"&&e!==null?e:{text:String(e??"")},d=!n&&!!u.details?.blocked;return _.jsxs("div",{className:`tool${n?" err":d?" blocked":""}`,children:[_.jsxs("div",{className:"tool-head",children:[_.jsx("span",{className:"tool-name",children:a[t]??"调用工具"}),o&&_.jsx("span",{className:"tool-run",children:"执行中…"}),!o&&n&&_.jsx("span",{className:"tool-run bad",children:"✗ 失败"}),!o&&d&&_.jsx("span",{className:"tool-run warn",children:"⛔ 受限"}),!o&&!n&&!d&&_.jsx("span",{className:"tool-run ok",children:"✓ 完成"})]}),d&&u.details?.user_message&&_.jsx("p",{className:"tool-blocked",children:u.details.user_message}),!o&&!n&&!d&&_.jsx(bV,{details:u.details}),n&&u.text&&_.jsx("pre",{className:"tool-err-text",children:u.text})]})}function SV({running:t,commands:e,tiers:n,tier:i,onTier:a,onSend:o,attachIconSpec:u,onStop:d}){const{Icon:f}=i2(),[p,m]=se.useState(""),[y,v]=se.useState([]),[b,T]=se.useState([]),[w,x]=se.useState(null),[E,C]=se.useState(null),R=se.useRef(null),O=se.useRef(null);se.useEffect(()=>{const V=O.current;V&&(V.style.height="auto",V.style.height=`${V.scrollHeight}px`)},[p]);const L=/^\/([a-z0-9-]*)$/.exec(p)?.[1],I=L===void 0?[]:e.filter(V=>V.name.startsWith(L)),P=V=>m(`/${V} `),k=async V=>{const z=[],q=[],W=[];for(const X of Array.from(V??[]))if(JA(X.name)){if(b.length+q.length>=Pp){W.push(`文档最多 ${Pp} 个`);continue}x(X.name),C(null);try{q.push(await UH(X))}catch(Z){W.push(Z.message)}finally{x(null)}}else if(z.length<4){const Z=await new Promise(oe=>{const he=new FileReader;he.onload=()=>oe(String(he.result)),he.readAsDataURL(X)}),ee=XA(Z);ee?z.push({url:Z,image:ee}):W.push(`暂不支持的文件:${X.name}`)}z.length>0&&v(X=>[...X,...z].slice(0,4)),q.length>0&&T(X=>[...X,...q].slice(0,Pp)),C(W.length>0?W.join(";"):null)},H=()=>{const V=p.trim();!V&&y.length===0&&b.length===0||w===null&&(V.startsWith("/")&&!e.some(z=>V===`/${z.name}`||V.startsWith(`/${z.name} `))||(o(V,y.map(z=>z.image),b),m(""),v([]),T([]),C(null)))};return _.jsxs("div",{className:"composer",children:[I.length>0&&_.jsx("div",{className:"cmds",role:"listbox","aria-label":"指令",children:I.map(V=>_.jsxs("button",{type:"button",className:"cmd",role:"option","aria-selected":!1,onClick:()=>P(V.name),children:[_.jsxs("span",{className:"cmd-name",children:["/",V.name]}),_.jsx("span",{className:"cmd-desc",children:V.description})]},V.name))}),y.length>0&&_.jsx("div",{className:"attach",children:y.map((V,z)=>_.jsxs("span",{className:"attach-thumb",children:[_.jsx("img",{src:V.url,alt:`附件 ${z+1}`}),_.jsx("button",{type:"button",title:"移除图片",onClick:()=>v(q=>q.filter((W,X)=>X!==z)),children:"×"})]},z))}),(b.length>0||w!==null)&&_.jsxs("div",{className:"attach",children:[b.map((V,z)=>_.jsxs("span",{className:"doc-chip",title:`${V.text.length} 字符${V.truncated?"(已截断)":""}`,children:["📄 ",V.name,_.jsx("button",{type:"button",title:"移除文档",onClick:()=>T(q=>q.filter((W,X)=>X!==z)),children:"×"})]},z)),w!==null&&_.jsxs("span",{className:"doc-chip pending",children:["⏳ 正在解析 ",w,"…"]})]}),E!==null&&_.jsx("div",{className:"attach-err",children:E}),_.jsx("textarea",{ref:O,rows:1,value:p,onChange:V=>m(V.target.value),onPaste:V=>{Array.from(V.clipboardData.files).length>0&&(V.preventDefault(),k(V.clipboardData.files))},onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),H())},placeholder:t?"输入追加需求,将在当前回答后执行…":"输入问题,Enter 发送(可粘贴或选择图片/文档)"}),_.jsx("input",{ref:R,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,.md,.markdown,.txt,.log,.json,.yaml,.yml,.csv,.tsv,.pdf,.docx,.xlsx,.xlsm",multiple:!0,hidden:!0,onChange:V=>{k(V.target.files),V.target.value=""}}),_.jsx("button",{type:"button",className:"attach-btn",title:"添加图片或文档(各最多 4 个)",onClick:()=>R.current?.click(),children:_.jsx(f,{spec:u})}),n&&n.length>0&&_.jsx(sV,{tiers:n,value:i,onChange:a}),t?_.jsx("button",{className:"stop",onClick:d,children:"停止"}):_.jsx("button",{className:"send",disabled:!p.trim()&&y.length===0&&b.length===0||w!==null,onClick:H,children:"发送"})]})}function TV(t,e,n){return Math.min(n,Math.max(e,t))}function wV(t,e,n,i){const a=Number(t);return t!==null&&t!==""&&Number.isFinite(a)&&a>=n&&a<=i?a:e}function f2(t,e,n,i){const[a,o]=se.useState(()=>{let f=null;try{f=localStorage.getItem(t)}catch{}return wV(f,e,n,i)}),u=se.useRef(null),d=se.useCallback(f=>{const p=TV(f,n,i);o(p);try{localStorage.setItem(t,String(p))}catch{}},[t,n,i]);return{width:a,handlers:{onPointerDown:f=>{f.currentTarget.setPointerCapture(f.pointerId),u.current={startX:f.clientX,startW:a}},onPointerMove:f=>{const p=u.current;p&&d(p.startW+f.clientX-p.startX)},onPointerUp:()=>{u.current=null},onDoubleClick:()=>d(e)}}}function h2(t){return _.jsx("div",{className:"splitter",role:"separator","aria-orientation":"vertical",title:"拖动调整宽度,双击恢复默认",...t})}const xV=864e5;function LT(t){const e=new Date(t);return e.setHours(0,0,0,0),e.getTime()}function p2(t,e){const n=Date.parse(t);return Number.isNaN(n)?0:Math.round((LT(e.getTime())-LT(n))/xV)}function CV(t,e){const n=Date.parse(t);if(Number.isNaN(n))return"";const i=e.getTime()-n;if(i<6e4)return"刚刚";if(i<36e5)return`${Math.floor(i/6e4)} 分钟前`;const a=p2(t,e);if(a===0)return`${Math.floor(i/36e5)} 小时前`;const o=new Date(n);if(a===1)return"昨天";const u=`${o.getMonth()+1}月${o.getDate()}日`;return o.getFullYear()===e.getFullYear()?u:`${o.getFullYear()}年${u}`}function EV(t,e){const n=p2(t,e);return n<=0?"今天":n===1?"昨天":n<=6?"近 7 天":n<=29?"近 30 天":"更早"}function AV(t,e){const n=[];for(const i of t){const a=EV(i.updatedAt,e),o=n[n.length-1];o&&o.label===a?o.items.push(i):n.push({label:a,items:[i]})}return n}function Up(t,e){const n=IV(t);return n?`${n.year}-${n.month}-${n.day} ${n.hour}:${n.minute}`:t?String(t):"—"}function IV(t,e,n){if(!t)return null;const i=new Date(t);if(Number.isNaN(i.getTime()))return null;const a=new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(i),o=u=>a.find(d=>d.type===u)?.value??"";return{year:o("year"),month:o("month"),day:o("day"),hour:o("hour"),minute:o("minute")}}function RV(t){const e=`(max-width: ${t}px)`;return se.useSyncExternalStore(n=>{const i=window.matchMedia(e);return i.addEventListener("change",n),()=>i.removeEventListener("change",n)},()=>window.matchMedia(e).matches,()=>!1)}function MV({branding:t,scope:e,renderCard:n,slots:i,persona:a,title:o,policyNote:u,welcome:d,suggestions:f,compact:p=!1,showBrand:m=!1,assistantLabel:y="助手"}){const[v,b]=se.useState({key:0}),[T,w]=se.useState(null),x=t.defaultPersona??"default",E=(T??[]).filter(ye=>(ye.persona??x)===(a??x)),[C,R]=se.useState(t.tiers?.[0]?.id),[O,L]=se.useState([]),I=f2("acnav.width",210,160,420),[P,k]=se.useState(()=>localStorage.getItem("acnav.collapsed")==="1"),H=RV(900),[V,z]=se.useState(!1),q=P||(p||H)&&!V,W=()=>{const ye=!q;k(ye),z(!0),localStorage.setItem("acnav.collapsed",ye?"1":"0")},X=se.useCallback(()=>{const ye=e?`?scope=${encodeURIComponent(e)}`:"";Kn(`/api/sessions${ye}`,Tt.token).then(D=>w(D.sessions)).catch(()=>w([]))},[e]);se.useEffect(()=>{const ye=e?`?qual=${encodeURIComponent(e)}`:"";Kn(`/api/commands${ye}`).then(D=>L(D.commands)).catch(()=>L([])),X()},[X]);const Z=se.useRef(e);se.useEffect(()=>{Z.current!==e&&(Z.current=e,b(ye=>({key:ye.key+1})))},[e]);const ee=()=>{Ym("新建会话",y)&&b(ye=>({key:ye.key+1}))},oe=async ye=>{if(!Ym("切换历史会话",y))return;let D;try{D=(await Kn(`/api/history?sessionId=${encodeURIComponent(ye.sessionId)}`,Tt.token)).messages.map(re=>({role:re.role,content:re.text,createdAt:new Date(re.at)}))}catch{D=void 0}b($=>({key:$.key+1,sessionId:ye.sessionId,initialMessages:D}))},he=_.jsx(uV,{branding:t,persona:a,title:o,policyNote:u,welcome:d,suggestions:f,sessionId:v.sessionId,initialMessages:v.initialMessages,tier:C,scope:e,renderCard:n,slots:i,onTier:R,commands:O,onRunEnd:X},v.key);return _.jsxs("div",{className:"ac-row",children:[_.jsxs("aside",{className:`side acnav${q?" collapsed":""}`,style:{flexBasis:I.width},children:[m&&_.jsxs("div",{className:"brand",children:[t.logo?_.jsx("img",{className:"logo",src:t.logo,alt:""}):null,_.jsx("span",{children:t.title})]}),_.jsx("button",{className:"newchat",onClick:ee,title:"重新开始一个会话",children:"+ 新会话"}),_.jsxs("div",{className:"hist-h",children:["历史会话",_.jsx("button",{className:"collapse-btn",onClick:W,title:"收起侧栏",children:"«"})]}),_.jsx("div",{className:"sessions",children:T===null?_.jsx("div",{className:"s-empty",children:"加载中…"}):E.length===0?_.jsx("div",{className:"s-empty",children:"暂无历史会话"}):AV(E,new Date).map(ye=>_.jsxs("div",{children:[_.jsx("div",{className:"s-group",children:ye.label}),ye.items.map(D=>_.jsxs("button",{className:"s-item",title:D.title,onClick:()=>{oe(D)},children:[_.jsx("span",{className:"s-title",children:D.title}),_.jsxs("span",{className:"s-meta",children:[CV(D.updatedAt,new Date)," · ",D.messageCount," 条"]})]},D.sessionId))]},ye.label))})]}),!q&&_.jsx(h2,{...I.handlers}),q&&_.jsxs("button",{className:"side-open",onClick:W,title:"展开历史会话侧栏","aria-label":"展开历史会话侧栏",children:[_.jsx("span",{className:"side-open-arrow",children:"»"}),_.jsx("span",{className:"side-open-text",children:"历史"})]}),_.jsx("main",{className:"content",children:he})]})}function kV({chat:t,full:e=!1,onClose:n,title:i="助手",children:a}){const o=VH(),u=e?"full":o,d=()=>{xr.setMode("closed"),n?.()};return _.jsxs("div",{className:`dock-wrap ${u}`,children:[!e&&_.jsx("main",{className:"content",children:a}),_.jsxs("aside",{className:`dock-pane${o==="closed"&&!e?" gone":""}`,"aria-label":i,children:[_.jsxs("div",{className:"dock-head",children:[_.jsx("span",{className:"dock-title",children:i}),e?null:_.jsx("button",{className:"dock-btn",onClick:()=>xr.setMode(o==="floating"?"docked":"floating"),title:o==="floating"?"停靠到右侧":"改为悬浮","aria-label":o==="floating"?"停靠到右侧":"改为悬浮",children:o==="floating"?"⇥":"⤢"}),_.jsx("button",{className:"dock-btn",onClick:d,title:`收起${i}`,"aria-label":`收起${i}`,children:"»"})]}),_.jsx("div",{className:"dock-body",children:t})]}),o==="closed"&&!e&&_.jsxs("button",{className:"side-open dock-open",onClick:()=>xr.setMode(qH(o,xr.lastOpen(),window.innerWidth>1100)),title:`打开${i}`,"aria-label":`打开${i}`,children:[_.jsx("span",{className:"side-open-arrow",children:"«"}),_.jsx("span",{className:"side-open-text",children:i})]})]})}const m2="ac.qual";function NV(){try{return localStorage.getItem(m2)}catch{return null}}function Lp(t){try{localStorage.setItem(m2,t)}catch{}}function id(t){return t.enabled!==!1}function OV(t){if(!t||t.length===0)return null;const e=NV();return(e?t.find(i=>i.id===e&&id(i)):void 0)??t.find(id)??null}function qT(t){const e=t.indexOf("?");if(e<0)return null;const n=new URLSearchParams(t.slice(e+1)).get("qual");return n||null}function HT(t){const e=/^#\/([a-z]+)/.exec(window.location.hash);return e&&e[1]in t.routes?e[1]:t.chatRoute}function DV(t){const e={...t.theme??{}};return e["--chat-primary"]&&!e["--ac-primary"]&&(e["--ac-primary"]=e["--chat-primary"]),e}function jV(t){const[e,n]=se.useState(()=>HT(t)),[i,a]=se.useState(""),[o,u]=se.useState(null),[d,f]=se.useState(null),[p,m]=se.useState(null),[y]=se.useState(()=>qT(window.location.hash)),v=se.useRef(t.home),[b,T]=se.useState(null);se.useEffect(()=>{Kn("/api/branding").then(I=>{u(I);const P=y?I.quals?.find(k=>k.id===y&&id(k)):void 0;P?(Lp(P.id),m(P.id)):m(k=>OV(I.quals)?.id??k)}).catch(I=>f(String(I)))},[]),se.useEffect(()=>{Kn("/api/whoami",Tt.token).then(T).catch(()=>{})},[]),se.useEffect(()=>{const I=()=>{n(HT(t));const P=qT(window.location.hash),k=P?o?.quals?.find(H=>H.id===P&&id(H)):void 0;k&&(Lp(k.id),m(H=>H===k.id?H:k.id))};return window.addEventListener("hashchange",I),()=>window.removeEventListener("hashchange",I)},[t,o]),se.useEffect(()=>{const I=t.rewrites?.[e];if(!I)return;const P=new URL(window.location.href);P.hash=`#/${I}`,window.history.replaceState(null,"",P.toString().slice(P.origin.length)),n(I.split("?")[0])},[e,t]);const w=I=>{I!==t.chatRoute&&(v.current=I),window.location.hash=`#/${I}`,n(I)},x=I=>{const P=i||o?.defaultPersona||"",k=o?.personas?.[P]?.label??P??"助手";I!==p&&!Ym(t.labels?.switchConfirm??"切换选项",k)||(Lp(I),m(I),w(t.chatRoute))},E=o?.quals??[],C=o?.quals?.find(I=>I.id===p)??null,R=E.length>0&&C===null||e==="quals",O=o?{branding:o,who:b,qual:C,route:e,persona:i,onQuals:R,go:w,pickQual:x}:null;se.useEffect(()=>{if(!O||!t.guard||!b?.authzEnabled||b.roles.includes("admin"))return;const I=t.guard(e,O);I&&(window.location.hash=`#/${I}`)},[O,t,b,e]);const L=R?"quals":t.navAlias?.[e]??e;return{ready:o!==null,loadError:d,branding:o,who:b,quals:E,qual:C,qualId:p,route:e,shown:L,onQuals:R,persona:i,setPersona:a,go:w,closeChat:()=>w(v.current),pickQual:x,ctx:O}}function zV({branding:t,qual:e,route:n,nav:i,who:a,onRoute:o,onQuals:u,switchTitle:d,footer:f,children:p}){const m=f2("shellnav.width",150,120,280);return _.jsxs(_.Fragment,{children:[_.jsxs("aside",{className:"side shellnav",style:{flexBasis:m.width},children:[_.jsxs("div",{className:"brand",children:[t.logo?_.jsx("img",{className:"logo",src:t.logo,alt:""}):null,_.jsx("span",{children:t.title}),_.jsx(l2,{})]}),e&&_.jsxs("button",{className:"qual-pick",onClick:u,title:d??"切换选项",children:[_.jsx("span",{className:"qual-name",children:e.label}),_.jsx("span",{className:"qual-switch",children:"切换"})]}),_.jsx("nav",{className:"nav",children:i.map(y=>_.jsx("button",{className:y.route===n?"nav-item on":"nav-item",onClick:()=>o(y.route),children:y.label},y.route))}),f,QA&&_.jsx(PV,{who:a})]}),_.jsx(h2,{...m.handlers}),p]})}function PV({who:t}){const e=Tt.devUserId??"",n=t?.roles??[],i=n.includes("admin")?"管理员":n.includes("member")?"会员":"普通用户",a=MT.some(o=>o.id===e);return _.jsxs("div",{className:"dev-id",children:[_.jsxs("label",{className:"dev-id-row",children:[_.jsx("span",{children:"开发身份"}),_.jsxs("select",{value:e,onChange:o=>{Tt.setDevUserId(o.target.value),window.location.reload()},"aria-label":"开发身份",children:[!a&&e&&_.jsx("option",{value:e,children:e}),MT.map(o=>_.jsx("option",{value:o.id,children:o.label},o.id))]})]}),_.jsxs("span",{className:"dev-id-note",title:`${t?.userId??e} · ${i}`,children:[i,t?.memberUntil?` 至 ${t.memberUntil.slice(5,10)}`:"",t?.bannedUntil?" · 已封禁":""]})]})}function BV({def:t,texts:e,slots:n,footer:i,extras:a,loadErrorHint:o}){const u=jV(t);if(u.loadError)return _.jsxs("div",{className:"center",children:[_.jsxs("p",{children:["无法连接服务:",u.loadError]}),o]});if(!u.ready)return _.jsx("div",{className:"center",children:"加载中…"});const{branding:d,who:f,qual:p,route:m,shown:y,onQuals:v,persona:b,go:T,ctx:w}=u,x=!v&&m===t.chatRoute,E=e(d,b);return _.jsx("div",{className:"shell",style:DV(d),children:_.jsxs(zV,{branding:d,qual:p,route:y,nav:t.navItems(w),who:f,onRoute:C=>{C===t.chatRoute&&u.persona&&u.setPersona(""),T(C)},onQuals:()=>T("quals"),switchTitle:t.labels?.switchTitle,footer:i?.(u),children:[_.jsx(kV,{title:E.title,full:x,onClose:u.closeChat,chat:_.jsx(MV,{branding:d,scope:p?.id,renderCard:t.cardRenderer,slots:n,persona:b||void 0,title:E.title,assistantLabel:E.assistantLabel,policyNote:E.policyNote,welcome:E.welcome,suggestions:E.suggestions,compact:!x},b),children:t.page(w)}),a?.(u)]})})}const UV=["off","static","llm"],VT=[{key:"label",label:"入口名"},{key:"icon",label:"图标"},{key:"tag",label:"标签"},{key:"hint",label:"悬停提示"},{key:"welcome",label:"空态标题",multiline:!0},{key:"policyNote",label:"常驻提示条",multiline:!0},{key:"suggestions",label:"快捷问法(一行一条)",multiline:!0,list:!0},{key:"followUpMode",label:"下一步建议",options:UV}],qp={manifest:"manifest",file:"已改",draft:"草稿"},$T={save:"保存",reset:"恢复默认",rollback:"回滚"},GT=t=>JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]])),FT=t=>JSON.stringify([...t].sort());async function sl(t,e,n,i){const a=await fetch(t,{method:e,headers:{...n===void 0?{}:{"content-type":"application/json"},...i===void 0?{}:{"if-match":String(i)},...eo(Tt.token)},...n===void 0?{}:{body:JSON.stringify(n)}}),o=await a.json().catch(()=>null);if(!a.ok)throw new Error(o?.error?.message??`HTTP ${a.status}`);return o}function LV(){const[t,e]=se.useState(null),[n,i]=se.useState(null),[a,o]=se.useState(null),[u,d]=se.useState(""),[f,p]=se.useState({}),[m,y]=se.useState([]),[v,b]=se.useState(null),[T,w]=se.useState([]),[x,E]=se.useState(null),[C,R]=se.useState("你好,用一句话说明你是谁、能做什么。"),[O,L]=se.useState(null),[I,P]=se.useState(null),[k,H]=se.useState(null),[V,z]=se.useState(null),[q,W]=se.useState(null),[X,Z]=se.useState(!1),ee=se.useCallback(async()=>{try{const B=await Kn("/api/admin/personas",Tt.token);e(B),z(null),i(ce=>ce??B.personas[0]?.id??null)}catch(B){z(`读取失败:${B.message}`)}},[]),oe=se.useCallback(async B=>{try{const ce=await Kn(`/api/admin/personas/${encodeURIComponent(B)}/versions`,Tt.token);w(ce.versions)}catch{w([])}},[]);se.useEffect(()=>{ee()},[ee]),se.useEffect(()=>{if(!n)return;let B=!0;return o(null),b(null),E(null),L(null),P(null),Z(!1),oe(n),Kn(`/api/admin/personas/${encodeURIComponent(n)}`,Tt.token).then(ce=>{B&&(o(ce),d(ce.effective.prompt),p(ce.effective.ui??{}),y(ce.effective.disabledTools))}).catch(ce=>B&&z(`读取 ${n} 失败:${ce.message}`)),()=>{B=!1}},[n,oe]);const he=a!==null&&(u!==a.effective.prompt||FT(m)!==FT(a.effective.disabledTools)||GT(f)!==GT(a.effective.ui??{})),ye=()=>{const B={...a?.overrideUi??{}},ce=a?.effective.ui??{};for(const fe of VT){const ge=f[fe.key];if(JSON.stringify(ge??null)===JSON.stringify(ce[fe.key]??null))continue;ge===void 0||ge===""||Array.isArray(ge)&&ge.length===0?delete B[fe.key]:B[fe.key]=ge}return B},D=a?.manifest.allowTools??null,$=D??[],re=(a?.manifest.requiredSections??[]).filter(B=>!u.split(`
47
- `).some(ce=>ce.trimStart().startsWith(B))),M=async()=>{if(a){H("save"),z(null),W(null);try{const B={prompt:u},ce=ye();Object.keys(ce).length>0&&(B.ui=ce),m.length>0&&(B.disabledTools=m),await sl(`/api/admin/personas/${encodeURIComponent(a.id)}`,"PUT",B,a.version),W("已保存。新会话生效;正在进行的会话不变。"),await ee(),i(a.id);const fe=await Kn(`/api/admin/personas/${encodeURIComponent(a.id)}`,Tt.token);o(fe),d(fe.effective.prompt),p(fe.effective.ui??{}),y(fe.effective.disabledTools),b(null),await oe(a.id)}catch(B){z(`保存失败:${B.message}`)}finally{H(null)}}},N=async()=>{if(a){if(!X){Z(!0),setTimeout(()=>Z(!1),4e3);return}H("reset"),z(null);try{await sl(`/api/admin/personas/${encodeURIComponent(a.id)}`,"DELETE",void 0,a.version),W("已恢复为 manifest 默认。"),Z(!1),await ee(),i(a.id);const B=await Kn(`/api/admin/personas/${encodeURIComponent(a.id)}`,Tt.token);o(B),d(B.effective.prompt),p(B.effective.ui??{}),y(B.effective.disabledTools),b(null),await oe(a.id)}catch(B){z(`恢复失败:${B.message}`)}finally{H(null)}}},te=async()=>{if(a){H("preview"),z(null);try{const B=await sl(`/api/admin/personas/${encodeURIComponent(a.id)}/preview`,"POST",{prompt:u,disabledTools:m});b(B)}catch(B){z(`预览失败:${B.message}`)}finally{H(null)}}},ie=async B=>{if(a){H("version"),z(null);try{const ce=await Kn(`/api/admin/personas/${encodeURIComponent(a.id)}/versions/${B}`,Tt.token);E(ce)}catch(ce){z(`读取 v${B} 失败:${ce.message}`)}finally{H(null)}}},pe=async B=>{if(a){H("rollback"),z(null),W(null);try{await sl(`/api/admin/personas/${encodeURIComponent(a.id)}/rollback`,"POST",{version:B},a.version);const ce=await Kn(`/api/admin/personas/${encodeURIComponent(a.id)}`,Tt.token);W(`已回滚到 v${B}(记为新版本)。新会话生效;历史版本都还在。`),o(ce),d(ce.effective.prompt),p(ce.effective.ui??{}),y(ce.effective.disabledTools),b(null),E(null),await ee(),await oe(a.id)}catch(ce){z(`回滚失败:${ce.message}`)}finally{H(null)}}},de=async()=>{if(!(!a||C.trim()==="")){H("trial"),P(null),L(null);try{const B=await sl(`/api/admin/personas/${encodeURIComponent(a.id)}/trial`,"POST",{message:C,prompt:u,disabledTools:m});L(B)}catch(B){P(`试跑失败:${B.message}`)}finally{H(null)}}};return V&&!t?_.jsxs("p",{className:"ps-note",children:["无法读取人格配置:",V]}):t?_.jsxs("div",{className:"ps",children:[_.jsxs("header",{className:"ps-head",children:[_.jsxs("div",{children:[_.jsx("h2",{className:"ps-title",children:"人格"}),_.jsxs("p",{className:"ps-note",children:["来源:",_.jsx("b",{children:qp[t.source]??t.source})," · 版本 ",t.version," ·"," ",_.jsx("code",{className:"ps-code",title:t.file,children:t.file.split(/[\\/]/).pop()})]}),_.jsxs("p",{className:"ps-note",children:["保存后",_.jsx("b",{children:"对新会话生效"}),";已在进行中的会话不变(人格与 prompt 在建会话时定死)。"]})]}),_.jsxs("div",{className:"ps-actions",children:[_.jsx("button",{className:"ps-btn",onClick:te,disabled:k!==null||!a,children:k==="preview"?"编译中…":"编译预览"}),_.jsx("button",{className:"ps-btn primary",onClick:M,disabled:k!==null||!a||!he,children:k==="save"?"保存中…":he?"保存":"已保存"}),_.jsx("button",{className:"ps-btn",onClick:N,disabled:k!==null||!a||a.source==="manifest",children:X?"确认恢复?":"恢复默认"})]})]}),t.problems.length>0&&_.jsxs("p",{className:"ps-warn",children:["配置文件有问题:",t.problems.join(";")]}),q&&_.jsx("p",{className:"ps-ok",children:q}),V&&_.jsx("p",{className:"ps-err",children:V}),_.jsxs("div",{className:"ps-body",children:[_.jsx("aside",{className:"ps-list",children:t.personas.map(B=>_.jsxs("button",{className:`ps-item${B.id===n?" on":""}`,onClick:()=>i(B.id),children:[_.jsx("span",{className:"ps-item-icon",children:B.icon??"·"}),_.jsx("span",{className:"ps-item-name",children:B.label??B.id}),_.jsx("span",{className:`ps-badge ${B.source}`,children:qp[B.source]})]},B.id))}),_.jsx("main",{className:"ps-editor",children:a?_.jsxs(_.Fragment,{children:[_.jsxs("section",{className:"ps-sec",children:[_.jsxs("div",{className:"ps-sec-head",children:[_.jsx("h3",{children:"人格正文"}),_.jsxs("span",{className:"ps-note",children:[u.length," 字",re.length>0&&_.jsxs("span",{className:"ps-err",children:[" · 缺必备段落:",re.join("、")]})]})]}),_.jsx("textarea",{className:"ps-prompt",value:u,onChange:B=>d(B.target.value),spellCheck:!1}),a.manifest.requiredSections.length>0&&_.jsxs("p",{className:"ps-note",children:["必备段落(产品声明,缺了存不进去):",a.manifest.requiredSections.map(B=>_.jsx("code",{className:"ps-code",children:B},B))]})]}),_.jsxs("section",{className:"ps-sec",children:[_.jsxs("div",{className:"ps-sec-head",children:[_.jsx("h3",{children:"用户看到的"}),_.jsx("span",{className:"ps-note",children:"只影响界面,不进模型"})]}),_.jsx("div",{className:"ps-ui-grid",children:VT.map(B=>_.jsxs("label",{className:`ps-field${B.multiline?" wide":""}`,children:[_.jsx("span",{children:B.label}),(()=>{const ce=f[B.key],fe=a.manifest.ui?.[B.key],ge=B.list?Array.isArray(ce)?ce.join(`
48
- `):"":typeof ce=="string"?ce:"",Oe=B.list?Array.isArray(fe)?fe.join(`
49
- `):"":typeof fe=="string"?fe:"",Pe=$e=>{const ve={...f};if(B.list){const Ae=$e.split(`
50
- `).map(Ie=>Ie.trim()).filter(Boolean);Ae.length===0?delete ve[B.key]:ve[B.key]=Ae}else $e===""?delete ve[B.key]:ve[B.key]=$e;p(ve)};if(B.options){const $e=t?.globalFollowUpMode==="off";return _.jsxs(_.Fragment,{children:[_.jsxs("select",{"data-field":B.key,value:ge,disabled:$e,onChange:ve=>Pe(ve.target.value),children:[_.jsx("option",{value:"",children:Oe?`用出厂值(${Oe})`:"用出厂值 / 跟随全局"}),B.options.map(ve=>_.jsx("option",{value:ve,children:ve},ve))]}),$e&&_.jsx("span",{children:"全局已关闭,此项暂不生效"})]})}return B.multiline?_.jsx("textarea",{"data-field":B.key,rows:B.list?3:2,value:ge,placeholder:Oe,onChange:$e=>Pe($e.target.value)}):_.jsx("input",{"data-field":B.key,value:ge,placeholder:Oe,onChange:$e=>Pe($e.target.value)})})()]},B.key))}),a.id===t.defaultPersona&&_.jsxs("p",{className:"ps-note",children:["默认助手没有侧栏入口:",_.jsx("b",{children:"图标 / 标签 / 悬停提示"}),"目前没有展示位置;",_.jsx("b",{children:"入口名"}),"用在聊天窗标题,",_.jsx("b",{children:"空态标题 / 提示条 / 快捷问法"}),"用在对话空态。"]})]}),_.jsxs("section",{className:"ps-sec",children:[_.jsxs("div",{className:"ps-sec-head",children:[_.jsx("h3",{children:"能力面(只读)"}),_.jsx("span",{className:"ps-note",children:"来自 manifest,改它要改代码 + review;这里只能临时停用"})]}),D===null?_.jsx("p",{className:"ps-note",children:"该人格没有工具白名单(= 不限)。停用仍然生效,但白名单本身不在这里改。"}):D.length===0?_.jsx("p",{className:"ps-note",children:"白名单是空数组:一个工具都不给(不是「全给」)。"}):_.jsx("ul",{className:"ps-tools",children:$.map(B=>_.jsx("li",{children:_.jsxs("label",{children:[_.jsx("input",{type:"checkbox",checked:m.includes(B),onChange:ce=>{y(fe=>ce.target.checked?[...fe,B]:fe.filter(ge=>ge!==B))}}),_.jsx("code",{className:"ps-code",children:B}),_.jsxs("span",{className:"ps-note",children:[" ",m.includes(B)?"已停用":"生效中"]})]})},B))}),_.jsx("p",{className:"ps-note",children:"技能目录同样只读(来自 manifest 的 `skills`)。"})]}),_.jsxs("section",{className:"ps-sec ps-versions",children:[_.jsxs("div",{className:"ps-sec-head",children:[_.jsx("h3",{children:"版本历史"}),_.jsx("span",{className:"ps-note",children:"每次写入留一版(每人格最近 20 版);回滚=写新版本,历史不删"})]}),T.length===0?_.jsx("p",{className:"ps-note",children:"还没有版本记录(当前就是 manifest 原样)。"}):_.jsx("ul",{className:"ps-version-list",children:T.map(B=>_.jsxs("li",{className:"ps-version",children:[_.jsxs("span",{className:"ps-vnum",children:["v",B.version]}),_.jsx("span",{className:"ps-vact",children:$T[B.action]??B.action}),_.jsxs("span",{className:"ps-note ps-vmeta",children:[B.by," · ",Up(B.at),B.promptLen!==null?` · ${B.promptLen} 字`:"",B.restoredFrom!==null?` · 来自 v${B.restoredFrom}`:""]}),_.jsxs("span",{className:"ps-vbtns",children:[_.jsxs("button",{className:"ps-btn mini",onClick:()=>{ie(B.version)},disabled:k!==null,children:["查看 v",B.version]}),_.jsxs("button",{className:"ps-btn mini",onClick:()=>{pe(B.version)},disabled:k!==null||B.version===T[0]?.version,children:["回滚到 v",B.version]})]})]},B.version))}),x&&_.jsxs("div",{className:"ps-vbody-wrap",children:[_.jsxs("p",{className:"ps-note",children:["v",x.version," 的快照(",$T[x.action]??x.action," · ",x.by," ·"," ",Up(x.at),"),只读:"]}),_.jsx("pre",{className:"ps-vbody",children:x.override?.prompt??"(这一版没有覆盖正文 = 用 manifest 原样)"})]})]}),a.updatedBy&&_.jsxs("p",{className:"ps-note",children:["最后修改:",a.updatedBy," · ",Up(a.updatedAt)]})]}):_.jsx("p",{className:"ps-note",children:"读取中…"})})]}),_.jsxs("section",{className:"ps-trial",children:[_.jsxs("div",{className:"ps-sec-head",children:[_.jsx("h3",{children:"试跑"}),_.jsxs("span",{className:"ps-note",children:["用编辑器里的",_.jsx("b",{children:"草稿"}),"真调一次模型(花 token;不写历史、不计费、不扣次数,只留一条审计)"]})]}),_.jsxs("div",{className:"ps-trial-row",children:[_.jsx("textarea",{className:"ps-trial-input",rows:2,placeholder:"输入一句话,看看这个人格会怎么答",value:C,onChange:B=>R(B.target.value)}),_.jsx("button",{className:"ps-btn primary",onClick:()=>{de()},disabled:k!==null||!a||C.trim()==="",children:k==="trial"?"试跑中…":"试跑"})]}),I&&_.jsx("p",{className:"ps-err ps-trial-err",children:I}),O&&_.jsxs("div",{className:"ps-trial-out",children:[_.jsxs("div",{className:"ps-trial-meta",children:[_.jsx("span",{className:`ps-badge ${O.draft?"draft":"file"}`,children:O.draft?"草稿":"已保存"}),_.jsxs("span",{className:"ps-note",children:[O.tokens," tokens · ",O.ms," ms · 工具:",O.tools.join("、")||"无"," · 未写历史、未计费"]})]}),_.jsx("pre",{className:"ps-trial-reply",children:O.reply})]})]}),v&&_.jsxs("section",{className:"ps-preview",children:[_.jsxs("div",{className:"ps-sec-head",children:[_.jsx("h3",{children:"编译预览"}),_.jsx("span",{className:`ps-badge ${v.source}`,children:qp[v.source]??v.source})]}),v.requiredSections.missing.length>0&&_.jsxs("p",{className:"ps-err",children:["缺必备段落:",v.requiredSections.missing.join("、")]}),_.jsxs("div",{className:"ps-prev-grid",children:[_.jsxs("div",{children:[_.jsx("h4",{children:"最终 system prompt"}),_.jsx("pre",{className:"ps-pre",children:v.systemPrompt})]}),_.jsxs("div",{children:[_.jsx("h4",{children:"工具(内联)"}),v.tools.length===0?_.jsx("p",{className:"ps-note",children:"该人格没有内联工具。"}):_.jsx("ul",{className:"ps-tools",children:v.tools.map(B=>_.jsxs("li",{children:[_.jsx("code",{className:"ps-code",children:B.name}),_.jsxs("span",{className:"ps-note",children:[" ",B.label?`「${B.label}」`:""," ",B.active?"生效":B.disabled?"已停用":"不在白名单"]})]},B.name))}),_.jsx("h4",{children:"技能"}),v.skills.length===0?_.jsx("p",{className:"ps-note",children:"不继承任何技能。"}):_.jsx("ul",{className:"ps-tools",children:v.skills.map(B=>_.jsxs("li",{children:[_.jsx("code",{className:"ps-code",children:B.name})," ",_.jsx("span",{className:"ps-note",children:B.description})]},B.name))}),_.jsx("h4",{children:"MCP"}),v.mcp.length===0?_.jsx("p",{className:"ps-note",children:"没有接入。"}):_.jsx("ul",{className:"ps-tools",children:v.mcp.map(B=>_.jsxs("li",{children:[_.jsx("code",{className:"ps-code",children:B.server})," ",_.jsx("span",{className:"ps-note",children:B.mode==="all"?"全部可见":B.mode==="whitelist"?`白名单:${B.visible.join("、")||"(空)"}`:"全部可见,逐个停用"})]},B.server))})]})]})]})]}):_.jsx("p",{className:"ps-note",children:"正在读取人格配置…"})}const wc={chat:"助手",home:"首页",personas:"人格"},qV={home:"home",chatRoute:"chat",routes:{...wc},navItems:()=>[{route:"chat",label:wc.chat},{route:"home",label:wc.home},{route:"personas",label:wc.personas}],page:t=>t.route==="home"?_.jsxs("main",{className:"content",style:{padding:24},children:[_.jsx("h2",{children:"样板首页"}),_.jsx("p",{children:"这是第二产品样板:只有两个业务路由,没有业务页面。"})]}):t.route==="personas"?_.jsx(LV,{}):null};function HV(){return _.jsx(BV,{def:qV,texts:()=>({title:"样板助手",assistantLabel:"助手"})})}o2(a2());yM.createRoot(document.getElementById("root")).render(_.jsx(HV,{}));export{xl as a,VV as c,$V as g};